@coolon/angular-ui-powerups 0.0.98 → 0.0.102

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +2036 -1518
  2. package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
  3. package/bundles/coolon-angular-ui-powerups.umd.min.js +1 -1
  4. package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
  5. package/coolon-angular-ui-powerups.d.ts +19 -19
  6. package/coolon-angular-ui-powerups.metadata.json +1 -1
  7. package/esm2015/coolon-angular-ui-powerups.js +19 -19
  8. package/esm2015/index.js +2 -2
  9. package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +20 -5
  10. package/esm2015/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.js +13 -3
  11. package/esm2015/lib/interaction/index.js +5 -4
  12. package/esm2015/lib/interaction/interaction-context-base.js +21 -8
  13. package/esm2015/lib/interaction/interaction-context.js +53 -46
  14. package/esm2015/lib/interaction/interaction.module.js +3 -3
  15. package/esm2015/lib/interaction/services/interaction.service.js +232 -0
  16. package/esm2015/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context-factory.js +62 -0
  17. package/esm2015/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context.js +145 -0
  18. package/esm2015/lib/interaction/services/modal-interaction-context.factory.js +17 -0
  19. package/esm2015/lib/place/components/place-outlet/place-outlet.component.js +3 -3
  20. package/esm2015/lib/place/guards/navigation-state.js +406 -262
  21. package/esm2015/lib/place/guards/place-component-deactivation-handler.js +63 -28
  22. package/esm2015/lib/place/guards/place.guard.js +215 -0
  23. package/esm2015/lib/place/index.js +2 -3
  24. package/esm2015/lib/place/place-router.js +161 -118
  25. package/esm2015/lib/place/url-snapshot.js +124 -36
  26. package/esm2015/public_api.js +3 -3
  27. package/esm5/coolon-angular-ui-powerups.js +19 -19
  28. package/esm5/index.js +2 -2
  29. package/esm5/lib/interaction/components/activity-container/activity-container.component.js +24 -14
  30. package/esm5/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.js +10 -3
  31. package/esm5/lib/interaction/index.js +5 -4
  32. package/esm5/lib/interaction/interaction-context-base.js +25 -8
  33. package/esm5/lib/interaction/interaction-context.js +81 -56
  34. package/esm5/lib/interaction/interaction.module.js +3 -3
  35. package/esm5/lib/interaction/services/interaction.service.js +280 -0
  36. package/esm5/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context-factory.js +65 -0
  37. package/esm5/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context.js +170 -0
  38. package/esm5/lib/interaction/services/modal-interaction-context.factory.js +27 -0
  39. package/esm5/lib/place/components/place-outlet/place-outlet.component.js +3 -3
  40. package/esm5/lib/place/guards/navigation-state.js +552 -304
  41. package/esm5/lib/place/guards/place-component-deactivation-handler.js +73 -27
  42. package/esm5/lib/place/guards/place.guard.js +300 -0
  43. package/esm5/lib/place/index.js +2 -3
  44. package/esm5/lib/place/place-router.js +199 -137
  45. package/esm5/lib/place/url-snapshot.js +153 -42
  46. package/esm5/public_api.js +3 -3
  47. package/fesm2015/coolon-angular-ui-powerups.js +1636 -1300
  48. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  49. package/fesm5/coolon-angular-ui-powerups.js +1985 -1466
  50. package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
  51. package/lib/interaction/components/activity-container/activity-container.component.d.ts +1 -0
  52. package/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.d.ts +3 -1
  53. package/lib/interaction/index.d.ts +4 -3
  54. package/lib/interaction/interaction-context-base.d.ts +3 -1
  55. package/lib/interaction/interaction-context.d.ts +11 -13
  56. package/lib/interaction/services/interaction.service.d.ts +46 -0
  57. package/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context-factory.d.ts +15 -0
  58. package/lib/interaction/services/{dialog-interaction-context.d.ts → mat-dialog-interaction/dialog-interaction-context.d.ts} +2 -2
  59. package/lib/interaction/services/modal-interaction-context.factory.d.ts +4 -0
  60. package/lib/place/guards/navigation-state.d.ts +83 -49
  61. package/lib/place/guards/place-component-deactivation-handler.d.ts +7 -4
  62. package/lib/place/guards/{abstract-place.guard.d.ts → place.guard.d.ts} +9 -4
  63. package/lib/place/index.d.ts +1 -2
  64. package/lib/place/place-router.d.ts +17 -22
  65. package/lib/place/url-snapshot.d.ts +23 -6
  66. package/package.json +1 -1
  67. package/schematics/place-routes/place-def.js +1 -0
  68. package/schematics/place-routes/place-def.js.map +1 -1
  69. package/schematics/place-routes/templates/place-routes.ts.template +10 -11
  70. package/styles/styles.scss +1 -1
  71. package/esm2015/lib/interaction/services/dialog-interaction-context.js +0 -163
  72. package/esm2015/lib/interaction/services/dialog-interaction.service.js +0 -151
  73. package/esm2015/lib/interaction/services/modal-interaction.service.js +0 -109
  74. package/esm2015/lib/place/guards/abstract-place.guard.js +0 -165
  75. package/esm2015/lib/place/guards/interaction.guard.js +0 -113
  76. package/esm5/lib/interaction/services/dialog-interaction-context.js +0 -188
  77. package/esm5/lib/interaction/services/dialog-interaction.service.js +0 -179
  78. package/esm5/lib/interaction/services/modal-interaction.service.js +0 -153
  79. package/esm5/lib/place/guards/abstract-place.guard.js +0 -212
  80. package/esm5/lib/place/guards/interaction.guard.js +0 -125
  81. package/lib/interaction/services/dialog-interaction.service.d.ts +0 -24
  82. package/lib/interaction/services/modal-interaction.service.d.ts +0 -15
  83. package/lib/place/guards/interaction.guard.d.ts +0 -17
@@ -1,24 +1,24 @@
1
1
  import { DOCUMENT, CommonModule, Location } from '@angular/common';
2
- import { Directive, ElementRef, Inject, Input, HostListener, NgZone, NgModule, EventEmitter, Output, Component, InjectionToken, Injector, ComponentFactoryResolver, ViewContainerRef, ViewChild, ViewChildren, Injectable, ɵɵdefineInjectable, ɵɵinject, Optional, SkipSelf, HostBinding, INJECTOR } from '@angular/core';
2
+ import { Directive, ElementRef, Inject, Input, HostListener, NgZone, NgModule, EventEmitter, Output, Component, InjectionToken, Injector, ComponentFactoryResolver, ViewContainerRef, ViewChild, ViewChildren, Injectable, ɵɵdefineInjectable, ɵɵinject, Optional, SkipSelf, HostBinding } from '@angular/core';
3
3
  import { FormsModule } from '@angular/forms';
4
- import { MatInputModule, MatFormFieldModule, MatSelectModule, MatDialog, MatButtonModule, MatDialogModule, MatTabsModule as MatTabsModule$1, MatProgressSpinnerModule } from '@angular/material';
4
+ import { MatInputModule, MatFormFieldModule, MatSelectModule, MatButtonModule, MatDialogModule, MatTabsModule as MatTabsModule$1, MatProgressSpinnerModule, MatDialog } from '@angular/material';
5
5
  import { MatTabsModule } from '@angular/material/tabs';
6
6
  import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7
- import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, EventListenerList, DelegatingListModel, Deferred, MutableStream, MutableValueModel, MutableListModel, Binding, Trace, Guard as Guard$1, StoreInValueModel, Command, OptionsHelper, ValueHolder } from '@coolon/pectin';
7
+ import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, Trace, DelegatingListModel, Deferred, MutableStream, MutableValueModel, MutableListModel, Binding, Guard, StoreInValueModel, Command, OptionsHelper, ValueHolder } from '@coolon/pectin';
8
8
  import { __decorate, __metadata, __awaiter } from 'tslib';
9
9
  import { PortalModule } from '@angular/cdk/portal';
10
- import { RouterModule, NavigationStart, NavigationCancel, NavigationError, NavigationEnd, UrlSegment, Router, UrlSerializer, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
11
- import ___default, { last, isNil, isEqual } from 'lodash';
10
+ import { RouterModule, NavigationStart, NavigationCancel, UrlSegment, NavigationEnd, NavigationError, Router, UrlSerializer } from '@angular/router';
12
11
  import { assert as assert$1, Opts, Klass } from '@coolon/typescript-utilities';
13
- import { MatDialogConfig, MatDialog as MatDialog$1, MAT_DIALOG_DEFAULT_OPTIONS } from '@angular/material/dialog';
14
12
  import { MatIconModule } from '@angular/material/icon';
15
13
  import { MatListModule } from '@angular/material/list';
16
14
  import { MatTooltipModule } from '@angular/material/tooltip';
17
15
  import { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';
18
16
  import { Memoize as Memoize$1 } from '@typescript-plus/fast-memoize-decorator';
19
17
  import 'reflect-metadata';
18
+ import ___default, { isNil, isEqual } from 'lodash';
20
19
  import { style, query, group, animate, trigger, transition } from '@angular/animations';
21
20
  import ResizeObserver from 'resize-observer-polyfill';
21
+ import { MatDialogConfig, MAT_DIALOG_DEFAULT_OPTIONS, MatDialog as MatDialog$1 } from '@angular/material/dialog';
22
22
  import { Observable } from 'rxjs';
23
23
 
24
24
  /**
@@ -896,10 +896,6 @@ if (false) {
896
896
  * @abstract
897
897
  */
898
898
  class InteractionContext extends GarbageCollector {
899
- constructor() {
900
- super(...arguments);
901
- this.activityListeners = new EventListenerList();
902
- }
903
899
  /**
904
900
  * Returns true if an activity is currently running.
905
901
  * @return {?}
@@ -908,49 +904,76 @@ class InteractionContext extends GarbageCollector {
908
904
  return this.active.value;
909
905
  }
910
906
  /**
911
- * @param {?} listener
912
907
  * @return {?}
913
908
  */
914
- addActivityListener(listener) {
915
- return this.activityListeners.add(listener);
909
+ dispose() {
910
+ // TODO: think about auto cancelling any outstanding activity on dispose.
911
+ // See NavigationState.Navigating for a use-case.
912
+ assert.isFalsey(this.isActive());
913
+ super.dispose();
916
914
  }
917
915
  /**
918
- * @protected
916
+ * Cancels the current activity and returns true the context is no longer active, false if
917
+ * there is still another activity running.
919
918
  * @return {?}
920
919
  */
921
- notifyActivityStarted() {
922
- this.activityListeners.fire((/**
923
- * @param {?} l
924
- * @return {?}
925
- */
926
- l => l.onActivityStarted()));
920
+ cancelCurrentActivity() {
921
+ return __awaiter(this, void 0, void 0, function* () {
922
+ const { when } = Dsl.disposeWith(this);
923
+ /** @type {?} */
924
+ const activity = yield this.getCurrentActivity();
925
+ return new Promise((/**
926
+ * @param {?} resolve
927
+ * @return {?}
928
+ */
929
+ resolve => {
930
+ when.valueOf(this.activeActivity)
931
+ .changes((/**
932
+ * @param {?} nextActivity
933
+ * @return {?}
934
+ */
935
+ nextActivity => {
936
+ resolve(!nextActivity);
937
+ }), { once: true });
938
+ activity.cancel();
939
+ }));
940
+ });
927
941
  }
928
942
  /**
929
- * @protected
930
943
  * @return {?}
931
944
  */
932
- notifyActivityFinished() {
933
- this.activityListeners.fire((/**
934
- * @param {?} l
935
- * @return {?}
936
- */
937
- l => l.onActivityFinished()));
945
+ abort() {
946
+ return __awaiter(this, void 0, void 0, function* () {
947
+ assert.isTruthy(this.isActive());
948
+ /** @type {?} */
949
+ let count = 1;
950
+ yield this.cancelCurrentActivity();
951
+ console.log(`aborted -> ${count++}`);
952
+ while (this.isActive()) {
953
+ yield this.cancelCurrentActivity();
954
+ console.log(`aborted -> ${count++}`);
955
+ }
956
+ });
938
957
  }
939
958
  }
959
+ __decorate([
960
+ Trace(),
961
+ __metadata("design:type", Function),
962
+ __metadata("design:paramtypes", []),
963
+ __metadata("design:returntype", Promise)
964
+ ], InteractionContext.prototype, "abort", null);
940
965
  if (false) {
941
- /**
942
- * @type {?}
943
- * @private
944
- */
945
- InteractionContext.prototype.activityListeners;
966
+ /** @type {?} */
967
+ InteractionContext.prototype.active;
946
968
  /** @type {?} */
947
969
  InteractionContext.prototype.activityList;
948
970
  /** @type {?} */
949
- InteractionContext.prototype.active;
971
+ InteractionContext.prototype.activeActivity;
950
972
  /**
951
973
  * Returns the activity that is currently active.
952
974
  * This model is only updated in the next tick after the view has been updated.
953
975
  * @abstract
976
+ * @protected
954
977
  * @return {?}
955
978
  */
956
979
  InteractionContext.prototype.getCurrentActivity = function () { };
@@ -991,23 +1014,6 @@ if (false) {
991
1014
  */
992
1015
  InteractionContext.prototype.confirmThen = function (confirm, activityType, data) { };
993
1016
  }
994
- (function (InteractionContext) {
995
- /**
996
- * @record
997
- */
998
- function Listener() { }
999
- InteractionContext.Listener = Listener;
1000
- if (false) {
1001
- /**
1002
- * @return {?}
1003
- */
1004
- Listener.prototype.onActivityStarted = function () { };
1005
- /**
1006
- * @return {?}
1007
- */
1008
- Listener.prototype.onActivityFinished = function () { };
1009
- }
1010
- })(InteractionContext || (InteractionContext = {}));
1011
1017
 
1012
1018
  /**
1013
1019
  * @fileoverview added by tsickle
@@ -1156,13 +1162,14 @@ class InteractionContextBase extends InteractionContext {
1156
1162
  */
1157
1163
  this._activityListDelegate = new DelegatingListModel();
1158
1164
  const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
1159
- when.listOf(this.activityList).becomesPopulated((/**
1160
- * @param {?} activities
1165
+ this._currentActivity = chain(this.activityList).last();
1166
+ when.valueOf(this._currentActivity).becomesTruthy((/**
1167
+ * @param {?} activity
1161
1168
  * @return {?}
1162
1169
  */
1163
- (activities) => {
1170
+ (activity) => {
1164
1171
  if (this.deferredGetCurrentActivity) {
1165
- this.deferredGetCurrentActivity.resolve(last(activities));
1172
+ this.deferredGetCurrentActivity.resolve(activity);
1166
1173
  this.deferredGetCurrentActivity = null;
1167
1174
  }
1168
1175
  }));
@@ -1181,6 +1188,12 @@ class InteractionContextBase extends InteractionContext {
1181
1188
  get activityList() {
1182
1189
  return this._activityListDelegate.readonly;
1183
1190
  }
1191
+ /**
1192
+ * @return {?}
1193
+ */
1194
+ get activeActivity() {
1195
+ return this._currentActivity;
1196
+ }
1184
1197
  /**
1185
1198
  * Returns the activity that is currently active.
1186
1199
  * This model is only updated in the next tick after the view has been updated.
@@ -1197,12 +1210,14 @@ class InteractionContextBase extends InteractionContext {
1197
1210
  return this.deferredGetCurrentActivity.promise;
1198
1211
  }
1199
1212
  else {
1200
- if (this.activityList.length < 1) {
1213
+ if (!this._currentActivity.value) {
1214
+ // we'be been asked before we've got any activities, create a deferred promise
1215
+ // that we resolve when the list populates.
1201
1216
  this.deferredGetCurrentActivity = Deferred.defer();
1202
1217
  return this.deferredGetCurrentActivity.promise;
1203
1218
  }
1204
1219
  else {
1205
- return last(this.activityList.value);
1220
+ return this._currentActivity.value;
1206
1221
  }
1207
1222
  }
1208
1223
  }
@@ -1276,6 +1291,11 @@ if (false) {
1276
1291
  * @private
1277
1292
  */
1278
1293
  InteractionContextBase.prototype.deferredGetCurrentActivity;
1294
+ /**
1295
+ * @type {?}
1296
+ * @private
1297
+ */
1298
+ InteractionContextBase.prototype._currentActivity;
1279
1299
  /**
1280
1300
  * @abstract
1281
1301
  * @protected
@@ -1480,6 +1500,12 @@ class TabContext {
1480
1500
  this._complete = true;
1481
1501
  this.activityCallbacks.onCancel(error);
1482
1502
  }
1503
+ /**
1504
+ * @return {?}
1505
+ */
1506
+ dispose() {
1507
+ this.component.dispose();
1508
+ }
1483
1509
  }
1484
1510
  if (false) {
1485
1511
  /**
@@ -1562,9 +1588,6 @@ class ActivityContainerComponent extends InteractionContextBase {
1562
1588
  get initialActivityOutletContext() {
1563
1589
  return this._initialActivityOutletContext.value;
1564
1590
  }
1565
- // get isFinished() {
1566
- // return !this._initialActivityOutletContext;
1567
- // }
1568
1591
  /**
1569
1592
  * @return {?}
1570
1593
  */
@@ -1632,6 +1655,7 @@ class ActivityContainerComponent extends InteractionContextBase {
1632
1655
  * @return {?}
1633
1656
  */
1634
1657
  finishInitialActivity() {
1658
+ this.updateActivityList();
1635
1659
  this._initialActivityOutletContext.value = null;
1636
1660
  this.initialActivityOutletContextEvent.emit(null);
1637
1661
  }
@@ -1651,12 +1675,23 @@ class ActivityContainerComponent extends InteractionContextBase {
1651
1675
  */
1652
1676
  cleanupStaleNestedActivities() {
1653
1677
  if (this.tabs.selectedIndex < this.activityTabs.length - 1) {
1678
+ /** @type {?} */
1679
+ const tabs = this.activityTabs.value;
1680
+ /** @type {?} */
1681
+ const remainingActivities = tabs.slice(0, 1 + this.tabs.selectedIndex);
1682
+ /** @type {?} */
1683
+ const finishedActivityTabs = tabs.slice(1 + this.tabs.selectedIndex);
1684
+ finishedActivityTabs.forEach((/**
1685
+ * @param {?} a
1686
+ * @return {?}
1687
+ */
1688
+ a => a.dispose()));
1654
1689
  this.activityTabs.runInTransaction((/**
1655
1690
  * @param {?} draft
1656
1691
  * @return {?}
1657
1692
  */
1658
1693
  draft => {
1659
- draft.value = draft.value.slice(0, 1 + this.tabs.selectedIndex);
1694
+ draft.value = remainingActivities;
1660
1695
  }));
1661
1696
  }
1662
1697
  }
@@ -1757,6 +1792,249 @@ if (false) {
1757
1792
  ActivityContainerComponent.prototype._activityList;
1758
1793
  }
1759
1794
 
1795
+ /**
1796
+ * @fileoverview added by tsickle
1797
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1798
+ */
1799
+ /**
1800
+ * @abstract
1801
+ */
1802
+ class ModalInteractionContextFactory {
1803
+ }
1804
+ if (false) {
1805
+ /**
1806
+ * @abstract
1807
+ * @return {?}
1808
+ */
1809
+ ModalInteractionContextFactory.prototype.createInteractionContext = function () { };
1810
+ }
1811
+
1812
+ /**
1813
+ * @fileoverview added by tsickle
1814
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1815
+ */
1816
+ /** @type {?} */
1817
+ let inplaceMonitorCount = 0;
1818
+ class InteractionService {
1819
+ /**
1820
+ * @param {?} modelInteractionContextFactory
1821
+ */
1822
+ constructor(modelInteractionContextFactory) {
1823
+ this.modelInteractionContextFactory = modelInteractionContextFactory;
1824
+ this.garbage = new GarbageCollector();
1825
+ this.exclusiveContext = new MutableValueModel();
1826
+ this._activeModalInteractionContextModel = new MutableValueModel();
1827
+ this._activeInlineInteractionContextModel = new MutableValueModel();
1828
+ const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this.garbage);
1829
+ this._activeInteractionContext = chain(this._activeModalInteractionContextModel)
1830
+ .otherwise(this._activeInlineInteractionContextModel)
1831
+ .pluck('interactionContext');
1832
+ this.active = chain(this._activeInteractionContext).isNotNil();
1833
+ this.modelInteractionActive = chain(this._activeModalInteractionContextModel).isNotNil();
1834
+ this.inlineInteractionActive = chain(this._activeInlineInteractionContextModel).isNotNil();
1835
+ // TODO: chain.concat(listOrValueModels) would be nice.
1836
+ this.activeInteractionContextIds = chain(new MutableListModel())
1837
+ .append(this._activeInlineInteractionContextModel)
1838
+ .append(this._activeModalInteractionContextModel)
1839
+ .rejectNil()
1840
+ .pluck('id');
1841
+ }
1842
+ /**
1843
+ * @return {?}
1844
+ */
1845
+ isActive() {
1846
+ return this.active.value;
1847
+ }
1848
+ /**
1849
+ * @return {?}
1850
+ */
1851
+ isModalActive() {
1852
+ return this.modelInteractionActive.value;
1853
+ }
1854
+ /**
1855
+ * @param {?} disposable
1856
+ * @return {?}
1857
+ */
1858
+ createModalInteractionContextFor(disposable) {
1859
+ /** @type {?} */
1860
+ const context = this.modelInteractionContextFactory.createInteractionContext();
1861
+ disposable.registerDisposable(new InteractionService.Monitor('modal', context, this._activeModalInteractionContextModel, this.exclusiveContext));
1862
+ return context;
1863
+ }
1864
+ /**
1865
+ * @param {?} interactionContext
1866
+ * @return {?}
1867
+ */
1868
+ _registerInplaceInteractionContext(interactionContext) {
1869
+ interactionContext.registerDisposable(new InteractionService.Monitor(`ip${++inplaceMonitorCount}`, interactionContext, this._activeInlineInteractionContextModel, this.exclusiveContext));
1870
+ }
1871
+ // @Trace()
1872
+ /**
1873
+ * @return {?}
1874
+ */
1875
+ getActiveContext() {
1876
+ assert$1.isTruthy(this.isActive());
1877
+ return this._activeInteractionContext.value;
1878
+ }
1879
+ /**
1880
+ * Creates an interaction context that will prevent any other contexts from starting an
1881
+ * activity until it is disposed. This is intended for use by the router for passing
1882
+ * to PlaceComponent.canDeactivate(interactionContext). This ensures components don't
1883
+ * try and interact in a way that we can't track and synchronise with the browser back
1884
+ * button.
1885
+ * @return {?}
1886
+ */
1887
+ _createExclusiveModalInteractionContext() {
1888
+ this.exclusiveContext.value = this.modelInteractionContextFactory.createInteractionContext();
1889
+ /** @type {?} */
1890
+ const self = this;
1891
+ this.exclusiveContext.value.registerDisposable({
1892
+ /**
1893
+ * @return {?}
1894
+ */
1895
+ dispose() {
1896
+ self.exclusiveContext.value = null;
1897
+ }
1898
+ });
1899
+ return this.exclusiveContext.value;
1900
+ }
1901
+ }
1902
+ InteractionService.decorators = [
1903
+ { type: Injectable, args: [{
1904
+ providedIn: 'root'
1905
+ },] }
1906
+ ];
1907
+ /** @nocollapse */
1908
+ InteractionService.ctorParameters = () => [
1909
+ { type: ModalInteractionContextFactory }
1910
+ ];
1911
+ /** @nocollapse */ InteractionService.ngInjectableDef = ɵɵdefineInjectable({ factory: function InteractionService_Factory() { return new InteractionService(ɵɵinject(ModalInteractionContextFactory)); }, token: InteractionService, providedIn: "root" });
1912
+ if (false) {
1913
+ /**
1914
+ * @type {?}
1915
+ * @private
1916
+ */
1917
+ InteractionService.prototype.garbage;
1918
+ /** @type {?} */
1919
+ InteractionService.prototype.active;
1920
+ /**
1921
+ * @type {?}
1922
+ * @private
1923
+ */
1924
+ InteractionService.prototype.exclusiveContext;
1925
+ /**
1926
+ * @type {?}
1927
+ * @private
1928
+ */
1929
+ InteractionService.prototype._activeModalInteractionContextModel;
1930
+ /**
1931
+ * @type {?}
1932
+ * @private
1933
+ */
1934
+ InteractionService.prototype._activeInlineInteractionContextModel;
1935
+ /**
1936
+ * @type {?}
1937
+ * @private
1938
+ */
1939
+ InteractionService.prototype._activeInteractionContext;
1940
+ /** @type {?} */
1941
+ InteractionService.prototype.activeInteractionContextIds;
1942
+ /** @type {?} */
1943
+ InteractionService.prototype.modelInteractionActive;
1944
+ /** @type {?} */
1945
+ InteractionService.prototype.inlineInteractionActive;
1946
+ /** @type {?} */
1947
+ InteractionService.prototype.modelInteractionContextFactory;
1948
+ }
1949
+ (function (InteractionService) {
1950
+ /**
1951
+ * @record
1952
+ */
1953
+ function Callback() { }
1954
+ InteractionService.Callback = Callback;
1955
+ if (false) {
1956
+ /**
1957
+ * @param {?} monitor
1958
+ * @return {?}
1959
+ */
1960
+ Callback.prototype.onStarted = function (monitor) { };
1961
+ /**
1962
+ * @param {?} monitor
1963
+ * @return {?}
1964
+ */
1965
+ Callback.prototype.onFinished = function (monitor) { };
1966
+ }
1967
+ class Monitor extends GarbageCollector {
1968
+ /**
1969
+ * @param {?} id
1970
+ * @param {?} interactionContext
1971
+ * @param {?} currentActiveMonitor
1972
+ * @param {?} exclusiveContext
1973
+ */
1974
+ constructor(id, interactionContext, currentActiveMonitor, exclusiveContext) {
1975
+ super();
1976
+ this.id = id;
1977
+ this.interactionContext = interactionContext;
1978
+ this.currentActiveMonitor = currentActiveMonitor;
1979
+ this.exclusiveContext = exclusiveContext;
1980
+ const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
1981
+ when.valueOf(interactionContext.active).becomesTruthy((/**
1982
+ * @return {?}
1983
+ */
1984
+ () => this.onStarted()));
1985
+ when.valueOf(interactionContext.active).becomesFalsey((/**
1986
+ * @return {?}
1987
+ */
1988
+ () => this.onFinished()));
1989
+ interactionContext.registerDisposable(this);
1990
+ }
1991
+ /**
1992
+ * @protected
1993
+ * @return {?}
1994
+ */
1995
+ onStarted() {
1996
+ this.assertCanStart();
1997
+ this.currentActiveMonitor.value = this;
1998
+ }
1999
+ /**
2000
+ * @private
2001
+ * @return {?}
2002
+ */
2003
+ assertCanStart() {
2004
+ assert$1.isFalsey(this.currentActiveMonitor.value);
2005
+ if (this.exclusiveContext.value && this.interactionContext !== this.exclusiveContext.value) {
2006
+ lang.illegalState('Interaction started while exclusive lock active. This is usually because you using a different context during place.canDeactivate(interactionContext)');
2007
+ }
2008
+ }
2009
+ /**
2010
+ * @protected
2011
+ * @return {?}
2012
+ */
2013
+ onFinished() {
2014
+ this.assertCurrentlyActive();
2015
+ this.currentActiveMonitor.value = null;
2016
+ }
2017
+ /**
2018
+ * @private
2019
+ * @return {?}
2020
+ */
2021
+ assertCurrentlyActive() {
2022
+ assert$1.isTruthy(this.currentActiveMonitor.value === this);
2023
+ }
2024
+ }
2025
+ InteractionService.Monitor = Monitor;
2026
+ if (false) {
2027
+ /** @type {?} */
2028
+ Monitor.prototype.id;
2029
+ /** @type {?} */
2030
+ Monitor.prototype.interactionContext;
2031
+ /** @type {?} */
2032
+ Monitor.prototype.currentActiveMonitor;
2033
+ /** @type {?} */
2034
+ Monitor.prototype.exclusiveContext;
2035
+ }
2036
+ })(InteractionService || (InteractionService = {}));
2037
+
1760
2038
  /**
1761
2039
  * @fileoverview added by tsickle
1762
2040
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -1765,9 +2043,14 @@ if (false) {
1765
2043
  * @template D, R, E
1766
2044
  */
1767
2045
  class InplaceInteractionContextComponent extends InteractionContextBase {
1768
- constructor() {
2046
+ /**
2047
+ * @param {?} interactionService
2048
+ */
2049
+ constructor(interactionService) {
1769
2050
  super();
2051
+ this.interactionService = interactionService;
1770
2052
  this._active = new MutableValueModel(false);
2053
+ this.interactionService._registerInplaceInteractionContext(this);
1771
2054
  }
1772
2055
  /**
1773
2056
  * @return {?}
@@ -1829,7 +2112,9 @@ InplaceInteractionContextComponent.decorators = [
1829
2112
  }] }
1830
2113
  ];
1831
2114
  /** @nocollapse */
1832
- InplaceInteractionContextComponent.ctorParameters = () => [];
2115
+ InplaceInteractionContextComponent.ctorParameters = () => [
2116
+ { type: InteractionService }
2117
+ ];
1833
2118
  InplaceInteractionContextComponent.propDecorators = {
1834
2119
  interactionContext: [{ type: ViewChild, args: ['activityContainer', { static: true },] }]
1835
2120
  };
@@ -1843,6 +2128,8 @@ if (false) {
1843
2128
  * @private
1844
2129
  */
1845
2130
  InplaceInteractionContextComponent.prototype._active;
2131
+ /** @type {?} */
2132
+ InplaceInteractionContextComponent.prototype.interactionService;
1846
2133
  }
1847
2134
 
1848
2135
  /**
@@ -1863,409 +2150,6 @@ InteractionOutletComponent.decorators = [
1863
2150
  /** @nocollapse */
1864
2151
  InteractionOutletComponent.ctorParameters = () => [];
1865
2152
 
1866
- /**
1867
- * @fileoverview added by tsickle
1868
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1869
- */
1870
- class DialogInteractionContext extends InteractionContextBase {
1871
- /**
1872
- * @param {?} dialogService
1873
- * @param {?} config
1874
- */
1875
- constructor(dialogService, config) {
1876
- super();
1877
- this.dialogService = dialogService;
1878
- this.config = config;
1879
- this._activeModel = new MutableValueModel(false);
1880
- assert$1.notNil(dialogService);
1881
- this.onDispose((/**
1882
- * @return {?}
1883
- */
1884
- () => {
1885
- if (this.isActive()) {
1886
- lang.illegalState('Dispose called while active.');
1887
- }
1888
- }));
1889
- }
1890
- /**
1891
- * @return {?}
1892
- */
1893
- get active() {
1894
- return this._activeModel.readonly;
1895
- }
1896
- /**
1897
- * @protected
1898
- * @template D, R, E
1899
- * @param {?} activityType
1900
- * @param {?} data
1901
- * @param {?=} disableClose
1902
- * @return {?}
1903
- */
1904
- _startActivity(activityType, data, disableClose = true) {
1905
- if (this.isActive()) {
1906
- lang.illegalState(`Activity already in progress: ${this.activityList.value.map((/**
1907
- * @param {?} a
1908
- * @return {?}
1909
- */
1910
- a => a.constructor.name)).join(', ')}`);
1911
- }
1912
- this._activeModel.value = true;
1913
- this.notifyActivityStarted();
1914
- /** @type {?} */
1915
- const config = Object.assign({}, this.config, {
1916
- data,
1917
- disableClose,
1918
- panelClass: 'dialog-interaction-service'
1919
- });
1920
- /** @type {?} */
1921
- const self = this;
1922
- /** @type {?} */
1923
- const matDialogRef = (/** @type {?} */ (this.dialogService.open(ActivityContainerComponent, config)));
1924
- return new Promise((/**
1925
- * @param {?} resolve
1926
- * @param {?} reject
1927
- * @return {?}
1928
- */
1929
- (resolve, reject) => {
1930
- /** @type {?} */
1931
- const activityContainer = matDialogRef.componentInstance;
1932
- self.safelyUpdateActivityListDelegate(activityContainer.activityList);
1933
- activityContainer.initialActivityOutletContext = {
1934
- activityClass: activityType,
1935
- activityData: data,
1936
- /**
1937
- * @param {?} result
1938
- * @return {?}
1939
- */
1940
- onDone(result) {
1941
- resolve(result);
1942
- matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
1943
- },
1944
- /**
1945
- * @param {?} error
1946
- * @return {?}
1947
- */
1948
- onCancel(error) {
1949
- reject(error);
1950
- matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
1951
- }
1952
- };
1953
- // we need to check if our onDone/onCancel methods above we called or if we were
1954
- // closed by the user clicking the backdrop. If the later then we need to reject
1955
- // our promise.
1956
- matDialogRef.afterClosed().subscribe((/**
1957
- * @param {?} promiseAlreadyFinished
1958
- * @return {?}
1959
- */
1960
- promiseAlreadyFinished => {
1961
- if (!promiseAlreadyFinished) {
1962
- reject('auto-closed');
1963
- }
1964
- }));
1965
- matDialogRef.updateSize();
1966
- matDialogRef.afterOpened().subscribe((/**
1967
- * @param {?} promiseAlreadyFinished
1968
- * @return {?}
1969
- */
1970
- promiseAlreadyFinished => {
1971
- matDialogRef.updateSize();
1972
- }));
1973
- })).finally((/**
1974
- * @return {?}
1975
- */
1976
- () => {
1977
- this._activeModel.value = false;
1978
- this.notifyActivityFinished();
1979
- self.safelyUpdateActivityListDelegate(null);
1980
- }));
1981
- }
1982
- /**
1983
- * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
1984
- * @param {?} delegate
1985
- * @return {?}
1986
- */
1987
- safelyUpdateActivityListDelegate(delegate) {
1988
- setTimeout((/**
1989
- * @return {?}
1990
- */
1991
- () => this.setActivityList(delegate)));
1992
- }
1993
- }
1994
- DialogInteractionContext.decorators = [
1995
- { type: Injectable, args: [{
1996
- providedIn: 'root'
1997
- },] }
1998
- ];
1999
- /** @nocollapse */
2000
- DialogInteractionContext.ctorParameters = () => [
2001
- { type: MatDialog },
2002
- { type: MatDialogConfig }
2003
- ];
2004
- /** @nocollapse */ DialogInteractionContext.ngInjectableDef = ɵɵdefineInjectable({ factory: function DialogInteractionContext_Factory() { return new DialogInteractionContext(ɵɵinject(MatDialog$1), ɵɵinject(MatDialogConfig)); }, token: DialogInteractionContext, providedIn: "root" });
2005
- if (false) {
2006
- /**
2007
- * @type {?}
2008
- * @private
2009
- */
2010
- DialogInteractionContext.prototype._activeModel;
2011
- /**
2012
- * @type {?}
2013
- * @private
2014
- */
2015
- DialogInteractionContext.prototype.dialogService;
2016
- /** @type {?} */
2017
- DialogInteractionContext.prototype.config;
2018
- }
2019
-
2020
- /**
2021
- * @fileoverview added by tsickle
2022
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2023
- */
2024
- class Guard extends ValueModel {
2025
- constructor() {
2026
- super({ initialValue: false });
2027
- }
2028
- /**
2029
- * @return {?}
2030
- */
2031
- get value() {
2032
- return this.store.read();
2033
- }
2034
- /**
2035
- * @template R
2036
- * @param {?} fun
2037
- * @return {?}
2038
- */
2039
- whileTrue(fun) {
2040
- this.startTransaction().commit(true);
2041
- try {
2042
- return fun();
2043
- }
2044
- finally {
2045
- this.startTransaction().commit(false);
2046
- }
2047
- }
2048
- /**
2049
- * @template R
2050
- * @param {?} fun
2051
- * @param {?=} defaultValue
2052
- * @return {?}
2053
- */
2054
- runIfFalse(fun, defaultValue = null) {
2055
- return !this.value ? fun() : defaultValue;
2056
- }
2057
- }
2058
- /**
2059
- * @abstract
2060
- */
2061
- class ModalInteractionService extends GarbageCollector {
2062
- constructor() {
2063
- super();
2064
- this._activityListeners = new EventListenerList();
2065
- }
2066
- /**
2067
- * @return {?}
2068
- */
2069
- isActive() {
2070
- return this.active.value;
2071
- }
2072
- /**
2073
- * @param {?} listener
2074
- * @return {?}
2075
- */
2076
- addActivityListener(listener) {
2077
- return this._activityListeners.add(listener);
2078
- }
2079
- /**
2080
- * @protected
2081
- * @return {?}
2082
- */
2083
- notifyActivityStarted() {
2084
- this._activityListeners.fire((/**
2085
- * @param {?} l
2086
- * @return {?}
2087
- */
2088
- l => l.onActivityStarted()));
2089
- }
2090
- /**
2091
- * @protected
2092
- * @return {?}
2093
- */
2094
- notifyActivityFinished() {
2095
- this._activityListeners.fire((/**
2096
- * @param {?} l
2097
- * @return {?}
2098
- */
2099
- l => l.onActivityFinished()));
2100
- }
2101
- }
2102
- if (false) {
2103
- /**
2104
- * @type {?}
2105
- * @private
2106
- */
2107
- ModalInteractionService.prototype._activityListeners;
2108
- /** @type {?} */
2109
- ModalInteractionService.prototype.active;
2110
- /**
2111
- * @abstract
2112
- * @param {?} disposable
2113
- * @return {?}
2114
- */
2115
- ModalInteractionService.prototype.createInteractionContextFor = function (disposable) { };
2116
- /**
2117
- * @abstract
2118
- * @return {?}
2119
- */
2120
- ModalInteractionService.prototype.createExclusiveInteractionContext = function () { };
2121
- /**
2122
- * @abstract
2123
- * @return {?}
2124
- */
2125
- ModalInteractionService.prototype.getCurrentActivity = function () { };
2126
- }
2127
-
2128
- /**
2129
- * @fileoverview added by tsickle
2130
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2131
- */
2132
- /** @type {?} */
2133
- const DIALOG_INTERACTION_SERVICE_DEFAULTS = new InjectionToken('DIALOG_INTERACTION_SERVICE_DEFAULTS');
2134
- class DialogInteractionService extends ModalInteractionService {
2135
- /**
2136
- * @param {?} dialogService
2137
- * @param {?} dialogServiceDefaults
2138
- * @param {?} matDialogDefaultConfig
2139
- */
2140
- constructor(dialogService, dialogServiceDefaults, matDialogDefaultConfig) {
2141
- super();
2142
- this.dialogService = dialogService;
2143
- this.dialogServiceDefaults = dialogServiceDefaults;
2144
- this.matDialogDefaultConfig = matDialogDefaultConfig;
2145
- this._activeInteractionContextModel = new MutableValueModel();
2146
- assert$1.notNil(dialogService);
2147
- const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
2148
- this.active = chain(this._activeInteractionContextModel).isNotNil();
2149
- }
2150
- /**
2151
- * @param {?} disposable
2152
- * @return {?}
2153
- */
2154
- createInteractionContextFor(disposable) {
2155
- return disposable.registerDisposable(this._createInteractionContext());
2156
- }
2157
- /**
2158
- * @return {?}
2159
- */
2160
- _createInteractionContext() {
2161
- /** @type {?} */
2162
- const config = Object.assign({ autoFocus: false, hasBackdrop: true, closeOnNavigation: false }, this.matDialogDefaultConfig, this.dialogServiceDefaults);
2163
- /** @type {?} */
2164
- const self = this;
2165
- /** @type {?} */
2166
- const dialogInteractionContext = new DialogInteractionContext(this.dialogService, config);
2167
- dialogInteractionContext.registerDisposable(dialogInteractionContext.addActivityListener({
2168
- /**
2169
- * @return {?}
2170
- */
2171
- onActivityStarted() {
2172
- self.onActivityStarted(dialogInteractionContext);
2173
- },
2174
- /**
2175
- * @return {?}
2176
- */
2177
- onActivityFinished() {
2178
- self.onActivityFinished(dialogInteractionContext);
2179
- }
2180
- }));
2181
- return dialogInteractionContext;
2182
- }
2183
- /**
2184
- * @return {?}
2185
- */
2186
- createExclusiveInteractionContext() {
2187
- this.exclusiveContext = this._createInteractionContext();
2188
- /** @type {?} */
2189
- const self = this;
2190
- this.exclusiveContext.registerDisposable({
2191
- /**
2192
- * @return {?}
2193
- */
2194
- dispose() {
2195
- self.exclusiveContext = null;
2196
- }
2197
- });
2198
- return this.exclusiveContext;
2199
- }
2200
- // @Trace()
2201
- /**
2202
- * @param {?} dialogInteractionContext
2203
- * @return {?}
2204
- */
2205
- onActivityStarted(dialogInteractionContext) {
2206
- assert$1.isFalsey(this.isActive());
2207
- if (this.exclusiveContext && dialogInteractionContext !== this.exclusiveContext) {
2208
- lang.illegalState("Interaction started while exclusive lock active. This is usually because you using a different context during place.canDeactivate(interactionContext)");
2209
- }
2210
- this._activeInteractionContextModel.value = dialogInteractionContext;
2211
- this.notifyActivityStarted();
2212
- }
2213
- // @Trace()
2214
- /**
2215
- * @param {?} dialogInteractionContext
2216
- * @return {?}
2217
- */
2218
- onActivityFinished(dialogInteractionContext) {
2219
- assert$1.isTruthy(this._activeInteractionContextModel.value === dialogInteractionContext);
2220
- this._activeInteractionContextModel.value = null;
2221
- this.notifyActivityFinished();
2222
- }
2223
- /**
2224
- * @return {?}
2225
- */
2226
- getCurrentActivity() {
2227
- return __awaiter(this, void 0, void 0, function* () {
2228
- assert$1.isTruthy(this.isActive());
2229
- return this._activeInteractionContextModel.value.getCurrentActivity();
2230
- });
2231
- }
2232
- }
2233
- DialogInteractionService.decorators = [
2234
- { type: Injectable, args: [{
2235
- providedIn: 'root'
2236
- },] }
2237
- ];
2238
- /** @nocollapse */
2239
- DialogInteractionService.ctorParameters = () => [
2240
- { type: MatDialog },
2241
- { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [DIALOG_INTERACTION_SERVICE_DEFAULTS,] }] },
2242
- { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [MAT_DIALOG_DEFAULT_OPTIONS,] }] }
2243
- ];
2244
- /** @nocollapse */ DialogInteractionService.ngInjectableDef = ɵɵdefineInjectable({ factory: function DialogInteractionService_Factory() { return new DialogInteractionService(ɵɵinject(MatDialog$1), ɵɵinject(DIALOG_INTERACTION_SERVICE_DEFAULTS, 8), ɵɵinject(MAT_DIALOG_DEFAULT_OPTIONS, 8)); }, token: DialogInteractionService, providedIn: "root" });
2245
- if (false) {
2246
- /**
2247
- * @type {?}
2248
- * @private
2249
- */
2250
- DialogInteractionService.prototype._activeInteractionContextModel;
2251
- /** @type {?} */
2252
- DialogInteractionService.prototype.active;
2253
- /**
2254
- * @type {?}
2255
- * @private
2256
- */
2257
- DialogInteractionService.prototype.exclusiveContext;
2258
- /**
2259
- * @type {?}
2260
- * @private
2261
- */
2262
- DialogInteractionService.prototype.dialogService;
2263
- /** @type {?} */
2264
- DialogInteractionService.prototype.dialogServiceDefaults;
2265
- /** @type {?} */
2266
- DialogInteractionService.prototype.matDialogDefaultConfig;
2267
- }
2268
-
2269
2153
  /**
2270
2154
  * @fileoverview added by tsickle
2271
2155
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -2304,7 +2188,7 @@ InteractionModule.decorators = [
2304
2188
  AlertDialogComponent
2305
2189
  ],
2306
2190
  providers: [
2307
- DialogInteractionService,
2191
+ InteractionService,
2308
2192
  ]
2309
2193
  },] }
2310
2194
  ];
@@ -3082,57 +2966,89 @@ if (false) {
3082
2966
  class PlaceComponentDeactivationHandler {
3083
2967
  /**
3084
2968
  * @param {?} component
3085
- * @param {?} navigationSession
2969
+ * @param {?} navigationState
2970
+ * @param {?} isPrimaryComponent
3086
2971
  */
3087
- constructor(component, navigationSession) {
2972
+ constructor(component, navigationState, isPrimaryComponent) {
3088
2973
  this.component = component;
3089
- this.navigationSession = navigationSession;
2974
+ this.navigationState = navigationState;
2975
+ this.isPrimaryComponent = isPrimaryComponent;
2976
+ }
2977
+ /**
2978
+ * @return {?}
2979
+ */
2980
+ get interactionService() {
2981
+ return this.navigationState.interactionService;
2982
+ }
2983
+ /**
2984
+ * @return {?}
2985
+ */
2986
+ get placeRouter() {
2987
+ return this.navigationState.placeRouter;
3090
2988
  }
3091
2989
  /**
2990
+ * @param {?} currentUrl
3092
2991
  * @param {?} nextState
3093
2992
  * @return {?}
3094
2993
  */
3095
- canDeactivate(nextState) {
2994
+ canDeactivate(currentUrl, nextState) {
3096
2995
  return __awaiter(this, void 0, void 0, function* () {
3097
2996
  // We'll get called multiple times if there's any parameter sanitisation so
3098
2997
  // we always return true if we accepted promise from a previous cycle of the current
3099
2998
  // navigation session.
3100
2999
  if (!this.canDeactivatePromise) {
3101
- this.canDeactivatePromise = this.canDeactivateComponent(nextState);
3000
+ console.log(`creating deactivate promise for -> ${this.component.constructor.name}`);
3001
+ this.canDeactivatePromise = this.canDeactivateComponent(currentUrl, nextState);
3102
3002
  }
3103
3003
  return this.canDeactivatePromise;
3104
3004
  });
3105
3005
  }
3006
+ // @Trace()
3106
3007
  /**
3107
3008
  * @protected
3009
+ * @param {?} currentUrl
3108
3010
  * @param {?} nextState
3109
3011
  * @return {?}
3110
3012
  */
3111
- canDeactivateComponent(nextState) {
3013
+ canDeactivateComponent(currentUrl, nextState) {
3112
3014
  return __awaiter(this, void 0, void 0, function* () {
3015
+ console.log(this.navigationState.toString());
3113
3016
  // Automatically cancel any active activities if the navigation session was triggered by the back button.
3114
- // any other navigations (such as the user clicking a differnt place) must be handled by the component itself
3115
- // during the canDeativate method. If we handled more than just the pop state then it leads to the UI ignoring
3116
- // clicks and just cancelling things which is deeply disconcerting.
3117
- if (this.navigationSession.isPopState && this.component.interactionContext && this.component.interactionContext.isActive()) {
3118
- // Note: Modal interactions are run in a different router outlet so we never get place deactivating while
3119
- // a model interaction is active. This is because:
3120
- // 1. the user can't click anything to navigate away
3121
- // 2. clicking the back button will only change the outlet route portion of the URL. This
3122
- // is all handled by the InteractionGuard and so the component guards will never run.
3123
- //
3124
- // Now we just cancel the current activity...
3125
- /** @type {?} */
3126
- const activity = yield this.component.interactionContext.getCurrentActivity();
3127
- activity.cancel(null);
3128
- return false; // ..and stay where we are.
3017
+ // If we handled more than just the pop state then it leads to the UI ignoring clicks and just cancelling things which is deeply disconcerting.
3018
+ if (this.navigationState.isPopState) {
3019
+ if (this.isPrimaryComponent && this.interactionService.isModalActive()) {
3020
+ /** @type {?} */
3021
+ const routeIds = this.placeRouter.getActiveInteractionIdsFromUrl(nextState.url);
3022
+ /** @type {?} */
3023
+ const currentIds = this.interactionService.activeInteractionContextIds.value;
3024
+ if (!isEqual(currentIds, routeIds)) {
3025
+ yield this.interactionService.getActiveContext().cancelCurrentActivity();
3026
+ return currentUrl.updateInteractionIds(this.interactionService.activeInteractionContextIds.value);
3027
+ }
3028
+ }
3029
+ else {
3030
+ // check if the component has an in place interaction
3031
+ if (this.component.interactionContext && this.component.interactionContext.isActive()) {
3032
+ yield this.component.interactionContext.cancelCurrentActivity();
3033
+ return currentUrl
3034
+ .updateInteractionIds(this.interactionService.activeInteractionContextIds.value);
3035
+ }
3036
+ }
3129
3037
  }
3130
3038
  // Ok, so now we're really leaving, so we ask the component if we should.;
3131
- if (this.isNotJustAChangeInRouteId(nextState) && this.component.canDeactivate) {
3132
- // No interaction in progress, so ask the component .
3133
- // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
3134
- // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
3135
- return this.component.canDeactivate(this.navigationSession.interactionContext);
3039
+ if (this.isNotJustAChangeInRouteId(nextState)) {
3040
+ if (this.component.canDeactivate) {
3041
+ // No interaction in progress, so ask the component .
3042
+ // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
3043
+ // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
3044
+ return this.component.canDeactivate(this.navigationState.interactionContext);
3045
+ }
3046
+ // The component has an active interaction but no deactivation hook. Rather than guessing what to do
3047
+ // we'll just cancel the navigation and print a warning.
3048
+ if (this.component.interactionContext && this.component.interactionContext.isActive()) {
3049
+ console.warn('Route changed while component has active interaction, cancelling navigation');
3050
+ return false;
3051
+ }
3136
3052
  }
3137
3053
  return true;
3138
3054
  });
@@ -3158,7 +3074,9 @@ if (false) {
3158
3074
  /** @type {?} */
3159
3075
  PlaceComponentDeactivationHandler.prototype.component;
3160
3076
  /** @type {?} */
3161
- PlaceComponentDeactivationHandler.prototype.navigationSession;
3077
+ PlaceComponentDeactivationHandler.prototype.navigationState;
3078
+ /** @type {?} */
3079
+ PlaceComponentDeactivationHandler.prototype.isPrimaryComponent;
3162
3080
  }
3163
3081
 
3164
3082
  /**
@@ -3170,32 +3088,99 @@ if (false) {
3170
3088
  */
3171
3089
  class NavigationState extends GarbageCollector {
3172
3090
  /**
3173
- * @param {?} context
3091
+ * @param {?} context
3092
+ */
3093
+ constructor(context) {
3094
+ super();
3095
+ this.context = context;
3096
+ this._visits = new Map();
3097
+ }
3098
+ /**
3099
+ * @return {?}
3100
+ */
3101
+ get name() {
3102
+ return this.constructor.name;
3103
+ }
3104
+ /**
3105
+ * @return {?}
3106
+ */
3107
+ get idle() {
3108
+ return !this.isTransitional;
3109
+ }
3110
+ /**
3111
+ * @return {?}
3112
+ */
3113
+ get placeRouter() {
3114
+ return this.context.placeRouter;
3115
+ }
3116
+ /**
3117
+ * @return {?}
3118
+ */
3119
+ get interactionService() {
3120
+ return this.context.interactionService;
3121
+ }
3122
+ /**
3123
+ * @return {?}
3124
+ */
3125
+ get interactionContext() {
3126
+ return null;
3127
+ }
3128
+ /**
3129
+ * @param {?} visit
3130
+ * @return {?}
3131
+ */
3132
+ storeVisit(visit) {
3133
+ this._visits.set(visit.placeDefinition, visit);
3134
+ }
3135
+ /**
3136
+ * @param {?} placeDef
3137
+ * @return {?}
3138
+ */
3139
+ getVisitFor(placeDef) {
3140
+ return this._visits.get(placeDef);
3141
+ }
3142
+ /**
3143
+ * @param {?} visit
3144
+ * @param {?} initialUrl
3145
+ * @return {?}
3146
+ */
3147
+ onPlaceNavigationStart(visit, initialUrl) {
3148
+ return this.illegalTransition('onPlaceNavigationStart');
3149
+ }
3150
+ /**
3151
+ * @param {?} event
3152
+ * @return {?}
3153
+ */
3154
+ onPopState(event) {
3155
+ return this.illegalTransition(event);
3156
+ }
3157
+ /**
3158
+ * @param {?} event
3159
+ * @return {?}
3174
3160
  */
3175
- constructor(context) {
3176
- super();
3177
- this.context = context;
3178
- this._visits = new Map();
3161
+ onRouterStarted(event) {
3162
+ return this.illegalTransition(event);
3179
3163
  }
3180
3164
  /**
3165
+ * @param {?} event
3181
3166
  * @return {?}
3182
3167
  */
3183
- get interactionContext() {
3184
- return null;
3168
+ onRouterCancelled(event) {
3169
+ return this.illegalTransition(event);
3185
3170
  }
3186
3171
  /**
3187
- * @param {?} visit
3172
+ * @param {?} event
3188
3173
  * @return {?}
3189
3174
  */
3190
- storeVisit(visit) {
3191
- this._visits.set(visit.placeDefinition, visit);
3175
+ onRouterError(event) {
3176
+ return this.illegalTransition(event);
3192
3177
  }
3193
3178
  /**
3194
- * @param {?} placeDef
3179
+ * @param {?} event
3195
3180
  * @return {?}
3196
3181
  */
3197
- getVisitFor(placeDef) {
3198
- return this._visits.get(placeDef);
3182
+ onRouterEnd(event) {
3183
+ return this.illegalTransition(event);
3199
3184
  }
3200
3185
  /**
3201
3186
  * @param {?} newUrl
@@ -3204,6 +3189,17 @@ class NavigationState extends GarbageCollector {
3204
3189
  onBackClickedDuringNavigationInteraction(newUrl) {
3205
3190
  return this.illegalTransition('onBackClickedDuringNavigationInteraction');
3206
3191
  }
3192
+ /**
3193
+ * @param {?} component
3194
+ * @param {?} currentUrl
3195
+ * @param {?} nextUrl
3196
+ * @return {?}
3197
+ */
3198
+ canDeactivatePlace(component, currentUrl, nextUrl) {
3199
+ return __awaiter(this, void 0, void 0, function* () {
3200
+ return this.illegalTransition('canDeactivatePlace');
3201
+ });
3202
+ }
3207
3203
  /**
3208
3204
  * @return {?}
3209
3205
  */
@@ -3224,24 +3220,40 @@ class NavigationState extends GarbageCollector {
3224
3220
  * @return {?}
3225
3221
  */
3226
3222
  currentRouterUrl() {
3227
- return this.context.router.routerState ? this.context.router.routerState.snapshot.url : null;
3223
+ return this.placeRouter.getCurrentRouterUrl();
3228
3224
  }
3229
3225
  /**
3230
3226
  * @protected
3231
3227
  * @param {?} event
3232
3228
  * @return {?}
3233
3229
  */
3234
- createActiveSession(event) {
3235
- // TODO: check if the event is purely for interaction context changes.
3236
- return new NavigationState.Active(this.context, event.navigationTrigger === 'popstate', this.currentRouterUrl());
3230
+ createTransitionStateFor(event) {
3231
+ /** @type {?} */
3232
+ const popstate = event.navigationTrigger === 'popstate';
3233
+ return popstate ?
3234
+ this.interactionService.isActive() ?
3235
+ new NavigationState.InteractionPopStateTransition(this.context, this.currentRouterUrl()) :
3236
+ new NavigationState.PopStateTransition(this.context, this.currentRouterUrl())
3237
+ :
3238
+ this.interactionService.isActive() ?
3239
+ new NavigationState.InteractionTransition(this.context, this.currentRouterUrl()) :
3240
+ new NavigationState.NavigationTransition(this.context, this.currentRouterUrl());
3237
3241
  }
3238
3242
  /**
3239
3243
  * @protected
3244
+ * @return {?}
3245
+ */
3246
+ createIdleState() {
3247
+ return this.interactionService.isActive() ?
3248
+ new NavigationState.IdleDuringInteraction(this.context, this.currentRouterUrl()) :
3249
+ new NavigationState.Idle(this.context);
3250
+ }
3251
+ /**
3240
3252
  * @param {?} url
3241
3253
  * @return {?}
3242
3254
  */
3243
- updateLocation(url) {
3244
- this.context.angularLocation.go(url);
3255
+ resetBrowserLocation(url) {
3256
+ this.placeRouter.resetBrowserLocation(url);
3245
3257
  }
3246
3258
  /**
3247
3259
  * @return {?}
@@ -3250,12 +3262,6 @@ class NavigationState extends GarbageCollector {
3250
3262
  return this.constructor.name;
3251
3263
  }
3252
3264
  }
3253
- __decorate([
3254
- Trace(),
3255
- __metadata("design:type", Function),
3256
- __metadata("design:paramtypes", [Object]),
3257
- __metadata("design:returntype", void 0)
3258
- ], NavigationState.prototype, "updateLocation", null);
3259
3265
  if (false) {
3260
3266
  /**
3261
3267
  * @type {?}
@@ -3263,71 +3269,36 @@ if (false) {
3263
3269
  */
3264
3270
  NavigationState.prototype._visits;
3265
3271
  /** @type {?} */
3266
- NavigationState.prototype.isPopState;
3267
- /** @type {?} */
3268
- NavigationState.prototype.active;
3272
+ NavigationState.prototype.isTransitional;
3269
3273
  /** @type {?} */
3270
3274
  NavigationState.prototype.startingUrl;
3275
+ /** @type {?} */
3276
+ NavigationState.prototype.isPopState;
3271
3277
  /**
3272
3278
  * @type {?}
3273
3279
  * @protected
3274
3280
  */
3275
3281
  NavigationState.prototype.context;
3276
- /**
3277
- * @abstract
3278
- * @param {?} event
3279
- * @return {?}
3280
- */
3281
- NavigationState.prototype.onStart = function (event) { };
3282
- /**
3283
- * @abstract
3284
- * @param {?} event
3285
- * @return {?}
3286
- */
3287
- NavigationState.prototype.onCancel = function (event) { };
3288
- /**
3289
- * @abstract
3290
- * @param {?} event
3291
- * @return {?}
3292
- */
3293
- NavigationState.prototype.onError = function (event) { };
3294
- /**
3295
- * @abstract
3296
- * @param {?} event
3297
- * @return {?}
3298
- */
3299
- NavigationState.prototype.onEnd = function (event) { };
3300
- /**
3301
- * @abstract
3302
- * @param {?} component
3303
- * @param {?} nextState
3304
- * @return {?}
3305
- */
3306
- NavigationState.prototype.canDeactivatePlace = function (component, nextState) { };
3307
3282
  }
3308
3283
  (function (NavigationState) {
3309
3284
  class Context {
3310
3285
  /**
3311
- * @param {?} router
3312
- * @param {?} modalInteractionService
3313
- * @param {?} angularLocation
3286
+ * @param {?} placeRouter
3287
+ * @param {?} interactionService
3314
3288
  * @param {?} notifySuccess
3315
3289
  */
3316
- constructor(router, modalInteractionService, angularLocation, notifySuccess) {
3317
- this.router = router;
3318
- this.modalInteractionService = modalInteractionService;
3319
- this.angularLocation = angularLocation;
3290
+ constructor(placeRouter, interactionService, notifySuccess) {
3291
+ this.placeRouter = placeRouter;
3292
+ this.interactionService = interactionService;
3320
3293
  this.notifySuccess = notifySuccess;
3321
3294
  }
3322
3295
  }
3323
3296
  NavigationState.Context = Context;
3324
3297
  if (false) {
3325
3298
  /** @type {?} */
3326
- Context.prototype.router;
3299
+ Context.prototype.placeRouter;
3327
3300
  /** @type {?} */
3328
- Context.prototype.modalInteractionService;
3329
- /** @type {?} */
3330
- Context.prototype.angularLocation;
3301
+ Context.prototype.interactionService;
3331
3302
  /** @type {?} */
3332
3303
  Context.prototype.notifySuccess;
3333
3304
  }
@@ -3337,79 +3308,70 @@ if (false) {
3337
3308
  */
3338
3309
  constructor(context) {
3339
3310
  super(context);
3340
- this.active = false;
3311
+ this.isTransitional = false;
3341
3312
  this.startingUrl = null;
3313
+ this.isPopState = false;
3342
3314
  }
3343
3315
  /**
3344
- * @param {?} component
3345
- * @param {?} nextState
3316
+ * @param {?} visit
3317
+ * @param {?} initialUrl
3346
3318
  * @return {?}
3347
3319
  */
3348
- canDeactivatePlace(component, nextState) {
3349
- return __awaiter(this, void 0, void 0, function* () {
3350
- return this.illegalTransition('canDeactivatePlace');
3351
- });
3320
+ onPlaceNavigationStart(visit, initialUrl) {
3321
+ /** @type {?} */
3322
+ const navigationTransition = new NavigationTransition(this.context, initialUrl);
3323
+ navigationTransition.storeVisit(visit);
3324
+ return navigationTransition;
3352
3325
  }
3353
3326
  /**
3354
3327
  * @param {?} event
3355
3328
  * @return {?}
3356
3329
  */
3357
- onStart(event) {
3330
+ onRouterStarted(event) {
3358
3331
  // calling angularLocation.go() to clear back state can trigger router cycles to the current url if we don't ignore them
3359
3332
  if (event.url === this.currentRouterUrl()) {
3360
3333
  Logger.get(this).info(`navigation started to same url -> ${event.url}`);
3361
3334
  return this;
3362
3335
  }
3363
- if (event.url === (`${this.currentRouterUrl()}(aup-interaction:modal)`)) {
3336
+ if (this.placeRouter.hasActiveInteractionIds(event.url)) {
3364
3337
  Logger.get(this).info(`navigation started with interaction outlet -> ${event.url}`);
3365
- return new ModalInteractionSession(this.context, event.url);
3338
+ return new InteractionTransition(this.context, event.url);
3339
+ }
3340
+ else {
3341
+ return this.createTransitionStateFor(event);
3366
3342
  }
3367
- return this.createActiveSession(event);
3368
- }
3369
- /**
3370
- * @param {?} event
3371
- * @return {?}
3372
- */
3373
- onCancel(event) {
3374
- return this.illegalTransition(event);
3375
- }
3376
- /**
3377
- * @param {?} event
3378
- * @return {?}
3379
- */
3380
- onEnd(event) {
3381
- return this.illegalTransition(event);
3382
3343
  }
3383
3344
  /**
3384
3345
  * @param {?} event
3385
3346
  * @return {?}
3386
3347
  */
3387
- onError(event) {
3388
- return this.illegalTransition(event);
3348
+ onPopState(event) {
3349
+ return this.createTransitionStateFor(event);
3389
3350
  }
3390
3351
  }
3391
3352
  NavigationState.Idle = Idle;
3392
3353
  if (false) {
3393
3354
  /** @type {?} */
3394
- Idle.prototype.isPopState;
3395
- /** @type {?} */
3396
- Idle.prototype.active;
3355
+ Idle.prototype.isTransitional;
3397
3356
  /** @type {?} */
3398
3357
  Idle.prototype.startingUrl;
3358
+ /** @type {?} */
3359
+ Idle.prototype.isPopState;
3399
3360
  }
3400
- class Active extends NavigationState {
3361
+ /**
3362
+ * @abstract
3363
+ */
3364
+ class AbstractNavigationTransition extends NavigationState {
3401
3365
  /**
3402
3366
  * @param {?} context
3403
- * @param {?} isPopState
3404
3367
  * @param {?} startingUrl
3405
3368
  */
3406
- constructor(context, isPopState, startingUrl) {
3369
+ constructor(context, startingUrl) {
3407
3370
  super(context);
3408
- this.isPopState = isPopState;
3409
3371
  this.startingUrl = startingUrl;
3410
- this.active = true;
3372
+ this.isTransitional = true;
3411
3373
  this.componentDeactivationHandlers = new Map();
3412
- this._interactionContext = this.context.modalInteractionService.createExclusiveInteractionContext();
3374
+ this._interactionContext = this.interactionService._createExclusiveModalInteractionContext();
3413
3375
  this.onDispose((/**
3414
3376
  * @return {?}
3415
3377
  */
@@ -3417,9 +3379,9 @@ if (false) {
3417
3379
  // the interaction context can be detached during the back button cancellation state transition
3418
3380
  // as the transition is synchronous and activityCancellation isn't. Otherwise dispose will be
3419
3381
  // called before the context has been cancelled. It might be work having the interaction context
3420
- // automatically cancel if the context is disposed.
3382
+ // automatically cancel if the context is disposed so we don't have worry about detaching etc.
3421
3383
  if (this._interactionContext) {
3422
- this._interactionContext.dispose();
3384
+ this._interactionContext.dispose(); // or do something like cancelAndDispose?
3423
3385
  }
3424
3386
  }));
3425
3387
  }
@@ -3433,81 +3395,48 @@ if (false) {
3433
3395
  * @param {?} event
3434
3396
  * @return {?}
3435
3397
  */
3436
- onStart(event) {
3437
- // active sessions can have many cancel start cycles.
3398
+ onRouterStarted(event) {
3399
+ // active sessions can have many cancel start cycles due
3400
+ // to place guard redirects
3438
3401
  return this;
3439
3402
  }
3440
3403
  /**
3441
3404
  * @param {?} event
3442
3405
  * @return {?}
3443
3406
  */
3444
- onEnd(event) {
3407
+ onRouterEnd(event) {
3445
3408
  // navigation succeeded
3446
3409
  this.context.notifySuccess(this);
3447
3410
  return new Idle(this.context);
3448
3411
  }
3449
- /**
3450
- * @param {?} event
3451
- * @return {?}
3452
- */
3453
- onCancel(event) {
3454
- if (this.isPopState) { // back button clicked and a guard cancelled
3455
- // Angular doesn't preserve the url when a guard cancels the back button.
3456
- // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
3457
- Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
3458
- this.updateLocation(this.startingUrl);
3459
- }
3460
- return this.isPopState ? new Idle(this.context) : this;
3461
- }
3462
- /**
3463
- * @param {?} event
3464
- * @return {?}
3465
- */
3466
- onError(event) {
3467
- // navigation was aborted.
3468
- if (this.isPopState && this.currentRouterUrl() !== this.startingUrl) {
3469
- // Angular doesn't preserve the url when a guard cancels the back button.
3470
- // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
3471
- Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
3472
- this.updateLocation(this.startingUrl);
3473
- }
3474
- return new Idle(this.context);
3475
- }
3476
3412
  /**
3477
3413
  * @param {?} locationTriggerUrl
3478
3414
  * @return {?}
3479
3415
  */
3480
3416
  onBackClickedDuringNavigationInteraction(locationTriggerUrl) {
3417
+ Logger.get(this).info(`back button pressed during navigation session interaction promise`);
3418
+ // detach the interaction from the session so it doesn't get disposed until the activity has completed.
3481
3419
  /** @type {?} */
3482
- const context = this.detachInteractionContext();
3483
- context.getCurrentActivity().then((/**
3484
- * @param {?} activity
3420
+ const navigationInteraction = this.detachInteractionContext();
3421
+ const { when } = Dsl.disposeWith(navigationInteraction);
3422
+ // TODO: I need to make the exclusive interaction context disallow nested activities or
3423
+ // that would mess things up entirely. Or, can I do a context.abortAll().then(..)
3424
+ navigationInteraction.cancelCurrentActivity().then((/**
3485
3425
  * @return {?}
3486
3426
  */
3487
- activity => {
3488
- context.addActivityListener({
3489
- /**
3490
- * @return {?}
3491
- */
3492
- onActivityFinished() {
3493
- context.dispose();
3494
- },
3495
- /**
3496
- * @return {?}
3497
- */
3498
- onActivityStarted() {
3499
- }
3500
- });
3501
- activity.cancel(null);
3427
+ () => {
3428
+ navigationInteraction.dispose();
3502
3429
  }));
3503
- return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, locationTriggerUrl);
3430
+ return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, this.isPopState, locationTriggerUrl);
3504
3431
  }
3432
+ // @Trace()
3505
3433
  /**
3506
3434
  * @param {?} component
3507
- * @param {?} nextState
3435
+ * @param {?} currentUrl
3436
+ * @param {?} nextUrl
3508
3437
  * @return {?}
3509
3438
  */
3510
- canDeactivatePlace(component, nextState) {
3439
+ canDeactivatePlace(component, currentUrl, nextUrl) {
3511
3440
  return __awaiter(this, void 0, void 0, function* () {
3512
3441
  // lookup the handler and create it if we've not seen it yet
3513
3442
  /** @type {?} */
@@ -3515,10 +3444,10 @@ if (false) {
3515
3444
  if (!handler) {
3516
3445
  /** @type {?} */
3517
3446
  const isPrimaryHandler = this.componentDeactivationHandlers.size === 0;
3518
- handler = new PlaceComponentDeactivationHandler(component, this);
3447
+ handler = new PlaceComponentDeactivationHandler(component, this, isPrimaryHandler);
3519
3448
  this.componentDeactivationHandlers.set(component, handler);
3520
3449
  }
3521
- return handler.canDeactivate(nextState);
3450
+ return handler.canDeactivate(currentUrl, nextUrl);
3522
3451
  });
3523
3452
  }
3524
3453
  /**
@@ -3531,11 +3460,127 @@ if (false) {
3531
3460
  this._interactionContext = null;
3532
3461
  return context;
3533
3462
  }
3463
+ }
3464
+ NavigationState.AbstractNavigationTransition = AbstractNavigationTransition;
3465
+ if (false) {
3466
+ /** @type {?} */
3467
+ AbstractNavigationTransition.prototype.isTransitional;
3468
+ /**
3469
+ * @type {?}
3470
+ * @private
3471
+ */
3472
+ AbstractNavigationTransition.prototype.componentDeactivationHandlers;
3473
+ /**
3474
+ * @type {?}
3475
+ * @private
3476
+ */
3477
+ AbstractNavigationTransition.prototype._interactionContext;
3478
+ /** @type {?} */
3479
+ AbstractNavigationTransition.prototype.startingUrl;
3480
+ }
3481
+ class NavigationTransition extends AbstractNavigationTransition {
3482
+ constructor() {
3483
+ super(...arguments);
3484
+ this.isPopState = false;
3485
+ }
3486
+ /**
3487
+ * @param {?} event
3488
+ * @return {?}
3489
+ */
3490
+ onRouterCancelled(event) {
3491
+ return this;
3492
+ }
3493
+ /**
3494
+ * @param {?} event
3495
+ * @return {?}
3496
+ */
3497
+ onRouterError(event) {
3498
+ // navigation was aborted.
3499
+ return new Idle(this.context);
3500
+ }
3534
3501
  /**
3535
3502
  * @return {?}
3536
3503
  */
3537
3504
  toString() {
3538
- return `${this.constructor.name}(startingUrl: ${this.startingUrl}, isPopState:${this.isPopState})`;
3505
+ return `${this.constructor.name}(startingUrl: ${this.startingUrl})`;
3506
+ }
3507
+ }
3508
+ NavigationState.NavigationTransition = NavigationTransition;
3509
+ if (false) {
3510
+ /** @type {?} */
3511
+ NavigationTransition.prototype.isPopState;
3512
+ }
3513
+ class PopStateTransition extends AbstractNavigationTransition {
3514
+ constructor() {
3515
+ super(...arguments);
3516
+ this.isPopState = true;
3517
+ }
3518
+ /**
3519
+ * @param {?} event
3520
+ * @return {?}
3521
+ */
3522
+ onRouterCancelled(event) {
3523
+ // Angular doesn't preserve the url when a guard cancels the back button.
3524
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
3525
+ Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
3526
+ this.resetBrowserLocation(this.startingUrl);
3527
+ return new Idle(this.context);
3528
+ }
3529
+ /**
3530
+ * @param {?} event
3531
+ * @return {?}
3532
+ */
3533
+ onRouterError(event) {
3534
+ // navigation was aborted.
3535
+ if (this.currentRouterUrl() !== this.startingUrl) {
3536
+ // Angular doesn't preserve the url when a guard cancels the back button.
3537
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
3538
+ Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
3539
+ this.resetBrowserLocation(this.startingUrl);
3540
+ }
3541
+ return new Idle(this.context);
3542
+ }
3543
+ }
3544
+ NavigationState.PopStateTransition = PopStateTransition;
3545
+ if (false) {
3546
+ /** @type {?} */
3547
+ PopStateTransition.prototype.isPopState;
3548
+ }
3549
+ class IdleDuringInteraction extends NavigationState {
3550
+ /**
3551
+ * @param {?} context
3552
+ * @param {?} startingUrl
3553
+ */
3554
+ constructor(context, startingUrl) {
3555
+ super(context);
3556
+ this.startingUrl = startingUrl;
3557
+ this.isTransitional = false;
3558
+ this.isPopState = false;
3559
+ }
3560
+ /**
3561
+ * @param {?} visit
3562
+ * @param {?} initialUrl
3563
+ * @return {?}
3564
+ */
3565
+ onPlaceNavigationStart(visit, initialUrl) {
3566
+ /** @type {?} */
3567
+ const navigationTransition = new InteractionTransition(this.context, initialUrl);
3568
+ navigationTransition.storeVisit(visit);
3569
+ return navigationTransition;
3570
+ }
3571
+ /**
3572
+ * @param {?} event
3573
+ * @return {?}
3574
+ */
3575
+ onRouterStarted(event) {
3576
+ return new InteractionTransition(this.context, event.url);
3577
+ }
3578
+ /**
3579
+ * @param {?} event
3580
+ * @return {?}
3581
+ */
3582
+ onPopState(event) {
3583
+ return new InteractionPopStateTransition(this.context, event.url);
3539
3584
  }
3540
3585
  }
3541
3586
  __decorate([
@@ -3543,89 +3588,112 @@ if (false) {
3543
3588
  __metadata("design:type", Function),
3544
3589
  __metadata("design:paramtypes", [NavigationStart]),
3545
3590
  __metadata("design:returntype", NavigationState)
3546
- ], Active.prototype, "onStart", null);
3547
- __decorate([
3548
- Trace(),
3549
- __metadata("design:type", Function),
3550
- __metadata("design:paramtypes", [NavigationCancel]),
3551
- __metadata("design:returntype", NavigationState)
3552
- ], Active.prototype, "onCancel", null);
3591
+ ], IdleDuringInteraction.prototype, "onRouterStarted", null);
3553
3592
  __decorate([
3554
3593
  Trace(),
3555
3594
  __metadata("design:type", Function),
3556
- __metadata("design:paramtypes", [NavigationError]),
3595
+ __metadata("design:paramtypes", [NavigationStart]),
3557
3596
  __metadata("design:returntype", NavigationState)
3558
- ], Active.prototype, "onError", null);
3559
- NavigationState.Active = Active;
3597
+ ], IdleDuringInteraction.prototype, "onPopState", null);
3598
+ NavigationState.IdleDuringInteraction = IdleDuringInteraction;
3560
3599
  if (false) {
3561
3600
  /** @type {?} */
3562
- Active.prototype.active;
3563
- /**
3564
- * @type {?}
3565
- * @private
3566
- */
3567
- Active.prototype.componentDeactivationHandlers;
3568
- /**
3569
- * @type {?}
3570
- * @private
3571
- */
3572
- Active.prototype._interactionContext;
3601
+ IdleDuringInteraction.prototype.isTransitional;
3573
3602
  /** @type {?} */
3574
- Active.prototype.isPopState;
3603
+ IdleDuringInteraction.prototype.isPopState;
3575
3604
  /** @type {?} */
3576
- Active.prototype.startingUrl;
3605
+ IdleDuringInteraction.prototype.startingUrl;
3577
3606
  }
3578
- class ModalInteractionSession extends NavigationState {
3607
+ /**
3608
+ * @abstract
3609
+ */
3610
+ class AbstractInteractionTransition extends AbstractNavigationTransition {
3579
3611
  /**
3580
3612
  * @param {?} context
3581
3613
  * @param {?} startingUrl
3582
3614
  */
3583
3615
  constructor(context, startingUrl) {
3584
- super(context);
3616
+ super(context, startingUrl);
3585
3617
  this.startingUrl = startingUrl;
3586
- this.active = false;
3618
+ this.isTransitional = true;
3619
+ }
3620
+ }
3621
+ NavigationState.AbstractInteractionTransition = AbstractInteractionTransition;
3622
+ if (false) {
3623
+ /** @type {?} */
3624
+ AbstractInteractionTransition.prototype.isTransitional;
3625
+ /** @type {?} */
3626
+ AbstractInteractionTransition.prototype.startingUrl;
3627
+ }
3628
+ /**
3629
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
3630
+ * happily ignore interaction contexts.
3631
+ */
3632
+ class InteractionTransition extends AbstractInteractionTransition {
3633
+ constructor() {
3634
+ super(...arguments);
3587
3635
  this.isPopState = false;
3588
3636
  }
3589
3637
  /**
3590
- * @param {?} url
3638
+ * @param {?} event
3591
3639
  * @return {?}
3592
3640
  */
3593
- static hasInteraction(url) {
3594
- return url.endsWith('(aup-interaction:modal)');
3641
+ onRouterCancelled(event) {
3642
+ if (this.context.interactionService.isActive()) {
3643
+ /** @type {?} */
3644
+ const interactionIds = this.interactionService.activeInteractionContextIds.value;
3645
+ this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
3646
+ return new IdleDuringInteraction(this.context, this.startingUrl);
3647
+ }
3648
+ else {
3649
+ return new Idle(this.context);
3650
+ }
3595
3651
  }
3596
3652
  /**
3597
3653
  * @param {?} event
3598
3654
  * @return {?}
3599
3655
  */
3600
- onStart(event) {
3601
- // VERY VERY IMPORTANT BACK BUTTON NOTE:
3602
- // When the back button is clicked we'll enter here first, and push the url
3603
- // back to the browser. Angular seems to ignore it from a routing perspective
3604
- // and then the InteractionGuard will cancel the navigation. This process seems
3605
- // to keep the brower history in a sane state.
3606
- if (this.context.modalInteractionService.isActive()) {
3607
- if (!ModalInteractionSession.hasInteraction(event.url)) {
3608
- // this capture the case where
3609
- this.updateLocation(this.startingUrl);
3610
- }
3611
- }
3612
- return this;
3656
+ onRouterError(event) {
3657
+ // navigation was aborted.
3658
+ return new IdleDuringInteraction(this.context, this.startingUrl);
3613
3659
  }
3614
3660
  /**
3615
3661
  * @param {?} event
3616
3662
  * @return {?}
3617
3663
  */
3618
- onCancel(event) {
3619
- // this.updateLocation(this.startingUrl);
3620
- return this;
3664
+ onRouterEnd(event) {
3665
+ if (this.context.interactionService.isActive()) {
3666
+ return new IdleDuringInteraction(this.context, this.startingUrl);
3667
+ }
3668
+ else {
3669
+ return new Idle(this.context);
3670
+ }
3671
+ }
3672
+ }
3673
+ NavigationState.InteractionTransition = InteractionTransition;
3674
+ if (false) {
3675
+ /** @type {?} */
3676
+ InteractionTransition.prototype.isPopState;
3677
+ }
3678
+ /**
3679
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
3680
+ * happily ignore interaction contexts.
3681
+ */
3682
+ class InteractionPopStateTransition extends AbstractInteractionTransition {
3683
+ constructor() {
3684
+ super(...arguments);
3685
+ this.isPopState = true;
3621
3686
  }
3622
3687
  /**
3623
3688
  * @param {?} event
3624
3689
  * @return {?}
3625
3690
  */
3626
- onEnd(event) {
3627
- if (this.context.modalInteractionService.isActive()) {
3628
- return this;
3691
+ onRouterCancelled(event) {
3692
+ if (this.interactionService.isActive()) {
3693
+ /** @type {?} */
3694
+ const interactionIds = this.interactionService.activeInteractionContextIds.value;
3695
+ this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
3696
+ return new IdleDuringInteraction(this.context, this.startingUrl);
3629
3697
  }
3630
3698
  else {
3631
3699
  return new Idle(this.context);
@@ -3635,105 +3703,93 @@ if (false) {
3635
3703
  * @param {?} event
3636
3704
  * @return {?}
3637
3705
  */
3638
- onError(event) {
3639
- return this.illegalTransition(event);
3640
- }
3641
- /**
3642
- * @param {?} component
3643
- * @param {?} nextState
3644
- * @return {?}
3645
- */
3646
- canDeactivatePlace(component, nextState) {
3647
- return __awaiter(this, void 0, void 0, function* () {
3648
- return true;
3649
- });
3706
+ onRouterEnd(event) {
3707
+ if (this.context.interactionService.isActive()) {
3708
+ return new IdleDuringInteraction(this.context, this.startingUrl);
3709
+ }
3710
+ else {
3711
+ return new Idle(this.context);
3712
+ }
3650
3713
  }
3651
3714
  }
3652
- __decorate([
3653
- Trace(),
3654
- __metadata("design:type", Function),
3655
- __metadata("design:paramtypes", [NavigationStart]),
3656
- __metadata("design:returntype", NavigationState)
3657
- ], ModalInteractionSession.prototype, "onStart", null);
3658
- __decorate([
3659
- Trace(),
3660
- __metadata("design:type", Function),
3661
- __metadata("design:paramtypes", [NavigationCancel]),
3662
- __metadata("design:returntype", NavigationState)
3663
- ], ModalInteractionSession.prototype, "onCancel", null);
3664
- __decorate([
3665
- Trace(),
3666
- __metadata("design:type", Function),
3667
- __metadata("design:paramtypes", [NavigationEnd]),
3668
- __metadata("design:returntype", NavigationState)
3669
- ], ModalInteractionSession.prototype, "onEnd", null);
3670
- NavigationState.ModalInteractionSession = ModalInteractionSession;
3715
+ NavigationState.InteractionPopStateTransition = InteractionPopStateTransition;
3671
3716
  if (false) {
3672
3717
  /** @type {?} */
3673
- ModalInteractionSession.prototype.active;
3674
- /** @type {?} */
3675
- ModalInteractionSession.prototype.isPopState;
3676
- /** @type {?} */
3677
- ModalInteractionSession.prototype.startingUrl;
3718
+ InteractionPopStateTransition.prototype.isPopState;
3678
3719
  }
3679
3720
  class CancelledDuringNavigationInteraction extends NavigationState {
3680
3721
  /**
3681
3722
  * @param {?} context
3682
3723
  * @param {?} startingUrl
3724
+ * @param {?} startingEventWasAPopState
3683
3725
  * @param {?} locationChangeTriggerUrl
3684
3726
  */
3685
- constructor(context, startingUrl, locationChangeTriggerUrl) {
3727
+ constructor(context, startingUrl, startingEventWasAPopState, locationChangeTriggerUrl) {
3686
3728
  super(context);
3687
3729
  this.startingUrl = startingUrl;
3730
+ this.startingEventWasAPopState = startingEventWasAPopState;
3688
3731
  this.locationChangeTriggerUrl = locationChangeTriggerUrl;
3689
- this.active = false;
3690
- this.capturedFauxRouterStart = false;
3691
- // This will trigger a return to the route we originally started with.
3692
- // this.angularLocation.go(this.startingUrl);
3732
+ this.isPopState = false;
3733
+ this.gotPopStateWithLeavingUrl = false;
3693
3734
  }
3694
3735
  /**
3695
- * @param {?} component
3696
- * @param {?} nextState
3697
3736
  * @return {?}
3698
3737
  */
3699
- canDeactivatePlace(component, nextState) {
3700
- return __awaiter(this, void 0, void 0, function* () {
3701
- return false;
3702
- });
3738
+ get isTransitional() {
3739
+ return true;
3703
3740
  }
3704
3741
  /**
3705
3742
  * @param {?} event
3706
3743
  * @return {?}
3707
3744
  */
3708
- onCancel(event) {
3745
+ onRouterStarted(event) {
3709
3746
  return this.ignore(event);
3710
3747
  }
3711
3748
  /**
3712
3749
  * @param {?} event
3713
3750
  * @return {?}
3714
3751
  */
3715
- onEnd(event) {
3752
+ onRouterCancelled(event) {
3753
+ // Depending on the state of the router and what was done we get a different
3754
+ // sequence of events. I.e. If they just clicked a link we'll get a cancel
3755
+ // with the locationChangeTriggerUrl as the final event. However the user
3756
+ // started the initial navigation with a pop state then we'll get one of
3757
+ // those with the locationChangeTriggerUrl but no cancel event with it.
3758
+ return this.gotPopStateWithLeavingUrl || this.locationChangeTriggerUrl === event.url ? this.createIdleState() : this.ignore(event);
3759
+ }
3760
+ /**
3761
+ * @param {?} event
3762
+ * @return {?}
3763
+ */
3764
+ onRouterEnd(event) {
3716
3765
  return this.ignore(event);
3717
3766
  }
3718
3767
  /**
3719
3768
  * @param {?} event
3720
3769
  * @return {?}
3721
3770
  */
3722
- onError(event) {
3771
+ onRouterError(event) {
3723
3772
  return this.ignore(event);
3724
3773
  }
3725
3774
  /**
3726
3775
  * @param {?} event
3727
3776
  * @return {?}
3728
3777
  */
3729
- onStart(event) {
3730
- if (event.url === this.locationChangeTriggerUrl && !this.capturedFauxRouterStart) {
3731
- this.capturedFauxRouterStart = true;
3732
- return this.ignore(event, 'url matched back button location change');
3733
- }
3734
- else {
3735
- return this.createActiveSession(event);
3736
- }
3778
+ onPopState(event) {
3779
+ this.gotPopStateWithLeavingUrl = this.gotPopStateWithLeavingUrl || event.url === this.locationChangeTriggerUrl;
3780
+ return this.ignore(event);
3781
+ }
3782
+ // @Trace()
3783
+ /**
3784
+ * @param {?} component
3785
+ * @param {?} currentUrl
3786
+ * @param {?} nextUrl
3787
+ * @return {?}
3788
+ */
3789
+ canDeactivatePlace(component, currentUrl, nextUrl) {
3790
+ return __awaiter(this, void 0, void 0, function* () {
3791
+ return false;
3792
+ });
3737
3793
  }
3738
3794
  /**
3739
3795
  * @param {?} event
@@ -3741,7 +3797,7 @@ if (false) {
3741
3797
  * @return {?}
3742
3798
  */
3743
3799
  ignore(event, reason) {
3744
- reason = reason ? ` (${reason})` : '';
3800
+ reason = reason ? ` -> ${reason}` : '';
3745
3801
  Logger.get(this).info(`ignoring router event${reason}: ${event.constructor.name} -> ${event.url}`);
3746
3802
  return this;
3747
3803
  }
@@ -3749,23 +3805,29 @@ if (false) {
3749
3805
  * @return {?}
3750
3806
  */
3751
3807
  toString() {
3752
- return `${this.constructor.name}(startingUrl: ${this.startingUrl}, locationChangeTriggerUrl:${this.locationChangeTriggerUrl})`;
3808
+ return `${this.constructor.name}(isIdl: ${this.idle}, startingUrl: ${this.startingUrl}, locationChangeTriggerUrl:${this.locationChangeTriggerUrl})`;
3753
3809
  }
3754
3810
  }
3811
+ __decorate([
3812
+ Trace(),
3813
+ __metadata("design:type", Function),
3814
+ __metadata("design:paramtypes", [NavigationCancel]),
3815
+ __metadata("design:returntype", NavigationState)
3816
+ ], CancelledDuringNavigationInteraction.prototype, "onRouterCancelled", null);
3755
3817
  NavigationState.CancelledDuringNavigationInteraction = CancelledDuringNavigationInteraction;
3756
3818
  if (false) {
3757
- /** @type {?} */
3758
- CancelledDuringNavigationInteraction.prototype.active;
3759
3819
  /** @type {?} */
3760
3820
  CancelledDuringNavigationInteraction.prototype.isPopState;
3761
3821
  /**
3762
3822
  * @type {?}
3763
3823
  * @private
3764
3824
  */
3765
- CancelledDuringNavigationInteraction.prototype.capturedFauxRouterStart;
3825
+ CancelledDuringNavigationInteraction.prototype.gotPopStateWithLeavingUrl;
3766
3826
  /** @type {?} */
3767
3827
  CancelledDuringNavigationInteraction.prototype.startingUrl;
3768
3828
  /** @type {?} */
3829
+ CancelledDuringNavigationInteraction.prototype.startingEventWasAPopState;
3830
+ /** @type {?} */
3769
3831
  CancelledDuringNavigationInteraction.prototype.locationChangeTriggerUrl;
3770
3832
  }
3771
3833
  })(NavigationState || (NavigationState = {}));
@@ -3837,29 +3899,30 @@ if (false) {
3837
3899
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3838
3900
  */
3839
3901
  class UrlSnapshot {
3902
+ // TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.
3840
3903
  /**
3841
- * @param {?} urlTree
3842
- */
3843
- constructor(urlTree) {
3844
- this.urlTree = urlTree;
3845
- // console.log({ segments: this.urlTree.root.children.primary.segments });
3846
- }
3847
- /**
3848
- * @return {?}
3904
+ * @param {?} urlSerializer
3905
+ * @param {?} url
3906
+ * @param {?} options
3849
3907
  */
3850
- cloneUrlSegmentList() {
3851
- return [...this.urlTree.root.children.primary.segments];
3908
+ constructor(urlSerializer, url, options) {
3909
+ this.urlSerializer = urlSerializer;
3910
+ this.url = url;
3911
+ this.options = options;
3912
+ this.urlTree = urlSerializer.parse(url);
3852
3913
  }
3853
3914
  /**
3854
3915
  * @param {?} visit
3855
3916
  * @return {?}
3856
3917
  */
3857
3918
  updateVisitSegments(visit) {
3919
+ /** @type {?} */
3920
+ const urlTree = this.urlSerializer.parse(this.url);
3858
3921
  // Ugly, but it works for now.
3859
3922
  /** @type {?} */
3860
- const segments = this.cloneUrlSegmentList();
3923
+ const segments = [...this.getPrimarySegments(urlTree)];
3861
3924
  /** @type {?} */
3862
- const visitSegments = this.convertToUrlSegments(visit);
3925
+ const visitSegments = this.getSegmentsFor(visit);
3863
3926
  /** @type {?} */
3864
3927
  const replaceAt = segments.findIndex((/**
3865
3928
  * @param {?} segment
@@ -3868,14 +3931,24 @@ class UrlSnapshot {
3868
3931
  segment => segment.path === visitSegments[0].path));
3869
3932
  // do not use the return value, it's the items that were removed!
3870
3933
  segments.splice(replaceAt, visitSegments.length, ...visitSegments);
3871
- return segments;
3934
+ urlTree.root.children.primary.segments = segments;
3935
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
3936
+ }
3937
+ /**
3938
+ * @private
3939
+ * @param {?} urlTree
3940
+ * @return {?}
3941
+ */
3942
+ getPrimarySegments(urlTree) {
3943
+ return this.urlTree.root.children.primary.segments;
3872
3944
  }
3873
3945
  /**
3874
3946
  * Converts the visit into segments. Please not that these segments are not e
3947
+ * @protected
3875
3948
  * @param {?} visit
3876
3949
  * @return {?}
3877
3950
  */
3878
- convertToUrlSegments(visit) {
3951
+ getSegmentsFor(visit) {
3879
3952
  return visit.placeDefinition.hasRouteId() ?
3880
3953
  [
3881
3954
  // NOTE:
@@ -3890,42 +3963,119 @@ class UrlSnapshot {
3890
3963
  ];
3891
3964
  }
3892
3965
  /**
3893
- * @param {?} visit
3966
+ * @param {?} placeDef
3894
3967
  * @return {?}
3895
3968
  */
3896
- createRedirectCommandsFor(visit) {
3897
- /** @type {?} */
3898
- const segments = this.updateVisitSegments(visit);
3899
- /** @type {?} */
3900
- const commands = [];
3901
- segments.forEach((/**
3969
+ includesPathOf(placeDef) {
3970
+ return this.getPrimarySegments(this.urlTree).find((/**
3902
3971
  * @param {?} s
3903
3972
  * @return {?}
3904
3973
  */
3905
- s => {
3906
- commands.push(s.path);
3907
- if (s.parameterMap.keys.length > 0) {
3908
- commands.push(s.parameters);
3909
- }
3910
- }));
3911
- return commands;
3974
+ s => s.path === placeDef.path));
3912
3975
  }
3913
3976
  /**
3914
- * @param {?} placeDef
3915
3977
  * @return {?}
3916
3978
  */
3917
- includesPathOf(placeDef) {
3918
- return this.cloneUrlSegmentList().find((/**
3919
- * @param {?} s
3920
- * @return {?}
3921
- */
3922
- s => s.path === placeDef.path));
3979
+ getInteractionIds() {
3980
+ /** @type {?} */
3981
+ const queryParam = this.urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM];
3982
+ if (queryParam) {
3983
+ return UrlSnapshot.parseInteractionIds(queryParam);
3984
+ }
3985
+ else {
3986
+ return [];
3987
+ }
3988
+ }
3989
+ /**
3990
+ * @return {?}
3991
+ */
3992
+ hasInteractionIds() {
3993
+ return this.getInteractionIds().length > 0;
3994
+ }
3995
+ // @Trace()
3996
+ /**
3997
+ * @param {?} ids
3998
+ * @return {?}
3999
+ */
4000
+ updateInteractionIds(ids) {
4001
+ if (ids.length === 0) {
4002
+ return this.removeInteractionIds();
4003
+ }
4004
+ else {
4005
+ /** @type {?} */
4006
+ const urlTree = this.urlSerializer.parse(this.url);
4007
+ urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM] = UrlSnapshot.createPathIdFor(ids);
4008
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
4009
+ }
4010
+ }
4011
+ // @Trace()
4012
+ /**
4013
+ * @return {?}
4014
+ */
4015
+ removeInteractionIds() {
4016
+ /** @type {?} */
4017
+ const urlTree = this.urlSerializer.parse(this.url);
4018
+ if (urlTree.queryParams && urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM]) {
4019
+ urlTree.queryParams = {}; //[UrlSnapshot.INTERACTION_ROUTER_OUTLET]
4020
+ }
4021
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
4022
+ }
4023
+ /**
4024
+ * @param {?} options
4025
+ * @return {?}
4026
+ */
4027
+ withOptions(options) {
4028
+ return new UrlSnapshot(this.urlSerializer, this.url, options);
4029
+ }
4030
+ /**
4031
+ * @return {?}
4032
+ */
4033
+ getNavigationExtras() {
4034
+ return this.options;
3923
4035
  }
3924
4036
  }
3925
4037
  if (false) {
3926
4038
  /** @type {?} */
3927
4039
  UrlSnapshot.prototype.urlTree;
4040
+ /** @type {?} */
4041
+ UrlSnapshot.prototype.urlSerializer;
4042
+ /** @type {?} */
4043
+ UrlSnapshot.prototype.url;
4044
+ /**
4045
+ * @type {?}
4046
+ * @private
4047
+ */
4048
+ UrlSnapshot.prototype.options;
3928
4049
  }
4050
+ (function (UrlSnapshot) {
4051
+ UrlSnapshot.INTERACTION_QUERY_PARAM = 'aup-interactions';
4052
+ UrlSnapshot.INTERACTION_ID_SEPARATOR = '--';
4053
+ /**
4054
+ * @param {?} path
4055
+ * @return {?}
4056
+ */
4057
+ function parseInteractionIds(path) {
4058
+ return path.split(UrlSnapshot.INTERACTION_ID_SEPARATOR);
4059
+ }
4060
+ UrlSnapshot.parseInteractionIds = parseInteractionIds;
4061
+ /**
4062
+ * @param {?} interactionIds
4063
+ * @return {?}
4064
+ */
4065
+ function createPathIdFor(interactionIds) {
4066
+ return interactionIds.join(UrlSnapshot.INTERACTION_ID_SEPARATOR);
4067
+ }
4068
+ UrlSnapshot.createPathIdFor = createPathIdFor;
4069
+ /**
4070
+ * @record
4071
+ */
4072
+ function NavigationOptions() { }
4073
+ UrlSnapshot.NavigationOptions = NavigationOptions;
4074
+ if (false) {
4075
+ /** @type {?|undefined} */
4076
+ NavigationOptions.prototype.replaceUrl;
4077
+ }
4078
+ })(UrlSnapshot || (UrlSnapshot = {}));
3929
4079
 
3930
4080
  /**
3931
4081
  * @fileoverview added by tsickle
@@ -3937,29 +4087,33 @@ class PlaceRouter extends GarbageCollector {
3937
4087
  * @param {?} urlSerializer
3938
4088
  * @param {?} angularLocation
3939
4089
  * @param {?} placeHistory
3940
- * @param {?} modalInteractionService
4090
+ * @param {?} interactionService
3941
4091
  */
3942
- constructor(router, urlSerializer, angularLocation, placeHistory, modalInteractionService) {
4092
+ constructor(router, urlSerializer, angularLocation, placeHistory, interactionService) {
3943
4093
  super();
3944
4094
  this.router = router;
3945
4095
  this.urlSerializer = urlSerializer;
3946
4096
  this.angularLocation = angularLocation;
3947
4097
  this.placeHistory = placeHistory;
3948
- this.modalInteractionService = modalInteractionService;
3949
- this.firstRoute = true;
3950
- this._navigationSessionModel = new MutableValueModel();
4098
+ this.interactionService = interactionService;
4099
+ this._navigationStateModel = new MutableValueModel();
3951
4100
  this._activeVisits = new MutableListModel();
3952
4101
  const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
3953
4102
  this.activeVisitIndex = chain(this._activeVisits).indexBy('placeDefinition');
3954
- this.navigationSessionActive = chain(this.navigationSessionModel).pluck('active');
3955
- this._navigationSessionContext = new NavigationState.Context(this.router, this.modalInteractionService, this.angularLocation, (/**
4103
+ this.navigationInProgress = chain(this.navigationStateModel).pluck('isTransitional');
4104
+ this._navigationSessionContext = new NavigationState.Context(this, this.interactionService, (/**
3956
4105
  * @param {?} session
3957
4106
  * @return {?}
3958
4107
  */
3959
4108
  session => {
3960
4109
  this.processNavigationSuccess(session);
3961
4110
  }));
3962
- this._navigationSessionModel.value = new NavigationState.Idle(this._navigationSessionContext);
4111
+ this._navigationStateModel.value = new NavigationState.Idle(this._navigationSessionContext);
4112
+ this._navigationStateTypeModel = chain(this._navigationStateModel).map((/**
4113
+ * @param {?} state
4114
+ * @return {?}
4115
+ */
4116
+ state => (/** @type {?} */ (state.constructor))));
3963
4117
  // TODO: make setup the callbacks in during module initiation to make this testable.
3964
4118
  this.router.events.subscribe((/**
3965
4119
  * @param {?} event
@@ -3973,53 +4127,83 @@ class PlaceRouter extends GarbageCollector {
3973
4127
  // NavigationStart -> .... -> NavigationError --> navigation aborted, end session.
3974
4128
  // =======================
3975
4129
  if (event instanceof NavigationStart) {
3976
- this.runStateTransition((/**
3977
- * @param {?} session
3978
- * @return {?}
3979
- */
3980
- session => session.onStart(event)));
4130
+ if (event.navigationTrigger === 'popstate') {
4131
+ this.runStateTransition((/**
4132
+ * @param {?} state
4133
+ * @return {?}
4134
+ */
4135
+ state => state.onPopState(event)));
4136
+ }
4137
+ else {
4138
+ this.runStateTransition((/**
4139
+ * @param {?} state
4140
+ * @return {?}
4141
+ */
4142
+ state => state.onRouterStarted(event)));
4143
+ }
3981
4144
  }
3982
4145
  if (event instanceof NavigationEnd) {
4146
+ console.log(event);
3983
4147
  this.runStateTransition((/**
3984
- * @param {?} session
4148
+ * @param {?} state
3985
4149
  * @return {?}
3986
4150
  */
3987
- session => session.onEnd(event)));
4151
+ state => state.onRouterEnd(event)));
3988
4152
  }
3989
4153
  if (event instanceof NavigationError) {
4154
+ console.log(event);
3990
4155
  this.runStateTransition((/**
3991
- * @param {?} session
4156
+ * @param {?} state
3992
4157
  * @return {?}
3993
4158
  */
3994
- session => session.onError(event)));
4159
+ state => state.onRouterError(event)));
3995
4160
  }
3996
4161
  if (event instanceof NavigationCancel) {
4162
+ console.log(event);
3997
4163
  this.runStateTransition((/**
3998
- * @param {?} session
4164
+ * @param {?} state
3999
4165
  * @return {?}
4000
4166
  */
4001
- session => session.onCancel(event)));
4167
+ state => state.onRouterCancelled(event)));
4002
4168
  }
4003
4169
  }));
4004
4170
  // Push dialog state to the url so we can capture the back button.
4005
- this.modalInteractionService.addActivityListener(new PlaceRouter.InteractionRouteMediator(this.navigationSessionActive, this.router));
4171
+ when.listOf(this.interactionService.activeInteractionContextIds).changes((/**
4172
+ * @param {?} ids
4173
+ * @param {?} previous
4174
+ * @return {?}
4175
+ */
4176
+ (ids, previous) => {
4177
+ this.syncInteractionIdsWithRouter();
4178
+ }), { unless: this.navigationInProgress }); // TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
4179
+ // TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
4180
+ /** @type {?} */
4181
+ const urlChanges = new MutableStream();
4006
4182
  // The angular router doesn't always fire router events when the back button is pushed while a navigation
4007
4183
  // session is in progress. Sometimes we only know about it from the url change.
4184
+ // IMPORTANT ORDER DEPENDENCY
4185
+ // This only works because we're notified of the change after the router has started reacting to it. This
4186
+ // we can can use our navigationState to determine things.
4008
4187
  angularLocation.onUrlChange((/**
4009
4188
  * @param {?} url
4010
4189
  * @return {?}
4011
4190
  */
4012
4191
  url => {
4013
- console.log(`#### url changed ->`, { url, navIsActive: this.navigationSessionActive.value });
4014
4192
  /** @type {?} */
4015
- const interactionContext = this.navigationSessionActive.value && this.navigationSession.interactionContext;
4016
- if (interactionContext && interactionContext.isActive()) {
4017
- Logger.get(this).info(`back button pressed during navigation session interaction`);
4018
- this.runStateTransition((/**
4019
- * @param {?} navigationSession
4020
- * @return {?}
4021
- */
4022
- navigationSession => navigationSession.onBackClickedDuringNavigationInteraction(url)));
4193
+ const navigationState = this._navigationStateModel.value;
4194
+ console.log(`URLChange -> ${url}`, { state: navigationState });
4195
+ urlChanges.publish({ url, state: navigationState });
4196
+ // The url has changed while we're in a transitional state
4197
+ if (navigationState.isTransitional) {
4198
+ /** @type {?} */
4199
+ const navigationInteraction = this.navigationState.interactionContext;
4200
+ if (navigationInteraction && navigationInteraction.isActive()) {
4201
+ this.runStateTransition((/**
4202
+ * @param {?} state
4203
+ * @return {?}
4204
+ */
4205
+ state => state.onBackClickedDuringNavigationInteraction(url)));
4206
+ }
4023
4207
  }
4024
4208
  }));
4025
4209
  }
@@ -4031,7 +4215,7 @@ class PlaceRouter extends GarbageCollector {
4031
4215
  processNavigationSuccess(session) {
4032
4216
  // We need to update the visits before the session finishes. This allows the placeOutets to ignore visit
4033
4217
  // changes that occur while routerNavigationActive is true.
4034
- assert.isTruthy(this.navigationSessionActive.value);
4218
+ assert.isTruthy(this.navigationInProgress.value);
4035
4219
  /** @type {?} */
4036
4220
  const visits = session.getVisits();
4037
4221
  visits.forEach((/**
@@ -4044,14 +4228,14 @@ class PlaceRouter extends GarbageCollector {
4044
4228
  /**
4045
4229
  * @return {?}
4046
4230
  */
4047
- get navigationSession() {
4048
- return this._navigationSessionModel.value;
4231
+ get navigationState() {
4232
+ return this._navigationStateModel.value;
4049
4233
  }
4050
4234
  /**
4051
4235
  * @return {?}
4052
4236
  */
4053
- get navigationSessionModel() {
4054
- return this._navigationSessionModel.readonly;
4237
+ get navigationStateModel() {
4238
+ return this._navigationStateModel.readonly;
4055
4239
  }
4056
4240
  /**
4057
4241
  * @return {?}
@@ -4103,9 +4287,9 @@ class PlaceRouter extends GarbageCollector {
4103
4287
  */
4104
4288
  router => {
4105
4289
  /** @type {?} */
4106
- const commands = this.parseUrl(this.router.routerState.snapshot).createRedirectCommandsFor(next);
4107
- console.log('### Push Changes to route Redirect', { commands });
4108
- return router.navigate(commands);
4290
+ const urlSnapshot = this.parseUrl(this.router.routerState.snapshot.url).updateVisitSegments(next);
4291
+ console.log('### Push Changes to route Redirect', { commands: urlSnapshot.url });
4292
+ return this.navigateByUrl(urlSnapshot);
4109
4293
  }));
4110
4294
  }
4111
4295
  });
@@ -4117,7 +4301,7 @@ class PlaceRouter extends GarbageCollector {
4117
4301
  */
4118
4302
  doNavigation(visit, runNavigationCommands) {
4119
4303
  return __awaiter(this, void 0, void 0, function* () {
4120
- if (this.navigationSessionActive.value) {
4304
+ if (this.navigationInProgress.value) {
4121
4305
  lang.illegalState('Navigation already in progress');
4122
4306
  }
4123
4307
  this.runStateTransition((/**
@@ -4126,7 +4310,7 @@ class PlaceRouter extends GarbageCollector {
4126
4310
  */
4127
4311
  current => {
4128
4312
  /** @type {?} */
4129
- const session = new NavigationState.Active(this._navigationSessionContext, false, this.router.routerState.snapshot.url);
4313
+ const session = this.navigationState.onPlaceNavigationStart(visit, this.getCurrentRouterUrl());
4130
4314
  session.storeVisit(visit);
4131
4315
  return session;
4132
4316
  }));
@@ -4136,16 +4320,17 @@ class PlaceRouter extends GarbageCollector {
4136
4320
  finally {
4137
4321
  // Router has finished (since there was no router change required) so we
4138
4322
  // need to end the navigation session.
4139
- if (this.navigationSession.active && !this.router.getCurrentNavigation()) {
4323
+ if (this.navigationState.isTransitional && !this.router.getCurrentNavigation()) {
4140
4324
  this.runStateTransition((/**
4141
4325
  * @param {?} session
4142
4326
  * @return {?}
4143
4327
  */
4144
- session => session.onEnd(new NavigationEnd(-1, '', ''))));
4328
+ session => session.onRouterEnd(new NavigationEnd(-1, '', ''))));
4145
4329
  }
4146
4330
  }
4147
4331
  });
4148
4332
  }
4333
+ // @Trace()
4149
4334
  /**
4150
4335
  * @protected
4151
4336
  * @param {?} transition
@@ -4153,10 +4338,10 @@ class PlaceRouter extends GarbageCollector {
4153
4338
  */
4154
4339
  runStateTransition(transition) {
4155
4340
  /** @type {?} */
4156
- const previous = this._navigationSessionModel.value;
4341
+ const previous = this._navigationStateModel.value;
4157
4342
  /** @type {?} */
4158
- const next = transition(this.navigationSession);
4159
- this._navigationSessionModel.value = next;
4343
+ const next = transition(this.navigationState);
4344
+ this._navigationStateModel.value = next;
4160
4345
  if (next !== previous) {
4161
4346
  previous.dispose();
4162
4347
  Logger.get(this).info(`Router State Transition: ${previous.toString()} -> ${next.toString()}`);
@@ -4186,11 +4371,76 @@ class PlaceRouter extends GarbageCollector {
4186
4371
  child => child.url)));
4187
4372
  }
4188
4373
  /**
4189
- * @param {?} snapshot
4374
+ * @param {?} url
4375
+ * @return {?}
4376
+ */
4377
+ parseUrl(url) {
4378
+ return new UrlSnapshot(this.urlSerializer, url, {});
4379
+ }
4380
+ /**
4381
+ * @param {?} url
4382
+ * @return {?}
4383
+ */
4384
+ resetBrowserLocation(url) {
4385
+ this.angularLocation.go(url);
4386
+ }
4387
+ /**
4388
+ * @return {?}
4389
+ */
4390
+ getCurrentRouterUrl() {
4391
+ return this.router.routerState ? this.router.routerState.snapshot.url : null;
4392
+ }
4393
+ /**
4394
+ * @return {?}
4395
+ */
4396
+ getCurrentRouteSnapshot() {
4397
+ return this.parseUrl(this.getCurrentRouterUrl());
4398
+ }
4399
+ /**
4400
+ * @param {?} url
4401
+ * @return {?}
4402
+ */
4403
+ getActiveInteractionIdsFromUrl(url) {
4404
+ return this.parseUrl(url).getInteractionIds();
4405
+ }
4406
+ // @Trace()
4407
+ /**
4408
+ * @param {?} url
4409
+ * @return {?}
4410
+ */
4411
+ hasActiveInteractionIds(url) {
4412
+ return this.getActiveInteractionIdsFromUrl(url).length > 0;
4413
+ }
4414
+ // @Trace()
4415
+ /**
4416
+ * @param {?} urlSnapshot
4417
+ * @return {?}
4418
+ */
4419
+ navigateByUrl(urlSnapshot) {
4420
+ this.router.navigateByUrl(urlSnapshot.urlTree, urlSnapshot.getNavigationExtras());
4421
+ }
4422
+ // @Trace()
4423
+ /**
4190
4424
  * @return {?}
4191
4425
  */
4192
- parseUrl(snapshot) {
4193
- return new UrlSnapshot(this.urlSerializer.parse(snapshot.url));
4426
+ syncInteractionIdsWithRouter() {
4427
+ assert.isFalsey(this.navigationInProgress.value); // Updating interaction routes during an existing navigation breaks all the things.
4428
+ // Updating interaction routes during an existing navigation breaks all the things.
4429
+ /** @type {?} */
4430
+ const currentIds = this.interactionService.activeInteractionContextIds.value;
4431
+ if (___default.isEqual(currentIds, this.getActiveInteractionIdsFromUrl(this.getCurrentRouterUrl()))) {
4432
+ console.log('activity ids were the same, skipping');
4433
+ }
4434
+ else {
4435
+ if (currentIds.length < 1) {
4436
+ // no more interactions to remove from history.
4437
+ this.navigateByUrl(this.getCurrentRouteSnapshot().removeInteractionIds());
4438
+ }
4439
+ else {
4440
+ // todo was or is...
4441
+ this.navigateByUrl(this.getCurrentRouteSnapshot().updateInteractionIds(currentIds));
4442
+ }
4443
+ }
4194
4444
  }
4195
4445
  }
4196
4446
  PlaceRouter.decorators = [
@@ -4204,27 +4454,22 @@ PlaceRouter.ctorParameters = () => [
4204
4454
  { type: UrlSerializer },
4205
4455
  { type: Location },
4206
4456
  { type: PlaceHistory },
4207
- { type: ModalInteractionService }
4457
+ { type: InteractionService }
4208
4458
  ];
4209
- /** @nocollapse */ PlaceRouter.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(ɵɵinject(Router), ɵɵinject(UrlSerializer), ɵɵinject(Location), ɵɵinject(PlaceHistory), ɵɵinject(ModalInteractionService)); }, token: PlaceRouter, providedIn: "root" });
4459
+ /** @nocollapse */ PlaceRouter.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(ɵɵinject(Router), ɵɵinject(UrlSerializer), ɵɵinject(Location), ɵɵinject(PlaceHistory), ɵɵinject(InteractionService)); }, token: PlaceRouter, providedIn: "root" });
4210
4460
  if (false) {
4211
4461
  /**
4212
4462
  * @type {?}
4213
4463
  * @private
4214
4464
  */
4215
- PlaceRouter.prototype.firstRoute;
4216
- /**
4217
- * @type {?}
4218
- * @private
4219
- */
4220
- PlaceRouter.prototype._navigationSessionModel;
4465
+ PlaceRouter.prototype._navigationStateModel;
4221
4466
  /**
4222
4467
  * @type {?}
4223
4468
  * @private
4224
4469
  */
4225
4470
  PlaceRouter.prototype._activeVisits;
4226
4471
  /** @type {?} */
4227
- PlaceRouter.prototype.navigationSessionActive;
4472
+ PlaceRouter.prototype.navigationInProgress;
4228
4473
  /** @type {?} */
4229
4474
  PlaceRouter.prototype.activeVisitIndex;
4230
4475
  /**
@@ -4236,85 +4481,33 @@ if (false) {
4236
4481
  * @type {?}
4237
4482
  * @private
4238
4483
  */
4239
- PlaceRouter.prototype.router;
4484
+ PlaceRouter.prototype._navigationStateTypeModel;
4240
4485
  /**
4241
4486
  * @type {?}
4242
4487
  * @private
4243
4488
  */
4244
- PlaceRouter.prototype.urlSerializer;
4489
+ PlaceRouter.prototype.router;
4245
4490
  /**
4246
4491
  * @type {?}
4247
4492
  * @private
4248
4493
  */
4249
- PlaceRouter.prototype.angularLocation;
4494
+ PlaceRouter.prototype.urlSerializer;
4250
4495
  /**
4251
4496
  * @type {?}
4252
4497
  * @private
4253
4498
  */
4254
- PlaceRouter.prototype.placeHistory;
4499
+ PlaceRouter.prototype.angularLocation;
4255
4500
  /**
4256
4501
  * @type {?}
4257
4502
  * @private
4258
4503
  */
4259
- PlaceRouter.prototype.modalInteractionService;
4260
- }
4261
- (function (PlaceRouter) {
4262
- PlaceRouter.INTERACTION_ROUTER_OUTLET = 'aup-interaction';
4263
- class InteractionRouteMediator {
4264
- /**
4265
- * @param {?} navigationSessionModelActive
4266
- * @param {?} router
4267
- */
4268
- constructor(navigationSessionModelActive, router) {
4269
- this.navigationSessionModelActive = navigationSessionModelActive;
4270
- this.router = router;
4271
- }
4272
- /**
4273
- * @return {?}
4274
- */
4275
- get isNavigating() {
4276
- return this.navigationSessionModelActive.value;
4277
- }
4278
- // If we're not in a navigation we push
4279
- // @Trace()
4280
- /**
4281
- * @return {?}
4282
- */
4283
- onActivityStarted() {
4284
- if (!this.isNavigating) {
4285
- this.router.navigate(['.', {
4286
- outlets: {
4287
- [PlaceRouter.INTERACTION_ROUTER_OUTLET]: ['modal'] // "open" must be a valid route for this outlet.
4288
- }
4289
- }], {
4290
- replaceUrl: false
4291
- });
4292
- }
4293
- }
4294
- // @Trace()
4295
- /**
4296
- * @return {?}
4297
- */
4298
- onActivityFinished() {
4299
- if (!this.isNavigating) {
4300
- this.router.navigate(['.', {
4301
- outlets: {
4302
- [PlaceRouter.INTERACTION_ROUTER_OUTLET]: null
4303
- }
4304
- }], {
4305
- replaceUrl: true // remove the interaction from the history.
4306
- });
4307
- }
4308
- }
4309
- }
4310
- PlaceRouter.InteractionRouteMediator = InteractionRouteMediator;
4311
- if (false) {
4312
- /** @type {?} */
4313
- InteractionRouteMediator.prototype.navigationSessionModelActive;
4314
- /** @type {?} */
4315
- InteractionRouteMediator.prototype.router;
4316
- }
4317
- })(PlaceRouter || (PlaceRouter = {}));
4504
+ PlaceRouter.prototype.placeHistory;
4505
+ /**
4506
+ * @type {?}
4507
+ * @private
4508
+ */
4509
+ PlaceRouter.prototype.interactionService;
4510
+ }
4318
4511
 
4319
4512
  /**
4320
4513
  * @fileoverview added by tsickle
@@ -4408,9 +4601,9 @@ class PlaceOutletComponent extends DisposableComponent {
4408
4601
  this.placeChanged = new EventEmitter();
4409
4602
  this._activePlace = new MutableValueModel();
4410
4603
  this._activePlaceVisitModel = new DelegatingValueModel();
4411
- this._inOutletActivation = new Guard$1();
4412
- this._inOutletDeactivation = new Guard$1();
4413
- this._inRouteVisitUpdate = new Guard$1();
4604
+ this._inOutletActivation = new Guard();
4605
+ this._inOutletDeactivation = new Guard();
4606
+ this._inRouteVisitUpdate = new Guard();
4414
4607
  this._activatedRouteModel = new MutableValueModel();
4415
4608
  this._placeDefinition = new MutableValueModel();
4416
4609
  this.initialPlaceIndex = null;
@@ -4470,10 +4663,10 @@ class PlaceOutletComponent extends DisposableComponent {
4470
4663
  (next, previous) => {
4471
4664
  this.pushVisitChangesToRoute(next, previous);
4472
4665
  }), {
4473
- unless: this.placeRouter.navigationSessionActive
4666
+ unless: this.placeRouter.navigationInProgress
4474
4667
  });
4475
4668
  chain(this._activePlace)
4476
- .postponeWhile(placeRouter.navigationSessionActive)
4669
+ .postponeWhile(placeRouter.navigationInProgress)
4477
4670
  .subscribe((/**
4478
4671
  * @param {?} place
4479
4672
  * @return {?}
@@ -5244,40 +5437,279 @@ class ResizeAwareComponent extends DisposableComponent {
5244
5437
  this.onDispose((/**
5245
5438
  * @return {?}
5246
5439
  */
5247
- () => ro.disconnect()));
5248
- }
5249
- /**
5250
- * @return {?}
5251
- */
5252
- get boundsModel() {
5253
- return this._boundsModel.readonly;
5254
- }
5255
- /**
5256
- * @return {?}
5257
- */
5258
- get nativeElement() {
5259
- return this.elementRef.nativeElement;
5260
- }
5261
- // TODO: Make this handle body scroll
5262
- /**
5263
- * @param {?} point
5264
- * @return {?}
5265
- */
5266
- relativePositionOf(point) {
5267
- return this.bounds.relativePositionOf(point);
5268
- }
5269
- /**
5270
- * @return {?}
5271
- */
5272
- get bounds() {
5273
- return this._boundsModel.value;
5440
+ () => ro.disconnect()));
5441
+ }
5442
+ /**
5443
+ * @return {?}
5444
+ */
5445
+ get boundsModel() {
5446
+ return this._boundsModel.readonly;
5447
+ }
5448
+ /**
5449
+ * @return {?}
5450
+ */
5451
+ get nativeElement() {
5452
+ return this.elementRef.nativeElement;
5453
+ }
5454
+ // TODO: Make this handle body scroll
5455
+ /**
5456
+ * @param {?} point
5457
+ * @return {?}
5458
+ */
5459
+ relativePositionOf(point) {
5460
+ return this.bounds.relativePositionOf(point);
5461
+ }
5462
+ /**
5463
+ * @return {?}
5464
+ */
5465
+ get bounds() {
5466
+ return this._boundsModel.value;
5467
+ }
5468
+ /**
5469
+ * @private
5470
+ * @return {?}
5471
+ */
5472
+ updateBounds() {
5473
+ this._boundsModel.value = Bounds.ofElement(this.nativeElement);
5474
+ }
5475
+ }
5476
+ if (false) {
5477
+ /**
5478
+ * @type {?}
5479
+ * @private
5480
+ */
5481
+ ResizeAwareComponent.prototype._boundsModel;
5482
+ /**
5483
+ * @type {?}
5484
+ * @protected
5485
+ */
5486
+ ResizeAwareComponent.prototype.elementRef;
5487
+ /**
5488
+ * @type {?}
5489
+ * @protected
5490
+ */
5491
+ ResizeAwareComponent.prototype.ngZone;
5492
+ }
5493
+
5494
+ /**
5495
+ * @fileoverview added by tsickle
5496
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5497
+ */
5498
+
5499
+ /**
5500
+ * @fileoverview added by tsickle
5501
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5502
+ */
5503
+
5504
+ /**
5505
+ * @fileoverview added by tsickle
5506
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5507
+ */
5508
+ /**
5509
+ * @record
5510
+ */
5511
+ function Alert() { }
5512
+ if (false) {
5513
+ /**
5514
+ * @return {?}
5515
+ */
5516
+ Alert.prototype.title = function () { };
5517
+ /**
5518
+ * @return {?}
5519
+ */
5520
+ Alert.prototype.content = function () { };
5521
+ /**
5522
+ * @return {?}
5523
+ */
5524
+ Alert.prototype.ok = function () { };
5525
+ }
5526
+
5527
+ /**
5528
+ * @fileoverview added by tsickle
5529
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5530
+ */
5531
+ /**
5532
+ * @record
5533
+ */
5534
+ function Confirm() { }
5535
+ if (false) {
5536
+ /** @type {?|undefined} */
5537
+ Confirm.prototype.destructive;
5538
+ /**
5539
+ * @return {?}
5540
+ */
5541
+ Confirm.prototype.cancel = function () { };
5542
+ }
5543
+
5544
+ /**
5545
+ * @fileoverview added by tsickle
5546
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5547
+ */
5548
+ /**
5549
+ * @record
5550
+ * @template R, E
5551
+ */
5552
+ function Result() { }
5553
+ (function (Result) {
5554
+ /**
5555
+ * @record
5556
+ * @template R, E
5557
+ */
5558
+ function Callback() { }
5559
+ Result.Callback = Callback;
5560
+ if (false) {
5561
+ /** @type {?} */
5562
+ Callback.prototype.then;
5563
+ /** @type {?} */
5564
+ Callback.prototype.catch;
5565
+ }
5566
+ })(Result || (Result = {}));
5567
+
5568
+ /**
5569
+ * @fileoverview added by tsickle
5570
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5571
+ */
5572
+ /**
5573
+ * @record
5574
+ * @template D, R, E
5575
+ */
5576
+ function ActivityOutletContext() { }
5577
+ if (false) {
5578
+ /** @type {?} */
5579
+ ActivityOutletContext.prototype.activityClass;
5580
+ /** @type {?} */
5581
+ ActivityOutletContext.prototype.activityData;
5582
+ /**
5583
+ * @param {?} component
5584
+ * @return {?}
5585
+ */
5586
+ ActivityOutletContext.prototype.componentReady = function (component) { };
5587
+ }
5588
+
5589
+ /**
5590
+ * @fileoverview added by tsickle
5591
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5592
+ */
5593
+ class DialogInteractionContext extends InteractionContextBase {
5594
+ /**
5595
+ * @param {?} dialogService
5596
+ * @param {?} config
5597
+ */
5598
+ constructor(dialogService, config) {
5599
+ super();
5600
+ this.dialogService = dialogService;
5601
+ this.config = config;
5602
+ this._activeModel = new MutableValueModel(false);
5603
+ assert$1.notNil(dialogService);
5604
+ this.onDispose((/**
5605
+ * @return {?}
5606
+ */
5607
+ () => {
5608
+ if (this.isActive()) {
5609
+ lang.illegalState('Dispose called while active.');
5610
+ }
5611
+ }));
5612
+ }
5613
+ /**
5614
+ * @return {?}
5615
+ */
5616
+ get active() {
5617
+ return this._activeModel.readonly;
5618
+ }
5619
+ /**
5620
+ * @protected
5621
+ * @template D, R, E
5622
+ * @param {?} activityType
5623
+ * @param {?} data
5624
+ * @param {?=} disableClose
5625
+ * @return {?}
5626
+ */
5627
+ _startActivity(activityType, data, disableClose = true) {
5628
+ if (this.isActive()) {
5629
+ lang.illegalState(`Activity already in progress: ${this.activityList.value.map((/**
5630
+ * @param {?} a
5631
+ * @return {?}
5632
+ */
5633
+ a => a.constructor.name)).join(', ')}`);
5634
+ }
5635
+ this._activeModel.value = true;
5636
+ /** @type {?} */
5637
+ const config = Object.assign({}, this.config, {
5638
+ data,
5639
+ disableClose,
5640
+ panelClass: 'dialog-interaction-context'
5641
+ });
5642
+ /** @type {?} */
5643
+ const self = this;
5644
+ /** @type {?} */
5645
+ const matDialogRef = (/** @type {?} */ (this.dialogService.open(ActivityContainerComponent, config)));
5646
+ return new Promise((/**
5647
+ * @param {?} resolve
5648
+ * @param {?} reject
5649
+ * @return {?}
5650
+ */
5651
+ (resolve, reject) => {
5652
+ /** @type {?} */
5653
+ const activityContainer = matDialogRef.componentInstance;
5654
+ self.safelyUpdateActivityListDelegate(activityContainer.activityList);
5655
+ activityContainer.initialActivityOutletContext = {
5656
+ activityClass: activityType,
5657
+ activityData: data,
5658
+ /**
5659
+ * @param {?} result
5660
+ * @return {?}
5661
+ */
5662
+ onDone(result) {
5663
+ resolve(result);
5664
+ matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
5665
+ },
5666
+ /**
5667
+ * @param {?} error
5668
+ * @return {?}
5669
+ */
5670
+ onCancel(error) {
5671
+ reject(error);
5672
+ matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
5673
+ }
5674
+ };
5675
+ // we need to check if our onDone/onCancel methods above we called or if we were
5676
+ // closed by the user clicking the backdrop. If the later then we need to reject
5677
+ // our promise.
5678
+ matDialogRef.afterClosed().subscribe((/**
5679
+ * @param {?} promiseAlreadyFinished
5680
+ * @return {?}
5681
+ */
5682
+ promiseAlreadyFinished => {
5683
+ if (!promiseAlreadyFinished) {
5684
+ reject('auto-closed');
5685
+ }
5686
+ }));
5687
+ matDialogRef.updateSize();
5688
+ matDialogRef.afterOpened().subscribe((/**
5689
+ * @param {?} promiseAlreadyFinished
5690
+ * @return {?}
5691
+ */
5692
+ promiseAlreadyFinished => {
5693
+ matDialogRef.updateSize();
5694
+ }));
5695
+ })).finally((/**
5696
+ * @return {?}
5697
+ */
5698
+ () => {
5699
+ self.safelyUpdateActivityListDelegate(null);
5700
+ this._activeModel.value = false;
5701
+ }));
5274
5702
  }
5275
5703
  /**
5276
- * @private
5704
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
5705
+ * @param {?} delegate
5277
5706
  * @return {?}
5278
5707
  */
5279
- updateBounds() {
5280
- this._boundsModel.value = Bounds.ofElement(this.nativeElement);
5708
+ safelyUpdateActivityListDelegate(delegate) {
5709
+ setTimeout((/**
5710
+ * @return {?}
5711
+ */
5712
+ () => this.setActivityList(delegate)));
5281
5713
  }
5282
5714
  }
5283
5715
  if (false) {
@@ -5285,112 +5717,68 @@ if (false) {
5285
5717
  * @type {?}
5286
5718
  * @private
5287
5719
  */
5288
- ResizeAwareComponent.prototype._boundsModel;
5289
- /**
5290
- * @type {?}
5291
- * @protected
5292
- */
5293
- ResizeAwareComponent.prototype.elementRef;
5720
+ DialogInteractionContext.prototype._activeModel;
5294
5721
  /**
5295
5722
  * @type {?}
5296
- * @protected
5723
+ * @private
5297
5724
  */
5298
- ResizeAwareComponent.prototype.ngZone;
5725
+ DialogInteractionContext.prototype.dialogService;
5726
+ /** @type {?} */
5727
+ DialogInteractionContext.prototype.config;
5299
5728
  }
5300
5729
 
5301
5730
  /**
5302
5731
  * @fileoverview added by tsickle
5303
5732
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5304
5733
  */
5305
-
5306
- /**
5307
- * @fileoverview added by tsickle
5308
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5309
- */
5310
-
5311
- /**
5312
- * @fileoverview added by tsickle
5313
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5314
- */
5315
- /**
5316
- * @record
5317
- */
5318
- function Alert() { }
5319
- if (false) {
5320
- /**
5321
- * @return {?}
5322
- */
5323
- Alert.prototype.title = function () { };
5324
- /**
5325
- * @return {?}
5326
- */
5327
- Alert.prototype.content = function () { };
5734
+ /** @type {?} */
5735
+ const DIALOG_INTERACTION_SERVICE_DEFAULTS = new InjectionToken('DIALOG_INTERACTION_SERVICE_DEFAULTS');
5736
+ class DialogInteractionContextFactory extends ModalInteractionContextFactory {
5328
5737
  /**
5329
- * @return {?}
5738
+ * @param {?} dialogService
5739
+ * @param {?} dialogServiceDefaults
5740
+ * @param {?} matDialogDefaultConfig
5330
5741
  */
5331
- Alert.prototype.ok = function () { };
5332
- }
5333
-
5334
- /**
5335
- * @fileoverview added by tsickle
5336
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5337
- */
5338
- /**
5339
- * @record
5340
- */
5341
- function Confirm() { }
5342
- if (false) {
5343
- /** @type {?|undefined} */
5344
- Confirm.prototype.destructive;
5742
+ constructor(dialogService, dialogServiceDefaults, matDialogDefaultConfig) {
5743
+ super();
5744
+ this.dialogService = dialogService;
5745
+ this.dialogServiceDefaults = dialogServiceDefaults;
5746
+ this.matDialogDefaultConfig = matDialogDefaultConfig;
5747
+ assert$1.notNil(dialogService);
5748
+ }
5345
5749
  /**
5346
5750
  * @return {?}
5347
5751
  */
5348
- Confirm.prototype.cancel = function () { };
5349
- }
5350
-
5351
- /**
5352
- * @fileoverview added by tsickle
5353
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5354
- */
5355
- /**
5356
- * @record
5357
- * @template R, E
5358
- */
5359
- function Result() { }
5360
- (function (Result) {
5361
- /**
5362
- * @record
5363
- * @template R, E
5364
- */
5365
- function Callback() { }
5366
- Result.Callback = Callback;
5367
- if (false) {
5368
- /** @type {?} */
5369
- Callback.prototype.then;
5752
+ createInteractionContext() {
5370
5753
  /** @type {?} */
5371
- Callback.prototype.catch;
5754
+ const config = Object.assign({ autoFocus: false, hasBackdrop: true, closeOnNavigation: false }, this.matDialogDefaultConfig, this.dialogServiceDefaults);
5755
+ return new DialogInteractionContext(this.dialogService, config);
5372
5756
  }
5373
- })(Result || (Result = {}));
5374
-
5375
- /**
5376
- * @fileoverview added by tsickle
5377
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5378
- */
5379
- /**
5380
- * @record
5381
- * @template D, R, E
5382
- */
5383
- function ActivityOutletContext() { }
5757
+ }
5758
+ DialogInteractionContextFactory.decorators = [
5759
+ { type: Injectable, args: [{
5760
+ providedIn: 'root'
5761
+ },] }
5762
+ ];
5763
+ /** @nocollapse */
5764
+ DialogInteractionContextFactory.ctorParameters = () => [
5765
+ { type: MatDialog },
5766
+ { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [DIALOG_INTERACTION_SERVICE_DEFAULTS,] }] },
5767
+ { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [MAT_DIALOG_DEFAULT_OPTIONS,] }] }
5768
+ ];
5769
+ /** @nocollapse */ DialogInteractionContextFactory.ngInjectableDef = ɵɵdefineInjectable({ factory: function DialogInteractionContextFactory_Factory() { return new DialogInteractionContextFactory(ɵɵinject(MatDialog$1), ɵɵinject(DIALOG_INTERACTION_SERVICE_DEFAULTS, 8), ɵɵinject(MAT_DIALOG_DEFAULT_OPTIONS, 8)); }, token: DialogInteractionContextFactory, providedIn: "root" });
5384
5770
  if (false) {
5385
5771
  /** @type {?} */
5386
- ActivityOutletContext.prototype.activityClass;
5387
- /** @type {?} */
5388
- ActivityOutletContext.prototype.activityData;
5772
+ DialogInteractionContextFactory.prototype.active;
5389
5773
  /**
5390
- * @param {?} component
5391
- * @return {?}
5774
+ * @type {?}
5775
+ * @private
5392
5776
  */
5393
- ActivityOutletContext.prototype.componentReady = function (component) { };
5777
+ DialogInteractionContextFactory.prototype.dialogService;
5778
+ /** @type {?} */
5779
+ DialogInteractionContextFactory.prototype.dialogServiceDefaults;
5780
+ /** @type {?} */
5781
+ DialogInteractionContextFactory.prototype.matDialogDefaultConfig;
5394
5782
  }
5395
5783
 
5396
5784
  /**
@@ -5462,97 +5850,10 @@ function Place(options) {
5462
5850
  Options.prototype.authenticate;
5463
5851
  /** @type {?|undefined} */
5464
5852
  Options.prototype.children;
5465
- /** @type {?|undefined} */
5466
- Options.prototype.defaultChild;
5467
- }
5468
- })(Place || (Place = {}));
5469
-
5470
- /**
5471
- * @fileoverview added by tsickle
5472
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5473
- */
5474
- class VisitSanitiser {
5475
- /**
5476
- * @param {?} activatedRoute
5477
- * @param {?} router
5478
- * @param {?} placeHistory
5479
- * @param {?} injector
5480
- */
5481
- constructor(activatedRoute, router, placeHistory, injector) {
5482
- this.activatedRoute = activatedRoute;
5483
- this.router = router;
5484
- this.placeHistory = placeHistory;
5485
- this.injector = injector;
5486
- }
5487
- // @Trace()
5488
- /**
5489
- * @param {?} visit
5490
- * @return {?}
5491
- */
5492
- sanitise(visit) {
5493
- return __awaiter(this, void 0, void 0, function* () {
5494
- /** @type {?} */
5495
- const placeDef = visit.placeDefinition;
5496
- if (placeDef.hasRouteId()) {
5497
- /** @type {?} */
5498
- const routeIdDef = placeDef.getRouteIdParameterDef();
5499
- /** @type {?} */
5500
- const routeId = visit.getRouteId();
5501
- /** @type {?} */
5502
- const sanitisedValue = yield routeIdDef.sanitise(routeId, visit, this.placeHistory, this.injector);
5503
- // console.log({routeId, sanitisedValue});
5504
- // ###------- EARLY EXIT --------###
5505
- if (routeIdDef.hasChanged(routeId, sanitisedValue)) {
5506
- // if the route id has changed we redirect immediately as other
5507
- // parameter sanitisers might use it.
5508
- return visit.replace(routeIdDef, sanitisedValue);
5509
- }
5510
- }
5511
- // if we didn't replace the routeId we continue the url present parameters.
5512
- /** @type {?} */
5513
- const parameterDefs = placeDef.getVisitParameterDefs({
5514
- includeRouteParameters: true,
5515
- includeNonRouteParameters: true
5516
- });
5517
- /** @type {?} */
5518
- let sanitisedVisit = visit;
5519
- for (let i = 0; i < parameterDefs.length; i++) {
5520
- /** @type {?} */
5521
- const def = parameterDefs[i];
5522
- /** @type {?} */
5523
- const value = visit.getParameter(def.name);
5524
- /** @type {?} */
5525
- const sanitisedValue = yield def.sanitise(value, sanitisedVisit, this.placeHistory, this.injector);
5526
- if (def.hasChanged(value, sanitisedValue)) {
5527
- sanitisedVisit = sanitisedVisit.replace(def, sanitisedValue);
5528
- }
5529
- }
5530
- return sanitisedVisit.hasChangedFrom(visit) ? sanitisedVisit : visit;
5531
- });
5532
- }
5533
- }
5534
- if (false) {
5535
- /**
5536
- * @type {?}
5537
- * @private
5538
- */
5539
- VisitSanitiser.prototype.activatedRoute;
5540
- /**
5541
- * @type {?}
5542
- * @private
5543
- */
5544
- VisitSanitiser.prototype.router;
5545
- /**
5546
- * @type {?}
5547
- * @private
5548
- */
5549
- VisitSanitiser.prototype.placeHistory;
5550
- /**
5551
- * @type {?}
5552
- * @private
5553
- */
5554
- VisitSanitiser.prototype.injector;
5555
- }
5853
+ /** @type {?|undefined} */
5854
+ Options.prototype.defaultChild;
5855
+ }
5856
+ })(Place || (Place = {}));
5556
5857
 
5557
5858
  /**
5558
5859
  * @fileoverview added by tsickle
@@ -5685,6 +5986,120 @@ if (false) {
5685
5986
  ParamMapAdapter.prototype.params;
5686
5987
  }
5687
5988
 
5989
+ /**
5990
+ * @fileoverview added by tsickle
5991
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5992
+ */
5993
+ class NoopAuthGuard {
5994
+ constructor() {
5995
+ }
5996
+ /**
5997
+ * @param {?} activatedRoute
5998
+ * @param {?} state
5999
+ * @return {?}
6000
+ */
6001
+ canActivate(activatedRoute, state) {
6002
+ return __awaiter(this, void 0, void 0, function* () {
6003
+ return true;
6004
+ });
6005
+ }
6006
+ }
6007
+ NoopAuthGuard.decorators = [
6008
+ { type: Injectable, args: [{
6009
+ providedIn: 'root'
6010
+ },] }
6011
+ ];
6012
+ /** @nocollapse */
6013
+ NoopAuthGuard.ctorParameters = () => [];
6014
+ /** @nocollapse */ NoopAuthGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function NoopAuthGuard_Factory() { return new NoopAuthGuard(); }, token: NoopAuthGuard, providedIn: "root" });
6015
+
6016
+ /**
6017
+ * @fileoverview added by tsickle
6018
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6019
+ */
6020
+ class VisitSanitiser {
6021
+ /**
6022
+ * @param {?} activatedRoute
6023
+ * @param {?} router
6024
+ * @param {?} placeHistory
6025
+ * @param {?} injector
6026
+ */
6027
+ constructor(activatedRoute, router, placeHistory, injector) {
6028
+ this.activatedRoute = activatedRoute;
6029
+ this.router = router;
6030
+ this.placeHistory = placeHistory;
6031
+ this.injector = injector;
6032
+ }
6033
+ // @Trace()
6034
+ /**
6035
+ * @param {?} visit
6036
+ * @return {?}
6037
+ */
6038
+ sanitise(visit) {
6039
+ return __awaiter(this, void 0, void 0, function* () {
6040
+ /** @type {?} */
6041
+ const placeDef = visit.placeDefinition;
6042
+ if (placeDef.hasRouteId()) {
6043
+ /** @type {?} */
6044
+ const routeIdDef = placeDef.getRouteIdParameterDef();
6045
+ /** @type {?} */
6046
+ const routeId = visit.getRouteId();
6047
+ /** @type {?} */
6048
+ const sanitisedValue = yield routeIdDef.sanitise(routeId, visit, this.placeHistory, this.injector);
6049
+ // console.log({routeId, sanitisedValue});
6050
+ // ###------- EARLY EXIT --------###
6051
+ if (routeIdDef.hasChanged(routeId, sanitisedValue)) {
6052
+ // if the route id has changed we redirect immediately as other
6053
+ // parameter sanitisers might use it.
6054
+ return visit.replace(routeIdDef, sanitisedValue);
6055
+ }
6056
+ }
6057
+ // if we didn't replace the routeId we continue the url present parameters.
6058
+ /** @type {?} */
6059
+ const parameterDefs = placeDef.getVisitParameterDefs({
6060
+ includeRouteParameters: true,
6061
+ includeNonRouteParameters: true
6062
+ });
6063
+ /** @type {?} */
6064
+ let sanitisedVisit = visit;
6065
+ for (let i = 0; i < parameterDefs.length; i++) {
6066
+ /** @type {?} */
6067
+ const def = parameterDefs[i];
6068
+ /** @type {?} */
6069
+ const value = visit.getParameter(def.name);
6070
+ /** @type {?} */
6071
+ const sanitisedValue = yield def.sanitise(value, sanitisedVisit, this.placeHistory, this.injector);
6072
+ if (def.hasChanged(value, sanitisedValue)) {
6073
+ sanitisedVisit = sanitisedVisit.replace(def, sanitisedValue);
6074
+ }
6075
+ }
6076
+ return sanitisedVisit.hasChangedFrom(visit) ? sanitisedVisit : visit;
6077
+ });
6078
+ }
6079
+ }
6080
+ if (false) {
6081
+ /**
6082
+ * @type {?}
6083
+ * @private
6084
+ */
6085
+ VisitSanitiser.prototype.activatedRoute;
6086
+ /**
6087
+ * @type {?}
6088
+ * @private
6089
+ */
6090
+ VisitSanitiser.prototype.router;
6091
+ /**
6092
+ * @type {?}
6093
+ * @private
6094
+ */
6095
+ VisitSanitiser.prototype.placeHistory;
6096
+ /**
6097
+ * @type {?}
6098
+ * @private
6099
+ */
6100
+ VisitSanitiser.prototype.injector;
6101
+ }
6102
+
5688
6103
  /**
5689
6104
  * @fileoverview added by tsickle
5690
6105
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -5692,19 +6107,21 @@ if (false) {
5692
6107
  /**
5693
6108
  * @abstract
5694
6109
  */
5695
- class AbstractPlaceGuard {
6110
+ class PlaceGuard {
5696
6111
  /**
5697
6112
  * @param {?} router
5698
6113
  * @param {?} urlSerializer
5699
6114
  * @param {?} placeRouter
5700
6115
  * @param {?} placeHistory
6116
+ * @param {?} interactionService
5701
6117
  * @param {?} injector
5702
6118
  */
5703
- constructor(router, urlSerializer, placeRouter, placeHistory, injector) {
6119
+ constructor(router, urlSerializer, placeRouter, placeHistory, interactionService, injector) {
5704
6120
  this.router = router;
5705
6121
  this.urlSerializer = urlSerializer;
5706
6122
  this.placeRouter = placeRouter;
5707
6123
  this.placeHistory = placeHistory;
6124
+ this.interactionService = interactionService;
5708
6125
  this.injector = injector;
5709
6126
  }
5710
6127
  // @Trace()
@@ -5715,40 +6132,47 @@ class AbstractPlaceGuard {
5715
6132
  */
5716
6133
  canActivate(activatedRoute, state) {
5717
6134
  return __awaiter(this, void 0, void 0, function* () {
6135
+ // TODO: this is ugly now that I'm return UrlSnapshots and not UrlTrees. It'd be better if the functions
6136
+ // weren't nested or if I implemented a handler chain.
5718
6137
  return this.authorisePlaceThen(activatedRoute, state, (/**
5719
6138
  * @param {?} placeDefinition
5720
6139
  * @return {?}
5721
6140
  */
5722
6141
  (placeDefinition) => __awaiter(this, void 0, void 0, function* () {
5723
- // Parse our route params.
5724
- /** @type {?} */
5725
- const params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
5726
- /** @type {?} */
5727
- const parsedParams = placeDefinition.parseRouteParams(params);
5728
6142
  /** @type {?} */
5729
- const initialVisit = this.placeRouter.navigationSession.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
5730
- /** @type {?} */
5731
- const sanitiser = new VisitSanitiser(activatedRoute, this.router, this.placeHistory, this.injector);
5732
- /** @type {?} */
5733
- const sanitisedVisit = yield sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams));
5734
- // Save the visit with any updated parameters. We need to save it so we remember any non route parameters
5735
- this.placeRouter.navigationSession.storeVisit(sanitisedVisit);
5736
- if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
5737
- // Regenerate the url
6143
+ const result = yield this.cleanInteractionState(activatedRoute, state, (/**
6144
+ * @return {?}
6145
+ */
6146
+ () => __awaiter(this, void 0, void 0, function* () {
6147
+ // Parse our route params.
5738
6148
  /** @type {?} */
5739
- const commands = this.placeRouter.parseUrl(state).createRedirectCommandsFor(sanitisedVisit);
5740
- console.log('##### Place Guard Redirect', commands);
5741
- return this.router.createUrlTree(commands, {
5742
- replaceUrl: true,
5743
- skipLocationChange: false
5744
- });
5745
- }
5746
- else {
5747
- return true;
5748
- }
6149
+ const params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
6150
+ /** @type {?} */
6151
+ const parsedParams = placeDefinition.parseRouteParams(params);
6152
+ /** @type {?} */
6153
+ const initialVisit = this.placeRouter.navigationState.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
6154
+ /** @type {?} */
6155
+ const sanitiser = new VisitSanitiser(activatedRoute, this.router, this.placeHistory, this.injector);
6156
+ /** @type {?} */
6157
+ const sanitisedVisit = yield sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams));
6158
+ // Save the visit with any updated parameters. We need to save it so we remember any non route parameters
6159
+ this.placeRouter.navigationState.storeVisit(sanitisedVisit);
6160
+ if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
6161
+ // Regenerate the url
6162
+ /** @type {?} */
6163
+ const urlSnapshot = this.placeRouter.parseUrl(state.url).updateVisitSegments(sanitisedVisit);
6164
+ console.log('##### Place Guard Redirect', urlSnapshot);
6165
+ return urlSnapshot;
6166
+ }
6167
+ else {
6168
+ return true;
6169
+ }
6170
+ })));
6171
+ return this.handleGuardResult(result);
5749
6172
  })));
5750
6173
  });
5751
6174
  }
6175
+ // @Trace()
5752
6176
  /**
5753
6177
  * @param {?} component
5754
6178
  * @param {?} currentRoute
@@ -5758,30 +6182,50 @@ class AbstractPlaceGuard {
5758
6182
  */
5759
6183
  canDeactivate(component, currentRoute, currentState, nextState) {
5760
6184
  return __awaiter(this, void 0, void 0, function* () {
5761
- return this.placeRouter.navigationSession.canDeactivatePlace(component, this.placeRouter.parseUrl(nextState));
6185
+ /** @type {?} */
6186
+ const currentUrl = this.placeRouter.parseUrl(currentState.url);
6187
+ /** @type {?} */
6188
+ const nextUrl = this.placeRouter.parseUrl(nextState.url);
6189
+ /** @type {?} */
6190
+ const result = yield this.placeRouter.navigationState.canDeactivatePlace(component, currentUrl, nextUrl);
6191
+ return this.handleGuardResult(result);
5762
6192
  });
5763
6193
  }
6194
+ /**
6195
+ * @private
6196
+ * @param {?} result
6197
+ * @return {?}
6198
+ */
6199
+ handleGuardResult(result) {
6200
+ if (result instanceof UrlSnapshot) {
6201
+ return result.urlTree;
6202
+ }
6203
+ else {
6204
+ return result;
6205
+ }
6206
+ }
5764
6207
  // @Trace()
5765
6208
  /**
5766
6209
  * @protected
5767
6210
  * @param {?} activatedRoute
5768
6211
  * @param {?} state
5769
- * @param {?} canActivate
6212
+ * @param {?} runPlaceGuards
5770
6213
  * @return {?}
5771
6214
  */
5772
- authorisePlaceThen(activatedRoute, state, canActivate) {
6215
+ authorisePlaceThen(activatedRoute, state, runPlaceGuards) {
5773
6216
  return __awaiter(this, void 0, void 0, function* () {
5774
6217
  if (PlaceComponent.isPlaceComponentConstructor(activatedRoute.component)) {
5775
6218
  /** @type {?} */
5776
6219
  const placeDefinition = PlaceComponent.getDefinition(activatedRoute.component);
5777
6220
  /** @type {?} */
5778
- const authorised = placeDefinition.authenticate ? yield this.isAuthorised(activatedRoute, state) : true;
5779
- if (authorised === true) {
5780
- return canActivate(placeDefinition);
6221
+ const authoriseResult = placeDefinition.authenticate ? yield this.isAuthorised(activatedRoute, state) : true;
6222
+ if (authoriseResult === true) {
6223
+ // we're authorised, now run the place guards.
6224
+ return runPlaceGuards(placeDefinition);
5781
6225
  }
5782
6226
  else {
5783
- console.log('not authorised result', authorised);
5784
- return authorised;
6227
+ console.log('not authorised result', authoriseResult);
6228
+ return authoriseResult;
5785
6229
  }
5786
6230
  }
5787
6231
  else {
@@ -5789,6 +6233,7 @@ class AbstractPlaceGuard {
5789
6233
  }
5790
6234
  });
5791
6235
  }
6236
+ // @Trace()
5792
6237
  /**
5793
6238
  * @param {?} activatedRoute
5794
6239
  * @param {?} state
@@ -5801,175 +6246,66 @@ class AbstractPlaceGuard {
5801
6246
  return (authorised instanceof Observable) ? authorised.toPromise() : authorised;
5802
6247
  });
5803
6248
  }
5804
- }
5805
- __decorate([
5806
- Trace(),
5807
- __metadata("design:type", Function),
5808
- __metadata("design:paramtypes", [ActivatedRouteSnapshot, RouterStateSnapshot]),
5809
- __metadata("design:returntype", Promise)
5810
- ], AbstractPlaceGuard.prototype, "isAuthorised", null);
5811
- if (false) {
5812
- /**
5813
- * @type {?}
5814
- * @private
5815
- */
5816
- AbstractPlaceGuard.prototype.router;
5817
- /**
5818
- * @type {?}
5819
- * @private
5820
- */
5821
- AbstractPlaceGuard.prototype.urlSerializer;
5822
- /**
5823
- * @type {?}
5824
- * @private
5825
- */
5826
- AbstractPlaceGuard.prototype.placeRouter;
5827
- /**
5828
- * @type {?}
5829
- * @private
5830
- */
5831
- AbstractPlaceGuard.prototype.placeHistory;
5832
- /**
5833
- * @type {?}
5834
- * @private
5835
- */
5836
- AbstractPlaceGuard.prototype.injector;
5837
- /**
5838
- * @abstract
5839
- * @param {?} injector
5840
- * @return {?}
5841
- */
5842
- AbstractPlaceGuard.prototype.getAuthGuard = function (injector) { };
5843
- }
5844
-
5845
- /**
5846
- * @fileoverview added by tsickle
5847
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5848
- */
5849
- class InteractionGuard {
5850
- /**
5851
- * @param {?} router
5852
- * @param {?} injector
5853
- * @param {?} placeRouter
5854
- * @param {?} angularLocation
5855
- * @param {?} modalInteractionService
5856
- */
5857
- constructor(router, injector, placeRouter, angularLocation, modalInteractionService) {
5858
- this.router = router;
5859
- this.injector = injector;
5860
- this.placeRouter = placeRouter;
5861
- this.angularLocation = angularLocation;
5862
- this.modalInteractionService = modalInteractionService;
5863
- }
6249
+ // @Trace()
5864
6250
  /**
5865
6251
  * @param {?} route
5866
6252
  * @param {?} state
6253
+ * @param {?} then
5867
6254
  * @return {?}
5868
6255
  */
5869
- canActivate(route, state) {
5870
- /** @type {?} */
5871
- const url = this.router.parseUrl(state.url);
5872
- if (!this.modalInteractionService.isActive() && url.root.children[PlaceRouter.INTERACTION_ROUTER_OUTLET]) {
5873
- // This happens if we reload the page or the url was pasted as the route should only be activated
5874
- // after the interaction context has become active.
5875
- delete url.root.children[PlaceRouter.INTERACTION_ROUTER_OUTLET];
5876
- return url;
5877
- }
5878
- else {
5879
- return true;
5880
- }
5881
- }
5882
- /**
5883
- * @param {?} component
5884
- * @param {?} currentRoute
5885
- * @param {?} currentState
5886
- * @param {?=} nextState
5887
- * @return {?}
5888
- */
5889
- canDeactivate(component, currentRoute, currentState, nextState) {
6256
+ cleanInteractionState(route, state, then) {
5890
6257
  return __awaiter(this, void 0, void 0, function* () {
5891
6258
  /** @type {?} */
5892
- const popstateReturnUrl = this.placeRouter.navigationSession.startingUrl;
5893
- if (this.modalInteractionService.isActive()) {
5894
- // The activity is still active so the route change was triggered by the back button.
5895
- /** @type {?} */
5896
- const activity = yield this.modalInteractionService.getCurrentActivity();
5897
- activity.cancel();
5898
- // See ModalInteractionSession#onStart() for the url updating.
5899
- return false;
6259
+ const url = this.placeRouter.parseUrl(state.url);
6260
+ if (!this.interactionService.isActive() && url.hasInteractionIds()) {
6261
+ // This happens if we reload the page or the url was pasted as the route should only be activated
6262
+ // after the interaction context has become active.
6263
+ return url.removeInteractionIds();
6264
+ }
6265
+ else {
6266
+ return then();
5900
6267
  }
5901
- return true;
5902
6268
  });
5903
6269
  }
5904
6270
  }
5905
- InteractionGuard.decorators = [
5906
- { type: Injectable, args: [{
5907
- providedIn: 'root'
5908
- },] }
5909
- ];
5910
- /** @nocollapse */
5911
- InteractionGuard.ctorParameters = () => [
5912
- { type: Router },
5913
- { type: Injector },
5914
- { type: PlaceRouter },
5915
- { type: Location },
5916
- { type: ModalInteractionService }
5917
- ];
5918
- /** @nocollapse */ InteractionGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function InteractionGuard_Factory() { return new InteractionGuard(ɵɵinject(Router), ɵɵinject(INJECTOR), ɵɵinject(PlaceRouter), ɵɵinject(Location), ɵɵinject(ModalInteractionService)); }, token: InteractionGuard, providedIn: "root" });
5919
6271
  if (false) {
5920
6272
  /**
5921
6273
  * @type {?}
5922
6274
  * @private
5923
6275
  */
5924
- InteractionGuard.prototype.router;
6276
+ PlaceGuard.prototype.router;
5925
6277
  /**
5926
6278
  * @type {?}
5927
6279
  * @private
5928
6280
  */
5929
- InteractionGuard.prototype.injector;
6281
+ PlaceGuard.prototype.urlSerializer;
5930
6282
  /**
5931
6283
  * @type {?}
5932
6284
  * @private
5933
6285
  */
5934
- InteractionGuard.prototype.placeRouter;
6286
+ PlaceGuard.prototype.placeRouter;
5935
6287
  /**
5936
6288
  * @type {?}
5937
6289
  * @private
5938
6290
  */
5939
- InteractionGuard.prototype.angularLocation;
6291
+ PlaceGuard.prototype.placeHistory;
5940
6292
  /**
5941
6293
  * @type {?}
5942
6294
  * @private
5943
6295
  */
5944
- InteractionGuard.prototype.modalInteractionService;
5945
- }
5946
-
5947
- /**
5948
- * @fileoverview added by tsickle
5949
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5950
- */
5951
- class NoopAuthGuard {
5952
- constructor() {
5953
- }
6296
+ PlaceGuard.prototype.interactionService;
5954
6297
  /**
5955
- * @param {?} activatedRoute
5956
- * @param {?} state
6298
+ * @type {?}
6299
+ * @private
6300
+ */
6301
+ PlaceGuard.prototype.injector;
6302
+ /**
6303
+ * @abstract
6304
+ * @param {?} injector
5957
6305
  * @return {?}
5958
6306
  */
5959
- canActivate(activatedRoute, state) {
5960
- return __awaiter(this, void 0, void 0, function* () {
5961
- return true;
5962
- });
5963
- }
6307
+ PlaceGuard.prototype.getAuthGuard = function (injector) { };
5964
6308
  }
5965
- NoopAuthGuard.decorators = [
5966
- { type: Injectable, args: [{
5967
- providedIn: 'root'
5968
- },] }
5969
- ];
5970
- /** @nocollapse */
5971
- NoopAuthGuard.ctorParameters = () => [];
5972
- /** @nocollapse */ NoopAuthGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function NoopAuthGuard_Factory() { return new NoopAuthGuard(); }, token: NoopAuthGuard, providedIn: "root" });
5973
6309
 
5974
6310
  /**
5975
6311
  * @fileoverview added by tsickle
@@ -6218,5 +6554,5 @@ if (false) {
6218
6554
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6219
6555
  */
6220
6556
 
6221
- export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractActivity, AbstractInputComponent, AbstractPlaceGuard, AbstractPlaceNavigationComponent, Activity, ActivityContainerComponent, ActivityOutletComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CommandDirective, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DialogInteractionContext, DialogInteractionService, Dimension, DirectivesModule, DisposableComponent, EmptyStateComponent, FocusBindingDirective, Formatter, InplaceInteractionContextComponent, InteractionContext, InteractionContextBase, InteractionGuard, InteractionModule, InteractionOutletComponent, LEFT_RIGHT_PLACE_ANIMATION, ListPlaceNavComponent, ModalInteractionService, NavigationState, NoopAuthGuard, NoopComponent, NumberInputComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, ROUTE_PARAMETER_LIST_KEY, ResizeAwareComponent, RouteId, SelectInputComponent, StringInputComponent, TabbedPlaceNavigationComponent, UrlSnapshot, Visit, VisitParameter, VisitParameterList, VisitSanitiser, leftRightPlaceAnimation, slideDownAndUpAnimation, DirectivesModule as ɵa, CommandDirective as ɵb, ActivityContainerComponent as ɵba, InteractionContextBase as ɵbb, InteractionContext as ɵbc, ActivityOutletComponent as ɵbd, ConfirmationDialogComponent as ɵbe, AbstractActivity as ɵbf, ACTIVITY_DATA as ɵbg, Activity as ɵbh, ConfirmThenDialogComponent as ɵbj, AlertDialogComponent as ɵbk, InteractionOutletComponent as ɵbm, InplaceInteractionContextComponent as ɵbn, DIALOG_INTERACTION_SERVICE_DEFAULTS as ɵbo, DialogInteractionService as ɵbp, FocusBindingDirective as ɵc, DisposableComponent as ɵd, ComponentsModule as ɵe, NumberInputComponent as ɵf, AbstractInputComponent as ɵg, StringInputComponent as ɵh, PasswordInputComponent as ɵi, SelectInputComponent as ɵj, NoopComponent as ɵk, PlaceModule as ɵl, EmptyStateComponent as ɵm, BusyOverlayComponent as ɵn, PlaceOutletComponent as ɵo, leftRightPlaceAnimation as ɵp, LEFT_RIGHT_PLACE_ANIMATION as ɵq, AUP_PLACE_CONFIG as ɵr, PlaceRouter as ɵt, PlaceHistory as ɵu, ModalInteractionService as ɵv, TabbedPlaceNavigationComponent as ɵw, AbstractPlaceNavigationComponent as ɵx, ListPlaceNavComponent as ɵy, InteractionModule as ɵz };
6557
+ export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractActivity, AbstractInputComponent, AbstractPlaceNavigationComponent, Activity, ActivityContainerComponent, ActivityOutletComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CommandDirective, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DialogInteractionContext, DialogInteractionContextFactory, Dimension, DirectivesModule, DisposableComponent, EmptyStateComponent, FocusBindingDirective, Formatter, InplaceInteractionContextComponent, InteractionContext, InteractionContextBase, InteractionModule, InteractionOutletComponent, InteractionService, LEFT_RIGHT_PLACE_ANIMATION, ListPlaceNavComponent, ModalInteractionContextFactory, NavigationState, NoopAuthGuard, NoopComponent, NumberInputComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceGuard, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, ROUTE_PARAMETER_LIST_KEY, ResizeAwareComponent, RouteId, SelectInputComponent, StringInputComponent, TabbedPlaceNavigationComponent, UrlSnapshot, Visit, VisitParameter, VisitParameterList, VisitSanitiser, leftRightPlaceAnimation, slideDownAndUpAnimation, DirectivesModule as ɵa, CommandDirective as ɵb, InteractionModule as ɵba, ActivityContainerComponent as ɵbb, InteractionContextBase as ɵbc, InteractionContext as ɵbd, ActivityOutletComponent as ɵbe, ConfirmationDialogComponent as ɵbf, AbstractActivity as ɵbg, ACTIVITY_DATA as ɵbh, Activity as ɵbi, ConfirmThenDialogComponent as ɵbk, AlertDialogComponent as ɵbl, InteractionOutletComponent as ɵbn, InplaceInteractionContextComponent as ɵbo, FocusBindingDirective as ɵc, DisposableComponent as ɵd, ComponentsModule as ɵe, NumberInputComponent as ɵf, AbstractInputComponent as ɵg, StringInputComponent as ɵh, PasswordInputComponent as ɵi, SelectInputComponent as ɵj, NoopComponent as ɵk, PlaceModule as ɵl, EmptyStateComponent as ɵm, BusyOverlayComponent as ɵn, PlaceOutletComponent as ɵo, leftRightPlaceAnimation as ɵp, LEFT_RIGHT_PLACE_ANIMATION as ɵq, AUP_PLACE_CONFIG as ɵr, PlaceRouter as ɵt, PlaceHistory as ɵu, InteractionService as ɵv, ModalInteractionContextFactory as ɵw, TabbedPlaceNavigationComponent as ɵx, AbstractPlaceNavigationComponent as ɵy, ListPlaceNavComponent as ɵz };
6222
6558
  //# sourceMappingURL=coolon-angular-ui-powerups.js.map