import{q as y}from"./chunk-VSIACUI5.js";import{h as x}from"./chunk-62GP7ATO.js";import{H as v,Ib as S,J as c,M as a,b as w,d as R,e as m,vb as b}from"./chunk-4SVIVQBS.js";import{f as d}from"./chunk-4IDNTCH7.js";var L=(()=>{let r=class r{constructor(t){this.location=t,this.transitionInMs=250,this.routes={},this.activeRoute=new m(void 0),this.isPWA=window.matchMedia("(display-mode: standalone)").matches}setTransition(t){this.transitionInMs=t}routeParams(t){let e=this.routes[t];return e!=null?e.params:new m([])}closeAllRoutes(t){for(let e in this.routes)if(this.routes.hasOwnProperty(e)){let i=this.routes[e];i.type!=t&&this.closeRoute(i.type)}}closeRoute(t,e=this.transitionInMs){let i=this.routes[t];i!=null&&(i.closing=!0,setTimeout(()=>{i.active=!1,i.closing=!1,i.animating=!1},e))}verifyRoute(t){return new Promise((e,i)=>{t.requireAuthentication,e(!0)})}setBrowserPath(t,e){if(!this.isPWA){let i=this.routes[t];if(i!=null)if(i.path==":base"){let n=`${e.join("/")}`;this.location.go(n)}else{let n=`${i.path}/${e.join("/")}`;this.location.go(n)}}}viewRouteByType(t,e=[],i=!0){let n=this.routes[t];n!=null&&(n.active?n.params.next(e):this.verifyRoute(n).then(o=>{o&&(this.closeAllRoutes(t),this.viewRoute(n,e,i))}))}viewRoute(t,e=[],i=!0){this.verifyRoute(t).then(n=>{n&&(t.params.next(e),t.active=!0,t.animating=i,this.setBrowserPath(t.type,e),this.activeRoute.next(t),setTimeout(()=>{t.animating=!1},this.transitionInMs))})}resetParams(t,e){let i=this.routes[t];i!=null&&(i.params.next(e),this.setBrowserPath(t,e))}watchLocationChange(){this.locationSubscription=this.location.subscribe(t=>{t.pop&&console.log(t.url)})}watchForLogin(){}monitorAuthentication(){}checkRoute(t,e=!0){let i=this.findMatchingRoute(t);i!=null&&this.viewRoute(i,i.params.getValue(),e)}findMatchingRoute(t){if(t=t.toLocaleLowerCase(),t.indexOf("code")>-1){let i=this.routes.Authentication;if(i!=null)return i}let e;for(let i in this.routes){let n=this.routes[i];if(t==n.path||t.indexOf(n.path)==0&&t.lastIndexOf("/")!=0){e=n;break}}if(e!=null){let i=e.path,o=t.slice(i.length).split("/");return o[0].length<=0&&o.splice(0,1),e.params.next(o),e}else return this.defaultRoute}init(t,e,i=250){this.routes=t,this.defaultRoute=e,this.transitionInMs=i,this.watchLocationChange(),this.monitorAuthentication(),this.checkRoute(window.location.pathname,!1)}ngOnDestroy(){this.authSubscription?.unsubscribe(),this.locationSubscription?.unsubscribe(),this.authSubscription?.unsubscribe()}};r.\u0275fac=function(e){return new(e||r)(a(b))},r.\u0275prov=c({token:r,factory:r.\u0275fac,providedIn:"root"});let s=r;return s})();var h=class{constructor(r,I){this.id="",this.title="",this.note="",this.events=[],this.status=u.Created,this.priority=C.Standard,this.scheduled_Utc=new Date,this.created_Utc=new Date,this.lastUpdated_Utc=new Date,this.completing=!1,this.creator=r,this.recipient=I}};var A=(function(s){return s.General="General",s.Appointment="Appointment",s})(A||{}),u=(function(s){return s.Created="Created",s.Completed="Completed",s})(u||{}),C=(function(s){return s.Standard="Standard",s.Critical="Critical",s})(C||{});var G=(()=>{let r=class r{constructor(t,e){this.http=t,this.storageService=e,this.managingReminder=!1,this.reminderSaved=new R}manageReminder(t,e,i){this.reminderToManage=t,t!=null?this.reminderToManage=t:this.reminderToManage=new h(e,i),this.managingReminder=!0}stopManagingReminder(){window.clearTimeout(this.managingReminderTimer),this.managingReminder=!1,this.reminderSaved.next(),this.managingReminderTimer=window.setTimeout(()=>{this.reminderToManage=void 0},250)}getLastRemindersRetrieval(t){let e=localStorage.getItem(`u_${t}_rr`);if(e!=null)try{return parseInt(e)}catch{return}}updateLastRemindersRetrieval(t){let e=new Date;localStorage.setItem(`u_${t}_rr`,`${e.getTime()}`)}syncRemindersForUser(t,e=!1){let i="{{api}}/reminders/latest";if(!e){let n=this.getLastRemindersRetrieval(t);if(n!=null){let l=new Date().getTime()-n;i=i+`/${l}`}}return this.http.get(i).pipe(v(n=>d(this,null,function*(){yield this.storageService.remoteStoreReminders(n),this.updateLastRemindersRetrieval(t)})))}getReminders(t){return new w(e=>{this.storageService.getRemindersForUser(t).then(i=>{e.next(i),e.complete()}).catch(()=>{e.error(),e.complete()})})}createReminder(t,e,i,n,o,l,f,p){let g;f!=null&&p!=null&&(g={referenceId:f,type:p,content:""});let M={id:x(),creator:t,recipient:e,title:i,note:n,events:[],status:u.Created,priority:o,scheduled_Utc:l,created_Utc:new Date,lastUpdated_Utc:new Date,reference:g,completing:!1};this.storeReminder(M)}storeReminder(t){return d(this,null,function*(){yield this.storageService.storeReminder(t)})}};r.\u0275fac=function(e){return new(e||r)(a(S),a(y))},r.\u0275prov=c({token:r,factory:r.\u0275fac,providedIn:"root"});let s=r;return s})();export{L as a,A as b,u as c,C as d,G as e};
