rails-vue 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * vue-resource v1.5.1
3
+ * https://github.com/pagekit/vue-resource
4
+ * Released under the MIT License.
5
+ */
6
+
7
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueResource=e()}(this,function(){"use strict";function u(t){this.state=2,this.value=void 0,this.deferred=[];var e=this;try{t(function(t){e.resolve(t)},function(t){e.reject(t)})}catch(t){e.reject(t)}}u.reject=function(n){return new u(function(t,e){e(n)})},u.resolve=function(n){return new u(function(t,e){t(n)})},u.all=function(s){return new u(function(n,t){var o=0,r=[];function e(e){return function(t){r[e]=t,(o+=1)===s.length&&n(r)}}0===s.length&&n(r);for(var i=0;i<s.length;i+=1)u.resolve(s[i]).then(e(i),t)})},u.race=function(o){return new u(function(t,e){for(var n=0;n<o.length;n+=1)u.resolve(o[n]).then(t,e)})};var t=u.prototype;function c(t,e){t instanceof Promise?this.promise=t:this.promise=new Promise(t.bind(e)),this.context=e}t.resolve=function(t){var e=this;if(2===e.state){if(t===e)throw new TypeError("Promise settled with itself.");var n=!1;try{var o=t&&t.then;if(null!==t&&"object"==typeof t&&"function"==typeof o)return void o.call(t,function(t){n||e.resolve(t),n=!0},function(t){n||e.reject(t),n=!0})}catch(t){return void(n||e.reject(t))}e.state=0,e.value=t,e.notify()}},t.reject=function(t){var e=this;if(2===e.state){if(t===e)throw new TypeError("Promise settled with itself.");e.state=1,e.value=t,e.notify()}},t.notify=function(){var t,i=this;r(function(){if(2!==i.state)for(;i.deferred.length;){var t=i.deferred.shift(),e=t[0],n=t[1],o=t[2],r=t[3];try{0===i.state?o("function"==typeof e?e.call(void 0,i.value):i.value):1===i.state&&("function"==typeof n?o(n.call(void 0,i.value)):r(i.value))}catch(t){r(t)}}},t)},t.then=function(n,o){var r=this;return new u(function(t,e){r.deferred.push([n,o,t,e]),r.notify()})},t.catch=function(t){return this.then(void 0,t)},"undefined"==typeof Promise&&(window.Promise=u),c.all=function(t,e){return new c(Promise.all(t),e)},c.resolve=function(t,e){return new c(Promise.resolve(t),e)},c.reject=function(t,e){return new c(Promise.reject(t),e)},c.race=function(t,e){return new c(Promise.race(t),e)};var e=c.prototype;e.bind=function(t){return this.context=t,this},e.then=function(t,e){return t&&t.bind&&this.context&&(t=t.bind(this.context)),e&&e.bind&&this.context&&(e=e.bind(this.context)),new c(this.promise.then(t,e),this.context)},e.catch=function(t){return t&&t.bind&&this.context&&(t=t.bind(this.context)),new c(this.promise.catch(t),this.context)},e.finally=function(e){return this.then(function(t){return e.call(this),t},function(t){return e.call(this),Promise.reject(t)})};var r,i={}.hasOwnProperty,o=[].slice,a=!1,s="undefined"!=typeof window;function f(t){return t?t.replace(/^\s*|\s*$/g,""):""}function p(t){return t?t.toLowerCase():""}var h=Array.isArray;function d(t){return"string"==typeof t}function l(t){return"function"==typeof t}function m(t){return null!==t&&"object"==typeof t}function y(t){return m(t)&&Object.getPrototypeOf(t)==Object.prototype}function v(t,e,n){var o=c.resolve(t);return arguments.length<2?o:o.then(e,n)}function b(t,e,n){return l(n=n||{})&&(n=n.call(e)),T(t.bind({$vm:e,$options:n}),t,{$options:n})}function g(t,e){var n,o;if(h(t))for(n=0;n<t.length;n++)e.call(t[n],t[n],n);else if(m(t))for(o in t)i.call(t,o)&&e.call(t[o],t[o],o);return t}var w=Object.assign||function(e){return o.call(arguments,1).forEach(function(t){x(e,t)}),e};function T(e){return o.call(arguments,1).forEach(function(t){x(e,t,!0)}),e}function x(t,e,n){for(var o in e)n&&(y(e[o])||h(e[o]))?(y(e[o])&&!y(t[o])&&(t[o]={}),h(e[o])&&!h(t[o])&&(t[o]=[]),x(t[o],e[o],n)):void 0!==e[o]&&(t[o]=e[o])}function j(t,e,n){var o,u,a,r=(o=t,u=["+","#",".","/",";","?","&"],{vars:a=[],expand:function(s){return o.replace(/\{([^{}]+)\}|([^{}]+)/g,function(t,e,n){if(e){var o=null,r=[];if(-1!==u.indexOf(e.charAt(0))&&(o=e.charAt(0),e=e.substr(1)),e.split(/,/g).forEach(function(t){var e=/([^:*]*)(?::(\d+)|(\*))?/.exec(t);r.push.apply(r,function(t,e,n,o){var r=t[n],i=[];if(E(r)&&""!==r)if("string"==typeof r||"number"==typeof r||"boolean"==typeof r)r=r.toString(),o&&"*"!==o&&(r=r.substring(0,parseInt(o,10))),i.push(O(e,r,P(e)?n:null));else if("*"===o)Array.isArray(r)?r.filter(E).forEach(function(t){i.push(O(e,t,P(e)?n:null))}):Object.keys(r).forEach(function(t){E(r[t])&&i.push(O(e,r[t],t))});else{var s=[];Array.isArray(r)?r.filter(E).forEach(function(t){s.push(O(e,t))}):Object.keys(r).forEach(function(t){E(r[t])&&(s.push(encodeURIComponent(t)),s.push(O(e,r[t].toString())))}),P(e)?i.push(encodeURIComponent(n)+"="+s.join(",")):0!==s.length&&i.push(s.join(","))}else";"===e?i.push(encodeURIComponent(n)):""!==r||"&"!==e&&"?"!==e?""===r&&i.push(""):i.push(encodeURIComponent(n)+"=");return i}(s,o,e[1],e[2]||e[3])),a.push(e[1])}),o&&"+"!==o){var i=",";return"?"===o?i="&":"#"!==o&&(i=o),(0!==r.length?o:"")+r.join(i)}return r.join(",")}return C(n)})}}),i=r.expand(e);return n&&n.push.apply(n,r.vars),i}function E(t){return null!=t}function P(t){return";"===t||"&"===t||"?"===t}function O(t,e,n){return e="+"===t||"#"===t?C(e):encodeURIComponent(e),n?encodeURIComponent(n)+"="+e:e}function C(t){return t.split(/(%[0-9A-Fa-f]{2})/g).map(function(t){return/%[0-9A-Fa-f]/.test(t)||(t=encodeURI(t)),t}).join("")}function $(t,e){var r,i=this||{},n=t;return d(t)&&(n={url:t,params:e}),n=T({},$.options,i.$options,n),$.transforms.forEach(function(t){var e,n,o;d(t)&&(t=$.transform[t]),l(t)&&(e=t,n=r,o=i.$vm,r=function(t){return e.call(o,t,n)})}),r(n)}function U(i){return new c(function(o){var r=new XDomainRequest,t=function(t){var e=t.type,n=0;"load"===e?n=200:"error"===e&&(n=500),o(i.respondWith(r.responseText,{status:n}))};i.abort=function(){return r.abort()},r.open(i.method,i.getUrl()),i.timeout&&(r.timeout=i.timeout),r.onload=t,r.onabort=t,r.onerror=t,r.ontimeout=t,r.onprogress=function(){},r.send(i.getBody())})}$.options={url:"",root:null,params:{}},$.transform={template:function(e){var t=[],n=j(e.url,e.params,t);return t.forEach(function(t){delete e.params[t]}),n},query:function(t,e){var n=Object.keys($.options.params),o={},r=e(t);return g(t.params,function(t,e){-1===n.indexOf(e)&&(o[e]=t)}),(o=$.params(o))&&(r+=(-1==r.indexOf("?")?"?":"&")+o),r},root:function(t,e){var n,o,r=e(t);return d(t.root)&&!/^(https?:)?\//.test(r)&&(n=t.root,o="/",r=(n&&void 0===o?n.replace(/\s+$/,""):n&&o?n.replace(new RegExp("["+o+"]+$"),""):n)+"/"+r),r}},$.transforms=["template","query","root"],$.params=function(t){var e=[],n=encodeURIComponent;return e.add=function(t,e){l(e)&&(e=e()),null===e&&(e=""),this.push(n(t)+"="+n(e))},function n(o,t,r){var i,s=h(t),u=y(t);g(t,function(t,e){i=m(t)||h(t),r&&(e=r+"["+(u||i?e:"")+"]"),!r&&s?o.add(t.name,t.value):i?n(o,t,e):o.add(e,t)})}(e,t),e.join("&").replace(/%20/g,"+")},$.parse=function(t){var e=document.createElement("a");return document.documentMode&&(e.href=t,t=e.href),e.href=t,{href:e.href,protocol:e.protocol?e.protocol.replace(/:$/,""):"",port:e.port,host:e.host,hostname:e.hostname,pathname:"/"===e.pathname.charAt(0)?e.pathname:"/"+e.pathname,search:e.search?e.search.replace(/^\?/,""):"",hash:e.hash?e.hash.replace(/^#/,""):""}};var R=s&&"withCredentials"in new XMLHttpRequest;function n(u){return new c(function(o){var t,r,e=u.jsonp||"callback",i=u.jsonpCallback||"_jsonp"+Math.random().toString(36).substr(2),s=null;t=function(t){var e=t.type,n=0;"load"===e&&null!==s?n=200:"error"===e&&(n=500),n&&window[i]&&(delete window[i],document.body.removeChild(r)),o(u.respondWith(s,{status:n}))},window[i]=function(t){s=JSON.stringify(t)},u.abort=function(){t({type:"abort"})},u.params[e]=i,u.timeout&&setTimeout(u.abort,u.timeout),(r=document.createElement("script")).src=u.getUrl(),r.type="text/javascript",r.async=!0,r.onload=t,r.onerror=t,document.body.appendChild(r)})}function A(r){return new c(function(n){var o=new XMLHttpRequest,t=function(t){var e=r.respondWith("response"in o?o.response:o.responseText,{status:1223===o.status?204:o.status,statusText:1223===o.status?"No Content":f(o.statusText)});g(f(o.getAllResponseHeaders()).split("\n"),function(t){e.headers.append(t.slice(0,t.indexOf(":")),t.slice(t.indexOf(":")+1))}),n(e)};r.abort=function(){return o.abort()},o.open(r.method,r.getUrl(),!0),r.timeout&&(o.timeout=r.timeout),r.responseType&&"responseType"in o&&(o.responseType=r.responseType),(r.withCredentials||r.credentials)&&(o.withCredentials=!0),r.crossOrigin||r.headers.set("X-Requested-With","XMLHttpRequest"),l(r.progress)&&"GET"===r.method&&o.addEventListener("progress",r.progress),l(r.downloadProgress)&&o.addEventListener("progress",r.downloadProgress),l(r.progress)&&/^(POST|PUT)$/i.test(r.method)&&o.upload.addEventListener("progress",r.progress),l(r.uploadProgress)&&o.upload&&o.upload.addEventListener("progress",r.uploadProgress),r.headers.forEach(function(t,e){o.setRequestHeader(e,t)}),o.onload=t,o.onabort=t,o.onerror=t,o.ontimeout=t,o.send(r.getBody())})}function S(s){var u=require("got");return new c(function(e){var n,t=s.getUrl(),o=s.getBody(),r=s.method,i={};s.headers.forEach(function(t,e){i[e]=t}),u(t,{body:o,method:r,headers:i}).then(n=function(t){var n=s.respondWith(t.body,{status:t.statusCode,statusText:f(t.statusMessage)});g(t.headers,function(t,e){n.headers.set(e,t)}),e(n)},function(t){return n(t.response)})})}function k(t){return(t.client||(s?A:S))(t)}var I=function(t){var n=this;this.map={},g(t,function(t,e){return n.append(e,t)})};function L(t,n){return Object.keys(t).reduce(function(t,e){return p(n)===p(e)?e:t},null)}I.prototype.has=function(t){return null!==L(this.map,t)},I.prototype.get=function(t){var e=this.map[L(this.map,t)];return e?e.join():null},I.prototype.getAll=function(t){return this.map[L(this.map,t)]||[]},I.prototype.set=function(t,e){this.map[function(t){if(/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return f(t)}(L(this.map,t)||t)]=[f(e)]},I.prototype.append=function(t,e){var n=this.map[L(this.map,t)];n?n.push(f(e)):this.set(t,e)},I.prototype.delete=function(t){delete this.map[L(this.map,t)]},I.prototype.deleteAll=function(){this.map={}},I.prototype.forEach=function(n,o){var r=this;g(this.map,function(t,e){g(t,function(t){return n.call(o,t,e,r)})})};var q=function(t,e){var n,o,r,i=e.url,s=e.headers,u=e.status,a=e.statusText;this.url=i,this.ok=200<=u&&u<300,this.status=u||0,this.statusText=a||"",this.headers=new I(s),d(this.body=t)?this.bodyText=t:(r=t,"undefined"!=typeof Blob&&r instanceof Blob&&(this.bodyBlob=t,(0===(o=t).type.indexOf("text")||-1!==o.type.indexOf("json"))&&(this.bodyText=(n=t,new c(function(t){var e=new FileReader;e.readAsText(n),e.onload=function(){t(e.result)}})))))};q.prototype.blob=function(){return v(this.bodyBlob)},q.prototype.text=function(){return v(this.bodyText)},q.prototype.json=function(){return v(this.text(),function(t){return JSON.parse(t)})},Object.defineProperty(q.prototype,"data",{get:function(){return this.body},set:function(t){this.body=t}});var H=function(t){var e;this.body=null,this.params={},w(this,t,{method:(e=t.method||"GET",e?e.toUpperCase():"")}),this.headers instanceof I||(this.headers=new I(this.headers))};H.prototype.getUrl=function(){return $(this)},H.prototype.getBody=function(){return this.body},H.prototype.respondWith=function(t,e){return new q(t,w(e||{},{url:this.getUrl()}))};var B={"Content-Type":"application/json;charset=utf-8"};function M(t){var e=this||{},n=function(i){var s=[k],u=[];function t(t){for(;s.length;){var e=s.pop();if(l(e)){var o=void 0,n=void 0;if(m(o=e.call(i,t,function(t){return n=t})||n))return new c(function(t,n){u.forEach(function(e){o=v(o,function(t){return e.call(i,t)||t},n)}),v(o,t,n)},i);l(o)&&u.unshift(o)}else r="Invalid interceptor of type "+typeof e+", must be a function","undefined"!=typeof console&&a&&console.warn("[VueResource warn]: "+r)}var r}return m(i)||(i=null),t.use=function(t){s.push(t)},t}(e.$vm);return function(n){o.call(arguments,1).forEach(function(t){for(var e in t)void 0===n[e]&&(n[e]=t[e])})}(t||{},e.$options,M.options),M.interceptors.forEach(function(t){d(t)&&(t=M.interceptor[t]),l(t)&&n.use(t)}),n(new H(t)).then(function(t){return t.ok?t:c.reject(t)},function(t){var e;return t instanceof Error&&(e=t,"undefined"!=typeof console&&console.error(e)),c.reject(t)})}function N(n,o,t,r){var i=this||{},s={};return g(t=w({},N.actions,t),function(t,e){t=T({url:n,params:w({},o)},r,t),s[e]=function(){return(i.$http||M)(function(t,e){var n,o=w({},t),r={};switch(e.length){case 2:r=e[0],n=e[1];break;case 1:/^(POST|PUT|PATCH)$/i.test(o.method)?n=e[0]:r=e[0];break;case 0:break;default:throw"Expected up to 2 arguments [params, body], got "+e.length+" arguments"}return o.body=n,o.params=w({},o.params,r),o}(t,arguments))}}),s}function D(n){var t,e,o;D.installed||(e=(t=n).config,o=t.nextTick,r=o,a=e.debug||!e.silent,n.url=$,n.http=M,n.resource=N,n.Promise=c,Object.defineProperties(n.prototype,{$url:{get:function(){return b(n.url,this,this.$options.url)}},$http:{get:function(){return b(n.http,this,this.$options.http)}},$resource:{get:function(){return n.resource.bind(this)}},$promise:{get:function(){var e=this;return function(t){return new n.Promise(t,e)}}}}))}return M.options={},M.headers={put:B,post:B,patch:B,delete:B,common:{Accept:"application/json, text/plain, */*"},custom:{}},M.interceptor={before:function(t){l(t.before)&&t.before.call(this,t)},method:function(t){t.emulateHTTP&&/^(PUT|PATCH|DELETE)$/i.test(t.method)&&(t.headers.set("X-HTTP-Method-Override",t.method),t.method="POST")},jsonp:function(t){"JSONP"==t.method&&(t.client=n)},json:function(t){var e=t.headers.get("Content-Type")||"";return m(t.body)&&0===e.indexOf("application/json")&&(t.body=JSON.stringify(t.body)),function(o){return o.bodyText?v(o.text(),function(t){var e,n;if(0===(o.headers.get("Content-Type")||"").indexOf("application/json")||(n=(e=t).match(/^\s*(\[|\{)/))&&{"[":/]\s*$/,"{":/}\s*$/}[n[1]].test(e))try{o.body=JSON.parse(t)}catch(t){o.body=null}else o.body=t;return o}):o}},form:function(t){var e;e=t.body,"undefined"!=typeof FormData&&e instanceof FormData?t.headers.delete("Content-Type"):m(t.body)&&t.emulateJSON&&(t.body=$.params(t.body),t.headers.set("Content-Type","application/x-www-form-urlencoded"))},header:function(n){g(w({},M.headers.common,n.crossOrigin?{}:M.headers.custom,M.headers[p(n.method)]),function(t,e){n.headers.has(e)||n.headers.set(e,t)})},cors:function(t){if(s){var e=$.parse(location.href),n=$.parse(t.getUrl());n.protocol===e.protocol&&n.host===e.host||(t.crossOrigin=!0,t.emulateHTTP=!1,R||(t.client=U))}}},M.interceptors=["before","method","jsonp","json","form","header","cors"],["get","delete","head","jsonp"].forEach(function(n){M[n]=function(t,e){return this(w(e||{},{url:t,method:n}))}}),["post","put","patch"].forEach(function(o){M[o]=function(t,e,n){return this(w(n||{},{url:t,method:o,body:e}))}}),N.actions={get:{method:"GET"},save:{method:"POST"},query:{method:"GET"},update:{method:"PUT"},remove:{method:"DELETE"},delete:{method:"DELETE"}},"undefined"!=typeof window&&window.Vue&&window.Vue.use(D),D});
@@ -0,0 +1,2626 @@
1
+ /*!
2
+ * vue-router v3.0.2
3
+ * (c) 2018 Evan You
4
+ * @license MIT
5
+ */
6
+ (function (global, factory) {
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
8
+ typeof define === 'function' && define.amd ? define(factory) :
9
+ (global.VueRouter = factory());
10
+ }(this, (function () { 'use strict';
11
+
12
+ /* */
13
+
14
+ function assert (condition, message) {
15
+ if (!condition) {
16
+ throw new Error(("[vue-router] " + message))
17
+ }
18
+ }
19
+
20
+ function warn (condition, message) {
21
+ if ("development" !== 'production' && !condition) {
22
+ typeof console !== 'undefined' && console.warn(("[vue-router] " + message));
23
+ }
24
+ }
25
+
26
+ function isError (err) {
27
+ return Object.prototype.toString.call(err).indexOf('Error') > -1
28
+ }
29
+
30
+ function extend (a, b) {
31
+ for (var key in b) {
32
+ a[key] = b[key];
33
+ }
34
+ return a
35
+ }
36
+
37
+ var View = {
38
+ name: 'RouterView',
39
+ functional: true,
40
+ props: {
41
+ name: {
42
+ type: String,
43
+ default: 'default'
44
+ }
45
+ },
46
+ render: function render (_, ref) {
47
+ var props = ref.props;
48
+ var children = ref.children;
49
+ var parent = ref.parent;
50
+ var data = ref.data;
51
+
52
+ // used by devtools to display a router-view badge
53
+ data.routerView = true;
54
+
55
+ // directly use parent context's createElement() function
56
+ // so that components rendered by router-view can resolve named slots
57
+ var h = parent.$createElement;
58
+ var name = props.name;
59
+ var route = parent.$route;
60
+ var cache = parent._routerViewCache || (parent._routerViewCache = {});
61
+
62
+ // determine current view depth, also check to see if the tree
63
+ // has been toggled inactive but kept-alive.
64
+ var depth = 0;
65
+ var inactive = false;
66
+ while (parent && parent._routerRoot !== parent) {
67
+ if (parent.$vnode && parent.$vnode.data.routerView) {
68
+ depth++;
69
+ }
70
+ if (parent._inactive) {
71
+ inactive = true;
72
+ }
73
+ parent = parent.$parent;
74
+ }
75
+ data.routerViewDepth = depth;
76
+
77
+ // render previous view if the tree is inactive and kept-alive
78
+ if (inactive) {
79
+ return h(cache[name], data, children)
80
+ }
81
+
82
+ var matched = route.matched[depth];
83
+ // render empty node if no matched route
84
+ if (!matched) {
85
+ cache[name] = null;
86
+ return h()
87
+ }
88
+
89
+ var component = cache[name] = matched.components[name];
90
+
91
+ // attach instance registration hook
92
+ // this will be called in the instance's injected lifecycle hooks
93
+ data.registerRouteInstance = function (vm, val) {
94
+ // val could be undefined for unregistration
95
+ var current = matched.instances[name];
96
+ if (
97
+ (val && current !== vm) ||
98
+ (!val && current === vm)
99
+ ) {
100
+ matched.instances[name] = val;
101
+ }
102
+ }
103
+
104
+ // also register instance in prepatch hook
105
+ // in case the same component instance is reused across different routes
106
+ ;(data.hook || (data.hook = {})).prepatch = function (_, vnode) {
107
+ matched.instances[name] = vnode.componentInstance;
108
+ };
109
+
110
+ // resolve props
111
+ var propsToPass = data.props = resolveProps(route, matched.props && matched.props[name]);
112
+ if (propsToPass) {
113
+ // clone to prevent mutation
114
+ propsToPass = data.props = extend({}, propsToPass);
115
+ // pass non-declared props as attrs
116
+ var attrs = data.attrs = data.attrs || {};
117
+ for (var key in propsToPass) {
118
+ if (!component.props || !(key in component.props)) {
119
+ attrs[key] = propsToPass[key];
120
+ delete propsToPass[key];
121
+ }
122
+ }
123
+ }
124
+
125
+ return h(component, data, children)
126
+ }
127
+ }
128
+
129
+ function resolveProps (route, config) {
130
+ switch (typeof config) {
131
+ case 'undefined':
132
+ return
133
+ case 'object':
134
+ return config
135
+ case 'function':
136
+ return config(route)
137
+ case 'boolean':
138
+ return config ? route.params : undefined
139
+ default:
140
+ {
141
+ warn(
142
+ false,
143
+ "props in \"" + (route.path) + "\" is a " + (typeof config) + ", " +
144
+ "expecting an object, function or boolean."
145
+ );
146
+ }
147
+ }
148
+ }
149
+
150
+ /* */
151
+
152
+ var encodeReserveRE = /[!'()*]/g;
153
+ var encodeReserveReplacer = function (c) { return '%' + c.charCodeAt(0).toString(16); };
154
+ var commaRE = /%2C/g;
155
+
156
+ // fixed encodeURIComponent which is more conformant to RFC3986:
157
+ // - escapes [!'()*]
158
+ // - preserve commas
159
+ var encode = function (str) { return encodeURIComponent(str)
160
+ .replace(encodeReserveRE, encodeReserveReplacer)
161
+ .replace(commaRE, ','); };
162
+
163
+ var decode = decodeURIComponent;
164
+
165
+ function resolveQuery (
166
+ query,
167
+ extraQuery,
168
+ _parseQuery
169
+ ) {
170
+ if ( extraQuery === void 0 ) extraQuery = {};
171
+
172
+ var parse = _parseQuery || parseQuery;
173
+ var parsedQuery;
174
+ try {
175
+ parsedQuery = parse(query || '');
176
+ } catch (e) {
177
+ "development" !== 'production' && warn(false, e.message);
178
+ parsedQuery = {};
179
+ }
180
+ for (var key in extraQuery) {
181
+ parsedQuery[key] = extraQuery[key];
182
+ }
183
+ return parsedQuery
184
+ }
185
+
186
+ function parseQuery (query) {
187
+ var res = {};
188
+
189
+ query = query.trim().replace(/^(\?|#|&)/, '');
190
+
191
+ if (!query) {
192
+ return res
193
+ }
194
+
195
+ query.split('&').forEach(function (param) {
196
+ var parts = param.replace(/\+/g, ' ').split('=');
197
+ var key = decode(parts.shift());
198
+ var val = parts.length > 0
199
+ ? decode(parts.join('='))
200
+ : null;
201
+
202
+ if (res[key] === undefined) {
203
+ res[key] = val;
204
+ } else if (Array.isArray(res[key])) {
205
+ res[key].push(val);
206
+ } else {
207
+ res[key] = [res[key], val];
208
+ }
209
+ });
210
+
211
+ return res
212
+ }
213
+
214
+ function stringifyQuery (obj) {
215
+ var res = obj ? Object.keys(obj).map(function (key) {
216
+ var val = obj[key];
217
+
218
+ if (val === undefined) {
219
+ return ''
220
+ }
221
+
222
+ if (val === null) {
223
+ return encode(key)
224
+ }
225
+
226
+ if (Array.isArray(val)) {
227
+ var result = [];
228
+ val.forEach(function (val2) {
229
+ if (val2 === undefined) {
230
+ return
231
+ }
232
+ if (val2 === null) {
233
+ result.push(encode(key));
234
+ } else {
235
+ result.push(encode(key) + '=' + encode(val2));
236
+ }
237
+ });
238
+ return result.join('&')
239
+ }
240
+
241
+ return encode(key) + '=' + encode(val)
242
+ }).filter(function (x) { return x.length > 0; }).join('&') : null;
243
+ return res ? ("?" + res) : ''
244
+ }
245
+
246
+ /* */
247
+
248
+ var trailingSlashRE = /\/?$/;
249
+
250
+ function createRoute (
251
+ record,
252
+ location,
253
+ redirectedFrom,
254
+ router
255
+ ) {
256
+ var stringifyQuery$$1 = router && router.options.stringifyQuery;
257
+
258
+ var query = location.query || {};
259
+ try {
260
+ query = clone(query);
261
+ } catch (e) {}
262
+
263
+ var route = {
264
+ name: location.name || (record && record.name),
265
+ meta: (record && record.meta) || {},
266
+ path: location.path || '/',
267
+ hash: location.hash || '',
268
+ query: query,
269
+ params: location.params || {},
270
+ fullPath: getFullPath(location, stringifyQuery$$1),
271
+ matched: record ? formatMatch(record) : []
272
+ };
273
+ if (redirectedFrom) {
274
+ route.redirectedFrom = getFullPath(redirectedFrom, stringifyQuery$$1);
275
+ }
276
+ return Object.freeze(route)
277
+ }
278
+
279
+ function clone (value) {
280
+ if (Array.isArray(value)) {
281
+ return value.map(clone)
282
+ } else if (value && typeof value === 'object') {
283
+ var res = {};
284
+ for (var key in value) {
285
+ res[key] = clone(value[key]);
286
+ }
287
+ return res
288
+ } else {
289
+ return value
290
+ }
291
+ }
292
+
293
+ // the starting route that represents the initial state
294
+ var START = createRoute(null, {
295
+ path: '/'
296
+ });
297
+
298
+ function formatMatch (record) {
299
+ var res = [];
300
+ while (record) {
301
+ res.unshift(record);
302
+ record = record.parent;
303
+ }
304
+ return res
305
+ }
306
+
307
+ function getFullPath (
308
+ ref,
309
+ _stringifyQuery
310
+ ) {
311
+ var path = ref.path;
312
+ var query = ref.query; if ( query === void 0 ) query = {};
313
+ var hash = ref.hash; if ( hash === void 0 ) hash = '';
314
+
315
+ var stringify = _stringifyQuery || stringifyQuery;
316
+ return (path || '/') + stringify(query) + hash
317
+ }
318
+
319
+ function isSameRoute (a, b) {
320
+ if (b === START) {
321
+ return a === b
322
+ } else if (!b) {
323
+ return false
324
+ } else if (a.path && b.path) {
325
+ return (
326
+ a.path.replace(trailingSlashRE, '') === b.path.replace(trailingSlashRE, '') &&
327
+ a.hash === b.hash &&
328
+ isObjectEqual(a.query, b.query)
329
+ )
330
+ } else if (a.name && b.name) {
331
+ return (
332
+ a.name === b.name &&
333
+ a.hash === b.hash &&
334
+ isObjectEqual(a.query, b.query) &&
335
+ isObjectEqual(a.params, b.params)
336
+ )
337
+ } else {
338
+ return false
339
+ }
340
+ }
341
+
342
+ function isObjectEqual (a, b) {
343
+ if ( a === void 0 ) a = {};
344
+ if ( b === void 0 ) b = {};
345
+
346
+ // handle null value #1566
347
+ if (!a || !b) { return a === b }
348
+ var aKeys = Object.keys(a);
349
+ var bKeys = Object.keys(b);
350
+ if (aKeys.length !== bKeys.length) {
351
+ return false
352
+ }
353
+ return aKeys.every(function (key) {
354
+ var aVal = a[key];
355
+ var bVal = b[key];
356
+ // check nested equality
357
+ if (typeof aVal === 'object' && typeof bVal === 'object') {
358
+ return isObjectEqual(aVal, bVal)
359
+ }
360
+ return String(aVal) === String(bVal)
361
+ })
362
+ }
363
+
364
+ function isIncludedRoute (current, target) {
365
+ return (
366
+ current.path.replace(trailingSlashRE, '/').indexOf(
367
+ target.path.replace(trailingSlashRE, '/')
368
+ ) === 0 &&
369
+ (!target.hash || current.hash === target.hash) &&
370
+ queryIncludes(current.query, target.query)
371
+ )
372
+ }
373
+
374
+ function queryIncludes (current, target) {
375
+ for (var key in target) {
376
+ if (!(key in current)) {
377
+ return false
378
+ }
379
+ }
380
+ return true
381
+ }
382
+
383
+ /* */
384
+
385
+ // work around weird flow bug
386
+ var toTypes = [String, Object];
387
+ var eventTypes = [String, Array];
388
+
389
+ var Link = {
390
+ name: 'RouterLink',
391
+ props: {
392
+ to: {
393
+ type: toTypes,
394
+ required: true
395
+ },
396
+ tag: {
397
+ type: String,
398
+ default: 'a'
399
+ },
400
+ exact: Boolean,
401
+ append: Boolean,
402
+ replace: Boolean,
403
+ activeClass: String,
404
+ exactActiveClass: String,
405
+ event: {
406
+ type: eventTypes,
407
+ default: 'click'
408
+ }
409
+ },
410
+ render: function render (h) {
411
+ var this$1 = this;
412
+
413
+ var router = this.$router;
414
+ var current = this.$route;
415
+ var ref = router.resolve(this.to, current, this.append);
416
+ var location = ref.location;
417
+ var route = ref.route;
418
+ var href = ref.href;
419
+
420
+ var classes = {};
421
+ var globalActiveClass = router.options.linkActiveClass;
422
+ var globalExactActiveClass = router.options.linkExactActiveClass;
423
+ // Support global empty active class
424
+ var activeClassFallback = globalActiveClass == null
425
+ ? 'router-link-active'
426
+ : globalActiveClass;
427
+ var exactActiveClassFallback = globalExactActiveClass == null
428
+ ? 'router-link-exact-active'
429
+ : globalExactActiveClass;
430
+ var activeClass = this.activeClass == null
431
+ ? activeClassFallback
432
+ : this.activeClass;
433
+ var exactActiveClass = this.exactActiveClass == null
434
+ ? exactActiveClassFallback
435
+ : this.exactActiveClass;
436
+ var compareTarget = location.path
437
+ ? createRoute(null, location, null, router)
438
+ : route;
439
+
440
+ classes[exactActiveClass] = isSameRoute(current, compareTarget);
441
+ classes[activeClass] = this.exact
442
+ ? classes[exactActiveClass]
443
+ : isIncludedRoute(current, compareTarget);
444
+
445
+ var handler = function (e) {
446
+ if (guardEvent(e)) {
447
+ if (this$1.replace) {
448
+ router.replace(location);
449
+ } else {
450
+ router.push(location);
451
+ }
452
+ }
453
+ };
454
+
455
+ var on = { click: guardEvent };
456
+ if (Array.isArray(this.event)) {
457
+ this.event.forEach(function (e) { on[e] = handler; });
458
+ } else {
459
+ on[this.event] = handler;
460
+ }
461
+
462
+ var data = {
463
+ class: classes
464
+ };
465
+
466
+ if (this.tag === 'a') {
467
+ data.on = on;
468
+ data.attrs = { href: href };
469
+ } else {
470
+ // find the first <a> child and apply listener and href
471
+ var a = findAnchor(this.$slots.default);
472
+ if (a) {
473
+ // in case the <a> is a static node
474
+ a.isStatic = false;
475
+ var aData = a.data = extend({}, a.data);
476
+ aData.on = on;
477
+ var aAttrs = a.data.attrs = extend({}, a.data.attrs);
478
+ aAttrs.href = href;
479
+ } else {
480
+ // doesn't have <a> child, apply listener to self
481
+ data.on = on;
482
+ }
483
+ }
484
+
485
+ return h(this.tag, data, this.$slots.default)
486
+ }
487
+ }
488
+
489
+ function guardEvent (e) {
490
+ // don't redirect with control keys
491
+ if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) { return }
492
+ // don't redirect when preventDefault called
493
+ if (e.defaultPrevented) { return }
494
+ // don't redirect on right click
495
+ if (e.button !== undefined && e.button !== 0) { return }
496
+ // don't redirect if `target="_blank"`
497
+ if (e.currentTarget && e.currentTarget.getAttribute) {
498
+ var target = e.currentTarget.getAttribute('target');
499
+ if (/\b_blank\b/i.test(target)) { return }
500
+ }
501
+ // this may be a Weex event which doesn't have this method
502
+ if (e.preventDefault) {
503
+ e.preventDefault();
504
+ }
505
+ return true
506
+ }
507
+
508
+ function findAnchor (children) {
509
+ if (children) {
510
+ var child;
511
+ for (var i = 0; i < children.length; i++) {
512
+ child = children[i];
513
+ if (child.tag === 'a') {
514
+ return child
515
+ }
516
+ if (child.children && (child = findAnchor(child.children))) {
517
+ return child
518
+ }
519
+ }
520
+ }
521
+ }
522
+
523
+ var _Vue;
524
+
525
+ function install (Vue) {
526
+ if (install.installed && _Vue === Vue) { return }
527
+ install.installed = true;
528
+
529
+ _Vue = Vue;
530
+
531
+ var isDef = function (v) { return v !== undefined; };
532
+
533
+ var registerInstance = function (vm, callVal) {
534
+ var i = vm.$options._parentVnode;
535
+ if (isDef(i) && isDef(i = i.data) && isDef(i = i.registerRouteInstance)) {
536
+ i(vm, callVal);
537
+ }
538
+ };
539
+
540
+ Vue.mixin({
541
+ beforeCreate: function beforeCreate () {
542
+ if (isDef(this.$options.router)) {
543
+ this._routerRoot = this;
544
+ this._router = this.$options.router;
545
+ this._router.init(this);
546
+ Vue.util.defineReactive(this, '_route', this._router.history.current);
547
+ } else {
548
+ this._routerRoot = (this.$parent && this.$parent._routerRoot) || this;
549
+ }
550
+ registerInstance(this, this);
551
+ },
552
+ destroyed: function destroyed () {
553
+ registerInstance(this);
554
+ }
555
+ });
556
+
557
+ Object.defineProperty(Vue.prototype, '$router', {
558
+ get: function get () { return this._routerRoot._router }
559
+ });
560
+
561
+ Object.defineProperty(Vue.prototype, '$route', {
562
+ get: function get () { return this._routerRoot._route }
563
+ });
564
+
565
+ Vue.component('RouterView', View);
566
+ Vue.component('RouterLink', Link);
567
+
568
+ var strats = Vue.config.optionMergeStrategies;
569
+ // use the same hook merging strategy for route hooks
570
+ strats.beforeRouteEnter = strats.beforeRouteLeave = strats.beforeRouteUpdate = strats.created;
571
+ }
572
+
573
+ /* */
574
+
575
+ var inBrowser = typeof window !== 'undefined';
576
+
577
+ /* */
578
+
579
+ function resolvePath (
580
+ relative,
581
+ base,
582
+ append
583
+ ) {
584
+ var firstChar = relative.charAt(0);
585
+ if (firstChar === '/') {
586
+ return relative
587
+ }
588
+
589
+ if (firstChar === '?' || firstChar === '#') {
590
+ return base + relative
591
+ }
592
+
593
+ var stack = base.split('/');
594
+
595
+ // remove trailing segment if:
596
+ // - not appending
597
+ // - appending to trailing slash (last segment is empty)
598
+ if (!append || !stack[stack.length - 1]) {
599
+ stack.pop();
600
+ }
601
+
602
+ // resolve relative path
603
+ var segments = relative.replace(/^\//, '').split('/');
604
+ for (var i = 0; i < segments.length; i++) {
605
+ var segment = segments[i];
606
+ if (segment === '..') {
607
+ stack.pop();
608
+ } else if (segment !== '.') {
609
+ stack.push(segment);
610
+ }
611
+ }
612
+
613
+ // ensure leading slash
614
+ if (stack[0] !== '') {
615
+ stack.unshift('');
616
+ }
617
+
618
+ return stack.join('/')
619
+ }
620
+
621
+ function parsePath (path) {
622
+ var hash = '';
623
+ var query = '';
624
+
625
+ var hashIndex = path.indexOf('#');
626
+ if (hashIndex >= 0) {
627
+ hash = path.slice(hashIndex);
628
+ path = path.slice(0, hashIndex);
629
+ }
630
+
631
+ var queryIndex = path.indexOf('?');
632
+ if (queryIndex >= 0) {
633
+ query = path.slice(queryIndex + 1);
634
+ path = path.slice(0, queryIndex);
635
+ }
636
+
637
+ return {
638
+ path: path,
639
+ query: query,
640
+ hash: hash
641
+ }
642
+ }
643
+
644
+ function cleanPath (path) {
645
+ return path.replace(/\/\//g, '/')
646
+ }
647
+
648
+ var isarray = Array.isArray || function (arr) {
649
+ return Object.prototype.toString.call(arr) == '[object Array]';
650
+ };
651
+
652
+ /**
653
+ * Expose `pathToRegexp`.
654
+ */
655
+ var pathToRegexp_1 = pathToRegexp;
656
+ var parse_1 = parse;
657
+ var compile_1 = compile;
658
+ var tokensToFunction_1 = tokensToFunction;
659
+ var tokensToRegExp_1 = tokensToRegExp;
660
+
661
+ /**
662
+ * The main path matching regexp utility.
663
+ *
664
+ * @type {RegExp}
665
+ */
666
+ var PATH_REGEXP = new RegExp([
667
+ // Match escaped characters that would otherwise appear in future matches.
668
+ // This allows the user to escape special characters that won't transform.
669
+ '(\\\\.)',
670
+ // Match Express-style parameters and un-named parameters with a prefix
671
+ // and optional suffixes. Matches appear as:
672
+ //
673
+ // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined]
674
+ // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined]
675
+ // "/*" => ["/", undefined, undefined, undefined, undefined, "*"]
676
+ '([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))'
677
+ ].join('|'), 'g');
678
+
679
+ /**
680
+ * Parse a string for the raw tokens.
681
+ *
682
+ * @param {string} str
683
+ * @param {Object=} options
684
+ * @return {!Array}
685
+ */
686
+ function parse (str, options) {
687
+ var tokens = [];
688
+ var key = 0;
689
+ var index = 0;
690
+ var path = '';
691
+ var defaultDelimiter = options && options.delimiter || '/';
692
+ var res;
693
+
694
+ while ((res = PATH_REGEXP.exec(str)) != null) {
695
+ var m = res[0];
696
+ var escaped = res[1];
697
+ var offset = res.index;
698
+ path += str.slice(index, offset);
699
+ index = offset + m.length;
700
+
701
+ // Ignore already escaped sequences.
702
+ if (escaped) {
703
+ path += escaped[1];
704
+ continue
705
+ }
706
+
707
+ var next = str[index];
708
+ var prefix = res[2];
709
+ var name = res[3];
710
+ var capture = res[4];
711
+ var group = res[5];
712
+ var modifier = res[6];
713
+ var asterisk = res[7];
714
+
715
+ // Push the current path onto the tokens.
716
+ if (path) {
717
+ tokens.push(path);
718
+ path = '';
719
+ }
720
+
721
+ var partial = prefix != null && next != null && next !== prefix;
722
+ var repeat = modifier === '+' || modifier === '*';
723
+ var optional = modifier === '?' || modifier === '*';
724
+ var delimiter = res[2] || defaultDelimiter;
725
+ var pattern = capture || group;
726
+
727
+ tokens.push({
728
+ name: name || key++,
729
+ prefix: prefix || '',
730
+ delimiter: delimiter,
731
+ optional: optional,
732
+ repeat: repeat,
733
+ partial: partial,
734
+ asterisk: !!asterisk,
735
+ pattern: pattern ? escapeGroup(pattern) : (asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?')
736
+ });
737
+ }
738
+
739
+ // Match any characters still remaining.
740
+ if (index < str.length) {
741
+ path += str.substr(index);
742
+ }
743
+
744
+ // If the path exists, push it onto the end.
745
+ if (path) {
746
+ tokens.push(path);
747
+ }
748
+
749
+ return tokens
750
+ }
751
+
752
+ /**
753
+ * Compile a string to a template function for the path.
754
+ *
755
+ * @param {string} str
756
+ * @param {Object=} options
757
+ * @return {!function(Object=, Object=)}
758
+ */
759
+ function compile (str, options) {
760
+ return tokensToFunction(parse(str, options))
761
+ }
762
+
763
+ /**
764
+ * Prettier encoding of URI path segments.
765
+ *
766
+ * @param {string}
767
+ * @return {string}
768
+ */
769
+ function encodeURIComponentPretty (str) {
770
+ return encodeURI(str).replace(/[\/?#]/g, function (c) {
771
+ return '%' + c.charCodeAt(0).toString(16).toUpperCase()
772
+ })
773
+ }
774
+
775
+ /**
776
+ * Encode the asterisk parameter. Similar to `pretty`, but allows slashes.
777
+ *
778
+ * @param {string}
779
+ * @return {string}
780
+ */
781
+ function encodeAsterisk (str) {
782
+ return encodeURI(str).replace(/[?#]/g, function (c) {
783
+ return '%' + c.charCodeAt(0).toString(16).toUpperCase()
784
+ })
785
+ }
786
+
787
+ /**
788
+ * Expose a method for transforming tokens into the path function.
789
+ */
790
+ function tokensToFunction (tokens) {
791
+ // Compile all the tokens into regexps.
792
+ var matches = new Array(tokens.length);
793
+
794
+ // Compile all the patterns before compilation.
795
+ for (var i = 0; i < tokens.length; i++) {
796
+ if (typeof tokens[i] === 'object') {
797
+ matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$');
798
+ }
799
+ }
800
+
801
+ return function (obj, opts) {
802
+ var path = '';
803
+ var data = obj || {};
804
+ var options = opts || {};
805
+ var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent;
806
+
807
+ for (var i = 0; i < tokens.length; i++) {
808
+ var token = tokens[i];
809
+
810
+ if (typeof token === 'string') {
811
+ path += token;
812
+
813
+ continue
814
+ }
815
+
816
+ var value = data[token.name];
817
+ var segment;
818
+
819
+ if (value == null) {
820
+ if (token.optional) {
821
+ // Prepend partial segment prefixes.
822
+ if (token.partial) {
823
+ path += token.prefix;
824
+ }
825
+
826
+ continue
827
+ } else {
828
+ throw new TypeError('Expected "' + token.name + '" to be defined')
829
+ }
830
+ }
831
+
832
+ if (isarray(value)) {
833
+ if (!token.repeat) {
834
+ throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`')
835
+ }
836
+
837
+ if (value.length === 0) {
838
+ if (token.optional) {
839
+ continue
840
+ } else {
841
+ throw new TypeError('Expected "' + token.name + '" to not be empty')
842
+ }
843
+ }
844
+
845
+ for (var j = 0; j < value.length; j++) {
846
+ segment = encode(value[j]);
847
+
848
+ if (!matches[i].test(segment)) {
849
+ throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received `' + JSON.stringify(segment) + '`')
850
+ }
851
+
852
+ path += (j === 0 ? token.prefix : token.delimiter) + segment;
853
+ }
854
+
855
+ continue
856
+ }
857
+
858
+ segment = token.asterisk ? encodeAsterisk(value) : encode(value);
859
+
860
+ if (!matches[i].test(segment)) {
861
+ throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"')
862
+ }
863
+
864
+ path += token.prefix + segment;
865
+ }
866
+
867
+ return path
868
+ }
869
+ }
870
+
871
+ /**
872
+ * Escape a regular expression string.
873
+ *
874
+ * @param {string} str
875
+ * @return {string}
876
+ */
877
+ function escapeString (str) {
878
+ return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1')
879
+ }
880
+
881
+ /**
882
+ * Escape the capturing group by escaping special characters and meaning.
883
+ *
884
+ * @param {string} group
885
+ * @return {string}
886
+ */
887
+ function escapeGroup (group) {
888
+ return group.replace(/([=!:$\/()])/g, '\\$1')
889
+ }
890
+
891
+ /**
892
+ * Attach the keys as a property of the regexp.
893
+ *
894
+ * @param {!RegExp} re
895
+ * @param {Array} keys
896
+ * @return {!RegExp}
897
+ */
898
+ function attachKeys (re, keys) {
899
+ re.keys = keys;
900
+ return re
901
+ }
902
+
903
+ /**
904
+ * Get the flags for a regexp from the options.
905
+ *
906
+ * @param {Object} options
907
+ * @return {string}
908
+ */
909
+ function flags (options) {
910
+ return options.sensitive ? '' : 'i'
911
+ }
912
+
913
+ /**
914
+ * Pull out keys from a regexp.
915
+ *
916
+ * @param {!RegExp} path
917
+ * @param {!Array} keys
918
+ * @return {!RegExp}
919
+ */
920
+ function regexpToRegexp (path, keys) {
921
+ // Use a negative lookahead to match only capturing groups.
922
+ var groups = path.source.match(/\((?!\?)/g);
923
+
924
+ if (groups) {
925
+ for (var i = 0; i < groups.length; i++) {
926
+ keys.push({
927
+ name: i,
928
+ prefix: null,
929
+ delimiter: null,
930
+ optional: false,
931
+ repeat: false,
932
+ partial: false,
933
+ asterisk: false,
934
+ pattern: null
935
+ });
936
+ }
937
+ }
938
+
939
+ return attachKeys(path, keys)
940
+ }
941
+
942
+ /**
943
+ * Transform an array into a regexp.
944
+ *
945
+ * @param {!Array} path
946
+ * @param {Array} keys
947
+ * @param {!Object} options
948
+ * @return {!RegExp}
949
+ */
950
+ function arrayToRegexp (path, keys, options) {
951
+ var parts = [];
952
+
953
+ for (var i = 0; i < path.length; i++) {
954
+ parts.push(pathToRegexp(path[i], keys, options).source);
955
+ }
956
+
957
+ var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options));
958
+
959
+ return attachKeys(regexp, keys)
960
+ }
961
+
962
+ /**
963
+ * Create a path regexp from string input.
964
+ *
965
+ * @param {string} path
966
+ * @param {!Array} keys
967
+ * @param {!Object} options
968
+ * @return {!RegExp}
969
+ */
970
+ function stringToRegexp (path, keys, options) {
971
+ return tokensToRegExp(parse(path, options), keys, options)
972
+ }
973
+
974
+ /**
975
+ * Expose a function for taking tokens and returning a RegExp.
976
+ *
977
+ * @param {!Array} tokens
978
+ * @param {(Array|Object)=} keys
979
+ * @param {Object=} options
980
+ * @return {!RegExp}
981
+ */
982
+ function tokensToRegExp (tokens, keys, options) {
983
+ if (!isarray(keys)) {
984
+ options = /** @type {!Object} */ (keys || options);
985
+ keys = [];
986
+ }
987
+
988
+ options = options || {};
989
+
990
+ var strict = options.strict;
991
+ var end = options.end !== false;
992
+ var route = '';
993
+
994
+ // Iterate over the tokens and create our regexp string.
995
+ for (var i = 0; i < tokens.length; i++) {
996
+ var token = tokens[i];
997
+
998
+ if (typeof token === 'string') {
999
+ route += escapeString(token);
1000
+ } else {
1001
+ var prefix = escapeString(token.prefix);
1002
+ var capture = '(?:' + token.pattern + ')';
1003
+
1004
+ keys.push(token);
1005
+
1006
+ if (token.repeat) {
1007
+ capture += '(?:' + prefix + capture + ')*';
1008
+ }
1009
+
1010
+ if (token.optional) {
1011
+ if (!token.partial) {
1012
+ capture = '(?:' + prefix + '(' + capture + '))?';
1013
+ } else {
1014
+ capture = prefix + '(' + capture + ')?';
1015
+ }
1016
+ } else {
1017
+ capture = prefix + '(' + capture + ')';
1018
+ }
1019
+
1020
+ route += capture;
1021
+ }
1022
+ }
1023
+
1024
+ var delimiter = escapeString(options.delimiter || '/');
1025
+ var endsWithDelimiter = route.slice(-delimiter.length) === delimiter;
1026
+
1027
+ // In non-strict mode we allow a slash at the end of match. If the path to
1028
+ // match already ends with a slash, we remove it for consistency. The slash
1029
+ // is valid at the end of a path match, not in the middle. This is important
1030
+ // in non-ending mode, where "/test/" shouldn't match "/test//route".
1031
+ if (!strict) {
1032
+ route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?';
1033
+ }
1034
+
1035
+ if (end) {
1036
+ route += '$';
1037
+ } else {
1038
+ // In non-ending mode, we need the capturing groups to match as much as
1039
+ // possible by using a positive lookahead to the end or next path segment.
1040
+ route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)';
1041
+ }
1042
+
1043
+ return attachKeys(new RegExp('^' + route, flags(options)), keys)
1044
+ }
1045
+
1046
+ /**
1047
+ * Normalize the given path string, returning a regular expression.
1048
+ *
1049
+ * An empty array can be passed in for the keys, which will hold the
1050
+ * placeholder key descriptions. For example, using `/user/:id`, `keys` will
1051
+ * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
1052
+ *
1053
+ * @param {(string|RegExp|Array)} path
1054
+ * @param {(Array|Object)=} keys
1055
+ * @param {Object=} options
1056
+ * @return {!RegExp}
1057
+ */
1058
+ function pathToRegexp (path, keys, options) {
1059
+ if (!isarray(keys)) {
1060
+ options = /** @type {!Object} */ (keys || options);
1061
+ keys = [];
1062
+ }
1063
+
1064
+ options = options || {};
1065
+
1066
+ if (path instanceof RegExp) {
1067
+ return regexpToRegexp(path, /** @type {!Array} */ (keys))
1068
+ }
1069
+
1070
+ if (isarray(path)) {
1071
+ return arrayToRegexp(/** @type {!Array} */ (path), /** @type {!Array} */ (keys), options)
1072
+ }
1073
+
1074
+ return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options)
1075
+ }
1076
+ pathToRegexp_1.parse = parse_1;
1077
+ pathToRegexp_1.compile = compile_1;
1078
+ pathToRegexp_1.tokensToFunction = tokensToFunction_1;
1079
+ pathToRegexp_1.tokensToRegExp = tokensToRegExp_1;
1080
+
1081
+ /* */
1082
+
1083
+ // $flow-disable-line
1084
+ var regexpCompileCache = Object.create(null);
1085
+
1086
+ function fillParams (
1087
+ path,
1088
+ params,
1089
+ routeMsg
1090
+ ) {
1091
+ try {
1092
+ var filler =
1093
+ regexpCompileCache[path] ||
1094
+ (regexpCompileCache[path] = pathToRegexp_1.compile(path));
1095
+ return filler(params || {}, { pretty: true })
1096
+ } catch (e) {
1097
+ {
1098
+ warn(false, ("missing param for " + routeMsg + ": " + (e.message)));
1099
+ }
1100
+ return ''
1101
+ }
1102
+ }
1103
+
1104
+ /* */
1105
+
1106
+ function createRouteMap (
1107
+ routes,
1108
+ oldPathList,
1109
+ oldPathMap,
1110
+ oldNameMap
1111
+ ) {
1112
+ // the path list is used to control path matching priority
1113
+ var pathList = oldPathList || [];
1114
+ // $flow-disable-line
1115
+ var pathMap = oldPathMap || Object.create(null);
1116
+ // $flow-disable-line
1117
+ var nameMap = oldNameMap || Object.create(null);
1118
+
1119
+ routes.forEach(function (route) {
1120
+ addRouteRecord(pathList, pathMap, nameMap, route);
1121
+ });
1122
+
1123
+ // ensure wildcard routes are always at the end
1124
+ for (var i = 0, l = pathList.length; i < l; i++) {
1125
+ if (pathList[i] === '*') {
1126
+ pathList.push(pathList.splice(i, 1)[0]);
1127
+ l--;
1128
+ i--;
1129
+ }
1130
+ }
1131
+
1132
+ return {
1133
+ pathList: pathList,
1134
+ pathMap: pathMap,
1135
+ nameMap: nameMap
1136
+ }
1137
+ }
1138
+
1139
+ function addRouteRecord (
1140
+ pathList,
1141
+ pathMap,
1142
+ nameMap,
1143
+ route,
1144
+ parent,
1145
+ matchAs
1146
+ ) {
1147
+ var path = route.path;
1148
+ var name = route.name;
1149
+ {
1150
+ assert(path != null, "\"path\" is required in a route configuration.");
1151
+ assert(
1152
+ typeof route.component !== 'string',
1153
+ "route config \"component\" for path: " + (String(path || name)) + " cannot be a " +
1154
+ "string id. Use an actual component instead."
1155
+ );
1156
+ }
1157
+
1158
+ var pathToRegexpOptions = route.pathToRegexpOptions || {};
1159
+ var normalizedPath = normalizePath(
1160
+ path,
1161
+ parent,
1162
+ pathToRegexpOptions.strict
1163
+ );
1164
+
1165
+ if (typeof route.caseSensitive === 'boolean') {
1166
+ pathToRegexpOptions.sensitive = route.caseSensitive;
1167
+ }
1168
+
1169
+ var record = {
1170
+ path: normalizedPath,
1171
+ regex: compileRouteRegex(normalizedPath, pathToRegexpOptions),
1172
+ components: route.components || { default: route.component },
1173
+ instances: {},
1174
+ name: name,
1175
+ parent: parent,
1176
+ matchAs: matchAs,
1177
+ redirect: route.redirect,
1178
+ beforeEnter: route.beforeEnter,
1179
+ meta: route.meta || {},
1180
+ props: route.props == null
1181
+ ? {}
1182
+ : route.components
1183
+ ? route.props
1184
+ : { default: route.props }
1185
+ };
1186
+
1187
+ if (route.children) {
1188
+ // Warn if route is named, does not redirect and has a default child route.
1189
+ // If users navigate to this route by name, the default child will
1190
+ // not be rendered (GH Issue #629)
1191
+ {
1192
+ if (route.name && !route.redirect && route.children.some(function (child) { return /^\/?$/.test(child.path); })) {
1193
+ warn(
1194
+ false,
1195
+ "Named Route '" + (route.name) + "' has a default child route. " +
1196
+ "When navigating to this named route (:to=\"{name: '" + (route.name) + "'\"), " +
1197
+ "the default child route will not be rendered. Remove the name from " +
1198
+ "this route and use the name of the default child route for named " +
1199
+ "links instead."
1200
+ );
1201
+ }
1202
+ }
1203
+ route.children.forEach(function (child) {
1204
+ var childMatchAs = matchAs
1205
+ ? cleanPath((matchAs + "/" + (child.path)))
1206
+ : undefined;
1207
+ addRouteRecord(pathList, pathMap, nameMap, child, record, childMatchAs);
1208
+ });
1209
+ }
1210
+
1211
+ if (route.alias !== undefined) {
1212
+ var aliases = Array.isArray(route.alias)
1213
+ ? route.alias
1214
+ : [route.alias];
1215
+
1216
+ aliases.forEach(function (alias) {
1217
+ var aliasRoute = {
1218
+ path: alias,
1219
+ children: route.children
1220
+ };
1221
+ addRouteRecord(
1222
+ pathList,
1223
+ pathMap,
1224
+ nameMap,
1225
+ aliasRoute,
1226
+ parent,
1227
+ record.path || '/' // matchAs
1228
+ );
1229
+ });
1230
+ }
1231
+
1232
+ if (!pathMap[record.path]) {
1233
+ pathList.push(record.path);
1234
+ pathMap[record.path] = record;
1235
+ }
1236
+
1237
+ if (name) {
1238
+ if (!nameMap[name]) {
1239
+ nameMap[name] = record;
1240
+ } else if ("development" !== 'production' && !matchAs) {
1241
+ warn(
1242
+ false,
1243
+ "Duplicate named routes definition: " +
1244
+ "{ name: \"" + name + "\", path: \"" + (record.path) + "\" }"
1245
+ );
1246
+ }
1247
+ }
1248
+ }
1249
+
1250
+ function compileRouteRegex (path, pathToRegexpOptions) {
1251
+ var regex = pathToRegexp_1(path, [], pathToRegexpOptions);
1252
+ {
1253
+ var keys = Object.create(null);
1254
+ regex.keys.forEach(function (key) {
1255
+ warn(!keys[key.name], ("Duplicate param keys in route with path: \"" + path + "\""));
1256
+ keys[key.name] = true;
1257
+ });
1258
+ }
1259
+ return regex
1260
+ }
1261
+
1262
+ function normalizePath (path, parent, strict) {
1263
+ if (!strict) { path = path.replace(/\/$/, ''); }
1264
+ if (path[0] === '/') { return path }
1265
+ if (parent == null) { return path }
1266
+ return cleanPath(((parent.path) + "/" + path))
1267
+ }
1268
+
1269
+ /* */
1270
+
1271
+ function normalizeLocation (
1272
+ raw,
1273
+ current,
1274
+ append,
1275
+ router
1276
+ ) {
1277
+ var next = typeof raw === 'string' ? { path: raw } : raw;
1278
+ // named target
1279
+ if (next.name || next._normalized) {
1280
+ return next
1281
+ }
1282
+
1283
+ // relative params
1284
+ if (!next.path && next.params && current) {
1285
+ next = extend({}, next);
1286
+ next._normalized = true;
1287
+ var params = extend(extend({}, current.params), next.params);
1288
+ if (current.name) {
1289
+ next.name = current.name;
1290
+ next.params = params;
1291
+ } else if (current.matched.length) {
1292
+ var rawPath = current.matched[current.matched.length - 1].path;
1293
+ next.path = fillParams(rawPath, params, ("path " + (current.path)));
1294
+ } else {
1295
+ warn(false, "relative params navigation requires a current route.");
1296
+ }
1297
+ return next
1298
+ }
1299
+
1300
+ var parsedPath = parsePath(next.path || '');
1301
+ var basePath = (current && current.path) || '/';
1302
+ var path = parsedPath.path
1303
+ ? resolvePath(parsedPath.path, basePath, append || next.append)
1304
+ : basePath;
1305
+
1306
+ var query = resolveQuery(
1307
+ parsedPath.query,
1308
+ next.query,
1309
+ router && router.options.parseQuery
1310
+ );
1311
+
1312
+ var hash = next.hash || parsedPath.hash;
1313
+ if (hash && hash.charAt(0) !== '#') {
1314
+ hash = "#" + hash;
1315
+ }
1316
+
1317
+ return {
1318
+ _normalized: true,
1319
+ path: path,
1320
+ query: query,
1321
+ hash: hash
1322
+ }
1323
+ }
1324
+
1325
+ /* */
1326
+
1327
+
1328
+
1329
+ function createMatcher (
1330
+ routes,
1331
+ router
1332
+ ) {
1333
+ var ref = createRouteMap(routes);
1334
+ var pathList = ref.pathList;
1335
+ var pathMap = ref.pathMap;
1336
+ var nameMap = ref.nameMap;
1337
+
1338
+ function addRoutes (routes) {
1339
+ createRouteMap(routes, pathList, pathMap, nameMap);
1340
+ }
1341
+
1342
+ function match (
1343
+ raw,
1344
+ currentRoute,
1345
+ redirectedFrom
1346
+ ) {
1347
+ var location = normalizeLocation(raw, currentRoute, false, router);
1348
+ var name = location.name;
1349
+
1350
+ if (name) {
1351
+ var record = nameMap[name];
1352
+ {
1353
+ warn(record, ("Route with name '" + name + "' does not exist"));
1354
+ }
1355
+ if (!record) { return _createRoute(null, location) }
1356
+ var paramNames = record.regex.keys
1357
+ .filter(function (key) { return !key.optional; })
1358
+ .map(function (key) { return key.name; });
1359
+
1360
+ if (typeof location.params !== 'object') {
1361
+ location.params = {};
1362
+ }
1363
+
1364
+ if (currentRoute && typeof currentRoute.params === 'object') {
1365
+ for (var key in currentRoute.params) {
1366
+ if (!(key in location.params) && paramNames.indexOf(key) > -1) {
1367
+ location.params[key] = currentRoute.params[key];
1368
+ }
1369
+ }
1370
+ }
1371
+
1372
+ if (record) {
1373
+ location.path = fillParams(record.path, location.params, ("named route \"" + name + "\""));
1374
+ return _createRoute(record, location, redirectedFrom)
1375
+ }
1376
+ } else if (location.path) {
1377
+ location.params = {};
1378
+ for (var i = 0; i < pathList.length; i++) {
1379
+ var path = pathList[i];
1380
+ var record$1 = pathMap[path];
1381
+ if (matchRoute(record$1.regex, location.path, location.params)) {
1382
+ return _createRoute(record$1, location, redirectedFrom)
1383
+ }
1384
+ }
1385
+ }
1386
+ // no match
1387
+ return _createRoute(null, location)
1388
+ }
1389
+
1390
+ function redirect (
1391
+ record,
1392
+ location
1393
+ ) {
1394
+ var originalRedirect = record.redirect;
1395
+ var redirect = typeof originalRedirect === 'function'
1396
+ ? originalRedirect(createRoute(record, location, null, router))
1397
+ : originalRedirect;
1398
+
1399
+ if (typeof redirect === 'string') {
1400
+ redirect = { path: redirect };
1401
+ }
1402
+
1403
+ if (!redirect || typeof redirect !== 'object') {
1404
+ {
1405
+ warn(
1406
+ false, ("invalid redirect option: " + (JSON.stringify(redirect)))
1407
+ );
1408
+ }
1409
+ return _createRoute(null, location)
1410
+ }
1411
+
1412
+ var re = redirect;
1413
+ var name = re.name;
1414
+ var path = re.path;
1415
+ var query = location.query;
1416
+ var hash = location.hash;
1417
+ var params = location.params;
1418
+ query = re.hasOwnProperty('query') ? re.query : query;
1419
+ hash = re.hasOwnProperty('hash') ? re.hash : hash;
1420
+ params = re.hasOwnProperty('params') ? re.params : params;
1421
+
1422
+ if (name) {
1423
+ // resolved named direct
1424
+ var targetRecord = nameMap[name];
1425
+ {
1426
+ assert(targetRecord, ("redirect failed: named route \"" + name + "\" not found."));
1427
+ }
1428
+ return match({
1429
+ _normalized: true,
1430
+ name: name,
1431
+ query: query,
1432
+ hash: hash,
1433
+ params: params
1434
+ }, undefined, location)
1435
+ } else if (path) {
1436
+ // 1. resolve relative redirect
1437
+ var rawPath = resolveRecordPath(path, record);
1438
+ // 2. resolve params
1439
+ var resolvedPath = fillParams(rawPath, params, ("redirect route with path \"" + rawPath + "\""));
1440
+ // 3. rematch with existing query and hash
1441
+ return match({
1442
+ _normalized: true,
1443
+ path: resolvedPath,
1444
+ query: query,
1445
+ hash: hash
1446
+ }, undefined, location)
1447
+ } else {
1448
+ {
1449
+ warn(false, ("invalid redirect option: " + (JSON.stringify(redirect))));
1450
+ }
1451
+ return _createRoute(null, location)
1452
+ }
1453
+ }
1454
+
1455
+ function alias (
1456
+ record,
1457
+ location,
1458
+ matchAs
1459
+ ) {
1460
+ var aliasedPath = fillParams(matchAs, location.params, ("aliased route with path \"" + matchAs + "\""));
1461
+ var aliasedMatch = match({
1462
+ _normalized: true,
1463
+ path: aliasedPath
1464
+ });
1465
+ if (aliasedMatch) {
1466
+ var matched = aliasedMatch.matched;
1467
+ var aliasedRecord = matched[matched.length - 1];
1468
+ location.params = aliasedMatch.params;
1469
+ return _createRoute(aliasedRecord, location)
1470
+ }
1471
+ return _createRoute(null, location)
1472
+ }
1473
+
1474
+ function _createRoute (
1475
+ record,
1476
+ location,
1477
+ redirectedFrom
1478
+ ) {
1479
+ if (record && record.redirect) {
1480
+ return redirect(record, redirectedFrom || location)
1481
+ }
1482
+ if (record && record.matchAs) {
1483
+ return alias(record, location, record.matchAs)
1484
+ }
1485
+ return createRoute(record, location, redirectedFrom, router)
1486
+ }
1487
+
1488
+ return {
1489
+ match: match,
1490
+ addRoutes: addRoutes
1491
+ }
1492
+ }
1493
+
1494
+ function matchRoute (
1495
+ regex,
1496
+ path,
1497
+ params
1498
+ ) {
1499
+ var m = path.match(regex);
1500
+
1501
+ if (!m) {
1502
+ return false
1503
+ } else if (!params) {
1504
+ return true
1505
+ }
1506
+
1507
+ for (var i = 1, len = m.length; i < len; ++i) {
1508
+ var key = regex.keys[i - 1];
1509
+ var val = typeof m[i] === 'string' ? decodeURIComponent(m[i]) : m[i];
1510
+ if (key) {
1511
+ // Fix #1994: using * with props: true generates a param named 0
1512
+ params[key.name || 'pathMatch'] = val;
1513
+ }
1514
+ }
1515
+
1516
+ return true
1517
+ }
1518
+
1519
+ function resolveRecordPath (path, record) {
1520
+ return resolvePath(path, record.parent ? record.parent.path : '/', true)
1521
+ }
1522
+
1523
+ /* */
1524
+
1525
+ var positionStore = Object.create(null);
1526
+
1527
+ function setupScroll () {
1528
+ // Fix for #1585 for Firefox
1529
+ // Fix for #2195 Add optional third attribute to workaround a bug in safari https://bugs.webkit.org/show_bug.cgi?id=182678
1530
+ window.history.replaceState({ key: getStateKey() }, '', window.location.href.replace(window.location.origin, ''));
1531
+ window.addEventListener('popstate', function (e) {
1532
+ saveScrollPosition();
1533
+ if (e.state && e.state.key) {
1534
+ setStateKey(e.state.key);
1535
+ }
1536
+ });
1537
+ }
1538
+
1539
+ function handleScroll (
1540
+ router,
1541
+ to,
1542
+ from,
1543
+ isPop
1544
+ ) {
1545
+ if (!router.app) {
1546
+ return
1547
+ }
1548
+
1549
+ var behavior = router.options.scrollBehavior;
1550
+ if (!behavior) {
1551
+ return
1552
+ }
1553
+
1554
+ {
1555
+ assert(typeof behavior === 'function', "scrollBehavior must be a function");
1556
+ }
1557
+
1558
+ // wait until re-render finishes before scrolling
1559
+ router.app.$nextTick(function () {
1560
+ var position = getScrollPosition();
1561
+ var shouldScroll = behavior.call(router, to, from, isPop ? position : null);
1562
+
1563
+ if (!shouldScroll) {
1564
+ return
1565
+ }
1566
+
1567
+ if (typeof shouldScroll.then === 'function') {
1568
+ shouldScroll.then(function (shouldScroll) {
1569
+ scrollToPosition((shouldScroll), position);
1570
+ }).catch(function (err) {
1571
+ {
1572
+ assert(false, err.toString());
1573
+ }
1574
+ });
1575
+ } else {
1576
+ scrollToPosition(shouldScroll, position);
1577
+ }
1578
+ });
1579
+ }
1580
+
1581
+ function saveScrollPosition () {
1582
+ var key = getStateKey();
1583
+ if (key) {
1584
+ positionStore[key] = {
1585
+ x: window.pageXOffset,
1586
+ y: window.pageYOffset
1587
+ };
1588
+ }
1589
+ }
1590
+
1591
+ function getScrollPosition () {
1592
+ var key = getStateKey();
1593
+ if (key) {
1594
+ return positionStore[key]
1595
+ }
1596
+ }
1597
+
1598
+ function getElementPosition (el, offset) {
1599
+ var docEl = document.documentElement;
1600
+ var docRect = docEl.getBoundingClientRect();
1601
+ var elRect = el.getBoundingClientRect();
1602
+ return {
1603
+ x: elRect.left - docRect.left - offset.x,
1604
+ y: elRect.top - docRect.top - offset.y
1605
+ }
1606
+ }
1607
+
1608
+ function isValidPosition (obj) {
1609
+ return isNumber(obj.x) || isNumber(obj.y)
1610
+ }
1611
+
1612
+ function normalizePosition (obj) {
1613
+ return {
1614
+ x: isNumber(obj.x) ? obj.x : window.pageXOffset,
1615
+ y: isNumber(obj.y) ? obj.y : window.pageYOffset
1616
+ }
1617
+ }
1618
+
1619
+ function normalizeOffset (obj) {
1620
+ return {
1621
+ x: isNumber(obj.x) ? obj.x : 0,
1622
+ y: isNumber(obj.y) ? obj.y : 0
1623
+ }
1624
+ }
1625
+
1626
+ function isNumber (v) {
1627
+ return typeof v === 'number'
1628
+ }
1629
+
1630
+ function scrollToPosition (shouldScroll, position) {
1631
+ var isObject = typeof shouldScroll === 'object';
1632
+ if (isObject && typeof shouldScroll.selector === 'string') {
1633
+ var el = document.querySelector(shouldScroll.selector);
1634
+ if (el) {
1635
+ var offset = shouldScroll.offset && typeof shouldScroll.offset === 'object' ? shouldScroll.offset : {};
1636
+ offset = normalizeOffset(offset);
1637
+ position = getElementPosition(el, offset);
1638
+ } else if (isValidPosition(shouldScroll)) {
1639
+ position = normalizePosition(shouldScroll);
1640
+ }
1641
+ } else if (isObject && isValidPosition(shouldScroll)) {
1642
+ position = normalizePosition(shouldScroll);
1643
+ }
1644
+
1645
+ if (position) {
1646
+ window.scrollTo(position.x, position.y);
1647
+ }
1648
+ }
1649
+
1650
+ /* */
1651
+
1652
+ var supportsPushState = inBrowser && (function () {
1653
+ var ua = window.navigator.userAgent;
1654
+
1655
+ if (
1656
+ (ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) &&
1657
+ ua.indexOf('Mobile Safari') !== -1 &&
1658
+ ua.indexOf('Chrome') === -1 &&
1659
+ ua.indexOf('Windows Phone') === -1
1660
+ ) {
1661
+ return false
1662
+ }
1663
+
1664
+ return window.history && 'pushState' in window.history
1665
+ })();
1666
+
1667
+ // use User Timing api (if present) for more accurate key precision
1668
+ var Time = inBrowser && window.performance && window.performance.now
1669
+ ? window.performance
1670
+ : Date;
1671
+
1672
+ var _key = genKey();
1673
+
1674
+ function genKey () {
1675
+ return Time.now().toFixed(3)
1676
+ }
1677
+
1678
+ function getStateKey () {
1679
+ return _key
1680
+ }
1681
+
1682
+ function setStateKey (key) {
1683
+ _key = key;
1684
+ }
1685
+
1686
+ function pushState (url, replace) {
1687
+ saveScrollPosition();
1688
+ // try...catch the pushState call to get around Safari
1689
+ // DOM Exception 18 where it limits to 100 pushState calls
1690
+ var history = window.history;
1691
+ try {
1692
+ if (replace) {
1693
+ history.replaceState({ key: _key }, '', url);
1694
+ } else {
1695
+ _key = genKey();
1696
+ history.pushState({ key: _key }, '', url);
1697
+ }
1698
+ } catch (e) {
1699
+ window.location[replace ? 'replace' : 'assign'](url);
1700
+ }
1701
+ }
1702
+
1703
+ function replaceState (url) {
1704
+ pushState(url, true);
1705
+ }
1706
+
1707
+ /* */
1708
+
1709
+ function runQueue (queue, fn, cb) {
1710
+ var step = function (index) {
1711
+ if (index >= queue.length) {
1712
+ cb();
1713
+ } else {
1714
+ if (queue[index]) {
1715
+ fn(queue[index], function () {
1716
+ step(index + 1);
1717
+ });
1718
+ } else {
1719
+ step(index + 1);
1720
+ }
1721
+ }
1722
+ };
1723
+ step(0);
1724
+ }
1725
+
1726
+ /* */
1727
+
1728
+ function resolveAsyncComponents (matched) {
1729
+ return function (to, from, next) {
1730
+ var hasAsync = false;
1731
+ var pending = 0;
1732
+ var error = null;
1733
+
1734
+ flatMapComponents(matched, function (def, _, match, key) {
1735
+ // if it's a function and doesn't have cid attached,
1736
+ // assume it's an async component resolve function.
1737
+ // we are not using Vue's default async resolving mechanism because
1738
+ // we want to halt the navigation until the incoming component has been
1739
+ // resolved.
1740
+ if (typeof def === 'function' && def.cid === undefined) {
1741
+ hasAsync = true;
1742
+ pending++;
1743
+
1744
+ var resolve = once(function (resolvedDef) {
1745
+ if (isESModule(resolvedDef)) {
1746
+ resolvedDef = resolvedDef.default;
1747
+ }
1748
+ // save resolved on async factory in case it's used elsewhere
1749
+ def.resolved = typeof resolvedDef === 'function'
1750
+ ? resolvedDef
1751
+ : _Vue.extend(resolvedDef);
1752
+ match.components[key] = resolvedDef;
1753
+ pending--;
1754
+ if (pending <= 0) {
1755
+ next();
1756
+ }
1757
+ });
1758
+
1759
+ var reject = once(function (reason) {
1760
+ var msg = "Failed to resolve async component " + key + ": " + reason;
1761
+ "development" !== 'production' && warn(false, msg);
1762
+ if (!error) {
1763
+ error = isError(reason)
1764
+ ? reason
1765
+ : new Error(msg);
1766
+ next(error);
1767
+ }
1768
+ });
1769
+
1770
+ var res;
1771
+ try {
1772
+ res = def(resolve, reject);
1773
+ } catch (e) {
1774
+ reject(e);
1775
+ }
1776
+ if (res) {
1777
+ if (typeof res.then === 'function') {
1778
+ res.then(resolve, reject);
1779
+ } else {
1780
+ // new syntax in Vue 2.3
1781
+ var comp = res.component;
1782
+ if (comp && typeof comp.then === 'function') {
1783
+ comp.then(resolve, reject);
1784
+ }
1785
+ }
1786
+ }
1787
+ }
1788
+ });
1789
+
1790
+ if (!hasAsync) { next(); }
1791
+ }
1792
+ }
1793
+
1794
+ function flatMapComponents (
1795
+ matched,
1796
+ fn
1797
+ ) {
1798
+ return flatten(matched.map(function (m) {
1799
+ return Object.keys(m.components).map(function (key) { return fn(
1800
+ m.components[key],
1801
+ m.instances[key],
1802
+ m, key
1803
+ ); })
1804
+ }))
1805
+ }
1806
+
1807
+ function flatten (arr) {
1808
+ return Array.prototype.concat.apply([], arr)
1809
+ }
1810
+
1811
+ var hasSymbol =
1812
+ typeof Symbol === 'function' &&
1813
+ typeof Symbol.toStringTag === 'symbol';
1814
+
1815
+ function isESModule (obj) {
1816
+ return obj.__esModule || (hasSymbol && obj[Symbol.toStringTag] === 'Module')
1817
+ }
1818
+
1819
+ // in Webpack 2, require.ensure now also returns a Promise
1820
+ // so the resolve/reject functions may get called an extra time
1821
+ // if the user uses an arrow function shorthand that happens to
1822
+ // return that Promise.
1823
+ function once (fn) {
1824
+ var called = false;
1825
+ return function () {
1826
+ var args = [], len = arguments.length;
1827
+ while ( len-- ) args[ len ] = arguments[ len ];
1828
+
1829
+ if (called) { return }
1830
+ called = true;
1831
+ return fn.apply(this, args)
1832
+ }
1833
+ }
1834
+
1835
+ /* */
1836
+
1837
+ var History = function History (router, base) {
1838
+ this.router = router;
1839
+ this.base = normalizeBase(base);
1840
+ // start with a route object that stands for "nowhere"
1841
+ this.current = START;
1842
+ this.pending = null;
1843
+ this.ready = false;
1844
+ this.readyCbs = [];
1845
+ this.readyErrorCbs = [];
1846
+ this.errorCbs = [];
1847
+ };
1848
+
1849
+ History.prototype.listen = function listen (cb) {
1850
+ this.cb = cb;
1851
+ };
1852
+
1853
+ History.prototype.onReady = function onReady (cb, errorCb) {
1854
+ if (this.ready) {
1855
+ cb();
1856
+ } else {
1857
+ this.readyCbs.push(cb);
1858
+ if (errorCb) {
1859
+ this.readyErrorCbs.push(errorCb);
1860
+ }
1861
+ }
1862
+ };
1863
+
1864
+ History.prototype.onError = function onError (errorCb) {
1865
+ this.errorCbs.push(errorCb);
1866
+ };
1867
+
1868
+ History.prototype.transitionTo = function transitionTo (location, onComplete, onAbort) {
1869
+ var this$1 = this;
1870
+
1871
+ var route = this.router.match(location, this.current);
1872
+ this.confirmTransition(route, function () {
1873
+ this$1.updateRoute(route);
1874
+ onComplete && onComplete(route);
1875
+ this$1.ensureURL();
1876
+
1877
+ // fire ready cbs once
1878
+ if (!this$1.ready) {
1879
+ this$1.ready = true;
1880
+ this$1.readyCbs.forEach(function (cb) { cb(route); });
1881
+ }
1882
+ }, function (err) {
1883
+ if (onAbort) {
1884
+ onAbort(err);
1885
+ }
1886
+ if (err && !this$1.ready) {
1887
+ this$1.ready = true;
1888
+ this$1.readyErrorCbs.forEach(function (cb) { cb(err); });
1889
+ }
1890
+ });
1891
+ };
1892
+
1893
+ History.prototype.confirmTransition = function confirmTransition (route, onComplete, onAbort) {
1894
+ var this$1 = this;
1895
+
1896
+ var current = this.current;
1897
+ var abort = function (err) {
1898
+ if (isError(err)) {
1899
+ if (this$1.errorCbs.length) {
1900
+ this$1.errorCbs.forEach(function (cb) { cb(err); });
1901
+ } else {
1902
+ warn(false, 'uncaught error during route navigation:');
1903
+ console.error(err);
1904
+ }
1905
+ }
1906
+ onAbort && onAbort(err);
1907
+ };
1908
+ if (
1909
+ isSameRoute(route, current) &&
1910
+ // in the case the route map has been dynamically appended to
1911
+ route.matched.length === current.matched.length
1912
+ ) {
1913
+ this.ensureURL();
1914
+ return abort()
1915
+ }
1916
+
1917
+ var ref = resolveQueue(this.current.matched, route.matched);
1918
+ var updated = ref.updated;
1919
+ var deactivated = ref.deactivated;
1920
+ var activated = ref.activated;
1921
+
1922
+ var queue = [].concat(
1923
+ // in-component leave guards
1924
+ extractLeaveGuards(deactivated),
1925
+ // global before hooks
1926
+ this.router.beforeHooks,
1927
+ // in-component update hooks
1928
+ extractUpdateHooks(updated),
1929
+ // in-config enter guards
1930
+ activated.map(function (m) { return m.beforeEnter; }),
1931
+ // async components
1932
+ resolveAsyncComponents(activated)
1933
+ );
1934
+
1935
+ this.pending = route;
1936
+ var iterator = function (hook, next) {
1937
+ if (this$1.pending !== route) {
1938
+ return abort()
1939
+ }
1940
+ try {
1941
+ hook(route, current, function (to) {
1942
+ if (to === false || isError(to)) {
1943
+ // next(false) -> abort navigation, ensure current URL
1944
+ this$1.ensureURL(true);
1945
+ abort(to);
1946
+ } else if (
1947
+ typeof to === 'string' ||
1948
+ (typeof to === 'object' && (
1949
+ typeof to.path === 'string' ||
1950
+ typeof to.name === 'string'
1951
+ ))
1952
+ ) {
1953
+ // next('/') or next({ path: '/' }) -> redirect
1954
+ abort();
1955
+ if (typeof to === 'object' && to.replace) {
1956
+ this$1.replace(to);
1957
+ } else {
1958
+ this$1.push(to);
1959
+ }
1960
+ } else {
1961
+ // confirm transition and pass on the value
1962
+ next(to);
1963
+ }
1964
+ });
1965
+ } catch (e) {
1966
+ abort(e);
1967
+ }
1968
+ };
1969
+
1970
+ runQueue(queue, iterator, function () {
1971
+ var postEnterCbs = [];
1972
+ var isValid = function () { return this$1.current === route; };
1973
+ // wait until async components are resolved before
1974
+ // extracting in-component enter guards
1975
+ var enterGuards = extractEnterGuards(activated, postEnterCbs, isValid);
1976
+ var queue = enterGuards.concat(this$1.router.resolveHooks);
1977
+ runQueue(queue, iterator, function () {
1978
+ if (this$1.pending !== route) {
1979
+ return abort()
1980
+ }
1981
+ this$1.pending = null;
1982
+ onComplete(route);
1983
+ if (this$1.router.app) {
1984
+ this$1.router.app.$nextTick(function () {
1985
+ postEnterCbs.forEach(function (cb) { cb(); });
1986
+ });
1987
+ }
1988
+ });
1989
+ });
1990
+ };
1991
+
1992
+ History.prototype.updateRoute = function updateRoute (route) {
1993
+ var prev = this.current;
1994
+ this.current = route;
1995
+ this.cb && this.cb(route);
1996
+ this.router.afterHooks.forEach(function (hook) {
1997
+ hook && hook(route, prev);
1998
+ });
1999
+ };
2000
+
2001
+ function normalizeBase (base) {
2002
+ if (!base) {
2003
+ if (inBrowser) {
2004
+ // respect <base> tag
2005
+ var baseEl = document.querySelector('base');
2006
+ base = (baseEl && baseEl.getAttribute('href')) || '/';
2007
+ // strip full URL origin
2008
+ base = base.replace(/^https?:\/\/[^\/]+/, '');
2009
+ } else {
2010
+ base = '/';
2011
+ }
2012
+ }
2013
+ // make sure there's the starting slash
2014
+ if (base.charAt(0) !== '/') {
2015
+ base = '/' + base;
2016
+ }
2017
+ // remove trailing slash
2018
+ return base.replace(/\/$/, '')
2019
+ }
2020
+
2021
+ function resolveQueue (
2022
+ current,
2023
+ next
2024
+ ) {
2025
+ var i;
2026
+ var max = Math.max(current.length, next.length);
2027
+ for (i = 0; i < max; i++) {
2028
+ if (current[i] !== next[i]) {
2029
+ break
2030
+ }
2031
+ }
2032
+ return {
2033
+ updated: next.slice(0, i),
2034
+ activated: next.slice(i),
2035
+ deactivated: current.slice(i)
2036
+ }
2037
+ }
2038
+
2039
+ function extractGuards (
2040
+ records,
2041
+ name,
2042
+ bind,
2043
+ reverse
2044
+ ) {
2045
+ var guards = flatMapComponents(records, function (def, instance, match, key) {
2046
+ var guard = extractGuard(def, name);
2047
+ if (guard) {
2048
+ return Array.isArray(guard)
2049
+ ? guard.map(function (guard) { return bind(guard, instance, match, key); })
2050
+ : bind(guard, instance, match, key)
2051
+ }
2052
+ });
2053
+ return flatten(reverse ? guards.reverse() : guards)
2054
+ }
2055
+
2056
+ function extractGuard (
2057
+ def,
2058
+ key
2059
+ ) {
2060
+ if (typeof def !== 'function') {
2061
+ // extend now so that global mixins are applied.
2062
+ def = _Vue.extend(def);
2063
+ }
2064
+ return def.options[key]
2065
+ }
2066
+
2067
+ function extractLeaveGuards (deactivated) {
2068
+ return extractGuards(deactivated, 'beforeRouteLeave', bindGuard, true)
2069
+ }
2070
+
2071
+ function extractUpdateHooks (updated) {
2072
+ return extractGuards(updated, 'beforeRouteUpdate', bindGuard)
2073
+ }
2074
+
2075
+ function bindGuard (guard, instance) {
2076
+ if (instance) {
2077
+ return function boundRouteGuard () {
2078
+ return guard.apply(instance, arguments)
2079
+ }
2080
+ }
2081
+ }
2082
+
2083
+ function extractEnterGuards (
2084
+ activated,
2085
+ cbs,
2086
+ isValid
2087
+ ) {
2088
+ return extractGuards(activated, 'beforeRouteEnter', function (guard, _, match, key) {
2089
+ return bindEnterGuard(guard, match, key, cbs, isValid)
2090
+ })
2091
+ }
2092
+
2093
+ function bindEnterGuard (
2094
+ guard,
2095
+ match,
2096
+ key,
2097
+ cbs,
2098
+ isValid
2099
+ ) {
2100
+ return function routeEnterGuard (to, from, next) {
2101
+ return guard(to, from, function (cb) {
2102
+ next(cb);
2103
+ if (typeof cb === 'function') {
2104
+ cbs.push(function () {
2105
+ // #750
2106
+ // if a router-view is wrapped with an out-in transition,
2107
+ // the instance may not have been registered at this time.
2108
+ // we will need to poll for registration until current route
2109
+ // is no longer valid.
2110
+ poll(cb, match.instances, key, isValid);
2111
+ });
2112
+ }
2113
+ })
2114
+ }
2115
+ }
2116
+
2117
+ function poll (
2118
+ cb, // somehow flow cannot infer this is a function
2119
+ instances,
2120
+ key,
2121
+ isValid
2122
+ ) {
2123
+ if (
2124
+ instances[key] &&
2125
+ !instances[key]._isBeingDestroyed // do not reuse being destroyed instance
2126
+ ) {
2127
+ cb(instances[key]);
2128
+ } else if (isValid()) {
2129
+ setTimeout(function () {
2130
+ poll(cb, instances, key, isValid);
2131
+ }, 16);
2132
+ }
2133
+ }
2134
+
2135
+ /* */
2136
+
2137
+ var HTML5History = (function (History$$1) {
2138
+ function HTML5History (router, base) {
2139
+ var this$1 = this;
2140
+
2141
+ History$$1.call(this, router, base);
2142
+
2143
+ var expectScroll = router.options.scrollBehavior;
2144
+ var supportsScroll = supportsPushState && expectScroll;
2145
+
2146
+ if (supportsScroll) {
2147
+ setupScroll();
2148
+ }
2149
+
2150
+ var initLocation = getLocation(this.base);
2151
+ window.addEventListener('popstate', function (e) {
2152
+ var current = this$1.current;
2153
+
2154
+ // Avoiding first `popstate` event dispatched in some browsers but first
2155
+ // history route not updated since async guard at the same time.
2156
+ var location = getLocation(this$1.base);
2157
+ if (this$1.current === START && location === initLocation) {
2158
+ return
2159
+ }
2160
+
2161
+ this$1.transitionTo(location, function (route) {
2162
+ if (supportsScroll) {
2163
+ handleScroll(router, route, current, true);
2164
+ }
2165
+ });
2166
+ });
2167
+ }
2168
+
2169
+ if ( History$$1 ) HTML5History.__proto__ = History$$1;
2170
+ HTML5History.prototype = Object.create( History$$1 && History$$1.prototype );
2171
+ HTML5History.prototype.constructor = HTML5History;
2172
+
2173
+ HTML5History.prototype.go = function go (n) {
2174
+ window.history.go(n);
2175
+ };
2176
+
2177
+ HTML5History.prototype.push = function push (location, onComplete, onAbort) {
2178
+ var this$1 = this;
2179
+
2180
+ var ref = this;
2181
+ var fromRoute = ref.current;
2182
+ this.transitionTo(location, function (route) {
2183
+ pushState(cleanPath(this$1.base + route.fullPath));
2184
+ handleScroll(this$1.router, route, fromRoute, false);
2185
+ onComplete && onComplete(route);
2186
+ }, onAbort);
2187
+ };
2188
+
2189
+ HTML5History.prototype.replace = function replace (location, onComplete, onAbort) {
2190
+ var this$1 = this;
2191
+
2192
+ var ref = this;
2193
+ var fromRoute = ref.current;
2194
+ this.transitionTo(location, function (route) {
2195
+ replaceState(cleanPath(this$1.base + route.fullPath));
2196
+ handleScroll(this$1.router, route, fromRoute, false);
2197
+ onComplete && onComplete(route);
2198
+ }, onAbort);
2199
+ };
2200
+
2201
+ HTML5History.prototype.ensureURL = function ensureURL (push) {
2202
+ if (getLocation(this.base) !== this.current.fullPath) {
2203
+ var current = cleanPath(this.base + this.current.fullPath);
2204
+ push ? pushState(current) : replaceState(current);
2205
+ }
2206
+ };
2207
+
2208
+ HTML5History.prototype.getCurrentLocation = function getCurrentLocation () {
2209
+ return getLocation(this.base)
2210
+ };
2211
+
2212
+ return HTML5History;
2213
+ }(History));
2214
+
2215
+ function getLocation (base) {
2216
+ var path = decodeURI(window.location.pathname);
2217
+ if (base && path.indexOf(base) === 0) {
2218
+ path = path.slice(base.length);
2219
+ }
2220
+ return (path || '/') + window.location.search + window.location.hash
2221
+ }
2222
+
2223
+ /* */
2224
+
2225
+ var HashHistory = (function (History$$1) {
2226
+ function HashHistory (router, base, fallback) {
2227
+ History$$1.call(this, router, base);
2228
+ // check history fallback deeplinking
2229
+ if (fallback && checkFallback(this.base)) {
2230
+ return
2231
+ }
2232
+ ensureSlash();
2233
+ }
2234
+
2235
+ if ( History$$1 ) HashHistory.__proto__ = History$$1;
2236
+ HashHistory.prototype = Object.create( History$$1 && History$$1.prototype );
2237
+ HashHistory.prototype.constructor = HashHistory;
2238
+
2239
+ // this is delayed until the app mounts
2240
+ // to avoid the hashchange listener being fired too early
2241
+ HashHistory.prototype.setupListeners = function setupListeners () {
2242
+ var this$1 = this;
2243
+
2244
+ var router = this.router;
2245
+ var expectScroll = router.options.scrollBehavior;
2246
+ var supportsScroll = supportsPushState && expectScroll;
2247
+
2248
+ if (supportsScroll) {
2249
+ setupScroll();
2250
+ }
2251
+
2252
+ window.addEventListener(supportsPushState ? 'popstate' : 'hashchange', function () {
2253
+ var current = this$1.current;
2254
+ if (!ensureSlash()) {
2255
+ return
2256
+ }
2257
+ this$1.transitionTo(getHash(), function (route) {
2258
+ if (supportsScroll) {
2259
+ handleScroll(this$1.router, route, current, true);
2260
+ }
2261
+ if (!supportsPushState) {
2262
+ replaceHash(route.fullPath);
2263
+ }
2264
+ });
2265
+ });
2266
+ };
2267
+
2268
+ HashHistory.prototype.push = function push (location, onComplete, onAbort) {
2269
+ var this$1 = this;
2270
+
2271
+ var ref = this;
2272
+ var fromRoute = ref.current;
2273
+ this.transitionTo(location, function (route) {
2274
+ pushHash(route.fullPath);
2275
+ handleScroll(this$1.router, route, fromRoute, false);
2276
+ onComplete && onComplete(route);
2277
+ }, onAbort);
2278
+ };
2279
+
2280
+ HashHistory.prototype.replace = function replace (location, onComplete, onAbort) {
2281
+ var this$1 = this;
2282
+
2283
+ var ref = this;
2284
+ var fromRoute = ref.current;
2285
+ this.transitionTo(location, function (route) {
2286
+ replaceHash(route.fullPath);
2287
+ handleScroll(this$1.router, route, fromRoute, false);
2288
+ onComplete && onComplete(route);
2289
+ }, onAbort);
2290
+ };
2291
+
2292
+ HashHistory.prototype.go = function go (n) {
2293
+ window.history.go(n);
2294
+ };
2295
+
2296
+ HashHistory.prototype.ensureURL = function ensureURL (push) {
2297
+ var current = this.current.fullPath;
2298
+ if (getHash() !== current) {
2299
+ push ? pushHash(current) : replaceHash(current);
2300
+ }
2301
+ };
2302
+
2303
+ HashHistory.prototype.getCurrentLocation = function getCurrentLocation () {
2304
+ return getHash()
2305
+ };
2306
+
2307
+ return HashHistory;
2308
+ }(History));
2309
+
2310
+ function checkFallback (base) {
2311
+ var location = getLocation(base);
2312
+ if (!/^\/#/.test(location)) {
2313
+ window.location.replace(
2314
+ cleanPath(base + '/#' + location)
2315
+ );
2316
+ return true
2317
+ }
2318
+ }
2319
+
2320
+ function ensureSlash () {
2321
+ var path = getHash();
2322
+ if (path.charAt(0) === '/') {
2323
+ return true
2324
+ }
2325
+ replaceHash('/' + path);
2326
+ return false
2327
+ }
2328
+
2329
+ function getHash () {
2330
+ // We can't use window.location.hash here because it's not
2331
+ // consistent across browsers - Firefox will pre-decode it!
2332
+ var href = window.location.href;
2333
+ var index = href.indexOf('#');
2334
+ return index === -1 ? '' : decodeURI(href.slice(index + 1))
2335
+ }
2336
+
2337
+ function getUrl (path) {
2338
+ var href = window.location.href;
2339
+ var i = href.indexOf('#');
2340
+ var base = i >= 0 ? href.slice(0, i) : href;
2341
+ return (base + "#" + path)
2342
+ }
2343
+
2344
+ function pushHash (path) {
2345
+ if (supportsPushState) {
2346
+ pushState(getUrl(path));
2347
+ } else {
2348
+ window.location.hash = path;
2349
+ }
2350
+ }
2351
+
2352
+ function replaceHash (path) {
2353
+ if (supportsPushState) {
2354
+ replaceState(getUrl(path));
2355
+ } else {
2356
+ window.location.replace(getUrl(path));
2357
+ }
2358
+ }
2359
+
2360
+ /* */
2361
+
2362
+ var AbstractHistory = (function (History$$1) {
2363
+ function AbstractHistory (router, base) {
2364
+ History$$1.call(this, router, base);
2365
+ this.stack = [];
2366
+ this.index = -1;
2367
+ }
2368
+
2369
+ if ( History$$1 ) AbstractHistory.__proto__ = History$$1;
2370
+ AbstractHistory.prototype = Object.create( History$$1 && History$$1.prototype );
2371
+ AbstractHistory.prototype.constructor = AbstractHistory;
2372
+
2373
+ AbstractHistory.prototype.push = function push (location, onComplete, onAbort) {
2374
+ var this$1 = this;
2375
+
2376
+ this.transitionTo(location, function (route) {
2377
+ this$1.stack = this$1.stack.slice(0, this$1.index + 1).concat(route);
2378
+ this$1.index++;
2379
+ onComplete && onComplete(route);
2380
+ }, onAbort);
2381
+ };
2382
+
2383
+ AbstractHistory.prototype.replace = function replace (location, onComplete, onAbort) {
2384
+ var this$1 = this;
2385
+
2386
+ this.transitionTo(location, function (route) {
2387
+ this$1.stack = this$1.stack.slice(0, this$1.index).concat(route);
2388
+ onComplete && onComplete(route);
2389
+ }, onAbort);
2390
+ };
2391
+
2392
+ AbstractHistory.prototype.go = function go (n) {
2393
+ var this$1 = this;
2394
+
2395
+ var targetIndex = this.index + n;
2396
+ if (targetIndex < 0 || targetIndex >= this.stack.length) {
2397
+ return
2398
+ }
2399
+ var route = this.stack[targetIndex];
2400
+ this.confirmTransition(route, function () {
2401
+ this$1.index = targetIndex;
2402
+ this$1.updateRoute(route);
2403
+ });
2404
+ };
2405
+
2406
+ AbstractHistory.prototype.getCurrentLocation = function getCurrentLocation () {
2407
+ var current = this.stack[this.stack.length - 1];
2408
+ return current ? current.fullPath : '/'
2409
+ };
2410
+
2411
+ AbstractHistory.prototype.ensureURL = function ensureURL () {
2412
+ // noop
2413
+ };
2414
+
2415
+ return AbstractHistory;
2416
+ }(History));
2417
+
2418
+ /* */
2419
+
2420
+
2421
+
2422
+ var VueRouter = function VueRouter (options) {
2423
+ if ( options === void 0 ) options = {};
2424
+
2425
+ this.app = null;
2426
+ this.apps = [];
2427
+ this.options = options;
2428
+ this.beforeHooks = [];
2429
+ this.resolveHooks = [];
2430
+ this.afterHooks = [];
2431
+ this.matcher = createMatcher(options.routes || [], this);
2432
+
2433
+ var mode = options.mode || 'hash';
2434
+ this.fallback = mode === 'history' && !supportsPushState && options.fallback !== false;
2435
+ if (this.fallback) {
2436
+ mode = 'hash';
2437
+ }
2438
+ if (!inBrowser) {
2439
+ mode = 'abstract';
2440
+ }
2441
+ this.mode = mode;
2442
+
2443
+ switch (mode) {
2444
+ case 'history':
2445
+ this.history = new HTML5History(this, options.base);
2446
+ break
2447
+ case 'hash':
2448
+ this.history = new HashHistory(this, options.base, this.fallback);
2449
+ break
2450
+ case 'abstract':
2451
+ this.history = new AbstractHistory(this, options.base);
2452
+ break
2453
+ default:
2454
+ {
2455
+ assert(false, ("invalid mode: " + mode));
2456
+ }
2457
+ }
2458
+ };
2459
+
2460
+ var prototypeAccessors = { currentRoute: { configurable: true } };
2461
+
2462
+ VueRouter.prototype.match = function match (
2463
+ raw,
2464
+ current,
2465
+ redirectedFrom
2466
+ ) {
2467
+ return this.matcher.match(raw, current, redirectedFrom)
2468
+ };
2469
+
2470
+ prototypeAccessors.currentRoute.get = function () {
2471
+ return this.history && this.history.current
2472
+ };
2473
+
2474
+ VueRouter.prototype.init = function init (app /* Vue component instance */) {
2475
+ var this$1 = this;
2476
+
2477
+ "development" !== 'production' && assert(
2478
+ install.installed,
2479
+ "not installed. Make sure to call `Vue.use(VueRouter)` " +
2480
+ "before creating root instance."
2481
+ );
2482
+
2483
+ this.apps.push(app);
2484
+
2485
+ // main app already initialized.
2486
+ if (this.app) {
2487
+ return
2488
+ }
2489
+
2490
+ this.app = app;
2491
+
2492
+ var history = this.history;
2493
+
2494
+ if (history instanceof HTML5History) {
2495
+ history.transitionTo(history.getCurrentLocation());
2496
+ } else if (history instanceof HashHistory) {
2497
+ var setupHashListener = function () {
2498
+ history.setupListeners();
2499
+ };
2500
+ history.transitionTo(
2501
+ history.getCurrentLocation(),
2502
+ setupHashListener,
2503
+ setupHashListener
2504
+ );
2505
+ }
2506
+
2507
+ history.listen(function (route) {
2508
+ this$1.apps.forEach(function (app) {
2509
+ app._route = route;
2510
+ });
2511
+ });
2512
+ };
2513
+
2514
+ VueRouter.prototype.beforeEach = function beforeEach (fn) {
2515
+ return registerHook(this.beforeHooks, fn)
2516
+ };
2517
+
2518
+ VueRouter.prototype.beforeResolve = function beforeResolve (fn) {
2519
+ return registerHook(this.resolveHooks, fn)
2520
+ };
2521
+
2522
+ VueRouter.prototype.afterEach = function afterEach (fn) {
2523
+ return registerHook(this.afterHooks, fn)
2524
+ };
2525
+
2526
+ VueRouter.prototype.onReady = function onReady (cb, errorCb) {
2527
+ this.history.onReady(cb, errorCb);
2528
+ };
2529
+
2530
+ VueRouter.prototype.onError = function onError (errorCb) {
2531
+ this.history.onError(errorCb);
2532
+ };
2533
+
2534
+ VueRouter.prototype.push = function push (location, onComplete, onAbort) {
2535
+ this.history.push(location, onComplete, onAbort);
2536
+ };
2537
+
2538
+ VueRouter.prototype.replace = function replace (location, onComplete, onAbort) {
2539
+ this.history.replace(location, onComplete, onAbort);
2540
+ };
2541
+
2542
+ VueRouter.prototype.go = function go (n) {
2543
+ this.history.go(n);
2544
+ };
2545
+
2546
+ VueRouter.prototype.back = function back () {
2547
+ this.go(-1);
2548
+ };
2549
+
2550
+ VueRouter.prototype.forward = function forward () {
2551
+ this.go(1);
2552
+ };
2553
+
2554
+ VueRouter.prototype.getMatchedComponents = function getMatchedComponents (to) {
2555
+ var route = to
2556
+ ? to.matched
2557
+ ? to
2558
+ : this.resolve(to).route
2559
+ : this.currentRoute;
2560
+ if (!route) {
2561
+ return []
2562
+ }
2563
+ return [].concat.apply([], route.matched.map(function (m) {
2564
+ return Object.keys(m.components).map(function (key) {
2565
+ return m.components[key]
2566
+ })
2567
+ }))
2568
+ };
2569
+
2570
+ VueRouter.prototype.resolve = function resolve (
2571
+ to,
2572
+ current,
2573
+ append
2574
+ ) {
2575
+ var location = normalizeLocation(
2576
+ to,
2577
+ current || this.history.current,
2578
+ append,
2579
+ this
2580
+ );
2581
+ var route = this.match(location, current);
2582
+ var fullPath = route.redirectedFrom || route.fullPath;
2583
+ var base = this.history.base;
2584
+ var href = createHref(base, fullPath, this.mode);
2585
+ return {
2586
+ location: location,
2587
+ route: route,
2588
+ href: href,
2589
+ // for backwards compat
2590
+ normalizedTo: location,
2591
+ resolved: route
2592
+ }
2593
+ };
2594
+
2595
+ VueRouter.prototype.addRoutes = function addRoutes (routes) {
2596
+ this.matcher.addRoutes(routes);
2597
+ if (this.history.current !== START) {
2598
+ this.history.transitionTo(this.history.getCurrentLocation());
2599
+ }
2600
+ };
2601
+
2602
+ Object.defineProperties( VueRouter.prototype, prototypeAccessors );
2603
+
2604
+ function registerHook (list, fn) {
2605
+ list.push(fn);
2606
+ return function () {
2607
+ var i = list.indexOf(fn);
2608
+ if (i > -1) { list.splice(i, 1); }
2609
+ }
2610
+ }
2611
+
2612
+ function createHref (base, fullPath, mode) {
2613
+ var path = mode === 'hash' ? '#' + fullPath : fullPath;
2614
+ return base ? cleanPath(base + '/' + path) : path
2615
+ }
2616
+
2617
+ VueRouter.install = install;
2618
+ VueRouter.version = '3.0.2';
2619
+
2620
+ if (inBrowser && window.Vue) {
2621
+ window.Vue.use(VueRouter);
2622
+ }
2623
+
2624
+ return VueRouter;
2625
+
2626
+ })));