var frontexpress=function(){"use strict";function t(t){var e=void 0,r=void 0,i=void 0,a=void 0;if(t&&t.length>0){if(1===t.length){var o=n(t,1);a=o[0]}else{var s=n(t,2);e=s[0],a=s[1]}a instanceof l?i=a:(a instanceof u||"function"==typeof a)&&(r=a)}return{baseUri:e,middleware:r,router:i,which:a}}var e=["GET","POST","PUT","DELETE"],r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},i=function(){function t(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";r(this,t),this.name=e}return i(t,[{key:"next",value:function(){return!0}}]),t}(),d=function(){function t(e,i,n,a){r(this,t),this.router=e,this.uriPart=i,this.method=n,this.middleware=a,this.visited=!1}return i(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}(),h="method takes at least a middleware",l=function(){function n(t){r(this,n),this._baseUri=t,this._routes=[]}return i(n,[{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 u)&&"function"!=typeof t)throw new TypeError(h);return this._add(new d(this,void 0,void 0,t)),this}},{key:"all",value:function(){for(var r=arguments.length,i=Array(r),n=0;n0&&void 0!==arguments[0]?arguments[0]:window.location.pathname+window.location.search,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GET",r=[],i=!0,n=!1,o=void 0;try{for(var s,u=this.routers[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var d=s.value;r.push.apply(r,a(d.routes(t,e)))}}catch(t){n=!0,o=t}finally{try{!i&&u.return&&u.return()}finally{if(n)throw o}}return r}},{key:"_callMiddlewareMethod",value:function(t,e,r,i){if("exited"!==t){var n=!0,a=!1,o=void 0;try{for(var s,u=e[Symbol.iterator]();!(n=(s=u.next()).done);n=!0){var d=s.value;if("updated"===t&&(d.visited=r),d.middleware[t]){if(d.middleware[t](r,i),d.middleware.next&&!d.middleware.next())break}else if("entered"!==t){var h=!0,l=function(){h=!1};if(d.middleware(r,i,l),h)break}}}catch(t){a=!0,o=t}finally{try{!n&&u.return&&u.return()}finally{if(a)throw o}}}else{var f=!0,c=!1,v=void 0;try{for(var y,w=this.routers[Symbol.iterator]();!(f=(y=w.next()).done);f=!0){var p=y.value,m=!0,g=!1,b=void 0;try{for(var x,M=p.visited()[Symbol.iterator]();!(m=(x=M.next()).done);m=!0){var T=x.value;T.middleware.exited&&(T.middleware.exited(T.visited),T.visited=null)}}catch(t){g=!0,b=t}finally{try{!m&&M.return&&M.return()}finally{if(g)throw b}}}}catch(t){c=!0,v=t}finally{try{!f&&w.return&&w.return()}finally{if(c)throw v}}}}},{key:"_fetch",value:function(t,e,r){var i=this,n=t.method,a=t.uri,o=t.headers,s=t.data,u=t.history,d=this.get("http "+n+" transformer");d&&(a=d.uri?d.uri({uri:a,headers:o,data:s}):a,o=d.headers?d.headers({uri:a,headers:o,data:s}):o,s=d.data?d.data({uri:a,headers:o,data:s}):s),this._callMiddlewareMethod("exited");var h=this._routes(a,n);this._callMiddlewareMethod("entered",h,t),this.settings.get("http requester").fetch(t,function(t,r){u&&window.history.pushState({request:t,response:r},u.title,u.uri),i._callMiddlewareMethod("updated",h,t,r),e&&e(t,r)},function(t,e){i._callMiddlewareMethod("failed",h,t,e),r&&r(t,e)})}}]),n}();e.reduce(function(e,r){var i=r.toLowerCase();e[i]=function(){for(var e=arguments.length,r=Array(e),n=0;n