{ "version": 3, "sources": ["apps/partner-center-client/src/app/core/guards/pending-changes-guard.service.ts"], "sourcesContent": ["import { Directive, HostListener, Injectable } from '@angular/core';\n\nimport { Observable } from 'rxjs';\n\nexport function displayPendingChangesDialog(): boolean {\n const message =\n 'You have unsaved changes. Press Cancel to go back and save these changes, or OK to lose these changes.';\n return confirm(message);\n}\n\n@Directive()\n// tslint:disable-next-line:directive-class-suffix\nexport abstract class ComponentCanDeactivate {\n abstract canDeactivate(): boolean | Observable;\n\n @HostListener('window:beforeunload', ['$event'])\n unloadNotification($event: any): void {\n if (!this.canDeactivate()) {\n $event.returnValue = true;\n }\n }\n\n // If you want your own dialog, you could override this method\n pendingChangesDialog(): boolean | Observable {\n return displayPendingChangesDialog();\n }\n}\n\n@Injectable({ providedIn: 'root' })\nexport class PendingChangesGuard {\n canDeactivate(component: ComponentCanDeactivate): boolean | Observable {\n if (component.canDeactivate()) {\n return true;\n }\n return component.pendingChangesDialog();\n }\n}\n"], "mappings": "iEAIM,SAAUA,GAA2B,CAGzC,OAAOC,QADL,wGACoB,CACxB,CAIA,IAAsBC,GAAsB,IAAA,CAAtC,IAAgBA,EAAhB,MAAgBA,CAAsB,CAI1CC,mBAAmBC,EAAW,CACvB,KAAKC,cAAa,IACrBD,EAAOE,YAAc,GAEzB,CAGAC,sBAAoB,CAClB,OAAOP,EAA2B,CACpC,yCAboBE,EAAsB,sBAAtBA,EAAsBM,aAAA,SAAAC,EAAAC,EAAA,CAAAD,EAAA,GAAtBE,EAAA,eAAA,SAAAP,EAAA,CAAA,OAAAM,EAAAP,mBAAAC,CAAA,CACrB,EAAA,GAAAQ,CAAA,KADK,IAAgBV,EAAhBW,SAAgBX,CAAsB,GAAA,EAiB/BY,GAAmB,IAAA,CAA1B,IAAOA,EAAP,MAAOA,CAAmB,CAC9BT,cAAcU,EAAiC,CAC7C,OAAIA,EAAUV,cAAa,EAClB,GAEFU,EAAUR,qBAAoB,CACvC,yCANWO,EAAmB,wBAAnBA,EAAmBE,QAAnBF,EAAmBG,UAAAC,WADN,MAAM,CAAA,EAC1B,IAAOJ,EAAPK,SAAOL,CAAmB,GAAA", "names": ["displayPendingChangesDialog", "confirm", "ComponentCanDeactivate", "unloadNotification", "$event", "canDeactivate", "returnValue", "pendingChangesDialog", "hostBindings", "rf", "ctx", "\u0275\u0275listener", "\u0275\u0275resolveWindow", "_ComponentCanDeactivate", "PendingChangesGuard", "component", "factory", "\u0275fac", "providedIn", "_PendingChangesGuard"] }