import{d,e as p,k as Q,s as k,t as K,u as V,v as n,w as R}from"./chunk-ALDBR463.js";import{c as y,d as D,e as L,g as A,h as T,k as _}from"./chunk-FRH63NMA.js";import{Da as S,Ia as b,Jd as w,La as N,Na as l,Oa as x,Sa as F,Za as j,a as C,b as M,lb as q}from"./chunk-V6BPA3D7.js";var Z="@ngrx/router-store/request",St=d(Z,p()),O="@ngrx/router-store/navigation",Nt=d(O,p()),P="@ngrx/router-store/cancel",yt=d(P,p()),U="@ngrx/router-store/error",At=d(U,p()),$="@ngrx/router-store/navigated",Tt=d($,p());function Ot(e,t){let r=t;switch(r.type){case O:case U:case P:return{state:r.payload.routerState,navigationId:r.payload.event.id};default:return e}}var g=class{serialize(t){return{root:this.serializeRoute(t.root),url:t.url}}serializeRoute(t){let r=t.children.map(s=>this.serializeRoute(s));return{params:t.params,data:t.data,url:t.url,outlet:t.outlet,title:t.title,routeConfig:t.routeConfig?{path:t.routeConfig.path,pathMatch:t.routeConfig.pathMatch,redirectTo:t.routeConfig.redirectTo,outlet:t.routeConfig.outlet,title:typeof t.routeConfig.title=="string"?t.routeConfig.title:void 0}:null,queryParams:t.queryParams,fragment:t.fragment,firstChild:r[0],children:r}}},z=function(e){return e[e.PreActivation=1]="PreActivation",e[e.PostActivation=2]="PostActivation",e}(z||{}),J="router",G=new N("@ngrx/router-store Internal Configuration"),W=new N("@ngrx/router-store Configuration");function it(e){return C({stateKey:J,serializer:g,navigationActionTiming:z.PreActivation},e)}var m=class{serialize(t){return{root:this.serializeRoute(t.root),url:t.url}}serializeRoute(t){let r=t.children.map(s=>this.serializeRoute(s));return{params:t.params,paramMap:t.paramMap,data:t.data,url:t.url,outlet:t.outlet,title:t.title,routeConfig:t.routeConfig?{component:t.routeConfig.component,path:t.routeConfig.path,pathMatch:t.routeConfig.pathMatch,redirectTo:t.routeConfig.redirectTo,outlet:t.routeConfig.outlet,title:t.routeConfig.title}:null,queryParams:t.queryParams,queryParamMap:t.queryParamMap,fragment:t.fragment,component:t.routeConfig?t.routeConfig.component:void 0,root:void 0,parent:void 0,firstChild:r[0],pathFromRoot:void 0,children:r}}},E=class{},c=function(e){return e[e.NONE=1]="NONE",e[e.ROUTER=2]="ROUTER",e[e.STORE=3]="STORE",e}(c||{}),H=(()=>{class e{constructor(r,s,o,u,v,f){this.store=r,this.router=s,this.serializer=o,this.errorHandler=u,this.config=v,this.activeRuntimeChecks=f,this.lastEvent=null,this.routerState=null,this.trigger=c.NONE,this.stateKey=this.config.stateKey,!V()&&w()&&(f?.strictActionSerializability||f?.strictStateSerializability)&&this.serializer instanceof m&&console.warn("@ngrx/router-store: The serializability runtime checks cannot be enabled with the FullRouterStateSerializer. The FullRouterStateSerializer has an unserializable router state and actions that are not serializable. To use the serializability runtime checks either use the MinimalRouterStateSerializer or implement a custom router state serializer."),this.setUpStoreStateListener(),this.setUpRouterEventsListener()}setUpStoreStateListener(){this.store.pipe(K(this.stateKey),S(this.store)).subscribe(([r,s])=>{this.navigateIfNeeded(r,s)})}navigateIfNeeded(r,s){if(!r||!r.state||this.trigger===c.ROUTER||this.lastEvent instanceof y)return;let o=r.state.url;st(this.router.url,o)||(this.storeState=s,this.trigger=c.STORE,this.router.navigateByUrl(o).catch(u=>{this.errorHandler.handleError(u)}))}setUpRouterEventsListener(){let r=this.config.navigationActionTiming===z.PostActivation,s;this.router.events.pipe(S(this.store)).subscribe(([o,u])=>{this.lastEvent=o,o instanceof y?(this.routerState=this.serializer.serialize(this.router.routerState.snapshot),this.trigger!==c.STORE&&(this.storeState=u,this.dispatchRouterRequest(o))):o instanceof T?(s=o,!r&&this.trigger!==c.STORE&&this.dispatchRouterNavigation(o)):o instanceof L?(this.dispatchRouterCancel(o),this.reset()):o instanceof A?(this.dispatchRouterError(o),this.reset()):o instanceof D&&(this.trigger!==c.STORE&&(r&&this.dispatchRouterNavigation(s),this.dispatchRouterNavigated(o)),this.reset())})}dispatchRouterRequest(r){this.dispatchRouterAction(Z,{event:r})}dispatchRouterNavigation(r){let s=this.serializer.serialize(r.state);this.dispatchRouterAction(O,{routerState:s,event:new T(r.id,r.url,r.urlAfterRedirects,s)})}dispatchRouterCancel(r){this.dispatchRouterAction(P,{storeState:this.storeState,event:r})}dispatchRouterError(r){this.dispatchRouterAction(U,{storeState:this.storeState,event:new A(r.id,r.url,`${r}`)})}dispatchRouterNavigated(r){let s=this.serializer.serialize(this.router.routerState.snapshot);this.dispatchRouterAction($,{event:r,routerState:s})}dispatchRouterAction(r,s){this.trigger=c.ROUTER;try{this.store.dispatch({type:r,payload:M(C({routerState:this.routerState},s),{event:this.config.routerState===0?s.event:{id:s.event.id,url:s.event.url,urlAfterRedirects:s.event.urlAfterRedirects}})})}finally{this.trigger=c.NONE}}reset(){this.trigger=c.NONE,this.storeState=null,this.routerState=null}static{this.\u0275fac=function(s){return new(s||e)(l(k),l(_),l(E),l(q),l(W),l(Q))}}static{this.\u0275prov=b({token:e,factory:e.\u0275fac})}}return e})();function st(e,t){return B(e)===B(t)}function B(e){return e?.length>0&&e[e.length-1]==="/"?e.substring(0,e.length-1):e}function Pt(e={}){return j([{provide:G,useValue:e},{provide:W,useFactory:it,deps:[G]},{provide:E,useClass:e.serializer?e.serializer:e.routerState===0?m:g},{provide:F,multi:!0,useFactory(){return()=>x(H)}},H])}function ot(){return R(J)}function X(e=ot()){let t=n(e,i=>i&&i.state),r=n(t,i=>i&&i.root),s=n(r,i=>{if(!i)return;let a=i;for(;a.firstChild;)a=a.firstChild;return a}),o=n(r,i=>i&&i.fragment),u=n(r,i=>i&&i.queryParams),v=i=>n(u,a=>a&&a[i]),f=n(s,i=>i&&i.params),Y=i=>n(f,a=>a&&a[i]),I=n(s,i=>i&&i.data),tt=i=>n(I,a=>a&&a[i]),et=n(t,i=>i&&i.url),rt=n(s,i=>{if(i?.routeConfig)return typeof i.routeConfig.title=="string"?i.routeConfig.title:i.title});return{selectCurrentRoute:s,selectFragment:o,selectQueryParams:u,selectQueryParam:v,selectRouteParams:f,selectRouteParam:Y,selectRouteData:I,selectRouteDataParam:tt,selectUrl:et,selectTitle:rt}}var nt=R("router"),h=X(nt),bt=h.selectCurrentRoute,xt=h.selectQueryParams,Ft=h.selectQueryParam,at=h.selectRouteParams,jt=h.selectRouteParam,qt=h.selectRouteData,ct=h.selectUrl,wt=n(at,ct,(e,t)=>({params:e,url:t}));export{O as a,Tt as b,Ot as c,Pt as d,X as e,xt as f,Ft as g,at as h,jt as i,qt as j,ct as k,wt as l};