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