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

@vaadin/router

Package Overview
Dependencies
Maintainers
14
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.2.0-pre.2 to 1.2.0-pre.3

index.polyfilled.js

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}const w=new class{};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 m={activate(){window.document.addEventListener("click",p)},inactivate(){window.document.removeEventListener("click",p)}};function v(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 y={activate(){window.addEventListener("popstate",v)},inactivate(){window.removeEventListener("popstate",v)}};var b=S,g=P,E=function(t,e){return R(P(t,e))},$=R,_=T,x="/",O="./",j=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");function P(t,e){for(var n,r=[],o=0,i=0,s="",u=e&&e.delimiter||x,c=e&&e.delimiters||O,a=!1;null!==(n=j.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="",w=t[i],p=n[2],m=n[3],v=n[4],y=n[5];if(!a&&s.length){var b=s.length-1;c.indexOf(s[b])>-1&&(d=s[b],s=s.slice(0,b))}s&&(r.push(s),s="",a=!1);var g=""!==d&&void 0!==w&&w!==d,E="+"===y||"*"===y,$="?"===y||"*"===y,_=d||u,P=m||v;r.push({name:p||o++,prefix:d,delimiter:_,optional:$,repeat:E,partial:g,pattern:P?C(P):"[^"+k(_)+"]+?"})}}return(s||i<t.length)&&r.push(s+t.substr(i)),r}function R(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 k(t){return t.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function C(t){return t.replace(/([=!:$/()])/g,"\\$1")}function A(t){return t&&t.sensitive?"":"i"}function T(t,e,n){for(var r=(n=n||{}).strict,o=!1!==n.end,i=k(n.delimiter||x),s=n.delimiters||O,u=[].concat(n.endsWith||[]).map(k).concat("$").join("|"),c="",a=0===t.length,f=0;f<t.length;f++){var l=t[f];if("string"==typeof l)c+=k(l),a=f===t.length-1&&s.indexOf(l[l.length-1])>-1;else{var h=k(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,A(n))}function S(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(S(t[o],e,n).source);return new RegExp("(?:"+r.join("|")+")",A(n))}(t,e,n):function(t,e,n){return T(P(t,n),e,n)}(t,e,n)}b.parse=g,b.compile=E,b.tokensToFunction=$,b.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:b(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 D(t){if(l(t.route.action))return t.route.action(t)}I.set("|false",{keys:[],pattern:/(?:)/});class F{constructor(t,e={}){if(Object(t)!==t)throw new TypeError("Invalid routes");this.baseUrl=e.baseUrl||"",this.errorHandler=e.errorHandler,this.resolveRoute=e.resolveRoute||D,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&&e!==w?(s.result=e.result||e,s):u(t,c,e))):(i=o,Promise.resolve(w))}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})}}F.pathToRegexp=b;let N=[];function H(t){N.forEach(t=>t.inactivate()),t.forEach(t=>t.activate()),N=t}const U=t=>{const e=getComputedStyle(t).getPropertyValue("animation-name");return e&&"none"!==e},W=(t,e)=>{const n=()=>{t.removeEventListener("animationend",n),e()};t.addEventListener("animationend",n)};function J(t,e){return t.classList.add(e),new Promise(n=>{if(U(t)){const r=t.getBoundingClientRect(),o=`height: ${r.bottom-r.top}px; width: ${r.right-r.left}px`;t.setAttribute("style",`position: absolute; ${o}`),W(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 Q(t,e,n){return r=>r&&(r.cancel||r.redirect)?r:n?G(n[t],e,n):void 0}function X(t){if(t&&t.length){const e=t[0].parentNode;for(let n=0;n<t.length;n++)e.removeChild(t[n])}}class Y extends F{constructor(t,e){super([],Object.assign({},e)),this.resolveRoute=(t=>this.s(t));const n=Y.NavigationTrigger;Y.setTriggers.apply(Y,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;let i=Promise.resolve();l(r.children)&&(i=i.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)}));const u={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)};return i.then(()=>G(r.action,[n,u],r)).then(t=>V(t)&&(t instanceof HTMLElement||t.redirect||t===w)?t:h(r.redirect)?u.redirect(r.redirect):r.bundle?(a=r.bundle,h(a)?c(a):Promise.race(o.filter(t=>t in a).map(t=>c(a[t],t)))).then(()=>{},()=>{throw new Error(e(`Bundle not found: ${r.bundle}. Check if the file name is correct`))}):void 0).then(t=>V(t)?t:h(r.component)?u.component(r.component):void 0);var a}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),X(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||t===w)&&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&&t!==w?this.v(r,t):this.C(r)})})}k(t){const n=t.result;return n instanceof HTMLElement?Promise.resolve(t):n.redirect?this.A(n.redirect,t.T).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: "${function(t){if("object"!=typeof t)return String(t);const e=Object.prototype.toString.call(t).match(/ (.*)\]$/)[1];return"Object"===e||"Array"===e?`${e} ${JSON.stringify(t)}`:e}(n)}". `+"Double check the action return value for the route.")))}C(t){return this.S(t).then(e=>e===this.g||e===t?e:this.v(e))}S(t){const e=(this.g||{}).chain||[],n=t.chain;let r=Promise.resolve();const o=()=>({cancel:!0}),i=e=>z(t,e);if(t.B=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&&(e[r].element&&e[r].element.localName)===(n[r].element&&n[r].element.localName));r=++t.B);for(let n=e.length-1;n>=t.B;n--){const i=q(t);r=r.then(Q("onBeforeLeave",[i,{prevent:o},this],e[n].element)).then(t=>{if(!(t||{}).redirect)return t})}}for(let e=t.B;e<n.length;e++){const s=q(t,n[e].route);r=r.then(Q("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.A(e.redirect,t.T)}return t})}A(t,n){if(n>K)throw new Error(e(`Too many redirects when rendering ${t.from}`));return this.resolve({pathname:this.constructor.urlForPath(t.pathname,t.params),redirectFrom:t.from,T:(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.B;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.B;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&&X(this.M),this.M=null,this.L=null}I(){this.M&&this.L&&(X(this.L),this.M=null,this.L=null)}P(t,e){if(e)for(let n=e.chain.length-1;n>=t.B;n--){const r=e.chain[n].element;if(r)try{const n=q(t);G(r.onAfterLeave,[n,{},e.resolver],r)}finally{X(r.children)}}}j(t){for(let e=t.B;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(J(e,t)),r.push(J(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 urlForPath(t,e){return Y.pathToRegexp.compile(t)(e)}static go(t){a("go",{pathname:t})}}const Z=/\/\*\*\s+vaadin-dev-mode:start([\s\S]*)vaadin-dev-mode:end\s+\*\*\//i;function tt(t,e){if("function"!=typeof t)return;const n=Z.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||{};const et=function(t,e){if(window.Vaadin.developmentMode)return tt(t,e)};function nt(){}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&&!tt(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}}());window.Vaadin=window.Vaadin||{},window.Vaadin.registrations=window.Vaadin.registrations||[],window.Vaadin.registrations.push({is:"@vaadin/router",version:"1.2.0-pre.2"}),et(nt),Y.NavigationTrigger={POPSTATE:y,CLICK:m};export{Y as Router,F 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,c=["component","redirect","bundle"];if(!(l(t.action)||Array.isArray(t.children)||l(t.children)||f(s)||c.some(e=>h(t[e]))))throw new Error(e(`Expected route config "${t.path}" to include either "${c.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 c(e){t(e).forEach(t=>s(t))}function u(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){return!window.dispatchEvent(new CustomEvent(`vaadin-router-${t}`,{cancelable:"go"===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}const w=new class{};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&&a("go",{pathname:e.pathname})&&t.preventDefault())}const m={activate(){window.document.addEventListener("click",p)},inactivate(){window.document.removeEventListener("click",p)}};function v(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 y={activate(){window.addEventListener("popstate",v)},inactivate(){window.removeEventListener("popstate",v)}};var b=S,g=R,E=function(t,e){return P(R(t,e))},$=P,_=C,O="/",x="./",j=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");function R(t,e){for(var n,r=[],o=0,i=0,s="",c=e&&e.delimiter||O,u=e&&e.delimiters||x,a=!1;null!==(n=j.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="",w=t[i],p=n[2],m=n[3],v=n[4],y=n[5];if(!a&&s.length){var b=s.length-1;u.indexOf(s[b])>-1&&(d=s[b],s=s.slice(0,b))}s&&(r.push(s),s="",a=!1);var g=""!==d&&void 0!==w&&w!==d,E="+"===y||"*"===y,$="?"===y||"*"===y,_=d||c,R=m||v;r.push({name:p||o++,prefix:d,delimiter:_,optional:$,repeat:E,partial:g,pattern:R?k(R):"[^"+A(_)+"]+?"})}}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 c=t[s];if("string"!=typeof c){var u,a=n?n[c.name]:void 0;if(Array.isArray(a)){if(!c.repeat)throw new TypeError('Expected "'+c.name+'" to not repeat, but got array');if(0===a.length){if(c.optional)continue;throw new TypeError('Expected "'+c.name+'" to not be empty')}for(var f=0;f<a.length;f++){if(u=i(a[f],c),!e[s].test(u))throw new TypeError('Expected all "'+c.name+'" to match "'+c.pattern+'"');o+=(0===f?c.prefix:c.delimiter)+u}}else if("string"!=typeof a&&"number"!=typeof a&&"boolean"!=typeof a){if(!c.optional)throw new TypeError('Expected "'+c.name+'" to be '+(c.repeat?"an array":"a string"));c.partial&&(o+=c.prefix)}else{if(u=i(String(a),c),!e[s].test(u))throw new TypeError('Expected "'+c.name+'" to match "'+c.pattern+'", but got "'+u+'"');o+=c.prefix+u}}else o+=c}return o}}function A(t){return t.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function k(t){return t.replace(/([=!:$/()])/g,"\\$1")}function T(t){return t&&t.sensitive?"":"i"}function C(t,e,n){for(var r=(n=n||{}).strict,o=!1!==n.end,i=A(n.delimiter||O),s=n.delimiters||x,c=[].concat(n.endsWith||[]).map(A).concat("$").join("|"),u="",a=0===t.length,f=0;f<t.length;f++){var l=t[f];if("string"==typeof l)u+=A(l),a=f===t.length-1&&s.indexOf(l[l.length-1])>-1;else{var h=A(l.prefix),d=l.repeat?"(?:"+l.pattern+")(?:"+h+"(?:"+l.pattern+"))*":l.pattern;e&&e.push(l),l.optional?l.partial?u+=h+"("+d+")?":u+="(?:"+h+"("+d+"))?":u+=h+"("+d+")"}}return o?(r||(u+="(?:"+i+")?"),u+="$"===c?"$":"(?="+c+")"):(r||(u+="(?:"+i+"(?="+c+"))?"),a||(u+="(?="+i+"|"+c+")")),new RegExp("^"+u,T(n))}function S(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(S(t[o],e,n).source);return new RegExp("(?:"+r.join("|")+")",T(n))}(t,e,n):function(t,e,n){return C(R(t,n),e,n)}(t,e,n)}b.parse=g,b.compile=E,b.tokensToFunction=$,b.tokensToRegExp=_;const{hasOwnProperty:B}=Object.prototype,M=new Map;function U(t){try{return decodeURIComponent(t)}catch(e){return t}}function D(t,e,n,r,o){let i,s,c=0,u=t.path||"";return"/"===u.charAt(0)&&(n&&(u=u.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=M.get(i);if(!s){const e=[];s={keys:e,pattern:b(t,e,{end:n,strict:""===t})},M.set(i,s)}const c=s.pattern.exec(e);if(!c)return null;const u=Object.assign({},o);for(let t=1;t<c.length;t++){const e=s.keys[t-1],n=e.name,r=c[t];void 0===r&&B.call(u,n)||(e.repeat?u[n]=r?r.split(e.delimiter).map(U):[]:u[n]=r?U(r):r)}return{path:c[0],keys:(r||[]).concat(s.keys),params:u}}(u,e,!f,r,o)))return{done:!1,value:{route:t,keys:i.keys,params:i.params,path:i.path}};if(i&&f)for(;c<f.length;){if(!s){const r=f[c];r.parent=t;let o=i.path.length;o>0&&"/"===e.charAt(o)&&(o+=1),s=D(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,c++}return{done:!0}}}}function I(t){if(l(t.route.action))return t.route.action(t)}M.set("|false",{keys:[],pattern:/(?:)/});class L{constructor(t,e={}){if(Object(t)!==t)throw new TypeError("Invalid routes");this.baseUrl=e.baseUrl||"",this.errorHandler=e.errorHandler,this.resolveRoute=e.resolveRoute||I,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){c(e);const n=[...t(e)];this.root.o=n}addRoutes(e){return c(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=D(this.root,this.s(e.pathname),this.baseUrl),r=this.resolveRoute;let o=null,i=null,s=e;function c(t,u=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}(u,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&&e!==w?(s.result=e.result||e,s):c(t,u,e))):(i=o,Promise.resolve(w))}return e.next=c,Promise.resolve().then(()=>c(!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})}static u(t,e){return new URL(t,e)}get l(){return this.baseUrl?this.constructor.u(this.baseUrl,document.baseURI||document.URL).href.replace(/[^\/]*$/,""):""}s(t){if(!this.baseUrl)return t;const e=this.l,n=this.constructor.u(t,e).href;return n.slice(0,e.length)===e?n.slice(e.length):void 0}}L.pathToRegexp=b;const{pathToRegexp:F}=L,N=new Map;function H(t){let e=t.path;return void 0!==(e=Array.isArray(e)?e[0]:e)?e:""}function W(t,e={}){if(!(t instanceof L))throw new TypeError("An instance of Resolver is expected");const n=new Map;return(r,o)=>{let i=n.get(r);if(!(i||(n.clear(),function t(e,n,r){if(e.has(n.name))throw new Error(`Duplicate route name for name "${n.name}"`);if(e.has(n.component))throw new Error(`Duplicate route name for component <${n.component}>`);const o=n.name||n.component;if(o&&e.set(o,n),Array.isArray(r))for(let o=0;o<r.length;o++){const i=r[o];i.parent=n,t(e,i,i.o||i.children)}}(n,t.root,t.root.o),i=n.get(r))))throw new Error(`Route "${r}" not found`);let s=N.get(i.fullPath);if(!s){let t=H(i),e=i.parent;for(;e;){const n=H(e);n&&(t=n.replace(/\/$/,"")+"/"+t.replace(/^\//,"")),e=e.parent}const n=F.parse(t),r=F.tokensToFunction(n),o=Object.create(null);for(let t=0;t<n.length;t++)h(n[t])||(o[n[t].name]=!0);s={toPath:r,keys:o},N.set(t,s),i.fullPath=t}let c=s.toPath(o,e)||"/";if(e.stringifyQueryParams&&o){const t={},n=Object.keys(o);for(let e=0;e<n.length;e++){const r=n[e];s.keys[r]||(t[r]=o[r])}const r=e.stringifyQueryParams(t);r&&(c+="?"===r.charAt(0)?r:`?${r}`)}return c}}let z=[];function J(t){z.forEach(t=>t.inactivate()),t.forEach(t=>t.activate()),z=t}const K=t=>{const e=getComputedStyle(t).getPropertyValue("animation-name");return e&&"none"!==e},V=(t,e)=>{const n=()=>{t.removeEventListener("animationend",n),e()};t.addEventListener("animationend",n)};function q(t,e){return t.classList.add(e),new Promise(n=>{if(K(t)){const r=t.getBoundingClientRect(),o=`height: ${r.bottom-r.top}px; width: ${r.right-r.left}px`;t.setAttribute("style",`position: absolute; ${o}`),V(t,()=>{t.classList.remove(e),t.removeAttribute("style"),n()})}else t.classList.remove(e),n()})}const G=256;function Q(t){return null!==t&&void 0!==t}function X({pathname:t="",chain:e=[],params:n={},redirectFrom:r,resolver:o},i){const s=e.map(t=>t.route);return{baseUrl:o&&o.baseUrl||"",pathname:t,routes:s,route:i||s.length&&s[s.length-1]||null,params:n,redirectFrom:r,getUrl:(t={})=>nt(ot.pathToRegexp.compile(rt(s))(Object.assign({},n,t)),o)}}function Y(t,e){const n=Object.assign({},t.params);return{redirect:{pathname:e,from:t.pathname,params:n}}}function Z(t,e,n){if(l(t))return t.apply(n,e)}function tt(t,e,n){return r=>r&&(r.cancel||r.redirect)?r:n?Z(n[t],e,n):void 0}function et(t){if(t&&t.length){const e=t[0].parentNode;for(let n=0;n<t.length;n++)e.removeChild(t[n])}}function nt(t,e){const n=e.l;return n?e.constructor.u(t.replace(/^\//,""),n).pathname:t}function rt(t){return t.map(t=>t.path).reduce((t,e)=>e.length?t.replace(/\/$/,"")+"/"+e.replace(/^\//,""):t)}class ot extends L{constructor(t,e){const n=document.head.querySelector("base");super([],Object.assign({baseUrl:n&&n.getAttribute("href")},e)),this.resolveRoute=(t=>this.h(t));const r=ot.NavigationTrigger;ot.setTriggers.apply(ot,Object.keys(r).map(t=>r[t])),this.baseUrl,this.ready,this.ready=Promise.resolve(t),this.location,this.location=X({resolver:this}),this.p=0,this.m=this.v.bind(this),this.setOutlet(t),this.subscribe()}h(n){const r=n.route;let i=Promise.resolve();l(r.children)&&(i=i.then(()=>r.children(function(t){const e=Object.assign({},t);return delete e.next,e}(n))).then(n=>{Q(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)}));const c={redirect:t=>Y(n,t),component:t=>(function(t,e){const n=document.createElement(e);n.location=X(t);const r=t.chain.map(t=>t.route).indexOf(t.route);return t.chain[r].element=n,n})(n,t)};return i.then(()=>Z(r.action,[n,c],r)).then(t=>Q(t)&&(t instanceof HTMLElement||t.redirect||t===w)?t:h(r.redirect)?c.redirect(r.redirect):r.bundle?(a=r.bundle,h(a)?u(a):Promise.race(o.filter(t=>t in a).map(t=>u(a[t],t)))).then(()=>{},()=>{throw new Error(e(`Bundle not found: ${r.bundle}. Check if the file name is correct`))}):void 0).then(t=>Q(t)?t:h(r.component)?c.component(r.component):void 0);var a}setOutlet(t){t&&this.g(t),this.$=t}getOutlet(){return this.$}setRoutes(t){this._=void 0,super.setRoutes(t),this.v()}render(t,e){const n=++this.p,r=t.pathname||t;return this.ready=this.resolve(t).then(t=>this.O(t)).then(t=>{if(n===this.p){const r=this.j;if(t===r)return this.location;e&&this.R(t.pathname,t.redirectFrom),this.P(t,r);const o=this.A(t);return this.k(t),this.T(t,r),o.then(()=>{if(n===this.p)return this.C(),this.j=t,this.location=X(t),a("location-changed",{router:this,location:this.location}),this.location})}}).catch(t=>{if(n===this.p)throw e&&this.R(r),et(this.$&&this.$.children),this.location=X({pathname:r,resolver:this}),a("error",{router:this,error:t,pathname:r}),t}),this.ready}O(t,e=t){return this.S(e).then(n=>{const r=n!==e?n:t;return n.next().then(t=>{if(null===t||t===w){if(nt(rt(n.chain),n.resolver)!==n.pathname)throw d(r)}return t&&t!==w?this.O(r,t):this.B(r)})})}S(t){const n=t.result;return n instanceof HTMLElement?Promise.resolve(t):n.redirect?this.M(n.redirect,t.U).then(t=>this.S(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: "${function(t){if("object"!=typeof t)return String(t);const e=Object.prototype.toString.call(t).match(/ (.*)\]$/)[1];return"Object"===e||"Array"===e?`${e} ${JSON.stringify(t)}`:e}(n)}". `+"Double check the action return value for the route.")))}B(t){return this.D(t).then(e=>e===this.j||e===t?e:this.O(e))}D(t){const e=(this.j||{}).chain||[],n=t.chain;let r=Promise.resolve();const o=()=>({cancel:!0}),i=e=>Y(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&&(e[r].element&&e[r].element.localName)===(n[r].element&&n[r].element.localName));r=++t.I);for(let n=e.length-1;n>=t.I;n--){const i=X(t);r=r.then(tt("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=X(t,n[e].route);r=r.then(tt("onBeforeEnter",[s,{prevent:o,redirect:i},this],n[e].element))}return r.then(e=>{if(e){if(e.cancel)return this.j;if(e.redirect)return this.M(e.redirect,t.U)}return t})}M(t,n){if(n>G)throw new Error(e(`Too many redirects when rendering ${t.from}`));return this.resolve({pathname:this.urlForPath(t.pathname,t.params),redirectFrom:t.from,U:(n||0)+1})}g(t=this.$){if(!(t instanceof Node))throw new TypeError(e(`Expected router outlet to be a valid DOM Node (but got ${t})`))}R(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"}))}}P(t,e){this.g(),this.L();let n=this.$;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.F=Array.from(n.children),this.N=[];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.N.push(o),r=o)}}C(){this.F&&et(this.F),this.F=null,this.N=null}L(){this.F&&this.N&&(et(this.N),this.F=null,this.N=null)}T(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=X(t);Z(r.onAfterLeave,[n,{},e.resolver],r)}finally{et(r.children)}}}k(t){for(let e=t.I;e<t.chain.length;e++){const n=t.chain[e].element||{},r=X(t,t.chain[e].route);Z(n.onAfterEnter,[r,{},t.resolver],n)}}A(t){const e=(this.F||[])[0],n=(this.N||[])[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(q(e,t)),r.push(q(n,o))}return Promise.all(r).then(()=>t)}subscribe(){window.addEventListener("vaadin-router-go",this.m)}unsubscribe(){window.removeEventListener("vaadin-router-go",this.m)}v(t){const e=t?t.detail.pathname:window.location.pathname;h(this.s(e))&&(t&&t.preventDefault&&t.preventDefault(),this.render(e,!0))}static setTriggers(...t){J(t)}urlForName(t,e){return this._||(this._=W(this)),nt(this._(t,e),this)}urlForPath(t,e){return nt(ot.pathToRegexp.compile(t)(e),this)}static go(t){return a("go",{pathname:t})}}const it=/\/\*\*\s+vaadin-dev-mode:start([\s\S]*)vaadin-dev-mode:end\s+\*\*\//i;function st(t,e){if("function"!=typeof t)return;const n=it.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||{};const ct=function(t,e){if(window.Vaadin.developmentMode)return st(t,e)};function ut(){}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&&!st(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}}());window.Vaadin=window.Vaadin||{},window.Vaadin.registrations=window.Vaadin.registrations||[],window.Vaadin.registrations.push({is:"@vaadin/router",version:"1.2.0-pre.3"}),ct(ut),ot.NavigationTrigger={POPSTATE:y,CLICK:m};export{ot as Router,L 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(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},i=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 a(e){return e=e||[],Array.isArray(e)?e:[e]}function u(e){return"[Vaadin.Router] "+e}var c="module",l="nomodule",s=[c,l];function d(e){if(!e.match(/.+\.[m]?js$/))throw new Error(u('Unsupported type for bundle "'+e+'": .js or .mjs expected.'))}function f(e){if(!e||!g(e.path))throw new Error(u('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(!(_(e.action)||Array.isArray(e.children)||_(e.children)||m(t)||n.some(function(t){return g(e[t])})))throw new Error(u('Expected route config "'+e.path+'" to include either "'+n.join('", "')+'" or "action" function but none found.'));if(t)if(g(t))d(t);else{if(!s.some(function(e){return e in t}))throw new Error(u('Expected route bundle to include either "'+l+'" or "'+c+'" keys, or both'));s.forEach(function(e){return e in t&&d(t[e])})}e.redirect&&["bundle","component"].forEach(function(t){t in e&&console.warn(u('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 h(e){a(e).forEach(function(e){return f(e)})}function p(e,t){var n=document.head.querySelector('script[src="'+e+'"][async]');return n||((n=document.createElement("script")).setAttribute("src",e),t===c?n.setAttribute("type",c):t===l&&n.setAttribute(l,""),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 v(e,t){window.dispatchEvent(new CustomEvent("vaadin-router-"+e,{detail:t}))}function m(e){return"object"===(void 0===e?"undefined":t(e))&&!!e}function _(e){return"function"==typeof e}function g(e){return"string"==typeof e}function y(e){var t=new Error(u("Page not found ("+e.pathname+")"));return t.context=e,t.code=404,t}var w=new function e(){n(this,e)};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(),v("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&&v("go",{pathname:window.location.pathname})}/Trident/.test(navigator.userAgent)&&!_(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=H,O=I,R=function(e,t){return T(I(e,t))},A=T,j=F,P="/",S="./",L=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||S,l=!1;null!==(n=L.exec(e));){var s=n[0],d=n[1],f=n.index;if(a+=e.slice(i,f),i=f+s.length,d)a+=d[1],l=!0;else{var h="",p=e[i],v=n[2],m=n[3],_=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 F(e,t,n){for(var r=(n=n||{}).strict,o=!1!==n.end,i=N(n.delimiter||P),a=n.delimiters||S,u=[].concat(n.endsWith||[]).map(N).concat("$").join("|"),c="",l=0===e.length,s=0;s<e.length;s++){var d=e[s];if("string"==typeof d)c+=N(d),l=s===e.length-1&&a.indexOf(d[d.length-1])>-1;else{var f=N(d.prefix),h=d.repeat?"(?:"+d.pattern+")(?:"+f+"(?:"+d.pattern+"))*":d.pattern;t&&t.push(d),d.optional?d.partial?c+=f+"("+h+")?":c+="(?:"+f+"("+h+"))?":c+=f+"("+h+")"}}return o?(r||(c+="(?:"+i+")?"),c+="$"===u?"$":"(?="+u+")"):(r||(c+="(?:"+i+"(?="+u+"))?"),l||(c+="(?="+i+"|"+u+")")),new RegExp("^"+c,B(n))}function H(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(H(e[o],t,n).source);return new RegExp("(?:"+r.join("|")+")",B(n))}(e,t,n):function(e,t,n){return F(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,$=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 d=a.keys[s-1],f=d.name,h=c[s];void 0===h&&M.call(l,f)||(d.repeat?l[f]=h?h.split(d.delimiter).map(D):[]:l[f]=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 d=s[u];d.parent=e;var f=i.path.length;f>0&&"/"===t.charAt(f)&&(f+=1),a=U(d,t.substr(f),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(_(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(i(this.root.__children))}},{key:"setRoutes",value:function(e){h(e);var t=[].concat(i(a(e)));this.root.__children=t}},{key:"addRoutes",value:function(e){var t;return h(e),(t=this.root.__children).push.apply(t,i(a(e))),this.getRoutes()}},{key:"removeRoutes",value:function(){this.setRoutes([])}},{key:"resolve",value:function(e){var t=this,n=Object.assign({},this.context,g(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(y(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&&n!==w?(u.result=n.result||n,u):c(e,t,n)})):(a=i,Promise.resolve(w))}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 J(e){q.forEach(function(e){return e.inactivate()}),e.forEach(function(e){return e.activate()}),q=e}var z=function(e){var t=getComputedStyle(e).getPropertyValue("animation-name");return t&&"none"!==t},G=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(z(e)){var r=e.getBoundingClientRect(),o="height: "+(r.bottom-r.top)+"px; width: "+(r.right-r.left)+"px";e.setAttribute("style","position: absolute; "+o),G(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(_(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 i(e,t){n(this,i);var r=o(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,[],Object.assign({},t)));r.resolveRoute=function(e){return r.__resolveRoute(e)};var a=i.NavigationTrigger;return i.setTriggers.apply(i,Object.keys(a).map(function(e){return a[e]})),r.ready,r.ready=Promise.resolve(e),r.location,r.location=Y({}),r.__lastStartedRenderId=0,r.__navigationEventHandler=r.__onNavigationEvent.bind(r),r.setOutlet(e),r.subscribe(),r}return 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,K),r(i,[{key:"__resolveRoute",value:function(e){var t=e.route,n=Promise.resolve();_(t.children)&&(n=n.then(function(){return t.children(function(e){var t=Object.assign({},e);return delete t.next,t}(e))}).then(function(e){X(e)||_(t.children)||(e=t.children),function(e,t){if(!Array.isArray(e)&&!m(e))throw new Error(u('Incorrect "children" value for the route '+t.path+": expected array or object, but got "+e));t.__children=[];for(var n=a(e),r=0;r<n.length;r++)f(n[r]),t.__children.push(n[r])}(e,t)}));var r={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)}};return n.then(function(){return ee(t.action,[e,r],t)}).then(function(e){return X(e)&&(e instanceof HTMLElement||e.redirect||e===w)?e:g(t.redirect)?r.redirect(t.redirect):t.bundle?(n=t.bundle,g(n)?p(n):Promise.race(s.filter(function(e){return e in n}).map(function(e){return p(n[e],e)}))).then(function(){},function(){throw new Error(u("Bundle not found: "+t.bundle+". Check if the file name is correct"))}):void 0;var n}).then(function(e){return X(e)?e:g(t.component)?r.component(t.component):void 0})}},{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})(i.prototype.__proto__||Object.getPrototypeOf(i.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),v("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}),v("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||e===w)&&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 y(o);return e&&e!==w?t.__fullyResolveChain(o,e):t.__amendWithOnBeforeCallbacks(o)})})}},{key:"__amendWithResolutionResult",value:function(e){var n=this,r=e.result;return r instanceof HTMLElement?Promise.resolve(e):r.redirect?this.__redirect(r.redirect,e.__redirectCount).then(function(e){return n.__amendWithResolutionResult(e)}):r instanceof Error?Promise.reject(r):Promise.reject(new Error(u('Invalid route resolution result for path "'+e.pathname+'". Expected redirect object or HTML element, but got: "'+function(e){if("object"!==(void 0===e?"undefined":t(e)))return String(e);var n=Object.prototype.toString.call(e).match(/ (.*)\]$/)[1];return"Object"===n||"Array"===n?n+" "+JSON.stringify(e):n}(r)+'". 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&&(n[u].element&&n[u].element.localName)===(r[u].element&&r[u].element.localName));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 d=Y(e,r[s].route);o=o.then(te("onBeforeEnter",[d,{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,t){if(t>256)throw new Error(u("Too many redirects when rendering "+e.from));return this.resolve({pathname:this.constructor.urlForPath(e.pathname,e.params),redirectFrom:e.from,__redirectCount:(t||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(u("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];J(t)}},{key:"urlForPath",value:function(e,t){return i.pathToRegexp.compile(e)(t)}},{key:"go",value:function(e){v("go",{pathname:e})}}]),i}(),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||{};var ae=function(e,t){if(window.Vaadin.developmentMode)return ie(e,t)};function ue(){}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}}());window.Vaadin=window.Vaadin||{},window.Vaadin.registrations=window.Vaadin.registrations||[],window.Vaadin.registrations.push({is:"@vaadin/router",version:"1.2.0-pre.2"}),ae(ue),re.NavigationTrigger={POPSTATE:C,CLICK:E},e.Router=re,e.Resolver=K,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(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},i=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 a(e){return e=e||[],Array.isArray(e)?e:[e]}function u(e){return"[Vaadin.Router] "+e}var c="module",l="nomodule",s=[c,l];function f(e){if(!e.match(/.+\.[m]?js$/))throw new Error(u('Unsupported type for bundle "'+e+'": .js or .mjs expected.'))}function d(e){if(!e||!g(e.path))throw new Error(u('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(!(_(e.action)||Array.isArray(e.children)||_(e.children)||m(t)||n.some(function(t){return g(e[t])})))throw new Error(u('Expected route config "'+e.path+'" to include either "'+n.join('", "')+'" or "action" function but none found.'));if(t)if(g(t))f(t);else{if(!s.some(function(e){return e in t}))throw new Error(u('Expected route bundle to include either "'+l+'" or "'+c+'" keys, or both'));s.forEach(function(e){return e in t&&f(t[e])})}e.redirect&&["bundle","component"].forEach(function(t){t in e&&console.warn(u('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 h(e){a(e).forEach(function(e){return d(e)})}function p(e,t){var n=document.head.querySelector('script[src="'+e+'"][async]');return n||((n=document.createElement("script")).setAttribute("src",e),t===c?n.setAttribute("type",c):t===l&&n.setAttribute(l,""),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 v(e,t){return!window.dispatchEvent(new CustomEvent("vaadin-router-"+e,{cancelable:"go"===e,detail:t}))}function m(e){return"object"===(void 0===e?"undefined":t(e))&&!!e}function _(e){return"function"==typeof e}function g(e){return"string"==typeof e}function y(e){var t=new Error(u("Page not found ("+e.pathname+")"));return t.context=e,t.code=404,t}var w=new function e(){n(this,e)};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&&v("go",{pathname:t.pathname})&&e.preventDefault()}}var E={activate:function(){window.document.addEventListener("click",b)},inactivate:function(){window.document.removeEventListener("click",b)}};function x(e){"vaadin-router-ignore"!==e.state&&v("go",{pathname:window.location.pathname})}/Trident/.test(navigator.userAgent)&&!_(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 k={activate:function(){window.addEventListener("popstate",x)},inactivate:function(){window.removeEventListener("popstate",x)}},C=B,O=U,R=function(e,t){return S(U(e,t))},A=S,P=V,j="/",L="./",T=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");function U(e,t){for(var n,r=[],o=0,i=0,a="",u=t&&t.delimiter||j,c=t&&t.delimiters||L,l=!1;null!==(n=T.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],m=n[3],_=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,k=m||_;r.push({name:v||o++,prefix:h,delimiter:x,optional:E,repeat:b,partial:w,pattern:k?I(k):"[^"+N(x)+"]+?"})}}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 I(e){return e.replace(/([=!:$/()])/g,"\\$1")}function F(e){return e&&e.sensitive?"":"i"}function V(e,t,n){for(var r=(n=n||{}).strict,o=!1!==n.end,i=N(n.delimiter||j),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,F(n))}function B(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(B(e[o],t,n).source);return new RegExp("(?:"+r.join("|")+")",F(n))}(e,t,n):function(e,t,n){return V(U(e,n),t,n)}(e,t,n)}C.parse=O,C.compile=R,C.tokensToFunction=A,C.tokensToRegExp=P;var M=Object.prototype.hasOwnProperty,H=new Map;function D(e){try{return decodeURIComponent(e)}catch(t){return e}}function $(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=H.get(i);if(!a){var u=[];a={keys:u,pattern:C(e,u,{end:n,strict:""===e})},H.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&&M.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=$(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(_(e.route.action))return e.route.action(e)}H.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(i(this.root.__children))}},{key:"setRoutes",value:function(e){h(e);var t=[].concat(i(a(e)));this.root.__children=t}},{key:"addRoutes",value:function(e){var t;return h(e),(t=this.root.__children).push.apply(t,i(a(e))),this.getRoutes()}},{key:"removeRoutes",value:function(){this.setRoutes([])}},{key:"resolve",value:function(e){var t=this,n=Object.assign({},this.context,g(e)?{pathname:e}:e),r=$(this.root,this.__normalizePathname(n.pathname),this.baseUrl),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(y(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&&n!==w?(u.result=n.result||n,u):c(e,t,n)})):(a=i,Promise.resolve(w))}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})}},{key:"__normalizePathname",value:function(e){if(!this.baseUrl)return e;var t=this.__effectiveBaseUrl,n=this.constructor.__createUrl(e,t).href;return n.slice(0,t.length)===t?n.slice(t.length):void 0}},{key:"__effectiveBaseUrl",get:function(){return this.baseUrl?this.constructor.__createUrl(this.baseUrl,document.baseURI||document.URL).href.replace(/[^\/]*$/,""):""}}],[{key:"__createUrl",value:function(e,t){return new URL(e,t)}}]),e}();K.pathToRegexp=C;var z=K.pathToRegexp,q=new Map;function Q(e){var t=e.path;return void 0!==(t=Array.isArray(t)?t[0]:t)?t:""}function J(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(e instanceof K))throw new TypeError("An instance of Resolver is expected");var n=new Map;return function(r,o){var i=n.get(r);if(!(i||(n.clear(),function e(t,n,r){if(t.has(n.name))throw new Error('Duplicate route name for name "'+n.name+'"');if(t.has(n.component))throw new Error("Duplicate route name for component <"+n.component+">");var o=n.name||n.component;if(o&&t.set(o,n),Array.isArray(r))for(var i=0;i<r.length;i++){var a=r[i];a.parent=n,e(t,a,a.__children||a.children)}}(n,e.root,e.root.__children),i=n.get(r))))throw new Error('Route "'+r+'" not found');var a=q.get(i.fullPath);if(!a){for(var u=Q(i),c=i.parent;c;){var l=Q(c);l&&(u=l.replace(/\/$/,"")+"/"+u.replace(/^\//,"")),c=c.parent}for(var s=z.parse(u),f=z.tokensToFunction(s),d=Object.create(null),h=0;h<s.length;h++)g(s[h])||(d[s[h].name]=!0);a={toPath:f,keys:d},q.set(u,a),i.fullPath=u}var p=a.toPath(o,t)||"/";if(t.stringifyQueryParams&&o){for(var v={},m=Object.keys(o),_=0;_<m.length;_++){var y=m[_];a.keys[y]||(v[y]=o[y])}var w=t.stringifyQueryParams(v);w&&(p+="?"===w.charAt(0)?w:"?"+w)}return p}}var G=[];function X(e){G.forEach(function(e){return e.inactivate()}),e.forEach(function(e){return e.activate()}),G=e}var Y=function(e){var t=getComputedStyle(e).getPropertyValue("animation-name");return t&&"none"!==t},Z=function(e,t){e.addEventListener("animationend",function n(){e.removeEventListener("animationend",n),t()})};function ee(e,t){return e.classList.add(t),new Promise(function(n){if(Y(e)){var r=e.getBoundingClientRect(),o="height: "+(r.bottom-r.top)+"px; width: "+(r.right-r.left)+"px";e.setAttribute("style","position: absolute; "+o),Z(e,function(){e.classList.remove(t),e.removeAttribute("style"),n()})}else e.classList.remove(t),n()})}function te(e){return null!==e&&void 0!==e}function ne(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,l=e.resolver,s=i.map(function(e){return e.route});return{baseUrl:l&&l.baseUrl||"",pathname:r,routes:s,route:t||s.length&&s[s.length-1]||null,params:u,redirectFrom:c,getUrl:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ue(le.pathToRegexp.compile(ce(s))(Object.assign({},u,e)),l)}}}function re(e,t){var n=Object.assign({},e.params);return{redirect:{pathname:t,from:e.pathname,params:n}}}function oe(e,t,n){if(_(e))return e.apply(n,t)}function ie(e,t,n){return function(r){return r&&(r.cancel||r.redirect)?r:n?oe(n[e],t,n):void 0}}function ae(e){if(e&&e.length)for(var t=e[0].parentNode,n=0;n<e.length;n++)t.removeChild(e[n])}function ue(e,t){var n=t.__effectiveBaseUrl;return n?t.constructor.__createUrl(e.replace(/^\//,""),n).pathname:e}function ce(e){return e.map(function(e){return e.path}).reduce(function(e,t){return t.length?e.replace(/\/$/,"")+"/"+t.replace(/^\//,""):e})}var le=function(e){function i(e,t){n(this,i);var r=document.head.querySelector("base"),a=o(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,[],Object.assign({baseUrl:r&&r.getAttribute("href")},t)));a.resolveRoute=function(e){return a.__resolveRoute(e)};var u=i.NavigationTrigger;return i.setTriggers.apply(i,Object.keys(u).map(function(e){return u[e]})),a.baseUrl,a.ready,a.ready=Promise.resolve(e),a.location,a.location=ne({resolver:a}),a.__lastStartedRenderId=0,a.__navigationEventHandler=a.__onNavigationEvent.bind(a),a.setOutlet(e),a.subscribe(),a}return 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,K),r(i,[{key:"__resolveRoute",value:function(e){var t=e.route,n=Promise.resolve();_(t.children)&&(n=n.then(function(){return t.children(function(e){var t=Object.assign({},e);return delete t.next,t}(e))}).then(function(e){te(e)||_(t.children)||(e=t.children),function(e,t){if(!Array.isArray(e)&&!m(e))throw new Error(u('Incorrect "children" value for the route '+t.path+": expected array or object, but got "+e));t.__children=[];for(var n=a(e),r=0;r<n.length;r++)d(n[r]),t.__children.push(n[r])}(e,t)}));var r={redirect:function(t){return re(e,t)},component:function(t){return function(e,t){var n=document.createElement(t);n.location=ne(e);var r=e.chain.map(function(e){return e.route}).indexOf(e.route);return e.chain[r].element=n,n}(e,t)}};return n.then(function(){return oe(t.action,[e,r],t)}).then(function(e){return te(e)&&(e instanceof HTMLElement||e.redirect||e===w)?e:g(t.redirect)?r.redirect(t.redirect):t.bundle?(n=t.bundle,g(n)?p(n):Promise.race(s.filter(function(e){return e in n}).map(function(e){return p(n[e],e)}))).then(function(){},function(){throw new Error(u("Bundle not found: "+t.bundle+". Check if the file name is correct"))}):void 0;var n}).then(function(e){return te(e)?e:g(t.component)?r.component(t.component):void 0})}},{key:"setOutlet",value:function(e){e&&this.__ensureOutlet(e),this.__outlet=e}},{key:"getOutlet",value:function(){return this.__outlet}},{key:"setRoutes",value:function(e){this.__urlForName=void 0,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}(i.prototype.__proto__||Object.getPrototypeOf(i.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=ne(e),v("location-changed",{router:n,location:n.location}),n.location})}}).catch(function(e){if(r===n.__lastStartedRenderId)throw t&&n.__updateBrowserHistory(o),ae(n.__outlet&&n.__outlet.children),n.location=ne({pathname:o,resolver:n}),v("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||e===w)&&ue(ce(r.chain),r.resolver)!==r.pathname)throw y(o);return e&&e!==w?t.__fullyResolveChain(o,e):t.__amendWithOnBeforeCallbacks(o)})})}},{key:"__amendWithResolutionResult",value:function(e){var n=this,r=e.result;return r instanceof HTMLElement?Promise.resolve(e):r.redirect?this.__redirect(r.redirect,e.__redirectCount).then(function(e){return n.__amendWithResolutionResult(e)}):r instanceof Error?Promise.reject(r):Promise.reject(new Error(u('Invalid route resolution result for path "'+e.pathname+'". Expected redirect object or HTML element, but got: "'+function(e){if("object"!==(void 0===e?"undefined":t(e)))return String(e);var n=Object.prototype.toString.call(e).match(/ (.*)\]$/)[1];return"Object"===n||"Array"===n?n+" "+JSON.stringify(e):n}(r)+'". 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 re(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&&(n[u].element&&n[u].element.localName)===(r[u].element&&r[u].element.localName));u=++e.__divergedChainIndex);for(var c=n.length-1;c>=e.__divergedChainIndex;c--){var l=ne(e);o=o.then(ie("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=ne(e,r[s].route);o=o.then(ie("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,t){if(t>256)throw new Error(u("Too many redirects when rendering "+e.from));return this.resolve({pathname:this.urlForPath(e.pathname,e.params),redirectFrom:e.from,__redirectCount:(t||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(u("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&&ae(this.__disappearingContent),this.__disappearingContent=null,this.__appearingContent=null}},{key:"__removeAppearingContent",value:function(){this.__disappearingContent&&this.__appearingContent&&(ae(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=ne(e);oe(r.onAfterLeave,[o,{},t.resolver],r)}finally{ae(r.children)}}}},{key:"__runOnAfterEnterCallbacks",value:function(e){for(var t=e.__divergedChainIndex;t<e.chain.length;t++){var n=e.chain[t].element||{},r=ne(e,e.chain[t].route);oe(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(ee(t,u)),r.push(ee(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;g(this.__normalizePathname(t))&&(e&&e.preventDefault&&e.preventDefault(),this.render(t,!0))}},{key:"urlForName",value:function(e,t){return this.__urlForName||(this.__urlForName=J(this)),ue(this.__urlForName(e,t),this)}},{key:"urlForPath",value:function(e,t){return ue(i.pathToRegexp.compile(e)(t),this)}}],[{key:"setTriggers",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];X(t)}},{key:"go",value:function(e){return v("go",{pathname:e})}}]),i}(),se=/\/\*\*\s+vaadin-dev-mode:start([\s\S]*)vaadin-dev-mode:end\s+\*\*\//i;function fe(e,t){if("function"==typeof e){var n=se.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||{};var de=function(e,t){if(window.Vaadin.developmentMode)return fe(e,t)};function he(){}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&&!fe(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}}());window.Vaadin=window.Vaadin||{},window.Vaadin.registrations=window.Vaadin.registrations||[],window.Vaadin.registrations.push({is:"@vaadin/router",version:"1.2.0-pre.3"}),de(he),le.NavigationTrigger={POPSTATE:k,CLICK:E};var pe=void 0,ve=void 0,me=void 0,_e=void 0;K.__ensureUrlAvailableOrPolyfilled=function(){if(void 0===pe){try{var e=new URL("b","http://a");e.pathname="c",pe="http://a/c"===e.href}catch(e){pe=!1}pe||(ve=document.implementation.createHTMLDocument("url"),me=ve.createElement("base"),ve.head.appendChild(me),(_e=ve.createElement("a")).origin||Object.defineProperty(_e,"origin",{get:function(){var e=_e.port,t=_e.protocol;return t+"//"+("http:"===t&&"80"===e||"https:"===t&&"443"===e?_e.hostname:_e.host)}}))}},K.__createUrl=function(e,t){return K.__ensureUrlAvailableOrPolyfilled(),pe?new URL(e,t):(me.href=t,_e.href=e.replace(/ /g,"%20"),_e)},e.Router=le,e.Resolver=K,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=vaadin-router.umd.min.js.map
{
"name": "@vaadin/router",
"version": "1.2.0-pre.2",
"version": "1.2.0-pre.3",
"description": "Small and powerful client-side router for Web Components. Framework-agnostic.",

@@ -22,2 +22,3 @@ "main": "dist/vaadin-router.js",

"index.js",
"index.polyfilled.js",
"src",

@@ -48,3 +49,3 @@ "dist/vaadin-router.*"

"path": "dist/vaadin-router.min.js",
"maxSize": "7 kB"
"maxSize": "7.5 kB"
}

@@ -51,0 +52,0 @@ ],

@@ -20,2 +20,11 @@ /**

/**
* The base URL used in the router. See [the `baseUrl` property
* ](#/classes/Vaadin.Router#property-baseUrl) in the Vaadin.Router.
*
* @public
* @type {string}
*/
this.baseUrl;
/**
* The pathname as entered in the browser address bar

@@ -96,2 +105,16 @@ * (e.g. `/users/42/messages/12/edit`). It always starts with a `/` (slash).

}
/**
* Returns a URL corresponding to the route path and the parameters of this
* location. When the parameters object is given in the arguments,
* the argument parameters override the location ones.
*
* @public
* @type {Function}
* @param {?Object} parameters optional object with parameters to override,
* where keys are parameter names or indicies to substitute in the full path
* of the location’s route chain.
* @return {string}
*/
getUrl(parameters) { }
}

@@ -18,14 +18,17 @@ /**

if (routesByName.has(route.name)) {
throw new Error(`Route "${route.name}" already exists`);
throw new Error(`Duplicate route name for name "${route.name}"`);
} else if (routesByName.has(route.component)) {
throw new Error(`Duplicate route name for component <${route.component}>`);
}
if (route.name) {
routesByName.set(route.name, route);
const name = route.name || route.component;
if (name) {
routesByName.set(name, route);
}
if (routes) {
if (Array.isArray(routes)) {
for (let i = 0; i < routes.length; i++) {
const childRoute = routes[i];
childRoute.parent = route;
cacheRoutes(routesByName, childRoute, childRoute.__children);
cacheRoutes(routesByName, childRoute, childRoute.__children || childRoute.children);
}

@@ -35,2 +38,8 @@ }

function getRoutePath(route) {
let path = route.path;
path = Array.isArray(path) ? path[0] : path;
return path !== undefined ? path : '';
}
function generateUrls(router, options = {}) {

@@ -41,11 +50,11 @@ if (!(router instanceof Resolver)) {

router.routesByName = router.routesByName || new Map();
const routesByName = new Map();
return (routeName, params) => {
let route = router.routesByName.get(routeName);
let route = routesByName.get(routeName);
if (!route) {
router.routesByName.clear(); // clear cache
cacheRoutes(router.routesByName, router.root, router.root.__children);
routesByName.clear(); // clear cache
cacheRoutes(routesByName, router.root, router.root.__children);
route = router.routesByName.get(routeName);
route = routesByName.get(routeName);
if (!route) {

@@ -58,8 +67,8 @@ throw new Error(`Route "${routeName}" not found`);

if (!regexp) {
let fullPath = '';
let rt = route;
let fullPath = getRoutePath(route);
let rt = route.parent;
while (rt) {
const path = Array.isArray(rt.path) ? rt.path[0] : rt.path;
const path = getRoutePath(rt);
if (path) {
fullPath = path + fullPath;
fullPath = path.replace(/\/$/, '') + '/' + fullPath.replace(/^\//, '');
}

@@ -81,3 +90,3 @@ rt = rt.parent;

let url = router.baseUrl + regexp.toPath(params, options) || '/';
let url = regexp.toPath(params, options) || '/';

@@ -84,0 +93,0 @@ if (options.stringifyQueryParams && params) {

@@ -138,3 +138,4 @@ /**

this.root,
context.pathname.substr(this.baseUrl.length)
this.__normalizePathname(context.pathname),
this.baseUrl
);

@@ -197,2 +198,46 @@ const resolve = this.resolveRoute;

}
/**
* URL constructor polyfill hook. Creates and returns an URL instance.
*/
static __createUrl(url, base) {
return new URL(url, base);
}
/**
* If the baseUrl property is set, transforms the baseUrl and returns the full
* actual `base` string for using in the `new URL(path, base);` and for
* prepernding the paths with. The returned base ends with a trailing slash.
*
* Otherwise, returns empty string.
*/
get __effectiveBaseUrl() {
return this.baseUrl
? this.constructor.__createUrl(
this.baseUrl,
document.baseURI || document.URL
).href.replace(/[^\/]*$/, '')
: '';
}
/**
* If the baseUrl is set, matches the pathname with the router’s baseUrl,
* and returns the local pathname with the baseUrl stripped out.
*
* If the pathname does not match the baseUrl, returns undefined.
*
* If the `baseUrl` is not set, returns the unmodified pathname argument.
*/
__normalizePathname(pathname) {
if (!this.baseUrl) {
// No base URL, no need to transform the pathname.
return pathname;
}
const base = this.__effectiveBaseUrl;
const normalizedUrl = this.constructor.__createUrl(pathname, base).href;
if (normalizedUrl.slice(0, base.length) === base) {
return normalizedUrl.slice(base.length);
}
}
}

@@ -199,0 +244,0 @@

@@ -8,5 +8,5 @@ import {usageStatistics} from '@vaadin/vaadin-usage-statistics/vaadin-usage-statistics.js';

is: '@vaadin/router',
version: '1.2.0-pre.2',
version: '1.2.0-pre.3',
});
usageStatistics();
import Resolver from './resolver/resolver.js';
import generateUrls from './resolver/generateUrls.js';
import setNavigationTriggers from './triggers/setNavigationTriggers.js';

@@ -15,3 +16,3 @@ import animate from './transitions/animate.js';

getNotFoundError,
notFoundResult,
notFoundResult
} from './utils.js';

@@ -31,9 +32,17 @@

function createLocation({pathname = '', chain = [], params = {}, redirectFrom}, route) {
function createLocation({pathname = '', chain = [], params = {}, redirectFrom, resolver}, route) {
const routes = chain.map(item => item.route);
return {
baseUrl: resolver && resolver.baseUrl || '',
pathname,
routes: chain.map(item => item.route),
route: (!route && chain.length && chain[chain.length - 1].route) || route,
routes,
route: route || routes.length && routes[routes.length - 1] || null,
params,
redirectFrom,
getUrl: (userParams = {}) => getPathnameForRouter(
Router.pathToRegexp.compile(
getMatchedPath(routes)
)(Object.assign({}, params, userParams)),
resolver
)
};

@@ -105,8 +114,15 @@ }

function getPathnameForRouter(pathname, router) {
const base = router.__effectiveBaseUrl;
return base
? router.constructor.__createUrl(pathname.replace(/^\//, ''), base).pathname
: pathname;
}
function getMatchedPath(chain) {
return chain.map(item => item.path).reduce((prev, path) => {
if (path.length) {
return prev + (prev.charAt(prev.length - 1) === '/' ? '' : '/') + path;
return chain.map(item => item.path).reduce((a, b) => {
if (b.length) {
return a.replace(/\/$/, '') + '/' + b.replace(/^\//, '');
}
return prev;
return a;
});

@@ -120,5 +136,16 @@ }

*
* Use `new Router(outlet)` to create a new Router instance. The `outlet` parameter is a reference to the DOM node
* to render the content into. The Router instance is automatically subscribed to navigation events on `window`.
* Use `new Router(outlet, options)` to create a new Router instance.
*
* * The `outlet` parameter is a reference to the DOM node to render
* the content into.
*
* * The `options` parameter is an optional object with options. The following
* keys are supported:
* * `baseUrl` — the initial value for [
* the `baseUrl` property
* ](#/classes/Vaadin.Router#property-baseUrl)
*
* The Router instance is automatically subscribed to navigation events
* on `window`.
*
* See [Live Examples](#/classes/Vaadin.Router/demos/demo/index.html) for the detailed usage demo and code snippets.

@@ -156,3 +183,8 @@ *

constructor(outlet, options) {
super([], Object.assign({}, options));
const baseElement = document.head.querySelector('base');
super([], Object.assign({
// Default options
baseUrl: baseElement && baseElement.getAttribute('href')
}, options));
this.resolveRoute = context => this.__resolveRoute(context);

@@ -164,2 +196,12 @@

/**
* The base URL for all routes in the router instance. By default,
* takes the `<base href>` attribute value if the base element exists
* in the `<head>`.
*
* @public
* @type {string}
*/
this.baseUrl;
/**
* A promise that is settled after the current render cycle completes. If

@@ -185,3 +227,3 @@ * there is no render cycle in progress the promise is immediately settled

this.location;
this.location = createLocation({});
this.location = createLocation({resolver: this});

@@ -328,2 +370,6 @@ this.__lastStartedRenderId = 0;

*
* * `name` – the string name of the route to use in the
* `[Router.urlForName(name, parameters)](#/classes/Vaadin.Router#staticmethod-urlForName)`
* navigation helper method.
*
* For any route function (`action`, `children`) defined, the corresponding `route` object is available inside the callback

@@ -355,2 +401,3 @@ * through the `this` reference. If you need to access it, make sure you define the callback as a non-arrow function

setRoutes(routes) {
this.__urlForName = undefined;
super.setRoutes(routes);

@@ -431,3 +478,3 @@ this.__onNavigationEvent();

removeDomNodes(this.__outlet && this.__outlet.children);
this.location = createLocation({pathname});
this.location = createLocation({pathname, resolver: this});
fireRouterEvent('error', {router: this, error, pathname});

@@ -447,3 +494,7 @@ throw error;

if (nextContext === null || nextContext === notFoundResult) {
if (amendedContext.pathname !== getMatchedPath(amendedContext.chain)) {
const matchedPath = getPathnameForRouter(
getMatchedPath(amendedContext.chain),
amendedContext.resolver
);
if (matchedPath !== amendedContext.pathname) {
throw getNotFoundError(initialContext);

@@ -546,3 +597,3 @@ }

return this.resolve({
pathname: this.constructor.urlForPath(
pathname: this.urlForPath(
redirectData.pathname,

@@ -710,3 +761,8 @@ redirectData.params

const pathname = event ? event.detail.pathname : window.location.pathname;
this.render(pathname, true);
if (isString(this.__normalizePathname(pathname))) {
if (event && event.preventDefault) {
event.preventDefault();
}
this.render(pathname, true);
}
}

@@ -735,4 +791,33 @@

/**
* Generates a URL for the route with the given name, optionally performing
* substitution of parameters.
*
* The route is searched in all the Vaadin.Router instances subscribed to
* navigation events.
*
* **Note:** For child route names, only array children are considered.
* It is not possible to generate URLs using a name for routes set with
* a children function.
*
* @function urlForName
* @param {!string} name the route name or the route’s `component` name.
* @param {?Object} parameters Optional object with route path parameters,
* where keys are route parameter names or indicies, and values
* are parameter values.
*
* @return {string}
*/
urlForName(name, parameters) {
if (!this.__urlForName) {
this.__urlForName = generateUrls(this);
}
return getPathnameForRouter(
this.__urlForName(name, parameters),
this
);
}
/**
* Generates a URL for the given route path, optionally performing
* subscription of parameters.
* substitution of parameters.
*

@@ -746,15 +831,21 @@ * @param {!string} path string route path declared in [express.js syntax](https://expressjs.com/en/guide/routing.html#route-paths").

*/
static urlForPath(path, parameters) {
return Router.pathToRegexp.compile(path)(parameters);
urlForPath(path, parameters) {
return getPathnameForRouter(
Router.pathToRegexp.compile(path)(parameters),
this
);
}
/**
* Triggers navigation to a new path and returns without waiting until the
* navigation is complete.
* Triggers navigation to a new path. Returns a boolean without waiting until
* the navigation is complete. Returns `true` if at least one `Vaadin.Router`
* has handled the navigation (was subscribed and had `baseUrl` matching
* the `pathname` argument), otherwise returns `false`.
*
* @param {!string} pathname a new in-app path
* @return {boolean}
*/
static go(pathname) {
fireRouterEvent('go', {pathname});
return fireRouterEvent('go', {pathname});
}
}

@@ -84,4 +84,5 @@ import {fireRouterEvent} from '../utils.js';

// if none of the above, convert the click into a navigation event
event.preventDefault();
fireRouterEvent('go', {pathname: anchor.pathname});
if (fireRouterEvent('go', {pathname: anchor.pathname})) {
event.preventDefault();
}
}

@@ -88,0 +89,0 @@

@@ -134,5 +134,6 @@ export function toArray(objectOrArray) {

export function fireRouterEvent(type, detail) {
window.dispatchEvent(
new CustomEvent(
`vaadin-router-${type}`, {detail}));
return !window.dispatchEvent(new CustomEvent(
`vaadin-router-${type}`,
{cancelable: type === 'go', detail}
));
}

@@ -139,0 +140,0 @@

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