1 |
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Router=e():t.Router=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var r={};return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=11)}([function(t,e){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e,r){t.exports=!r(3)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e,r){var n=r(0),o=r(5),i=r(6),s=r(19),c=r(8),u=function(t,e,r){var a,f,h,l,p=t&u.F,y=t&u.G,d=t&u.S,v=t&u.P,m=t&u.B,g=y?n:d?n[e]||(n[e]={}):(n[e]||{}).prototype,x=y?o:o[e]||(o[e]={}),w=x.prototype||(x.prototype={});y&&(r=e);for(a in r)f=!p&&g&&void 0!==g[a],h=(f?g:r)[a],l=m&&f?c(h,n):v&&"function"==typeof h?c(Function.call,h):h,g&&s(g,a,h,t&u.U),x[a]!=h&&i(x,a,l),v&&w[a]!=h&&(w[a]=h)};n.core=o,u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,t.exports=u},function(t,e){var r=t.exports={version:"2.4.0"};"number"==typeof __e&&(__e=r)},function(t,e,r){var n=r(13),o=r(18);t.exports=r(2)?function(t,e,r){return n.f(t,e,o(1,r))}:function(t,e,r){return t[e]=r,t}},function(t,e){var r=0,n=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+n).toString(36))}},function(t,e,r){var n=r(21);t.exports=function(t,e,r){if(n(t),void 0===e)return t;switch(r){case 1:return function(r){return t.call(e,r)};case 2:return function(r,n){return t.call(e,r,n)};case 3:return function(r,n,o){return t.call(e,r,n,o)}}return function(){return t.apply(e,arguments)}}},function(t,e,r){var n=r(10);t.exports=Array.isArray||function(t){return"Array"==n(t)}},function(t,e){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,e,r){"use strict";var n="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};r(12),r(22);var o=r(34),i=r(35),c=function t(e){if(!(this instanceof t))return new t(e);this.params={},this.routes={},this.methods=["on","once","after","before"],this.scope=[],this._methods={},this._insert=this.insert,this.insert=this.insertEx,this.historySupport=null!=(null!=window.history?window.history.pushState:null),this.config(),this.mount(e||{})};c.prototype.init=function(t){var e,r=this;return this.handler=function(t){var e=t&&t.newURL||window.location.hash,n=!0===r.history?r.getPath():e.replace(/.*#/,"");r.dispatch("on","/"===n.charAt(0)?n:"/"+n)},o.listener.init(this.handler,this.history),!1===this.history?(0,o.dlocHashEmpty)()&&t?o.dloc.hash=t:(0,o.dlocHashEmpty)()||r.dispatch("on","/"+o.dloc.hash.replace(/^(#\/|#|\/)/,"")):(this.convert_hash_in_init?(e=(0,o.dlocHashEmpty)()&&t?t:(0,o.dlocHashEmpty)()?null:o.dloc.hash.replace(/^#/,""))&&window.history.replaceState({},document.title,e):e=this.getPath(),(e||!0===this.run_in_init)&&this.handler()),this},c.prototype.explode=function(){var t=!0===this.history?this.getPath():o.dloc.hash;return"/"===t.charAt(1)&&(t=t.slice(1)),t.slice(1,t.length).split("/")},c.prototype.setRoute=function(t,e,r){var n=this.explode();return"number"==typeof t&&"string"==typeof e?n[t]=e:"string"==typeof r?n.splice(t,e,s):n=[t],o.listener.setHash(n.join("/")),n},c.prototype.insertEx=function(t,e,r,n){return"once"===t&&(t="on",r=function(t){var e=!1;return function(){if(!e)return e=!0,t.apply(this,arguments)}}(r)),this._insert(t,e,r,n)},c.prototype.getRoute=function(t){var e=t;if("number"==typeof t)e=this.explode()[t];else if("string"==typeof t){var r=this.explode();e=r.indexOf(t)}else e=this.explode();return e},c.prototype.destroy=function(){return o.listener.destroy(this.handler),this},c.prototype.getPath=function(){var t=window.location.pathname;return"/"!==t.substr(0,1)&&(t="/"+t),t},c.prototype.config=function(t){t=t||{};for(var e=0;e<this.methods.length;e++)this._methods[this.methods[e]]=!0;return this.recurse=t.recurse||this.recurse||!1,this.async=t.async||!1,this.delimiter=t.delimiter||"/",this.strict=void 0===t.strict||t.strict,this.notfound=t.notfound,this.resource=t.resource,this.history=t.html5history&&this.historySupport||!1,this.run_in_init=!0===this.history&&!1!==t.run_handler_in_init,this.convert_hash_in_init=!0===this.history&&!1!==t.convert_hash_in_init,this.every={after:t.after||null,before:t.before||null,on:t.on||null},this},c.prototype.param=function(t,e){":"!==t[0]&&(t=":"+t);var r=new RegExp(t,"g");return this.params[t]=function(t){return t.replace(r,e.source||e)},this},c.prototype.on=c.prototype.route=function(t,e,r){var n=this;return r||"function"!=typeof e||(r=e,e=t,t="on"),Array.isArray(e)?e.forEach(function(e){n.on(t,e,r)}):(e.source&&(e=e.source.replace(/\\\//gi,"/")),Array.isArray(t)?t.forEach(function(t){n.on(t.toLowerCase(),e,r)}):(e=e.split(new RegExp(this.delimiter)),e=(0,i.terminator)(e,this.delimiter),void this.insert(t,this.scope.concat(e),r)))},c.prototype.path=function(t,e){var r=this.scope.length;t.source&&(t=t.source.replace(/\\\//gi,"/")),t=t.split(new RegExp(this.delimiter)),t=(0,i.terminator)(t,this.delimiter),this.scope=this.scope.concat(t),e.call(this,this),this.scope.splice(r,t.length)},c.prototype.dispatch=function(t,e,r){function n(){i.last=s.after,i.invoke(i.runlist(s),i,r)}var o,i=this,s=this.traverse(t,e.replace(/\?.*/,""),this.routes,""),c=this._invoked;return this._invoked=!0,s&&0!==s.length?("forward"===this.recurse&&(s=s.reverse()),(o=this.every&&this.every.after?[this.every.after].concat(this.last):[this.last])&&o.length>0&&c?(this.async?this.invoke(o,this,n):(this.invoke(o,this),n()),!0):(n(),!0)):(this.last=[],"function"==typeof this.notfound&&this.invoke([this.notfound],{method:t,path:e},r),!1)},c.prototype.invoke=function(t,e,r){var n,o=this;this.async?(n=function(r,o){if(Array.isArray(r))return(0,i._asyncEverySeries)(r,n,o);"function"==typeof r&&r.apply(e,(t.captures||[]).concat(o))},(0,i._asyncEverySeries)(t,n,function(){r&&r.apply(e,arguments)})):(n=function(r){return Array.isArray(r)?(0,i._every)(r,n):"function"==typeof r?r.apply(e,t.captures||[]):void("string"==typeof r&&o.resource&&o.resource[r].apply(e,t.captures||[]))},(0,i._every)(t,n))},c.prototype.traverse=function(t,e,r,o,i){function s(t){function e(t){for(var r=[],n=0;n<t.length;n++)r[n]=Array.isArray(t[n])?e(t[n]):t[n];return r}function r(t){for(var e=t.length-1;e>=0;e--)Array.isArray(t[e])?(r(t[e]),0===t[e].length&&t.splice(e,1)):i(t[e])||t.splice(e,1)}if(!i)return t;var n=e(t);return n.matched=t.matched,n.captures=t.captures,n.after=t.after.filter(i),r(n),n}var c,u,a,f,h=[];if(e===this.delimiter&&r[t])return f=[[r.before,r[t]].filter(Boolean)],f.after=[r.after].filter(Boolean),f.matched=!0,f.captures=[],s(f);for(var l in r)if(r.hasOwnProperty(l)&&(!this._methods[l]||this._methods[l]&&"object"===n(r[l])&&!Array.isArray(r[l]))){if(c=u=o+this.delimiter+l,this.strict||(u+="["+this.delimiter+"]?"),!(a=e.match(new RegExp("^"+u))))continue;if(a[0]&&a[0]==e&&r[l][t])return f=[[r[l].before,r[l][t]].filter(Boolean)],f.after=[r[l].after].filter(Boolean),f.matched=!0,f.captures=a.slice(1),this.recurse&&r===this.routes&&(f.push([r.before,r.on].filter(Boolean)),f.after=f.after.concat([r.after].filter(Boolean))),s(f);if(f=this.traverse(t,e,r[l],c),f.matched)return f.length>0&&(h=h.concat(f)),this.recurse&&(h.push([r[l].before,r[l].on].filter(Boolean)),f.after=f.after.concat([r[l].after].filter(Boolean)),r===this.routes&&(h.push([r.before,r.on].filter(Boolean)),f.after=f.after.concat([r.after].filter(Boolean)))),h.matched=!0,h.captures=f.captures,h.after=f.after,s(h)}return!1},c.prototype.insert=function(t,e,r,o){var s,c,u,a;if(e=e.filter(function(t){return t&&t.length>0}),o=o||this.routes,a=e.shift(),/\:|\*/.test(a)&&!/\\d|\\w/.test(a)&&(a=(0,i.regifyString)(a,this.params)),e.length>0)return o[a]=o[a]||{},this.insert(t,e,r,o[a]);if(a||e.length||o!==this.routes){if(s=n(o[a]),c=Array.isArray(o[a]),o[a]&&!c&&"object"==s)switch(n(o[a][t])){case"function":return void(o[a][t]=[o[a][t],r]);case"object":return void o[a][t].push(r);case"undefined":return void(o[a][t]=r)}else if("undefined"==s)return u={},u[t]=r,void(o[a]=u);throw new Error("Invalid route context: "+s)}switch(n(o[t])){case"function":return void(o[t]=[o[t],r]);case"object":return void o[t].push(r);case"undefined":return void(o[t]=r)}},c.prototype.extend=function(t){var e,r=this,n=t.length;for(e=0;e<n;e++)!function(t){r._methods[t]=!0,r[t]=function(){var e=1===arguments.length?[t,""]:[t];r.on.apply(r,e.concat(Array.prototype.slice.call(arguments)))}}(t[e])},c.prototype.runlist=function(t){var e=this.every&&this.every.before?[this.every.before].concat((0,i._flatten)(t)):(0,i._flatten)(t);return this.every&&this.every.on&&e.push(this.every.on),e.captures=t.captures,e.source=t.source,e},c.prototype.mount=function(t,e){if(t&&"object"===(void 0===t?"undefined":n(t))&&!Array.isArray(t)){var r=this;e=e||[],Array.isArray(e)||(e=e.split(r.delimiter));for(var o in t)t.hasOwnProperty(o)&&function(e,o){var s=e,c=e.split(r.delimiter),u=n(t[e]),a=""===c[0]||!r._methods[c[0]],f=a?"on":s;if(a&&(s=s.slice((s.match(new RegExp("^"+r.delimiter))||[""])[0].length),c.shift()),a&&"object"===u&&!Array.isArray(t[e]))return o=o.concat(c),void r.mount(t[e],o);a&&(o=o.concat(s.split(r.delimiter)),o=(0,i.terminator)(o,r.delimiter)),r.insert(f,o,t[e])}(o,e.slice(0))}},t.exports=c},function(t,e,r){var n=r(4);n(n.S,"Array",{isArray:r(9)})},function(t,e,r){var n=r(14),o=r(15),i=r(17),s=Object.defineProperty;e.f=r(2)?Object.defineProperty:function(t,e,r){if(n(t),e=i(e,!0),n(r),o)try{return s(t,e,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[e]=r.value),t}},function(t,e,r){var n=r(1);t.exports=function(t){if(!n(t))throw TypeError(t+" is not an object!");return t}},function(t,e,r){t.exports=!r(2)&&!r(3)(function(){return 7!=Object.defineProperty(r(16)("div"),"a",{get:function(){return 7}}).a})},function(t,e,r){var n=r(1),o=r(0).document,i=n(o)&&n(o.createElement);t.exports=function(t){return i?o.createElement(t):{}}},function(t,e,r){var n=r(1);t.exports=function(t,e){if(!n(t))return t;var r,o;if(e&&"function"==typeof(r=t.toString)&&!n(o=r.call(t)))return o;if("function"==typeof(r=t.valueOf)&&!n(o=r.call(t)))return o;if(!e&&"function"==typeof(r=t.toString)&&!n(o=r.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e,r){var n=r(0),o=r(6),i=r(20),s=r(7)("src"),c=Function.toString,u=(""+c).split("toString");r(5).inspectSource=function(t){return c.call(t)},(t.exports=function(t,e,r,c){var a="function"==typeof r;a&&(i(r,"name")||o(r,"name",e)),t[e]!==r&&(a&&(i(r,s)||o(r,s,t[e]?""+t[e]:u.join(String(e)))),t===n?t[e]=r:c?t[e]?t[e]=r:o(t,e,r):(delete t[e],o(t,e,r)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[s]||c.call(this)})},function(t,e){var r={}.hasOwnProperty;t.exports=function(t,e){return r.call(t,e)}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,e,r){"use strict";var n=r(4),o=r(23)(2);n(n.P+n.F*!r(33)([].filter,!0),"Array",{filter:function(t){return o(this,t,arguments[1])}})},function(t,e,r){var n=r(8),o=r(24),i=r(25),s=r(27),c=r(29);t.exports=function(t,e){var r=1==t,u=2==t,a=3==t,f=4==t,h=6==t,l=5==t||h,p=e||c;return function(e,c,y){for(var d,v,m=i(e),g=o(m),x=n(c,y,3),w=s(g.length),_=0,b=r?p(e,w):u?p(e,0):void 0;w>_;_++)if((l||_ in g)&&(d=g[_],v=x(d,_,m),t))if(r)b[_]=v;else if(v)switch(t){case 3:return!0;case 5:return d;case 6:return _;case 2:b.push(d)}else if(f)return!1;return h?-1:a||f?f:b}}},function(t,e,r){var n=r(10);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==n(t)?t.split(""):Object(t)}},function(t,e,r){var n=r(26);t.exports=function(t){return Object(n(t))}},function(t,e){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,e,r){var n=r(28),o=Math.min;t.exports=function(t){return t>0?o(n(t),9007199254740991):0}},function(t,e){var r=Math.ceil,n=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?n:r)(t)}},function(t,e,r){var n=r(30);t.exports=function(t,e){return new(n(t))(e)}},function(t,e,r){var n=r(1),o=r(9),i=r(31)("species");t.exports=function(t){var e;return o(t)&&(e=t.constructor,"function"!=typeof e||e!==Array&&!o(e.prototype)||(e=void 0),n(e)&&null===(e=e[i])&&(e=void 0)),void 0===e?Array:e}},function(t,e,r){var n=r(32)("wks"),o=r(7),i=r(0).Symbol,s="function"==typeof i;(t.exports=function(t){return n[t]||(n[t]=s&&i[t]||(s?i:o)("Symbol."+t))}).store=n},function(t,e,r){var n=r(0),o=n["__core-js_shared__"]||(n["__core-js_shared__"]={});t.exports=function(t){return o[t]||(o[t]={})}},function(t,e,r){var n=r(3);t.exports=function(t,e){return!!t&&n(function(){e?t.call(null,function(){},1):t.call(null)})}},function(t,e,r){"use strict";function n(){return""===o.hash||"#"===o.hash}var o=document.location,i={mode:"modern",hash:o.hash,history:!1,check:function(){var t=o.hash;t!=this.hash&&(this.hash=t,this.onHashChanged())},fire:function(){"modern"===this.mode?!0===this.history?window.onpopstate():window.onhashchange():this.onHashChanged()},init:function(t,e){function r(t){for(var e=0,r=Router.listeners.length;e<r;e++)Router.listeners[e](t)}var n=this;if(this.history=e,Router.listeners||(Router.listeners=[]),"onhashchange"in window&&(void 0===document.documentMode||document.documentMode>7))!0===this.history?setTimeout(function(){window.onpopstate=r},500):window.onhashchange=r,this.mode="modern";else{var o=document.createElement("iframe");o.id="state-frame",o.style.display="none",document.body.appendChild(o),this.writeFrame(""),"onpropertychange"in document&&"attachEvent"in document&&document.attachEvent("onpropertychange",function(){"location"===event.propertyName&&n.check()}),window.setInterval(function(){n.check()},50),this.onHashChanged=r,this.mode="legacy"}return Router.listeners.push(t),this.mode},destroy:function(t){if(Router&&Router.listeners)for(var e=Router.listeners,r=e.length-1;r>=0;r--)e[r]===t&&e.splice(r,1)},setHash:function(t){return"legacy"===this.mode&&this.writeFrame(t),!0===this.history?(window.history.pushState({},document.title,t),this.fire()):o.hash="/"===t[0]?t:"/"+t,this},writeFrame:function(t){var e=document.getElementById("state-frame"),r=e.contentDocument||e.contentWindow.document;r.open(),r.write("<script>_hash = '"+t+"'; onload = parent.listener.syncHash;<script>"),r.close()},syncHash:function(){var t=this._hash;return t!=o.hash&&(o.hash=t),this},onHashChanged:function(){}};t.exports={dloc:o,dlocHashEmpty:n,listener:i}},function(t,e,r){"use strict";function n(t,e){for(var r=0;r<t.length;r+=1)if(!1===e(t[r],r,t))return}function o(t){for(var e=[],r=0,n=t.length;r<n;r++)e=e.concat(t[r]);return e}function i(t,e,r){if(!t.length)return r();var n=0;!function o(){e(t[n],function(e){e||!1===e?(r(e),r=function(){}):(n+=1,n===t.length?r():o())})}()}function s(t,e,r){r=t;for(var n in e)if(e.hasOwnProperty(n)&&(r=e[n](t))!==t)break;return r===t?"([._a-zA-Z0-9-%()]+)":r}function c(t,e){for(var r,n=0,o="";r=t.substr(n).match(/[^\w\d\- %@&]*\*[^\w\d\- %@&]*/);)n=r.index+r[0].length,r[0]=r[0].replace(/^\*/,"([_.()!\\ %@&a-zA-Z0-9-]+)"),o+=t.substr(0,r.index)+r[0];t=o+=t.substr(n);var i,c,u=t.match(/:([^\/]+)/gi);if(u){c=u.length;for(var a=0;a<c;a++)i=u[a],t="::"===i.slice(0,2)?i.slice(1):t.replace(i,s(i,e))}return t}function u(t,e,r,n){var o,i=0,s=0,c=0,r=(r||"(").toString(),n=(n||")").toString();for(o=0;o<t.length;o++){var u=t[o];if(u.indexOf(r,i)>u.indexOf(n,i)||~u.indexOf(r,i)&&!~u.indexOf(n,i)||!~u.indexOf(r,i)&&~u.indexOf(n,i)){if(s=u.indexOf(r,i),c=u.indexOf(n,i),~s&&!~c||!~s&&~c){t=[t.slice(0,(o||1)+1).join(e)].concat(t.slice((o||1)+1))}i=(c>s?c:s)+1,o=0}else i=0}return t}t.exports={_every:n,_flatten:o,_asyncEverySeries:i,paramifyString:s,regifyString:c,terminator:u}}])});
|