import{A as h,Oa as c,c as r,y as u}from"./chunk-4BILO7NM.js";var m=(()=>{let o=class o{constructor(t){this.location=t,this.transitionInMs=250,this.routes={},this.activeRoute=new r(void 0),this.isPWA=window.matchMedia("(display-mode: standalone)").matches}setTransition(t){this.transitionInMs=t}routeParams(t){let i=this.routes[t];return i!=null?i.params:new r([])}closeAllRoutes(t){for(let i in this.routes)if(this.routes.hasOwnProperty(i)){let e=this.routes[i];e.type!=t&&this.closeRoute(e.type)}}closeRoute(t,i=this.transitionInMs){let e=this.routes[t];e!=null&&(e.closing=!0,setTimeout(()=>{e.active=!1,e.closing=!1,e.animating=!1},i))}verifyRoute(t){return new Promise((i,e)=>{t.requireAuthentication,i(!0)})}setBrowserPath(t,i){if(!this.isPWA){let e=this.routes[t];if(e!=null)if(e.path==":base"){let s=`${i.join("/")}`;this.location.go(s)}else{let s=`${e.path}/${i.join("/")}`;this.location.go(s)}}}viewRouteByType(t,i=[],e=!0){let s=this.routes[t];s!=null&&(s.active?s.params.next(i):this.verifyRoute(s).then(n=>{n&&(this.closeAllRoutes(t),this.viewRoute(s,i,e))}))}viewRoute(t,i=[],e=!0){this.verifyRoute(t).then(s=>{s&&(t.params.next(i),t.active=!0,t.animating=e,this.setBrowserPath(t.type,i),this.activeRoute.next(t),setTimeout(()=>{t.animating=!1},this.transitionInMs))})}resetParams(t,i){let e=this.routes[t];e!=null&&(e.params.next(i),this.setBrowserPath(t,i))}watchLocationChange(){this.locationSubscription=this.location.subscribe(t=>{t.pop&&console.log(t.url)})}watchForLogin(){}monitorAuthentication(){}checkRoute(t,i=!0){let e=this.findMatchingRoute(t);e!=null&&this.viewRoute(e,e.params.getValue(),i)}findMatchingRoute(t){if(t=t.toLocaleLowerCase(),t.indexOf("code")>-1){let e=this.routes.Authentication;if(e!=null)return e}let i;for(let e in this.routes){let s=this.routes[e];if(t==s.path||t.indexOf(s.path)==0&&t.lastIndexOf("/")!=0){i=s;break}}if(i!=null){let e=i.path,n=t.slice(e.length).split("/");return n[0].length<=0&&n.splice(0,1),i.params.next(n),i}else return this.defaultRoute}init(t,i,e=250){this.routes=t,this.defaultRoute=i,this.transitionInMs=e,this.watchLocationChange(),this.monitorAuthentication(),this.checkRoute(window.location.pathname,!1)}ngOnDestroy(){this.authSubscription?.unsubscribe(),this.locationSubscription?.unsubscribe(),this.authSubscription?.unsubscribe()}};o.\u0275fac=function(i){return new(i||o)(h(c))},o.\u0275prov=u({token:o,factory:o.\u0275fac,providedIn:"root"});let a=o;return a})();export{m as a};
