{ "version": 3, "sources": ["src/app/content-block/guards/content-blocks.guard.ts"], "sourcesContent": ["import { Injectable } from '@angular/core';\r\n\r\n\r\nimport { Store } from '@ngrx/store';\r\nimport { tap, filter, take, switchMap, catchError, withLatestFrom, map } from 'rxjs/operators';\r\n\r\nimport * as fromStore from '../store';\r\nimport * as fromRoot from '../../store';\r\nimport { Observable, of } from 'rxjs';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class ContentBlocksGuard {\r\n constructor(private store: Store) {}\r\n\r\n canActivate(): Observable {\r\n return this.checkStore().pipe(\r\n switchMap(() => of(true)),\r\n catchError(() => of(false))\r\n );\r\n }\r\n\r\n checkStore(): Observable {\r\n return this.store.select(fromStore.getSelectedContentBlocksLoaded).pipe(\r\n withLatestFrom(this.store.select(fromRoot.getRouterState)),\r\n tap(([loaded, router]) => {\r\n if (!loaded) {\r\n const pageId = router.state.params?.pageId || router.state.data?.pageId;\r\n this.store.dispatch(fromStore.LoadContentBlocks({ pageId }));\r\n }\r\n }),\r\n map(([loaded, router]) => loaded),\r\n filter(loaded => loaded),\r\n take(1)\r\n );\r\n }\r\n}\r\n"], "mappings": "sMAWA,IAAaA,GAAkB,IAAA,CAAzB,IAAOA,EAAP,MAAOA,CAAkB,CAC7BC,YAAoBC,EAA0C,CAA1C,KAAAA,MAAAA,CAA6C,CAEjEC,aAAW,CACT,OAAO,KAAKC,WAAU,EAAGC,KACvBC,EAAU,IAAMC,EAAG,EAAI,CAAC,EACxBC,EAAW,IAAMD,EAAG,EAAK,CAAC,CAAC,CAE/B,CAEAH,YAAU,CACR,OAAO,KAAKF,MAAMO,OAAiBC,CAA8B,EAAEL,KACjEM,EAAe,KAAKT,MAAMO,OAAgBG,CAAc,CAAC,EACzDC,EAAI,CAAC,CAACC,EAAQC,CAAM,IAAK,CACvB,GAAI,CAACD,EAAQ,CACX,IAAME,EAASD,EAAOE,MAAMC,QAAQF,QAAUD,EAAOE,MAAME,MAAMH,OACjE,KAAKd,MAAMkB,SAAmBC,EAAkB,CAAEL,OAAAA,CAAM,CAAE,CAAC,EAE/D,CAAC,EACDM,EAAI,CAAC,CAACR,EAAQC,CAAM,IAAMD,CAAM,EAChCS,EAAOT,GAAUA,CAAM,EACvBU,EAAK,CAAC,CAAC,CAEX,yCAvBWxB,GAAkByB,EAAAC,CAAA,CAAA,CAAA,wBAAlB1B,EAAkB2B,QAAlB3B,EAAkB4B,UAAAC,WADL,MAAM,CAAA,EAC1B,IAAO7B,EAAP8B,SAAO9B,CAAkB,GAAA", "names": ["ContentBlocksGuard", "constructor", "store", "canActivate", "checkStore", "pipe", "switchMap", "of", "catchError", "select", "getSelectedContentBlocksLoaded", "withLatestFrom", "getRouterState", "tap", "loaded", "router", "pageId", "state", "params", "data", "dispatch", "LoadContentBlocks", "map", "filter", "take", "\u0275\u0275inject", "Store", "factory", "\u0275fac", "providedIn", "_ContentBlocksGuard"] }