Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

navi

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

navi - npm Package Compare versions

Comparing version 0.12.9 to 0.13.0-alpha.0

11

dist/commonjs/BrowserNavigation.js

@@ -17,12 +17,7 @@ "use strict";

function createBrowserNavigation(options) {
if (options.pages) {
if (process.env.NODE_ENV !== 'production') {
console.warn("Deprecation Warning: passing a \"pages\" option to \"createBrowserNavigation()\" will " +
"no longer be supported from Navi 0.13. Use the \"routes\" option instead.");
}
options.routes = options.pages;
}
// If there's a server state on the window object, use it and then remove
// it so that it won't be picked up by any nested navigation objects.
if (!options.state && typeof window !== undefined && window['__NAVI_STATE__']) {
if (!options.state &&
typeof window !== undefined &&
window['__NAVI_STATE__']) {
options.state = window['__NAVI_STATE__'];

@@ -29,0 +24,0 @@ delete window['__NAVI_STATE__'];

@@ -57,3 +57,2 @@ "use strict";

var Mapping_1 = require("./Mapping");
var NaviRequest_1 = require("./NaviRequest");
var ChunksMapObservable = /** @class */ (function () {

@@ -104,4 +103,6 @@ function ChunksMapObservable(url, rootContext, matcherGeneratorClass, rootMapping, router, options) {

return chunk.type === 'error' ||
(chunk.url.href.length >= item.url.href.length) && ((chunk.type === 'mount' && item.lastMountPatterns !== chunk.patterns) ||
(chunk.type === 'redirect' && item.lastRedirectTo !== chunk.to));
(chunk.url.href.length >= item.url.href.length &&
((chunk.type === 'mount' &&
item.lastMountPatterns !== chunk.patterns) ||
(chunk.type === 'redirect' && item.lastRedirectTo !== chunk.to)));
});

@@ -121,3 +122,4 @@ _a.label = 1;

if (focusChunk.type === 'error' ||
(this_1.options.predicate && !this_1.options.predicate(focusChunk, chunks))) {
(this_1.options.predicate &&
!this_1.options.predicate(focusChunk, chunks))) {
this_1.removeFromQueue(item);

@@ -135,3 +137,6 @@ return [2 /*return*/, "continue-items"];

item.lastMountPatterns = patterns;
key = patterns.slice(0).sort().join("\n");
key = patterns
.slice(0)
.sort()
.join('\n');
if (!(patterns && !item.walkedPatternLists.has(key))) return [3 /*break*/, 5];

@@ -187,7 +192,9 @@ item.walkedPatternLists.add(key);

lastChunk.type !== 'error' &&
(lastChunk.type === 'busy' || !this.options.predicate || this.options.predicate(lastChunk, item.chunksCache))) {
(lastChunk.type === 'busy' ||
!this.options.predicate ||
this.options.predicate(lastChunk, item.chunksCache))) {
chunksMapArray.push([
URLTools_1.joinPaths(item.pathname, '/'),
item.chunksCache,
item.order
item.order,
]);

@@ -198,5 +205,3 @@ }

handleUpdate = function () { return _this.handleResolverUpdate(listenId); };
Promise.race(allChunks
.filter(isBusy)
.map(pickChunkPromise)).then(handleUpdate, handleUpdate);
Promise.race(allChunks.filter(isBusy).map(pickChunkPromise)).then(handleUpdate, handleUpdate);
chunksMapArray.sort(function (itemX, itemY) {

@@ -268,3 +273,3 @@ var x = itemX[2];

}
this.addToQueue(pathname, 0, new Set);
this.addToQueue(pathname, 0, new Set());
}

@@ -318,3 +323,3 @@ ChunksMapObservable.prototype.subscribe = function (onNextOrObserver, onError, onComplete) {

});
var request = NaviRequest_1.createRequest({
var request = {
body: null,

@@ -330,3 +335,2 @@ context: this.rootContext,

hash: url.hash,
router: this.router,
path: url.pathname,

@@ -336,3 +340,3 @@ url: url.pathname + url.search,

state: {},
}, this.router);
};
var matchRequest = Mapping_1.matchAgainstPathname(request, this.rootMapping);

@@ -339,0 +343,0 @@ if (matchRequest) {

@@ -9,3 +9,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./matchers/compat"));
__export(require("./matchers/map"));

@@ -25,3 +24,2 @@ __export(require("./matchers/mount"));

__export(require("./Errors"));
__export(require("./NaviRequest"));
__export(require("./Chunks"));

@@ -28,0 +26,0 @@ __export(require("./URLTools"));

@@ -15,3 +15,2 @@ "use strict";

var URLTools_1 = require("./URLTools");
var NaviRequest_1 = require("./NaviRequest");
exports.KEY_WILDCARD = '\0';

@@ -21,3 +20,3 @@ exports.MEMO_KEY_PREFIX = '\0';

if (rootPath === void 0) { rootPath = ''; }
return (rootPath !== ''
return rootPath !== ''
? createMapping(rootPath, matcher)

@@ -29,3 +28,3 @@ : {

matcher: matcher,
});
};
}

@@ -103,4 +102,4 @@ exports.createRootMapping = createRootMapping;

var mountpath = URLTools_1.joinPaths(request.mountpath, matchedPathname) || '/';
return NaviRequest_1.createRequest(__assign({}, request, { params: params,
mountpath: mountpath, path: unmatchedPath, url: unmatchedPath + request.search }), request['_router']);
return __assign({}, request, { params: params,
mountpath: mountpath, path: unmatchedPath, url: unmatchedPath + request.search });
}

@@ -111,4 +110,4 @@ exports.matchAgainstPathname = matchAgainstPathname;

function escapeRegExp(value) {
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}
//# sourceMappingURL=Mapping.js.map

@@ -17,9 +17,2 @@ "use strict";

function createMemoryNavigation(options) {
if (options.pages) {
if (process.env.NODE_ENV !== 'production') {
console.warn("Deprecation Warning: passing a \"pages\" option to \"createMemoryNavigation()\" will " +
"no longer be supported from Navi 0.13. Use the \"routes\" option instead.");
}
options.routes = options.pages;
}
var url = options.url || (options.request && options.request.url);

@@ -26,0 +19,0 @@ if (!url) {

@@ -118,3 +118,4 @@ "use strict";

});
this.trailingSlash = options.trailingSlash === undefined ? 'remove' : options.trailingSlash;
this.trailingSlash =
options.trailingSlash === undefined ? 'remove' : options.trailingSlash;
this.unlisten = this._history.listen(function (location) {

@@ -124,22 +125,2 @@ return _this.handleLocationChange(location, false);

}
Object.defineProperty(Navigation.prototype, "history", {
get: function () {
if (process.env.NODE_ENV !== 'production') {
console.warn("Deprecation Warning: \"navigation.history\" will be removed in Navi 0.13. Please use \"navigation.navigate()\", \"navigation.goBack()\" or \"navigation.goForward()\" instead.");
}
return this._history;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Navigation.prototype, "router", {
get: function () {
if (process.env.NODE_ENV !== 'production') {
console.warn("Deprecation Warning: \"navigation.router\" will be removed in Navi 0.13. Please import and use the \"resolve()\" or \"crawl()\" functions instead.");
}
return this._router;
},
enumerable: true,
configurable: true
});
Navigation.prototype.dispose = function () {

@@ -146,0 +127,0 @@ this.observers.length = 0;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function createRequest(request, router) {
Object.defineProperties(request, {
mountname: {
get: function () {
if (process.env.NODE_ENV !== 'production') {
console.warn("Deprecation Warning: \"request.mountname\" will be removed in Navi 0.13. Please use \"request.mountpath\" instead.");
}
return request.mountpath;
},
},
pathname: {
get: function () {
if (process.env.NODE_ENV !== 'production') {
console.warn("Deprecation Warning: \"request.pathname\" will be removed in Navi 0.13. Please use \"request.mountpath\" instead.");
}
return request.mountpath;
}
},
});
if (router) {
Object.defineProperties(request, {
router: {
get: function () {
if (process.env.NODE_ENV !== 'production') {
console.warn("Deprecation Warning: \"request.router\" will be removed in Navi 0.13. Please import and use the \"resolve()\" or \"crawl()\" functions instead.");
}
return router;
},
enumerable: false,
},
_router: {
value: router,
},
});
}
return request;
}
exports.createRequest = createRequest;
//# sourceMappingURL=NaviRequest.js.map

@@ -9,3 +9,2 @@ "use strict";

var URLTools_1 = require("./URLTools");
var NaviRequest_1 = require("./NaviRequest");
var Errors_1 = require("./Errors");

@@ -32,3 +31,3 @@ function createRouter(options) {

Router.prototype.createObservable = function (url, options) {
var request = NaviRequest_1.createRequest({
var request = {
body: options.body,

@@ -44,3 +43,2 @@ context: this.context,

search: url.search,
router: this,
url: url.pathname + url.search,

@@ -51,3 +49,3 @@ originalUrl: url.href,

state: options.state || {},
}, this);
};
var matchRequest = Mapping_1.matchAgainstPathname(request, this.rootMapping);

@@ -85,3 +83,5 @@ if (matchRequest) {

}
var promises = urlDescriptors.map(function (url) { return _this.getPageRoutePromise(url, options); });
var promises = urlDescriptors.map(function (url) {
return _this.getPageRoutePromise(url, options);
});
return !Array.isArray(urls) ? promises[0] : Promise.all(promises);

@@ -104,6 +104,5 @@ };

else {
routeMap[url] =
[{ type: 'url', url: URLTools_1.createURLDescriptor(url) }]
.concat(chunks)
.reduce(Route_1.routeReducer, undefined);
routeMap[url] = [{ type: 'url', url: URLTools_1.createURLDescriptor(url) }]
.concat(chunks)
.reduce(Route_1.routeReducer, undefined);
}

@@ -140,5 +139,5 @@ }

}
return ([{ type: 'url', url: URLTools_1.createURLDescriptor(url) }]
return [{ type: 'url', url: URLTools_1.createURLDescriptor(url) }]
.concat(chunks)
.reduce(Route_1.routeReducer, undefined));
.reduce(Route_1.routeReducer, undefined);
});

@@ -145,0 +144,0 @@ };

@@ -15,12 +15,7 @@ var __assign = (this && this.__assign) || function () {

export function createBrowserNavigation(options) {
if (options.pages) {
if (process.env.NODE_ENV !== 'production') {
console.warn("Deprecation Warning: passing a \"pages\" option to \"createBrowserNavigation()\" will " +
"no longer be supported from Navi 0.13. Use the \"routes\" option instead.");
}
options.routes = options.pages;
}
// If there's a server state on the window object, use it and then remove
// it so that it won't be picked up by any nested navigation objects.
if (!options.state && typeof window !== undefined && window['__NAVI_STATE__']) {
if (!options.state &&
typeof window !== undefined &&
window['__NAVI_STATE__']) {
options.state = window['__NAVI_STATE__'];

@@ -27,0 +22,0 @@ delete window['__NAVI_STATE__'];

@@ -52,6 +52,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

};
import { createURLDescriptor, joinPaths, modifyTrailingSlash } from './URLTools';
import { createURLDescriptor, joinPaths, modifyTrailingSlash, } from './URLTools';
import { SimpleSubscription, createOrPassthroughObserver, } from './Observable';
import { matchAgainstPathname } from './Mapping';
import { createRequest } from './NaviRequest';
var ChunksMapObservable = /** @class */ (function () {

@@ -102,4 +101,6 @@ function ChunksMapObservable(url, rootContext, matcherGeneratorClass, rootMapping, router, options) {

return chunk.type === 'error' ||
(chunk.url.href.length >= item.url.href.length) && ((chunk.type === 'mount' && item.lastMountPatterns !== chunk.patterns) ||
(chunk.type === 'redirect' && item.lastRedirectTo !== chunk.to));
(chunk.url.href.length >= item.url.href.length &&
((chunk.type === 'mount' &&
item.lastMountPatterns !== chunk.patterns) ||
(chunk.type === 'redirect' && item.lastRedirectTo !== chunk.to)));
});

@@ -119,3 +120,4 @@ _a.label = 1;

if (focusChunk.type === 'error' ||
(this_1.options.predicate && !this_1.options.predicate(focusChunk, chunks))) {
(this_1.options.predicate &&
!this_1.options.predicate(focusChunk, chunks))) {
this_1.removeFromQueue(item);

@@ -133,3 +135,6 @@ return [2 /*return*/, "continue-items"];

item.lastMountPatterns = patterns;
key = patterns.slice(0).sort().join("\n");
key = patterns
.slice(0)
.sort()
.join('\n');
if (!(patterns && !item.walkedPatternLists.has(key))) return [3 /*break*/, 5];

@@ -185,7 +190,9 @@ item.walkedPatternLists.add(key);

lastChunk.type !== 'error' &&
(lastChunk.type === 'busy' || !this.options.predicate || this.options.predicate(lastChunk, item.chunksCache))) {
(lastChunk.type === 'busy' ||
!this.options.predicate ||
this.options.predicate(lastChunk, item.chunksCache))) {
chunksMapArray.push([
joinPaths(item.pathname, '/'),
item.chunksCache,
item.order
item.order,
]);

@@ -196,5 +203,3 @@ }

handleUpdate = function () { return _this.handleResolverUpdate(listenId); };
Promise.race(allChunks
.filter(isBusy)
.map(pickChunkPromise)).then(handleUpdate, handleUpdate);
Promise.race(allChunks.filter(isBusy).map(pickChunkPromise)).then(handleUpdate, handleUpdate);
chunksMapArray.sort(function (itemX, itemY) {

@@ -266,3 +271,3 @@ var x = itemX[2];

}
this.addToQueue(pathname, 0, new Set);
this.addToQueue(pathname, 0, new Set());
}

@@ -316,3 +321,3 @@ ChunksMapObservable.prototype.subscribe = function (onNextOrObserver, onError, onComplete) {

});
var request = createRequest({
var request = {
body: null,

@@ -328,3 +333,2 @@ context: this.rootContext,

hash: url.hash,
router: this.router,
path: url.pathname,

@@ -334,3 +338,3 @@ url: url.pathname + url.search,

state: {},
}, this.router);
};
var matchRequest = matchAgainstPathname(request, this.rootMapping);

@@ -337,0 +341,0 @@ if (matchRequest) {

//
// Exports
//
export * from './matchers/compat';
export * from './matchers/map';

@@ -19,3 +18,2 @@ export * from './matchers/mount';

export * from './Errors';
export * from './NaviRequest';
export * from './Chunks';

@@ -28,3 +26,3 @@ export * from './URLTools';

export { routeReducer } from './Route';
export { concatMatcherIterators } from './Matcher';
export { concatMatcherIterators, } from './Matcher';
export { Navigation } from './Navigation';

@@ -31,0 +29,0 @@ export { default as resolveChunks } from './Resolvable';

@@ -13,3 +13,2 @@ var __assign = (this && this.__assign) || function () {

import { joinPaths } from './URLTools';
import { createRequest } from './NaviRequest';
export var KEY_WILDCARD = '\0';

@@ -19,3 +18,3 @@ export var MEMO_KEY_PREFIX = '\0';

if (rootPath === void 0) { rootPath = ''; }
return (rootPath !== ''
return rootPath !== ''
? createMapping(rootPath, matcher)

@@ -27,3 +26,3 @@ : {

matcher: matcher,
});
};
}

@@ -99,4 +98,4 @@ export function createMapping(pattern, matcher) {

var mountpath = joinPaths(request.mountpath, matchedPathname) || '/';
return createRequest(__assign({}, request, { params: params,
mountpath: mountpath, path: unmatchedPath, url: unmatchedPath + request.search }), request['_router']);
return __assign({}, request, { params: params,
mountpath: mountpath, path: unmatchedPath, url: unmatchedPath + request.search });
}

@@ -106,4 +105,4 @@ // From http://stackoverflow.com/a/5306111/106302

function escapeRegExp(value) {
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}
//# sourceMappingURL=Mapping.js.map

@@ -15,9 +15,2 @@ var __assign = (this && this.__assign) || function () {

export function createMemoryNavigation(options) {
if (options.pages) {
if (process.env.NODE_ENV !== 'production') {
console.warn("Deprecation Warning: passing a \"pages\" option to \"createMemoryNavigation()\" will " +
"no longer be supported from Navi 0.13. Use the \"routes\" option instead.");
}
options.routes = options.pages;
}
var url = options.url || (options.request && options.request.url);

@@ -24,0 +17,0 @@ if (!url) {

@@ -59,3 +59,3 @@ var __assign = (this && this.__assign) || function () {

import { resolve } from './resolve';
import { createURLDescriptor, modifyTrailingSlash } from './URLTools';
import { createURLDescriptor, modifyTrailingSlash, } from './URLTools';
import { SimpleSubscription, createOrPassthroughObserver, } from './Observable';

@@ -117,3 +117,4 @@ import { OutOfRootError } from './Errors';

});
this.trailingSlash = options.trailingSlash === undefined ? 'remove' : options.trailingSlash;
this.trailingSlash =
options.trailingSlash === undefined ? 'remove' : options.trailingSlash;
this.unlisten = this._history.listen(function (location) {

@@ -123,22 +124,2 @@ return _this.handleLocationChange(location, false);

}
Object.defineProperty(Navigation.prototype, "history", {
get: function () {
if (process.env.NODE_ENV !== 'production') {
console.warn("Deprecation Warning: \"navigation.history\" will be removed in Navi 0.13. Please use \"navigation.navigate()\", \"navigation.goBack()\" or \"navigation.goForward()\" instead.");
}
return this._history;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Navigation.prototype, "router", {
get: function () {
if (process.env.NODE_ENV !== 'production') {
console.warn("Deprecation Warning: \"navigation.router\" will be removed in Navi 0.13. Please import and use the \"resolve()\" or \"crawl()\" functions instead.");
}
return this._router;
},
enumerable: true,
configurable: true
});
Navigation.prototype.dispose = function () {

@@ -145,0 +126,0 @@ this.observers.length = 0;

@@ -1,38 +0,1 @@

export function createRequest(request, router) {
Object.defineProperties(request, {
mountname: {
get: function () {
if (process.env.NODE_ENV !== 'production') {
console.warn("Deprecation Warning: \"request.mountname\" will be removed in Navi 0.13. Please use \"request.mountpath\" instead.");
}
return request.mountpath;
},
},
pathname: {
get: function () {
if (process.env.NODE_ENV !== 'production') {
console.warn("Deprecation Warning: \"request.pathname\" will be removed in Navi 0.13. Please use \"request.mountpath\" instead.");
}
return request.mountpath;
}
},
});
if (router) {
Object.defineProperties(request, {
router: {
get: function () {
if (process.env.NODE_ENV !== 'production') {
console.warn("Deprecation Warning: \"request.router\" will be removed in Navi 0.13. Please import and use the \"resolve()\" or \"crawl()\" functions instead.");
}
return router;
},
enumerable: false,
},
_router: {
value: router,
},
});
}
return request;
}
//# sourceMappingURL=NaviRequest.js.map

@@ -7,3 +7,2 @@ import { createRootMapping, matchAgainstPathname } from './Mapping';

import { createURLDescriptor } from './URLTools';
import { createRequest } from './NaviRequest';
import { OutOfRootError } from './Errors';

@@ -29,3 +28,3 @@ export function createRouter(options) {

Router.prototype.createObservable = function (url, options) {
var request = createRequest({
var request = {
body: options.body,

@@ -41,3 +40,2 @@ context: this.context,

search: url.search,
router: this,
url: url.pathname + url.search,

@@ -48,3 +46,3 @@ originalUrl: url.href,

state: options.state || {},
}, this);
};
var matchRequest = matchAgainstPathname(request, this.rootMapping);

@@ -82,3 +80,5 @@ if (matchRequest) {

}
var promises = urlDescriptors.map(function (url) { return _this.getPageRoutePromise(url, options); });
var promises = urlDescriptors.map(function (url) {
return _this.getPageRoutePromise(url, options);
});
return !Array.isArray(urls) ? promises[0] : Promise.all(promises);

@@ -101,6 +101,5 @@ };

else {
routeMap[url] =
[{ type: 'url', url: createURLDescriptor(url) }]
.concat(chunks)
.reduce(routeReducer, undefined);
routeMap[url] = [{ type: 'url', url: createURLDescriptor(url) }]
.concat(chunks)
.reduce(routeReducer, undefined);
}

@@ -137,5 +136,5 @@ }

}
return ([{ type: 'url', url: createURLDescriptor(url) }]
return [{ type: 'url', url: createURLDescriptor(url) }]
.concat(chunks)
.reduce(routeReducer, undefined));
.reduce(routeReducer, undefined);
});

@@ -142,0 +141,0 @@ };

@@ -9,3 +9,2 @@ import { History } from 'history';

routes?: Matcher<Context>;
pages?: Matcher<Context>;
/**

@@ -12,0 +11,0 @@ * If provided, this part of any URLs will be ignored. This is useful

@@ -1,2 +0,1 @@

export * from './matchers/compat';
export * from './matchers/map';

@@ -26,3 +25,3 @@ export * from './matchers/mount';

export { SiteMap, RouteMap } from './Maps';
export { Matcher, MatcherGenerator, MatcherIterator, concatMatcherIterators } from './Matcher';
export { Matcher, MatcherGenerator, MatcherIterator, concatMatcherIterators, } from './Matcher';
export { Navigation } from './Navigation';

@@ -29,0 +28,0 @@ export { Resolvable, default as resolveChunks } from './Resolvable';

@@ -9,3 +9,2 @@ import { Matcher } from './Matcher';

routes?: Matcher<Context>;
pages?: Matcher<Context>;
/**

@@ -12,0 +11,0 @@ * The initial URL to match.

import { History } from 'history';
import { Router } from './Router';
import { Route } from './Route';

@@ -52,3 +51,3 @@ import { URLDescriptor } from './URLTools';

private _router;
private _history;
_history: History;
private lastHandledLocation?;

@@ -67,4 +66,2 @@ private navigationsSinceSteady;

constructor(options: NavigationOptions<Context>);
readonly history: History<any>;
readonly router: Router<Context>;
dispose(): void;

@@ -71,0 +68,0 @@ go(n: number): Promise<Route<any>>;

@@ -1,2 +0,1 @@

import { Router } from './Router';
import { Crawler } from './Crawler';

@@ -65,6 +64,2 @@ export interface NaviRequest<Context extends object = any> {

readonly context: Context;
readonly mountname?: string;
readonly pathname?: string;
readonly router: Router<any>;
}
export declare function createRequest<Context extends object = any>(request: NaviRequest<Context>, router?: Router): NaviRequest<Context>;

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("history")):"function"==typeof define&&define.amd?define(["exports","history"],e):e((t=t||self).Navi={},t.History)}(this,function(t,e){"use strict";var r=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},n=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(r(arguments[e]));return t};function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(0===t.length)throw new Error("composeMatchers() expects at least one matcher.");return 1===t.length?t[0]:t.reduce(function(t,e){return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return t(e.apply(void 0,n(r)))}})}var a=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},i=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(a(arguments[e]));return t},u=/((((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;function s(t,e){var r,n,o,a,i,s=void 0===e?{}:e,h=s.removeHash,f=void 0!==h&&h,y=s.trailingSlash,d=void 0===y?null:y;if("string"==typeof t){var b=u.exec(t);if(!b)throw new Error("Couldn't parse the provided URL.");r="",n=p(b[2]||"",d),o=c(a=b[6]||""),i=b[7]||""}else r=t.hostname||"",n=p(t.pathname||"",d),o=t.query||(t.search?c(t.search):{}),a=t.search||l(o),i=t.hash||"";return{hostname:r,pathname:n,query:o,search:a,hash:f?"":i,href:n+a+i}}function c(t,e){if(void 0===e&&(e="?"),!t||t[0]!=e)return{};for(var r={},n=t.slice(1).split("&"),o=0,a=n.length;o<a;o++){var i=n[o].split("=");r[i[0]]=i[1]?decodeURIComponent(i[1]):""}return r}function l(t,e){void 0===e&&(e="?");var r=Object.keys(t);if(0===r.length)return"";for(var n=[],o=0,a=r.length;o<a;o++){var i=r[o],u=String(t[i]);n.push(""===u?i:i+"="+encodeURIComponent(u))}return e+n.join("&")}function h(t){return""===t?[]:t.split("/")}function f(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var n=h(t),o=0;o<e.length;o++)n.push.apply(n,i(h(e[o])));var a=[],u=n.length-1;for(o=0;o<=u;o++){var s=n[o];".."===s?a.pop():"."===s||""===s&&0!==o&&o!==u||a.push(s)}return a.join("/")}function p(t,e){var r="/"===t.slice(-1);return"add"!==e||r?"remove"===e&&r&&t.length>1?t.slice(0,-1):t:t+"/"}var y,d=(y=function(t,e){return(y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}y(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),b=function(t){function e(e){var r=this,n=this.constructor.prototype;return(r=t.call(this,e)||this).__proto__=n,Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(r,r.constructor):Object.defineProperty(r,"stack",{value:(new Error).stack}),Object.defineProperty(r,"message",{value:e}),r}return d(e,t),e}(Error),v=function(t){function e(e){var r=t.call(this,"URL not found: "+e)||this;return r.pathname=e,r.status=404,r.name="NotFoundError",r}return d(e,t),e}(b),m=function(t){function e(e){var r=t.call(this,"URL not managed by router: "+e.href)||this;return r.url=e,r.name="OutOfRootError",r}return d(e,t),e}(b);function w(t,e,r){return Object.assign({type:t,request:e,url:s({pathname:e.mountpath,query:e.query})},r)}function g(t){var e=f(t.mountpath,t.path);return{type:"error",request:t,url:s({pathname:e,query:t.query}),error:new v(e)}}var x=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},S=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function O(t,e,r){var n,o,a,i,u,s,c;return x(this,function(l){switch(l.label){case 0:n="function"==typeof t?t:function(){return t};try{o=n(e,e.context)}catch(t){o=Promise.reject(t)}return k(o)?[3,1]:(a=r(o),[3,7]);case 1:i=o.then(P),u=function(t){var e={};return t.then(function(t){e.value=t,e.outcome="resolved"},function(t){e.error=t,e.outcome="rejected"}),e}(i),s=[w("busy",e,{promise:i})],l.label=2;case 2:return u.outcome?[3,4]:[4,s];case 3:return l.sent(),[3,2];case 4:return"rejected"!==u.outcome?[3,6]:((c=u.error)instanceof v&&!c.pathname&&(c.pathname=f(e.mountpath,e.path)),[4,[w("error",e,{error:c})]]);case 5:return l.sent(),[3,7];case 6:a=r(u.value),l.label=7;case 7:return a?Array.isArray(a)?[4,a.length?a:[]]:[3,9]:[3,11];case 8:return l.sent(),[3,11];case 9:return[5,S(a)];case 10:l.sent(),l.label=11;case 11:return[2]}})}function k(t){return!!t&&!!t.then}function P(t){return function(t){return t&&"object"==typeof t&&"default"in t}(t)?t.default:t}var j=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};function _(t,e,r){return void 0===r&&(r=""),t(e)}function R(t,e){var r,n,o,a;return j(this,function(i){switch(i.label){case 0:o=[],a=[],i.label=1;case 1:return(r=t.next()).done||(o=r.value||[]),(n=e.next()).done||(a=n.value||[]),[4,o.concat(a)];case 2:i.sent(),i.label=3;case 3:if(!r.done||!n.done)return[3,1];i.label=4;case 4:return[2]}})}var E=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},T=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function C(t,e,r,n,o,a){function i(e,i){var u,s;return E(this,function(c){switch(c.label){case 0:return u=e.path,(void 0===n?!i:n)&&u&&"/"!==u?[4,[g(e)]]:[3,2];case 1:return c.sent(),[3,4];case 2:return s=e.crawler&&!o||a&&!a(e)?function(){return E(this,function(t){switch(t.label){case 0:return[4,[]];case 1:return t.sent(),[2]}})}():O(t,e,function(t){return r(t,e)}),[5,T(i?R(s,_(i,e)):s)];case 3:c.sent(),c.label=4;case 4:return[2]}})}return function(t){return function(r){return i(r,e?e(t):t)}}}function L(t,e,r){return C(t,e,function(t,e){return t?[w("view",e,{view:t})]:[]},r,!1,function(t){return"HEAD"!==t.method})}var I=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},D=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function M(t){return function(e){return function(r){return I(this,function(n){switch(n.label){case 0:return[5,D(O(t,r,function(t){return _(t(e),r)}))];case 1:return n.sent(),[2]}})}}}function U(t,e){return Object.defineProperties(t,{mountname:{get:function(){return t.mountpath}},pathname:{get:function(){return t.mountpath}}}),e&&Object.defineProperties(t,{router:{get:function(){return e},enumerable:!1},_router:{value:e}}),t}var q=function(){return(q=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},A="\0";function G(t,e){var r=t;if(r.length>1&&"/"===r.substr(-1)&&(r=r.substr(0,r.length-1)),"/"!==r[0]&&(r="/"+r),/\/{2,}/.test(r)&&(r=r.replace(/\/{2,}/g,"/")),/^([A-Za-z0-9\$\-_\.+!*'\(\),\/]|\/:)+$/.test(r),0===r.length)throw new Error('You cannot use an empty string "" as a pattern!');for(var n=r.split("/").slice(1),o=[],a=[],i=["^"],u=0;u<n.length;u++){var s=n[u];s.length>1&&":"===s[0]?(o.push(s.slice(1)),a.push(A),i.push("([^/]+)")):(a.push(s),i.push(s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")))}return{key:a.join("/"),matcher:e,pattern:r,pathParamNames:o.length?o:void 0,regExp:"/"===r?/^\/$/:new RegExp(i.join("/"))}}function N(t,e){var r=e.regExp.exec(t.path||"/");if(r){var n=r[0],o=t.params;if(e.pathParamNames){o=q({},t.params);for(var a=0;a<e.pathParamNames.length;a++){o[e.pathParamNames[a]]=r[a+1]}}var i=t.path.slice(n.length)||"",u=f(t.mountpath,n)||"/";return U(q({},t,{params:o,mountpath:u,path:i,url:i+t.search}),t._router)}}function H(t){return[].concat.apply([],t)}var F=function(){return(F=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},Q=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},V=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Y=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i};function $(t){if(!t)throw new Error("mount() must be supplied with a paths object.");var e=Object.keys(t),r=e.filter(function(t){return"*"!==t}).map(function(e){return G(e,t[e])}).sort(function(t,e){return r=t.key,n=e.key,r<n?-1:r>n?1:0;var r,n});return function(n){return function(o){var a,i,u,s,c,l,h,f,p,y,d,b,v,m,x,S,O;return V(this,function(k){switch(k.label){case 0:if(u=[],s=[],c=[],l=o.crawler,!(h=l&&(""===o.path||"/"===o.path)))return[3,5];(f=function(t,e,r){return Q(this,void 0,void 0,function(){var n;return V(this,function(o){switch(o.label){case 0:return n=H,[4,Promise.all(Object.entries(t).map(function(t){var n,o=Y(t,2),a=o[0],i=o[1];return e("*"===a?"":a,r).then((n=i,function(t){return t.map(function(t){return[n,t]})}))}))];case 1:return[2,n.apply(void 0,[o.sent()])]}})})}(t,l,o)).then(function(t){p=t},function(t){return y=t}),k.label=1;case 1:return[4,[w("busy",o,{promise:f})]];case 2:if(k.sent(),y)throw y;k.label=3;case 3:if(!p)return[3,1];k.label=4;case 4:return i=p.map(function(t,e){var r=Y(t,2),a=r[0],i=r[1],u=F({},o,{mountpath:i.url.pathname,url:"",path:""});return c[e]=u,_(a(n),u,u.mountpath)}),[3,6];case 5:for(S=r.length-1;S>=0;S--)if(d=r[S],b=N(o,d)){i=[_(d.matcher(n),b,d.pattern)];break}i||(v=t["*"])&&(i=[_(v(n),o,"*")]),k.label=6;case 6:if(i)for(S=0;S<i.length;S++)(m=u[S])&&m.done||(m=u[S]=i[S].next()),m&&!m.done&&(s[S]=m.value);for(a=[w("mount",o,{patterns:e})],x=!1,S=0;S<u.length;S++)(O=s[S])&&(x=!0,h&&!O.some(z)&&(a=a.concat(w("crawl",c[S]))),a=a.concat(O));return l||x||a.push(g(o)),[4,a];case 7:k.sent(),k.label=8;case 8:if(a.filter(B).length)return[3,6];k.label=9;case 9:return[2]}})}}}function B(t){return"busy"===t.type}function z(t){return"mount"===t.type}function W(t,e){var r=(void 0===e?{}:e).exact;return C(t,void 0,function(t,e){var r;return"string"==typeof t?r="/"===t[0]?t:f("/",e.mountpath,t):t&&(r=s(t).href),r?[w("redirect",e,{to:r})]:[]},void 0===r||r,!0)}var Z=function(){return(Z=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},J=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},K=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function X(t,e){return function(r){return function(n){return function(e,r){return J(this,function(n){switch(n.label){case 0:return[5,K(O(t,e,function(t){return _(r,Z({},e,{context:t||{}}))}))];case 1:return n.sent(),[2]}})}(n,e?e(r):r)}}}function tt(t,e){return C(t,e,function(t,e){return t?[w("data",e,{data:t})]:[]})}function et(t,e){return C(t,e,function(t,e){return t?[w("title",e,{title:t})]:[]})}var rt=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},nt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},ot=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&(r[n[o]]=t[n[o]])}return r},at=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function it(t){return function(e,r){return rt(this,void 0,void 0,function(){var n,o,a,i;return nt(this,function(u){switch(u.label){case 0:return n=t.getMeta?Promise.resolve(t.getMeta(e,r,void 0)).then(P).then(ut):Promise.resolve(t.meta||{}),o=t.getTitle?Promise.resolve(t.getTitle(e,r,n)).then(P):Promise.resolve(t.title),"HEAD"!==e.method&&(a=t.getContent?Promise.resolve(t.getContent(e,r,n)).then(P):Promise.resolve(t.content)),i={},[4,n];case 1:return i.meta=u.sent(),[4,a];case 2:return i.content=u.sent(),[4,o];case 3:return[2,(i.title=u.sent(),i)]}})})}}function ut(t){return t||{}}function st(t,e){return C(t,e,function(t,e){return t?[w("head",e,{head:t})]:[]})}function ct(t,e){return C(t,e,function(t,e){return t?[w("headers",e,{headers:t})]:[]})}var lt=function(){return(lt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},ht=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},ft=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function pt(t,e){function r(e,r){return ht(this,function(n){switch(n.label){case 0:return[5,ft(O(t,e,function(t){var n=null===t?e.state:lt({},e.state,t);return R(function(t){return ht(this,function(e){switch(e.label){case 0:return[4,t];case 1:return e.sent(),[2]}})}(null===t?[]:[w("state",e,{state:n})]),_(r,lt({},e,{state:n})))}))];case 1:return n.sent(),[2]}})}return function(t){return function(n){return r(n,e?e(t):t)}}}function yt(t,e){return C(t,e,function(t,e){return t?[w("status",e,{status:t})]:[]})}var dt=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},bt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},vt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&(r[n[o]]=t[n[o]])}return r},mt=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i};function wt(t){return t||{}}function gt(t,e,r,n){if(e){var o=e(r,n);return k(o)?[o.then(P),!0]:[o,!1]}return[t,!1]}var xt=function(){return(xt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},St=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},Ot=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},kt=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};var Pt=function(){function t(t,e){this.close=t,this.observer=e,this.observer.start&&this.observer.start(this)}return t.prototype.unsubscribe=function(){this.closed||(this.closed=!0,this.close(this.observer),delete this.close,delete this.observer)},t}();function jt(t,e,r){return"function"==typeof t?{next:t,error:e,complete:r}:t}function _t(t){return new Promise(function(e,r){t.subscribe({start:function(t){this.subscription=t},next:function(t){this.value=t},complete:function(){e(this.value),this.subscription.unsubscribe()},error:function(t){r(t),this.subscription.unsubscribe()}})})}var Rt=function(){function t(t,e,r){var n=this;this.handleUnsubscribe=function(t){var e=n.observers.indexOf(t);-1!==e&&n.observers.splice(e,1)},this.handleChange=function(t){if(t===n.lastListenId){n.lastListenId++,n.refresh();for(var e=n.result.done||n.result.value.every(function(t){return"busy"!==t.type}),r=0;r<n.observers.length;r++){var o=n.observers[r];o.next(n.result.value),e&&o.complete&&o.complete()}e&&delete n.matcherIterator}},this.refresh=function(){var t=n.matcherIterator.next();if(t.value&&(n.result=t),!n.result.done){var e=++n.lastListenId,r=function(){return n.handleChange(e)};Promise.race(n.result.value.filter(Et).map(Tt)).then(r,r)}},this.url=t,this.lastListenId=0,this.observers=[],this.matcherIterator=r(e)}return t.prototype.subscribe=function(t,e,r){if(!this.matcherIterator)throw new Error("Can't subscribe to an already-complete RoutingObservable.");var n=jt(t,e,r);this.observers.push(n);var o=new Pt(this.handleUnsubscribe,n);return 1===this.observers.length&&this.handleChange(this.lastListenId),o},t}();function Et(t){return"busy"===t.type}function Tt(t){return t.promise}var Ct=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},Lt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},It=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},Dt=function(){function t(t,e,r,n,o,a){var i=this;this.handleUnsubscribe=function(t){var e=i.observers.indexOf(t);-1!==e&&i.observers.splice(e,1)},this.handleResolverUpdate=function(t){t===i.lastListenId&&(i.lastListenId++,i.isRefreshing?i.isRefreshScheduled||(i.isRefreshScheduled=!0):i.refresh())},this.refresh=function(){return Ct(i,void 0,void 0,function(){var t,e,r,n,o,a,i,u,s,c,l,h,y,d,b,v,m,w,g=this;return Lt(this,function(x){switch(x.label){case 0:this.isRefreshScheduled=!1,this.isRefreshing=!0,t=[],e=0,r=function(){var r,o,a,i,u,s,c,l,h,p,y;return Lt(this,function(d){switch(d.label){case 0:r=n.mapItems[e],o=r.pathname,a=r.matcherIterator.next(),r.lastResult&&!a.value||(r.lastResult=a),i=r.lastResult.value,r.chunksCache=i||[],u=i.findIndex(function(t){return"error"===t.type||t.url.href.length>=r.url.href.length&&("mount"===t.type&&r.lastMountPatterns!==t.patterns||"redirect"===t.type&&r.lastRedirectTo!==t.to)}),d.label=1;case 1:if(!(u>=0&&u<i.length))return[3,6];if(s=i[u],u++,"error"===s.type||n.options.predicate&&!n.options.predicate(s,i))return n.removeFromQueue(r),[2,"continue-items"];if("redirect"===s.type&&(r.lastRedirectTo=s.to,n.options.followRedirects&&n.addToQueue(s.to,r.depth+1,r.walkedPatternLists,o,r.order)),"mount"!==s.type)return[3,5];if(c=s.patterns,r.lastMountPatterns=c,l=c.slice(0).sort().join("\n"),!c||r.walkedPatternLists.has(l))return[3,5];r.walkedPatternLists.add(l),h=0,d.label=2;case 2:return h<c.length?[4,n.expandPatterns(f(o,c[h]))]:[3,5];case 3:for(p=d.sent(),y=0;y<p.length;y++)n.addToQueue(p[y],r.depth+1,r.walkedPatternLists,o,r.order.concat(h,y));d.label=4;case 4:return h++,[3,2];case 5:return[3,1];case 6:return i&&(t=t.concat(i)),e++,[2]}})},n=this,x.label=1;case 1:return this.mapItems&&e<this.mapItems.length?[5,r()]:[3,3];case 2:switch(x.sent()){case"continue-items":return[3,1]}return[3,1];case 3:if(!this.mapItems)return[2];for(o=[],a=0;a<this.mapItems.length;a++)i=this.mapItems[a],"mount"===(u=i.chunksCache[i.chunksCache.length-1]).type||"error"===u.type||"busy"!==u.type&&this.options.predicate&&!this.options.predicate(u,i.chunksCache)||o.push([f(i.pathname,"/"),i.chunksCache,i.order]);if(s=++this.lastListenId,c=function(){return g.handleResolverUpdate(s)},Promise.race(t.filter(Mt).map(Ut)).then(c,c),o.sort(function(t,e){var r=t[2],n=e[2];if(r.length<n.length)return-1;if(r.length>n.length)return 1;for(var o=0;o<r.length;o++){if(r[o]<n[o])return-1;if(r[o]>n[o])return 1}return 0}),this.isRefreshScheduled)this.refresh();else{for(l={},h=!0,y=0;y<o.length;y++)d=It(o[y],2),b=d[0],(v=d[1]).some(function(t){return"busy"===t.type})&&(h=!1),l[p(b,"remove")]=v;for(m=0;m<this.observers.length;m++)(w=this.observers[m]).next(l),h&&w.complete&&w.complete();h&&(delete this.rootContext,delete this.mapItems,delete this.router,delete this.observers),this.isRefreshing=!1}return[2]}})})},this.observers=[],this.lastListenId=0,this.mapItems=[],this.router=o,this.rootContext=e,this.matcherGeneratorFunction=r,this.rootMapping=n,this.options=a,this.seenPathnames=new Set;var u=t.pathname;"/"===u.substr(-1)&&(u=u.substr(0,u.length-1)),this.addToQueue(u,0,new Set)}return t.prototype.subscribe=function(t,e,r){if(!this.observers)throw new Error("Can't subscribe to an already-complete RoutingObservable.");var n=jt(t,e,r);this.observers.push(n);var o=new Pt(this.handleUnsubscribe,n);return 1===this.observers.length&&this.refresh(),o},t.prototype.expandPatterns=function(t){return Ct(this,void 0,void 0,function(){var e;return Lt(this,function(r){switch(r.label){case 0:return this.options.expandPattern?[4,this.options.expandPattern(t,this.router)]:[3,2];case 1:if(e=r.sent())return[2,e];r.label=2;case 2:return[2,[t].filter(function(t){return!/\/:/.test(t)})]}})})},t.prototype.removeFromQueue=function(t){var e=this.mapItems.indexOf(t);-1!==e&&this.mapItems.splice(e,1)},t.prototype.addToQueue=function(t,e,r,n,o){if(void 0===o&&(o=[0]),!this.seenPathnames.has(t)&&(!this.options.maxDepth||e<=this.options.maxDepth)){this.seenPathnames.add(t);var a=s(t,{removeHash:!0}),i=N(U({body:null,context:this.rootContext,headers:this.options.headers||{},method:this.options.method||"HEAD",params:{},hostname:this.options.hostname||"",mountpath:"",query:a.query,search:a.search,hash:a.hash,router:this.router,path:a.pathname,url:a.pathname+a.search,originalUrl:a.href,state:{}},this.router),this.rootMapping);i&&this.mapItems.push({url:a,fromPathname:n,depth:e,pathname:t,order:o,walkedPatternLists:new Set(r),matcherIterator:this.matcherGeneratorFunction(i)})}},t}();function Mt(t){return"busy"===t.type}function Ut(t){return t.promise}var qt=function(){return(qt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function At(t,e){return t=function(t,e){if(t){if("url"===e.type)return qt({},t,{chunks:t.chunks.filter(function(t){return"url"!==t.type}),url:e.url});if("ready"!==t.type)return t}var r={lastChunk:e,method:e.request&&e.request.method,chunks:t?t.chunks.concat(e):[e],data:t?t.data:{},headers:t?t.headers:{},heads:t?t.heads:[],state:t?t.state:{},status:t?t.status:200,title:t&&t.title,url:t?t.url:e.url,views:t?t.views:[]};switch(e.type){case"busy":return qt({},r,{type:"busy"});case"data":return qt({},r,{type:"ready",data:qt({},r.data,e.data)});case"error":return qt({},r,{type:"error",error:e.error,status:r.status&&r.status>=400?r.status:e.error.status||500});case"head":return qt({},r,{type:"ready",heads:r.heads.concat(e.head)});case"headers":return qt({},r,{type:"ready",headers:qt({},r.headers,e.headers)});case"redirect":return qt({},r,{type:"redirect",to:e.to});case"state":return qt({},r,{type:"ready",state:qt({},r.state,e.state)});case"status":return qt({},r,{type:"ready",status:e.status});case"title":return qt({},r,{type:"ready",title:e.title});case"view":return qt({},r,{type:"ready",views:r.views.concat(e.view)});default:return qt({},r,{type:"ready"})}}(t,e),Object.defineProperties(t,{meta:{configurable:!0,get:function(){return t.data}},content:{configurable:!0,get:function(){return e.view}},segments:{configurable:!0,get:function(){return t.chunks}},lastSegment:{configurable:!0,get:function(){return t.lastChunk}}}),t}function Gt(t){return new Nt(t)}var Nt=function(){function t(t){this.context=t.context||{},this.matcherGenerator=t.routes();var e,r,n=t.basename;n&&"/"===n.slice(-1)&&(n=n.slice(0,-1)),this.rootMapping=(e=t.routes,void 0===(r=n)&&(r=""),""!==r?G(r,e):{pattern:r,key:"",regExp:new RegExp(""),matcher:e})}return t.prototype.setContext=function(t){this.context=t||{}},t.prototype.createObservable=function(t,e){var r=N(U({body:e.body,context:this.context,headers:e.headers||{},method:e.method||"GET",hostname:t.hostname,hash:t.hash,mountpath:"/",params:t.query,query:t.query,search:t.search,router:this,url:t.pathname+t.search,originalUrl:t.href,path:t.pathname,crawler:e.crawler,state:e.state||{}},this),this.rootMapping);if(r)return new Rt(t,r,this.matcherGenerator)},t.prototype.createMapObservable=function(t,e){return void 0===e&&(e={}),new Dt(s(t),this.context,this.matcherGenerator,this.rootMapping,this,e)},t.prototype.resolve=function(t,e){var r,n=this;if(void 0===e&&(e={}),Array.isArray(t))r=t.map(function(t){return s(t)});else if("string"==typeof t)r=[s(t)];else if(t.url)r=[s((e=t).url)];else{if(!e)throw new Error("You must specify a URL for router.resolve().");r=[s(t)]}if(!r.length)return Promise.resolve([]);var o=r.map(function(t){return n.getPageRoutePromise(t,e)});return Array.isArray(t)?Promise.all(o):o[0]},t.prototype.resolveSiteMap=function(t,e){return void 0===e&&(e={}),_t(this.createMapObservable(t,e)).then(function(t){for(var e={},r={},n=Object.keys(t),o=0;o<n.length;o++){var a=n[o],i=t[a],u=i[i.length-1];"redirect"!==u.type?e[a]=[{type:"url",url:s(a)}].concat(i).reduce(At,void 0):r[a]=u.to}return{routes:e,redirects:r}})},t.prototype.resolveRouteMap=function(t,e){return void 0===e&&(e={}),this.resolveSiteMap(t,e).then(function(t){return t.routes})},t.prototype.getPageRoutePromise=function(t,e){var r=this,n=this.createObservable(t,e);return n?_t(n).then(function(n){for(var o=0;o<n.length;o++){var a=n[o];if("busy"===a.type)break;if("redirect"===a.type&&e.followRedirects)return r.getPageRoutePromise(s(a.to),e);if("error"===a.type)throw a.error}return[{type:"url",url:s(t)}].concat(n).reduce(At,void 0)}):Promise.reject(new m(t))},t}(),Ht=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},Ft=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};var Qt=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},Vt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Yt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&(r[n[o]]=t[n[o]])}return r};function $t(t){return Qt(this,void 0,void 0,function(){var e,r,n,o,a,i;return Vt(this,function(u){if(e=t.basename,r=t.context,n=t.routes,o=t.url,a=t.urls,i=Yt(t,["basename","context","routes","url","urls"]),o&&a)throw new Error("You cannot pass both `url` and `urls` options to resolve(). Please pick one!");if(!o&&!a)throw new Error("You must pass one of `url` or `urls` options to resolve().");return[2,Gt({basename:e,context:r,routes:n}).resolve(o||a,i)]})})}var Bt=function(){return function(){this.promise=new Promise(function(t,e){this.resolve=t,this.reject=e}.bind(this)),Object.freeze(this)}}(),zt=function(){return(zt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},Wt=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},Zt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Jt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&(r[n[o]]=t[n[o]])}return r},Kt=function(){function t(t){var e=this;this.handleUnsubscribe=function(t){var r=e.observers.indexOf(t);-1!==r&&e.observers.splice(r,1)},this.handleChunkList=function(t){for(var r=!0,n=e._history.location,o=0;o<t.length;o++){var a=t[o];if("busy"===a.type&&(r=!1),"state"===a.type&&(e.ignoreNextLocationChange=!0,e._history.replace(zt({},n,{state:te(n.state,a.state)}))),"redirect"===a.type){var i=re(n.state);return void(i?(e.ignoreNextLocationChange=!0,e._history.replace(zt({},n,{state:i})),e._history.push(a.to)):e._history.replace(a.to))}}e.setRoute([{type:"url",url:s(e.lastHandledLocation)}].concat(t).reduce(At,void 0),r)},this._history=t.history,this.observers=[],this.isLastRouteSteady=!1,this.navigationsSinceSteady=0,this.basename=t.basename,this.matcher=t.routes,this._router=new Nt({context:t.context,routes:t.routes,basename:t.basename}),this.trailingSlash=void 0===t.trailingSlash?"remove":t.trailingSlash,this.unlisten=this._history.listen(function(t){return e.handleLocationChange(t,!1)})}return Object.defineProperty(t.prototype,"history",{get:function(){return this._history},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"router",{get:function(){return this._router},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.observers.length=0,this.unlisten(),delete this.unlisten,delete this._history,this.observableSubscription&&this.observableSubscription.unsubscribe(),delete this.observableSubscription,delete this._router,delete this.waitUntilSteadyDeferred,delete this.lastRoute,delete this._router},t.prototype.go=function(t){return Wt(this,void 0,void 0,function(){var e,r=this;return Zt(this,function(n){switch(n.label){case 0:return e=new Promise(function(t){var e=r._history.listen(function(){e(),t()})}),this._history.go(t),[4,e];case 1:return n.sent(),[2,this.getRoute()]}})})},t.prototype.goBack=function(){return this.go(-1)},t.prototype.goForward=function(){return this.go(1)},t.prototype.navigate=function(t,e){var r;if(void 0===e&&(e={}),"string"==typeof t)r=s(t);else if(t.url)r=s((e=t).url);else{if(!t)throw new Error("You must specify a URL or state to navigation.navigate().");r=s(t)}var n=this._history.location,o=e.replace||!1!==e.replace&&n.pathname===r.pathname&&n.search===r.search&&n.hash===r.hash;return this._history[o?"replace":"push"]({pathname:r.pathname,search:r.search,hash:r.hash,state:ee({revertTo:o?n.state:void 0,method:e.method,headers:e.headers,body:e.body,state:e.state})}),this.getRoute()},t.prototype.prefetch=function(t){return Wt(this,void 0,void 0,function(){return Zt(this,function(e){switch(e.label){case 0:return[4,$t({basename:this.basename,routes:this.matcher,context:this._router.context,url:t})];case 1:return e.sent(),[2]}})})},t.prototype.refresh=function(){return this.handleLocationChange(this._history.location,!0),this.getRoute()},t.prototype.setContext=function(t){return this._router.setContext(t),this.refresh()},t.prototype.getCurrentValue=function(){return this.lastRoute},t.prototype.getRoute=function(){return Wt(this,void 0,void 0,function(){return Zt(this,function(t){return this.isLastRouteSteady?[2,this.lastRoute]:(this.waitUntilSteadyDeferred||(this.waitUntilSteadyDeferred=new Bt),[2,this.waitUntilSteadyDeferred.promise])})})},t.prototype.getSteadyValue=function(){return Wt(this,void 0,void 0,function(){return Zt(this,function(t){return[2,this.getRoute()]})})},t.prototype.steady=function(){return Wt(this,void 0,void 0,function(){return Zt(this,function(t){switch(t.label){case 0:return[4,this.getRoute()];case 1:return t.sent(),[2]}})})},t.prototype.extractState=function(){return this._history.location.state},t.prototype.subscribe=function(t,e,r){var n=jt(t,e,r);return this.observers.push(n),new Pt(this.handleUnsubscribe,n)},t.prototype.handleLocationChange=function(t,e){if(this.ignoreNextLocationChange)this.ignoreNextLocationChange=!1;else if(++this.navigationsSinceSteady>100)console.error("Detected possible navigation loop with 100 navigations between steady routes. Bailing.");else{if(null!==this.trailingSlash){var r=p(t.pathname,this.trailingSlash);if(t.pathname!==r)return void this._history.replace(zt({},t,{pathname:r}))}var n=s(t),o=this.lastHandledLocation;this.lastHandledLocation=t,this.observableSubscription&&this.observableSubscription.unsubscribe();var a=this._router.createObservable(n,function(t){void 0===t&&(t={});var e=zt({},t);delete e[Xt];var r=t[Xt]||{};return zt({},r.requestDataWithoutState,{state:Object.keys(e).length?e:void 0})}(t.state));if(a)this.observableSubscription=a.subscribe(this.handleChunkList);else if(!o)throw new m(n)}},t.prototype.setRoute=function(t,e){if(t!==this.lastRoute){this.lastRoute=t,this.isLastRouteSteady=e,e&&(this.navigationsSinceSteady=0);for(var r=0;r<this.observers.length;r++)this.observers[r].next(t);this.isLastRouteSteady&&this.waitUntilSteadyDeferred&&(this.waitUntilSteadyDeferred.resolve(t),delete this.waitUntilSteadyDeferred)}},t}(),Xt="__navi__";function te(t,e){var r;return void 0===t&&(t={}),zt({},e,((r={})[Xt]=t[Xt],r))}function ee(t){var e,r=t.revertTo,n=t.state,o=Jt(t,["revertTo","state"]);return r&&(r=zt({},r))[Xt]&&delete r[Xt].revertTo,zt({},n,((e={})[Xt]={requestDataWithoutState:o,revertTo:r},e))}function re(t){return void 0===t&&(t={}),(t[Xt]||{}).revertTo}var ne=function(){return(ne=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};var oe=function(){return(oe=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};t.crawl=function(t){return Ht(this,void 0,void 0,function(){var e,r,n,o,a,i,u,c,l,h,y,d,b,v=this;return Ft(this,function(m){switch(m.label){case 0:return e=Gt({basename:t.basename,context:t.context,routes:t.routes}),r=s(t.root||""),n=t.predicate||function(){return!0},o=t.expandPattern||function(t){return[t||""]},a=function(t,e){return Ht(v,void 0,void 0,function(){return Ft(this,function(r){switch(r.label){case 0:return[4,o(t)];case 1:return[2,(r.sent()||[]).map(function(t){return{headers:e.headers,url:s(f(e.mountpath,t)),context:e.headers}}).filter(n)]}})})},[4,_t(e.createObservable(r,{crawler:a,headers:t.headers,method:"HEAD"}))];case 1:i=m.sent(),u=[],c={};t:for(l=0;l<i.length;l++)if("crawl"===(h=i[l]).type){if(-1!==(y=h.url.pathname).indexOf(":"))continue;for(d=l+1;d<i.length&&"crawl"!==(b=i[d]).type&&"mount"!==b.type;d++,l++)if("redirect"===b.type){c[y]=b.to;continue t}u.push(y)}return[2,{paths:null!==t.trailingSlash?u.map(function(e){return p(e,t.trailingSlash||"remove")}):u,redirects:c}]}})})},t.resolve=$t,t.compose=o,t.Router=Nt,t.createRouter=Gt,t.routeReducer=At,t.concatMatcherIterators=R,t.Navigation=Kt,t.resolveChunks=O,t.createBrowserNavigation=function(t){t.pages&&(t.routes=t.pages),!t.state&&void 0!==typeof window&&window.__NAVI_STATE__&&(t.state=window.__NAVI_STATE__,delete window.__NAVI_STATE__);var r=t.history||e.createBrowserHistory();t.state&&r.replace(ne({},r.location,{state:t.state}));var n=new Kt({history:r,basename:t.basename,context:t.context,routes:t.routes,trailingSlash:t.trailingSlash});return n.refresh(),n},t.createMemoryNavigation=function(t){t.pages&&(t.routes=t.pages);var r=t.url||t.request&&t.request.url;if(!r)throw new Error("createMemoryNavigation() could not find a URL.");var n=e.createMemoryHistory({initialEntries:["/"]}),o=new Kt({history:n,basename:t.basename,context:t.context,routes:t.routes,trailingSlash:t.trailingSlash});return o.navigate(oe({},t.request,{url:r,replace:!0})),o},t.lazy=M,t.map=M,t.createPage=function(t){return Object.assign(o(X(it(t)),tt(function(t,e){return e.meta}),et(function(t,e){return e.title}),L(function(t,e){return e.content})),{isDeprecatedMatcher:!0})},t.createContext=function(t,e){return Object.assign(X(t,e.isDeprecatedMatcher?e:M(e)),{isDeprecatedMatcher:!0})},t.createSwitch=function(t){var e,r,n={};try{for(var a=at(Object.keys(t.paths)),i=a.next();!i.done;i=a.next()){var u=i.value,s=t.paths[u];n[u]=s.isDeprecatedMatcher?s:M(s)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}if(1===Object.keys(t).length)return Object.assign($(n),{isDeprecatedMatcher:!0});t.paths;var c=ot(t,["paths"]);return Object.assign(o(X(it(c)),tt(function(t,e){return e.meta}),et(function(t,e){return e.title}),L(function(t,e){return e.content}),$(n)),{isDeprecatedMatcher:!0})},t.createRedirect=function(t,e){var r=W(t);return e?o(tt(e),r):Object.assign(r,{isDeprecatedMatcher:!0})},t.mount=$,t.redirect=W,t.route=function(t){var e;if(void 0===t&&(t={}),"function"==typeof t)e=t;else{var r=t.data,n=t.getData,a=t.error,i=t.head,u=t.getHead,s=t.headers,c=t.getHeaders,l=t.state,h=t.getState,f=t.status,p=t.getStatus,y=t.title,d=t.getTitle,b=t.view,v=t.getView;vt(t,["data","getData","error","head","getHead","headers","getHeaders","state","getState","status","getStatus","title","getTitle","view","getView"]),e=function(t,e){var o,m=this,w=mt(gt(r,n,t,e),2),g=w[0],x=w[1];g?k(g)&&(g=g.then(wt)):g={};var S,O,P=mt(gt(s,c,t,e),2),j=P[0],_=P[1],R=mt(gt(l,h,t,e),2),E=R[0],T=R[1],C=mt(gt(f,p,t,e),2),L=C[0],I=C[1],D=mt(gt(y,d,t,e),2),M=D[0],U=D[1],q=mt(gt(i,u,t,e),2),A=q[0],G=q[1];return"HEAD"!==t.method&&(o=mt(gt(b,v,t,e),2),S=o[0],O=o[1]),x||_||T||I||U||G||O?dt(m,void 0,void 0,function(){var t;return bt(this,function(e){switch(e.label){case 0:return t={},[4,g];case 1:return t.data=e.sent(),t.error=a,[4,A];case 2:return t.head=e.sent(),[4,j];case 3:return t.headers=e.sent(),[4,E];case 4:return t.state=e.sent(),[4,L];case 5:return t.status=e.sent(),[4,M];case 6:return t.title=e.sent(),[4,S];case 7:return[2,(t.view=e.sent(),t)]}})}):{data:g,error:a,head:A,headers:j,state:E,status:L,title:M,view:S}}}return o(X(function(t,r){return t.crawler?{}:e(t,r)}),tt(function(t){return t.context.data}),st(function(t){return t.context.head}),ct(function(t){return t.context.headers}),pt(function(t){return t.context.state||null}),yt(function(t){return t.context.status}),et(function(t){return t.context.title}),L(function(t){return t.context.view},void 0,!0),C(function(t){return t.context.error},void 0,function(t,e){return t?[w("error",e,{error:t})]:[]}))},t.withContext=X,t.withCrawlerPatterns=function(t,e){var r=this,n=function(e){return function(n,o){return St(r,void 0,void 0,function(){var r,a,i,u;return Ot(this,function(s){switch(s.label){case 0:return r=t[n],o.mountpath===e.mountpath&&r?[3,1]:[2,e.crawler(n,o)];case 1:return Array.isArray(r)?(i=r,[3,4]):[3,2];case 2:return[4,r(e,e.context)];case 3:i=s.sent(),s.label=4;case 4:return a=i,u=H,[4,Promise.all(a.map(function(t){return e.crawler(t,o)}))];case 5:return[2,u.apply(void 0,[s.sent()])]}})})}};return function(t){return function(r){return function(t,e){return Ot(this,function(r){switch(r.label){case 0:return t.crawler?[3,2]:[5,kt(_(e,t))];case 1:return r.sent(),[3,4];case 2:return[5,kt(O(n,t,function(r){return _(e,xt({},t,{crawler:r}))}))];case 3:r.sent(),r.label=4;case 4:return[2]}})}(r,e?e(t):t)}}},t.withData=tt,t.withHead=st,t.withHeaders=ct,t.withState=pt,t.withStatus=yt,t.withTitle=et,t.withView=L,t.NaviError=b,t.NotFoundError=v,t.OutOfRootError=m,t.createRequest=U,t.createChunk=w,t.createNotFoundChunk=g,t.createURLDescriptor=s,t.parseQuery=c,t.stringifyQuery=l,t.joinPaths=f,t.modifyTrailingSlash=p,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("history")):"function"==typeof define&&define.amd?define(["exports","history"],e):e((t=t||self).Navi={},t.History)}(this,function(t,e){"use strict";var r=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},n=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(r(arguments[e]));return t},o=/((((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;function a(t,e){var r,n,a,s,c,h=void 0===e?{}:e,f=h.removeHash,p=void 0!==f&&f,y=h.trailingSlash,d=void 0===y?null:y;if("string"==typeof t){var v=o.exec(t);if(!v)throw new Error("Couldn't parse the provided URL.");r="",n=l(v[2]||"",d),a=i(s=v[6]||""),c=v[7]||""}else r=t.hostname||"",n=l(t.pathname||"",d),a=t.query||(t.search?i(t.search):{}),s=t.search||u(a),c=t.hash||"";return{hostname:r,pathname:n,query:a,search:s,hash:p?"":c,href:n+s+c}}function i(t,e){if(void 0===e&&(e="?"),!t||t[0]!=e)return{};for(var r={},n=t.slice(1).split("&"),o=0,a=n.length;o<a;o++){var i=n[o].split("=");r[i[0]]=i[1]?decodeURIComponent(i[1]):""}return r}function u(t,e){void 0===e&&(e="?");var r=Object.keys(t);if(0===r.length)return"";for(var n=[],o=0,a=r.length;o<a;o++){var i=r[o],u=String(t[i]);n.push(""===u?i:i+"="+encodeURIComponent(u))}return e+n.join("&")}function s(t){return""===t?[]:t.split("/")}function c(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var o=s(t),a=0;a<e.length;a++)o.push.apply(o,n(s(e[a])));var i=[],u=o.length-1;for(a=0;a<=u;a++){var c=o[a];".."===c?i.pop():"."===c||""===c&&0!==a&&a!==u||i.push(c)}return i.join("/")}function l(t,e){var r="/"===t.slice(-1);return"add"!==e||r?"remove"===e&&r&&t.length>1?t.slice(0,-1):t:t+"/"}var h,f=(h=function(t,e){return(h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}h(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),p=function(t){function e(e){var r=this,n=this.constructor.prototype;return(r=t.call(this,e)||this).__proto__=n,Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(r,r.constructor):Object.defineProperty(r,"stack",{value:(new Error).stack}),Object.defineProperty(r,"message",{value:e}),r}return f(e,t),e}(Error),y=function(t){function e(e){var r=t.call(this,"URL not found: "+e)||this;return r.pathname=e,r.status=404,r.name="NotFoundError",r}return f(e,t),e}(p),d=function(t){function e(e){var r=t.call(this,"URL not managed by router: "+e.href)||this;return r.url=e,r.name="OutOfRootError",r}return f(e,t),e}(p);function v(t,e,r){return Object.assign({type:t,request:e,url:a({pathname:e.mountpath,query:e.query})},r)}function b(t){var e=c(t.mountpath,t.path);return{type:"error",request:t,url:a({pathname:e,query:t.query}),error:new y(e)}}var m=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},w=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function g(t,e,r){var n,o,a,i,u,s,l;return m(this,function(h){switch(h.label){case 0:n="function"==typeof t?t:function(){return t};try{o=n(e,e.context)}catch(t){o=Promise.reject(t)}return x(o)?[3,1]:(a=r(o),[3,7]);case 1:i=o.then(S),u=function(t){var e={};return t.then(function(t){e.value=t,e.outcome="resolved"},function(t){e.error=t,e.outcome="rejected"}),e}(i),s=[v("busy",e,{promise:i})],h.label=2;case 2:return u.outcome?[3,4]:[4,s];case 3:return h.sent(),[3,2];case 4:return"rejected"!==u.outcome?[3,6]:((l=u.error)instanceof y&&!l.pathname&&(l.pathname=c(e.mountpath,e.path)),[4,[v("error",e,{error:l})]]);case 5:return h.sent(),[3,7];case 6:a=r(u.value),h.label=7;case 7:return a?Array.isArray(a)?[4,a.length?a:[]]:[3,9]:[3,11];case 8:return h.sent(),[3,11];case 9:return[5,w(a)];case 10:h.sent(),h.label=11;case 11:return[2]}})}function x(t){return!!t&&!!t.then}function S(t){return function(t){return t&&"object"==typeof t&&"default"in t}(t)?t.default:t}var k=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};function O(t,e,r){return void 0===r&&(r=""),t(e)}function P(t,e){var r,n,o,a;return k(this,function(i){switch(i.label){case 0:o=[],a=[],i.label=1;case 1:return(r=t.next()).done||(o=r.value||[]),(n=e.next()).done||(a=n.value||[]),[4,o.concat(a)];case 2:i.sent(),i.label=3;case 3:if(!r.done||!n.done)return[3,1];i.label=4;case 4:return[2]}})}var R=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},_=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function j(t){return function(e){return function(r){return R(this,function(n){switch(n.label){case 0:return[5,_(g(t,r,function(t){return O(t(e),r)}))];case 1:return n.sent(),[2]}})}}}var E=function(){return(E=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},T="\0";function L(t,e){var r=t;if(r.length>1&&"/"===r.substr(-1)&&(r=r.substr(0,r.length-1)),"/"!==r[0]&&(r="/"+r),/\/{2,}/.test(r)&&(r=r.replace(/\/{2,}/g,"/")),/^([A-Za-z0-9\$\-_\.+!*'\(\),\/]|\/:)+$/.test(r),0===r.length)throw new Error('You cannot use an empty string "" as a pattern!');for(var n=r.split("/").slice(1),o=[],a=[],i=["^"],u=0;u<n.length;u++){var s=n[u];s.length>1&&":"===s[0]?(o.push(s.slice(1)),a.push(T),i.push("([^/]+)")):(a.push(s),i.push(s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")))}return{key:a.join("/"),matcher:e,pattern:r,pathParamNames:o.length?o:void 0,regExp:"/"===r?/^\/$/:new RegExp(i.join("/"))}}function C(t,e){var r=e.regExp.exec(t.path||"/");if(r){var n=r[0],o=t.params;if(e.pathParamNames){o=E({},t.params);for(var a=0;a<e.pathParamNames.length;a++){o[e.pathParamNames[a]]=r[a+1]}}var i=t.path.slice(n.length)||"",u=c(t.mountpath,n)||"/";return E({},t,{params:o,mountpath:u,path:i,url:i+t.search})}}function I(t){return[].concat.apply([],t)}var U=function(){return(U=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},q=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},A=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},D=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i};function N(t){return"busy"===t.type}function G(t){return"mount"===t.type}var H=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},M=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function F(t,e,r,n,o,a){function i(e,i){var u,s;return H(this,function(c){switch(c.label){case 0:return u=e.path,(void 0===n?!i:n)&&u&&"/"!==u?[4,[b(e)]]:[3,2];case 1:return c.sent(),[3,4];case 2:return s=e.crawler&&!o||a&&!a(e)?function(){return H(this,function(t){switch(t.label){case 0:return[4,[]];case 1:return t.sent(),[2]}})}():g(t,e,function(t){return r(t,e)}),[5,M(i?P(s,O(i,e)):s)];case 3:c.sent(),c.label=4;case 4:return[2]}})}return function(t){return function(r){return i(r,e?e(t):t)}}}var Q=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},V=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Q(arguments[e]));return t};function Y(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(0===t.length)throw new Error("composeMatchers() expects at least one matcher.");return 1===t.length?t[0]:t.reduce(function(t,e){return function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return t(e.apply(void 0,V(r)))}})}var $=function(){return($=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},B=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},z=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function W(t,e){return function(r){return function(n){return function(e,r){return B(this,function(n){switch(n.label){case 0:return[5,z(g(t,e,function(t){return O(r,$({},e,{context:t||{}}))}))];case 1:return n.sent(),[2]}})}(n,e?e(r):r)}}}function Z(t,e){return F(t,e,function(t,e){return t?[v("data",e,{data:t})]:[]})}function J(t,e){return F(t,e,function(t,e){return t?[v("head",e,{head:t})]:[]})}function K(t,e){return F(t,e,function(t,e){return t?[v("headers",e,{headers:t})]:[]})}var X=function(){return(X=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},tt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},et=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function rt(t,e){function r(e,r){return tt(this,function(n){switch(n.label){case 0:return[5,et(g(t,e,function(t){var n=null===t?e.state:X({},e.state,t);return P(function(t){return tt(this,function(e){switch(e.label){case 0:return[4,t];case 1:return e.sent(),[2]}})}(null===t?[]:[v("state",e,{state:n})]),O(r,X({},e,{state:n})))}))];case 1:return n.sent(),[2]}})}return function(t){return function(n){return r(n,e?e(t):t)}}}function nt(t,e){return F(t,e,function(t,e){return t?[v("status",e,{status:t})]:[]})}function ot(t,e,r){return F(t,e,function(t,e){return t?[v("view",e,{view:t})]:[]},r,!1,function(t){return"HEAD"!==t.method})}function at(t,e){return F(t,e,function(t,e){return t?[v("title",e,{title:t})]:[]})}var it=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},ut=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},st=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&(r[n[o]]=t[n[o]])}return r},ct=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i};function lt(t){return t||{}}function ht(t,e,r,n){if(e){var o=e(r,n);return x(o)?[o.then(S),!0]:[o,!1]}return[t,!1]}var ft=function(){return(ft=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},pt=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},yt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},dt=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};var vt=function(){function t(t,e){this.close=t,this.observer=e,this.observer.start&&this.observer.start(this)}return t.prototype.unsubscribe=function(){this.closed||(this.closed=!0,this.close(this.observer),delete this.close,delete this.observer)},t}();function bt(t,e,r){return"function"==typeof t?{next:t,error:e,complete:r}:t}function mt(t){return new Promise(function(e,r){t.subscribe({start:function(t){this.subscription=t},next:function(t){this.value=t},complete:function(){e(this.value),this.subscription.unsubscribe()},error:function(t){r(t),this.subscription.unsubscribe()}})})}var wt=function(){function t(t,e,r){var n=this;this.handleUnsubscribe=function(t){var e=n.observers.indexOf(t);-1!==e&&n.observers.splice(e,1)},this.handleChange=function(t){if(t===n.lastListenId){n.lastListenId++,n.refresh();for(var e=n.result.done||n.result.value.every(function(t){return"busy"!==t.type}),r=0;r<n.observers.length;r++){var o=n.observers[r];o.next(n.result.value),e&&o.complete&&o.complete()}e&&delete n.matcherIterator}},this.refresh=function(){var t=n.matcherIterator.next();if(t.value&&(n.result=t),!n.result.done){var e=++n.lastListenId,r=function(){return n.handleChange(e)};Promise.race(n.result.value.filter(gt).map(xt)).then(r,r)}},this.url=t,this.lastListenId=0,this.observers=[],this.matcherIterator=r(e)}return t.prototype.subscribe=function(t,e,r){if(!this.matcherIterator)throw new Error("Can't subscribe to an already-complete RoutingObservable.");var n=bt(t,e,r);this.observers.push(n);var o=new vt(this.handleUnsubscribe,n);return 1===this.observers.length&&this.handleChange(this.lastListenId),o},t}();function gt(t){return"busy"===t.type}function xt(t){return t.promise}var St=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},kt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Ot=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},Pt=function(){function t(t,e,r,n,o,a){var i=this;this.handleUnsubscribe=function(t){var e=i.observers.indexOf(t);-1!==e&&i.observers.splice(e,1)},this.handleResolverUpdate=function(t){t===i.lastListenId&&(i.lastListenId++,i.isRefreshing?i.isRefreshScheduled||(i.isRefreshScheduled=!0):i.refresh())},this.refresh=function(){return St(i,void 0,void 0,function(){var t,e,r,n,o,a,i,u,s,h,f,p,y,d,v,b,m,w,g=this;return kt(this,function(x){switch(x.label){case 0:this.isRefreshScheduled=!1,this.isRefreshing=!0,t=[],e=0,r=function(){var r,o,a,i,u,s,l,h,f,p,y;return kt(this,function(d){switch(d.label){case 0:r=n.mapItems[e],o=r.pathname,a=r.matcherIterator.next(),r.lastResult&&!a.value||(r.lastResult=a),i=r.lastResult.value,r.chunksCache=i||[],u=i.findIndex(function(t){return"error"===t.type||t.url.href.length>=r.url.href.length&&("mount"===t.type&&r.lastMountPatterns!==t.patterns||"redirect"===t.type&&r.lastRedirectTo!==t.to)}),d.label=1;case 1:if(!(u>=0&&u<i.length))return[3,6];if(s=i[u],u++,"error"===s.type||n.options.predicate&&!n.options.predicate(s,i))return n.removeFromQueue(r),[2,"continue-items"];if("redirect"===s.type&&(r.lastRedirectTo=s.to,n.options.followRedirects&&n.addToQueue(s.to,r.depth+1,r.walkedPatternLists,o,r.order)),"mount"!==s.type)return[3,5];if(l=s.patterns,r.lastMountPatterns=l,h=l.slice(0).sort().join("\n"),!l||r.walkedPatternLists.has(h))return[3,5];r.walkedPatternLists.add(h),f=0,d.label=2;case 2:return f<l.length?[4,n.expandPatterns(c(o,l[f]))]:[3,5];case 3:for(p=d.sent(),y=0;y<p.length;y++)n.addToQueue(p[y],r.depth+1,r.walkedPatternLists,o,r.order.concat(f,y));d.label=4;case 4:return f++,[3,2];case 5:return[3,1];case 6:return i&&(t=t.concat(i)),e++,[2]}})},n=this,x.label=1;case 1:return this.mapItems&&e<this.mapItems.length?[5,r()]:[3,3];case 2:switch(x.sent()){case"continue-items":return[3,1]}return[3,1];case 3:if(!this.mapItems)return[2];for(o=[],a=0;a<this.mapItems.length;a++)i=this.mapItems[a],"mount"===(u=i.chunksCache[i.chunksCache.length-1]).type||"error"===u.type||"busy"!==u.type&&this.options.predicate&&!this.options.predicate(u,i.chunksCache)||o.push([c(i.pathname,"/"),i.chunksCache,i.order]);if(s=++this.lastListenId,h=function(){return g.handleResolverUpdate(s)},Promise.race(t.filter(Rt).map(_t)).then(h,h),o.sort(function(t,e){var r=t[2],n=e[2];if(r.length<n.length)return-1;if(r.length>n.length)return 1;for(var o=0;o<r.length;o++){if(r[o]<n[o])return-1;if(r[o]>n[o])return 1}return 0}),this.isRefreshScheduled)this.refresh();else{for(f={},p=!0,y=0;y<o.length;y++)d=Ot(o[y],2),v=d[0],(b=d[1]).some(function(t){return"busy"===t.type})&&(p=!1),f[l(v,"remove")]=b;for(m=0;m<this.observers.length;m++)(w=this.observers[m]).next(f),p&&w.complete&&w.complete();p&&(delete this.rootContext,delete this.mapItems,delete this.router,delete this.observers),this.isRefreshing=!1}return[2]}})})},this.observers=[],this.lastListenId=0,this.mapItems=[],this.router=o,this.rootContext=e,this.matcherGeneratorFunction=r,this.rootMapping=n,this.options=a,this.seenPathnames=new Set;var u=t.pathname;"/"===u.substr(-1)&&(u=u.substr(0,u.length-1)),this.addToQueue(u,0,new Set)}return t.prototype.subscribe=function(t,e,r){if(!this.observers)throw new Error("Can't subscribe to an already-complete RoutingObservable.");var n=bt(t,e,r);this.observers.push(n);var o=new vt(this.handleUnsubscribe,n);return 1===this.observers.length&&this.refresh(),o},t.prototype.expandPatterns=function(t){return St(this,void 0,void 0,function(){var e;return kt(this,function(r){switch(r.label){case 0:return this.options.expandPattern?[4,this.options.expandPattern(t,this.router)]:[3,2];case 1:if(e=r.sent())return[2,e];r.label=2;case 2:return[2,[t].filter(function(t){return!/\/:/.test(t)})]}})})},t.prototype.removeFromQueue=function(t){var e=this.mapItems.indexOf(t);-1!==e&&this.mapItems.splice(e,1)},t.prototype.addToQueue=function(t,e,r,n,o){if(void 0===o&&(o=[0]),!this.seenPathnames.has(t)&&(!this.options.maxDepth||e<=this.options.maxDepth)){this.seenPathnames.add(t);var i=a(t,{removeHash:!0}),u=C({body:null,context:this.rootContext,headers:this.options.headers||{},method:this.options.method||"HEAD",params:{},hostname:this.options.hostname||"",mountpath:"",query:i.query,search:i.search,hash:i.hash,path:i.pathname,url:i.pathname+i.search,originalUrl:i.href,state:{}},this.rootMapping);u&&this.mapItems.push({url:i,fromPathname:n,depth:e,pathname:t,order:o,walkedPatternLists:new Set(r),matcherIterator:this.matcherGeneratorFunction(u)})}},t}();function Rt(t){return"busy"===t.type}function _t(t){return t.promise}var jt=function(){return(jt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function Et(t,e){return t=function(t,e){if(t){if("url"===e.type)return jt({},t,{chunks:t.chunks.filter(function(t){return"url"!==t.type}),url:e.url});if("ready"!==t.type)return t}var r={lastChunk:e,method:e.request&&e.request.method,chunks:t?t.chunks.concat(e):[e],data:t?t.data:{},headers:t?t.headers:{},heads:t?t.heads:[],state:t?t.state:{},status:t?t.status:200,title:t&&t.title,url:t?t.url:e.url,views:t?t.views:[]};switch(e.type){case"busy":return jt({},r,{type:"busy"});case"data":return jt({},r,{type:"ready",data:jt({},r.data,e.data)});case"error":return jt({},r,{type:"error",error:e.error,status:r.status&&r.status>=400?r.status:e.error.status||500});case"head":return jt({},r,{type:"ready",heads:r.heads.concat(e.head)});case"headers":return jt({},r,{type:"ready",headers:jt({},r.headers,e.headers)});case"redirect":return jt({},r,{type:"redirect",to:e.to});case"state":return jt({},r,{type:"ready",state:jt({},r.state,e.state)});case"status":return jt({},r,{type:"ready",status:e.status});case"title":return jt({},r,{type:"ready",title:e.title});case"view":return jt({},r,{type:"ready",views:r.views.concat(e.view)});default:return jt({},r,{type:"ready"})}}(t,e),Object.defineProperties(t,{meta:{configurable:!0,get:function(){return t.data}},content:{configurable:!0,get:function(){return e.view}},segments:{configurable:!0,get:function(){return t.chunks}},lastSegment:{configurable:!0,get:function(){return t.lastChunk}}}),t}function Tt(t){return new Lt(t)}var Lt=function(){function t(t){this.context=t.context||{},this.matcherGenerator=t.routes();var e,r,n=t.basename;n&&"/"===n.slice(-1)&&(n=n.slice(0,-1)),this.rootMapping=(e=t.routes,void 0===(r=n)&&(r=""),""!==r?L(r,e):{pattern:r,key:"",regExp:new RegExp(""),matcher:e})}return t.prototype.setContext=function(t){this.context=t||{}},t.prototype.createObservable=function(t,e){var r=C({body:e.body,context:this.context,headers:e.headers||{},method:e.method||"GET",hostname:t.hostname,hash:t.hash,mountpath:"/",params:t.query,query:t.query,search:t.search,url:t.pathname+t.search,originalUrl:t.href,path:t.pathname,crawler:e.crawler,state:e.state||{}},this.rootMapping);if(r)return new wt(t,r,this.matcherGenerator)},t.prototype.createMapObservable=function(t,e){return void 0===e&&(e={}),new Pt(a(t),this.context,this.matcherGenerator,this.rootMapping,this,e)},t.prototype.resolve=function(t,e){var r,n=this;if(void 0===e&&(e={}),Array.isArray(t))r=t.map(function(t){return a(t)});else if("string"==typeof t)r=[a(t)];else if(t.url)r=[a((e=t).url)];else{if(!e)throw new Error("You must specify a URL for router.resolve().");r=[a(t)]}if(!r.length)return Promise.resolve([]);var o=r.map(function(t){return n.getPageRoutePromise(t,e)});return Array.isArray(t)?Promise.all(o):o[0]},t.prototype.resolveSiteMap=function(t,e){return void 0===e&&(e={}),mt(this.createMapObservable(t,e)).then(function(t){for(var e={},r={},n=Object.keys(t),o=0;o<n.length;o++){var i=n[o],u=t[i],s=u[u.length-1];"redirect"!==s.type?e[i]=[{type:"url",url:a(i)}].concat(u).reduce(Et,void 0):r[i]=s.to}return{routes:e,redirects:r}})},t.prototype.resolveRouteMap=function(t,e){return void 0===e&&(e={}),this.resolveSiteMap(t,e).then(function(t){return t.routes})},t.prototype.getPageRoutePromise=function(t,e){var r=this,n=this.createObservable(t,e);return n?mt(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&&e.followRedirects)return r.getPageRoutePromise(a(i.to),e);if("error"===i.type)throw i.error}return[{type:"url",url:a(t)}].concat(n).reduce(Et,void 0)}):Promise.reject(new d(t))},t}(),Ct=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},It=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};var Ut=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},qt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},At=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&(r[n[o]]=t[n[o]])}return r};function Dt(t){return Ut(this,void 0,void 0,function(){var e,r,n,o,a,i;return qt(this,function(u){if(e=t.basename,r=t.context,n=t.routes,o=t.url,a=t.urls,i=At(t,["basename","context","routes","url","urls"]),o&&a)throw new Error("You cannot pass both `url` and `urls` options to resolve(). Please pick one!");if(!o&&!a)throw new Error("You must pass one of `url` or `urls` options to resolve().");return[2,Tt({basename:e,context:r,routes:n}).resolve(o||a,i)]})})}var Nt=function(){return function(){this.promise=new Promise(function(t,e){this.resolve=t,this.reject=e}.bind(this)),Object.freeze(this)}}(),Gt=function(){return(Gt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},Ht=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},Mt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Ft=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&(r[n[o]]=t[n[o]])}return r},Qt=function(){function t(t){var e=this;this.handleUnsubscribe=function(t){var r=e.observers.indexOf(t);-1!==r&&e.observers.splice(r,1)},this.handleChunkList=function(t){for(var r=!0,n=e._history.location,o=0;o<t.length;o++){var i=t[o];if("busy"===i.type&&(r=!1),"state"===i.type&&(e.ignoreNextLocationChange=!0,e._history.replace(Gt({},n,{state:Yt(n.state,i.state)}))),"redirect"===i.type){var u=Bt(n.state);return void(u?(e.ignoreNextLocationChange=!0,e._history.replace(Gt({},n,{state:u})),e._history.push(i.to)):e._history.replace(i.to))}}e.setRoute([{type:"url",url:a(e.lastHandledLocation)}].concat(t).reduce(Et,void 0),r)},this._history=t.history,this.observers=[],this.isLastRouteSteady=!1,this.navigationsSinceSteady=0,this.basename=t.basename,this.matcher=t.routes,this._router=new Lt({context:t.context,routes:t.routes,basename:t.basename}),this.trailingSlash=void 0===t.trailingSlash?"remove":t.trailingSlash,this.unlisten=this._history.listen(function(t){return e.handleLocationChange(t,!1)})}return t.prototype.dispose=function(){this.observers.length=0,this.unlisten(),delete this.unlisten,delete this._history,this.observableSubscription&&this.observableSubscription.unsubscribe(),delete this.observableSubscription,delete this._router,delete this.waitUntilSteadyDeferred,delete this.lastRoute,delete this._router},t.prototype.go=function(t){return Ht(this,void 0,void 0,function(){var e,r=this;return Mt(this,function(n){switch(n.label){case 0:return e=new Promise(function(t){var e=r._history.listen(function(){e(),t()})}),this._history.go(t),[4,e];case 1:return n.sent(),[2,this.getRoute()]}})})},t.prototype.goBack=function(){return this.go(-1)},t.prototype.goForward=function(){return this.go(1)},t.prototype.navigate=function(t,e){var r;if(void 0===e&&(e={}),"string"==typeof t)r=a(t);else if(t.url)r=a((e=t).url);else{if(!t)throw new Error("You must specify a URL or state to navigation.navigate().");r=a(t)}var n=this._history.location,o=e.replace||!1!==e.replace&&n.pathname===r.pathname&&n.search===r.search&&n.hash===r.hash;return this._history[o?"replace":"push"]({pathname:r.pathname,search:r.search,hash:r.hash,state:$t({revertTo:o?n.state:void 0,method:e.method,headers:e.headers,body:e.body,state:e.state})}),this.getRoute()},t.prototype.prefetch=function(t){return Ht(this,void 0,void 0,function(){return Mt(this,function(e){switch(e.label){case 0:return[4,Dt({basename:this.basename,routes:this.matcher,context:this._router.context,url:t})];case 1:return e.sent(),[2]}})})},t.prototype.refresh=function(){return this.handleLocationChange(this._history.location,!0),this.getRoute()},t.prototype.setContext=function(t){return this._router.setContext(t),this.refresh()},t.prototype.getCurrentValue=function(){return this.lastRoute},t.prototype.getRoute=function(){return Ht(this,void 0,void 0,function(){return Mt(this,function(t){return this.isLastRouteSteady?[2,this.lastRoute]:(this.waitUntilSteadyDeferred||(this.waitUntilSteadyDeferred=new Nt),[2,this.waitUntilSteadyDeferred.promise])})})},t.prototype.getSteadyValue=function(){return Ht(this,void 0,void 0,function(){return Mt(this,function(t){return[2,this.getRoute()]})})},t.prototype.steady=function(){return Ht(this,void 0,void 0,function(){return Mt(this,function(t){switch(t.label){case 0:return[4,this.getRoute()];case 1:return t.sent(),[2]}})})},t.prototype.extractState=function(){return this._history.location.state},t.prototype.subscribe=function(t,e,r){var n=bt(t,e,r);return this.observers.push(n),new vt(this.handleUnsubscribe,n)},t.prototype.handleLocationChange=function(t,e){if(this.ignoreNextLocationChange)this.ignoreNextLocationChange=!1;else if(++this.navigationsSinceSteady>100)console.error("Detected possible navigation loop with 100 navigations between steady routes. Bailing.");else{if(null!==this.trailingSlash){var r=l(t.pathname,this.trailingSlash);if(t.pathname!==r)return void this._history.replace(Gt({},t,{pathname:r}))}var n=a(t),o=this.lastHandledLocation;this.lastHandledLocation=t,this.observableSubscription&&this.observableSubscription.unsubscribe();var i=this._router.createObservable(n,function(t){void 0===t&&(t={});var e=Gt({},t);delete e[Vt];var r=t[Vt]||{};return Gt({},r.requestDataWithoutState,{state:Object.keys(e).length?e:void 0})}(t.state));if(i)this.observableSubscription=i.subscribe(this.handleChunkList);else if(!o)throw new d(n)}},t.prototype.setRoute=function(t,e){if(t!==this.lastRoute){this.lastRoute=t,this.isLastRouteSteady=e,e&&(this.navigationsSinceSteady=0);for(var r=0;r<this.observers.length;r++)this.observers[r].next(t);this.isLastRouteSteady&&this.waitUntilSteadyDeferred&&(this.waitUntilSteadyDeferred.resolve(t),delete this.waitUntilSteadyDeferred)}},t}(),Vt="__navi__";function Yt(t,e){var r;return void 0===t&&(t={}),Gt({},e,((r={})[Vt]=t[Vt],r))}function $t(t){var e,r=t.revertTo,n=t.state,o=Ft(t,["revertTo","state"]);return r&&(r=Gt({},r))[Vt]&&delete r[Vt].revertTo,Gt({},n,((e={})[Vt]={requestDataWithoutState:o,revertTo:r},e))}function Bt(t){return void 0===t&&(t={}),(t[Vt]||{}).revertTo}var zt=function(){return(zt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};var Wt=function(){return(Wt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};t.crawl=function(t){return Ct(this,void 0,void 0,function(){var e,r,n,o,i,u,s,h,f,p,y,d,v,b=this;return It(this,function(m){switch(m.label){case 0:return e=Tt({basename:t.basename,context:t.context,routes:t.routes}),r=a(t.root||""),n=t.predicate||function(){return!0},o=t.expandPattern||function(t){return[t||""]},i=function(t,e){return Ct(b,void 0,void 0,function(){return It(this,function(r){switch(r.label){case 0:return[4,o(t)];case 1:return[2,(r.sent()||[]).map(function(t){return{headers:e.headers,url:a(c(e.mountpath,t)),context:e.headers}}).filter(n)]}})})},[4,mt(e.createObservable(r,{crawler:i,headers:t.headers,method:"HEAD"}))];case 1:u=m.sent(),s=[],h={};t:for(f=0;f<u.length;f++)if("crawl"===(p=u[f]).type){if(-1!==(y=p.url.pathname).indexOf(":"))continue;for(d=f+1;d<u.length&&"crawl"!==(v=u[d]).type&&"mount"!==v.type;d++,f++)if("redirect"===v.type){h[y]=v.to;continue t}s.push(y)}return[2,{paths:null!==t.trailingSlash?s.map(function(e){return l(e,t.trailingSlash||"remove")}):s,redirects:h}]}})})},t.resolve=Dt,t.compose=Y,t.Router=Lt,t.createRouter=Tt,t.routeReducer=Et,t.concatMatcherIterators=P,t.Navigation=Qt,t.resolveChunks=g,t.createBrowserNavigation=function(t){!t.state&&void 0!==typeof window&&window.__NAVI_STATE__&&(t.state=window.__NAVI_STATE__,delete window.__NAVI_STATE__);var r=t.history||e.createBrowserHistory();t.state&&r.replace(zt({},r.location,{state:t.state}));var n=new Qt({history:r,basename:t.basename,context:t.context,routes:t.routes,trailingSlash:t.trailingSlash});return n.refresh(),n},t.createMemoryNavigation=function(t){var r=t.url||t.request&&t.request.url;if(!r)throw new Error("createMemoryNavigation() could not find a URL.");var n=e.createMemoryHistory({initialEntries:["/"]}),o=new Qt({history:n,basename:t.basename,context:t.context,routes:t.routes,trailingSlash:t.trailingSlash});return o.navigate(Wt({},t.request,{url:r,replace:!0})),o},t.lazy=j,t.map=j,t.mount=function(t){if(!t)throw new Error("mount() must be supplied with a paths object.");var e=Object.keys(t),r=e.filter(function(t){return"*"!==t}).map(function(e){return L(e,t[e])}).sort(function(t,e){return r=t.key,n=e.key,r<n?-1:r>n?1:0;var r,n});return function(n){return function(o){var a,i,u,s,c,l,h,f,p,y,d,m,w,g,x,S,k;return A(this,function(P){switch(P.label){case 0:if(u=[],s=[],c=[],l=o.crawler,!(h=l&&(""===o.path||"/"===o.path)))return[3,5];(f=function(t,e,r){return q(this,void 0,void 0,function(){var n;return A(this,function(o){switch(o.label){case 0:return n=I,[4,Promise.all(Object.entries(t).map(function(t){var n,o=D(t,2),a=o[0],i=o[1];return e("*"===a?"":a,r).then((n=i,function(t){return t.map(function(t){return[n,t]})}))}))];case 1:return[2,n.apply(void 0,[o.sent()])]}})})}(t,l,o)).then(function(t){p=t},function(t){return y=t}),P.label=1;case 1:return[4,[v("busy",o,{promise:f})]];case 2:if(P.sent(),y)throw y;P.label=3;case 3:if(!p)return[3,1];P.label=4;case 4:return i=p.map(function(t,e){var r=D(t,2),a=r[0],i=r[1],u=U({},o,{mountpath:i.url.pathname,url:"",path:""});return c[e]=u,O(a(n),u,u.mountpath)}),[3,6];case 5:for(S=r.length-1;S>=0;S--)if(d=r[S],m=C(o,d)){i=[O(d.matcher(n),m,d.pattern)];break}i||(w=t["*"])&&(i=[O(w(n),o,"*")]),P.label=6;case 6:if(i)for(S=0;S<i.length;S++)(g=u[S])&&g.done||(g=u[S]=i[S].next()),g&&!g.done&&(s[S]=g.value);for(a=[v("mount",o,{patterns:e})],x=!1,S=0;S<u.length;S++)(k=s[S])&&(x=!0,h&&!k.some(G)&&(a=a.concat(v("crawl",c[S]))),a=a.concat(k));return l||x||a.push(b(o)),[4,a];case 7:P.sent(),P.label=8;case 8:if(a.filter(N).length)return[3,6];P.label=9;case 9:return[2]}})}}},t.redirect=function(t,e){var r=(void 0===e?{}:e).exact;return F(t,void 0,function(t,e){var r;return"string"==typeof t?r="/"===t[0]?t:c("/",e.mountpath,t):t&&(r=a(t).href),r?[v("redirect",e,{to:r})]:[]},void 0===r||r,!0)},t.route=function(t){var e;if(void 0===t&&(t={}),"function"==typeof t)e=t;else{var r=t.data,n=t.getData,o=t.error,a=t.head,i=t.getHead,u=t.headers,s=t.getHeaders,c=t.state,l=t.getState,h=t.status,f=t.getStatus,p=t.title,y=t.getTitle,d=t.view,b=t.getView;st(t,["data","getData","error","head","getHead","headers","getHeaders","state","getState","status","getStatus","title","getTitle","view","getView"]),e=function(t,e){var v,m=this,w=ct(ht(r,n,t,e),2),g=w[0],S=w[1];g?x(g)&&(g=g.then(lt)):g={};var k,O,P=ct(ht(u,s,t,e),2),R=P[0],_=P[1],j=ct(ht(c,l,t,e),2),E=j[0],T=j[1],L=ct(ht(h,f,t,e),2),C=L[0],I=L[1],U=ct(ht(p,y,t,e),2),q=U[0],A=U[1],D=ct(ht(a,i,t,e),2),N=D[0],G=D[1];return"HEAD"!==t.method&&(v=ct(ht(d,b,t,e),2),k=v[0],O=v[1]),S||_||T||I||A||G||O?it(m,void 0,void 0,function(){var t;return ut(this,function(e){switch(e.label){case 0:return t={},[4,g];case 1:return t.data=e.sent(),t.error=o,[4,N];case 2:return t.head=e.sent(),[4,R];case 3:return t.headers=e.sent(),[4,E];case 4:return t.state=e.sent(),[4,C];case 5:return t.status=e.sent(),[4,q];case 6:return t.title=e.sent(),[4,k];case 7:return[2,(t.view=e.sent(),t)]}})}):{data:g,error:o,head:N,headers:R,state:E,status:C,title:q,view:k}}}return Y(W(function(t,r){return t.crawler?{}:e(t,r)}),Z(function(t){return t.context.data}),J(function(t){return t.context.head}),K(function(t){return t.context.headers}),rt(function(t){return t.context.state||null}),nt(function(t){return t.context.status}),at(function(t){return t.context.title}),ot(function(t){return t.context.view},void 0,!0),F(function(t){return t.context.error},void 0,function(t,e){return t?[v("error",e,{error:t})]:[]}))},t.withContext=W,t.withCrawlerPatterns=function(t,e){var r=this,n=function(e){return function(n,o){return pt(r,void 0,void 0,function(){var r,a,i,u;return yt(this,function(s){switch(s.label){case 0:return r=t[n],o.mountpath===e.mountpath&&r?[3,1]:[2,e.crawler(n,o)];case 1:return Array.isArray(r)?(i=r,[3,4]):[3,2];case 2:return[4,r(e,e.context)];case 3:i=s.sent(),s.label=4;case 4:return a=i,u=I,[4,Promise.all(a.map(function(t){return e.crawler(t,o)}))];case 5:return[2,u.apply(void 0,[s.sent()])]}})})}};return function(t){return function(r){return function(t,e){return yt(this,function(r){switch(r.label){case 0:return t.crawler?[3,2]:[5,dt(O(e,t))];case 1:return r.sent(),[3,4];case 2:return[5,dt(g(n,t,function(r){return O(e,ft({},t,{crawler:r}))}))];case 3:r.sent(),r.label=4;case 4:return[2]}})}(r,e?e(t):t)}}},t.withData=Z,t.withHead=J,t.withHeaders=K,t.withState=rt,t.withStatus=nt,t.withTitle=at,t.withView=ot,t.NaviError=p,t.NotFoundError=y,t.OutOfRootError=d,t.createChunk=v,t.createNotFoundChunk=b,t.createURLDescriptor=a,t.parseQuery=i,t.stringifyQuery=u,t.joinPaths=c,t.modifyTrailingSlash=l,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "navi",
"version": "0.12.9",
"version": "0.13.0-alpha.0",
"description": "A router-loader for React.",

@@ -60,3 +60,3 @@ "author": "James K Nelson <james@jamesknelson.com>",

},
"gitHead": "87a356d4d68f6fdc0b40b2beb58cf124d1e8b51c"
"gitHead": "7e2d77304dc7ee57eadbeb9cc23e6dfa4e902e2b"
}

@@ -5,77 +5,70 @@ import { createBrowserHistory, History } from 'history'

export interface BrowserNavigationOptions<Context extends object> {
/**
* The Matcher that declares your app's pages.
*/
routes?: Matcher<Context>,
pages?: Matcher<Context>,
/**
* The Matcher that declares your app's pages.
*/
routes?: Matcher<Context>
/**
* If provided, this part of any URLs will be ignored. This is useful
* for mounting a Navi app in a subdirectory on a domain.
*/
basename?: string,
/**
* If provided, this part of any URLs will be ignored. This is useful
* for mounting a Navi app in a subdirectory on a domain.
*/
basename?: string
/**
* This will be made available within your matcher through
* the `env` object passed to any getter functions.
*/
context?: Context,
/**
* This will be made available within your matcher through
* the `env` object passed to any getter functions.
*/
context?: Context
/**
* If you specify a react-router style `history` object, then Navi will
* use it to interact with the browser history -- allowing for integration
* with react-router (and other custom behaviors).
*/
history?: History,
/**
* If you specify a react-router style `history` object, then Navi will
* use it to interact with the browser history -- allowing for integration
* with react-router (and other custom behaviors).
*/
history?: History
/**
* Accepts the history.state of the Navigation object used to pre-render
* the page on the server.
*/
state?: any,
/**
* Accepts the history.state of the Navigation object used to pre-render
* the page on the server.
*/
state?: any
/**
* Configures whether a trailing slash will be added or removed. By default,
* the trailing slash will be removed.
*/
trailingSlash?: 'add' | 'remove' | null
/**
* Configures whether a trailing slash will be added or removed. By default,
* the trailing slash will be removed.
*/
trailingSlash?: 'add' | 'remove' | null
}
export function createBrowserNavigation<Context extends object>(
options: BrowserNavigationOptions<Context>,
) {
// If there's a server state on the window object, use it and then remove
// it so that it won't be picked up by any nested navigation objects.
if (
!options.state &&
typeof window !== undefined &&
window['__NAVI_STATE__']
) {
options.state = window['__NAVI_STATE__']
delete window['__NAVI_STATE__']
}
export function createBrowserNavigation<Context extends object>(options: BrowserNavigationOptions<Context>) {
if (options.pages) {
if (process.env.NODE_ENV !== 'production') {
console.warn(
`Deprecation Warning: passing a "pages" option to "createBrowserNavigation()" will `+
`no longer be supported from Navi 0.13. Use the "routes" option instead.`
)
}
options.routes = options.pages
}
// If there's a server state on the window object, use it and then remove
// it so that it won't be picked up by any nested navigation objects.
if (!options.state && typeof window !== undefined && window['__NAVI_STATE__']) {
options.state = window['__NAVI_STATE__']
delete window['__NAVI_STATE__']
}
let history = options.history || createBrowserHistory()
if (options.state) {
history.replace({
...history.location,
state: options.state,
})
}
let navigation = new Navigation({
history,
basename: options.basename,
context: options.context,
routes: options.routes!,
trailingSlash: options.trailingSlash,
let history = options.history || createBrowserHistory()
if (options.state) {
history.replace({
...history.location,
state: options.state,
})
navigation.refresh()
return navigation
}
let navigation = new Navigation({
history,
basename: options.basename,
context: options.context,
routes: options.routes!,
trailingSlash: options.trailingSlash,
})
navigation.refresh()
return navigation
}

@@ -1,3 +0,8 @@

import { URLDescriptor, createURLDescriptor, joinPaths, modifyTrailingSlash } from './URLTools'
import {
URLDescriptor,
createURLDescriptor,
joinPaths,
modifyTrailingSlash,
} from './URLTools'
import {
Observable,

@@ -12,3 +17,2 @@ Observer,

import { Mapping, matchAgainstPathname } from './Mapping'
import { createRequest } from './NaviRequest';

@@ -43,3 +47,3 @@ interface MapItem {

private lastListenId: number
private seenPathnames: Set<string>

@@ -74,9 +78,7 @@ private mapItems: MapItem[]

this.addToQueue(pathname, 0, new Set)
this.addToQueue(pathname, 0, new Set())
}
subscribe(
onNextOrObserver:
| Observer<ChunksMap>
| ((value: ChunksMap) => void),
onNextOrObserver: Observer<ChunksMap> | ((value: ChunksMap) => void),
onError?: (error: any) => void,

@@ -86,3 +88,5 @@ onComplete?: () => void,

if (!this.observers) {
throw new Error("Can't subscribe to an already-complete RoutingObservable.")
throw new Error(
"Can't subscribe to an already-complete RoutingObservable.",
)
}

@@ -105,3 +109,6 @@

if (this.options.expandPattern) {
let expandedPatterns = await this.options.expandPattern(pattern, this.router)
let expandedPatterns = await this.options.expandPattern(
pattern,
this.router,
)
if (expandedPatterns) {

@@ -121,3 +128,3 @@ return expandedPatterns

private handleResolverUpdate = (listenId) => {
private handleResolverUpdate = listenId => {
if (listenId === this.lastListenId) {

@@ -127,4 +134,3 @@ this.lastListenId++

this.refresh()
}
else if (!this.isRefreshScheduled) {
} else if (!this.isRefreshScheduled) {
this.isRefreshScheduled = true

@@ -141,7 +147,6 @@ }

let i = 0
// This is a while loop instead of a for loop, as new items can be added
// to this.mapItems within the loop body.
items:
while (this.mapItems && i < this.mapItems.length) {
items: while (this.mapItems && i < this.mapItems.length) {
let item = this.mapItems[i]

@@ -156,8 +161,9 @@

item.chunksCache = chunks || []
let focusIndex = chunks.findIndex(chunk =>
chunk.type === 'error' ||
(chunk.url.href.length >= item.url.href.length) && (
(chunk.type === 'mount' && item.lastMountPatterns !== chunk.patterns) ||
(chunk.type === 'redirect' && item.lastRedirectTo !== chunk.to)
)
let focusIndex = chunks.findIndex(
chunk =>
chunk.type === 'error' ||
(chunk.url.href.length >= item.url.href.length &&
((chunk.type === 'mount' &&
item.lastMountPatterns !== chunk.patterns) ||
(chunk.type === 'redirect' && item.lastRedirectTo !== chunk.to))),
)

@@ -168,3 +174,3 @@

focusIndex++
// If an item in the map cannot be found, throws an error, or is

@@ -179,3 +185,4 @@ // no longer referenced by other items, then remove it from the

focusChunk.type === 'error' ||
(this.options.predicate && !this.options.predicate(focusChunk, chunks))
(this.options.predicate &&
!this.options.predicate(focusChunk, chunks))
) {

@@ -189,3 +196,9 @@ this.removeFromQueue(item)

if (this.options.followRedirects) {
this.addToQueue(focusChunk.to, item.depth + 1, item.walkedPatternLists, pathname, item.order)
this.addToQueue(
focusChunk.to,
item.depth + 1,
item.walkedPatternLists,
pathname,
item.order,
)
}

@@ -197,7 +210,12 @@ }

item.lastMountPatterns = patterns
let key = patterns.slice(0).sort().join("\n")
let key = patterns
.slice(0)
.sort()
.join('\n')
if (patterns && !item.walkedPatternLists.has(key)) {
item.walkedPatternLists.add(key)
for (let j = 0; j < patterns.length; j++) {
let expandedPatterns = await this.expandPatterns(joinPaths(pathname, patterns[j]))
let expandedPatterns = await this.expandPatterns(
joinPaths(pathname, patterns[j]),
)
for (let k = 0; k < expandedPatterns.length; k++) {

@@ -209,3 +227,3 @@ this.addToQueue(

pathname,
item.order.concat(j, k)
item.order.concat(j, k),
)

@@ -239,7 +257,10 @@ }

lastChunk.type !== 'error' &&
(lastChunk.type === 'busy' || !this.options.predicate || this.options.predicate(lastChunk, item.chunksCache!))) {
(lastChunk.type === 'busy' ||
!this.options.predicate ||
this.options.predicate(lastChunk, item.chunksCache!))
) {
chunksMapArray.push([
joinPaths(item.pathname, '/'),
item.chunksCache!,
item.order
item.order,
])

@@ -251,7 +272,6 @@ }

let handleUpdate = () => this.handleResolverUpdate(listenId)
Promise.race(
allChunks
.filter(isBusy)
.map(pickChunkPromise)
).then(handleUpdate, handleUpdate)
Promise.race(allChunks.filter(isBusy).map(pickChunkPromise)).then(
handleUpdate,
handleUpdate,
)

@@ -261,3 +281,3 @@ chunksMapArray.sort((itemX, itemY) => {

let y = itemY[2]
if (x.length < y.length) {

@@ -269,3 +289,3 @@ return -1

}
for (let i = 0; i < x.length; i++) {

@@ -279,3 +299,3 @@ if (x[i] < y[i]) {

}
return 0

@@ -286,4 +306,3 @@ })

this.refresh()
}
else {
} else {
let chunksMap: ChunksMap = {}

@@ -298,3 +317,3 @@ let isSteady = true

}
for (let i = 0; i < this.observers.length; i++) {

@@ -325,3 +344,9 @@ let observer = this.observers[i]

private addToQueue(pathname: string, depth: number, walkedPatternLists: Set<string>, fromPathname?: string, order = [0]) {
private addToQueue(
pathname: string,
depth: number,
walkedPatternLists: Set<string>,
fromPathname?: string,
order = [0],
) {
if (this.seenPathnames.has(pathname)) {

@@ -337,3 +362,3 @@ return

})
let request = createRequest({
let request = {
body: null,

@@ -349,8 +374,7 @@ context: this.rootContext,

hash: url.hash,
router: this.router,
path: url.pathname,
url: url.pathname+url.search,
url: url.pathname + url.search,
originalUrl: url.href,
state: {},
}, this.router)
}
let matchRequest = matchAgainstPathname(request, this.rootMapping)

@@ -378,2 +402,2 @@ if (matchRequest) {

return chunk.promise
}
}

@@ -5,3 +5,2 @@ //

export * from './matchers/compat'
export * from './matchers/map'

@@ -31,3 +30,8 @@ export * from './matchers/mount'

export { SiteMap, RouteMap } from './Maps'
export { Matcher, MatcherGenerator, MatcherIterator, concatMatcherIterators } from './Matcher'
export {
Matcher,
MatcherGenerator,
MatcherIterator,
concatMatcherIterators,
} from './Matcher'
export { Navigation } from './Navigation'

@@ -34,0 +38,0 @@ export { Resolvable, default as resolveChunks } from './Resolvable'

import { Matcher } from './Matcher'
import { joinPaths } from './URLTools'
import { createRequest, NaviRequest } from './NaviRequest'
import { NaviRequest } from './NaviRequest'
export const KEY_WILDCARD = '\0'
export const MEMO_KEY_PREFIX = '\0'
/**

@@ -15,140 +13,149 @@ * An object that holds information about a path that can be matched

export interface Mapping {
/**
* The relative path of a Map to its parent, with wildcards
* represented by a colon `:`, followed by the name of the param where
* their value should be placed.
*/
pattern: string,
/**
* A string where wildcards have been replaced with the null character
* '\0', so that no two identical keys will match the same URL.
*/
key: string,
/**
* The relative path of a Map to its parent, with wildcards
* represented by a colon `:`, followed by the name of the param where
* their value should be placed.
*/
pattern: string
/**
* A regex that matches the path.
* It should start with ^, but should not end with $.`
*/
regExp: RegExp,
/**
* A string where wildcards have been replaced with the null character
* '\0', so that no two identical keys will match the same URL.
*/
key: string
/**
* The names of params that correspond to wildcards in the relative path.
*/
pathParamNames?: string[],
/**
* A regex that matches the path.
* It should start with ^, but should not end with $.`
*/
regExp: RegExp
/**
* The node that will be used to handle detailed matching of this path,
* once a tentative match is found.
*/
matcher: Matcher<any>,
/**
* The names of params that correspond to wildcards in the relative path.
*/
pathParamNames?: string[]
/**
* The node that will be used to handle detailed matching of this path,
* once a tentative match is found.
*/
matcher: Matcher<any>
}
export function createRootMapping(matcher: Matcher<any>, rootPath: string = ''): Mapping {
return (
rootPath !== ''
? createMapping(rootPath, matcher)
: {
pattern: rootPath,
key: '',
regExp: new RegExp(''),
matcher,
}
)
export function createRootMapping(
matcher: Matcher<any>,
rootPath: string = '',
): Mapping {
return rootPath !== ''
? createMapping(rootPath, matcher)
: {
pattern: rootPath,
key: '',
regExp: new RegExp(''),
matcher,
}
}
export function createMapping(pattern: string, matcher: Matcher<any>): Mapping {
let processedPattern = pattern
if (processedPattern.length > 1 && processedPattern.substr(-1) === '/') {
if (process.env.NODE_ENV !== 'production') {
console.warn(`The pattern "${pattern}" ends with the character '/', so it has been automatically removed. To avoid this warning, don't add a final "/" to patterns.`)
}
processedPattern = processedPattern.substr(0, processedPattern.length - 1)
let processedPattern = pattern
if (processedPattern.length > 1 && processedPattern.substr(-1) === '/') {
if (process.env.NODE_ENV !== 'production') {
console.warn(
`The pattern "${pattern}" ends with the character '/', so it has been automatically removed. To avoid this warning, don't add a final "/" to patterns.`,
)
}
processedPattern = processedPattern.substr(0, processedPattern.length - 1)
}
if (processedPattern[0] !== '/') {
if (process.env.NODE_ENV !== 'production') {
console.warn(`The pattern "${pattern}" does not start with the character '/', so it has been automatically added. To avoid this warning, make sure to add the leading "/" to all patterns.`)
}
processedPattern = '/'+processedPattern
if (processedPattern[0] !== '/') {
if (process.env.NODE_ENV !== 'production') {
console.warn(
`The pattern "${pattern}" does not start with the character '/', so it has been automatically added. To avoid this warning, make sure to add the leading "/" to all patterns.`,
)
}
processedPattern = '/' + processedPattern
}
if (/\/{2,}/.test(processedPattern)) {
if (process.env.NODE_ENV !== 'production') {
console.warn(`The pattern "${pattern} has adjacent '/' characters, which have been combined into single '/' characters. To avoid this warning, don't use adjacent '/' characters within patterns.`)
}
processedPattern = processedPattern.replace(/\/{2,}/g, '/')
if (/\/{2,}/.test(processedPattern)) {
if (process.env.NODE_ENV !== 'production') {
console.warn(
`The pattern "${pattern} has adjacent '/' characters, which have been combined into single '/' characters. To avoid this warning, don't use adjacent '/' characters within patterns.`,
)
}
if (!/^([A-Za-z0-9\$\-_\.+!*'\(\),\/]|\/:)+$/.test(processedPattern)) {
if (process.env.NODE_ENV !== 'production') {
console.warn(`The pattern "${pattern}" uses non-URL safe characters. The URL-safe characters are: A-Z a-z 0-9 $ - _ . + ! * ' ( ) ,`)
}
processedPattern = processedPattern.replace(/\/{2,}/g, '/')
}
if (!/^([A-Za-z0-9\$\-_\.+!*'\(\),\/]|\/:)+$/.test(processedPattern)) {
if (process.env.NODE_ENV !== 'production') {
console.warn(
`The pattern "${pattern}" uses non-URL safe characters. The URL-safe characters are: A-Z a-z 0-9 $ - _ . + ! * ' ( ) ,`,
)
}
if (processedPattern.length === 0) {
throw new Error(`You cannot use an empty string "" as a pattern!`)
}
if (processedPattern.length === 0) {
throw new Error(`You cannot use an empty string "" as a pattern!`)
}
let parts = processedPattern.split('/').slice(1)
let pathParams: string[] = []
let keyParts: string[] = []
let regExpParts = ['^']
for (let i = 0; i < parts.length; i++) {
let part = parts[i]
if (part.length > 1 && part[0] === ':') {
pathParams.push(part.slice(1))
keyParts.push(KEY_WILDCARD)
regExpParts.push('([^/]+)')
} else {
keyParts.push(part)
regExpParts.push(escapeRegExp(part))
}
let parts = processedPattern.split('/').slice(1)
let pathParams: string[] = []
let keyParts: string[] = []
let regExpParts = ['^']
for (let i = 0; i < parts.length; i++) {
let part = parts[i]
if (part.length > 1 && part[0] === ':') {
pathParams.push(part.slice(1))
keyParts.push(KEY_WILDCARD)
regExpParts.push('([^/]+)')
}
else {
keyParts.push(part)
regExpParts.push(escapeRegExp(part))
}
}
return {
key: keyParts.join('/'),
matcher,
pattern: processedPattern,
pathParamNames: pathParams.length ? pathParams : undefined,
regExp: processedPattern === '/' ? /^\/$/ : new RegExp(regExpParts.join('/')),
}
}
return {
key: keyParts.join('/'),
matcher,
pattern: processedPattern,
pathParamNames: pathParams.length ? pathParams : undefined,
regExp:
processedPattern === '/' ? /^\/$/ : new RegExp(regExpParts.join('/')),
}
}
export function matchAgainstPathname(
request: NaviRequest,
mapping: Mapping,
): NaviRequest | undefined {
let match = mapping.regExp.exec(request.path || '/')
if (!match) {
return
}
export function matchAgainstPathname(request: NaviRequest, mapping: Mapping): NaviRequest | undefined {
let match = mapping.regExp.exec(request.path || '/')
if (!match) {
return
}
let matchedPathname = match[0]
let matchedPathname = match[0]
// Set path params using RegExp match
let params = request.params
if (mapping.pathParamNames) {
params = { ...request.params }
for (let i = 0; i < mapping.pathParamNames.length; i++) {
let paramName = mapping.pathParamNames[i]
params[paramName] = match[i+1]
}
// Set path params using RegExp match
let params = request.params
if (mapping.pathParamNames) {
params = { ...request.params }
for (let i = 0; i < mapping.pathParamNames.length; i++) {
let paramName = mapping.pathParamNames[i]
params[paramName] = match[i + 1]
}
}
let unmatchedPath = request.path.slice(matchedPathname.length) || ''
let mountpath = joinPaths(request.mountpath, matchedPathname) || '/'
return createRequest({
...request,
params,
mountpath,
path: unmatchedPath,
url: unmatchedPath+request.search,
}, request['_router'])
let unmatchedPath = request.path.slice(matchedPathname.length) || ''
let mountpath = joinPaths(request.mountpath, matchedPathname) || '/'
return {
...request,
params,
mountpath,
path: unmatchedPath,
url: unmatchedPath + request.search,
}
}
// From http://stackoverflow.com/a/5306111/106302
// Originally from http://simonwillison.net/2006/Jan/20/escape/ (dead link)
function escapeRegExp(value) {
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")
}
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
}

@@ -1,2 +0,2 @@

import { createMemoryHistory } from 'history';
import { createMemoryHistory } from 'history'
import { Matcher } from './Matcher'

@@ -6,72 +6,61 @@ import { Navigation, NavigateOptions } from './Navigation'

export interface MemoryNavigationOptions<Context extends object> {
/**
* The Matcher that declares your app's pages.
*/
routes?: Matcher<Context>,
pages?: Matcher<Context>,
/**
* The Matcher that declares your app's pages.
*/
routes?: Matcher<Context>
/**
* The initial URL to match.
*/
url?: string | Partial<URLDescriptor>
request?: NavigateOptions,
/**
* The initial URL to match.
*/
url?: string | Partial<URLDescriptor>
request?: NavigateOptions
/**
* If provided, this part of any URLs will be ignored. This is useful
* for mounting a Navi app in a subdirectory on a domain.
*/
basename?: string,
/**
* If provided, this part of any URLs will be ignored. This is useful
* for mounting a Navi app in a subdirectory on a domain.
*/
basename?: string
/**
* This will be made available within your matcher through
* the second argument passed to any getter functions.
*/
context?: Context,
/**
* This will be made available within your matcher through
* the second argument passed to any getter functions.
*/
context?: Context
/**
* Configures whether a trailing slash will be added or removed. By default,
* the trailing slash will be removed.
*/
trailingSlash?: 'add' | 'remove' | null
/**
* Configures whether a trailing slash will be added or removed. By default,
* the trailing slash will be removed.
*/
trailingSlash?: 'add' | 'remove' | null
}
export function createMemoryNavigation<Context extends object>(
options: MemoryNavigationOptions<Context>,
) {
let url = options.url || (options.request && options.request.url)
export function createMemoryNavigation<Context extends object>(options: MemoryNavigationOptions<Context>) {
if (options.pages) {
if (process.env.NODE_ENV !== 'production') {
console.warn(
`Deprecation Warning: passing a "pages" option to "createMemoryNavigation()" will `+
`no longer be supported from Navi 0.13. Use the "routes" option instead.`
)
}
options.routes = options.pages
}
if (!url) {
throw new Error(`createMemoryNavigation() could not find a URL.`)
}
let url = options.url || (options.request && options.request.url)
let history = createMemoryHistory({
// The initial entry is ignored, and replaced during the call
// to navigate below.
initialEntries: ['/'],
})
if (!url) {
throw new Error(`createMemoryNavigation() could not find a URL.`)
}
let history = createMemoryHistory({
// The initial entry is ignored, and replaced during the call
// to navigate below.
initialEntries: ['/'],
})
let navigation = new Navigation({
history,
basename: options.basename,
context: options.context,
routes: options.routes!,
trailingSlash: options.trailingSlash,
})
navigation.navigate({
...options.request,
url,
replace: true,
})
return navigation
let navigation = new Navigation({
history,
basename: options.basename,
context: options.context,
routes: options.routes!,
trailingSlash: options.trailingSlash,
})
navigation.navigate({
...options.request,
url,
replace: true,
})
return navigation
}

@@ -5,4 +5,8 @@ import { History, Location } from 'history'

import { resolve } from './resolve'
import { URLDescriptor, createURLDescriptor, modifyTrailingSlash } from './URLTools'
import {
URLDescriptor,
createURLDescriptor,
modifyTrailingSlash,
} from './URLTools'
import {
Observer,

@@ -74,9 +78,9 @@ Observable,

implements Observable<Route> {
private _router: Router<Context>
private _history: History
_history: History
// Stores the last receive location, even if we haven't processed it.
private lastHandledLocation?: Location
private navigationsSinceSteady: number

@@ -106,3 +110,4 @@ private basename?: string

})
this.trailingSlash = options.trailingSlash === undefined ? 'remove' : options.trailingSlash
this.trailingSlash =
options.trailingSlash === undefined ? 'remove' : options.trailingSlash
this.unlisten = this._history.listen(location =>

@@ -113,16 +118,2 @@ this.handleLocationChange(location, false),

get history() {
if (process.env.NODE_ENV !== 'production') {
console.warn(`Deprecation Warning: "navigation.history" will be removed in Navi 0.13. Please use "navigation.navigate()", "navigation.goBack()" or "navigation.goForward()" instead.`)
}
return this._history
}
get router() {
if (process.env.NODE_ENV !== 'production') {
console.warn(`Deprecation Warning: "navigation.router" will be removed in Navi 0.13. Please import and use the "resolve()" or "crawl()" functions instead.`)
}
return this._router
}
dispose() {

@@ -158,7 +149,7 @@ this.observers.length = 0

goBack() {
return this.go(-1)
return this.go(-1)
}
goForward() {
return this.go(1)
return this.go(1)
}

@@ -184,3 +175,5 @@

} else {
throw new Error(`You must specify a URL or state to navigation.navigate().`)
throw new Error(
`You must specify a URL or state to navigation.navigate().`,
)
}

@@ -198,3 +191,3 @@

currentLocation.hash === nextURL.hash)
this._history[shouldReplace ? 'replace' : 'push']({

@@ -240,3 +233,3 @@ pathname: nextURL.pathname,

* Get the latest Route object, regardless of whether it is loading.
*
*
* This is named as `getCurrentValue()` so that Navigation objects can be

@@ -270,3 +263,5 @@ * used with React's `createSubscription()`, and other tools that follow

if (process.env.NODE_ENV !== 'production') {
console.warn('Deprecation Warning: "navigation.getSteadyValue()" will be removed in Navi 0.13. Please use navigation.getRoute() instead.')
console.warn(
'Deprecation Warning: "navigation.getSteadyValue()" will be removed in Navi 0.13. Please use navigation.getRoute() instead.',
)
}

@@ -279,3 +274,5 @@

if (process.env.NODE_ENV !== 'production') {
console.warn('Deprecation Warning: "navigation.steady()" will be removed in Navi 0.13. Please use navigation.getRoute() instead.')
console.warn(
'Deprecation Warning: "navigation.steady()" will be removed in Navi 0.13. Please use navigation.getRoute() instead.',
)
}

@@ -318,6 +315,3 @@

private handleLocationChange(
location: Location,
force?: boolean,
) {
private handleLocationChange(location: Location, force?: boolean) {
if (this.ignoreNextLocationChange) {

@@ -328,4 +322,6 @@ this.ignoreNextLocationChange = false

if (++this.navigationsSinceSteady > MAX_NAVIGATIONS_SINCE_STEADY) {
console.error(`Detected possible navigation loop with ${MAX_NAVIGATIONS_SINCE_STEADY} navigations between steady routes. Bailing.`)
if (++this.navigationsSinceSteady > MAX_NAVIGATIONS_SINCE_STEADY) {
console.error(
`Detected possible navigation loop with ${MAX_NAVIGATIONS_SINCE_STEADY} navigations between steady routes. Bailing.`,
)
return

@@ -337,3 +333,6 @@ }

if (this.trailingSlash !== null) {
let modifiedPathname = modifyTrailingSlash(location.pathname, this.trailingSlash)
let modifiedPathname = modifyTrailingSlash(
location.pathname,
this.trailingSlash,
)
if (location.pathname !== modifiedPathname) {

@@ -354,3 +353,6 @@ this._history.replace({

}
let observable = this._router.createObservable(url, unpackLocationState(location.state))
let observable = this._router.createObservable(
url,
unpackLocationState(location.state),
)
if (observable) {

@@ -388,4 +390,3 @@ this.observableSubscription = observable.subscribe(this.handleChunkList)

this._history.push(chunk.to)
}
else {
} else {
this._history.replace(chunk.to)

@@ -413,3 +414,3 @@ }

}
for (let i = 0; i < this.observers.length; i++) {

@@ -432,14 +433,14 @@ this.observers[i].next(route)

interface RequestDataWithoutState {
method?: string,
body?: string,
headers?: { [name: string]: string },
method?: string
body?: string
headers?: { [name: string]: string }
}
interface RequestData extends RequestDataWithoutState {
// The current `request.state` is stored directly on `window.history.state`.
state?: any,
// The current `request.state` is stored directly on `window.history.state`.
state?: any
}
interface NaviState {
requestDataWithoutState?: RequestDataWithoutState,
requestDataWithoutState?: RequestDataWithoutState
revertTo?: any

@@ -462,3 +463,7 @@ }

function packLocationState({ revertTo, state, ...requestDataWithoutState }: PackLocationStateOptions): any {
function packLocationState({
revertTo,
state,
...requestDataWithoutState
}: PackLocationStateOptions): any {
if (revertTo) {

@@ -475,10 +480,10 @@ revertTo = { ...revertTo }

revertTo,
}
},
}
}
function unpackLocationState(state: any = {}): RequestData {
function unpackLocationState(state: any = {}): RequestData {
let requestDataState = { ...state }
delete requestDataState[NAVI_STATE_KEY]
let naviState: NaviState = state[NAVI_STATE_KEY] || {}
let naviState: NaviState = state[NAVI_STATE_KEY] || {}
return {

@@ -485,0 +490,0 @@ ...naviState.requestDataWithoutState,

@@ -1,5 +0,4 @@

import { Router } from './Router'
import { Crawler } from './Crawler';
import { Crawler } from './Crawler'
export interface NaviRequest<Context extends object=any> {
export interface NaviRequest<Context extends object = any> {
/**

@@ -43,3 +42,3 @@ * The path at which the matcher is mounted.

* Contains the unmatched part of the request URL, as a string.
*
*
* This is a string instead of a URLDescriptor, to be consistent

@@ -73,47 +72,2 @@ * with the Request type for Express.

readonly context: Context
// TODO: these are deprecated, remove in Navi 0.13
readonly mountname?: string
readonly pathname?: string
readonly router: Router<any>
}
export function createRequest<Context extends object=any>(request: NaviRequest<Context>, router?: Router) {
Object.defineProperties(request, {
mountname: {
get: () => {
if (process.env.NODE_ENV !== 'production') {
console.warn(`Deprecation Warning: "request.mountname" will be removed in Navi 0.13. Please use "request.mountpath" instead.`)
}
return request.mountpath
},
},
pathname: {
get: () => {
if (process.env.NODE_ENV !== 'production') {
console.warn(`Deprecation Warning: "request.pathname" will be removed in Navi 0.13. Please use "request.mountpath" instead.`)
}
return request.mountpath
}
},
})
if (router) {
Object.defineProperties(request, {
router: {
get: () => {
if (process.env.NODE_ENV !== 'production') {
console.warn(`Deprecation Warning: "request.router" will be removed in Navi 0.13. Please import and use the "resolve()" or "crawl()" functions instead.`)
}
return router
},
enumerable: false,
},
_router: {
value: router,
},
})
}
return request
}

@@ -10,189 +10,216 @@ import { Matcher, MatcherGenerator } from './Matcher'

import { createURLDescriptor, URLDescriptor } from './URLTools'
import { createRequest } from './NaviRequest'
import { OutOfRootError } from './Errors'
import { Crawler } from './Crawler'
export interface RouterOptions<Context extends object> {
context?: Context,
routes?: Matcher<Context>,
basename?: string,
context?: Context
routes?: Matcher<Context>
basename?: string
}
export interface RouterResolveOptions {
followRedirects?: boolean,
body?: any,
headers?: { [name: string]: string },
method?: string,
url?: string | URLDescriptor,
crawler?: Crawler,
state?: any,
followRedirects?: boolean
body?: any
headers?: { [name: string]: string }
method?: string
url?: string | URLDescriptor
crawler?: Crawler
state?: any
}
export interface RouterMapOptions {
followRedirects?: boolean,
maxDepth?: number,
predicate?: (chunk: Chunk, chunks: Chunk[]) => boolean,
expandPattern?: (pattern: string, router: Router) => undefined | string[] | Promise<undefined | string[]>,
method?: 'GET' | 'HEAD',
headers?: { [name: string]: string },
hostname?: string
followRedirects?: boolean
maxDepth?: number
predicate?: (chunk: Chunk, chunks: Chunk[]) => boolean
expandPattern?: (
pattern: string,
router: Router,
) => undefined | string[] | Promise<undefined | string[]>
method?: 'GET' | 'HEAD'
headers?: { [name: string]: string }
hostname?: string
}
export function createRouter<Context extends object>(options: RouterOptions<Context>){
return new Router(options)
export function createRouter<Context extends object>(
options: RouterOptions<Context>,
) {
return new Router(options)
}
export class Router<Context extends object=any> {
context: Context
private matcherGenerator: MatcherGenerator<Context>
private rootMapping: Mapping
constructor(options: RouterOptions<Context>) {
this.context = options.context || {} as any
this.matcherGenerator = options.routes!()
export class Router<Context extends object = any> {
context: Context
let basename = options.basename
if (basename && basename.slice(-1) === '/') {
basename = basename.slice(0, -1)
}
private matcherGenerator: MatcherGenerator<Context>
private rootMapping: Mapping
this.rootMapping = createRootMapping(options.routes!, basename)
}
constructor(options: RouterOptions<Context>) {
this.context = options.context || ({} as any)
this.matcherGenerator = options.routes!()
// Please don't document this API. It should only be used through
// "createBrowserNavigation()" or "createMemoryNavigation()"
setContext(context: Context) {
this.context = context || {}
let basename = options.basename
if (basename && basename.slice(-1) === '/') {
basename = basename.slice(0, -1)
}
createObservable(url: URLDescriptor, options: RouterResolveOptions): ChunkListObservable | undefined {
let request = createRequest({
body: options.body,
context: this.context,
headers: options.headers || {},
method: options.method || 'GET',
hostname: url.hostname,
hash: url.hash,
mountpath: '/',
params: url.query,
query: url.query,
search: url.search,
router: this,
url: url.pathname+url.search,
originalUrl: url.href,
path: url.pathname,
crawler: options.crawler,
state: options.state || {},
}, this as any)
let matchRequest = matchAgainstPathname(request, this.rootMapping)
if (matchRequest) {
return new ChunkListObservable(
url,
matchRequest,
this.matcherGenerator
)
}
}
this.rootMapping = createRootMapping(options.routes!, basename)
}
createMapObservable(urlOrDescriptor: string | Partial<URLDescriptor>, options: RouterMapOptions = {}): ChunksMapObservable {
return new ChunksMapObservable(
createURLDescriptor(urlOrDescriptor),
this.context,
this.matcherGenerator,
this.rootMapping,
this,
options,
)
// Please don't document this API. It should only be used through
// "createBrowserNavigation()" or "createMemoryNavigation()"
setContext(context: Context) {
this.context = context || {}
}
createObservable(
url: URLDescriptor,
options: RouterResolveOptions,
): ChunkListObservable | undefined {
let request = {
body: options.body,
context: this.context,
headers: options.headers || {},
method: options.method || 'GET',
hostname: url.hostname,
hash: url.hash,
mountpath: '/',
params: url.query,
query: url.query,
search: url.search,
url: url.pathname + url.search,
originalUrl: url.href,
path: url.pathname,
crawler: options.crawler,
state: options.state || {},
}
let matchRequest = matchAgainstPathname(request, this.rootMapping)
if (matchRequest) {
return new ChunkListObservable(url, matchRequest, this.matcherGenerator)
}
}
resolve(url: string | Partial<URLDescriptor> | RouterResolveOptions, options?: RouterResolveOptions): Promise<Route>;
resolve(urls: (string | Partial<URLDescriptor>)[], options?: RouterResolveOptions): Promise<Route[]>;
resolve(urls: string | Partial<URLDescriptor> | (string | Partial<URLDescriptor>)[] | RouterResolveOptions, options: RouterResolveOptions = {}): Promise<Route | Route[]> {
let urlDescriptors: URLDescriptor[]
createMapObservable(
urlOrDescriptor: string | Partial<URLDescriptor>,
options: RouterMapOptions = {},
): ChunksMapObservable {
return new ChunksMapObservable(
createURLDescriptor(urlOrDescriptor),
this.context,
this.matcherGenerator,
this.rootMapping,
this,
options,
)
}
if (Array.isArray(urls)) {
urlDescriptors = urls.map(url => createURLDescriptor(url))
}
else if (typeof urls === 'string') {
urlDescriptors = [createURLDescriptor(urls)]
}
else if ((urls as RouterResolveOptions).url) {
options = urls as RouterResolveOptions
urlDescriptors = [createURLDescriptor(options.url!)]
}
else if (options) {
urlDescriptors = [createURLDescriptor(urls as any)]
}
else {
throw new Error(`You must specify a URL for router.resolve().`)
}
resolve(
url: string | Partial<URLDescriptor> | RouterResolveOptions,
options?: RouterResolveOptions,
): Promise<Route>
resolve(
urls: (string | Partial<URLDescriptor>)[],
options?: RouterResolveOptions,
): Promise<Route[]>
resolve(
urls:
| string
| Partial<URLDescriptor>
| (string | Partial<URLDescriptor>)[]
| RouterResolveOptions,
options: RouterResolveOptions = {},
): Promise<Route | Route[]> {
let urlDescriptors: URLDescriptor[]
if (!urlDescriptors.length) {
return Promise.resolve([])
}
let promises = urlDescriptors.map(url => this.getPageRoutePromise(url, options))
return !Array.isArray(urls) ? promises[0] : Promise.all(promises)
if (Array.isArray(urls)) {
urlDescriptors = urls.map(url => createURLDescriptor(url))
} else if (typeof urls === 'string') {
urlDescriptors = [createURLDescriptor(urls)]
} else if ((urls as RouterResolveOptions).url) {
options = urls as RouterResolveOptions
urlDescriptors = [createURLDescriptor(options.url!)]
} else if (options) {
urlDescriptors = [createURLDescriptor(urls as any)]
} else {
throw new Error(`You must specify a URL for router.resolve().`)
}
resolveSiteMap(urlOrDescriptor: string | Partial<URLDescriptor>, options: RouterMapOptions = {}): Promise<SiteMap<Route>> {
return createPromiseFromObservable(this.createMapObservable(urlOrDescriptor, options)).then(chunksMap => {
let routeMap = {} as RouteMap<Route>
let redirectMap = {} as { [name: string]: string }
let urls = Object.keys(chunksMap)
for (let i = 0; i < urls.length; i++) {
let url = urls[i]
let chunks = chunksMap[url]
let lastChunk = chunks[chunks.length - 1]
if (lastChunk.type === 'redirect') {
redirectMap[url] = lastChunk.to
continue
}
else {
routeMap[url] =
[{ type: 'url', url: createURLDescriptor(url) }]
.concat(chunks)
.reduce(routeReducer, undefined)!
}
}
return {
routes: routeMap,
redirects: redirectMap,
}
})
if (!urlDescriptors.length) {
return Promise.resolve([])
}
resolveRouteMap(urlOrDescriptor: string | Partial<URLDescriptor>, options: RouterMapOptions = {}): Promise<RouteMap<Route>> {
return this.resolveSiteMap(urlOrDescriptor, options).then(siteMap => siteMap.routes)
}
let promises = urlDescriptors.map(url =>
this.getPageRoutePromise(url, options),
)
return !Array.isArray(urls) ? promises[0] : Promise.all(promises)
}
private getPageRoutePromise(url: URLDescriptor, options: RouterResolveOptions): Promise<Route> {
let observable = this.createObservable(url, options)
if (!observable) {
return Promise.reject(new OutOfRootError(url))
resolveSiteMap(
urlOrDescriptor: string | Partial<URLDescriptor>,
options: RouterMapOptions = {},
): Promise<SiteMap<Route>> {
return createPromiseFromObservable(
this.createMapObservable(urlOrDescriptor, options),
).then(chunksMap => {
let routeMap = {} as RouteMap<Route>
let redirectMap = {} as { [name: string]: string }
let urls = Object.keys(chunksMap)
for (let i = 0; i < urls.length; i++) {
let url = urls[i]
let chunks = chunksMap[url]
let lastChunk = chunks[chunks.length - 1]
if (lastChunk.type === 'redirect') {
redirectMap[url] = lastChunk.to
continue
} else {
routeMap[url] = [{ type: 'url', url: createURLDescriptor(url) }]
.concat(chunks)
.reduce(routeReducer, undefined)!
}
}
return {
routes: routeMap,
redirects: redirectMap,
}
})
}
return createPromiseFromObservable(observable).then(chunks => {
for (let i = 0; i < chunks.length; i++) {
let chunk = chunks[i]
if (chunk.type === 'busy') {
break
}
if (chunk.type === 'redirect' && options.followRedirects) {
return this.getPageRoutePromise(createURLDescriptor(chunk.to), options)
}
if (chunk.type === 'error') {
throw chunk.error
}
}
resolveRouteMap(
urlOrDescriptor: string | Partial<URLDescriptor>,
options: RouterMapOptions = {},
): Promise<RouteMap<Route>> {
return this.resolveSiteMap(urlOrDescriptor, options).then(
siteMap => siteMap.routes,
)
}
return (
[{ type: 'url', url: createURLDescriptor(url) }]
.concat(chunks)
.reduce(routeReducer, undefined)!
)
})
private getPageRoutePromise(
url: URLDescriptor,
options: RouterResolveOptions,
): Promise<Route> {
let observable = this.createObservable(url, options)
if (!observable) {
return Promise.reject(new OutOfRootError(url))
}
return createPromiseFromObservable(observable).then(chunks => {
for (let i = 0; i < chunks.length; i++) {
let chunk = chunks[i]
if (chunk.type === 'busy') {
break
}
if (chunk.type === 'redirect' && options.followRedirects) {
return this.getPageRoutePromise(
createURLDescriptor(chunk.to),
options,
)
}
if (chunk.type === 'error') {
throw chunk.error
}
}
return [{ type: 'url', url: createURLDescriptor(url) }]
.concat(chunks)
.reduce(routeReducer, undefined)!
})
}
}

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 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc