Comparing version 0.11.4 to 0.11.5
@@ -46,2 +46,18 @@ "use strict"; | ||
}; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -70,51 +86,63 @@ var Resolvable_1 = require("../Resolvable"); | ||
options = function getRoute(req, context) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var dataPromise, headersPromise, statusPromise, titlePromise, headPromise, viewPromise, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
dataPromise = getData_1 | ||
? Promise.resolve(getData_1(req, context, undefined)) | ||
.then(Resolvable_1.extractDefault) | ||
.then(inputOrEmptyObject) | ||
: Promise.resolve(data_1 || {}); | ||
headersPromise = getHeaders_1 | ||
? Promise.resolve(getHeaders_1(req, context, dataPromise)).then(Resolvable_1.extractDefault) | ||
: Promise.resolve(headers_1); | ||
statusPromise = getStatus_1 | ||
? Promise.resolve(getStatus_1(req, context, dataPromise)).then(Resolvable_1.extractDefault) | ||
: Promise.resolve(status_1); | ||
titlePromise = getTitle_1 | ||
? Promise.resolve(getTitle_1(req, context, dataPromise)).then(Resolvable_1.extractDefault) | ||
: Promise.resolve(title_1); | ||
if (req.method !== 'HEAD') { | ||
headPromise = getHead_1 | ||
? Promise.resolve(getHead_1(req, context, dataPromise)).then(Resolvable_1.extractDefault) | ||
: Promise.resolve(head_1); | ||
viewPromise = getView_1 | ||
? Promise.resolve(getView_1(req, context, dataPromise)).then(Resolvable_1.extractDefault) | ||
: Promise.resolve(view_1); | ||
} | ||
_a = {}; | ||
return [4 /*yield*/, dataPromise]; | ||
case 1: | ||
_a.data = _b.sent(); | ||
return [4 /*yield*/, headPromise]; | ||
case 2: | ||
_a.head = _b.sent(); | ||
return [4 /*yield*/, headersPromise]; | ||
case 3: | ||
_a.headers = _b.sent(); | ||
return [4 /*yield*/, statusPromise]; | ||
case 4: | ||
_a.status = _b.sent(); | ||
return [4 /*yield*/, titlePromise]; | ||
case 5: | ||
_a.title = _b.sent(); | ||
return [4 /*yield*/, viewPromise]; | ||
case 6: return [2 /*return*/, (_a.view = _b.sent(), | ||
_a)]; | ||
} | ||
}); | ||
}); | ||
var _this = this; | ||
var _a, _b; | ||
var _c = __read(extractValue(data_1, getData_1, req, context), 2), dataMaybePromise = _c[0], a = _c[1]; | ||
if (!dataMaybePromise) { | ||
dataMaybePromise = {}; | ||
} | ||
else if (Resolvable_1.isPromiseLike(dataMaybePromise)) { | ||
dataMaybePromise = dataMaybePromise.then(inputOrEmptyObject); | ||
} | ||
var _d = __read(extractValue(headers_1, getHeaders_1, req, context), 2), headersMaybePromise = _d[0], b = _d[1]; | ||
var _e = __read(extractValue(status_1, getStatus_1, req, context), 2), statusMaybePromise = _e[0], c = _e[1]; | ||
var _f = __read(extractValue(title_1, getTitle_1, req, context), 2), titleMaybePromise = _f[0], d = _f[1]; | ||
var headMaybePromise; | ||
var viewMaybePromise; | ||
var e; | ||
var f; | ||
if (req.method !== 'HEAD') { | ||
_a = __read(extractValue(head_1, getHead_1, req, context), 2), headMaybePromise = _a[0], e = _a[1]; | ||
_b = __read(extractValue(view_1, getView_1, req, context), 2), viewMaybePromise = _b[0], f = _b[1]; | ||
} | ||
// If anything is a promise, return a promise | ||
if (a || b || c || d || e || f) { | ||
return (function () { return __awaiter(_this, void 0, void 0, function () { | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_a = {}; | ||
return [4 /*yield*/, dataMaybePromise]; | ||
case 1: | ||
_a.data = _b.sent(); | ||
return [4 /*yield*/, headMaybePromise]; | ||
case 2: | ||
_a.head = _b.sent(); | ||
return [4 /*yield*/, headersMaybePromise]; | ||
case 3: | ||
_a.headers = _b.sent(); | ||
return [4 /*yield*/, statusMaybePromise]; | ||
case 4: | ||
_a.status = _b.sent(); | ||
return [4 /*yield*/, titleMaybePromise]; | ||
case 5: | ||
_a.title = _b.sent(); | ||
return [4 /*yield*/, viewMaybePromise]; | ||
case 6: return [2 /*return*/, (_a.view = _b.sent(), | ||
_a)]; | ||
} | ||
}); | ||
}); })(); | ||
} | ||
// If nothing is a promise, return a synchronous result | ||
else { | ||
return { | ||
data: dataMaybePromise, | ||
head: headMaybePromise, | ||
headers: headersMaybePromise, | ||
status: statusMaybePromise, | ||
title: titleMaybePromise, | ||
view: viewMaybePromise, | ||
}; | ||
} | ||
}; | ||
@@ -128,2 +156,14 @@ } | ||
} | ||
function extractValue(value, getter, request, context) { | ||
if (getter) { | ||
var valueOrPromise = getter(request, context); | ||
if (Resolvable_1.isPromiseLike(valueOrPromise)) { | ||
return [valueOrPromise.then(Resolvable_1.extractDefault), true]; | ||
} | ||
return [valueOrPromise, false]; | ||
} | ||
else { | ||
return [value, false]; | ||
} | ||
} | ||
//# sourceMappingURL=route.js.map |
@@ -116,2 +116,3 @@ "use strict"; | ||
} | ||
exports.isPromiseLike = isPromiseLike; | ||
function extractDefault(value) { | ||
@@ -118,0 +119,0 @@ if (hasDefault(value)) { |
@@ -45,3 +45,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
import { extractDefault } from '../Resolvable'; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
import { extractDefault, isPromiseLike } from '../Resolvable'; | ||
import { compose } from '../utils/compose'; | ||
@@ -68,51 +84,63 @@ import { withContext } from './withContext'; | ||
options = function getRoute(req, context) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var dataPromise, headersPromise, statusPromise, titlePromise, headPromise, viewPromise, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
dataPromise = getData_1 | ||
? Promise.resolve(getData_1(req, context, undefined)) | ||
.then(extractDefault) | ||
.then(inputOrEmptyObject) | ||
: Promise.resolve(data_1 || {}); | ||
headersPromise = getHeaders_1 | ||
? Promise.resolve(getHeaders_1(req, context, dataPromise)).then(extractDefault) | ||
: Promise.resolve(headers_1); | ||
statusPromise = getStatus_1 | ||
? Promise.resolve(getStatus_1(req, context, dataPromise)).then(extractDefault) | ||
: Promise.resolve(status_1); | ||
titlePromise = getTitle_1 | ||
? Promise.resolve(getTitle_1(req, context, dataPromise)).then(extractDefault) | ||
: Promise.resolve(title_1); | ||
if (req.method !== 'HEAD') { | ||
headPromise = getHead_1 | ||
? Promise.resolve(getHead_1(req, context, dataPromise)).then(extractDefault) | ||
: Promise.resolve(head_1); | ||
viewPromise = getView_1 | ||
? Promise.resolve(getView_1(req, context, dataPromise)).then(extractDefault) | ||
: Promise.resolve(view_1); | ||
} | ||
_a = {}; | ||
return [4 /*yield*/, dataPromise]; | ||
case 1: | ||
_a.data = _b.sent(); | ||
return [4 /*yield*/, headPromise]; | ||
case 2: | ||
_a.head = _b.sent(); | ||
return [4 /*yield*/, headersPromise]; | ||
case 3: | ||
_a.headers = _b.sent(); | ||
return [4 /*yield*/, statusPromise]; | ||
case 4: | ||
_a.status = _b.sent(); | ||
return [4 /*yield*/, titlePromise]; | ||
case 5: | ||
_a.title = _b.sent(); | ||
return [4 /*yield*/, viewPromise]; | ||
case 6: return [2 /*return*/, (_a.view = _b.sent(), | ||
_a)]; | ||
} | ||
}); | ||
}); | ||
var _this = this; | ||
var _a, _b; | ||
var _c = __read(extractValue(data_1, getData_1, req, context), 2), dataMaybePromise = _c[0], a = _c[1]; | ||
if (!dataMaybePromise) { | ||
dataMaybePromise = {}; | ||
} | ||
else if (isPromiseLike(dataMaybePromise)) { | ||
dataMaybePromise = dataMaybePromise.then(inputOrEmptyObject); | ||
} | ||
var _d = __read(extractValue(headers_1, getHeaders_1, req, context), 2), headersMaybePromise = _d[0], b = _d[1]; | ||
var _e = __read(extractValue(status_1, getStatus_1, req, context), 2), statusMaybePromise = _e[0], c = _e[1]; | ||
var _f = __read(extractValue(title_1, getTitle_1, req, context), 2), titleMaybePromise = _f[0], d = _f[1]; | ||
var headMaybePromise; | ||
var viewMaybePromise; | ||
var e; | ||
var f; | ||
if (req.method !== 'HEAD') { | ||
_a = __read(extractValue(head_1, getHead_1, req, context), 2), headMaybePromise = _a[0], e = _a[1]; | ||
_b = __read(extractValue(view_1, getView_1, req, context), 2), viewMaybePromise = _b[0], f = _b[1]; | ||
} | ||
// If anything is a promise, return a promise | ||
if (a || b || c || d || e || f) { | ||
return (function () { return __awaiter(_this, void 0, void 0, function () { | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_a = {}; | ||
return [4 /*yield*/, dataMaybePromise]; | ||
case 1: | ||
_a.data = _b.sent(); | ||
return [4 /*yield*/, headMaybePromise]; | ||
case 2: | ||
_a.head = _b.sent(); | ||
return [4 /*yield*/, headersMaybePromise]; | ||
case 3: | ||
_a.headers = _b.sent(); | ||
return [4 /*yield*/, statusMaybePromise]; | ||
case 4: | ||
_a.status = _b.sent(); | ||
return [4 /*yield*/, titleMaybePromise]; | ||
case 5: | ||
_a.title = _b.sent(); | ||
return [4 /*yield*/, viewMaybePromise]; | ||
case 6: return [2 /*return*/, (_a.view = _b.sent(), | ||
_a)]; | ||
} | ||
}); | ||
}); })(); | ||
} | ||
// If nothing is a promise, return a synchronous result | ||
else { | ||
return { | ||
data: dataMaybePromise, | ||
head: headMaybePromise, | ||
headers: headersMaybePromise, | ||
status: statusMaybePromise, | ||
title: titleMaybePromise, | ||
view: viewMaybePromise, | ||
}; | ||
} | ||
}; | ||
@@ -125,2 +153,14 @@ } | ||
} | ||
function extractValue(value, getter, request, context) { | ||
if (getter) { | ||
var valueOrPromise = getter(request, context); | ||
if (isPromiseLike(valueOrPromise)) { | ||
return [valueOrPromise.then(extractDefault), true]; | ||
} | ||
return [valueOrPromise, false]; | ||
} | ||
else { | ||
return [value, false]; | ||
} | ||
} | ||
//# sourceMappingURL=route.js.map |
@@ -110,3 +110,3 @@ var __generator = (this && this.__generator) || function (thisArg, body) { | ||
// so there isn't a better way to check if it's a promise :-( | ||
function isPromiseLike(x) { | ||
export function isPromiseLike(x) { | ||
return !!x && !!x['then']; | ||
@@ -113,0 +113,0 @@ } |
@@ -7,4 +7,9 @@ import { NaviRequest } from './NaviRequest'; | ||
export default function resolveChunks<T>(maybeResolvable: T | Resolvable<T>, request: NaviRequest, context: any, createChunks: (value: T) => Chunk[] | IterableIterator<Chunk[]>): IterableIterator<Chunk[]>; | ||
export declare function isPromiseLike<T>(x: PromiseLike<{ | ||
default: T; | ||
} | T> | T): x is PromiseLike<{ | ||
default: T; | ||
} | T>; | ||
export declare function extractDefault<T>(value: { | ||
default: T; | ||
} | T): T; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("history")):"function"==typeof define&&define.amd?define(["exports","history"],t):t((e=e||self).Navi={},e.History)}(this,function(e,t){"use strict";var r=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},n=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(r(arguments[t]));return e};function o(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(0===e.length)throw new Error("composeMatchers() expects at least one matcher.");return 1===e.length?e[0]:e.reduce(function(e,t){return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return e(t.apply(void 0,n(r)))}})}function i(e,t){return e==t||!(!e||!t)&&(e.pathname==t.pathname&&e.search==t.search&&e.hash==t.hash&&e.state==t.state)}var a=/((((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;function s(e,t){var r,n,o,i,s,l,h=void 0===t?{}:t,f=h.ensureTrailingSlash,p=void 0===f||f,b=h.removeHash,d=void 0!==b&&b;if("string"==typeof e){var y=a.exec(e);if(!y)throw new Error("Couldn't parse the provided URL.");r="",n=y[2]||"",o=u(i=y[6]||""),s=y[7]||""}else r=e.hostname||"",n=e.pathname||"",o=e.query||(e.search?u(e.search):{}),i=e.search||c(o),s=e.hash||"",l=e.state;return p&&n.length&&"/"!==n.substr(-1)&&(n+="/"),{hostname:r,pathname:n,query:o,search:i,hash:d?"":s,href:n+i+s,state:l}}function u(e,t){if(void 0===t&&(t="?"),!e||e[0]!=t)return{};for(var r={},n=e.slice(1).split("&"),o=0,i=n.length;o<i;o++){var a=n[o].split("=");r[a[0]]=a[1]?decodeURIComponent(a[1]):""}return r}function c(e,t){void 0===t&&(t="?");var r=Object.keys(e);if(0===r.length)return"";for(var n=[],o=0,i=r.length;o<i;o++){var a=r[o],s=String(e[a]);n.push(""===s?a:a+"="+encodeURIComponent(s))}return t+n.join("&")}function l(e,t){return t?("/"===e[e.length-1]&&(e=e.substr(0,e.length-1)),"/"===t[0]&&(t=t.substr(1)),e+"/"+t):e}var h,f=(h=function(e,t){return(h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),p=function(e){function t(t){var r=this,n=this.constructor.prototype;return(r=e.call(this,t)||this).__proto__=n,Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(r,r.constructor):Object.defineProperty(r,"stack",{value:(new Error).stack}),Object.defineProperty(r,"message",{value:t}),r}return f(t,e),t}(Error),b=function(e){function t(t){var r=e.call(this,"URL not found: "+t)||this;return r.pathname=t,r.status=404,r.name="NotFoundError",r}return f(t,e),t}(p),d=function(e){function t(t){var r=e.call(this,"URL not managed by router: "+t.href)||this;return r.url=t,r.name="OutOfRootError",r}return f(t,e),t}(p);function y(e,t,r,n){return void 0===n&&(n=!0),Object.assign({type:e,url:s({pathname:t.mountpath,query:t.query},{ensureTrailingSlash:n})},r)}function v(e){var t=l(e.mountpath,e.path);return{type:"error",url:s({pathname:t,query:e.query}),error:new b(t)}}var m=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},w=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function g(e,t,r,n){var o,i,a,s,u,c,h;return m(this,function(f){switch(f.label){case 0:o="function"==typeof e?e:function(){return e};try{i=o(t,r)}catch(e){i=Promise.reject(e)}return(p=i)&&p.then?[3,1]:(a=n(i),[3,7]);case 1:s=i.then(x),u=function(e){var t={};return e.then(function(e){t.value=e,t.outcome="resolved"},function(e){t.error=e,t.outcome="rejected"}),t}(s),c=[y("busy",t,{promise:s})],f.label=2;case 2:return u.outcome?[3,4]:[4,c];case 3:return f.sent(),[3,2];case 4:return"rejected"!==u.outcome?[3,6]:((h=u.error)instanceof b&&!h.pathname&&(h.pathname=l(t.mountpath,t.path)),[4,[y("error",t,{error:h})]]);case 5:return f.sent(),[3,7];case 6:a=n(u.value),f.label=7;case 7:return a?Array.isArray(a)?[4,a.length?a:[]]:[3,9]:[3,11];case 8:return f.sent(),[3,11];case 9:return[5,w(a)];case 10:f.sent(),f.label=11;case 11:return[2]}var p})}function x(e){return function(e){return e&&"object"==typeof e&&"default"in e}(e)?e.default:e}var S=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};function R(e,t,r,n){return void 0===n&&(n=""),e(t,r)}function k(e,t){var r,n,o,i;return S(this,function(a){switch(a.label){case 0:o=[],i=[],a.label=1;case 1:return(r=e.next()).done||(o=r.value||[]),(n=t.next()).done||(i=n.value||[]),[4,o.concat(i)];case 2:a.sent(),a.label=3;case 3:if(!r.done||!n.done)return[3,1];a.label=4;case 4:return[2]}})}var O=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},P=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function j(e,t,r,n){function o(t,o,i){var a,s;return O(this,function(u){switch(u.label){case 0:return a=t.path,i||!a||"/"===a?[3,2]:[4,[v(t)]];case 1:return u.sent(),[3,4];case 2:return s=n&&!n(t)?function(){return O(this,function(e){switch(e.label){case 0:return[4,[]];case 1:return e.sent(),[2]}})}():g(e,t,o,function(e){return r(e,t)}),[5,P(i?k(s,R(i,t,o)):s)];case 3:u.sent(),u.label=4;case 4:return[2]}})}return function(e){return function(r,n){return o(r,n,t?t():e)}}}function E(e,t){return j(e,t,function(e,t){return e?[y("view",t,{view:e})]:[]},function(e){return"HEAD"!==e.method})}var C=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},L=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function U(e){return function(){return function(t,r){return C(this,function(n){switch(n.label){case 0:return[5,L(g(e,t,r,function(e){return R(e(),t,r)}))];case 1:return n.sent(),[2]}})}}}function I(e,t){return Object.defineProperties(t,{mountname:{get:function(){return t.mountpath}},pathname:{get:function(){return t.mountpath}},context:{get:function(){return e}}}),t}var T=function(){return(T=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},M="\0";function D(e,t){var r=e;if(r.length>1&&"/"===r.substr(-1)&&(r=r.substr(0,r.length-1)),"/"!==r[0]&&(r="/"+r),/\/{2,}/.test(r)&&(r=r.replace(/\/{2,}/g,"/")),/^([A-Za-z0-9\$\-_\.+!*'\(\),\/]|\/:)+$/.test(r),0===r.length)throw new Error('You cannot use an empty string "" as a pattern!');for(var n=r.split("/").slice(1),o=[],i=[],a=["^"],s=0;s<n.length;s++){var u=n[s];u.length>1&&":"===u[0]?(o.push(u.slice(1)),i.push(M),a.push("([^/]+)")):(i.push(u),a.push(u.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")))}return{key:i.join("/"),matcher:t,pattern:r,pathParamNames:o.length?o:void 0,regExp:new RegExp(a.join("/"))}}function G(e,t,r){var n=t.regExp.exec(e.path);if(n){var o=n[0],i=e.params;if(t.pathParamNames){i=T({},e.params);for(var a=0;a<t.pathParamNames.length;a++){i[t.pathParamNames[a]]=n[a+1]}}var s=e.path.slice(o.length)||"/",u=l(e.mountpath,o);return I(r,T({},e,{params:i,mountpath:u,path:s,url:s+e.search}))}}var q=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};function H(e){if(!e)throw new Error("mount() must be supplied with a paths object.");var t=Object.keys(e),r=t.map(function(t){return D(t,e[t])}).sort(function(e,t){return r=e.key,n=t.key,r<n?-1:r>n?1:0;var r,n});return function(){return function(e,n){var o,i,a,s,u,c,l;return q(this,function(h){switch(h.label){case 0:for(s=r.length-1;s>=0;s--)if(u=r[s],c=G(e,u,n)){i=R(u.matcher(),c,n,u.pattern);break}h.label=1;case 1:return!i||a&&a.done||(a=i.next()),o=[y("mount",e,{patterns:t},!1)],(l=a&&a.value)?o=o.concat(l.length?l:[]):o.push(v(e)),[4,o];case 2:h.sent(),h.label=3;case 3:if(o.filter(_).length)return[3,1];h.label=4;case 4:return[2]}})}}}function _(e){return"busy"===e.type}function N(e){return j(e,void 0,function(e,t){var r,n=t.path;return n&&"/"!==n?[v(t)]:("string"==typeof e?r="./"===e.slice(0,2)?l(t.mountpath.split("/").slice(0,-1).join("/"),e.slice(2)):e:e&&(r=s(e).href),r?[y("redirect",t,{to:r})]:[])})}var A=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},V=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function Q(e,t){return function(r){return function(n,o){return function(t,r,n){return A(this,function(o){switch(o.label){case 0:return[5,V(g(e,t,r,function(e){return R(n,t,e||{})}))];case 1:return o.sent(),[2]}})}(n,o,t?t():r)}}}function F(e,t){return j(e,t,function(e,t){return e?[y("data",t,{data:e})]:[]})}function $(e,t){return j(e,t,function(e,t){return e?[y("title",t,{title:e})]:[]})}var z=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},B=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},Y=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&(r[n[o]]=e[n[o]])}return r},Z=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function J(e){return function(t,r){return z(this,void 0,void 0,function(){var n,o,i,a;return B(this,function(s){switch(s.label){case 0:return n=e.getMeta?Promise.resolve(e.getMeta(t,r,void 0)).then(x).then(K):Promise.resolve(e.meta||{}),o=e.getTitle?Promise.resolve(e.getTitle(t,r,n)).then(x):Promise.resolve(e.title),"HEAD"!==t.method&&(i=e.getContent?Promise.resolve(e.getContent(t,r,n)).then(x):Promise.resolve(e.content)),a={},[4,n];case 1:return a.meta=s.sent(),[4,i];case 2:return a.content=s.sent(),[4,o];case 3:return[2,(a.title=s.sent(),a)]}})})}}function K(e){return e||{}}function W(e,t){return j(e,t,function(e,t){return e?[y("head",t,{head:e})]:[]},function(e){return"HEAD"!==e.method})}function X(e,t){return j(e,t,function(e,t){return e?[y("headers",t,{headers:e})]:[]})}function ee(e,t){return j(e,t,function(e,t){return e?[y("status",t,{status:e})]:[]})}var te=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},re=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},ne=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&(r[n[o]]=e[n[o]])}return r};function oe(e){return e||{}}var ie=function(){function e(e,t){this.close=e,this.observer=t,this.observer.start&&this.observer.start(this)}return e.prototype.unsubscribe=function(){this.closed||(this.closed=!0,this.close(this.observer),delete this.close,delete this.observer)},e}();function ae(e,t,r){return"function"==typeof e?{next:e,error:t,complete:r}:e}function se(e){return new Promise(function(t,r){e.subscribe({start:function(e){this.subscription=e},next:function(e){this.value=e},complete:function(){t(this.value),this.subscription.unsubscribe()},error:function(e){r(e),this.subscription.unsubscribe()}})})}var ue=function(){function e(e,t,r,n){var o=this;this.handleUnsubscribe=function(e){var t=o.observers.indexOf(e);-1!==t&&o.observers.splice(t,1)},this.handleChange=function(e){if(e===o.lastListenId){o.lastListenId++,o.refresh();for(var t=o.result.done||o.result.value.every(function(e){return"busy"!==e.type}),r=0;r<o.observers.length;r++){var n=o.observers[r];n.next(o.result.value),t&&n.complete&&n.complete()}t&&delete o.matcherIterator}},this.refresh=function(){var e=o.matcherIterator.next();if(e.value&&(o.result=e),!o.result.done){var t=++o.lastListenId,r=function(){return o.handleChange(t)};Promise.race(o.result.value.filter(ce).map(le)).then(r,r)}},this.url=e,this.lastListenId=0,this.observers=[],this.matcherIterator=n(t,r)}return e.prototype.subscribe=function(e,t,r){if(!this.matcherIterator)throw new Error("Can't subscribe to an already-complete RoutingObservable.");var n=ae(e,t,r);this.observers.push(n);var o=new ie(this.handleUnsubscribe,n);return 1===this.observers.length&&this.handleChange(this.lastListenId),o},e}();function ce(e){return"busy"===e.type}function le(e){return e.promise}var he=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},fe=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},pe=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},be=function(){function e(e,t,r,n,o,i){var a=this;this.handleUnsubscribe=function(e){var t=a.observers.indexOf(e);-1!==t&&a.observers.splice(t,1)},this.handleResolverUpdate=function(e){e===a.lastListenId&&(a.lastListenId++,a.isRefreshing?a.isRefreshScheduled||(a.isRefreshScheduled=!0):a.refresh())},this.refresh=function(){return he(a,void 0,void 0,function(){var e,t,r,n,o,i,a,s,u,c,h,f,p,b,d,y,v,m,w=this;return fe(this,function(g){switch(g.label){case 0:this.isRefreshScheduled=!1,this.isRefreshing=!0,e=[],t=0,r=function(){var r,o,i,a,s,u,c,h,f,p,b;return fe(this,function(d){switch(d.label){case 0:r=n.mapItems[t],o=r.pathname,i=r.matcherIterator.next(),r.lastResult&&!i.value||(r.lastResult=i),a=r.lastResult.value,r.chunksCache=a||[],s=a.findIndex(function(e){return"error"===e.type||e.url.href.length>=r.url.href.length&&("mount"===e.type&&r.lastMountPatterns!==e.patterns||"redirect"===e.type&&r.lastRedirectTo!==e.to)}),d.label=1;case 1:if(!(s>=0&&s<a.length))return[3,6];if(u=a[s],s++,"error"===u.type||n.options.predicate&&!n.options.predicate(u,a))return n.removeFromQueue(r),[2,"continue-items"];if("redirect"===u.type&&(r.lastRedirectTo=u.to,n.options.followRedirects&&n.addToQueue(u.to,r.depth+1,r.walkedPatternLists,o,r.order)),"mount"!==u.type)return[3,5];if(c=u.patterns,r.lastMountPatterns=c,h=c.slice(0).sort().join("\n"),!c||r.walkedPatternLists.has(h))return[3,5];r.walkedPatternLists.add(h),f=0,d.label=2;case 2:return f<c.length?[4,n.expandPatterns(l(o,c[f]))]:[3,5];case 3:for(p=d.sent(),b=0;b<p.length;b++)n.addToQueue(p[b],r.depth+1,r.walkedPatternLists,o,r.order.concat(f,b));d.label=4;case 4:return f++,[3,2];case 5:return[3,1];case 6:return a&&(e=e.concat(a)),t++,[2]}})},n=this,g.label=1;case 1:return this.mapItems&&t<this.mapItems.length?[5,r()]:[3,3];case 2:switch(g.sent()){case"continue-items":return[3,1]}return[3,1];case 3:if(!this.mapItems)return[2];for(o=[],i=0;i<this.mapItems.length;i++)a=this.mapItems[i],"mount"===(s=a.chunksCache[a.chunksCache.length-1]).type||"error"===s.type||"busy"!==s.type&&this.options.predicate&&!this.options.predicate(s,a.chunksCache)||o.push([l(a.pathname,"/"),a.chunksCache,a.order]);if(u=++this.lastListenId,c=function(){return w.handleResolverUpdate(u)},Promise.race(e.filter(de).map(ye)).then(c,c),o.sort(function(e,t){var r=e[2],n=t[2];if(r.length<n.length)return-1;if(r.length>n.length)return 1;for(var o=0;o<r.length;o++){if(r[o]<n[o])return-1;if(r[o]>n[o])return 1}return 0}),this.isRefreshScheduled)this.refresh();else{for(h={},f=!0,p=0;p<o.length;p++)b=pe(o[p],2),d=b[0],(y=b[1]).some(function(e){return"busy"===e.type})&&(f=!1),h[d]=y;for(v=0;v<this.observers.length;v++)(m=this.observers[v]).next(h),f&&m.complete&&m.complete();f&&(delete this.rootContext,delete this.mapItems,delete this.router,delete this.observers),this.isRefreshing=!1}return[2]}})})},this.observers=[],this.lastListenId=0,this.mapItems=[],this.router=o,this.rootContext=t,this.matcherGeneratorFunction=r,this.rootMapping=n,this.options=i,this.seenPathnames=new Set;var s=e.pathname;"/"===s.substr(-1)&&(s=s.substr(0,s.length-1)),this.addToQueue(s,0,new Set)}return e.prototype.subscribe=function(e,t,r){if(!this.observers)throw new Error("Can't subscribe to an already-complete RoutingObservable.");var n=ae(e,t,r);this.observers.push(n);var o=new ie(this.handleUnsubscribe,n);return 1===this.observers.length&&this.refresh(),o},e.prototype.expandPatterns=function(e){return he(this,void 0,void 0,function(){var t;return fe(this,function(r){switch(r.label){case 0:return this.options.expandPattern?[4,this.options.expandPattern(e,this.router)]:[3,2];case 1:if(t=r.sent())return[2,t];r.label=2;case 2:return[2,[e].filter(function(e){return!/\/:/.test(e)})]}})})},e.prototype.removeFromQueue=function(e){var t=this.mapItems.indexOf(e);-1!==t&&this.mapItems.splice(t,1)},e.prototype.addToQueue=function(e,t,r,n,o){if(void 0===o&&(o=[0]),!this.seenPathnames.has(e)&&(!this.options.maxDepth||t<=this.options.maxDepth)){this.seenPathnames.add(e);var i=s(e,{ensureTrailingSlash:!1,removeHash:!0}),a=G(I(this.rootContext,{body:null,headers:this.options.headers||{},method:this.options.method||"HEAD",params:{},hostname:this.options.hostname||"",mountpath:"",query:i.query,search:i.search,router:this.router,path:i.pathname,url:i.pathname+i.search,originalUrl:i.href}),this.rootMapping,this.rootContext);a&&this.mapItems.push({url:i,fromPathname:n,depth:t,pathname:e,order:o,walkedPatternLists:new Set(r),matcherIterator:this.matcherGeneratorFunction(a,this.rootContext)})}},e}();function de(e){return"busy"===e.type}function ye(e){return e.promise}var ve=function(){return(ve=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function me(e,t){return e=function(e,t){if(e){if("url"===t.type)return ve({},e,{chunks:e.chunks.filter(function(e){return"url"!==e.type}),url:t.url});if("ready"!==e.type)return e}var r={lastChunk:t,chunks:e?e.chunks.concat(t):[t],data:e?e.data:{},headers:e?e.headers:{},heads:e?e.heads:[],status:e?e.status:200,title:e&&e.title,url:e?e.url:t.url,views:e?e.views:[]};switch(t.type){case"busy":return ve({},r,{type:"busy"});case"data":return ve({},r,{type:"ready",data:ve({},r.data,t.data)});case"error":return ve({},r,{type:"error",error:t.error,status:r.status&&r.status>=400?r.status:t.error.status||500});case"head":return ve({},r,{type:"ready",heads:r.heads.concat(t.head)});case"headers":return ve({},r,{type:"ready",headers:ve({},r.headers,t.headers)});case"redirect":return ve({},r,{type:"redirect",to:t.to});case"status":return ve({},r,{type:"ready",status:t.status});case"title":return ve({},r,{type:"ready",title:t.title});case"view":return ve({},r,{type:"ready",views:r.views.concat(t.view)});default:return ve({},r,{type:"ready"})}}(e,t),Object.defineProperties(e,{meta:{configurable:!0,get:function(){return e.data}},content:{configurable:!0,get:function(){return t.view}},segments:{configurable:!0,get:function(){return e.chunks}},lastSegment:{configurable:!0,get:function(){return e.lastChunk}}}),e}var we=function(){function e(e){this.context=e.context||{},this.matcherGenerator=e.routes(),this.reducer=e.reducer||me;var t,r,n=e.basename;n&&"/"===n.slice(-1)&&(n=n.slice(0,-1)),this.rootMapping=(t=e.routes,void 0===(r=n)&&(r=""),""!==r?D(r,t):{pattern:r,key:"",regExp:new RegExp(""),matcher:t})}return e.prototype.setContext=function(e){this.context=e||{}},e.prototype.createObservable=function(e,t){void 0===t&&(t={}),e.hash&&delete(e=Object.assign({},e)).hash;var r=G(I(this.context,{body:t.body,headers:t.headers||{},method:t.method||"GET",hostname:e.hostname,mountpath:"",params:e.query,query:e.query,search:e.search,router:this,url:e.pathname+e.search,originalUrl:e.href,path:e.pathname}),this.rootMapping,this.context);if(r)return new ue(e,r,this.context,this.matcherGenerator)},e.prototype.createMapObservable=function(e,t){return void 0===t&&(t={}),new be(s(e,{ensureTrailingSlash:!1}),this.context,this.matcherGenerator,this.rootMapping,this,t)},e.prototype.resolve=function(e,t){var r,n=this;if(void 0===t&&(t={}),Array.isArray(e))r=e.map(function(e){return s(e)});else if("string"==typeof e)r=[s(e)];else if(e.url)r=[s((t=e).url)];else{if(!t)throw new Error("You must specify a URL for router.resolve().");r=[s(e)]}if(!r.length)return Promise.resolve([]);var o=r.map(function(e){return n.getPageRoutePromise(e,t)});return Array.isArray(e)?Promise.all(o):o[0]},e.prototype.resolveSiteMap=function(e,t){var r=this;return void 0===t&&(t={}),se(this.createMapObservable(e,t)).then(function(e){for(var t={},n={},o=Object.keys(e),i=0;i<o.length;i++){var a=o[i],u=e[a],c=u[u.length-1];"redirect"!==c.type?t[a]=[{type:"url",url:s(a)}].concat(u).reduce(r.reducer,void 0):n[a]=c.to}return{routes:t,redirects:n}})},e.prototype.resolveRouteMap=function(e,t){return void 0===t&&(t={}),this.resolveSiteMap(e,t).then(function(e){return e.routes})},e.prototype.getPageRoutePromise=function(e,t){var r=this,n=this.createObservable(e,t);return n?se(n).then(function(n){for(var o=0;o<n.length;o++){var i=n[o];if("busy"===i.type)break;if("redirect"===i.type&&t.followRedirects)return r.getPageRoutePromise(s(i.to),t);if("error"===i.type)throw i.error}return[{type:"url",url:s(e)}].concat(n).reduce(r.reducer,void 0)}):Promise.reject(new d(e))},e}(),ge=function(){return function(){this.promise=new Promise(function(e,t){this.resolve=e,this.reject=t}.bind(this)),Object.freeze(this)}}(),xe=function(){return(xe=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},Se=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},Re=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},ke=function(){function e(e,t,r,n){var o=this;this.handleUnsubscribe=function(e){var t=o.observers.indexOf(e);-1!==t&&o.observers.splice(t,1)},this.handleChunkList=function(e){for(var t=!0,r=0;r<e.length;r++){var n=e[r];if("busy"===n.type&&(t=!1),"redirect"===n.type)return void o.history.replace(n.to)}o.setRoute([{type:"url",url:o.lastURL}].concat(e).reduce(o.reducer,void 0),t)},this.observers=[],this.isLastRouteSteady=!1,this.router=t,this.history=e,this.reducer=r,this.resolveOptions=n,this.lastURL=s(this.history.location),this.unlisten=this.history.listen(function(e){return o.handleURLChange(s(e))}),this.refresh()}return e.prototype.dispose=function(){this.observers.length=0,this.unlisten(),delete this.unlisten,delete this.history,this.observableSubscription&&this.observableSubscription.unsubscribe(),delete this.observableSubscription,delete this.router,delete this.waitUntilSteadyDeferred,delete this.lastRoute},e.prototype.refresh=function(){this.handleURLChange(s(this.history.location),!0)},e.prototype.setContext=function(e){this.router.setContext(e),this.refresh()},e.prototype.getValue=function(){return this.lastRoute},e.prototype.getSteadyRoute=function(){return Se(this,void 0,void 0,function(){return Re(this,function(e){return this.isLastRouteSteady?[2,Promise.resolve(this.lastRoute)]:(this.waitUntilSteadyDeferred||(this.waitUntilSteadyDeferred=new ge),[2,this.waitUntilSteadyDeferred.promise])})})},e.prototype.subscribe=function(e,t,r){var n=ae(e,t,r);return this.observers.push(n),new ie(this.handleUnsubscribe,n)},e.prototype.handleURLChange=function(e,t){if(!t&&this.lastReceivedURL&&i(this.lastReceivedURL,e))for(var r=0;r<this.observers.length;r++)this.observers[r].next(this.lastRoute);else{if(this.lastReceivedURL=e,"/"!==e.pathname.substr(-1))return e=xe({},e,{pathname:e.pathname+"/"}),void this.history.replace(e);var n,o,a=this.lastURL;if(this.lastURL=e,e&&a&&(n=e.pathname!==a.pathname,o=e.search!==a.search),t||n||o||!this.lastRoute){this.observableSubscription&&this.observableSubscription.unsubscribe();var s=this.router.createObservable(e,this.resolveOptions);if(s)this.observableSubscription=s.subscribe(this.handleChunkList);else if(!a)throw new d(e)}else e.hash!==a.hash&&this.setRoute(this.reducer(this.lastRoute,{type:"url",url:e}),this.isLastRouteSteady)}},e.prototype.setRoute=function(e,t){if(e!==this.lastRoute){this.lastRoute=e,this.isLastRouteSteady=t,t&&this.waitUntilSteadyDeferred&&(this.waitUntilSteadyDeferred.resolve(e),delete this.waitUntilSteadyDeferred);for(var r=0;r<this.observers.length;r++)this.observers[r].next(e)}},e}(),Oe=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},Pe=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};var je=function(){function e(e){e.pages&&(e.routes=e.pages);var r=e.reducer||me;this.history=e.history||t.createBrowserHistory(),this.router=new we({context:e.context,routes:e.routes,basename:e.basename,reducer:r}),this.currentRouteObservable=new ke(this.history,this.router,r)}return e.prototype.dispose=function(){this.currentRouteObservable.dispose(),delete this.currentRouteObservable,delete this.router,delete this.history},e.prototype.setContext=function(e){this.currentRouteObservable.setContext(e)},e.prototype.getCurrentValue=function(){return this.currentRouteObservable.getValue()},e.prototype.getSteadyValue=function(){return this.currentRouteObservable.getSteadyRoute()},e.prototype.steady=function(){return Oe(this,void 0,void 0,function(){return Pe(this,function(e){switch(e.label){case 0:return[4,this.getSteadyValue()];case 1:return e.sent(),[2]}})})},e.prototype.subscribe=function(e,t,r){var n=ae(e,t,r);return this.currentRouteObservable.subscribe(n)},e}(),Ee=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},Ce=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};var Le=function(){function e(e){e.pages&&(e.routes=e.pages);var r=e.reducer||me,n=e.url||e.request&&e.request.url;if(!n)throw new Error("createMemoriNavigation() could not find a URL.");this.history=t.createMemoryHistory({initialEntries:[s(n).href]}),this.options=e,this.router=new we({context:e.context,routes:this.options.routes||this.options.pages,basename:this.options.basename,reducer:r}),this.currentRouteObservable=new ke(this.history,this.router,r,e.request)}return e.prototype.dispose=function(){this.currentRouteObservable.dispose(),delete this.currentRouteObservable,delete this.router,delete this.options},e.prototype.setContext=function(e){this.currentRouteObservable.setContext(e)},e.prototype.getCurrentValue=function(){return this.currentRouteObservable.getValue()},e.prototype.getSteadyValue=function(){return this.currentRouteObservable.getSteadyRoute()},e.prototype.steady=function(){return Ee(this,void 0,void 0,function(){return Ce(this,function(e){switch(e.label){case 0:return[4,this.getSteadyValue()];case 1:return e.sent(),[2]}})})},e.prototype.subscribe=function(e,t,r){var n=ae(e,t,r);return this.currentRouteObservable.subscribe(n)},e}();e.compose=o,e.Router=we,e.createRouter=function(e){return new we(e)},e.defaultRouteReducer=me,e.concatMatcherIterators=k,e.resolveChunks=g,e.createBrowserNavigation=function(e){return new je(e)},e.BrowserNavigation=je,e.createMemoryNavigation=function(e){return new Le(e)},e.MemoryNavigation=Le,e.lazy=U,e.map=U,e.createPage=function(e){return Object.assign(o(Q(J(e)),F(function(e,t){return t.meta}),$(function(e,t){return t.title}),E(function(e,t){return t.content})),{isDeprecatedMatcher:!0})},e.createContext=function(e,t){return Object.assign(Q(e,t.isDeprecatedMatcher?t:U(t)),{isDeprecatedMatcher:!0})},e.createSwitch=function(e){var t,r,n={};try{for(var i=Z(Object.keys(e.paths)),a=i.next();!a.done;a=i.next()){var s=a.value,u=e.paths[s];n[s]=u.isDeprecatedMatcher?u:U(u)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}if(1===Object.keys(e).length)return Object.assign(H(n),{isDeprecatedMatcher:!0});e.paths;var c=Y(e,["paths"]);return Object.assign(o(Q(J(c)),F(function(e,t){return t.meta}),$(function(e,t){return t.title}),E(function(e,t){return t.content}),H(n)),{isDeprecatedMatcher:!0})},e.createRedirect=function(e,t){var r=N(e);return t?o(F(t),r):Object.assign(r,{isDeprecatedMatcher:!0})},e.mount=H,e.redirect=N,e.route=function(e){if(void 0===e&&(e={}),"function"!=typeof e){var t=e.data,r=e.getData,n=e.head,i=e.getHead,a=e.headers,s=e.getHeaders,u=e.status,c=e.getStatus,l=e.title,h=e.getTitle,f=e.view,p=e.getView;ne(e,["data","getData","head","getHead","headers","getHeaders","status","getStatus","title","getTitle","view","getView"]),e=function(e,o){return te(this,void 0,void 0,function(){var b,d,y,v,m,w,g;return re(this,function(S){switch(S.label){case 0:return b=r?Promise.resolve(r(e,o,void 0)).then(x).then(oe):Promise.resolve(t||{}),d=s?Promise.resolve(s(e,o,b)).then(x):Promise.resolve(a),y=c?Promise.resolve(c(e,o,b)).then(x):Promise.resolve(u),v=h?Promise.resolve(h(e,o,b)).then(x):Promise.resolve(l),"HEAD"!==e.method&&(m=i?Promise.resolve(i(e,o,b)).then(x):Promise.resolve(n),w=p?Promise.resolve(p(e,o,b)).then(x):Promise.resolve(f)),g={},[4,b];case 1:return g.data=S.sent(),[4,m];case 2:return g.head=S.sent(),[4,d];case 3:return g.headers=S.sent(),[4,y];case 4:return g.status=S.sent(),[4,v];case 5:return g.title=S.sent(),[4,w];case 6:return[2,(g.view=S.sent(),g)]}})})}}return o(Q(e),F(function(e,t){return t.data}),W(function(e,t){return t.head}),X(function(e,t){return t.headers}),ee(function(e,t){return t.status}),$(function(e,t){return t.title}),E(function(e,t){return t.view}))},e.withContext=Q,e.withData=F,e.withHead=W,e.withHeaders=X,e.withStatus=ee,e.withTitle=$,e.withView=E,e.NaviError=p,e.NotFoundError=b,e.OutOfRootError=d,e.createRequest=I,e.createChunk=y,e.createNotFoundChunk=v,e.areURLDescriptorsEqual=i,e.createURLDescriptor=s,e.parseQuery=u,e.stringifyQuery=c,e.joinPaths=l,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("history")):"function"==typeof define&&define.amd?define(["exports","history"],t):t((e=e||self).Navi={},e.History)}(this,function(e,t){"use strict";var r=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},n=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(r(arguments[t]));return e};function o(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(0===e.length)throw new Error("composeMatchers() expects at least one matcher.");return 1===e.length?e[0]:e.reduce(function(e,t){return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return e(t.apply(void 0,n(r)))}})}function i(e,t){return e==t||!(!e||!t)&&(e.pathname==t.pathname&&e.search==t.search&&e.hash==t.hash&&e.state==t.state)}var a=/((((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;function u(e,t){var r,n,o,i,u,l,h=void 0===t?{}:t,f=h.ensureTrailingSlash,p=void 0===f||f,b=h.removeHash,d=void 0!==b&&b;if("string"==typeof e){var y=a.exec(e);if(!y)throw new Error("Couldn't parse the provided URL.");r="",n=y[2]||"",o=s(i=y[6]||""),u=y[7]||""}else r=e.hostname||"",n=e.pathname||"",o=e.query||(e.search?s(e.search):{}),i=e.search||c(o),u=e.hash||"",l=e.state;return p&&n.length&&"/"!==n.substr(-1)&&(n+="/"),{hostname:r,pathname:n,query:o,search:i,hash:d?"":u,href:n+i+u,state:l}}function s(e,t){if(void 0===t&&(t="?"),!e||e[0]!=t)return{};for(var r={},n=e.slice(1).split("&"),o=0,i=n.length;o<i;o++){var a=n[o].split("=");r[a[0]]=a[1]?decodeURIComponent(a[1]):""}return r}function c(e,t){void 0===t&&(t="?");var r=Object.keys(e);if(0===r.length)return"";for(var n=[],o=0,i=r.length;o<i;o++){var a=r[o],u=String(e[a]);n.push(""===u?a:a+"="+encodeURIComponent(u))}return t+n.join("&")}function l(e,t){return t?("/"===e[e.length-1]&&(e=e.substr(0,e.length-1)),"/"===t[0]&&(t=t.substr(1)),e+"/"+t):e}var h,f=(h=function(e,t){return(h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),p=function(e){function t(t){var r=this,n=this.constructor.prototype;return(r=e.call(this,t)||this).__proto__=n,Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(r,r.constructor):Object.defineProperty(r,"stack",{value:(new Error).stack}),Object.defineProperty(r,"message",{value:t}),r}return f(t,e),t}(Error),b=function(e){function t(t){var r=e.call(this,"URL not found: "+t)||this;return r.pathname=t,r.status=404,r.name="NotFoundError",r}return f(t,e),t}(p),d=function(e){function t(t){var r=e.call(this,"URL not managed by router: "+t.href)||this;return r.url=t,r.name="OutOfRootError",r}return f(t,e),t}(p);function y(e,t,r,n){return void 0===n&&(n=!0),Object.assign({type:e,url:u({pathname:t.mountpath,query:t.query},{ensureTrailingSlash:n})},r)}function v(e){var t=l(e.mountpath,e.path);return{type:"error",url:u({pathname:t,query:e.query}),error:new b(t)}}var m=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},w=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function g(e,t,r,n){var o,i,a,u,s,c,h;return m(this,function(f){switch(f.label){case 0:o="function"==typeof e?e:function(){return e};try{i=o(t,r)}catch(e){i=Promise.reject(e)}return x(i)?[3,1]:(a=n(i),[3,7]);case 1:u=i.then(S),s=function(e){var t={};return e.then(function(e){t.value=e,t.outcome="resolved"},function(e){t.error=e,t.outcome="rejected"}),t}(u),c=[y("busy",t,{promise:u})],f.label=2;case 2:return s.outcome?[3,4]:[4,c];case 3:return f.sent(),[3,2];case 4:return"rejected"!==s.outcome?[3,6]:((h=s.error)instanceof b&&!h.pathname&&(h.pathname=l(t.mountpath,t.path)),[4,[y("error",t,{error:h})]]);case 5:return f.sent(),[3,7];case 6:a=n(s.value),f.label=7;case 7:return a?Array.isArray(a)?[4,a.length?a:[]]:[3,9]:[3,11];case 8:return f.sent(),[3,11];case 9:return[5,w(a)];case 10:f.sent(),f.label=11;case 11:return[2]}})}function x(e){return!!e&&!!e.then}function S(e){return function(e){return e&&"object"==typeof e&&"default"in e}(e)?e.default:e}var R=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};function k(e,t,r,n){return void 0===n&&(n=""),e(t,r)}function O(e,t){var r,n,o,i;return R(this,function(a){switch(a.label){case 0:o=[],i=[],a.label=1;case 1:return(r=e.next()).done||(o=r.value||[]),(n=t.next()).done||(i=n.value||[]),[4,o.concat(i)];case 2:a.sent(),a.label=3;case 3:if(!r.done||!n.done)return[3,1];a.label=4;case 4:return[2]}})}var P=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},j=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function E(e,t,r,n){function o(t,o,i){var a,u;return P(this,function(s){switch(s.label){case 0:return a=t.path,i||!a||"/"===a?[3,2]:[4,[v(t)]];case 1:return s.sent(),[3,4];case 2:return u=n&&!n(t)?function(){return P(this,function(e){switch(e.label){case 0:return[4,[]];case 1:return e.sent(),[2]}})}():g(e,t,o,function(e){return r(e,t)}),[5,j(i?O(u,k(i,t,o)):u)];case 3:s.sent(),s.label=4;case 4:return[2]}})}return function(e){return function(r,n){return o(r,n,t?t():e)}}}function C(e,t){return E(e,t,function(e,t){return e?[y("view",t,{view:e})]:[]},function(e){return"HEAD"!==e.method})}var L=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},U=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function I(e){return function(){return function(t,r){return L(this,function(n){switch(n.label){case 0:return[5,U(g(e,t,r,function(e){return k(e(),t,r)}))];case 1:return n.sent(),[2]}})}}}function T(e,t){return Object.defineProperties(t,{mountname:{get:function(){return t.mountpath}},pathname:{get:function(){return t.mountpath}},context:{get:function(){return e}}}),t}var M=function(){return(M=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},D="\0";function G(e,t){var r=e;if(r.length>1&&"/"===r.substr(-1)&&(r=r.substr(0,r.length-1)),"/"!==r[0]&&(r="/"+r),/\/{2,}/.test(r)&&(r=r.replace(/\/{2,}/g,"/")),/^([A-Za-z0-9\$\-_\.+!*'\(\),\/]|\/:)+$/.test(r),0===r.length)throw new Error('You cannot use an empty string "" as a pattern!');for(var n=r.split("/").slice(1),o=[],i=[],a=["^"],u=0;u<n.length;u++){var s=n[u];s.length>1&&":"===s[0]?(o.push(s.slice(1)),i.push(D),a.push("([^/]+)")):(i.push(s),a.push(s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")))}return{key:i.join("/"),matcher:t,pattern:r,pathParamNames:o.length?o:void 0,regExp:new RegExp(a.join("/"))}}function q(e,t,r){var n=t.regExp.exec(e.path);if(n){var o=n[0],i=e.params;if(t.pathParamNames){i=M({},e.params);for(var a=0;a<t.pathParamNames.length;a++){i[t.pathParamNames[a]]=n[a+1]}}var u=e.path.slice(o.length)||"/",s=l(e.mountpath,o);return T(r,M({},e,{params:i,mountpath:s,path:u,url:u+e.search}))}}var H=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};function _(e){if(!e)throw new Error("mount() must be supplied with a paths object.");var t=Object.keys(e),r=t.map(function(t){return G(t,e[t])}).sort(function(e,t){return r=e.key,n=t.key,r<n?-1:r>n?1:0;var r,n});return function(){return function(e,n){var o,i,a,u,s,c,l;return H(this,function(h){switch(h.label){case 0:for(u=r.length-1;u>=0;u--)if(s=r[u],c=q(e,s,n)){i=k(s.matcher(),c,n,s.pattern);break}h.label=1;case 1:return!i||a&&a.done||(a=i.next()),o=[y("mount",e,{patterns:t},!1)],(l=a&&a.value)?o=o.concat(l.length?l:[]):o.push(v(e)),[4,o];case 2:h.sent(),h.label=3;case 3:if(o.filter(N).length)return[3,1];h.label=4;case 4:return[2]}})}}}function N(e){return"busy"===e.type}function A(e){return E(e,void 0,function(e,t){var r,n=t.path;return n&&"/"!==n?[v(t)]:("string"==typeof e?r="./"===e.slice(0,2)?l(t.mountpath.split("/").slice(0,-1).join("/"),e.slice(2)):e:e&&(r=u(e).href),r?[y("redirect",t,{to:r})]:[])})}var V=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},Q=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function F(e,t){return function(r){return function(n,o){return function(t,r,n){return V(this,function(o){switch(o.label){case 0:return[5,Q(g(e,t,r,function(e){return k(n,t,e||{})}))];case 1:return o.sent(),[2]}})}(n,o,t?t():r)}}}function $(e,t){return E(e,t,function(e,t){return e?[y("data",t,{data:e})]:[]})}function z(e,t){return E(e,t,function(e,t){return e?[y("title",t,{title:e})]:[]})}var B=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{s(n.next(e))}catch(e){i(e)}}function u(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,u)}s((n=n.apply(e,t||[])).next())})},Y=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},Z=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&(r[n[o]]=e[n[o]])}return r},J=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function K(e){return function(t,r){return B(this,void 0,void 0,function(){var n,o,i,a;return Y(this,function(u){switch(u.label){case 0:return n=e.getMeta?Promise.resolve(e.getMeta(t,r,void 0)).then(S).then(W):Promise.resolve(e.meta||{}),o=e.getTitle?Promise.resolve(e.getTitle(t,r,n)).then(S):Promise.resolve(e.title),"HEAD"!==t.method&&(i=e.getContent?Promise.resolve(e.getContent(t,r,n)).then(S):Promise.resolve(e.content)),a={},[4,n];case 1:return a.meta=u.sent(),[4,i];case 2:return a.content=u.sent(),[4,o];case 3:return[2,(a.title=u.sent(),a)]}})})}}function W(e){return e||{}}function X(e,t){return E(e,t,function(e,t){return e?[y("head",t,{head:e})]:[]},function(e){return"HEAD"!==e.method})}function ee(e,t){return E(e,t,function(e,t){return e?[y("headers",t,{headers:e})]:[]})}function te(e,t){return E(e,t,function(e,t){return e?[y("status",t,{status:e})]:[]})}var re=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{s(n.next(e))}catch(e){i(e)}}function u(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,u)}s((n=n.apply(e,t||[])).next())})},ne=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},oe=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&(r[n[o]]=e[n[o]])}return r},ie=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a};function ae(e){return e||{}}function ue(e,t,r,n){if(t){var o=t(r,n);return x(o)?[o.then(S),!0]:[o,!1]}return[e,!1]}var se=function(){function e(e,t){this.close=e,this.observer=t,this.observer.start&&this.observer.start(this)}return e.prototype.unsubscribe=function(){this.closed||(this.closed=!0,this.close(this.observer),delete this.close,delete this.observer)},e}();function ce(e,t,r){return"function"==typeof e?{next:e,error:t,complete:r}:e}function le(e){return new Promise(function(t,r){e.subscribe({start:function(e){this.subscription=e},next:function(e){this.value=e},complete:function(){t(this.value),this.subscription.unsubscribe()},error:function(e){r(e),this.subscription.unsubscribe()}})})}var he=function(){function e(e,t,r,n){var o=this;this.handleUnsubscribe=function(e){var t=o.observers.indexOf(e);-1!==t&&o.observers.splice(t,1)},this.handleChange=function(e){if(e===o.lastListenId){o.lastListenId++,o.refresh();for(var t=o.result.done||o.result.value.every(function(e){return"busy"!==e.type}),r=0;r<o.observers.length;r++){var n=o.observers[r];n.next(o.result.value),t&&n.complete&&n.complete()}t&&delete o.matcherIterator}},this.refresh=function(){var e=o.matcherIterator.next();if(e.value&&(o.result=e),!o.result.done){var t=++o.lastListenId,r=function(){return o.handleChange(t)};Promise.race(o.result.value.filter(fe).map(pe)).then(r,r)}},this.url=e,this.lastListenId=0,this.observers=[],this.matcherIterator=n(t,r)}return e.prototype.subscribe=function(e,t,r){if(!this.matcherIterator)throw new Error("Can't subscribe to an already-complete RoutingObservable.");var n=ce(e,t,r);this.observers.push(n);var o=new se(this.handleUnsubscribe,n);return 1===this.observers.length&&this.handleChange(this.lastListenId),o},e}();function fe(e){return"busy"===e.type}function pe(e){return e.promise}var be=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{s(n.next(e))}catch(e){i(e)}}function u(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,u)}s((n=n.apply(e,t||[])).next())})},de=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},ye=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},ve=function(){function e(e,t,r,n,o,i){var a=this;this.handleUnsubscribe=function(e){var t=a.observers.indexOf(e);-1!==t&&a.observers.splice(t,1)},this.handleResolverUpdate=function(e){e===a.lastListenId&&(a.lastListenId++,a.isRefreshing?a.isRefreshScheduled||(a.isRefreshScheduled=!0):a.refresh())},this.refresh=function(){return be(a,void 0,void 0,function(){var e,t,r,n,o,i,a,u,s,c,h,f,p,b,d,y,v,m,w=this;return de(this,function(g){switch(g.label){case 0:this.isRefreshScheduled=!1,this.isRefreshing=!0,e=[],t=0,r=function(){var r,o,i,a,u,s,c,h,f,p,b;return de(this,function(d){switch(d.label){case 0:r=n.mapItems[t],o=r.pathname,i=r.matcherIterator.next(),r.lastResult&&!i.value||(r.lastResult=i),a=r.lastResult.value,r.chunksCache=a||[],u=a.findIndex(function(e){return"error"===e.type||e.url.href.length>=r.url.href.length&&("mount"===e.type&&r.lastMountPatterns!==e.patterns||"redirect"===e.type&&r.lastRedirectTo!==e.to)}),d.label=1;case 1:if(!(u>=0&&u<a.length))return[3,6];if(s=a[u],u++,"error"===s.type||n.options.predicate&&!n.options.predicate(s,a))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,h=c.slice(0).sort().join("\n"),!c||r.walkedPatternLists.has(h))return[3,5];r.walkedPatternLists.add(h),f=0,d.label=2;case 2:return f<c.length?[4,n.expandPatterns(l(o,c[f]))]:[3,5];case 3:for(p=d.sent(),b=0;b<p.length;b++)n.addToQueue(p[b],r.depth+1,r.walkedPatternLists,o,r.order.concat(f,b));d.label=4;case 4:return f++,[3,2];case 5:return[3,1];case 6:return a&&(e=e.concat(a)),t++,[2]}})},n=this,g.label=1;case 1:return this.mapItems&&t<this.mapItems.length?[5,r()]:[3,3];case 2:switch(g.sent()){case"continue-items":return[3,1]}return[3,1];case 3:if(!this.mapItems)return[2];for(o=[],i=0;i<this.mapItems.length;i++)a=this.mapItems[i],"mount"===(u=a.chunksCache[a.chunksCache.length-1]).type||"error"===u.type||"busy"!==u.type&&this.options.predicate&&!this.options.predicate(u,a.chunksCache)||o.push([l(a.pathname,"/"),a.chunksCache,a.order]);if(s=++this.lastListenId,c=function(){return w.handleResolverUpdate(s)},Promise.race(e.filter(me).map(we)).then(c,c),o.sort(function(e,t){var r=e[2],n=t[2];if(r.length<n.length)return-1;if(r.length>n.length)return 1;for(var o=0;o<r.length;o++){if(r[o]<n[o])return-1;if(r[o]>n[o])return 1}return 0}),this.isRefreshScheduled)this.refresh();else{for(h={},f=!0,p=0;p<o.length;p++)b=ye(o[p],2),d=b[0],(y=b[1]).some(function(e){return"busy"===e.type})&&(f=!1),h[d]=y;for(v=0;v<this.observers.length;v++)(m=this.observers[v]).next(h),f&&m.complete&&m.complete();f&&(delete this.rootContext,delete this.mapItems,delete this.router,delete this.observers),this.isRefreshing=!1}return[2]}})})},this.observers=[],this.lastListenId=0,this.mapItems=[],this.router=o,this.rootContext=t,this.matcherGeneratorFunction=r,this.rootMapping=n,this.options=i,this.seenPathnames=new Set;var u=e.pathname;"/"===u.substr(-1)&&(u=u.substr(0,u.length-1)),this.addToQueue(u,0,new Set)}return e.prototype.subscribe=function(e,t,r){if(!this.observers)throw new Error("Can't subscribe to an already-complete RoutingObservable.");var n=ce(e,t,r);this.observers.push(n);var o=new se(this.handleUnsubscribe,n);return 1===this.observers.length&&this.refresh(),o},e.prototype.expandPatterns=function(e){return be(this,void 0,void 0,function(){var t;return de(this,function(r){switch(r.label){case 0:return this.options.expandPattern?[4,this.options.expandPattern(e,this.router)]:[3,2];case 1:if(t=r.sent())return[2,t];r.label=2;case 2:return[2,[e].filter(function(e){return!/\/:/.test(e)})]}})})},e.prototype.removeFromQueue=function(e){var t=this.mapItems.indexOf(e);-1!==t&&this.mapItems.splice(t,1)},e.prototype.addToQueue=function(e,t,r,n,o){if(void 0===o&&(o=[0]),!this.seenPathnames.has(e)&&(!this.options.maxDepth||t<=this.options.maxDepth)){this.seenPathnames.add(e);var i=u(e,{ensureTrailingSlash:!1,removeHash:!0}),a=q(T(this.rootContext,{body:null,headers:this.options.headers||{},method:this.options.method||"HEAD",params:{},hostname:this.options.hostname||"",mountpath:"",query:i.query,search:i.search,router:this.router,path:i.pathname,url:i.pathname+i.search,originalUrl:i.href}),this.rootMapping,this.rootContext);a&&this.mapItems.push({url:i,fromPathname:n,depth:t,pathname:e,order:o,walkedPatternLists:new Set(r),matcherIterator:this.matcherGeneratorFunction(a,this.rootContext)})}},e}();function me(e){return"busy"===e.type}function we(e){return e.promise}var ge=function(){return(ge=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function xe(e,t){return e=function(e,t){if(e){if("url"===t.type)return ge({},e,{chunks:e.chunks.filter(function(e){return"url"!==e.type}),url:t.url});if("ready"!==e.type)return e}var r={lastChunk:t,chunks:e?e.chunks.concat(t):[t],data:e?e.data:{},headers:e?e.headers:{},heads:e?e.heads:[],status:e?e.status:200,title:e&&e.title,url:e?e.url:t.url,views:e?e.views:[]};switch(t.type){case"busy":return ge({},r,{type:"busy"});case"data":return ge({},r,{type:"ready",data:ge({},r.data,t.data)});case"error":return ge({},r,{type:"error",error:t.error,status:r.status&&r.status>=400?r.status:t.error.status||500});case"head":return ge({},r,{type:"ready",heads:r.heads.concat(t.head)});case"headers":return ge({},r,{type:"ready",headers:ge({},r.headers,t.headers)});case"redirect":return ge({},r,{type:"redirect",to:t.to});case"status":return ge({},r,{type:"ready",status:t.status});case"title":return ge({},r,{type:"ready",title:t.title});case"view":return ge({},r,{type:"ready",views:r.views.concat(t.view)});default:return ge({},r,{type:"ready"})}}(e,t),Object.defineProperties(e,{meta:{configurable:!0,get:function(){return e.data}},content:{configurable:!0,get:function(){return t.view}},segments:{configurable:!0,get:function(){return e.chunks}},lastSegment:{configurable:!0,get:function(){return e.lastChunk}}}),e}var Se=function(){function e(e){this.context=e.context||{},this.matcherGenerator=e.routes(),this.reducer=e.reducer||xe;var t,r,n=e.basename;n&&"/"===n.slice(-1)&&(n=n.slice(0,-1)),this.rootMapping=(t=e.routes,void 0===(r=n)&&(r=""),""!==r?G(r,t):{pattern:r,key:"",regExp:new RegExp(""),matcher:t})}return e.prototype.setContext=function(e){this.context=e||{}},e.prototype.createObservable=function(e,t){void 0===t&&(t={}),e.hash&&delete(e=Object.assign({},e)).hash;var r=q(T(this.context,{body:t.body,headers:t.headers||{},method:t.method||"GET",hostname:e.hostname,mountpath:"",params:e.query,query:e.query,search:e.search,router:this,url:e.pathname+e.search,originalUrl:e.href,path:e.pathname}),this.rootMapping,this.context);if(r)return new he(e,r,this.context,this.matcherGenerator)},e.prototype.createMapObservable=function(e,t){return void 0===t&&(t={}),new ve(u(e,{ensureTrailingSlash:!1}),this.context,this.matcherGenerator,this.rootMapping,this,t)},e.prototype.resolve=function(e,t){var r,n=this;if(void 0===t&&(t={}),Array.isArray(e))r=e.map(function(e){return u(e)});else if("string"==typeof e)r=[u(e)];else if(e.url)r=[u((t=e).url)];else{if(!t)throw new Error("You must specify a URL for router.resolve().");r=[u(e)]}if(!r.length)return Promise.resolve([]);var o=r.map(function(e){return n.getPageRoutePromise(e,t)});return Array.isArray(e)?Promise.all(o):o[0]},e.prototype.resolveSiteMap=function(e,t){var r=this;return void 0===t&&(t={}),le(this.createMapObservable(e,t)).then(function(e){for(var t={},n={},o=Object.keys(e),i=0;i<o.length;i++){var a=o[i],s=e[a],c=s[s.length-1];"redirect"!==c.type?t[a]=[{type:"url",url:u(a)}].concat(s).reduce(r.reducer,void 0):n[a]=c.to}return{routes:t,redirects:n}})},e.prototype.resolveRouteMap=function(e,t){return void 0===t&&(t={}),this.resolveSiteMap(e,t).then(function(e){return e.routes})},e.prototype.getPageRoutePromise=function(e,t){var r=this,n=this.createObservable(e,t);return n?le(n).then(function(n){for(var o=0;o<n.length;o++){var i=n[o];if("busy"===i.type)break;if("redirect"===i.type&&t.followRedirects)return r.getPageRoutePromise(u(i.to),t);if("error"===i.type)throw i.error}return[{type:"url",url:u(e)}].concat(n).reduce(r.reducer,void 0)}):Promise.reject(new d(e))},e}(),Re=function(){return function(){this.promise=new Promise(function(e,t){this.resolve=e,this.reject=t}.bind(this)),Object.freeze(this)}}(),ke=function(){return(ke=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},Oe=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{s(n.next(e))}catch(e){i(e)}}function u(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,u)}s((n=n.apply(e,t||[])).next())})},Pe=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},je=function(){function e(e,t,r,n){var o=this;this.handleUnsubscribe=function(e){var t=o.observers.indexOf(e);-1!==t&&o.observers.splice(t,1)},this.handleChunkList=function(e){for(var t=!0,r=0;r<e.length;r++){var n=e[r];if("busy"===n.type&&(t=!1),"redirect"===n.type)return void o.history.replace(n.to)}o.setRoute([{type:"url",url:o.lastURL}].concat(e).reduce(o.reducer,void 0),t)},this.observers=[],this.isLastRouteSteady=!1,this.router=t,this.history=e,this.reducer=r,this.resolveOptions=n,this.lastURL=u(this.history.location),this.unlisten=this.history.listen(function(e){return o.handleURLChange(u(e))}),this.refresh()}return e.prototype.dispose=function(){this.observers.length=0,this.unlisten(),delete this.unlisten,delete this.history,this.observableSubscription&&this.observableSubscription.unsubscribe(),delete this.observableSubscription,delete this.router,delete this.waitUntilSteadyDeferred,delete this.lastRoute},e.prototype.refresh=function(){this.handleURLChange(u(this.history.location),!0)},e.prototype.setContext=function(e){this.router.setContext(e),this.refresh()},e.prototype.getValue=function(){return this.lastRoute},e.prototype.getSteadyRoute=function(){return Oe(this,void 0,void 0,function(){return Pe(this,function(e){return this.isLastRouteSteady?[2,Promise.resolve(this.lastRoute)]:(this.waitUntilSteadyDeferred||(this.waitUntilSteadyDeferred=new Re),[2,this.waitUntilSteadyDeferred.promise])})})},e.prototype.subscribe=function(e,t,r){var n=ce(e,t,r);return this.observers.push(n),new se(this.handleUnsubscribe,n)},e.prototype.handleURLChange=function(e,t){if(!t&&this.lastReceivedURL&&i(this.lastReceivedURL,e))for(var r=0;r<this.observers.length;r++)this.observers[r].next(this.lastRoute);else{if(this.lastReceivedURL=e,"/"!==e.pathname.substr(-1))return e=ke({},e,{pathname:e.pathname+"/"}),void this.history.replace(e);var n,o,a=this.lastURL;if(this.lastURL=e,e&&a&&(n=e.pathname!==a.pathname,o=e.search!==a.search),t||n||o||!this.lastRoute){this.observableSubscription&&this.observableSubscription.unsubscribe();var u=this.router.createObservable(e,this.resolveOptions);if(u)this.observableSubscription=u.subscribe(this.handleChunkList);else if(!a)throw new d(e)}else e.hash!==a.hash&&this.setRoute(this.reducer(this.lastRoute,{type:"url",url:e}),this.isLastRouteSteady)}},e.prototype.setRoute=function(e,t){if(e!==this.lastRoute){this.lastRoute=e,this.isLastRouteSteady=t,t&&this.waitUntilSteadyDeferred&&(this.waitUntilSteadyDeferred.resolve(e),delete this.waitUntilSteadyDeferred);for(var r=0;r<this.observers.length;r++)this.observers[r].next(e)}},e}(),Ee=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{s(n.next(e))}catch(e){i(e)}}function u(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,u)}s((n=n.apply(e,t||[])).next())})},Ce=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};var Le=function(){function e(e){e.pages&&(e.routes=e.pages);var r=e.reducer||xe;this.history=e.history||t.createBrowserHistory(),this.router=new Se({context:e.context,routes:e.routes,basename:e.basename,reducer:r}),this.currentRouteObservable=new je(this.history,this.router,r)}return e.prototype.dispose=function(){this.currentRouteObservable.dispose(),delete this.currentRouteObservable,delete this.router,delete this.history},e.prototype.setContext=function(e){this.currentRouteObservable.setContext(e)},e.prototype.getCurrentValue=function(){return this.currentRouteObservable.getValue()},e.prototype.getSteadyValue=function(){return this.currentRouteObservable.getSteadyRoute()},e.prototype.steady=function(){return Ee(this,void 0,void 0,function(){return Ce(this,function(e){switch(e.label){case 0:return[4,this.getSteadyValue()];case 1:return e.sent(),[2]}})})},e.prototype.subscribe=function(e,t,r){var n=ce(e,t,r);return this.currentRouteObservable.subscribe(n)},e}(),Ue=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{s(n.next(e))}catch(e){i(e)}}function u(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,u)}s((n=n.apply(e,t||[])).next())})},Ie=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};var Te=function(){function e(e){e.pages&&(e.routes=e.pages);var r=e.reducer||xe,n=e.url||e.request&&e.request.url;if(!n)throw new Error("createMemoriNavigation() could not find a URL.");this.history=t.createMemoryHistory({initialEntries:[u(n).href]}),this.options=e,this.router=new Se({context:e.context,routes:this.options.routes||this.options.pages,basename:this.options.basename,reducer:r}),this.currentRouteObservable=new je(this.history,this.router,r,e.request)}return e.prototype.dispose=function(){this.currentRouteObservable.dispose(),delete this.currentRouteObservable,delete this.router,delete this.options},e.prototype.setContext=function(e){this.currentRouteObservable.setContext(e)},e.prototype.getCurrentValue=function(){return this.currentRouteObservable.getValue()},e.prototype.getSteadyValue=function(){return this.currentRouteObservable.getSteadyRoute()},e.prototype.steady=function(){return Ue(this,void 0,void 0,function(){return Ie(this,function(e){switch(e.label){case 0:return[4,this.getSteadyValue()];case 1:return e.sent(),[2]}})})},e.prototype.subscribe=function(e,t,r){var n=ce(e,t,r);return this.currentRouteObservable.subscribe(n)},e}();e.compose=o,e.Router=Se,e.createRouter=function(e){return new Se(e)},e.defaultRouteReducer=xe,e.concatMatcherIterators=O,e.resolveChunks=g,e.createBrowserNavigation=function(e){return new Le(e)},e.BrowserNavigation=Le,e.createMemoryNavigation=function(e){return new Te(e)},e.MemoryNavigation=Te,e.lazy=I,e.map=I,e.createPage=function(e){return Object.assign(o(F(K(e)),$(function(e,t){return t.meta}),z(function(e,t){return t.title}),C(function(e,t){return t.content})),{isDeprecatedMatcher:!0})},e.createContext=function(e,t){return Object.assign(F(e,t.isDeprecatedMatcher?t:I(t)),{isDeprecatedMatcher:!0})},e.createSwitch=function(e){var t,r,n={};try{for(var i=J(Object.keys(e.paths)),a=i.next();!a.done;a=i.next()){var u=a.value,s=e.paths[u];n[u]=s.isDeprecatedMatcher?s:I(s)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}if(1===Object.keys(e).length)return Object.assign(_(n),{isDeprecatedMatcher:!0});e.paths;var c=Z(e,["paths"]);return Object.assign(o(F(K(c)),$(function(e,t){return t.meta}),z(function(e,t){return t.title}),C(function(e,t){return t.content}),_(n)),{isDeprecatedMatcher:!0})},e.createRedirect=function(e,t){var r=A(e);return t?o($(t),r):Object.assign(r,{isDeprecatedMatcher:!0})},e.mount=_,e.redirect=A,e.route=function(e){if(void 0===e&&(e={}),"function"!=typeof e){var t=e.data,r=e.getData,n=e.head,i=e.getHead,a=e.headers,u=e.getHeaders,s=e.status,c=e.getStatus,l=e.title,h=e.getTitle,f=e.view,p=e.getView;oe(e,["data","getData","head","getHead","headers","getHeaders","status","getStatus","title","getTitle","view","getView"]),e=function(e,o){var b,d,y=this,v=ie(ue(t,r,e,o),2),m=v[0],w=v[1];m?x(m)&&(m=m.then(ae)):m={};var g,S,R,k,O=ie(ue(a,u,e,o),2),P=O[0],j=O[1],E=ie(ue(s,c,e,o),2),C=E[0],L=E[1],U=ie(ue(l,h,e,o),2),I=U[0],T=U[1];return"HEAD"!==e.method&&(b=ie(ue(n,i,e,o),2),g=b[0],R=b[1],d=ie(ue(f,p,e,o),2),S=d[0],k=d[1]),w||j||L||T||R||k?re(y,void 0,void 0,function(){var e;return ne(this,function(t){switch(t.label){case 0:return e={},[4,m];case 1:return e.data=t.sent(),[4,g];case 2:return e.head=t.sent(),[4,P];case 3:return e.headers=t.sent(),[4,C];case 4:return e.status=t.sent(),[4,I];case 5:return e.title=t.sent(),[4,S];case 6:return[2,(e.view=t.sent(),e)]}})}):{data:m,head:g,headers:P,status:C,title:I,view:S}}}return o(F(e),$(function(e,t){return t.data}),X(function(e,t){return t.head}),ee(function(e,t){return t.headers}),te(function(e,t){return t.status}),z(function(e,t){return t.title}),C(function(e,t){return t.view}))},e.withContext=F,e.withData=$,e.withHead=X,e.withHeaders=ee,e.withStatus=te,e.withTitle=z,e.withView=C,e.NaviError=p,e.NotFoundError=b,e.OutOfRootError=d,e.createRequest=T,e.createChunk=y,e.createNotFoundChunk=v,e.areURLDescriptorsEqual=i,e.createURLDescriptor=u,e.parseQuery=s,e.stringifyQuery=c,e.joinPaths=l,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "navi", | ||
"version": "0.11.4", | ||
"version": "0.11.5", | ||
"description": "A router-loader for React.", | ||
@@ -5,0 +5,0 @@ "author": "James K Nelson <james@jamesknelson.com>", |
@@ -1,2 +0,2 @@ | ||
import { Resolvable, extractDefault } from '../Resolvable' | ||
import { Resolvable, extractDefault, isPromiseLike } from '../Resolvable' | ||
import { compose } from '../utils/compose' | ||
@@ -67,55 +67,49 @@ import { withContext } from './withContext' | ||
options = async function getRoute( | ||
options = function getRoute( | ||
req: NaviRequest, | ||
context: Context, | ||
): Promise<Route<Data>> { | ||
let dataPromise: Promise<Data> = getData | ||
? Promise.resolve(getData(req, context, undefined as any)) | ||
.then(extractDefault) | ||
.then(inputOrEmptyObject) | ||
: Promise.resolve(data || {}) | ||
): Route<Data> | Promise<Route<Data>> { | ||
let [dataMaybePromise, a]: [Data | PromiseLike<Data>, boolean] = extractValue(data, getData, req, context) | ||
if (!dataMaybePromise) { | ||
dataMaybePromise = {} as Data | ||
} | ||
else if (isPromiseLike(dataMaybePromise)) { | ||
dataMaybePromise = dataMaybePromise.then(inputOrEmptyObject) | ||
} | ||
let headersPromise: Promise<{ [name: string]: string } | undefined> = getHeaders | ||
? Promise.resolve(getHeaders(req, context, dataPromise)).then( | ||
extractDefault, | ||
) | ||
: Promise.resolve(headers) | ||
let [headersMaybePromise, b] = extractValue(headers, getHeaders, req, context) | ||
let [statusMaybePromise, c] = extractValue(status, getStatus, req, context) | ||
let [titleMaybePromise, d] = extractValue(title, getTitle, req, context) | ||
let statusPromise: Promise<number | undefined> = getStatus | ||
? Promise.resolve(getStatus(req, context, dataPromise)).then( | ||
extractDefault, | ||
) | ||
: Promise.resolve(status) | ||
let titlePromise: Promise<string | undefined> = getTitle | ||
? Promise.resolve(getTitle(req, context, dataPromise)).then( | ||
extractDefault, | ||
) | ||
: Promise.resolve(title) | ||
let headPromise: Promise<any | undefined> | undefined | ||
let viewPromise: Promise<any | undefined> | undefined | ||
let headMaybePromise: any | Promise<any | undefined> | undefined | ||
let viewMaybePromise: any | Promise<any | undefined> | undefined | ||
let e: boolean | undefined | ||
let f: boolean | undefined | ||
if (req.method !== 'HEAD') { | ||
headPromise = getHead | ||
? Promise.resolve(getHead(req, context, dataPromise)).then( | ||
extractDefault, | ||
) | ||
: Promise.resolve(head) | ||
viewPromise = getView | ||
? Promise.resolve(getView(req, context, dataPromise)).then( | ||
extractDefault, | ||
) | ||
: Promise.resolve(view) | ||
[headMaybePromise, e] = extractValue(head, getHead, req, context); | ||
[viewMaybePromise, f] = extractValue(view, getView, req, context) | ||
} | ||
return { | ||
data: await dataPromise, | ||
head: await headPromise, | ||
headers: await headersPromise, | ||
status: await statusPromise, | ||
title: await titlePromise, | ||
view: await viewPromise, | ||
// If anything is a promise, return a promise | ||
if (a || b || c || d || e || f) { | ||
return (async () => ({ | ||
data: await dataMaybePromise, | ||
head: await headMaybePromise, | ||
headers: await headersMaybePromise, | ||
status: await statusMaybePromise, | ||
title: await titleMaybePromise, | ||
view: await viewMaybePromise, | ||
}))() | ||
} | ||
// If nothing is a promise, return a synchronous result | ||
else { | ||
return { | ||
data: dataMaybePromise as Data, | ||
head: headMaybePromise as { [name: string]: string }, | ||
headers: headersMaybePromise as any, | ||
status: statusMaybePromise as number, | ||
title: titleMaybePromise as string, | ||
view: viewMaybePromise as any, | ||
} | ||
} | ||
} | ||
@@ -138,1 +132,14 @@ } | ||
} | ||
function extractValue<T, Context extends object>(value: T | undefined, getter: Resolvable<T, Context> | undefined, request: NaviRequest, context: Context): [T | PromiseLike<T>, boolean] { | ||
if (getter) { | ||
let valueOrPromise: T | PromiseLike<T | { default: T }> = getter(request, context) | ||
if (isPromiseLike(valueOrPromise)) { | ||
return [valueOrPromise.then(extractDefault), true] | ||
} | ||
return [valueOrPromise, false] | ||
} | ||
else { | ||
return [value!, false] | ||
} | ||
} |
@@ -89,3 +89,3 @@ import { joinPaths } from './URLTools' | ||
// so there isn't a better way to check if it's a promise :-( | ||
function isPromiseLike<T>( | ||
export function isPromiseLike<T>( | ||
x: PromiseLike<{ default: T } | T> | T, | ||
@@ -92,0 +92,0 @@ ): x is PromiseLike<{ default: T } | T> { |
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
641813
10933
209