var frontexpress=function(){"use strict";function e(e){var t=void 0,r=void 0,i=void 0,n=void 0;if(e&&e.length>0){if(1===e.length)n=a(e,1)[0];else{var o=a(e,2);t=o[0],n=o[1]}n instanceof f?i=n:(n instanceof d||"function"==typeof n)&&(r=n)}return{baseUri:t,middleware:r,router:i,which:n}}var t=["GET","POST","PUT","PATCH","DELETE"],r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";i(this,e),this.name=t}return n(e,[{key:"entered",value:function(e){}},{key:"exited",value:function(e){}},{key:"updated",value:function(e,t){}},{key:"failed",value:function(e,t){}},{key:"next",value:function(){return!0}}]),e}(),h=function(){function e(t,r,n,a){i(this,e),this.router=t,this.uriPart=r,this.method=n,this.middleware=a,this.visited=!1}return n(e,[{key:"uri",get:function(){if(this.uriPart||this.method){if(this.uriPart instanceof RegExp)return this.uriPart;if(this.router.baseUri instanceof RegExp)return this.router.baseUri;if(this.router.baseUri){var e=this.router.baseUri.trim();return this.uriPart?(e+this.uriPart.trim()).replace(/\/{2,}/,"/"):e}return this.uriPart}}}]),e}(),f=function(){function a(e){i(this,a),this._baseUri=e,this._routes=[]}return n(a,[{key:"_add",value:function(e){return this._routes.push(e),this}},{key:"routes",value:function(e,t){return this._routes.filter(function(r){if(r.method&&r.method!==t)return!1;if(!r.uri||!e)return!0;var i=/^(.*)\?.*#.*|(.*)(?=\?|#)|(.*[^\?#])$/.exec(e),n=i[1]||i[2]||i[3];return r.uri instanceof RegExp?n.match(r.uri):r.uri===n})}},{key:"visited",value:function(){return this._routes.filter(function(e){return e.visited})}},{key:"use",value:function(e){if(!(e instanceof d)&&"function"!=typeof e)throw new TypeError("method takes at least a middleware");return this._add(new h(this,void 0,void 0,e)),this}},{key:"all",value:function(){for(var r=this,i=arguments.length,n=Array(i),a=0;a0&&void 0!==arguments[0]?arguments[0]:window.location.pathname+window.location.search,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GET",r=[];return this.routers.forEach(function(i){r.push.apply(r,o(i.routes(e,t)))}),r}},{key:"_callMiddlewareMethod",value:function(e,t,r,i){if("exited"===e)return void this.routers.forEach(function(e){e.visited().forEach(function(e){e.middleware.exited&&(e.middleware.exited(e.visited),e.visited=null)})});t.some(function(t){if("updated"===e&&(t.visited=r),t.middleware[e]){if(t.middleware[e](r,i),t.middleware.next&&!t.middleware.next())return!0}else if("entered"!==e){var n=!0,a=function(){n=!1};if(t.middleware(r,i,a),n)return!0}return!1})}},{key:"_fetch",value:function(e,t,r){var i=this,n=e.method,a=e.uri,o=e.headers,u=e.data,s=e.history,d=this.get("http "+n+" transformer");if(d){var h=d.uri,f=d.headers,c=d.data;e.uri=h?h({uri:a,headers:o,data:u}):a,e.headers=f?f({uri:a,headers:o,data:u}):o,e.data=c?c({uri:a,headers:o,data:u}):u}this._callMiddlewareMethod("exited");var l=this._routes(a,n);this._callMiddlewareMethod("entered",l,e),this.settings.get("http requester").fetch(e,function(e,r){s&&window.history.pushState({request:e,response:r},s.title,s.uri),i._callMiddlewareMethod("updated",l,e,r),t&&t(e,r)},function(e,t){i._callMiddlewareMethod("failed",l,e,t),r&&r(e,t)})}}]),r}();t.reduce(function(t,r){var i=r.toLowerCase();return t[i]=function(){for(var t=arguments.length,r=Array(t),n=0;n