Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vaadin/router

Package Overview
Dependencies
Maintainers
9
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vaadin/router - npm Package Compare versions

Comparing version 1.0.0-rc.0 to 1.0.0-rc.1

2

dist/vaadin-router.min.js

@@ -1,1 +0,1 @@

function t(t){return t=t||[],Array.isArray(t)?t:[t]}function e(t){return`[Vaadin.Router] ${t}`}const n="module",r="nomodule",o=[n,r];function i(t){if(!t.match(/.+\.[m]?js$/))throw new Error(e(`Unsupported type for bundle "${t}": .js or .mjs expected.`))}function s(t){if(!t||!h(t.path))throw new Error(e('Expected route config to be an object with a "path" string property, or an array of such objects'));const s=t.bundle,u=["component","redirect","bundle"];if(!(l(t.action)||Array.isArray(t.children)||l(t.children)||f(s)||u.some(e=>h(t[e]))))throw new Error(e(`Expected route config "${t.path}" to include either "${u.join('", "')}" `+'or "action" function but none found.'));if(s)if(h(s))i(s);else{if(!o.some(t=>t in s))throw new Error(e('Expected route bundle to include either "'+r+'" or "'+n+'" keys, or both'));o.forEach(t=>t in s&&i(s[t]))}t.redirect&&["bundle","component"].forEach(n=>{n in t&&console.warn(e(`Route config "${t.path}" has both "redirect" and "${n}" properties, `+`and "redirect" will always override the latter. Did you mean to only use "${n}"?`))})}function u(e){t(e).forEach(t=>s(t))}function c(t,e){let o=document.head.querySelector('script[src="'+t+'"][async]');return o||((o=document.createElement("script")).setAttribute("src",t),e===n?o.setAttribute("type",n):e===r&&o.setAttribute(r,""),o.async=!0),new Promise((t,e)=>{o.onreadystatechange=o.onload=(e=>{o.t=!0,t(e)}),o.onerror=(t=>{o.parentNode&&o.parentNode.removeChild(o),e(t)}),null===o.parentNode?document.head.appendChild(o):o.t&&t()})}function a(t,e){window.dispatchEvent(new CustomEvent(`vaadin-router-${t}`,{detail:e}))}function f(t){return"object"==typeof t&&!!t}function l(t){return"function"==typeof t}function h(t){return"string"==typeof t}function d(t){const n=new Error(e(`Page not found (${t.pathname})`));return n.context=t,n.code=404,n}function p(t){if(t.defaultPrevented)return;if(0!==t.button)return;if(t.shiftKey||t.ctrlKey||t.altKey||t.metaKey)return;let e=t.target;const n=t.composedPath?t.composedPath():t.path||[];for(let t=0;t<n.length;t++){const r=n[t];if(r.nodeName&&"a"===r.nodeName.toLowerCase()){e=r;break}}for(;e&&"a"!==e.nodeName.toLowerCase();)e=e.parentNode;e&&"a"===e.nodeName.toLowerCase()&&(e.target&&"_self"!==e.target.toLowerCase()||e.hasAttribute("download")||e.pathname===window.location.pathname&&""!==e.hash||(e.origin||function(t){const e=t.port,n=t.protocol;return`${n}//${"http:"===n&&"80"===e||"https:"===n&&"443"===e?t.hostname:t.host}`}(e))===window.location.origin&&(t.preventDefault(),a("go",{pathname:e.pathname})))}const w={activate(){window.document.addEventListener("click",p)},inactivate(){window.document.removeEventListener("click",p)}};function m(t){"vaadin-router-ignore"!==t.state&&a("go",{pathname:window.location.pathname})}/Trident/.test(navigator.userAgent)&&!l(window.PopStateEvent)&&(window.PopStateEvent=function(t,e){e=e||{};var n=document.createEvent("Event");return n.initEvent(t,Boolean(e.bubbles),Boolean(e.cancelable)),n.state=e.state||null,n},window.PopStateEvent.prototype=window.Event.prototype);const v={activate(){window.addEventListener("popstate",m)},inactivate(){window.removeEventListener("popstate",m)}};var y=A,g=P,b=function(t,e){return j(P(t,e))},E=j,_=T,$="/",x="./",O=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");function P(t,e){for(var n,r=[],o=0,i=0,s="",u=e&&e.delimiter||$,c=e&&e.delimiters||x,a=!1;null!==(n=O.exec(t));){var f=n[0],l=n[1],h=n.index;if(s+=t.slice(i,h),i=h+f.length,l)s+=l[1],a=!0;else{var d="",p=t[i],w=n[2],m=n[3],v=n[4],y=n[5];if(!a&&s.length){var g=s.length-1;c.indexOf(s[g])>-1&&(d=s[g],s=s.slice(0,g))}s&&(r.push(s),s="",a=!1);var b=""!==d&&void 0!==p&&p!==d,E="+"===y||"*"===y,_="?"===y||"*"===y,P=d||u,j=m||v;r.push({name:w||o++,prefix:d,delimiter:P,optional:_,repeat:E,partial:b,pattern:j?k(j):"[^"+R(P)+"]+?"})}}return(s||i<t.length)&&r.push(s+t.substr(i)),r}function j(t){for(var e=new Array(t.length),n=0;n<t.length;n++)"object"==typeof t[n]&&(e[n]=new RegExp("^(?:"+t[n].pattern+")$"));return function(n,r){for(var o="",i=r&&r.encode||encodeURIComponent,s=0;s<t.length;s++){var u=t[s];if("string"!=typeof u){var c,a=n?n[u.name]:void 0;if(Array.isArray(a)){if(!u.repeat)throw new TypeError('Expected "'+u.name+'" to not repeat, but got array');if(0===a.length){if(u.optional)continue;throw new TypeError('Expected "'+u.name+'" to not be empty')}for(var f=0;f<a.length;f++){if(c=i(a[f],u),!e[s].test(c))throw new TypeError('Expected all "'+u.name+'" to match "'+u.pattern+'"');o+=(0===f?u.prefix:u.delimiter)+c}}else if("string"!=typeof a&&"number"!=typeof a&&"boolean"!=typeof a){if(!u.optional)throw new TypeError('Expected "'+u.name+'" to be '+(u.repeat?"an array":"a string"));u.partial&&(o+=u.prefix)}else{if(c=i(String(a),u),!e[s].test(c))throw new TypeError('Expected "'+u.name+'" to match "'+u.pattern+'", but got "'+c+'"');o+=u.prefix+c}}else o+=u}return o}}function R(t){return t.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function k(t){return t.replace(/([=!:$/()])/g,"\\$1")}function C(t){return t&&t.sensitive?"":"i"}function T(t,e,n){for(var r=(n=n||{}).strict,o=!1!==n.end,i=R(n.delimiter||$),s=n.delimiters||x,u=[].concat(n.endsWith||[]).map(R).concat("$").join("|"),c="",a=!1,f=0;f<t.length;f++){var l=t[f];if("string"==typeof l)c+=R(l),a=f===t.length-1&&s.indexOf(l[l.length-1])>-1;else{var h=R(l.prefix),d=l.repeat?"(?:"+l.pattern+")(?:"+h+"(?:"+l.pattern+"))*":l.pattern;e&&e.push(l),l.optional?l.partial?c+=h+"("+d+")?":c+="(?:"+h+"("+d+"))?":c+=h+"("+d+")"}}return o?(r||(c+="(?:"+i+")?"),c+="$"===u?"$":"(?="+u+")"):(r||(c+="(?:"+i+"(?="+u+"))?"),a||(c+="(?="+i+"|"+u+")")),new RegExp("^"+c,C(n))}function A(t,e,n){return t instanceof RegExp?function(t,e){if(!e)return t;var n=t.source.match(/\((?!\?)/g);if(n)for(var r=0;r<n.length;r++)e.push({name:r,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,pattern:null});return t}(t,e):Array.isArray(t)?function(t,e,n){for(var r=[],o=0;o<t.length;o++)r.push(A(t[o],e,n).source);return new RegExp("(?:"+r.join("|")+")",C(n))}(t,e,n):function(t,e,n){return T(P(t,n),e,n)}(t,e,n)}y.parse=g,y.compile=b,y.tokensToFunction=E,y.tokensToRegExp=_;const{hasOwnProperty:B}=Object.prototype,I=new Map;function M(t){try{return decodeURIComponent(t)}catch(e){return t}}function L(t,e,n,r,o){let i,s,u=0,c=t.path||"";return"/"===c.charAt(0)&&(n&&(c=c.substr(1)),n=!0),{next(a){if(t===a)return{done:!0};const f=t.o=t.o||t.children;if(!i&&(i=function(t,e,n,r,o){const i=`${t}|${n=!!n}`;let s=I.get(i);if(!s){const e=[];s={keys:e,pattern:y(t,e,{end:n,strict:""===t})},I.set(i,s)}const u=s.pattern.exec(e);if(!u)return null;const c=Object.assign({},o);for(let t=1;t<u.length;t++){const e=s.keys[t-1],n=e.name,r=u[t];void 0===r&&B.call(c,n)||(e.repeat?c[n]=r?r.split(e.delimiter).map(M):[]:c[n]=r?M(r):r)}return{path:u[0],keys:(r||[]).concat(s.keys),params:c}}(c,e,!f,r,o)))return{done:!1,value:{route:t,keys:i.keys,params:i.params,path:i.path}};if(i&&f)for(;u<f.length;){if(!s){const r=f[u];r.parent=t;let o=i.path.length;o>0&&"/"===e.charAt(o)&&(o+=1),s=L(r,e.substr(o),n,i.keys,i.params)}const r=s.next(a);if(!r.done)return{done:!1,value:r.value};s=null,u++}return{done:!0}}}}function S(t){if(l(t.route.action))return t.route.action(t)}I.set("|false",{keys:[],pattern:/(?:)/});class D{constructor(t,e={}){if(Object(t)!==t)throw new TypeError("Invalid routes");this.baseUrl=e.baseUrl||"",this.errorHandler=e.errorHandler,this.resolveRoute=e.resolveRoute||S,this.context=Object.assign({resolver:this},e.context),this.root=Array.isArray(t)?{path:"",o:t,parent:null,i:!0}:t,this.root.parent=null}getRoutes(){return[...this.root.o]}setRoutes(e){u(e);const n=[...t(e)];this.root.o=n}addRoutes(e){return u(e),this.root.o.push(...t(e)),this.getRoutes()}removeRoutes(){this.setRoutes([])}resolve(t){const e=Object.assign({},this.context,h(t)?{pathname:t}:t),n=L(this.root,e.pathname.substr(this.baseUrl.length)),r=this.resolveRoute;let o=null,i=null,s=e;function u(t,c=o.value.route,a){const f=null===a&&o.value.route;return o=i||n.next(f),i=null,t||!o.done&&function(t,e){let n=e;for(;n;)if((n=n.parent)===t)return!0;return!1}(c,o.value.route)?o.done?Promise.reject(d(e)):(function(t,e){const{route:n,path:r}=e;if(n&&!n.i){const e={path:r,route:n};!function(t,e){return!e.parent||!t||!t.length||t[t.length-1].route!==e.parent}(t.chain,n)?t.chain.push(e):t.chain=[e]}}(e,o.value),s=Object.assign({},e,o.value),Promise.resolve(r(s)).then(e=>null!==e&&void 0!==e?(s.result=e.result||e,s):u(t,c,e))):(i=o,Promise.resolve(null))}return e.next=u,Promise.resolve().then(()=>u(!0,this.root)).catch(t=>{const e=function(t){let e=`Path '${t.pathname}' is not properly resolved due to an error.`;const n=(t.route||{}).path;return n&&(e+=` Resolution had failed on route: '${n}'`),e}(s);if(t?console.warn(e):t=new Error(e),t.context=t.context||s,t instanceof DOMException||(t.code=t.code||500),this.errorHandler)return s.result=this.errorHandler(t),s;throw t})}}D.pathToRegexp=y;let H=[];function N(t){H.forEach(t=>t.inactivate()),t.forEach(t=>t.activate()),H=t}const F=t=>{const e=getComputedStyle(t).getPropertyValue("animation-name");return e&&"none"!==e},U=(t,e)=>{const n=()=>{t.removeEventListener("animationend",n),e()};t.addEventListener("animationend",n)};function W(t,e){return t.classList.add(e),new Promise(n=>{if(F(t)){const r=t.getBoundingClientRect(),o=`height: ${r.bottom-r.top}px; width: ${r.right-r.left}px`;t.setAttribute("style",`position: absolute; ${o}`),U(t,()=>{t.classList.remove(e),t.removeAttribute("style"),n()})}else t.classList.remove(e),n()})}const K=256;function V(t){return null!==t&&void 0!==t}function q({pathname:t="",chain:e=[],params:n={},redirectFrom:r},o){return{pathname:t,routes:e.map(t=>t.route),route:!o&&e.length&&e[e.length-1].route||o,params:n,redirectFrom:r}}function z(t,e){const n=Object.assign({},t.params);return{redirect:{pathname:e,from:t.pathname,params:n}}}function G(t,e,n){if(l(t))return t.apply(n,e)}function J(t,e,n){return r=>r&&(r.cancel||r.redirect)?r:n?G(n[t],e,n):void 0}function Q(t){if(t&&t.length){const e=t[0].parentNode;for(let n=0;n<t.length;n++)e.removeChild(t[n])}}class X extends D{constructor(t,e){super([],Object.assign({},e)),this.resolveRoute=(t=>this.s(t));const n=X.NavigationTrigger;X.setTriggers.apply(X,Object.keys(n).map(t=>n[t])),this.ready,this.ready=Promise.resolve(t),this.location,this.location=q({}),this.u=0,this.l=this.h.bind(this),this.setOutlet(t),this.subscribe()}s(n){const r=n.route,i={redirect:t=>z(n,t),component:t=>(function(t,e){const n=document.createElement(e);n.location=q(t);const r=t.chain.map(t=>t.route).indexOf(t.route);return t.chain[r].element=n,n})(n,t)},u=G(r.action,[n,i],r);if(V(u))return u;if(h(r.redirect))return i.redirect(r.redirect);let a=Promise.resolve();var d;return r.bundle&&(a=a.then(()=>(d=r.bundle,h(d)?c(d):Promise.race(o.filter(t=>t in d).map(t=>c(d[t],t))))).catch(()=>{throw new Error(e(`Bundle not found: ${r.bundle}. Check if the file name is correct`))})),l(r.children)&&(a=a.then(()=>r.children(function(t){const e=Object.assign({},t);return delete e.next,e}(n))).then(n=>{V(n)||l(r.children)||(n=r.children),function(n,r){if(!Array.isArray(n)&&!f(n))throw new Error(e(`Incorrect "children" value for the route ${r.path}: expected array or object, but got ${n}`));r.o=[];const o=t(n);for(let t=0;t<o.length;t++)s(o[t]),r.o.push(o[t])}(n,r)})),a.then(()=>{if(h(r.component))return i.component(r.component)})}setOutlet(t){t&&this.p(t),this.m=t}getOutlet(){return this.m}setRoutes(t){super.setRoutes(t),this.h()}render(t,e){const n=++this.u,r=t.pathname||t;return this.ready=this.resolve(t).then(t=>this.v(t)).then(t=>{if(n===this.u){const r=this.g;if(t===r)return this.location;e&&this._(t.pathname,t.redirectFrom),this.$(t,r);const o=this.O(t);return this.P(t),this.j(t,r),o.then(()=>{if(n===this.u)return this.R(),this.g=t,this.location=q(t),a("location-changed",{router:this,location:this.location}),this.location})}}).catch(t=>{if(n===this.u)throw e&&this._(r),Q(this.m&&this.m.children),this.location=q({pathname:r}),a("error",{router:this,error:t,pathname:r}),t}),this.ready}v(t,e=t){return this.k(e).then(n=>{const r=n!==e?n:t;return n.next().then(t=>{if(null===t&&n.pathname!==n.chain.map(t=>t.path).reduce((t,e)=>e.length?"/"===t?t+e:t+"/"+e:t))throw d(r);return t?this.v(r,t):this.C(r)})})}k(t){const n=t.result;return n instanceof HTMLElement?Promise.resolve(t):n.redirect?this.T(n.redirect,t.A).then(t=>this.k(t)):n instanceof Error?Promise.reject(n):Promise.reject(new Error(e(`Invalid route resolution result for path "${t.pathname}". `+`Expected redirect object or HTML element, but got: "${n}". `+"Double check the action return value for the route.")))}C(t){return this.B(t).then(e=>e===this.g||e===t?e:this.v(e))}B(t){const e=(this.g||{}).chain||[],n=t.chain;let r=Promise.resolve();const o=()=>({cancel:!0}),i=e=>z(t,e);if(t.I=0,e.length){for(let r=0;r<Math.min(e.length,n.length)&&(e[r].route===n[r].route&&e[r].path===n[r].path);r=++t.I);for(let n=e.length-1;n>=t.I;n--){const i=q(t);r=r.then(J("onBeforeLeave",[i,{prevent:o},this],e[n].element)).then(t=>{if(!(t||{}).redirect)return t})}}for(let e=t.I;e<n.length;e++){const s=q(t,n[e].route);r=r.then(J("onBeforeEnter",[s,{prevent:o,redirect:i},this],n[e].element))}return r.then(e=>{if(e){if(e.cancel)return this.g;if(e.redirect)return this.T(e.redirect,t.A)}return t})}T(t,n){if(n>K)throw new Error(e(`Too many redirects when rendering ${t.from}`));return this.resolve({pathname:X.pathToRegexp.compile(t.pathname)(t.params),redirectFrom:t.from,A:(n||0)+1})}p(t=this.m){if(!(t instanceof Node))throw new TypeError(e(`Expected router outlet to be a valid DOM Node (but got ${t})`))}_(t,e){if(window.location.pathname!==t){const n=e?"replaceState":"pushState";window.history[n](null,document.title,t),window.dispatchEvent(new PopStateEvent("popstate",{state:"vaadin-router-ignore"}))}}$(t,e){this.p(),this.M();let n=this.m;for(let r=0;r<t.I;r++){const o=e&&e.chain[r].element;if(o){if(o.parentNode!==n)break;t.chain[r].element=o,n=o}}this.L=Array.from(n.children),this.S=[];let r=n;for(let e=t.I;e<t.chain.length;e++){const o=t.chain[e].element;o&&(r.appendChild(o),r===n&&this.S.push(o),r=o)}}R(){this.L&&Q(this.L),this.L=null,this.S=null}M(){this.L&&this.S&&(Q(this.S),this.L=null,this.S=null)}j(t,e){if(e)for(let n=e.chain.length-1;n>=t.I;n--){const r=e.chain[n].element;if(r)try{const n=q(t);G(r.onAfterLeave,[n,{},e.resolver],r)}finally{Q(r.children)}}}P(t){for(let e=t.I;e<t.chain.length;e++){const n=t.chain[e].element||{},r=q(t,t.chain[e].route);G(n.onAfterEnter,[r,{},t.resolver],n)}}O(t){const e=(this.L||[])[0],n=(this.S||[])[0],r=[],o=t.chain;let i;for(let t=o.length;t>0;t--)if(o[t-1].route.animate){i=o[t-1].route.animate;break}if(e&&n&&i){const t=f(i)&&i.leave||"leaving",o=f(i)&&i.enter||"entering";r.push(W(e,t)),r.push(W(n,o))}return Promise.all(r).then(()=>t)}subscribe(){window.addEventListener("vaadin-router-go",this.l)}unsubscribe(){window.removeEventListener("vaadin-router-go",this.l)}h(t){const e=t?t.detail.pathname:window.location.pathname;this.render(e,!0)}static setTriggers(...t){N(t)}static go(t){a("go",{pathname:t})}}const Y=(()=>(class extends HTMLElement{static get is(){return"vaadin-router-meta"}static get version(){return"0.3.0"}}))();customElements.define(Y.is,Y),X.NavigationTrigger={POPSTATE:v,CLICK:w};export{X as Router,D as Resolver};
function t(t){return t=t||[],Array.isArray(t)?t:[t]}function e(t){return`[Vaadin.Router] ${t}`}const n="module",r="nomodule",o=[n,r];function i(t){if(!t.match(/.+\.[m]?js$/))throw new Error(e(`Unsupported type for bundle "${t}": .js or .mjs expected.`))}function s(t){if(!t||!h(t.path))throw new Error(e('Expected route config to be an object with a "path" string property, or an array of such objects'));const s=t.bundle,u=["component","redirect","bundle"];if(!(l(t.action)||Array.isArray(t.children)||l(t.children)||f(s)||u.some(e=>h(t[e]))))throw new Error(e(`Expected route config "${t.path}" to include either "${u.join('", "')}" `+'or "action" function but none found.'));if(s)if(h(s))i(s);else{if(!o.some(t=>t in s))throw new Error(e('Expected route bundle to include either "'+r+'" or "'+n+'" keys, or both'));o.forEach(t=>t in s&&i(s[t]))}t.redirect&&["bundle","component"].forEach(n=>{n in t&&console.warn(e(`Route config "${t.path}" has both "redirect" and "${n}" properties, `+`and "redirect" will always override the latter. Did you mean to only use "${n}"?`))})}function u(e){t(e).forEach(t=>s(t))}function c(t,e){let o=document.head.querySelector('script[src="'+t+'"][async]');return o||((o=document.createElement("script")).setAttribute("src",t),e===n?o.setAttribute("type",n):e===r&&o.setAttribute(r,""),o.async=!0),new Promise((t,e)=>{o.onreadystatechange=o.onload=(e=>{o.t=!0,t(e)}),o.onerror=(t=>{o.parentNode&&o.parentNode.removeChild(o),e(t)}),null===o.parentNode?document.head.appendChild(o):o.t&&t()})}function a(t,e){window.dispatchEvent(new CustomEvent(`vaadin-router-${t}`,{detail:e}))}function f(t){return"object"==typeof t&&!!t}function l(t){return"function"==typeof t}function h(t){return"string"==typeof t}function d(t){const n=new Error(e(`Page not found (${t.pathname})`));return n.context=t,n.code=404,n}function p(t){if(t.defaultPrevented)return;if(0!==t.button)return;if(t.shiftKey||t.ctrlKey||t.altKey||t.metaKey)return;let e=t.target;const n=t.composedPath?t.composedPath():t.path||[];for(let t=0;t<n.length;t++){const r=n[t];if(r.nodeName&&"a"===r.nodeName.toLowerCase()){e=r;break}}for(;e&&"a"!==e.nodeName.toLowerCase();)e=e.parentNode;e&&"a"===e.nodeName.toLowerCase()&&(e.target&&"_self"!==e.target.toLowerCase()||e.hasAttribute("download")||e.pathname===window.location.pathname&&""!==e.hash||(e.origin||function(t){const e=t.port,n=t.protocol;return`${n}//${"http:"===n&&"80"===e||"https:"===n&&"443"===e?t.hostname:t.host}`}(e))===window.location.origin&&(t.preventDefault(),a("go",{pathname:e.pathname})))}const w={activate(){window.document.addEventListener("click",p)},inactivate(){window.document.removeEventListener("click",p)}};function m(t){"vaadin-router-ignore"!==t.state&&a("go",{pathname:window.location.pathname})}/Trident/.test(navigator.userAgent)&&!l(window.PopStateEvent)&&(window.PopStateEvent=function(t,e){e=e||{};var n=document.createEvent("Event");return n.initEvent(t,Boolean(e.bubbles),Boolean(e.cancelable)),n.state=e.state||null,n},window.PopStateEvent.prototype=window.Event.prototype);const v={activate(){window.addEventListener("popstate",m)},inactivate(){window.removeEventListener("popstate",m)}};var y=A,g=j,b=function(t,e){return P(j(t,e))},E=P,_=T,$="/",x="./",O=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");function j(t,e){for(var n,r=[],o=0,i=0,s="",u=e&&e.delimiter||$,c=e&&e.delimiters||x,a=!1;null!==(n=O.exec(t));){var f=n[0],l=n[1],h=n.index;if(s+=t.slice(i,h),i=h+f.length,l)s+=l[1],a=!0;else{var d="",p=t[i],w=n[2],m=n[3],v=n[4],y=n[5];if(!a&&s.length){var g=s.length-1;c.indexOf(s[g])>-1&&(d=s[g],s=s.slice(0,g))}s&&(r.push(s),s="",a=!1);var b=""!==d&&void 0!==p&&p!==d,E="+"===y||"*"===y,_="?"===y||"*"===y,j=d||u,P=m||v;r.push({name:w||o++,prefix:d,delimiter:j,optional:_,repeat:E,partial:b,pattern:P?k(P):"[^"+R(j)+"]+?"})}}return(s||i<t.length)&&r.push(s+t.substr(i)),r}function P(t){for(var e=new Array(t.length),n=0;n<t.length;n++)"object"==typeof t[n]&&(e[n]=new RegExp("^(?:"+t[n].pattern+")$"));return function(n,r){for(var o="",i=r&&r.encode||encodeURIComponent,s=0;s<t.length;s++){var u=t[s];if("string"!=typeof u){var c,a=n?n[u.name]:void 0;if(Array.isArray(a)){if(!u.repeat)throw new TypeError('Expected "'+u.name+'" to not repeat, but got array');if(0===a.length){if(u.optional)continue;throw new TypeError('Expected "'+u.name+'" to not be empty')}for(var f=0;f<a.length;f++){if(c=i(a[f],u),!e[s].test(c))throw new TypeError('Expected all "'+u.name+'" to match "'+u.pattern+'"');o+=(0===f?u.prefix:u.delimiter)+c}}else if("string"!=typeof a&&"number"!=typeof a&&"boolean"!=typeof a){if(!u.optional)throw new TypeError('Expected "'+u.name+'" to be '+(u.repeat?"an array":"a string"));u.partial&&(o+=u.prefix)}else{if(c=i(String(a),u),!e[s].test(c))throw new TypeError('Expected "'+u.name+'" to match "'+u.pattern+'", but got "'+c+'"');o+=u.prefix+c}}else o+=u}return o}}function R(t){return t.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function k(t){return t.replace(/([=!:$/()])/g,"\\$1")}function C(t){return t&&t.sensitive?"":"i"}function T(t,e,n){for(var r=(n=n||{}).strict,o=!1!==n.end,i=R(n.delimiter||$),s=n.delimiters||x,u=[].concat(n.endsWith||[]).map(R).concat("$").join("|"),c="",a=0===t.length,f=0;f<t.length;f++){var l=t[f];if("string"==typeof l)c+=R(l),a=f===t.length-1&&s.indexOf(l[l.length-1])>-1;else{var h=R(l.prefix),d=l.repeat?"(?:"+l.pattern+")(?:"+h+"(?:"+l.pattern+"))*":l.pattern;e&&e.push(l),l.optional?l.partial?c+=h+"("+d+")?":c+="(?:"+h+"("+d+"))?":c+=h+"("+d+")"}}return o?(r||(c+="(?:"+i+")?"),c+="$"===u?"$":"(?="+u+")"):(r||(c+="(?:"+i+"(?="+u+"))?"),a||(c+="(?="+i+"|"+u+")")),new RegExp("^"+c,C(n))}function A(t,e,n){return t instanceof RegExp?function(t,e){if(!e)return t;var n=t.source.match(/\((?!\?)/g);if(n)for(var r=0;r<n.length;r++)e.push({name:r,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,pattern:null});return t}(t,e):Array.isArray(t)?function(t,e,n){for(var r=[],o=0;o<t.length;o++)r.push(A(t[o],e,n).source);return new RegExp("(?:"+r.join("|")+")",C(n))}(t,e,n):function(t,e,n){return T(j(t,n),e,n)}(t,e,n)}y.parse=g,y.compile=b,y.tokensToFunction=E,y.tokensToRegExp=_;const{hasOwnProperty:B}=Object.prototype,S=new Map;function I(t){try{return decodeURIComponent(t)}catch(e){return t}}function M(t,e,n,r,o){let i,s,u=0,c=t.path||"";return"/"===c.charAt(0)&&(n&&(c=c.substr(1)),n=!0),{next(a){if(t===a)return{done:!0};const f=t.o=t.o||t.children;if(!i&&(i=function(t,e,n,r,o){const i=`${t}|${n=!!n}`;let s=S.get(i);if(!s){const e=[];s={keys:e,pattern:y(t,e,{end:n,strict:""===t})},S.set(i,s)}const u=s.pattern.exec(e);if(!u)return null;const c=Object.assign({},o);for(let t=1;t<u.length;t++){const e=s.keys[t-1],n=e.name,r=u[t];void 0===r&&B.call(c,n)||(e.repeat?c[n]=r?r.split(e.delimiter).map(I):[]:c[n]=r?I(r):r)}return{path:u[0],keys:(r||[]).concat(s.keys),params:c}}(c,e,!f,r,o)))return{done:!1,value:{route:t,keys:i.keys,params:i.params,path:i.path}};if(i&&f)for(;u<f.length;){if(!s){const r=f[u];r.parent=t;let o=i.path.length;o>0&&"/"===e.charAt(o)&&(o+=1),s=M(r,e.substr(o),n,i.keys,i.params)}const r=s.next(a);if(!r.done)return{done:!1,value:r.value};s=null,u++}return{done:!0}}}}function L(t){if(l(t.route.action))return t.route.action(t)}S.set("|false",{keys:[],pattern:/(?:)/});class D{constructor(t,e={}){if(Object(t)!==t)throw new TypeError("Invalid routes");this.baseUrl=e.baseUrl||"",this.errorHandler=e.errorHandler,this.resolveRoute=e.resolveRoute||L,this.context=Object.assign({resolver:this},e.context),this.root=Array.isArray(t)?{path:"",o:t,parent:null,i:!0}:t,this.root.parent=null}getRoutes(){return[...this.root.o]}setRoutes(e){u(e);const n=[...t(e)];this.root.o=n}addRoutes(e){return u(e),this.root.o.push(...t(e)),this.getRoutes()}removeRoutes(){this.setRoutes([])}resolve(t){const e=Object.assign({},this.context,h(t)?{pathname:t}:t),n=M(this.root,e.pathname.substr(this.baseUrl.length)),r=this.resolveRoute;let o=null,i=null,s=e;function u(t,c=o.value.route,a){const f=null===a&&o.value.route;return o=i||n.next(f),i=null,t||!o.done&&function(t,e){let n=e;for(;n;)if((n=n.parent)===t)return!0;return!1}(c,o.value.route)?o.done?Promise.reject(d(e)):(function(t,e){const{route:n,path:r}=e;if(n&&!n.i){const e={path:r,route:n};!function(t,e){return!e.parent||!t||!t.length||t[t.length-1].route!==e.parent}(t.chain,n)?t.chain.push(e):t.chain=[e]}}(e,o.value),s=Object.assign({},e,o.value),Promise.resolve(r(s)).then(e=>null!==e&&void 0!==e?(s.result=e.result||e,s):u(t,c,e))):(i=o,Promise.resolve(null))}return e.next=u,Promise.resolve().then(()=>u(!0,this.root)).catch(t=>{const e=function(t){let e=`Path '${t.pathname}' is not properly resolved due to an error.`;const n=(t.route||{}).path;return n&&(e+=` Resolution had failed on route: '${n}'`),e}(s);if(t?console.warn(e):t=new Error(e),t.context=t.context||s,t instanceof DOMException||(t.code=t.code||500),this.errorHandler)return s.result=this.errorHandler(t),s;throw t})}}D.pathToRegexp=y;let F=[];function H(t){F.forEach(t=>t.inactivate()),t.forEach(t=>t.activate()),F=t}const N=t=>{const e=getComputedStyle(t).getPropertyValue("animation-name");return e&&"none"!==e},U=(t,e)=>{const n=()=>{t.removeEventListener("animationend",n),e()};t.addEventListener("animationend",n)};function W(t,e){return t.classList.add(e),new Promise(n=>{if(N(t)){const r=t.getBoundingClientRect(),o=`height: ${r.bottom-r.top}px; width: ${r.right-r.left}px`;t.setAttribute("style",`position: absolute; ${o}`),U(t,()=>{t.classList.remove(e),t.removeAttribute("style"),n()})}else t.classList.remove(e),n()})}const K=256;function V(t){return null!==t&&void 0!==t}function q({pathname:t="",chain:e=[],params:n={},redirectFrom:r},o){return{pathname:t,routes:e.map(t=>t.route),route:!o&&e.length&&e[e.length-1].route||o,params:n,redirectFrom:r}}function z(t,e){const n=Object.assign({},t.params);return{redirect:{pathname:e,from:t.pathname,params:n}}}function G(t,e,n){if(l(t))return t.apply(n,e)}function J(t,e,n){return r=>r&&(r.cancel||r.redirect)?r:n?G(n[t],e,n):void 0}function Q(t){if(t&&t.length){const e=t[0].parentNode;for(let n=0;n<t.length;n++)e.removeChild(t[n])}}class X extends D{constructor(t,e){super([],Object.assign({},e)),this.resolveRoute=(t=>this.s(t));const n=X.NavigationTrigger;X.setTriggers.apply(X,Object.keys(n).map(t=>n[t])),this.ready,this.ready=Promise.resolve(t),this.location,this.location=q({}),this.u=0,this.l=this.h.bind(this),this.setOutlet(t),this.subscribe()}s(n){const r=n.route,i={redirect:t=>z(n,t),component:t=>(function(t,e){const n=document.createElement(e);n.location=q(t);const r=t.chain.map(t=>t.route).indexOf(t.route);return t.chain[r].element=n,n})(n,t)},u=G(r.action,[n,i],r);if(V(u))return u;if(h(r.redirect))return i.redirect(r.redirect);let a=Promise.resolve();var d;return r.bundle&&(a=a.then(()=>(d=r.bundle,h(d)?c(d):Promise.race(o.filter(t=>t in d).map(t=>c(d[t],t))))).catch(()=>{throw new Error(e(`Bundle not found: ${r.bundle}. Check if the file name is correct`))})),l(r.children)&&(a=a.then(()=>r.children(function(t){const e=Object.assign({},t);return delete e.next,e}(n))).then(n=>{V(n)||l(r.children)||(n=r.children),function(n,r){if(!Array.isArray(n)&&!f(n))throw new Error(e(`Incorrect "children" value for the route ${r.path}: expected array or object, but got ${n}`));r.o=[];const o=t(n);for(let t=0;t<o.length;t++)s(o[t]),r.o.push(o[t])}(n,r)})),a.then(()=>{if(h(r.component))return i.component(r.component)})}setOutlet(t){t&&this.p(t),this.m=t}getOutlet(){return this.m}setRoutes(t){super.setRoutes(t),this.h()}render(t,e){const n=++this.u,r=t.pathname||t;return this.ready=this.resolve(t).then(t=>this.v(t)).then(t=>{if(n===this.u){const r=this.g;if(t===r)return this.location;e&&this._(t.pathname,t.redirectFrom),this.$(t,r);const o=this.O(t);return this.j(t),this.P(t,r),o.then(()=>{if(n===this.u)return this.R(),this.g=t,this.location=q(t),a("location-changed",{router:this,location:this.location}),this.location})}}).catch(t=>{if(n===this.u)throw e&&this._(r),Q(this.m&&this.m.children),this.location=q({pathname:r}),a("error",{router:this,error:t,pathname:r}),t}),this.ready}v(t,e=t){return this.k(e).then(n=>{const r=n!==e?n:t;return n.next().then(t=>{if(null===t&&n.pathname!==n.chain.map(t=>t.path).reduce((t,e)=>e.length?t+("/"===t.charAt(t.length-1)?"":"/")+e:t))throw d(r);return t?this.v(r,t):this.C(r)})})}k(t){const n=t.result;return n instanceof HTMLElement?Promise.resolve(t):n.redirect?this.T(n.redirect,t.A).then(t=>this.k(t)):n instanceof Error?Promise.reject(n):Promise.reject(new Error(e(`Invalid route resolution result for path "${t.pathname}". `+`Expected redirect object or HTML element, but got: "${n}". `+"Double check the action return value for the route.")))}C(t){return this.B(t).then(e=>e===this.g||e===t?e:this.v(e))}B(t){const e=(this.g||{}).chain||[],n=t.chain;let r=Promise.resolve();const o=()=>({cancel:!0}),i=e=>z(t,e);if(t.S=0,e.length){for(let r=0;r<Math.min(e.length,n.length)&&(e[r].route===n[r].route&&e[r].path===n[r].path);r=++t.S);for(let n=e.length-1;n>=t.S;n--){const i=q(t);r=r.then(J("onBeforeLeave",[i,{prevent:o},this],e[n].element)).then(t=>{if(!(t||{}).redirect)return t})}}for(let e=t.S;e<n.length;e++){const s=q(t,n[e].route);r=r.then(J("onBeforeEnter",[s,{prevent:o,redirect:i},this],n[e].element))}return r.then(e=>{if(e){if(e.cancel)return this.g;if(e.redirect)return this.T(e.redirect,t.A)}return t})}T(t,n){if(n>K)throw new Error(e(`Too many redirects when rendering ${t.from}`));return this.resolve({pathname:X.pathToRegexp.compile(t.pathname)(t.params),redirectFrom:t.from,A:(n||0)+1})}p(t=this.m){if(!(t instanceof Node))throw new TypeError(e(`Expected router outlet to be a valid DOM Node (but got ${t})`))}_(t,e){if(window.location.pathname!==t){const n=e?"replaceState":"pushState";window.history[n](null,document.title,t),window.dispatchEvent(new PopStateEvent("popstate",{state:"vaadin-router-ignore"}))}}$(t,e){this.p(),this.I();let n=this.m;for(let r=0;r<t.S;r++){const o=e&&e.chain[r].element;if(o){if(o.parentNode!==n)break;t.chain[r].element=o,n=o}}this.M=Array.from(n.children),this.L=[];let r=n;for(let e=t.S;e<t.chain.length;e++){const o=t.chain[e].element;o&&(r.appendChild(o),r===n&&this.L.push(o),r=o)}}R(){this.M&&Q(this.M),this.M=null,this.L=null}I(){this.M&&this.L&&(Q(this.L),this.M=null,this.L=null)}P(t,e){if(e)for(let n=e.chain.length-1;n>=t.S;n--){const r=e.chain[n].element;if(r)try{const n=q(t);G(r.onAfterLeave,[n,{},e.resolver],r)}finally{Q(r.children)}}}j(t){for(let e=t.S;e<t.chain.length;e++){const n=t.chain[e].element||{},r=q(t,t.chain[e].route);G(n.onAfterEnter,[r,{},t.resolver],n)}}O(t){const e=(this.M||[])[0],n=(this.L||[])[0],r=[],o=t.chain;let i;for(let t=o.length;t>0;t--)if(o[t-1].route.animate){i=o[t-1].route.animate;break}if(e&&n&&i){const t=f(i)&&i.leave||"leaving",o=f(i)&&i.enter||"entering";r.push(W(e,t)),r.push(W(n,o))}return Promise.all(r).then(()=>t)}subscribe(){window.addEventListener("vaadin-router-go",this.l)}unsubscribe(){window.removeEventListener("vaadin-router-go",this.l)}h(t){const e=t?t.detail.pathname:window.location.pathname;this.render(e,!0)}static setTriggers(...t){H(t)}static go(t){a("go",{pathname:t})}}const Y=/\/\*\*\s+vaadin-dev-mode:start([\s\S]*)vaadin-dev-mode:end\s+\*\*\//i;function Z(t,e){if("function"!=typeof t)return;const n=Y.exec(t.toString());if(n)try{t=new Function(n[1])}catch(t){console.log("vaadin-development-mode-detector: uncommentAndRun() failed",t)}return t(e)}window.Vaadin=window.Vaadin||{};function tt(){}void 0===window.Vaadin.developmentMode&&(window.Vaadin.developmentMode=function(){try{return localStorage.getItem("vaadin.developmentmode.force")||["localhost","127.0.0.1"].indexOf(window.location.hostname)>=0&&!Z(function(){return!0})&&!function(){if(window.Vaadin&&window.Vaadin.Flow&&window.Vaadin.Flow.clients){const t=Object.keys(window.Vaadin.Flow.clients).map(t=>window.Vaadin.Flow.clients[t]).filter(t=>t.productionMode);if(t.length>0)return!0}return!1}()}catch(t){return!1}}());const et=(()=>(class extends HTMLElement{static get is(){return"vaadin-router-meta"}static get version(){return"1.0.0-rc.1"}}))();customElements.define(et.is,et),function(t,e){if(window.Vaadin.developmentMode)Z(t,e)}(tt),X.NavigationTrigger={POPSTATE:v,CLICK:w};export{X as Router,D as Resolver};

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.Vaadin=e.Vaadin||{})}(this,function(e){"use strict";var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},i=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},a=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)};function u(e){return e=e||[],Array.isArray(e)?e:[e]}function c(e){return"[Vaadin.Router] "+e}var l="module",s="nomodule",f=[l,s];function h(e){if(!e.match(/.+\.[m]?js$/))throw new Error(c('Unsupported type for bundle "'+e+'": .js or .mjs expected.'))}function p(e){if(!e||!y(e.path))throw new Error(c('Expected route config to be an object with a "path" string property, or an array of such objects'));var t=e.bundle,n=["component","redirect","bundle"];if(!(g(e.action)||Array.isArray(e.children)||g(e.children)||m(t)||n.some(function(t){return y(e[t])})))throw new Error(c('Expected route config "'+e.path+'" to include either "'+n.join('", "')+'" or "action" function but none found.'));if(t)if(y(t))h(t);else{if(!f.some(function(e){return e in t}))throw new Error(c('Expected route bundle to include either "'+s+'" or "'+l+'" keys, or both'));f.forEach(function(e){return e in t&&h(t[e])})}e.redirect&&["bundle","component"].forEach(function(t){t in e&&console.warn(c('Route config "'+e.path+'" has both "redirect" and "'+t+'" properties, and "redirect" will always override the latter. Did you mean to only use "'+t+'"?'))})}function d(e){u(e).forEach(function(e){return p(e)})}function v(e,t){var n=document.head.querySelector('script[src="'+e+'"][async]');return n||((n=document.createElement("script")).setAttribute("src",e),t===l?n.setAttribute("type",l):t===s&&n.setAttribute(s,""),n.async=!0),new Promise(function(e,t){n.onreadystatechange=n.onload=function(t){n.__dynamicImportLoaded=!0,e(t)},n.onerror=function(e){n.parentNode&&n.parentNode.removeChild(n),t(e)},null===n.parentNode?document.head.appendChild(n):n.__dynamicImportLoaded&&e()})}function _(e,t){window.dispatchEvent(new CustomEvent("vaadin-router-"+e,{detail:t}))}function m(e){return"object"===(void 0===e?"undefined":t(e))&&!!e}function g(e){return"function"==typeof e}function y(e){return"string"==typeof e}function b(e){var t=new Error(c("Page not found ("+e.pathname+")"));return t.context=e,t.code=404,t}function w(e){if(!e.defaultPrevented&&0===e.button&&!(e.shiftKey||e.ctrlKey||e.altKey||e.metaKey)){for(var t=e.target,n=e.composedPath?e.composedPath():e.path||[],r=0;r<n.length;r++){var o=n[r];if(o.nodeName&&"a"===o.nodeName.toLowerCase()){t=o;break}}for(;t&&"a"!==t.nodeName.toLowerCase();)t=t.parentNode;if(t&&"a"===t.nodeName.toLowerCase())if(!t.target||"_self"===t.target.toLowerCase())if(!t.hasAttribute("download"))if(t.pathname!==window.location.pathname||""===t.hash)(t.origin||function(e){var t=e.port,n=e.protocol;return n+"//"+("http:"===n&&"80"===t||"https:"===n&&"443"===t?e.hostname:e.host)}(t))===window.location.origin&&(e.preventDefault(),_("go",{pathname:t.pathname}))}}var E={activate:function(){window.document.addEventListener("click",w)},inactivate:function(){window.document.removeEventListener("click",w)}};function C(e){"vaadin-router-ignore"!==e.state&&_("go",{pathname:window.location.pathname})}/Trident/.test(navigator.userAgent)&&!g(window.PopStateEvent)&&(window.PopStateEvent=function(e,t){t=t||{};var n=document.createEvent("Event");return n.initEvent(e,Boolean(t.bubbles),Boolean(t.cancelable)),n.state=t.state||null,n},window.PopStateEvent.prototype=window.Event.prototype);var x={activate:function(){window.addEventListener("popstate",C)},inactivate:function(){window.removeEventListener("popstate",C)}},k=D,O=I,R=function(e,t){return S(I(e,t))},A=S,j=$,P="/",L="./",T=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");function I(e,t){for(var n,r=[],o=0,i=0,a="",u=t&&t.delimiter||P,c=t&&t.delimiters||L,l=!1;null!==(n=T.exec(e));){var s=n[0],f=n[1],h=n.index;if(a+=e.slice(i,h),i=h+s.length,f)a+=f[1],l=!0;else{var p="",d=e[i],v=n[2],_=n[3],m=n[4],g=n[5];if(!l&&a.length){var y=a.length-1;c.indexOf(a[y])>-1&&(p=a[y],a=a.slice(0,y))}a&&(r.push(a),a="",l=!1);var b=""!==p&&void 0!==d&&d!==p,w="+"===g||"*"===g,E="?"===g||"*"===g,C=p||u,x=_||m;r.push({name:v||o++,prefix:p,delimiter:C,optional:E,repeat:w,partial:b,pattern:x?B(x):"[^"+N(C)+"]+?"})}}return(a||i<e.length)&&r.push(a+e.substr(i)),r}function S(e){for(var n=new Array(e.length),r=0;r<e.length;r++)"object"===t(e[r])&&(n[r]=new RegExp("^(?:"+e[r].pattern+")$"));return function(t,r){for(var o="",i=r&&r.encode||encodeURIComponent,a=0;a<e.length;a++){var u=e[a];if("string"!=typeof u){var c,l=t?t[u.name]:void 0;if(Array.isArray(l)){if(!u.repeat)throw new TypeError('Expected "'+u.name+'" to not repeat, but got array');if(0===l.length){if(u.optional)continue;throw new TypeError('Expected "'+u.name+'" to not be empty')}for(var s=0;s<l.length;s++){if(c=i(l[s],u),!n[a].test(c))throw new TypeError('Expected all "'+u.name+'" to match "'+u.pattern+'"');o+=(0===s?u.prefix:u.delimiter)+c}}else if("string"!=typeof l&&"number"!=typeof l&&"boolean"!=typeof l){if(!u.optional)throw new TypeError('Expected "'+u.name+'" to be '+(u.repeat?"an array":"a string"));u.partial&&(o+=u.prefix)}else{if(c=i(String(l),u),!n[a].test(c))throw new TypeError('Expected "'+u.name+'" to match "'+u.pattern+'", but got "'+c+'"');o+=u.prefix+c}}else o+=u}return o}}function N(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function B(e){return e.replace(/([=!:$/()])/g,"\\$1")}function H(e){return e&&e.sensitive?"":"i"}function $(e,t,n){for(var r=(n=n||{}).strict,o=!1!==n.end,i=N(n.delimiter||P),a=n.delimiters||L,u=[].concat(n.endsWith||[]).map(N).concat("$").join("|"),c="",l=!1,s=0;s<e.length;s++){var f=e[s];if("string"==typeof f)c+=N(f),l=s===e.length-1&&a.indexOf(f[f.length-1])>-1;else{var h=N(f.prefix),p=f.repeat?"(?:"+f.pattern+")(?:"+h+"(?:"+f.pattern+"))*":f.pattern;t&&t.push(f),f.optional?f.partial?c+=h+"("+p+")?":c+="(?:"+h+"("+p+"))?":c+=h+"("+p+")"}}return o?(r||(c+="(?:"+i+")?"),c+="$"===u?"$":"(?="+u+")"):(r||(c+="(?:"+i+"(?="+u+"))?"),l||(c+="(?="+i+"|"+u+")")),new RegExp("^"+c,H(n))}function D(e,t,n){return e instanceof RegExp?function(e,t){if(!t)return e;var n=e.source.match(/\((?!\?)/g);if(n)for(var r=0;r<n.length;r++)t.push({name:r,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,pattern:null});return e}(e,t):Array.isArray(e)?function(e,t,n){for(var r=[],o=0;o<e.length;o++)r.push(D(e[o],t,n).source);return new RegExp("(?:"+r.join("|")+")",H(n))}(e,t,n):function(e,t,n){return $(I(e,n),t,n)}(e,t,n)}k.parse=O,k.compile=R,k.tokensToFunction=A,k.tokensToRegExp=j;var M=Object.prototype.hasOwnProperty,F=new Map;function U(e){try{return decodeURIComponent(e)}catch(t){return e}}function W(e,t,n,r,o){var i=void 0,a=void 0,u=0,c=e.path||"";return"/"===c.charAt(0)&&(n&&(c=c.substr(1)),n=!0),{next:function(l){if(e===l)return{done:!0};var s=e.__children=e.__children||e.children;if(!i&&(i=function(e,t,n,r,o){var i=e+"|"+(n=!!n),a=F.get(i);if(!a){var u=[];a={keys:u,pattern:k(e,u,{end:n,strict:""===e})},F.set(i,a)}var c=a.pattern.exec(t);if(!c)return null;for(var l=Object.assign({},o),s=1;s<c.length;s++){var f=a.keys[s-1],h=f.name,p=c[s];void 0===p&&M.call(l,h)||(f.repeat?l[h]=p?p.split(f.delimiter).map(U):[]:l[h]=p?U(p):p)}return{path:c[0],keys:(r||[]).concat(a.keys),params:l}}(c,t,!s,r,o)))return{done:!1,value:{route:e,keys:i.keys,params:i.params,path:i.path}};if(i&&s)for(;u<s.length;){if(!a){var f=s[u];f.parent=e;var h=i.path.length;h>0&&"/"===t.charAt(h)&&(h+=1),a=W(f,t.substr(h),n,i.keys,i.params)}var p=a.next(l);if(!p.done)return{done:!1,value:p.value};a=null,u++}return{done:!0}}}}function K(e){if(g(e.route.action))return e.route.action(e)}F.set("|false",{keys:[],pattern:/(?:)/});var V=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(n(this,e),Object(t)!==t)throw new TypeError("Invalid routes");this.baseUrl=r.baseUrl||"",this.errorHandler=r.errorHandler,this.resolveRoute=r.resolveRoute||K,this.context=Object.assign({resolver:this},r.context),this.root=Array.isArray(t)?{path:"",__children:t,parent:null,__synthetic:!0}:t,this.root.parent=null}return r(e,[{key:"getRoutes",value:function(){return[].concat(a(this.root.__children))}},{key:"setRoutes",value:function(e){d(e);var t=[].concat(a(u(e)));this.root.__children=t}},{key:"addRoutes",value:function(e){var t;return d(e),(t=this.root.__children).push.apply(t,a(u(e))),this.getRoutes()}},{key:"removeRoutes",value:function(){this.setRoutes([])}},{key:"resolve",value:function(e){var t=this,n=Object.assign({},this.context,y(e)?{pathname:e}:e),r=W(this.root,n.pathname.substr(this.baseUrl.length)),o=this.resolveRoute,i=null,a=null,u=n;function c(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.value.route,l=null===arguments[2]&&i.value.route;return i=a||r.next(l),a=null,e||!i.done&&function(e,t){for(var n=t;n;)if((n=n.parent)===e)return!0;return!1}(t,i.value.route)?i.done?Promise.reject(b(n)):(function(e,t){var n=t.route,r=t.path;if(n&&!n.__synthetic){var o={path:r,route:n};!function(e,t){return!t.parent||!e||!e.length||e[e.length-1].route!==t.parent}(e.chain,n)?e.chain.push(o):e.chain=[o]}}(n,i.value),u=Object.assign({},n,i.value),Promise.resolve(o(u)).then(function(n){return null!==n&&void 0!==n?(u.result=n.result||n,u):c(e,t,n)})):(a=i,Promise.resolve(null))}return n.next=c,Promise.resolve().then(function(){return c(!0,t.root)}).catch(function(e){var n=function(e){var t="Path '"+e.pathname+"' is not properly resolved due to an error.",n=(e.route||{}).path;return n&&(t+=" Resolution had failed on route: '"+n+"'"),t}(u);if(e?console.warn(n):e=new Error(n),e.context=e.context||u,e instanceof DOMException||(e.code=e.code||500),t.errorHandler)return u.result=t.errorHandler(e),u;throw e})}}]),e}();V.pathToRegexp=k;var q=[];function z(e){q.forEach(function(e){return e.inactivate()}),e.forEach(function(e){return e.activate()}),q=e}var G=function(e){var t=getComputedStyle(e).getPropertyValue("animation-name");return t&&"none"!==t},J=function(e,t){e.addEventListener("animationend",function n(){e.removeEventListener("animationend",n),t()})};function Q(e,t){return e.classList.add(t),new Promise(function(n){if(G(e)){var r=e.getBoundingClientRect(),o="height: "+(r.bottom-r.top)+"px; width: "+(r.right-r.left)+"px";e.setAttribute("style","position: absolute; "+o),J(e,function(){e.classList.remove(t),e.removeAttribute("style"),n()})}else e.classList.remove(t),n()})}function X(e){return null!==e&&void 0!==e}function Y(e,t){var n=e.pathname,r=void 0===n?"":n,o=e.chain,i=void 0===o?[]:o,a=e.params,u=void 0===a?{}:a,c=e.redirectFrom;return{pathname:r,routes:i.map(function(e){return e.route}),route:!t&&i.length&&i[i.length-1].route||t,params:u,redirectFrom:c}}function Z(e,t){var n=Object.assign({},e.params);return{redirect:{pathname:t,from:e.pathname,params:n}}}function ee(e,t,n){if(g(e))return e.apply(n,t)}function te(e,t,n){return function(r){return r&&(r.cancel||r.redirect)?r:n?ee(n[e],t,n):void 0}}function ne(e){if(e&&e.length)for(var t=e[0].parentNode,n=0;n<e.length;n++)t.removeChild(e[n])}var re=function(e){function t(e,r){n(this,t);var o=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,[],Object.assign({},r)));o.resolveRoute=function(e){return o.__resolveRoute(e)};var a=t.NavigationTrigger;return t.setTriggers.apply(t,Object.keys(a).map(function(e){return a[e]})),o.ready,o.ready=Promise.resolve(e),o.location,o.location=Y({}),o.__lastStartedRenderId=0,o.__navigationEventHandler=o.__onNavigationEvent.bind(o),o.setOutlet(e),o.subscribe(),o}return o(t,V),r(t,[{key:"__resolveRoute",value:function(e){var t=e.route,n={redirect:function(t){return Z(e,t)},component:function(t){return function(e,t){var n=document.createElement(t);n.location=Y(e);var r=e.chain.map(function(e){return e.route}).indexOf(e.route);return e.chain[r].element=n,n}(e,t)}},r=ee(t.action,[e,n],t);if(X(r))return r;if(y(t.redirect))return n.redirect(t.redirect);var o=Promise.resolve();return t.bundle&&(o=o.then(function(){return y(e=t.bundle)?v(e):Promise.race(f.filter(function(t){return t in e}).map(function(t){return v(e[t],t)}));var e}).catch(function(){throw new Error(c("Bundle not found: "+t.bundle+". Check if the file name is correct"))})),g(t.children)&&(o=o.then(function(){return t.children(function(e){var t=Object.assign({},e);return delete t.next,t}(e))}).then(function(e){X(e)||g(t.children)||(e=t.children),function(e,t){if(!Array.isArray(e)&&!m(e))throw new Error(c('Incorrect "children" value for the route '+t.path+": expected array or object, but got "+e));t.__children=[];for(var n=u(e),r=0;r<n.length;r++)p(n[r]),t.__children.push(n[r])}(e,t)})),o.then(function(){if(y(t.component))return n.component(t.component)})}},{key:"setOutlet",value:function(e){e&&this.__ensureOutlet(e),this.__outlet=e}},{key:"getOutlet",value:function(){return this.__outlet}},{key:"setRoutes",value:function(e){(function e(t,n,r){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,n);if(void 0===o){var i=Object.getPrototypeOf(t);return null===i?void 0:e(i,n,r)}if("value"in o)return o.value;var a=o.get;return void 0!==a?a.call(r):void 0})(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setRoutes",this).call(this,e),this.__onNavigationEvent()}},{key:"render",value:function(e,t){var n=this,r=++this.__lastStartedRenderId,o=e.pathname||e;return this.ready=this.resolve(e).then(function(e){return n.__fullyResolveChain(e)}).then(function(e){if(r===n.__lastStartedRenderId){var o=n.__previousContext;if(e===o)return n.location;t&&n.__updateBrowserHistory(e.pathname,e.redirectFrom),n.__addAppearingContent(e,o);var i=n.__animateIfNeeded(e);return n.__runOnAfterEnterCallbacks(e),n.__runOnAfterLeaveCallbacks(e,o),i.then(function(){if(r===n.__lastStartedRenderId)return n.__removeDisappearingContent(),n.__previousContext=e,n.location=Y(e),_("location-changed",{router:n,location:n.location}),n.location})}}).catch(function(e){if(r===n.__lastStartedRenderId)throw t&&n.__updateBrowserHistory(o),ne(n.__outlet&&n.__outlet.children),n.location=Y({pathname:o}),_("error",{router:n,error:e,pathname:o}),e}),this.ready}},{key:"__fullyResolveChain",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return this.__amendWithResolutionResult(n).then(function(r){var o=r!==n?r:e;return r.next().then(function(e){if(null===e&&r.pathname!==r.chain.map(function(e){return e.path}).reduce(function(e,t){return t.length?"/"===e?e+t:e+"/"+t:e}))throw b(o);return e?t.__fullyResolveChain(o,e):t.__amendWithOnBeforeCallbacks(o)})})}},{key:"__amendWithResolutionResult",value:function(e){var t=this,n=e.result;return n instanceof HTMLElement?Promise.resolve(e):n.redirect?this.__redirect(n.redirect,e.__redirectCount).then(function(e){return t.__amendWithResolutionResult(e)}):n instanceof Error?Promise.reject(n):Promise.reject(new Error(c('Invalid route resolution result for path "'+e.pathname+'". Expected redirect object or HTML element, but got: "'+n+'". Double check the action return value for the route.')))}},{key:"__amendWithOnBeforeCallbacks",value:function(e){var t=this;return this.__runOnBeforeCallbacks(e).then(function(n){return n===t.__previousContext||n===e?n:t.__fullyResolveChain(n)})}},{key:"__runOnBeforeCallbacks",value:function(e){var t=this,n=(this.__previousContext||{}).chain||[],r=e.chain,o=Promise.resolve(),i=function(){return{cancel:!0}},a=function(t){return Z(e,t)};if(e.__divergedChainIndex=0,n.length){for(var u=0;u<Math.min(n.length,r.length)&&(n[u].route===r[u].route&&n[u].path===r[u].path);u=++e.__divergedChainIndex);for(var c=n.length-1;c>=e.__divergedChainIndex;c--){var l=Y(e);o=o.then(te("onBeforeLeave",[l,{prevent:i},this],n[c].element)).then(function(e){if(!(e||{}).redirect)return e})}}for(var s=e.__divergedChainIndex;s<r.length;s++){var f=Y(e,r[s].route);o=o.then(te("onBeforeEnter",[f,{prevent:i,redirect:a},this],r[s].element))}return o.then(function(n){if(n){if(n.cancel)return t.__previousContext;if(n.redirect)return t.__redirect(n.redirect,e.__redirectCount)}return e})}},{key:"__redirect",value:function(e,n){if(n>256)throw new Error(c("Too many redirects when rendering "+e.from));return this.resolve({pathname:t.pathToRegexp.compile(e.pathname)(e.params),redirectFrom:e.from,__redirectCount:(n||0)+1})}},{key:"__ensureOutlet",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.__outlet;if(!(e instanceof Node))throw new TypeError(c("Expected router outlet to be a valid DOM Node (but got "+e+")"))}},{key:"__updateBrowserHistory",value:function(e,t){if(window.location.pathname!==e){var n=t?"replaceState":"pushState";window.history[n](null,document.title,e),window.dispatchEvent(new PopStateEvent("popstate",{state:"vaadin-router-ignore"}))}}},{key:"__addAppearingContent",value:function(e,t){this.__ensureOutlet(),this.__removeAppearingContent();for(var n=this.__outlet,r=0;r<e.__divergedChainIndex;r++){var o=t&&t.chain[r].element;if(o){if(o.parentNode!==n)break;e.chain[r].element=o,n=o}}this.__disappearingContent=Array.from(n.children),this.__appearingContent=[];for(var i=n,a=e.__divergedChainIndex;a<e.chain.length;a++){var u=e.chain[a].element;u&&(i.appendChild(u),i===n&&this.__appearingContent.push(u),i=u)}}},{key:"__removeDisappearingContent",value:function(){this.__disappearingContent&&ne(this.__disappearingContent),this.__disappearingContent=null,this.__appearingContent=null}},{key:"__removeAppearingContent",value:function(){this.__disappearingContent&&this.__appearingContent&&(ne(this.__appearingContent),this.__disappearingContent=null,this.__appearingContent=null)}},{key:"__runOnAfterLeaveCallbacks",value:function(e,t){if(t)for(var n=t.chain.length-1;n>=e.__divergedChainIndex;n--){var r=t.chain[n].element;if(r)try{var o=Y(e);ee(r.onAfterLeave,[o,{},t.resolver],r)}finally{ne(r.children)}}}},{key:"__runOnAfterEnterCallbacks",value:function(e){for(var t=e.__divergedChainIndex;t<e.chain.length;t++){var n=e.chain[t].element||{},r=Y(e,e.chain[t].route);ee(n.onAfterEnter,[r,{},e.resolver],n)}}},{key:"__animateIfNeeded",value:function(e){for(var t=(this.__disappearingContent||[])[0],n=(this.__appearingContent||[])[0],r=[],o=e.chain,i=void 0,a=o.length;a>0;a--)if(o[a-1].route.animate){i=o[a-1].route.animate;break}if(t&&n&&i){var u=m(i)&&i.leave||"leaving",c=m(i)&&i.enter||"entering";r.push(Q(t,u)),r.push(Q(n,c))}return Promise.all(r).then(function(){return e})}},{key:"subscribe",value:function(){window.addEventListener("vaadin-router-go",this.__navigationEventHandler)}},{key:"unsubscribe",value:function(){window.removeEventListener("vaadin-router-go",this.__navigationEventHandler)}},{key:"__onNavigationEvent",value:function(e){var t=e?e.detail.pathname:window.location.pathname;this.render(t,!0)}}],[{key:"setTriggers",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];z(t)}},{key:"go",value:function(e){_("go",{pathname:e})}}]),t}(),oe=function(e){function t(){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),r(t,null,[{key:"is",get:function(){return"vaadin-router-meta"}},{key:"version",get:function(){return"0.3.0"}}]),t}(HTMLElement);customElements.define(oe.is,oe),re.NavigationTrigger={POPSTATE:x,CLICK:E},e.Router=re,e.Resolver=V,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.Vaadin=e.Vaadin||{})}(this,function(e){"use strict";var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},i=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},a=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)};function u(e){return e=e||[],Array.isArray(e)?e:[e]}function c(e){return"[Vaadin.Router] "+e}var l="module",s="nomodule",f=[l,s];function d(e){if(!e.match(/.+\.[m]?js$/))throw new Error(c('Unsupported type for bundle "'+e+'": .js or .mjs expected.'))}function h(e){if(!e||!y(e.path))throw new Error(c('Expected route config to be an object with a "path" string property, or an array of such objects'));var t=e.bundle,n=["component","redirect","bundle"];if(!(g(e.action)||Array.isArray(e.children)||g(e.children)||m(t)||n.some(function(t){return y(e[t])})))throw new Error(c('Expected route config "'+e.path+'" to include either "'+n.join('", "')+'" or "action" function but none found.'));if(t)if(y(t))d(t);else{if(!f.some(function(e){return e in t}))throw new Error(c('Expected route bundle to include either "'+s+'" or "'+l+'" keys, or both'));f.forEach(function(e){return e in t&&d(t[e])})}e.redirect&&["bundle","component"].forEach(function(t){t in e&&console.warn(c('Route config "'+e.path+'" has both "redirect" and "'+t+'" properties, and "redirect" will always override the latter. Did you mean to only use "'+t+'"?'))})}function p(e){u(e).forEach(function(e){return h(e)})}function v(e,t){var n=document.head.querySelector('script[src="'+e+'"][async]');return n||((n=document.createElement("script")).setAttribute("src",e),t===l?n.setAttribute("type",l):t===s&&n.setAttribute(s,""),n.async=!0),new Promise(function(e,t){n.onreadystatechange=n.onload=function(t){n.__dynamicImportLoaded=!0,e(t)},n.onerror=function(e){n.parentNode&&n.parentNode.removeChild(n),t(e)},null===n.parentNode?document.head.appendChild(n):n.__dynamicImportLoaded&&e()})}function _(e,t){window.dispatchEvent(new CustomEvent("vaadin-router-"+e,{detail:t}))}function m(e){return"object"===(void 0===e?"undefined":t(e))&&!!e}function g(e){return"function"==typeof e}function y(e){return"string"==typeof e}function w(e){var t=new Error(c("Page not found ("+e.pathname+")"));return t.context=e,t.code=404,t}function b(e){if(!e.defaultPrevented&&0===e.button&&!(e.shiftKey||e.ctrlKey||e.altKey||e.metaKey)){for(var t=e.target,n=e.composedPath?e.composedPath():e.path||[],r=0;r<n.length;r++){var o=n[r];if(o.nodeName&&"a"===o.nodeName.toLowerCase()){t=o;break}}for(;t&&"a"!==t.nodeName.toLowerCase();)t=t.parentNode;if(t&&"a"===t.nodeName.toLowerCase())if(!t.target||"_self"===t.target.toLowerCase())if(!t.hasAttribute("download"))if(t.pathname!==window.location.pathname||""===t.hash)(t.origin||function(e){var t=e.port,n=e.protocol;return n+"//"+("http:"===n&&"80"===t||"https:"===n&&"443"===t?e.hostname:e.host)}(t))===window.location.origin&&(e.preventDefault(),_("go",{pathname:t.pathname}))}}var E={activate:function(){window.document.addEventListener("click",b)},inactivate:function(){window.document.removeEventListener("click",b)}};function x(e){"vaadin-router-ignore"!==e.state&&_("go",{pathname:window.location.pathname})}/Trident/.test(navigator.userAgent)&&!g(window.PopStateEvent)&&(window.PopStateEvent=function(e,t){t=t||{};var n=document.createEvent("Event");return n.initEvent(e,Boolean(t.bubbles),Boolean(t.cancelable)),n.state=t.state||null,n},window.PopStateEvent.prototype=window.Event.prototype);var C={activate:function(){window.addEventListener("popstate",x)},inactivate:function(){window.removeEventListener("popstate",x)}},k=M,O=S,R=function(e,t){return T(S(e,t))},A=T,j=H,P="/",L="./",I=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");function S(e,t){for(var n,r=[],o=0,i=0,a="",u=t&&t.delimiter||P,c=t&&t.delimiters||L,l=!1;null!==(n=I.exec(e));){var s=n[0],f=n[1],d=n.index;if(a+=e.slice(i,d),i=d+s.length,f)a+=f[1],l=!0;else{var h="",p=e[i],v=n[2],_=n[3],m=n[4],g=n[5];if(!l&&a.length){var y=a.length-1;c.indexOf(a[y])>-1&&(h=a[y],a=a.slice(0,y))}a&&(r.push(a),a="",l=!1);var w=""!==h&&void 0!==p&&p!==h,b="+"===g||"*"===g,E="?"===g||"*"===g,x=h||u,C=_||m;r.push({name:v||o++,prefix:h,delimiter:x,optional:E,repeat:b,partial:w,pattern:C?V(C):"[^"+N(x)+"]+?"})}}return(a||i<e.length)&&r.push(a+e.substr(i)),r}function T(e){for(var n=new Array(e.length),r=0;r<e.length;r++)"object"===t(e[r])&&(n[r]=new RegExp("^(?:"+e[r].pattern+")$"));return function(t,r){for(var o="",i=r&&r.encode||encodeURIComponent,a=0;a<e.length;a++){var u=e[a];if("string"!=typeof u){var c,l=t?t[u.name]:void 0;if(Array.isArray(l)){if(!u.repeat)throw new TypeError('Expected "'+u.name+'" to not repeat, but got array');if(0===l.length){if(u.optional)continue;throw new TypeError('Expected "'+u.name+'" to not be empty')}for(var s=0;s<l.length;s++){if(c=i(l[s],u),!n[a].test(c))throw new TypeError('Expected all "'+u.name+'" to match "'+u.pattern+'"');o+=(0===s?u.prefix:u.delimiter)+c}}else if("string"!=typeof l&&"number"!=typeof l&&"boolean"!=typeof l){if(!u.optional)throw new TypeError('Expected "'+u.name+'" to be '+(u.repeat?"an array":"a string"));u.partial&&(o+=u.prefix)}else{if(c=i(String(l),u),!n[a].test(c))throw new TypeError('Expected "'+u.name+'" to match "'+u.pattern+'", but got "'+c+'"');o+=u.prefix+c}}else o+=u}return o}}function N(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function V(e){return e.replace(/([=!:$/()])/g,"\\$1")}function B(e){return e&&e.sensitive?"":"i"}function H(e,t,n){for(var r=(n=n||{}).strict,o=!1!==n.end,i=N(n.delimiter||P),a=n.delimiters||L,u=[].concat(n.endsWith||[]).map(N).concat("$").join("|"),c="",l=0===e.length,s=0;s<e.length;s++){var f=e[s];if("string"==typeof f)c+=N(f),l=s===e.length-1&&a.indexOf(f[f.length-1])>-1;else{var d=N(f.prefix),h=f.repeat?"(?:"+f.pattern+")(?:"+d+"(?:"+f.pattern+"))*":f.pattern;t&&t.push(f),f.optional?f.partial?c+=d+"("+h+")?":c+="(?:"+d+"("+h+"))?":c+=d+"("+h+")"}}return o?(r||(c+="(?:"+i+")?"),c+="$"===u?"$":"(?="+u+")"):(r||(c+="(?:"+i+"(?="+u+"))?"),l||(c+="(?="+i+"|"+u+")")),new RegExp("^"+c,B(n))}function M(e,t,n){return e instanceof RegExp?function(e,t){if(!t)return e;var n=e.source.match(/\((?!\?)/g);if(n)for(var r=0;r<n.length;r++)t.push({name:r,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,pattern:null});return e}(e,t):Array.isArray(e)?function(e,t,n){for(var r=[],o=0;o<e.length;o++)r.push(M(e[o],t,n).source);return new RegExp("(?:"+r.join("|")+")",B(n))}(e,t,n):function(e,t,n){return H(S(e,n),t,n)}(e,t,n)}k.parse=O,k.compile=R,k.tokensToFunction=A,k.tokensToRegExp=j;var F=Object.prototype.hasOwnProperty,$=new Map;function D(e){try{return decodeURIComponent(e)}catch(t){return e}}function U(e,t,n,r,o){var i=void 0,a=void 0,u=0,c=e.path||"";return"/"===c.charAt(0)&&(n&&(c=c.substr(1)),n=!0),{next:function(l){if(e===l)return{done:!0};var s=e.__children=e.__children||e.children;if(!i&&(i=function(e,t,n,r,o){var i=e+"|"+(n=!!n),a=$.get(i);if(!a){var u=[];a={keys:u,pattern:k(e,u,{end:n,strict:""===e})},$.set(i,a)}var c=a.pattern.exec(t);if(!c)return null;for(var l=Object.assign({},o),s=1;s<c.length;s++){var f=a.keys[s-1],d=f.name,h=c[s];void 0===h&&F.call(l,d)||(f.repeat?l[d]=h?h.split(f.delimiter).map(D):[]:l[d]=h?D(h):h)}return{path:c[0],keys:(r||[]).concat(a.keys),params:l}}(c,t,!s,r,o)))return{done:!1,value:{route:e,keys:i.keys,params:i.params,path:i.path}};if(i&&s)for(;u<s.length;){if(!a){var f=s[u];f.parent=e;var d=i.path.length;d>0&&"/"===t.charAt(d)&&(d+=1),a=U(f,t.substr(d),n,i.keys,i.params)}var h=a.next(l);if(!h.done)return{done:!1,value:h.value};a=null,u++}return{done:!0}}}}function W(e){if(g(e.route.action))return e.route.action(e)}$.set("|false",{keys:[],pattern:/(?:)/});var K=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(n(this,e),Object(t)!==t)throw new TypeError("Invalid routes");this.baseUrl=r.baseUrl||"",this.errorHandler=r.errorHandler,this.resolveRoute=r.resolveRoute||W,this.context=Object.assign({resolver:this},r.context),this.root=Array.isArray(t)?{path:"",__children:t,parent:null,__synthetic:!0}:t,this.root.parent=null}return r(e,[{key:"getRoutes",value:function(){return[].concat(a(this.root.__children))}},{key:"setRoutes",value:function(e){p(e);var t=[].concat(a(u(e)));this.root.__children=t}},{key:"addRoutes",value:function(e){var t;return p(e),(t=this.root.__children).push.apply(t,a(u(e))),this.getRoutes()}},{key:"removeRoutes",value:function(){this.setRoutes([])}},{key:"resolve",value:function(e){var t=this,n=Object.assign({},this.context,y(e)?{pathname:e}:e),r=U(this.root,n.pathname.substr(this.baseUrl.length)),o=this.resolveRoute,i=null,a=null,u=n;function c(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.value.route,l=null===arguments[2]&&i.value.route;return i=a||r.next(l),a=null,e||!i.done&&function(e,t){for(var n=t;n;)if((n=n.parent)===e)return!0;return!1}(t,i.value.route)?i.done?Promise.reject(w(n)):(function(e,t){var n=t.route,r=t.path;if(n&&!n.__synthetic){var o={path:r,route:n};!function(e,t){return!t.parent||!e||!e.length||e[e.length-1].route!==t.parent}(e.chain,n)?e.chain.push(o):e.chain=[o]}}(n,i.value),u=Object.assign({},n,i.value),Promise.resolve(o(u)).then(function(n){return null!==n&&void 0!==n?(u.result=n.result||n,u):c(e,t,n)})):(a=i,Promise.resolve(null))}return n.next=c,Promise.resolve().then(function(){return c(!0,t.root)}).catch(function(e){var n=function(e){var t="Path '"+e.pathname+"' is not properly resolved due to an error.",n=(e.route||{}).path;return n&&(t+=" Resolution had failed on route: '"+n+"'"),t}(u);if(e?console.warn(n):e=new Error(n),e.context=e.context||u,e instanceof DOMException||(e.code=e.code||500),t.errorHandler)return u.result=t.errorHandler(e),u;throw e})}}]),e}();K.pathToRegexp=k;var q=[];function z(e){q.forEach(function(e){return e.inactivate()}),e.forEach(function(e){return e.activate()}),q=e}var G=function(e){var t=getComputedStyle(e).getPropertyValue("animation-name");return t&&"none"!==t},J=function(e,t){e.addEventListener("animationend",function n(){e.removeEventListener("animationend",n),t()})};function Q(e,t){return e.classList.add(t),new Promise(function(n){if(G(e)){var r=e.getBoundingClientRect(),o="height: "+(r.bottom-r.top)+"px; width: "+(r.right-r.left)+"px";e.setAttribute("style","position: absolute; "+o),J(e,function(){e.classList.remove(t),e.removeAttribute("style"),n()})}else e.classList.remove(t),n()})}function X(e){return null!==e&&void 0!==e}function Y(e,t){var n=e.pathname,r=void 0===n?"":n,o=e.chain,i=void 0===o?[]:o,a=e.params,u=void 0===a?{}:a,c=e.redirectFrom;return{pathname:r,routes:i.map(function(e){return e.route}),route:!t&&i.length&&i[i.length-1].route||t,params:u,redirectFrom:c}}function Z(e,t){var n=Object.assign({},e.params);return{redirect:{pathname:t,from:e.pathname,params:n}}}function ee(e,t,n){if(g(e))return e.apply(n,t)}function te(e,t,n){return function(r){return r&&(r.cancel||r.redirect)?r:n?ee(n[e],t,n):void 0}}function ne(e){if(e&&e.length)for(var t=e[0].parentNode,n=0;n<e.length;n++)t.removeChild(e[n])}var re=function(e){function t(e,r){n(this,t);var o=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,[],Object.assign({},r)));o.resolveRoute=function(e){return o.__resolveRoute(e)};var a=t.NavigationTrigger;return t.setTriggers.apply(t,Object.keys(a).map(function(e){return a[e]})),o.ready,o.ready=Promise.resolve(e),o.location,o.location=Y({}),o.__lastStartedRenderId=0,o.__navigationEventHandler=o.__onNavigationEvent.bind(o),o.setOutlet(e),o.subscribe(),o}return o(t,K),r(t,[{key:"__resolveRoute",value:function(e){var t=e.route,n={redirect:function(t){return Z(e,t)},component:function(t){return function(e,t){var n=document.createElement(t);n.location=Y(e);var r=e.chain.map(function(e){return e.route}).indexOf(e.route);return e.chain[r].element=n,n}(e,t)}},r=ee(t.action,[e,n],t);if(X(r))return r;if(y(t.redirect))return n.redirect(t.redirect);var o=Promise.resolve();return t.bundle&&(o=o.then(function(){return y(e=t.bundle)?v(e):Promise.race(f.filter(function(t){return t in e}).map(function(t){return v(e[t],t)}));var e}).catch(function(){throw new Error(c("Bundle not found: "+t.bundle+". Check if the file name is correct"))})),g(t.children)&&(o=o.then(function(){return t.children(function(e){var t=Object.assign({},e);return delete t.next,t}(e))}).then(function(e){X(e)||g(t.children)||(e=t.children),function(e,t){if(!Array.isArray(e)&&!m(e))throw new Error(c('Incorrect "children" value for the route '+t.path+": expected array or object, but got "+e));t.__children=[];for(var n=u(e),r=0;r<n.length;r++)h(n[r]),t.__children.push(n[r])}(e,t)})),o.then(function(){if(y(t.component))return n.component(t.component)})}},{key:"setOutlet",value:function(e){e&&this.__ensureOutlet(e),this.__outlet=e}},{key:"getOutlet",value:function(){return this.__outlet}},{key:"setRoutes",value:function(e){(function e(t,n,r){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,n);if(void 0===o){var i=Object.getPrototypeOf(t);return null===i?void 0:e(i,n,r)}if("value"in o)return o.value;var a=o.get;return void 0!==a?a.call(r):void 0})(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setRoutes",this).call(this,e),this.__onNavigationEvent()}},{key:"render",value:function(e,t){var n=this,r=++this.__lastStartedRenderId,o=e.pathname||e;return this.ready=this.resolve(e).then(function(e){return n.__fullyResolveChain(e)}).then(function(e){if(r===n.__lastStartedRenderId){var o=n.__previousContext;if(e===o)return n.location;t&&n.__updateBrowserHistory(e.pathname,e.redirectFrom),n.__addAppearingContent(e,o);var i=n.__animateIfNeeded(e);return n.__runOnAfterEnterCallbacks(e),n.__runOnAfterLeaveCallbacks(e,o),i.then(function(){if(r===n.__lastStartedRenderId)return n.__removeDisappearingContent(),n.__previousContext=e,n.location=Y(e),_("location-changed",{router:n,location:n.location}),n.location})}}).catch(function(e){if(r===n.__lastStartedRenderId)throw t&&n.__updateBrowserHistory(o),ne(n.__outlet&&n.__outlet.children),n.location=Y({pathname:o}),_("error",{router:n,error:e,pathname:o}),e}),this.ready}},{key:"__fullyResolveChain",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return this.__amendWithResolutionResult(n).then(function(r){var o=r!==n?r:e;return r.next().then(function(e){if(null===e&&r.pathname!==r.chain.map(function(e){return e.path}).reduce(function(e,t){return t.length?e+("/"===e.charAt(e.length-1)?"":"/")+t:e}))throw w(o);return e?t.__fullyResolveChain(o,e):t.__amendWithOnBeforeCallbacks(o)})})}},{key:"__amendWithResolutionResult",value:function(e){var t=this,n=e.result;return n instanceof HTMLElement?Promise.resolve(e):n.redirect?this.__redirect(n.redirect,e.__redirectCount).then(function(e){return t.__amendWithResolutionResult(e)}):n instanceof Error?Promise.reject(n):Promise.reject(new Error(c('Invalid route resolution result for path "'+e.pathname+'". Expected redirect object or HTML element, but got: "'+n+'". Double check the action return value for the route.')))}},{key:"__amendWithOnBeforeCallbacks",value:function(e){var t=this;return this.__runOnBeforeCallbacks(e).then(function(n){return n===t.__previousContext||n===e?n:t.__fullyResolveChain(n)})}},{key:"__runOnBeforeCallbacks",value:function(e){var t=this,n=(this.__previousContext||{}).chain||[],r=e.chain,o=Promise.resolve(),i=function(){return{cancel:!0}},a=function(t){return Z(e,t)};if(e.__divergedChainIndex=0,n.length){for(var u=0;u<Math.min(n.length,r.length)&&(n[u].route===r[u].route&&n[u].path===r[u].path);u=++e.__divergedChainIndex);for(var c=n.length-1;c>=e.__divergedChainIndex;c--){var l=Y(e);o=o.then(te("onBeforeLeave",[l,{prevent:i},this],n[c].element)).then(function(e){if(!(e||{}).redirect)return e})}}for(var s=e.__divergedChainIndex;s<r.length;s++){var f=Y(e,r[s].route);o=o.then(te("onBeforeEnter",[f,{prevent:i,redirect:a},this],r[s].element))}return o.then(function(n){if(n){if(n.cancel)return t.__previousContext;if(n.redirect)return t.__redirect(n.redirect,e.__redirectCount)}return e})}},{key:"__redirect",value:function(e,n){if(n>256)throw new Error(c("Too many redirects when rendering "+e.from));return this.resolve({pathname:t.pathToRegexp.compile(e.pathname)(e.params),redirectFrom:e.from,__redirectCount:(n||0)+1})}},{key:"__ensureOutlet",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.__outlet;if(!(e instanceof Node))throw new TypeError(c("Expected router outlet to be a valid DOM Node (but got "+e+")"))}},{key:"__updateBrowserHistory",value:function(e,t){if(window.location.pathname!==e){var n=t?"replaceState":"pushState";window.history[n](null,document.title,e),window.dispatchEvent(new PopStateEvent("popstate",{state:"vaadin-router-ignore"}))}}},{key:"__addAppearingContent",value:function(e,t){this.__ensureOutlet(),this.__removeAppearingContent();for(var n=this.__outlet,r=0;r<e.__divergedChainIndex;r++){var o=t&&t.chain[r].element;if(o){if(o.parentNode!==n)break;e.chain[r].element=o,n=o}}this.__disappearingContent=Array.from(n.children),this.__appearingContent=[];for(var i=n,a=e.__divergedChainIndex;a<e.chain.length;a++){var u=e.chain[a].element;u&&(i.appendChild(u),i===n&&this.__appearingContent.push(u),i=u)}}},{key:"__removeDisappearingContent",value:function(){this.__disappearingContent&&ne(this.__disappearingContent),this.__disappearingContent=null,this.__appearingContent=null}},{key:"__removeAppearingContent",value:function(){this.__disappearingContent&&this.__appearingContent&&(ne(this.__appearingContent),this.__disappearingContent=null,this.__appearingContent=null)}},{key:"__runOnAfterLeaveCallbacks",value:function(e,t){if(t)for(var n=t.chain.length-1;n>=e.__divergedChainIndex;n--){var r=t.chain[n].element;if(r)try{var o=Y(e);ee(r.onAfterLeave,[o,{},t.resolver],r)}finally{ne(r.children)}}}},{key:"__runOnAfterEnterCallbacks",value:function(e){for(var t=e.__divergedChainIndex;t<e.chain.length;t++){var n=e.chain[t].element||{},r=Y(e,e.chain[t].route);ee(n.onAfterEnter,[r,{},e.resolver],n)}}},{key:"__animateIfNeeded",value:function(e){for(var t=(this.__disappearingContent||[])[0],n=(this.__appearingContent||[])[0],r=[],o=e.chain,i=void 0,a=o.length;a>0;a--)if(o[a-1].route.animate){i=o[a-1].route.animate;break}if(t&&n&&i){var u=m(i)&&i.leave||"leaving",c=m(i)&&i.enter||"entering";r.push(Q(t,u)),r.push(Q(n,c))}return Promise.all(r).then(function(){return e})}},{key:"subscribe",value:function(){window.addEventListener("vaadin-router-go",this.__navigationEventHandler)}},{key:"unsubscribe",value:function(){window.removeEventListener("vaadin-router-go",this.__navigationEventHandler)}},{key:"__onNavigationEvent",value:function(e){var t=e?e.detail.pathname:window.location.pathname;this.render(t,!0)}}],[{key:"setTriggers",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];z(t)}},{key:"go",value:function(e){_("go",{pathname:e})}}]),t}(),oe=/\/\*\*\s+vaadin-dev-mode:start([\s\S]*)vaadin-dev-mode:end\s+\*\*\//i;function ie(e,t){if("function"==typeof e){var n=oe.exec(e.toString());if(n)try{e=new Function(n[1])}catch(e){console.log("vaadin-development-mode-detector: uncommentAndRun() failed",e)}return e(t)}}window.Vaadin=window.Vaadin||{};function ae(){}void 0===window.Vaadin.developmentMode&&(window.Vaadin.developmentMode=function(){try{return localStorage.getItem("vaadin.developmentmode.force")||["localhost","127.0.0.1"].indexOf(window.location.hostname)>=0&&!ie(function(){return!0})&&!function(){if(window.Vaadin&&window.Vaadin.Flow&&window.Vaadin.Flow.clients){var e=Object.keys(window.Vaadin.Flow.clients).map(function(e){return window.Vaadin.Flow.clients[e]}).filter(function(e){return e.productionMode});if(e.length>0)return!0}return!1}()}catch(e){return!1}}());var ue=function(e){function t(){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),r(t,null,[{key:"is",get:function(){return"vaadin-router-meta"}},{key:"version",get:function(){return"1.0.0-rc.1"}}]),t}(HTMLElement);customElements.define(ue.is,ue),function(e,t){if(window.Vaadin.developmentMode)ie(e,t)}(ae),re.NavigationTrigger={POPSTATE:C,CLICK:E},e.Router=re,e.Resolver=K,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=vaadin-router.umd.min.js.map
{
"name": "@vaadin/router",
"version": "1.0.0-rc.0",
"version": "1.0.0-rc.1",
"description": "Small and powerful client-side router for Web Components. Framework-agnostic.",

@@ -62,3 +62,4 @@ "main": "dist/vaadin-router.js",

"dependencies": {
"path-to-regexp": "2.2.0"
"@vaadin/vaadin-usage-statistics": "^2.0.0-alpha4",
"path-to-regexp": "2.2.1"
},

@@ -65,0 +66,0 @@ "devDependencies": {

@@ -13,6 +13,7 @@ [![NPM version](https://img.shields.io/npm/v/@vaadin/router.svg)](https://www.npmjs.com/package/@vaadin/router)

<p align="center">
<img src="https://raw.github.com/vaadin/vaadin-router/master/screenshot.png" width="196" alt="under construction">
<img width="120" alt="router hero banner" src="https://user-images.githubusercontent.com/22416150/42952145-74cead64-8b80-11e8-9dfd-09b01f904972.png">
<h2 align="center">A client-side router for Web Components</h2>
</p>
Vaadin.Router is a small yet powerfull client-side router JS library. It uses the widely adopted express.js syntax for routes (`/users/:id`) to map URLs to Web Component views. All features one might expect from a modern router are supported: async route resolution, animated transitions, navigation guards, redirects, and more. It is framework-agnostic and works equally well with all Web Components regardless of how they are created (Polymer / SkateJS / Stencil / Angular / Vue / etc).
Vaadin.Router is a small and powerful client-side router JS library. It uses the widely adopted express.js syntax for routes (`/users/:id`) to map URLs to Web Component views. All features one might expect from a modern router are supported: async route resolution, animated transitions, navigation guards, redirects, and more. It is framework-agnostic and works equally well with all Web Components regardless of how they are created (Polymer / SkateJS / Stencil / Angular / Vue / etc).

@@ -38,5 +39,7 @@ Vaadin.Router is a good fit for developers that do not want to go all-in with one framework, and prefer to have freedom in picking the components that work best for their specific needs.

Testing environments for Vaadin.Router are provided by [SauceLabs](https://saucelabs.com).
### Big Thanks
Cross-browser Testing Platform and Open Source <3 Provided by [Sauce Labs](https://saucelabs.com).
## Running demos and tests in the browser

@@ -43,0 +46,0 @@

@@ -0,1 +1,3 @@

import {usageStatistics} from '@vaadin/vaadin-usage-statistics/vaadin-usage-statistics.js';
// NOTE(web-padawan): Have to use an awkward IIFE returning class here

@@ -10,3 +12,3 @@ // to prevent this class from showing up in analysis.json & API docs.

static get version() {
return '0.3.0';
return '1.0.0-rc.1';
}

@@ -16,1 +18,2 @@ })();

customElements.define(VaadinRouterMeta.is, VaadinRouterMeta);
usageStatistics();

@@ -104,3 +104,3 @@ import Resolver from './resolver/resolver.js';

if (path.length) {
return prev === '/' ? prev + path : prev + '/' + path;
return prev + (prev.charAt(prev.length - 1) === '/' ? '' : '/') + path;
}

@@ -107,0 +107,0 @@ return prev;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc