@coolon/angular-ui-powerups 0.0.98 → 0.0.101

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 (70) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +1351 -1109
  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 +19 -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.js +7 -53
  13. package/esm2015/lib/interaction/interaction.module.js +3 -3
  14. package/esm2015/lib/interaction/services/interaction.service.js +228 -0
  15. package/esm2015/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context-factory.js +62 -0
  16. package/esm2015/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context.js +145 -0
  17. package/esm2015/lib/interaction/services/modal-interaction-context.factory.js +17 -0
  18. package/esm2015/lib/place/components/place-outlet/place-outlet.component.js +3 -3
  19. package/esm2015/lib/place/guards/abstract-place.guard.js +13 -12
  20. package/esm2015/lib/place/guards/interaction.guard.js +27 -19
  21. package/esm2015/lib/place/guards/navigation-state.js +309 -246
  22. package/esm2015/lib/place/place-router.js +160 -115
  23. package/esm2015/lib/place/url-snapshot.js +91 -19
  24. package/esm2015/public_api.js +2 -2
  25. package/esm5/coolon-angular-ui-powerups.js +19 -19
  26. package/esm5/index.js +2 -2
  27. package/esm5/lib/interaction/components/activity-container/activity-container.component.js +23 -14
  28. package/esm5/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.js +10 -3
  29. package/esm5/lib/interaction/index.js +5 -4
  30. package/esm5/lib/interaction/interaction-context.js +8 -61
  31. package/esm5/lib/interaction/interaction.module.js +3 -3
  32. package/esm5/lib/interaction/services/interaction.service.js +271 -0
  33. package/esm5/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context-factory.js +65 -0
  34. package/esm5/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context.js +170 -0
  35. package/esm5/lib/interaction/services/modal-interaction-context.factory.js +27 -0
  36. package/esm5/lib/place/components/place-outlet/place-outlet.component.js +3 -3
  37. package/esm5/lib/place/guards/abstract-place.guard.js +15 -14
  38. package/esm5/lib/place/guards/interaction.guard.js +25 -17
  39. package/esm5/lib/place/guards/navigation-state.js +422 -292
  40. package/esm5/lib/place/place-router.js +182 -133
  41. package/esm5/lib/place/url-snapshot.js +105 -21
  42. package/esm5/public_api.js +2 -2
  43. package/fesm2015/coolon-angular-ui-powerups.js +1112 -918
  44. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  45. package/fesm5/coolon-angular-ui-powerups.js +1302 -1060
  46. package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
  47. package/lib/interaction/components/activity-container/activity-container.component.d.ts +1 -0
  48. package/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.d.ts +3 -1
  49. package/lib/interaction/index.d.ts +4 -3
  50. package/lib/interaction/interaction-context.d.ts +2 -11
  51. package/lib/interaction/services/interaction.service.d.ts +46 -0
  52. package/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context-factory.d.ts +15 -0
  53. package/lib/interaction/services/{dialog-interaction-context.d.ts → mat-dialog-interaction/dialog-interaction-context.d.ts} +2 -2
  54. package/lib/interaction/services/modal-interaction-context.factory.d.ts +4 -0
  55. package/lib/place/guards/abstract-place.guard.d.ts +1 -1
  56. package/lib/place/guards/interaction.guard.d.ts +3 -3
  57. package/lib/place/guards/navigation-state.d.ts +65 -37
  58. package/lib/place/place-router.d.ts +15 -22
  59. package/lib/place/url-snapshot.d.ts +18 -6
  60. package/package.json +1 -1
  61. package/schematics/place-routes/templates/place-routes.ts.template +3 -3
  62. package/styles/styles.scss +1 -1
  63. package/esm2015/lib/interaction/services/dialog-interaction-context.js +0 -163
  64. package/esm2015/lib/interaction/services/dialog-interaction.service.js +0 -151
  65. package/esm2015/lib/interaction/services/modal-interaction.service.js +0 -109
  66. package/esm5/lib/interaction/services/dialog-interaction-context.js +0 -188
  67. package/esm5/lib/interaction/services/dialog-interaction.service.js +0 -179
  68. package/esm5/lib/interaction/services/modal-interaction.service.js +0 -153
  69. package/lib/interaction/services/dialog-interaction.service.d.ts +0 -24
  70. package/lib/interaction/services/modal-interaction.service.d.ts +0 -15
@@ -1,16 +1,15 @@
1
1
  import { DOCUMENT, CommonModule, Location } from '@angular/common';
2
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';
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
7
  import { __extends, __decorate, __metadata, __awaiter, __generator, __assign, __spread } from 'tslib';
8
- import { DelegatingValueModel, assert, UnaryCommand, lang, Dsl, GarbageCollector, 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';
8
+ import { DelegatingValueModel, assert, UnaryCommand, lang, Dsl, GarbageCollector, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, DelegatingListModel, Deferred, MutableStream, MutableValueModel, MutableListModel, Binding, Trace, Guard, StoreInValueModel, Command, OptionsHelper, ValueHolder } from '@coolon/pectin';
9
9
  import { PortalModule } from '@angular/cdk/portal';
10
- import { RouterModule, NavigationStart, NavigationCancel, NavigationError, NavigationEnd, UrlSegment, Router, UrlSerializer, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
10
+ import { RouterModule, UrlSegment, UrlSegmentGroup, NavigationStart, NavigationEnd, NavigationError, NavigationCancel, Router, UrlSerializer, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
11
11
  import ___default, { last, isNil, isEqual } from 'lodash';
12
12
  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
13
  import { MatIconModule } from '@angular/material/icon';
15
14
  import { MatListModule } from '@angular/material/list';
16
15
  import { MatTooltipModule } from '@angular/material/tooltip';
@@ -19,6 +18,7 @@ import { Memoize as Memoize$1 } from '@typescript-plus/fast-memoize-decorator';
19
18
  import 'reflect-metadata';
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
  /**
@@ -1106,9 +1106,7 @@ var /**
1106
1106
  InteractionContext = /** @class */ (function (_super) {
1107
1107
  __extends(InteractionContext, _super);
1108
1108
  function InteractionContext() {
1109
- var _this = _super !== null && _super.apply(this, arguments) || this;
1110
- _this.activityListeners = new EventListenerList();
1111
- return _this;
1109
+ return _super !== null && _super.apply(this, arguments) || this;
1112
1110
  }
1113
1111
  /**
1114
1112
  * Returns true if an activity is currently running.
@@ -1125,54 +1123,20 @@ InteractionContext = /** @class */ (function (_super) {
1125
1123
  return this.active.value;
1126
1124
  };
1127
1125
  /**
1128
- * @param {?} listener
1129
- * @return {?}
1130
- */
1131
- InteractionContext.prototype.addActivityListener = /**
1132
- * @param {?} listener
1133
- * @return {?}
1134
- */
1135
- function (listener) {
1136
- return this.activityListeners.add(listener);
1137
- };
1138
- /**
1139
- * @protected
1140
- * @return {?}
1141
- */
1142
- InteractionContext.prototype.notifyActivityStarted = /**
1143
- * @protected
1144
- * @return {?}
1145
- */
1146
- function () {
1147
- this.activityListeners.fire((/**
1148
- * @param {?} l
1149
- * @return {?}
1150
- */
1151
- function (l) { return l.onActivityStarted(); }));
1152
- };
1153
- /**
1154
- * @protected
1155
1126
  * @return {?}
1156
1127
  */
1157
- InteractionContext.prototype.notifyActivityFinished = /**
1158
- * @protected
1128
+ InteractionContext.prototype.dispose = /**
1159
1129
  * @return {?}
1160
1130
  */
1161
1131
  function () {
1162
- this.activityListeners.fire((/**
1163
- * @param {?} l
1164
- * @return {?}
1165
- */
1166
- function (l) { return l.onActivityFinished(); }));
1132
+ // TODO: think about auto cancelling any outstanding activity on dispose.
1133
+ // See NavigationState.Navigating for a use-case.
1134
+ assert.isFalsey(this.isActive());
1135
+ _super.prototype.dispose.call(this);
1167
1136
  };
1168
1137
  return InteractionContext;
1169
1138
  }(GarbageCollector));
1170
1139
  if (false) {
1171
- /**
1172
- * @type {?}
1173
- * @private
1174
- */
1175
- InteractionContext.prototype.activityListeners;
1176
1140
  /** @type {?} */
1177
1141
  InteractionContext.prototype.activityList;
1178
1142
  /** @type {?} */
@@ -1221,23 +1185,6 @@ if (false) {
1221
1185
  */
1222
1186
  InteractionContext.prototype.confirmThen = function (confirm, activityType, data) { };
1223
1187
  }
1224
- (function (InteractionContext) {
1225
- /**
1226
- * @record
1227
- */
1228
- function Listener() { }
1229
- InteractionContext.Listener = Listener;
1230
- if (false) {
1231
- /**
1232
- * @return {?}
1233
- */
1234
- Listener.prototype.onActivityStarted = function () { };
1235
- /**
1236
- * @return {?}
1237
- */
1238
- Listener.prototype.onActivityFinished = function () { };
1239
- }
1240
- })(InteractionContext || (InteractionContext = {}));
1241
1188
 
1242
1189
  /**
1243
1190
  * @fileoverview added by tsickle
@@ -1817,6 +1764,15 @@ TabContext = /** @class */ (function () {
1817
1764
  this._complete = true;
1818
1765
  this.activityCallbacks.onCancel(error);
1819
1766
  };
1767
+ /**
1768
+ * @return {?}
1769
+ */
1770
+ TabContext.prototype.dispose = /**
1771
+ * @return {?}
1772
+ */
1773
+ function () {
1774
+ this.component.dispose();
1775
+ };
1820
1776
  return TabContext;
1821
1777
  }());
1822
1778
  if (false) {
@@ -1906,20 +1862,10 @@ var ActivityContainerComponent = /** @class */ (function (_super) {
1906
1862
  enumerable: true,
1907
1863
  configurable: true
1908
1864
  });
1909
- // get isFinished() {
1910
- // return !this._initialActivityOutletContext;
1911
- // }
1912
- // get isFinished() {
1913
- // return !this._initialActivityOutletContext;
1914
- // }
1915
1865
  /**
1916
1866
  * @return {?}
1917
1867
  */
1918
- ActivityContainerComponent.prototype.ngOnInit =
1919
- // get isFinished() {
1920
- // return !this._initialActivityOutletContext;
1921
- // }
1922
- /**
1868
+ ActivityContainerComponent.prototype.ngOnInit = /**
1923
1869
  * @return {?}
1924
1870
  */
1925
1871
  function () {
@@ -2033,14 +1979,24 @@ var ActivityContainerComponent = /** @class */ (function (_super) {
2033
1979
  * @return {?}
2034
1980
  */
2035
1981
  function () {
2036
- var _this = this;
2037
1982
  if (this.tabs.selectedIndex < this.activityTabs.length - 1) {
1983
+ /** @type {?} */
1984
+ var tabs = this.activityTabs.value;
1985
+ /** @type {?} */
1986
+ var remainingActivities_1 = tabs.slice(0, 1 + this.tabs.selectedIndex);
1987
+ /** @type {?} */
1988
+ var finishedActivityTabs = tabs.slice(1 + this.tabs.selectedIndex);
1989
+ finishedActivityTabs.forEach((/**
1990
+ * @param {?} a
1991
+ * @return {?}
1992
+ */
1993
+ function (a) { return a.dispose(); }));
2038
1994
  this.activityTabs.runInTransaction((/**
2039
1995
  * @param {?} draft
2040
1996
  * @return {?}
2041
1997
  */
2042
1998
  function (draft) {
2043
- draft.value = draft.value.slice(0, 1 + _this.tabs.selectedIndex);
1999
+ draft.value = remainingActivities_1;
2044
2000
  }));
2045
2001
  }
2046
2002
  };
@@ -2167,6 +2123,292 @@ if (false) {
2167
2123
  ActivityContainerComponent.prototype._activityList;
2168
2124
  }
2169
2125
 
2126
+ /**
2127
+ * @fileoverview added by tsickle
2128
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2129
+ */
2130
+ /**
2131
+ * @abstract
2132
+ */
2133
+ var /**
2134
+ * @abstract
2135
+ */
2136
+ ModalInteractionContextFactory = /** @class */ (function () {
2137
+ function ModalInteractionContextFactory() {
2138
+ }
2139
+ return ModalInteractionContextFactory;
2140
+ }());
2141
+ if (false) {
2142
+ /**
2143
+ * @abstract
2144
+ * @return {?}
2145
+ */
2146
+ ModalInteractionContextFactory.prototype.createInteractionContext = function () { };
2147
+ }
2148
+
2149
+ /**
2150
+ * @fileoverview added by tsickle
2151
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2152
+ */
2153
+ /** @type {?} */
2154
+ var inplaceMonitorCount = 0;
2155
+ var InteractionService = /** @class */ (function () {
2156
+ function InteractionService(modelInteractionContextFactory) {
2157
+ this.modelInteractionContextFactory = modelInteractionContextFactory;
2158
+ this.garbage = new GarbageCollector();
2159
+ this.exclusiveContext = new MutableValueModel();
2160
+ this._activeModalInteractionContextModel = new MutableValueModel();
2161
+ this._activeInlineInteractionContextModel = new MutableValueModel();
2162
+ var _a = Dsl.disposeWith(this.garbage), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
2163
+ this._activeInteractionContext = chain(this._activeModalInteractionContextModel)
2164
+ .otherwise(this._activeInlineInteractionContextModel)
2165
+ .pluck('interactionContext');
2166
+ this.active = chain(this._activeInteractionContext).isNotNil();
2167
+ this.modelInteractionActive = chain(this._activeModalInteractionContextModel).isNotNil();
2168
+ this.inlineInteractionActive = chain(this._activeInlineInteractionContextModel).isNotNil();
2169
+ // TODO: chain.concat(listOrValueModels) would be nice.
2170
+ this.activeInteractionContextIds = chain(new MutableListModel())
2171
+ .append(this._activeInlineInteractionContextModel)
2172
+ .append(this._activeModalInteractionContextModel)
2173
+ .rejectNil()
2174
+ .pluck('id');
2175
+ }
2176
+ /**
2177
+ * @return {?}
2178
+ */
2179
+ InteractionService.prototype.isActive = /**
2180
+ * @return {?}
2181
+ */
2182
+ function () {
2183
+ return this.active.value;
2184
+ };
2185
+ /**
2186
+ * @param {?} disposable
2187
+ * @return {?}
2188
+ */
2189
+ InteractionService.prototype.createModalInteractionContextFor = /**
2190
+ * @param {?} disposable
2191
+ * @return {?}
2192
+ */
2193
+ function (disposable) {
2194
+ /** @type {?} */
2195
+ var context = this.modelInteractionContextFactory.createInteractionContext();
2196
+ disposable.registerDisposable(new InteractionService.Monitor('modal', context, this._activeModalInteractionContextModel, this.exclusiveContext));
2197
+ return context;
2198
+ };
2199
+ /**
2200
+ * @param {?} interactionContext
2201
+ * @return {?}
2202
+ */
2203
+ InteractionService.prototype._registerInplaceInteractionContext = /**
2204
+ * @param {?} interactionContext
2205
+ * @return {?}
2206
+ */
2207
+ function (interactionContext) {
2208
+ interactionContext.registerDisposable(new InteractionService.Monitor("ip" + ++inplaceMonitorCount, interactionContext, this._activeInlineInteractionContextModel, this.exclusiveContext));
2209
+ };
2210
+ /**
2211
+ * @return {?}
2212
+ */
2213
+ InteractionService.prototype.getCurrentActivity = /**
2214
+ * @return {?}
2215
+ */
2216
+ function () {
2217
+ return __awaiter(this, void 0, void 0, function () {
2218
+ return __generator(this, function (_a) {
2219
+ assert$1.isTruthy(this.isActive());
2220
+ return [2 /*return*/, this._activeInteractionContext.value.getCurrentActivity()];
2221
+ });
2222
+ });
2223
+ };
2224
+ /**
2225
+ * Creates an interaction context that will prevent any other contexts from starting an
2226
+ * activity until it is disposed. This is intended for use by the router for passing
2227
+ * to PlaceComponent.canDeactivate(interactionContext). This ensures components don't
2228
+ * try and interact in a way that we can't track and synchronise with the browser back
2229
+ * button.
2230
+ */
2231
+ /**
2232
+ * Creates an interaction context that will prevent any other contexts from starting an
2233
+ * activity until it is disposed. This is intended for use by the router for passing
2234
+ * to PlaceComponent.canDeactivate(interactionContext). This ensures components don't
2235
+ * try and interact in a way that we can't track and synchronise with the browser back
2236
+ * button.
2237
+ * @return {?}
2238
+ */
2239
+ InteractionService.prototype._createExclusiveModalInteractionContext = /**
2240
+ * Creates an interaction context that will prevent any other contexts from starting an
2241
+ * activity until it is disposed. This is intended for use by the router for passing
2242
+ * to PlaceComponent.canDeactivate(interactionContext). This ensures components don't
2243
+ * try and interact in a way that we can't track and synchronise with the browser back
2244
+ * button.
2245
+ * @return {?}
2246
+ */
2247
+ function () {
2248
+ this.exclusiveContext.value = this.modelInteractionContextFactory.createInteractionContext();
2249
+ /** @type {?} */
2250
+ var self = this;
2251
+ this.exclusiveContext.value.registerDisposable({
2252
+ dispose: /**
2253
+ * @return {?}
2254
+ */
2255
+ function () {
2256
+ self.exclusiveContext.value = null;
2257
+ }
2258
+ });
2259
+ return this.exclusiveContext.value;
2260
+ };
2261
+ InteractionService.decorators = [
2262
+ { type: Injectable, args: [{
2263
+ providedIn: 'root'
2264
+ },] }
2265
+ ];
2266
+ /** @nocollapse */
2267
+ InteractionService.ctorParameters = function () { return [
2268
+ { type: ModalInteractionContextFactory }
2269
+ ]; };
2270
+ /** @nocollapse */ InteractionService.ngInjectableDef = ɵɵdefineInjectable({ factory: function InteractionService_Factory() { return new InteractionService(ɵɵinject(ModalInteractionContextFactory)); }, token: InteractionService, providedIn: "root" });
2271
+ return InteractionService;
2272
+ }());
2273
+ if (false) {
2274
+ /**
2275
+ * @type {?}
2276
+ * @private
2277
+ */
2278
+ InteractionService.prototype.garbage;
2279
+ /** @type {?} */
2280
+ InteractionService.prototype.active;
2281
+ /**
2282
+ * @type {?}
2283
+ * @private
2284
+ */
2285
+ InteractionService.prototype.exclusiveContext;
2286
+ /**
2287
+ * @type {?}
2288
+ * @private
2289
+ */
2290
+ InteractionService.prototype._activeModalInteractionContextModel;
2291
+ /**
2292
+ * @type {?}
2293
+ * @private
2294
+ */
2295
+ InteractionService.prototype._activeInlineInteractionContextModel;
2296
+ /**
2297
+ * @type {?}
2298
+ * @private
2299
+ */
2300
+ InteractionService.prototype._activeInteractionContext;
2301
+ /** @type {?} */
2302
+ InteractionService.prototype.activeInteractionContextIds;
2303
+ /** @type {?} */
2304
+ InteractionService.prototype.modelInteractionActive;
2305
+ /** @type {?} */
2306
+ InteractionService.prototype.inlineInteractionActive;
2307
+ /** @type {?} */
2308
+ InteractionService.prototype.modelInteractionContextFactory;
2309
+ }
2310
+ (function (InteractionService) {
2311
+ /**
2312
+ * @record
2313
+ */
2314
+ function Callback() { }
2315
+ InteractionService.Callback = Callback;
2316
+ if (false) {
2317
+ /**
2318
+ * @param {?} monitor
2319
+ * @return {?}
2320
+ */
2321
+ Callback.prototype.onStarted = function (monitor) { };
2322
+ /**
2323
+ * @param {?} monitor
2324
+ * @return {?}
2325
+ */
2326
+ Callback.prototype.onFinished = function (monitor) { };
2327
+ }
2328
+ var Monitor = /** @class */ (function (_super) {
2329
+ __extends(Monitor, _super);
2330
+ function Monitor(id, interactionContext, currentActiveMonitor, exclusiveContext) {
2331
+ var _this = _super.call(this) || this;
2332
+ _this.id = id;
2333
+ _this.interactionContext = interactionContext;
2334
+ _this.currentActiveMonitor = currentActiveMonitor;
2335
+ _this.exclusiveContext = exclusiveContext;
2336
+ var _a = Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
2337
+ when.valueOf(interactionContext.active).becomesTruthy((/**
2338
+ * @return {?}
2339
+ */
2340
+ function () { return _this.onStarted(); }));
2341
+ when.valueOf(interactionContext.active).becomesFalsey((/**
2342
+ * @return {?}
2343
+ */
2344
+ function () { return _this.onFinished(); }));
2345
+ interactionContext.registerDisposable(_this);
2346
+ return _this;
2347
+ }
2348
+ /**
2349
+ * @protected
2350
+ * @return {?}
2351
+ */
2352
+ Monitor.prototype.onStarted = /**
2353
+ * @protected
2354
+ * @return {?}
2355
+ */
2356
+ function () {
2357
+ this.assertCanStart();
2358
+ this.currentActiveMonitor.value = this;
2359
+ };
2360
+ /**
2361
+ * @private
2362
+ * @return {?}
2363
+ */
2364
+ Monitor.prototype.assertCanStart = /**
2365
+ * @private
2366
+ * @return {?}
2367
+ */
2368
+ function () {
2369
+ assert$1.isFalsey(this.currentActiveMonitor.value);
2370
+ if (this.exclusiveContext.value && this.interactionContext !== this.exclusiveContext.value) {
2371
+ lang.illegalState('Interaction started while exclusive lock active. This is usually because you using a different context during place.canDeactivate(interactionContext)');
2372
+ }
2373
+ };
2374
+ /**
2375
+ * @protected
2376
+ * @return {?}
2377
+ */
2378
+ Monitor.prototype.onFinished = /**
2379
+ * @protected
2380
+ * @return {?}
2381
+ */
2382
+ function () {
2383
+ this.assertCurrentlyActive();
2384
+ this.currentActiveMonitor.value = null;
2385
+ };
2386
+ /**
2387
+ * @private
2388
+ * @return {?}
2389
+ */
2390
+ Monitor.prototype.assertCurrentlyActive = /**
2391
+ * @private
2392
+ * @return {?}
2393
+ */
2394
+ function () {
2395
+ assert$1.isTruthy(this.currentActiveMonitor.value === this);
2396
+ };
2397
+ return Monitor;
2398
+ }(GarbageCollector));
2399
+ InteractionService.Monitor = Monitor;
2400
+ if (false) {
2401
+ /** @type {?} */
2402
+ Monitor.prototype.id;
2403
+ /** @type {?} */
2404
+ Monitor.prototype.interactionContext;
2405
+ /** @type {?} */
2406
+ Monitor.prototype.currentActiveMonitor;
2407
+ /** @type {?} */
2408
+ Monitor.prototype.exclusiveContext;
2409
+ }
2410
+ })(InteractionService || (InteractionService = {}));
2411
+
2170
2412
  /**
2171
2413
  * @fileoverview added by tsickle
2172
2414
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -2176,9 +2418,11 @@ if (false) {
2176
2418
  */
2177
2419
  var InplaceInteractionContextComponent = /** @class */ (function (_super) {
2178
2420
  __extends(InplaceInteractionContextComponent, _super);
2179
- function InplaceInteractionContextComponent() {
2421
+ function InplaceInteractionContextComponent(interactionService) {
2180
2422
  var _this = _super.call(this) || this;
2423
+ _this.interactionService = interactionService;
2181
2424
  _this._active = new MutableValueModel(false);
2425
+ _this.interactionService._registerInplaceInteractionContext(_this);
2182
2426
  return _this;
2183
2427
  }
2184
2428
  /**
@@ -2255,7 +2499,9 @@ var InplaceInteractionContextComponent = /** @class */ (function (_super) {
2255
2499
  }] }
2256
2500
  ];
2257
2501
  /** @nocollapse */
2258
- InplaceInteractionContextComponent.ctorParameters = function () { return []; };
2502
+ InplaceInteractionContextComponent.ctorParameters = function () { return [
2503
+ { type: InteractionService }
2504
+ ]; };
2259
2505
  InplaceInteractionContextComponent.propDecorators = {
2260
2506
  interactionContext: [{ type: ViewChild, args: ['activityContainer', { static: true },] }]
2261
2507
  };
@@ -2271,6 +2517,8 @@ if (false) {
2271
2517
  * @private
2272
2518
  */
2273
2519
  InplaceInteractionContextComponent.prototype._active;
2520
+ /** @type {?} */
2521
+ InplaceInteractionContextComponent.prototype.interactionService;
2274
2522
  }
2275
2523
 
2276
2524
  /**
@@ -2296,500 +2544,8 @@ var InteractionOutletComponent = /** @class */ (function () {
2296
2544
  * @fileoverview added by tsickle
2297
2545
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2298
2546
  */
2299
- var DialogInteractionContext = /** @class */ (function (_super) {
2300
- __extends(DialogInteractionContext, _super);
2301
- function DialogInteractionContext(dialogService, config) {
2302
- var _this = _super.call(this) || this;
2303
- _this.dialogService = dialogService;
2304
- _this.config = config;
2305
- _this._activeModel = new MutableValueModel(false);
2306
- assert$1.notNil(dialogService);
2307
- _this.onDispose((/**
2308
- * @return {?}
2309
- */
2310
- function () {
2311
- if (_this.isActive()) {
2312
- lang.illegalState('Dispose called while active.');
2313
- }
2314
- }));
2315
- return _this;
2316
- }
2317
- Object.defineProperty(DialogInteractionContext.prototype, "active", {
2318
- get: /**
2319
- * @return {?}
2320
- */
2321
- function () {
2322
- return this._activeModel.readonly;
2323
- },
2324
- enumerable: true,
2325
- configurable: true
2326
- });
2327
- /**
2328
- * @protected
2329
- * @template D, R, E
2330
- * @param {?} activityType
2331
- * @param {?} data
2332
- * @param {?=} disableClose
2333
- * @return {?}
2334
- */
2335
- DialogInteractionContext.prototype._startActivity = /**
2336
- * @protected
2337
- * @template D, R, E
2338
- * @param {?} activityType
2339
- * @param {?} data
2340
- * @param {?=} disableClose
2341
- * @return {?}
2342
- */
2343
- function (activityType, data, disableClose) {
2344
- var _this = this;
2345
- if (disableClose === void 0) { disableClose = true; }
2346
- if (this.isActive()) {
2347
- lang.illegalState("Activity already in progress: " + this.activityList.value.map((/**
2348
- * @param {?} a
2349
- * @return {?}
2350
- */
2351
- function (a) { return a.constructor.name; })).join(', '));
2352
- }
2353
- this._activeModel.value = true;
2354
- this.notifyActivityStarted();
2355
- /** @type {?} */
2356
- var config = __assign({}, this.config, {
2357
- data: data,
2358
- disableClose: disableClose,
2359
- panelClass: 'dialog-interaction-service'
2360
- });
2361
- /** @type {?} */
2362
- var self = this;
2363
- /** @type {?} */
2364
- var matDialogRef = (/** @type {?} */ (this.dialogService.open(ActivityContainerComponent, config)));
2365
- return new Promise((/**
2366
- * @param {?} resolve
2367
- * @param {?} reject
2368
- * @return {?}
2369
- */
2370
- function (resolve, reject) {
2371
- /** @type {?} */
2372
- var activityContainer = matDialogRef.componentInstance;
2373
- self.safelyUpdateActivityListDelegate(activityContainer.activityList);
2374
- activityContainer.initialActivityOutletContext = {
2375
- activityClass: activityType,
2376
- activityData: data,
2377
- onDone: /**
2378
- * @param {?} result
2379
- * @return {?}
2380
- */
2381
- function (result) {
2382
- resolve(result);
2383
- matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
2384
- },
2385
- onCancel: /**
2386
- * @param {?} error
2387
- * @return {?}
2388
- */
2389
- function (error) {
2390
- reject(error);
2391
- matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
2392
- }
2393
- };
2394
- // we need to check if our onDone/onCancel methods above we called or if we were
2395
- // closed by the user clicking the backdrop. If the later then we need to reject
2396
- // our promise.
2397
- matDialogRef.afterClosed().subscribe((/**
2398
- * @param {?} promiseAlreadyFinished
2399
- * @return {?}
2400
- */
2401
- function (promiseAlreadyFinished) {
2402
- if (!promiseAlreadyFinished) {
2403
- reject('auto-closed');
2404
- }
2405
- }));
2406
- matDialogRef.updateSize();
2407
- matDialogRef.afterOpened().subscribe((/**
2408
- * @param {?} promiseAlreadyFinished
2409
- * @return {?}
2410
- */
2411
- function (promiseAlreadyFinished) {
2412
- matDialogRef.updateSize();
2413
- }));
2414
- })).finally((/**
2415
- * @return {?}
2416
- */
2417
- function () {
2418
- _this._activeModel.value = false;
2419
- _this.notifyActivityFinished();
2420
- self.safelyUpdateActivityListDelegate(null);
2421
- }));
2422
- };
2423
- /**
2424
- * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
2425
- * @param delegate
2426
- */
2427
- /**
2428
- * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
2429
- * @param {?} delegate
2430
- * @return {?}
2431
- */
2432
- DialogInteractionContext.prototype.safelyUpdateActivityListDelegate = /**
2433
- * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
2434
- * @param {?} delegate
2435
- * @return {?}
2436
- */
2437
- function (delegate) {
2438
- var _this = this;
2439
- setTimeout((/**
2440
- * @return {?}
2441
- */
2442
- function () { return _this.setActivityList(delegate); }));
2443
- };
2444
- DialogInteractionContext.decorators = [
2445
- { type: Injectable, args: [{
2446
- providedIn: 'root'
2447
- },] }
2448
- ];
2449
- /** @nocollapse */
2450
- DialogInteractionContext.ctorParameters = function () { return [
2451
- { type: MatDialog },
2452
- { type: MatDialogConfig }
2453
- ]; };
2454
- /** @nocollapse */ DialogInteractionContext.ngInjectableDef = ɵɵdefineInjectable({ factory: function DialogInteractionContext_Factory() { return new DialogInteractionContext(ɵɵinject(MatDialog$1), ɵɵinject(MatDialogConfig)); }, token: DialogInteractionContext, providedIn: "root" });
2455
- return DialogInteractionContext;
2456
- }(InteractionContextBase));
2457
- if (false) {
2458
- /**
2459
- * @type {?}
2460
- * @private
2461
- */
2462
- DialogInteractionContext.prototype._activeModel;
2463
- /**
2464
- * @type {?}
2465
- * @private
2466
- */
2467
- DialogInteractionContext.prototype.dialogService;
2468
- /** @type {?} */
2469
- DialogInteractionContext.prototype.config;
2470
- }
2471
-
2472
- /**
2473
- * @fileoverview added by tsickle
2474
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2475
- */
2476
- var Guard = /** @class */ (function (_super) {
2477
- __extends(Guard, _super);
2478
- function Guard() {
2479
- return _super.call(this, { initialValue: false }) || this;
2480
- }
2481
- Object.defineProperty(Guard.prototype, "value", {
2482
- get: /**
2483
- * @return {?}
2484
- */
2485
- function () {
2486
- return this.store.read();
2487
- },
2488
- enumerable: true,
2489
- configurable: true
2490
- });
2491
- /**
2492
- * @template R
2493
- * @param {?} fun
2494
- * @return {?}
2495
- */
2496
- Guard.prototype.whileTrue = /**
2497
- * @template R
2498
- * @param {?} fun
2499
- * @return {?}
2500
- */
2501
- function (fun) {
2502
- this.startTransaction().commit(true);
2503
- try {
2504
- return fun();
2505
- }
2506
- finally {
2507
- this.startTransaction().commit(false);
2508
- }
2509
- };
2510
- /**
2511
- * @template R
2512
- * @param {?} fun
2513
- * @param {?=} defaultValue
2514
- * @return {?}
2515
- */
2516
- Guard.prototype.runIfFalse = /**
2517
- * @template R
2518
- * @param {?} fun
2519
- * @param {?=} defaultValue
2520
- * @return {?}
2521
- */
2522
- function (fun, defaultValue) {
2523
- if (defaultValue === void 0) { defaultValue = null; }
2524
- return !this.value ? fun() : defaultValue;
2525
- };
2526
- return Guard;
2527
- }(ValueModel));
2528
- /**
2529
- * @abstract
2530
- */
2531
- var /**
2532
- * @abstract
2533
- */
2534
- ModalInteractionService = /** @class */ (function (_super) {
2535
- __extends(ModalInteractionService, _super);
2536
- function ModalInteractionService() {
2537
- var _this = _super.call(this) || this;
2538
- _this._activityListeners = new EventListenerList();
2539
- return _this;
2540
- }
2541
- /**
2542
- * @return {?}
2543
- */
2544
- ModalInteractionService.prototype.isActive = /**
2545
- * @return {?}
2546
- */
2547
- function () {
2548
- return this.active.value;
2549
- };
2550
- /**
2551
- * @param {?} listener
2552
- * @return {?}
2553
- */
2554
- ModalInteractionService.prototype.addActivityListener = /**
2555
- * @param {?} listener
2556
- * @return {?}
2557
- */
2558
- function (listener) {
2559
- return this._activityListeners.add(listener);
2560
- };
2561
- /**
2562
- * @protected
2563
- * @return {?}
2564
- */
2565
- ModalInteractionService.prototype.notifyActivityStarted = /**
2566
- * @protected
2567
- * @return {?}
2568
- */
2569
- function () {
2570
- this._activityListeners.fire((/**
2571
- * @param {?} l
2572
- * @return {?}
2573
- */
2574
- function (l) { return l.onActivityStarted(); }));
2575
- };
2576
- /**
2577
- * @protected
2578
- * @return {?}
2579
- */
2580
- ModalInteractionService.prototype.notifyActivityFinished = /**
2581
- * @protected
2582
- * @return {?}
2583
- */
2584
- function () {
2585
- this._activityListeners.fire((/**
2586
- * @param {?} l
2587
- * @return {?}
2588
- */
2589
- function (l) { return l.onActivityFinished(); }));
2590
- };
2591
- return ModalInteractionService;
2592
- }(GarbageCollector));
2593
- if (false) {
2594
- /**
2595
- * @type {?}
2596
- * @private
2597
- */
2598
- ModalInteractionService.prototype._activityListeners;
2599
- /** @type {?} */
2600
- ModalInteractionService.prototype.active;
2601
- /**
2602
- * @abstract
2603
- * @param {?} disposable
2604
- * @return {?}
2605
- */
2606
- ModalInteractionService.prototype.createInteractionContextFor = function (disposable) { };
2607
- /**
2608
- * @abstract
2609
- * @return {?}
2610
- */
2611
- ModalInteractionService.prototype.createExclusiveInteractionContext = function () { };
2612
- /**
2613
- * @abstract
2614
- * @return {?}
2615
- */
2616
- ModalInteractionService.prototype.getCurrentActivity = function () { };
2617
- }
2618
-
2619
- /**
2620
- * @fileoverview added by tsickle
2621
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2622
- */
2623
- /** @type {?} */
2624
- var DIALOG_INTERACTION_SERVICE_DEFAULTS = new InjectionToken('DIALOG_INTERACTION_SERVICE_DEFAULTS');
2625
- var DialogInteractionService = /** @class */ (function (_super) {
2626
- __extends(DialogInteractionService, _super);
2627
- function DialogInteractionService(dialogService, dialogServiceDefaults, matDialogDefaultConfig) {
2628
- var _this = _super.call(this) || this;
2629
- _this.dialogService = dialogService;
2630
- _this.dialogServiceDefaults = dialogServiceDefaults;
2631
- _this.matDialogDefaultConfig = matDialogDefaultConfig;
2632
- _this._activeInteractionContextModel = new MutableValueModel();
2633
- assert$1.notNil(dialogService);
2634
- var _a = Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
2635
- _this.active = chain(_this._activeInteractionContextModel).isNotNil();
2636
- return _this;
2637
- }
2638
- /**
2639
- * @param {?} disposable
2640
- * @return {?}
2641
- */
2642
- DialogInteractionService.prototype.createInteractionContextFor = /**
2643
- * @param {?} disposable
2644
- * @return {?}
2645
- */
2646
- function (disposable) {
2647
- return disposable.registerDisposable(this._createInteractionContext());
2648
- };
2649
- /**
2650
- * @return {?}
2651
- */
2652
- DialogInteractionService.prototype._createInteractionContext = /**
2653
- * @return {?}
2654
- */
2655
- function () {
2656
- /** @type {?} */
2657
- var config = __assign({ autoFocus: false, hasBackdrop: true, closeOnNavigation: false }, this.matDialogDefaultConfig, this.dialogServiceDefaults);
2658
- /** @type {?} */
2659
- var self = this;
2660
- /** @type {?} */
2661
- var dialogInteractionContext = new DialogInteractionContext(this.dialogService, config);
2662
- dialogInteractionContext.registerDisposable(dialogInteractionContext.addActivityListener({
2663
- onActivityStarted: /**
2664
- * @return {?}
2665
- */
2666
- function () {
2667
- self.onActivityStarted(dialogInteractionContext);
2668
- },
2669
- onActivityFinished: /**
2670
- * @return {?}
2671
- */
2672
- function () {
2673
- self.onActivityFinished(dialogInteractionContext);
2674
- }
2675
- }));
2676
- return dialogInteractionContext;
2677
- };
2678
- /**
2679
- * @return {?}
2680
- */
2681
- DialogInteractionService.prototype.createExclusiveInteractionContext = /**
2682
- * @return {?}
2683
- */
2684
- function () {
2685
- this.exclusiveContext = this._createInteractionContext();
2686
- /** @type {?} */
2687
- var self = this;
2688
- this.exclusiveContext.registerDisposable({
2689
- dispose: /**
2690
- * @return {?}
2691
- */
2692
- function () {
2693
- self.exclusiveContext = null;
2694
- }
2695
- });
2696
- return this.exclusiveContext;
2697
- };
2698
- // @Trace()
2699
- // @Trace()
2700
- /**
2701
- * @param {?} dialogInteractionContext
2702
- * @return {?}
2703
- */
2704
- DialogInteractionService.prototype.onActivityStarted =
2705
- // @Trace()
2706
- /**
2707
- * @param {?} dialogInteractionContext
2708
- * @return {?}
2709
- */
2710
- function (dialogInteractionContext) {
2711
- assert$1.isFalsey(this.isActive());
2712
- if (this.exclusiveContext && dialogInteractionContext !== this.exclusiveContext) {
2713
- lang.illegalState("Interaction started while exclusive lock active. This is usually because you using a different context during place.canDeactivate(interactionContext)");
2714
- }
2715
- this._activeInteractionContextModel.value = dialogInteractionContext;
2716
- this.notifyActivityStarted();
2717
- };
2718
- // @Trace()
2719
- // @Trace()
2720
- /**
2721
- * @param {?} dialogInteractionContext
2722
- * @return {?}
2723
- */
2724
- DialogInteractionService.prototype.onActivityFinished =
2725
- // @Trace()
2726
- /**
2727
- * @param {?} dialogInteractionContext
2728
- * @return {?}
2729
- */
2730
- function (dialogInteractionContext) {
2731
- assert$1.isTruthy(this._activeInteractionContextModel.value === dialogInteractionContext);
2732
- this._activeInteractionContextModel.value = null;
2733
- this.notifyActivityFinished();
2734
- };
2735
- /**
2736
- * @return {?}
2737
- */
2738
- DialogInteractionService.prototype.getCurrentActivity = /**
2739
- * @return {?}
2740
- */
2741
- function () {
2742
- return __awaiter(this, void 0, void 0, function () {
2743
- return __generator(this, function (_a) {
2744
- assert$1.isTruthy(this.isActive());
2745
- return [2 /*return*/, this._activeInteractionContextModel.value.getCurrentActivity()];
2746
- });
2747
- });
2748
- };
2749
- DialogInteractionService.decorators = [
2750
- { type: Injectable, args: [{
2751
- providedIn: 'root'
2752
- },] }
2753
- ];
2754
- /** @nocollapse */
2755
- DialogInteractionService.ctorParameters = function () { return [
2756
- { type: MatDialog },
2757
- { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [DIALOG_INTERACTION_SERVICE_DEFAULTS,] }] },
2758
- { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [MAT_DIALOG_DEFAULT_OPTIONS,] }] }
2759
- ]; };
2760
- /** @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" });
2761
- return DialogInteractionService;
2762
- }(ModalInteractionService));
2763
- if (false) {
2764
- /**
2765
- * @type {?}
2766
- * @private
2767
- */
2768
- DialogInteractionService.prototype._activeInteractionContextModel;
2769
- /** @type {?} */
2770
- DialogInteractionService.prototype.active;
2771
- /**
2772
- * @type {?}
2773
- * @private
2774
- */
2775
- DialogInteractionService.prototype.exclusiveContext;
2776
- /**
2777
- * @type {?}
2778
- * @private
2779
- */
2780
- DialogInteractionService.prototype.dialogService;
2781
- /** @type {?} */
2782
- DialogInteractionService.prototype.dialogServiceDefaults;
2783
- /** @type {?} */
2784
- DialogInteractionService.prototype.matDialogDefaultConfig;
2785
- }
2786
-
2787
- /**
2788
- * @fileoverview added by tsickle
2789
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2790
- */
2791
- var InteractionModule = /** @class */ (function () {
2792
- function InteractionModule() {
2547
+ var InteractionModule = /** @class */ (function () {
2548
+ function InteractionModule() {
2793
2549
  }
2794
2550
  InteractionModule.decorators = [
2795
2551
  { type: NgModule, args: [{
@@ -2823,7 +2579,7 @@ var InteractionModule = /** @class */ (function () {
2823
2579
  AlertDialogComponent
2824
2580
  ],
2825
2581
  providers: [
2826
- DialogInteractionService,
2582
+ InteractionService,
2827
2583
  ]
2828
2584
  },] }
2829
2585
  ];
@@ -3900,7 +3656,10 @@ if (false) {
3900
3656
  /**
3901
3657
  * @abstract
3902
3658
  */
3903
- var NavigationState = /** @class */ (function (_super) {
3659
+ var /**
3660
+ * @abstract
3661
+ */
3662
+ NavigationState = /** @class */ (function (_super) {
3904
3663
  __extends(NavigationState, _super);
3905
3664
  function NavigationState(context) {
3906
3665
  var _this = _super.call(this) || this;
@@ -3908,6 +3667,36 @@ var NavigationState = /** @class */ (function (_super) {
3908
3667
  _this._visits = new Map();
3909
3668
  return _this;
3910
3669
  }
3670
+ Object.defineProperty(NavigationState.prototype, "idle", {
3671
+ get: /**
3672
+ * @return {?}
3673
+ */
3674
+ function () {
3675
+ return !this.isTransitional;
3676
+ },
3677
+ enumerable: true,
3678
+ configurable: true
3679
+ });
3680
+ Object.defineProperty(NavigationState.prototype, "placeRouter", {
3681
+ get: /**
3682
+ * @return {?}
3683
+ */
3684
+ function () {
3685
+ return this.context.placeRouter;
3686
+ },
3687
+ enumerable: true,
3688
+ configurable: true
3689
+ });
3690
+ Object.defineProperty(NavigationState.prototype, "interactionService", {
3691
+ get: /**
3692
+ * @return {?}
3693
+ */
3694
+ function () {
3695
+ return this.context.interactionService;
3696
+ },
3697
+ enumerable: true,
3698
+ configurable: true
3699
+ });
3911
3700
  Object.defineProperty(NavigationState.prototype, "interactionContext", {
3912
3701
  get: /**
3913
3702
  * @return {?}
@@ -3940,16 +3729,88 @@ var NavigationState = /** @class */ (function (_super) {
3940
3729
  function (placeDef) {
3941
3730
  return this._visits.get(placeDef);
3942
3731
  };
3732
+ /**
3733
+ * @param {?} event
3734
+ * @return {?}
3735
+ */
3736
+ NavigationState.prototype.onPopState = /**
3737
+ * @param {?} event
3738
+ * @return {?}
3739
+ */
3740
+ function (event) {
3741
+ return this.illegalTransition(event);
3742
+ };
3743
+ /**
3744
+ * @param {?} event
3745
+ * @return {?}
3746
+ */
3747
+ NavigationState.prototype.onStart = /**
3748
+ * @param {?} event
3749
+ * @return {?}
3750
+ */
3751
+ function (event) {
3752
+ return this.illegalTransition(event);
3753
+ };
3754
+ /**
3755
+ * @param {?} event
3756
+ * @return {?}
3757
+ */
3758
+ NavigationState.prototype.onCancel = /**
3759
+ * @param {?} event
3760
+ * @return {?}
3761
+ */
3762
+ function (event) {
3763
+ return this.illegalTransition(event);
3764
+ };
3765
+ /**
3766
+ * @param {?} event
3767
+ * @return {?}
3768
+ */
3769
+ NavigationState.prototype.onError = /**
3770
+ * @param {?} event
3771
+ * @return {?}
3772
+ */
3773
+ function (event) {
3774
+ return this.illegalTransition(event);
3775
+ };
3776
+ /**
3777
+ * @param {?} event
3778
+ * @return {?}
3779
+ */
3780
+ NavigationState.prototype.onEnd = /**
3781
+ * @param {?} event
3782
+ * @return {?}
3783
+ */
3784
+ function (event) {
3785
+ return this.illegalTransition(event);
3786
+ };
3943
3787
  /**
3944
3788
  * @param {?} newUrl
3945
3789
  * @return {?}
3946
3790
  */
3947
- NavigationState.prototype.onBackClickedDuringNavigationInteraction = /**
3948
- * @param {?} newUrl
3791
+ NavigationState.prototype.onBackClickedDuringNavigationInteraction = /**
3792
+ * @param {?} newUrl
3793
+ * @return {?}
3794
+ */
3795
+ function (newUrl) {
3796
+ return this.illegalTransition('onBackClickedDuringNavigationInteraction');
3797
+ };
3798
+ /**
3799
+ * @param {?} component
3800
+ * @param {?} nextState
3801
+ * @return {?}
3802
+ */
3803
+ NavigationState.prototype.canDeactivatePlace = /**
3804
+ * @param {?} component
3805
+ * @param {?} nextState
3949
3806
  * @return {?}
3950
3807
  */
3951
- function (newUrl) {
3952
- return this.illegalTransition('onBackClickedDuringNavigationInteraction');
3808
+ function (component, nextState) {
3809
+ return __awaiter(this, void 0, void 0, function () {
3810
+ return __generator(this, function (_a) {
3811
+ return [2 /*return*/, this.illegalTransition('canDeactivatePlace')];
3812
+ });
3813
+ });
3953
3814
  };
3954
3815
  /**
3955
3816
  * @return {?}
@@ -3984,34 +3845,41 @@ var NavigationState = /** @class */ (function (_super) {
3984
3845
  * @return {?}
3985
3846
  */
3986
3847
  function () {
3987
- return this.context.router.routerState ? this.context.router.routerState.snapshot.url : null;
3848
+ return this.placeRouter.getCurrentRouterUrl();
3988
3849
  };
3989
3850
  /**
3990
3851
  * @protected
3991
3852
  * @param {?} event
3992
3853
  * @return {?}
3993
3854
  */
3994
- NavigationState.prototype.createActiveSession = /**
3855
+ NavigationState.prototype.createTransitionStateFor = /**
3995
3856
  * @protected
3996
3857
  * @param {?} event
3997
3858
  * @return {?}
3998
3859
  */
3999
3860
  function (event) {
4000
3861
  // TODO: check if the event is purely for interaction context changes.
4001
- return new NavigationState.Active(this.context, event.navigationTrigger === 'popstate', this.currentRouterUrl());
3862
+ /** @type {?} */
3863
+ var popstate = event.navigationTrigger === 'popstate';
3864
+ return popstate ?
3865
+ new NavigationState.NavigationBackTransition(this.context, popstate, this.currentRouterUrl()) :
3866
+ new NavigationState.NavigationTransition(this.context, popstate, this.currentRouterUrl());
4002
3867
  };
4003
3868
  /**
4004
- * @protected
4005
3869
  * @param {?} url
4006
3870
  * @return {?}
4007
3871
  */
4008
- NavigationState.prototype.updateLocation = /**
4009
- * @protected
3872
+ NavigationState.prototype.resetBrowserLocation = /**
4010
3873
  * @param {?} url
4011
3874
  * @return {?}
4012
3875
  */
4013
3876
  function (url) {
4014
- this.context.angularLocation.go(url);
3877
+ var _this = this;
3878
+ // TODO: Should this be a navigate operation to avoid confusing the router...??
3879
+ setTimeout((/**
3880
+ * @return {?}
3881
+ */
3882
+ function () { return _this.placeRouter.resetBrowserLocation(url); }));
4015
3883
  };
4016
3884
  /**
4017
3885
  * @return {?}
@@ -4022,12 +3890,6 @@ var NavigationState = /** @class */ (function (_super) {
4022
3890
  function () {
4023
3891
  return this.constructor.name;
4024
3892
  };
4025
- __decorate([
4026
- Trace(),
4027
- __metadata("design:type", Function),
4028
- __metadata("design:paramtypes", [Object]),
4029
- __metadata("design:returntype", void 0)
4030
- ], NavigationState.prototype, "updateLocation", null);
4031
3893
  return NavigationState;
4032
3894
  }(GarbageCollector));
4033
3895
  if (false) {
@@ -4037,54 +3899,22 @@ if (false) {
4037
3899
  */
4038
3900
  NavigationState.prototype._visits;
4039
3901
  /** @type {?} */
4040
- NavigationState.prototype.isPopState;
4041
- /** @type {?} */
4042
- NavigationState.prototype.active;
3902
+ NavigationState.prototype.isTransitional;
4043
3903
  /** @type {?} */
4044
3904
  NavigationState.prototype.startingUrl;
3905
+ /** @type {?} */
3906
+ NavigationState.prototype.isPopState;
4045
3907
  /**
4046
3908
  * @type {?}
4047
3909
  * @protected
4048
3910
  */
4049
3911
  NavigationState.prototype.context;
4050
- /**
4051
- * @abstract
4052
- * @param {?} event
4053
- * @return {?}
4054
- */
4055
- NavigationState.prototype.onStart = function (event) { };
4056
- /**
4057
- * @abstract
4058
- * @param {?} event
4059
- * @return {?}
4060
- */
4061
- NavigationState.prototype.onCancel = function (event) { };
4062
- /**
4063
- * @abstract
4064
- * @param {?} event
4065
- * @return {?}
4066
- */
4067
- NavigationState.prototype.onError = function (event) { };
4068
- /**
4069
- * @abstract
4070
- * @param {?} event
4071
- * @return {?}
4072
- */
4073
- NavigationState.prototype.onEnd = function (event) { };
4074
- /**
4075
- * @abstract
4076
- * @param {?} component
4077
- * @param {?} nextState
4078
- * @return {?}
4079
- */
4080
- NavigationState.prototype.canDeactivatePlace = function (component, nextState) { };
4081
3912
  }
4082
3913
  (function (NavigationState) {
4083
3914
  var Context = /** @class */ (function () {
4084
- function Context(router, modalInteractionService, angularLocation, notifySuccess) {
4085
- this.router = router;
4086
- this.modalInteractionService = modalInteractionService;
4087
- this.angularLocation = angularLocation;
3915
+ function Context(placeRouter, interactionService, notifySuccess) {
3916
+ this.placeRouter = placeRouter;
3917
+ this.interactionService = interactionService;
4088
3918
  this.notifySuccess = notifySuccess;
4089
3919
  }
4090
3920
  return Context;
@@ -4092,11 +3922,9 @@ if (false) {
4092
3922
  NavigationState.Context = Context;
4093
3923
  if (false) {
4094
3924
  /** @type {?} */
4095
- Context.prototype.router;
3925
+ Context.prototype.placeRouter;
4096
3926
  /** @type {?} */
4097
- Context.prototype.modalInteractionService;
4098
- /** @type {?} */
4099
- Context.prototype.angularLocation;
3927
+ Context.prototype.interactionService;
4100
3928
  /** @type {?} */
4101
3929
  Context.prototype.notifySuccess;
4102
3930
  }
@@ -4104,27 +3932,11 @@ if (false) {
4104
3932
  __extends(Idle, _super);
4105
3933
  function Idle(context) {
4106
3934
  var _this = _super.call(this, context) || this;
4107
- _this.active = false;
3935
+ _this.isTransitional = false;
4108
3936
  _this.startingUrl = null;
3937
+ _this.isPopState = false;
4109
3938
  return _this;
4110
3939
  }
4111
- /**
4112
- * @param {?} component
4113
- * @param {?} nextState
4114
- * @return {?}
4115
- */
4116
- Idle.prototype.canDeactivatePlace = /**
4117
- * @param {?} component
4118
- * @param {?} nextState
4119
- * @return {?}
4120
- */
4121
- function (component, nextState) {
4122
- return __awaiter(this, void 0, void 0, function () {
4123
- return __generator(this, function (_a) {
4124
- return [2 /*return*/, this.illegalTransition('canDeactivatePlace')];
4125
- });
4126
- });
4127
- };
4128
3940
  /**
4129
3941
  * @param {?} event
4130
3942
  * @return {?}
@@ -4139,65 +3951,51 @@ if (false) {
4139
3951
  Logger.get(this).info("navigation started to same url -> " + event.url);
4140
3952
  return this;
4141
3953
  }
4142
- if (event.url === (this.currentRouterUrl() + "(aup-interaction:modal)")) {
3954
+ if (this.placeRouter.hasActiveInteractionIds(event.url)) {
4143
3955
  Logger.get(this).info("navigation started with interaction outlet -> " + event.url);
4144
- return new ModalInteractionSession(this.context, event.url);
3956
+ return new InteractionTransition(this.context, event.url);
3957
+ }
3958
+ else {
3959
+ return this.createTransitionStateFor(event);
4145
3960
  }
4146
- return this.createActiveSession(event);
4147
- };
4148
- /**
4149
- * @param {?} event
4150
- * @return {?}
4151
- */
4152
- Idle.prototype.onCancel = /**
4153
- * @param {?} event
4154
- * @return {?}
4155
- */
4156
- function (event) {
4157
- return this.illegalTransition(event);
4158
- };
4159
- /**
4160
- * @param {?} event
4161
- * @return {?}
4162
- */
4163
- Idle.prototype.onEnd = /**
4164
- * @param {?} event
4165
- * @return {?}
4166
- */
4167
- function (event) {
4168
- return this.illegalTransition(event);
4169
3961
  };
4170
3962
  /**
4171
3963
  * @param {?} event
4172
3964
  * @return {?}
4173
3965
  */
4174
- Idle.prototype.onError = /**
3966
+ Idle.prototype.onPopState = /**
4175
3967
  * @param {?} event
4176
3968
  * @return {?}
4177
3969
  */
4178
3970
  function (event) {
4179
- return this.illegalTransition(event);
3971
+ return this.createTransitionStateFor(event);
4180
3972
  };
4181
3973
  return Idle;
4182
3974
  }(NavigationState));
4183
3975
  NavigationState.Idle = Idle;
4184
3976
  if (false) {
4185
3977
  /** @type {?} */
4186
- Idle.prototype.isPopState;
4187
- /** @type {?} */
4188
- Idle.prototype.active;
3978
+ Idle.prototype.isTransitional;
4189
3979
  /** @type {?} */
4190
3980
  Idle.prototype.startingUrl;
3981
+ /** @type {?} */
3982
+ Idle.prototype.isPopState;
4191
3983
  }
4192
- var Active = /** @class */ (function (_super) {
4193
- __extends(Active, _super);
4194
- function Active(context, isPopState, startingUrl) {
3984
+ /**
3985
+ * @abstract
3986
+ */
3987
+ var /**
3988
+ * @abstract
3989
+ */
3990
+ AbstractNavigationTransition = /** @class */ (function (_super) {
3991
+ __extends(AbstractNavigationTransition, _super);
3992
+ function AbstractNavigationTransition(context, isPopState, startingUrl) {
4195
3993
  var _this = _super.call(this, context) || this;
4196
3994
  _this.isPopState = isPopState;
4197
3995
  _this.startingUrl = startingUrl;
4198
- _this.active = true;
3996
+ _this.isTransitional = true;
4199
3997
  _this.componentDeactivationHandlers = new Map();
4200
- _this._interactionContext = _this.context.modalInteractionService.createExclusiveInteractionContext();
3998
+ _this._interactionContext = _this.interactionService._createExclusiveModalInteractionContext();
4201
3999
  _this.onDispose((/**
4202
4000
  * @return {?}
4203
4001
  */
@@ -4205,14 +4003,14 @@ if (false) {
4205
4003
  // the interaction context can be detached during the back button cancellation state transition
4206
4004
  // as the transition is synchronous and activityCancellation isn't. Otherwise dispose will be
4207
4005
  // called before the context has been cancelled. It might be work having the interaction context
4208
- // automatically cancel if the context is disposed.
4006
+ // automatically cancel if the context is disposed so we don't have worry about detaching etc.
4209
4007
  if (_this._interactionContext) {
4210
- _this._interactionContext.dispose();
4008
+ _this._interactionContext.dispose(); // or do something like cancelAndDispose?
4211
4009
  }
4212
4010
  }));
4213
4011
  return _this;
4214
4012
  }
4215
- Object.defineProperty(Active.prototype, "interactionContext", {
4013
+ Object.defineProperty(AbstractNavigationTransition.prototype, "interactionContext", {
4216
4014
  get: /**
4217
4015
  * @return {?}
4218
4016
  */
@@ -4226,19 +4024,20 @@ if (false) {
4226
4024
  * @param {?} event
4227
4025
  * @return {?}
4228
4026
  */
4229
- Active.prototype.onStart = /**
4027
+ AbstractNavigationTransition.prototype.onStart = /**
4230
4028
  * @param {?} event
4231
4029
  * @return {?}
4232
4030
  */
4233
4031
  function (event) {
4234
- // active sessions can have many cancel start cycles.
4032
+ // active sessions can have many cancel start cycles due
4033
+ // to place guard redirects
4235
4034
  return this;
4236
4035
  };
4237
4036
  /**
4238
4037
  * @param {?} event
4239
4038
  * @return {?}
4240
4039
  */
4241
- Active.prototype.onEnd = /**
4040
+ AbstractNavigationTransition.prototype.onEnd = /**
4242
4041
  * @param {?} event
4243
4042
  * @return {?}
4244
4043
  */
@@ -4247,70 +4046,31 @@ if (false) {
4247
4046
  this.context.notifySuccess(this);
4248
4047
  return new Idle(this.context);
4249
4048
  };
4250
- /**
4251
- * @param {?} event
4252
- * @return {?}
4253
- */
4254
- Active.prototype.onCancel = /**
4255
- * @param {?} event
4256
- * @return {?}
4257
- */
4258
- function (event) {
4259
- if (this.isPopState) { // back button clicked and a guard cancelled
4260
- // Angular doesn't preserve the url when a guard cancels the back button.
4261
- // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4262
- Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4263
- this.updateLocation(this.startingUrl);
4264
- }
4265
- return this.isPopState ? new Idle(this.context) : this;
4266
- };
4267
- /**
4268
- * @param {?} event
4269
- * @return {?}
4270
- */
4271
- Active.prototype.onError = /**
4272
- * @param {?} event
4273
- * @return {?}
4274
- */
4275
- function (event) {
4276
- // navigation was aborted.
4277
- if (this.isPopState && this.currentRouterUrl() !== this.startingUrl) {
4278
- // Angular doesn't preserve the url when a guard cancels the back button.
4279
- // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4280
- Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4281
- this.updateLocation(this.startingUrl);
4282
- }
4283
- return new Idle(this.context);
4284
- };
4285
4049
  /**
4286
4050
  * @param {?} locationTriggerUrl
4287
4051
  * @return {?}
4288
4052
  */
4289
- Active.prototype.onBackClickedDuringNavigationInteraction = /**
4053
+ AbstractNavigationTransition.prototype.onBackClickedDuringNavigationInteraction = /**
4290
4054
  * @param {?} locationTriggerUrl
4291
4055
  * @return {?}
4292
4056
  */
4293
4057
  function (locationTriggerUrl) {
4058
+ // detach the interactoin from the session so it doesn't get disposed until the activity
4059
+ // has completed.
4294
4060
  /** @type {?} */
4295
4061
  var context = this.detachInteractionContext();
4062
+ var when = Dsl.disposeWith(context).when;
4063
+ // TODO: I need to make the exclusive interaction context disallow nested activities or
4064
+ // that would mess things up entirely.
4296
4065
  context.getCurrentActivity().then((/**
4297
4066
  * @param {?} activity
4298
4067
  * @return {?}
4299
4068
  */
4300
4069
  function (activity) {
4301
- context.addActivityListener({
4302
- onActivityFinished: /**
4303
- * @return {?}
4304
- */
4305
- function () {
4306
- context.dispose();
4307
- },
4308
- onActivityStarted: /**
4309
- * @return {?}
4310
- */
4311
- function () {
4312
- }
4313
- });
4070
+ when.valueOf(context.active).becomesFalsey((/**
4071
+ * @return {?}
4072
+ */
4073
+ function () { return context.dispose(); }), { once: true });
4314
4074
  activity.cancel(null);
4315
4075
  }));
4316
4076
  return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, locationTriggerUrl);
@@ -4320,7 +4080,7 @@ if (false) {
4320
4080
  * @param {?} nextState
4321
4081
  * @return {?}
4322
4082
  */
4323
- Active.prototype.canDeactivatePlace = /**
4083
+ AbstractNavigationTransition.prototype.canDeactivatePlace = /**
4324
4084
  * @param {?} component
4325
4085
  * @param {?} nextState
4326
4086
  * @return {?}
@@ -4344,7 +4104,7 @@ if (false) {
4344
4104
  * @private
4345
4105
  * @return {?}
4346
4106
  */
4347
- Active.prototype.detachInteractionContext = /**
4107
+ AbstractNavigationTransition.prototype.detachInteractionContext = /**
4348
4108
  * @private
4349
4109
  * @return {?}
4350
4110
  */
@@ -4354,180 +4114,304 @@ if (false) {
4354
4114
  this._interactionContext = null;
4355
4115
  return context;
4356
4116
  };
4117
+ return AbstractNavigationTransition;
4118
+ }(NavigationState));
4119
+ NavigationState.AbstractNavigationTransition = AbstractNavigationTransition;
4120
+ if (false) {
4121
+ /** @type {?} */
4122
+ AbstractNavigationTransition.prototype.isTransitional;
4123
+ /**
4124
+ * @type {?}
4125
+ * @private
4126
+ */
4127
+ AbstractNavigationTransition.prototype.componentDeactivationHandlers;
4128
+ /**
4129
+ * @type {?}
4130
+ * @private
4131
+ */
4132
+ AbstractNavigationTransition.prototype._interactionContext;
4133
+ /** @type {?} */
4134
+ AbstractNavigationTransition.prototype.isPopState;
4135
+ /** @type {?} */
4136
+ AbstractNavigationTransition.prototype.startingUrl;
4137
+ }
4138
+ var NavigationTransition = /** @class */ (function (_super) {
4139
+ __extends(NavigationTransition, _super);
4140
+ function NavigationTransition() {
4141
+ var _this = _super !== null && _super.apply(this, arguments) || this;
4142
+ _this.isPopState = false;
4143
+ return _this;
4144
+ }
4145
+ /**
4146
+ * @param {?} event
4147
+ * @return {?}
4148
+ */
4149
+ NavigationTransition.prototype.onStart = /**
4150
+ * @param {?} event
4151
+ * @return {?}
4152
+ */
4153
+ function (event) {
4154
+ // active sessions can have many cancel start cycles due
4155
+ // to place guard redirects
4156
+ return this;
4157
+ };
4158
+ /**
4159
+ * @param {?} event
4160
+ * @return {?}
4161
+ */
4162
+ NavigationTransition.prototype.onEnd = /**
4163
+ * @param {?} event
4164
+ * @return {?}
4165
+ */
4166
+ function (event) {
4167
+ // navigation succeeded
4168
+ this.context.notifySuccess(this);
4169
+ return new Idle(this.context);
4170
+ };
4171
+ /**
4172
+ * @param {?} event
4173
+ * @return {?}
4174
+ */
4175
+ NavigationTransition.prototype.onCancel = /**
4176
+ * @param {?} event
4177
+ * @return {?}
4178
+ */
4179
+ function (event) {
4180
+ return new Idle(this.context);
4181
+ };
4182
+ /**
4183
+ * @param {?} event
4184
+ * @return {?}
4185
+ */
4186
+ NavigationTransition.prototype.onError = /**
4187
+ * @param {?} event
4188
+ * @return {?}
4189
+ */
4190
+ function (event) {
4191
+ // navigation was aborted.
4192
+ return new Idle(this.context);
4193
+ };
4357
4194
  /**
4358
4195
  * @return {?}
4359
4196
  */
4360
- Active.prototype.toString = /**
4197
+ NavigationTransition.prototype.toString = /**
4361
4198
  * @return {?}
4362
4199
  */
4363
4200
  function () {
4364
- return this.constructor.name + "(startingUrl: " + this.startingUrl + ", isPopState:" + this.isPopState + ")";
4201
+ return this.constructor.name + "(startingUrl: " + this.startingUrl + ")";
4365
4202
  };
4366
- __decorate([
4367
- Trace(),
4368
- __metadata("design:type", Function),
4369
- __metadata("design:paramtypes", [NavigationStart]),
4370
- __metadata("design:returntype", NavigationState)
4371
- ], Active.prototype, "onStart", null);
4372
- __decorate([
4373
- Trace(),
4374
- __metadata("design:type", Function),
4375
- __metadata("design:paramtypes", [NavigationCancel]),
4376
- __metadata("design:returntype", NavigationState)
4377
- ], Active.prototype, "onCancel", null);
4378
- __decorate([
4379
- Trace(),
4380
- __metadata("design:type", Function),
4381
- __metadata("design:paramtypes", [NavigationError]),
4382
- __metadata("design:returntype", NavigationState)
4383
- ], Active.prototype, "onError", null);
4384
- return Active;
4385
- }(NavigationState));
4386
- NavigationState.Active = Active;
4203
+ return NavigationTransition;
4204
+ }(AbstractNavigationTransition));
4205
+ NavigationState.NavigationTransition = NavigationTransition;
4387
4206
  if (false) {
4388
4207
  /** @type {?} */
4389
- Active.prototype.active;
4208
+ NavigationTransition.prototype.isPopState;
4209
+ }
4210
+ var NavigationBackTransition = /** @class */ (function (_super) {
4211
+ __extends(NavigationBackTransition, _super);
4212
+ function NavigationBackTransition() {
4213
+ var _this = _super !== null && _super.apply(this, arguments) || this;
4214
+ _this.isPopState = true;
4215
+ return _this;
4216
+ }
4390
4217
  /**
4391
- * @type {?}
4392
- * @private
4218
+ * @param {?} event
4219
+ * @return {?}
4220
+ */
4221
+ NavigationBackTransition.prototype.onCancel = /**
4222
+ * @param {?} event
4223
+ * @return {?}
4393
4224
  */
4394
- Active.prototype.componentDeactivationHandlers;
4225
+ function (event) {
4226
+ // Angular doesn't preserve the url when a guard cancels the back button.
4227
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4228
+ Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4229
+ this.resetBrowserLocation(this.startingUrl);
4230
+ return new Idle(this.context);
4231
+ };
4395
4232
  /**
4396
- * @type {?}
4397
- * @private
4233
+ * @param {?} event
4234
+ * @return {?}
4398
4235
  */
4399
- Active.prototype._interactionContext;
4400
- /** @type {?} */
4401
- Active.prototype.isPopState;
4236
+ NavigationBackTransition.prototype.onError = /**
4237
+ * @param {?} event
4238
+ * @return {?}
4239
+ */
4240
+ function (event) {
4241
+ // navigation was aborted.
4242
+ if (this.currentRouterUrl() !== this.startingUrl) {
4243
+ // Angular doesn't preserve the url when a guard cancels the back button.
4244
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4245
+ Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4246
+ this.resetBrowserLocation(this.startingUrl);
4247
+ }
4248
+ return new Idle(this.context);
4249
+ };
4250
+ return NavigationBackTransition;
4251
+ }(AbstractNavigationTransition));
4252
+ NavigationState.NavigationBackTransition = NavigationBackTransition;
4253
+ if (false) {
4402
4254
  /** @type {?} */
4403
- Active.prototype.startingUrl;
4255
+ NavigationBackTransition.prototype.isPopState;
4404
4256
  }
4405
- var ModalInteractionSession = /** @class */ (function (_super) {
4406
- __extends(ModalInteractionSession, _super);
4407
- function ModalInteractionSession(context, startingUrl) {
4257
+ /**
4258
+ * @abstract
4259
+ */
4260
+ var /**
4261
+ * @abstract
4262
+ */
4263
+ AbstractInteractionTransition = /** @class */ (function (_super) {
4264
+ __extends(AbstractInteractionTransition, _super);
4265
+ function AbstractInteractionTransition(context, startingUrl) {
4408
4266
  var _this = _super.call(this, context) || this;
4409
4267
  _this.startingUrl = startingUrl;
4410
- _this.active = false;
4268
+ _this.isTransitional = true;
4269
+ return _this;
4270
+ }
4271
+ /**
4272
+ * @protected
4273
+ * @return {?}
4274
+ */
4275
+ AbstractInteractionTransition.prototype.reinstateInteractionRoute = /**
4276
+ * @protected
4277
+ * @return {?}
4278
+ */
4279
+ function () {
4280
+ var _this = this;
4281
+ console.log(this.startingUrl);
4282
+ setTimeout((/**
4283
+ * @return {?}
4284
+ */
4285
+ function () { return _this.placeRouter.syncInteractionIdsWithRouter(); }));
4286
+ };
4287
+ return AbstractInteractionTransition;
4288
+ }(NavigationState));
4289
+ NavigationState.AbstractInteractionTransition = AbstractInteractionTransition;
4290
+ if (false) {
4291
+ /** @type {?} */
4292
+ AbstractInteractionTransition.prototype.isTransitional;
4293
+ /** @type {?} */
4294
+ AbstractInteractionTransition.prototype.startingUrl;
4295
+ }
4296
+ /**
4297
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4298
+ * happily ignore interaction contexts.
4299
+ */
4300
+ var /**
4301
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4302
+ * happily ignore interaction contexts.
4303
+ */
4304
+ InteractionTransition = /** @class */ (function (_super) {
4305
+ __extends(InteractionTransition, _super);
4306
+ function InteractionTransition() {
4307
+ var _this = _super !== null && _super.apply(this, arguments) || this;
4411
4308
  _this.isPopState = false;
4412
4309
  return _this;
4413
4310
  }
4414
- /**
4415
- * @param {?} url
4416
- * @return {?}
4417
- */
4418
- ModalInteractionSession.hasInteraction = /**
4419
- * @param {?} url
4420
- * @return {?}
4421
- */
4422
- function (url) {
4423
- return url.endsWith('(aup-interaction:modal)');
4424
- };
4425
4311
  /**
4426
4312
  * @param {?} event
4427
4313
  * @return {?}
4428
4314
  */
4429
- ModalInteractionSession.prototype.onStart = /**
4315
+ InteractionTransition.prototype.onEnd = /**
4430
4316
  * @param {?} event
4431
4317
  * @return {?}
4432
4318
  */
4433
4319
  function (event) {
4434
- // VERY VERY IMPORTANT BACK BUTTON NOTE:
4435
- // When the back button is clicked we'll enter here first, and push the url
4436
- // back to the browser. Angular seems to ignore it from a routing perspective
4437
- // and then the InteractionGuard will cancel the navigation. This process seems
4438
- // to keep the brower history in a sane state.
4439
- if (this.context.modalInteractionService.isActive()) {
4440
- if (!ModalInteractionSession.hasInteraction(event.url)) {
4441
- // this capture the case where
4442
- this.updateLocation(this.startingUrl);
4443
- }
4320
+ if (this.context.interactionService.isActive()) {
4321
+ this.reinstateInteractionRoute();
4322
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4323
+ }
4324
+ else {
4325
+ return new Idle(this.context);
4444
4326
  }
4445
- return this;
4446
- };
4447
- /**
4448
- * @param {?} event
4449
- * @return {?}
4450
- */
4451
- ModalInteractionSession.prototype.onCancel = /**
4452
- * @param {?} event
4453
- * @return {?}
4454
- */
4455
- function (event) {
4456
- // this.updateLocation(this.startingUrl);
4457
- return this;
4458
4327
  };
4328
+ return InteractionTransition;
4329
+ }(AbstractInteractionTransition));
4330
+ NavigationState.InteractionTransition = InteractionTransition;
4331
+ if (false) {
4332
+ /** @type {?} */
4333
+ InteractionTransition.prototype.isPopState;
4334
+ }
4335
+ /**
4336
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4337
+ * happily ignore interaction contexts.
4338
+ */
4339
+ var /**
4340
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4341
+ * happily ignore interaction contexts.
4342
+ */
4343
+ InteractionBackTransition = /** @class */ (function (_super) {
4344
+ __extends(InteractionBackTransition, _super);
4345
+ function InteractionBackTransition() {
4346
+ var _this = _super !== null && _super.apply(this, arguments) || this;
4347
+ _this.isPopState = true;
4348
+ return _this;
4349
+ }
4459
4350
  /**
4460
4351
  * @param {?} event
4461
4352
  * @return {?}
4462
4353
  */
4463
- ModalInteractionSession.prototype.onEnd = /**
4354
+ InteractionBackTransition.prototype.onEnd = /**
4464
4355
  * @param {?} event
4465
4356
  * @return {?}
4466
4357
  */
4467
4358
  function (event) {
4468
- if (this.context.modalInteractionService.isActive()) {
4469
- return this;
4359
+ if (this.interactionService.isActive()) {
4360
+ this.reinstateInteractionRoute();
4361
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4470
4362
  }
4471
4363
  else {
4472
4364
  return new Idle(this.context);
4473
4365
  }
4474
4366
  };
4367
+ return InteractionBackTransition;
4368
+ }(AbstractInteractionTransition));
4369
+ NavigationState.InteractionBackTransition = InteractionBackTransition;
4370
+ if (false) {
4371
+ /** @type {?} */
4372
+ InteractionBackTransition.prototype.isPopState;
4373
+ }
4374
+ var IdleDuringInteraction = /** @class */ (function (_super) {
4375
+ __extends(IdleDuringInteraction, _super);
4376
+ function IdleDuringInteraction(context, startingUrl) {
4377
+ var _this = _super.call(this, context) || this;
4378
+ _this.startingUrl = startingUrl;
4379
+ _this.isTransitional = false;
4380
+ _this.isPopState = false;
4381
+ return _this;
4382
+ }
4475
4383
  /**
4476
4384
  * @param {?} event
4477
4385
  * @return {?}
4478
4386
  */
4479
- ModalInteractionSession.prototype.onError = /**
4387
+ IdleDuringInteraction.prototype.onStart = /**
4480
4388
  * @param {?} event
4481
4389
  * @return {?}
4482
4390
  */
4483
4391
  function (event) {
4484
- return this.illegalTransition(event);
4392
+ return new InteractionTransition(this.context, event.url);
4485
4393
  };
4486
4394
  /**
4487
- * @param {?} component
4488
- * @param {?} nextState
4395
+ * @param {?} event
4489
4396
  * @return {?}
4490
4397
  */
4491
- ModalInteractionSession.prototype.canDeactivatePlace = /**
4492
- * @param {?} component
4493
- * @param {?} nextState
4398
+ IdleDuringInteraction.prototype.onPopState = /**
4399
+ * @param {?} event
4494
4400
  * @return {?}
4495
4401
  */
4496
- function (component, nextState) {
4497
- return __awaiter(this, void 0, void 0, function () {
4498
- return __generator(this, function (_a) {
4499
- return [2 /*return*/, true];
4500
- });
4501
- });
4402
+ function (event) {
4403
+ return new InteractionBackTransition(this.context, event.url);
4502
4404
  };
4503
- __decorate([
4504
- Trace(),
4505
- __metadata("design:type", Function),
4506
- __metadata("design:paramtypes", [NavigationStart]),
4507
- __metadata("design:returntype", NavigationState)
4508
- ], ModalInteractionSession.prototype, "onStart", null);
4509
- __decorate([
4510
- Trace(),
4511
- __metadata("design:type", Function),
4512
- __metadata("design:paramtypes", [NavigationCancel]),
4513
- __metadata("design:returntype", NavigationState)
4514
- ], ModalInteractionSession.prototype, "onCancel", null);
4515
- __decorate([
4516
- Trace(),
4517
- __metadata("design:type", Function),
4518
- __metadata("design:paramtypes", [NavigationEnd]),
4519
- __metadata("design:returntype", NavigationState)
4520
- ], ModalInteractionSession.prototype, "onEnd", null);
4521
- return ModalInteractionSession;
4405
+ return IdleDuringInteraction;
4522
4406
  }(NavigationState));
4523
- NavigationState.ModalInteractionSession = ModalInteractionSession;
4407
+ NavigationState.IdleDuringInteraction = IdleDuringInteraction;
4524
4408
  if (false) {
4525
4409
  /** @type {?} */
4526
- ModalInteractionSession.prototype.active;
4410
+ IdleDuringInteraction.prototype.isTransitional;
4527
4411
  /** @type {?} */
4528
- ModalInteractionSession.prototype.isPopState;
4412
+ IdleDuringInteraction.prototype.isPopState;
4529
4413
  /** @type {?} */
4530
- ModalInteractionSession.prototype.startingUrl;
4414
+ IdleDuringInteraction.prototype.startingUrl;
4531
4415
  }
4532
4416
  var CancelledDuringNavigationInteraction = /** @class */ (function (_super) {
4533
4417
  __extends(CancelledDuringNavigationInteraction, _super);
@@ -4535,28 +4419,36 @@ if (false) {
4535
4419
  var _this = _super.call(this, context) || this;
4536
4420
  _this.startingUrl = startingUrl;
4537
4421
  _this.locationChangeTriggerUrl = locationChangeTriggerUrl;
4538
- _this.active = false;
4422
+ _this.isPopState = false;
4539
4423
  _this.capturedFauxRouterStart = false;
4540
4424
  return _this;
4541
- // This will trigger a return to the route we originally started with.
4542
- // this.angularLocation.go(this.startingUrl);
4543
4425
  }
4426
+ Object.defineProperty(CancelledDuringNavigationInteraction.prototype, "isTransitional", {
4427
+ get: /**
4428
+ * @return {?}
4429
+ */
4430
+ function () {
4431
+ return !this.capturedFauxRouterStart;
4432
+ },
4433
+ enumerable: true,
4434
+ configurable: true
4435
+ });
4544
4436
  /**
4545
- * @param {?} component
4546
- * @param {?} nextState
4437
+ * @param {?} event
4547
4438
  * @return {?}
4548
4439
  */
4549
- CancelledDuringNavigationInteraction.prototype.canDeactivatePlace = /**
4550
- * @param {?} component
4551
- * @param {?} nextState
4440
+ CancelledDuringNavigationInteraction.prototype.onStart = /**
4441
+ * @param {?} event
4552
4442
  * @return {?}
4553
4443
  */
4554
- function (component, nextState) {
4555
- return __awaiter(this, void 0, void 0, function () {
4556
- return __generator(this, function (_a) {
4557
- return [2 /*return*/, false];
4558
- });
4559
- });
4444
+ function (event) {
4445
+ if (event.url === this.locationChangeTriggerUrl && !this.capturedFauxRouterStart) {
4446
+ this.capturedFauxRouterStart = true;
4447
+ return this.ignore(event, 'url matched back button location change');
4448
+ }
4449
+ else {
4450
+ return this.createTransitionStateFor(event);
4451
+ }
4560
4452
  };
4561
4453
  /**
4562
4454
  * @param {?} event
@@ -4595,18 +4487,12 @@ if (false) {
4595
4487
  * @param {?} event
4596
4488
  * @return {?}
4597
4489
  */
4598
- CancelledDuringNavigationInteraction.prototype.onStart = /**
4490
+ CancelledDuringNavigationInteraction.prototype.onPopState = /**
4599
4491
  * @param {?} event
4600
4492
  * @return {?}
4601
4493
  */
4602
4494
  function (event) {
4603
- if (event.url === this.locationChangeTriggerUrl && !this.capturedFauxRouterStart) {
4604
- this.capturedFauxRouterStart = true;
4605
- return this.ignore(event, 'url matched back button location change');
4606
- }
4607
- else {
4608
- return this.createActiveSession(event);
4609
- }
4495
+ return this.createTransitionStateFor(event);
4610
4496
  };
4611
4497
  /**
4612
4498
  * @param {?} event
@@ -4636,8 +4522,6 @@ if (false) {
4636
4522
  }(NavigationState));
4637
4523
  NavigationState.CancelledDuringNavigationInteraction = CancelledDuringNavigationInteraction;
4638
4524
  if (false) {
4639
- /** @type {?} */
4640
- CancelledDuringNavigationInteraction.prototype.active;
4641
4525
  /** @type {?} */
4642
4526
  CancelledDuringNavigationInteraction.prototype.isPopState;
4643
4527
  /**
@@ -4737,33 +4621,28 @@ if (false) {
4737
4621
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4738
4622
  */
4739
4623
  var UrlSnapshot = /** @class */ (function () {
4740
- function UrlSnapshot(urlTree) {
4741
- this.urlTree = urlTree;
4742
- // console.log({ segments: this.urlTree.root.children.primary.segments });
4624
+ // TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.
4625
+ function UrlSnapshot(urlSerializer, url) {
4626
+ this.urlSerializer = urlSerializer;
4627
+ this.url = url;
4628
+ this.urlTree = urlSerializer.parse(url);
4743
4629
  }
4744
4630
  /**
4745
- * @return {?}
4746
- */
4747
- UrlSnapshot.prototype.cloneUrlSegmentList = /**
4748
- * @return {?}
4749
- */
4750
- function () {
4751
- return __spread(this.urlTree.root.children.primary.segments);
4752
- };
4753
- /**
4631
+ * @protected
4754
4632
  * @param {?} visit
4755
4633
  * @return {?}
4756
4634
  */
4757
- UrlSnapshot.prototype.updateVisitSegments = /**
4635
+ UrlSnapshot.prototype.replaceExistingVisitSegmentsWith = /**
4636
+ * @protected
4758
4637
  * @param {?} visit
4759
4638
  * @return {?}
4760
4639
  */
4761
4640
  function (visit) {
4762
4641
  // Ugly, but it works for now.
4763
4642
  /** @type {?} */
4764
- var segments = this.cloneUrlSegmentList();
4643
+ var segments = __spread(this.getPrimarySegments());
4765
4644
  /** @type {?} */
4766
- var visitSegments = this.convertToUrlSegments(visit);
4645
+ var visitSegments = this.getSegmentsFor(visit);
4767
4646
  /** @type {?} */
4768
4647
  var replaceAt = segments.findIndex((/**
4769
4648
  * @param {?} segment
@@ -4774,17 +4653,30 @@ var UrlSnapshot = /** @class */ (function () {
4774
4653
  segments.splice.apply(segments, __spread([replaceAt, visitSegments.length], visitSegments));
4775
4654
  return segments;
4776
4655
  };
4656
+ /**
4657
+ * @private
4658
+ * @return {?}
4659
+ */
4660
+ UrlSnapshot.prototype.getPrimarySegments = /**
4661
+ * @private
4662
+ * @return {?}
4663
+ */
4664
+ function () {
4665
+ return this.urlTree.root.children.primary.segments;
4666
+ };
4777
4667
  /**
4778
4668
  * Converts the visit into segments. Please not that these segments are not e
4779
4669
  * @param visit
4780
4670
  */
4781
4671
  /**
4782
4672
  * Converts the visit into segments. Please not that these segments are not e
4673
+ * @protected
4783
4674
  * @param {?} visit
4784
4675
  * @return {?}
4785
4676
  */
4786
- UrlSnapshot.prototype.convertToUrlSegments = /**
4677
+ UrlSnapshot.prototype.getSegmentsFor = /**
4787
4678
  * Converts the visit into segments. Please not that these segments are not e
4679
+ * @protected
4788
4680
  * @param {?} visit
4789
4681
  * @return {?}
4790
4682
  */
@@ -4812,7 +4704,7 @@ var UrlSnapshot = /** @class */ (function () {
4812
4704
  */
4813
4705
  function (visit) {
4814
4706
  /** @type {?} */
4815
- var segments = this.updateVisitSegments(visit);
4707
+ var segments = this.replaceExistingVisitSegmentsWith(visit);
4816
4708
  /** @type {?} */
4817
4709
  var commands = [];
4818
4710
  segments.forEach((/**
@@ -4836,18 +4728,93 @@ var UrlSnapshot = /** @class */ (function () {
4836
4728
  * @return {?}
4837
4729
  */
4838
4730
  function (placeDef) {
4839
- return this.cloneUrlSegmentList().find((/**
4731
+ return this.getPrimarySegments().find((/**
4840
4732
  * @param {?} s
4841
4733
  * @return {?}
4842
4734
  */
4843
4735
  function (s) { return s.path === placeDef.path; }));
4844
4736
  };
4737
+ /**
4738
+ * @return {?}
4739
+ */
4740
+ UrlSnapshot.prototype.getInteractionIds = /**
4741
+ * @return {?}
4742
+ */
4743
+ function () {
4744
+ /** @type {?} */
4745
+ var interactionOutlet = this.urlTree.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET];
4746
+ if (interactionOutlet) {
4747
+ assert.isTruthy(interactionOutlet.segments.length === 2);
4748
+ assert.isTruthy(interactionOutlet.segments[0].path === UrlSnapshot.INTERACTION_ROUTER_PATH);
4749
+ return UrlSnapshot.parseInteractionIds(interactionOutlet.segments[1].path);
4750
+ }
4751
+ else {
4752
+ return [];
4753
+ }
4754
+ };
4755
+ // @Trace()
4756
+ // @Trace()
4757
+ /**
4758
+ * @param {?} ids
4759
+ * @return {?}
4760
+ */
4761
+ UrlSnapshot.prototype.addOrReplaceInteractionIds =
4762
+ // @Trace()
4763
+ /**
4764
+ * @param {?} ids
4765
+ * @return {?}
4766
+ */
4767
+ function (ids) {
4768
+ /** @type {?} */
4769
+ var urlTree = this.urlSerializer.parse(this.url);
4770
+ urlTree.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET] = new UrlSegmentGroup([
4771
+ new UrlSegment(UrlSnapshot.INTERACTION_ROUTER_PATH, {}),
4772
+ new UrlSegment(UrlSnapshot.createPathIdFor(ids), {})
4773
+ ], {});
4774
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString());
4775
+ };
4845
4776
  return UrlSnapshot;
4846
4777
  }());
4847
4778
  if (false) {
4848
- /** @type {?} */
4779
+ /**
4780
+ * @type {?}
4781
+ * @private
4782
+ */
4849
4783
  UrlSnapshot.prototype.urlTree;
4784
+ /** @type {?} */
4785
+ UrlSnapshot.prototype.urlSerializer;
4786
+ /** @type {?} */
4787
+ UrlSnapshot.prototype.url;
4850
4788
  }
4789
+ (function (UrlSnapshot) {
4790
+ UrlSnapshot.INTERACTION_ROUTER_OUTLET = 'aup-interactions';
4791
+ UrlSnapshot.INTERACTION_ROUTER_PATH = 'active';
4792
+ UrlSnapshot.INTERACTION_ID_SEPARATOR = '--';
4793
+ /**
4794
+ * @param {?} path
4795
+ * @return {?}
4796
+ */
4797
+ function parseInteractionIds(path) {
4798
+ return path.split(UrlSnapshot.INTERACTION_ID_SEPARATOR);
4799
+ }
4800
+ UrlSnapshot.parseInteractionIds = parseInteractionIds;
4801
+ /**
4802
+ * @param {?} interactionIds
4803
+ * @return {?}
4804
+ */
4805
+ function createPathIdFor(interactionIds) {
4806
+ return interactionIds.join(UrlSnapshot.INTERACTION_ID_SEPARATOR);
4807
+ }
4808
+ UrlSnapshot.createPathIdFor = createPathIdFor;
4809
+ /**
4810
+ * @param {?} interactionIds
4811
+ * @return {?}
4812
+ */
4813
+ function createInteractionOutletRouterCommands(interactionIds) {
4814
+ return [UrlSnapshot.INTERACTION_ROUTER_PATH, createPathIdFor(interactionIds)];
4815
+ }
4816
+ UrlSnapshot.createInteractionOutletRouterCommands = createInteractionOutletRouterCommands;
4817
+ })(UrlSnapshot || (UrlSnapshot = {}));
4851
4818
 
4852
4819
  /**
4853
4820
  * @fileoverview added by tsickle
@@ -4855,27 +4822,31 @@ if (false) {
4855
4822
  */
4856
4823
  var PlaceRouter = /** @class */ (function (_super) {
4857
4824
  __extends(PlaceRouter, _super);
4858
- function PlaceRouter(router, urlSerializer, angularLocation, placeHistory, modalInteractionService) {
4825
+ function PlaceRouter(router, urlSerializer, angularLocation, placeHistory, interactionService) {
4859
4826
  var _this = _super.call(this) || this;
4860
4827
  _this.router = router;
4861
4828
  _this.urlSerializer = urlSerializer;
4862
4829
  _this.angularLocation = angularLocation;
4863
4830
  _this.placeHistory = placeHistory;
4864
- _this.modalInteractionService = modalInteractionService;
4865
- _this.firstRoute = true;
4866
- _this._navigationSessionModel = new MutableValueModel();
4831
+ _this.interactionService = interactionService;
4832
+ _this._navigationStateModel = new MutableValueModel();
4867
4833
  _this._activeVisits = new MutableListModel();
4868
4834
  var _a = Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
4869
4835
  _this.activeVisitIndex = chain(_this._activeVisits).indexBy('placeDefinition');
4870
- _this.navigationSessionActive = chain(_this.navigationSessionModel).pluck('active');
4871
- _this._navigationSessionContext = new NavigationState.Context(_this.router, _this.modalInteractionService, _this.angularLocation, (/**
4836
+ _this.navigationInProgress = chain(_this.navigationStateModel).pluck('isTransitional');
4837
+ _this._navigationSessionContext = new NavigationState.Context(_this, _this.interactionService, (/**
4872
4838
  * @param {?} session
4873
4839
  * @return {?}
4874
4840
  */
4875
4841
  function (session) {
4876
4842
  _this.processNavigationSuccess(session);
4877
4843
  }));
4878
- _this._navigationSessionModel.value = new NavigationState.Idle(_this._navigationSessionContext);
4844
+ _this._navigationStateModel.value = new NavigationState.Idle(_this._navigationSessionContext);
4845
+ _this._navigationStateTypeModel = chain(_this._navigationStateModel).map((/**
4846
+ * @param {?} state
4847
+ * @return {?}
4848
+ */
4849
+ function (state) { return (/** @type {?} */ (state.constructor)); }));
4879
4850
  // TODO: make setup the callbacks in during module initiation to make this testable.
4880
4851
  _this.router.events.subscribe((/**
4881
4852
  * @param {?} event
@@ -4889,53 +4860,85 @@ var PlaceRouter = /** @class */ (function (_super) {
4889
4860
  // NavigationStart -> .... -> NavigationError --> navigation aborted, end session.
4890
4861
  // =======================
4891
4862
  if (event instanceof NavigationStart) {
4892
- _this.runStateTransition((/**
4893
- * @param {?} session
4894
- * @return {?}
4895
- */
4896
- function (session) { return session.onStart(event); }));
4863
+ console.log(event);
4864
+ if (event.navigationTrigger === 'popstate') {
4865
+ _this.runStateTransition((/**
4866
+ * @param {?} state
4867
+ * @return {?}
4868
+ */
4869
+ function (state) { return state.onPopState(event); }));
4870
+ }
4871
+ else {
4872
+ _this.runStateTransition((/**
4873
+ * @param {?} state
4874
+ * @return {?}
4875
+ */
4876
+ function (state) { return state.onStart(event); }));
4877
+ }
4897
4878
  }
4898
4879
  if (event instanceof NavigationEnd) {
4880
+ console.log(event);
4899
4881
  _this.runStateTransition((/**
4900
- * @param {?} session
4882
+ * @param {?} state
4901
4883
  * @return {?}
4902
4884
  */
4903
- function (session) { return session.onEnd(event); }));
4885
+ function (state) { return state.onEnd(event); }));
4904
4886
  }
4905
4887
  if (event instanceof NavigationError) {
4888
+ console.log(event);
4906
4889
  _this.runStateTransition((/**
4907
- * @param {?} session
4890
+ * @param {?} state
4908
4891
  * @return {?}
4909
4892
  */
4910
- function (session) { return session.onError(event); }));
4893
+ function (state) { return state.onError(event); }));
4911
4894
  }
4912
4895
  if (event instanceof NavigationCancel) {
4896
+ console.log(event);
4913
4897
  _this.runStateTransition((/**
4914
- * @param {?} session
4898
+ * @param {?} state
4915
4899
  * @return {?}
4916
4900
  */
4917
- function (session) { return session.onCancel(event); }));
4901
+ function (state) { return state.onCancel(event); }));
4918
4902
  }
4919
4903
  }));
4920
4904
  // Push dialog state to the url so we can capture the back button.
4921
- _this.modalInteractionService.addActivityListener(new PlaceRouter.InteractionRouteMediator(_this.navigationSessionActive, _this.router));
4905
+ when.listOf(_this.interactionService.activeInteractionContextIds).changes((/**
4906
+ * @param {?} ids
4907
+ * @param {?} previous
4908
+ * @return {?}
4909
+ */
4910
+ function (ids, previous) {
4911
+ _this.syncInteractionIdsWithRouter();
4912
+ }), { unless: _this.navigationInProgress }); // TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
4913
+ // TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
4914
+ /** @type {?} */
4915
+ var urlChanges = new MutableStream();
4922
4916
  // The angular router doesn't always fire router events when the back button is pushed while a navigation
4923
4917
  // session is in progress. Sometimes we only know about it from the url change.
4918
+ // IMPORTANT ORDER DEPENDENCY
4919
+ // This only works because we're notified of the change after the router has started reacting to it. This
4920
+ // we can can use our navigationState to determine things.
4924
4921
  angularLocation.onUrlChange((/**
4925
4922
  * @param {?} url
4926
4923
  * @return {?}
4927
4924
  */
4928
4925
  function (url) {
4929
- console.log("#### url changed ->", { url: url, navIsActive: _this.navigationSessionActive.value });
4930
4926
  /** @type {?} */
4931
- var interactionContext = _this.navigationSessionActive.value && _this.navigationSession.interactionContext;
4932
- if (interactionContext && interactionContext.isActive()) {
4933
- Logger.get(_this).info("back button pressed during navigation session interaction");
4934
- _this.runStateTransition((/**
4935
- * @param {?} navigationSession
4936
- * @return {?}
4937
- */
4938
- function (navigationSession) { return navigationSession.onBackClickedDuringNavigationInteraction(url); }));
4927
+ var navigationState = _this._navigationStateModel.value;
4928
+ console.log("URLChange -> " + url, { state: navigationState });
4929
+ urlChanges.publish({ url: url, state: navigationState });
4930
+ // We've entered a navigation transition
4931
+ if (navigationState instanceof NavigationState.NavigationTransition) {
4932
+ /** @type {?} */
4933
+ var navigationInteraction = _this.navigationState.interactionContext;
4934
+ if (navigationInteraction && navigationInteraction.isActive()) {
4935
+ Logger.get(_this).info("back button pressed during navigation session interaction promise");
4936
+ _this.runStateTransition((/**
4937
+ * @param {?} state
4938
+ * @return {?}
4939
+ */
4940
+ function (state) { return state.onBackClickedDuringNavigationInteraction(url); }));
4941
+ }
4939
4942
  }
4940
4943
  }));
4941
4944
  return _this;
@@ -4954,7 +4957,7 @@ var PlaceRouter = /** @class */ (function (_super) {
4954
4957
  var _this = this;
4955
4958
  // We need to update the visits before the session finishes. This allows the placeOutets to ignore visit
4956
4959
  // changes that occur while routerNavigationActive is true.
4957
- assert.isTruthy(this.navigationSessionActive.value);
4960
+ assert.isTruthy(this.navigationInProgress.value);
4958
4961
  /** @type {?} */
4959
4962
  var visits = session.getVisits();
4960
4963
  visits.forEach((/**
@@ -4964,22 +4967,22 @@ var PlaceRouter = /** @class */ (function (_super) {
4964
4967
  function (v) { return _this.placeHistory.add(v); }));
4965
4968
  this._activeVisits.value = visits;
4966
4969
  };
4967
- Object.defineProperty(PlaceRouter.prototype, "navigationSession", {
4970
+ Object.defineProperty(PlaceRouter.prototype, "navigationState", {
4968
4971
  get: /**
4969
4972
  * @return {?}
4970
4973
  */
4971
4974
  function () {
4972
- return this._navigationSessionModel.value;
4975
+ return this._navigationStateModel.value;
4973
4976
  },
4974
4977
  enumerable: true,
4975
4978
  configurable: true
4976
4979
  });
4977
- Object.defineProperty(PlaceRouter.prototype, "navigationSessionModel", {
4980
+ Object.defineProperty(PlaceRouter.prototype, "navigationStateModel", {
4978
4981
  get: /**
4979
4982
  * @return {?}
4980
4983
  */
4981
4984
  function () {
4982
- return this._navigationSessionModel.readonly;
4985
+ return this._navigationStateModel.readonly;
4983
4986
  },
4984
4987
  enumerable: true,
4985
4988
  configurable: true
@@ -5070,7 +5073,7 @@ var PlaceRouter = /** @class */ (function (_super) {
5070
5073
  */
5071
5074
  function (router) {
5072
5075
  /** @type {?} */
5073
- var commands = _this.parseUrl(_this.router.routerState.snapshot).createRedirectCommandsFor(next);
5076
+ var commands = _this.parseUrl(_this.router.routerState.snapshot.url).createRedirectCommandsFor(next);
5074
5077
  console.log('### Push Changes to route Redirect', { commands: commands });
5075
5078
  return router.navigate(commands);
5076
5079
  }))];
@@ -5095,7 +5098,7 @@ var PlaceRouter = /** @class */ (function (_super) {
5095
5098
  return __generator(this, function (_a) {
5096
5099
  switch (_a.label) {
5097
5100
  case 0:
5098
- if (this.navigationSessionActive.value) {
5101
+ if (this.navigationInProgress.value) {
5099
5102
  lang.illegalState('Navigation already in progress');
5100
5103
  }
5101
5104
  this.runStateTransition((/**
@@ -5104,7 +5107,7 @@ var PlaceRouter = /** @class */ (function (_super) {
5104
5107
  */
5105
5108
  function (current) {
5106
5109
  /** @type {?} */
5107
- var session = new NavigationState.Active(_this._navigationSessionContext, false, _this.router.routerState.snapshot.url);
5110
+ var session = new NavigationState.NavigationTransition(_this._navigationSessionContext, false, _this.router.routerState.snapshot.url);
5108
5111
  session.storeVisit(visit);
5109
5112
  return session;
5110
5113
  }));
@@ -5118,7 +5121,7 @@ var PlaceRouter = /** @class */ (function (_super) {
5118
5121
  case 3:
5119
5122
  // Router has finished (since there was no router change required) so we
5120
5123
  // need to end the navigation session.
5121
- if (this.navigationSession.active && !this.router.getCurrentNavigation()) {
5124
+ if (this.navigationState.isTransitional && !this.router.getCurrentNavigation()) {
5122
5125
  this.runStateTransition((/**
5123
5126
  * @param {?} session
5124
5127
  * @return {?}
@@ -5143,10 +5146,10 @@ var PlaceRouter = /** @class */ (function (_super) {
5143
5146
  */
5144
5147
  function (transition) {
5145
5148
  /** @type {?} */
5146
- var previous = this._navigationSessionModel.value;
5149
+ var previous = this._navigationStateModel.value;
5147
5150
  /** @type {?} */
5148
- var next = transition(this.navigationSession);
5149
- this._navigationSessionModel.value = next;
5151
+ var next = transition(this.navigationState);
5152
+ this._navigationStateModel.value = next;
5150
5153
  if (next !== previous) {
5151
5154
  previous.dispose();
5152
5155
  Logger.get(this).info("Router State Transition: " + previous.toString() + " -> " + next.toString());
@@ -5185,15 +5188,97 @@ var PlaceRouter = /** @class */ (function (_super) {
5185
5188
  function (child) { return child.url; })));
5186
5189
  };
5187
5190
  /**
5188
- * @param {?} snapshot
5191
+ * @param {?} url
5189
5192
  * @return {?}
5190
5193
  */
5191
5194
  PlaceRouter.prototype.parseUrl = /**
5192
- * @param {?} snapshot
5195
+ * @param {?} url
5196
+ * @return {?}
5197
+ */
5198
+ function (url) {
5199
+ return new UrlSnapshot(this.urlSerializer, url);
5200
+ };
5201
+ /**
5202
+ * @param {?} url
5203
+ * @return {?}
5204
+ */
5205
+ PlaceRouter.prototype.resetBrowserLocation = /**
5206
+ * @param {?} url
5207
+ * @return {?}
5208
+ */
5209
+ function (url) {
5210
+ this.angularLocation.go(url);
5211
+ };
5212
+ /**
5213
+ * @return {?}
5214
+ */
5215
+ PlaceRouter.prototype.getCurrentRouterUrl = /**
5216
+ * @return {?}
5217
+ */
5218
+ function () {
5219
+ return this.router.routerState ? this.router.routerState.snapshot.url : null;
5220
+ };
5221
+ /**
5222
+ * @param {?} url
5223
+ * @return {?}
5224
+ */
5225
+ PlaceRouter.prototype.getActiveInteractionIdsFromUrl = /**
5226
+ * @param {?} url
5227
+ * @return {?}
5228
+ */
5229
+ function (url) {
5230
+ return this.parseUrl(url).getInteractionIds();
5231
+ };
5232
+ // @Trace()
5233
+ // @Trace()
5234
+ /**
5235
+ * @param {?} url
5236
+ * @return {?}
5237
+ */
5238
+ PlaceRouter.prototype.hasActiveInteractionIds =
5239
+ // @Trace()
5240
+ /**
5241
+ * @param {?} url
5242
+ * @return {?}
5243
+ */
5244
+ function (url) {
5245
+ return this.getActiveInteractionIdsFromUrl(url).length > 0;
5246
+ };
5247
+ /**
5193
5248
  * @return {?}
5194
5249
  */
5195
- function (snapshot) {
5196
- return new UrlSnapshot(this.urlSerializer.parse(snapshot.url));
5250
+ PlaceRouter.prototype.syncInteractionIdsWithRouter = /**
5251
+ * @return {?}
5252
+ */
5253
+ function () {
5254
+ var _a, _b;
5255
+ assert.isFalsey(this.navigationInProgress.value); // Updating interaction routes during an existing navigation breaks all the things.
5256
+ // Updating interaction routes during an existing navigation breaks all the things.
5257
+ /** @type {?} */
5258
+ var currentIds = this.interactionService.activeInteractionContextIds.value;
5259
+ if (___default.isEqual(currentIds, this.getActiveInteractionIdsFromUrl(this.getCurrentRouterUrl()))) {
5260
+ console.log('activity ids were the same, skipping');
5261
+ }
5262
+ else {
5263
+ if (currentIds.length < 1) {
5264
+ this.router.navigate(['.', {
5265
+ outlets: (_a = {},
5266
+ _a[UrlSnapshot.INTERACTION_ROUTER_OUTLET] = null,
5267
+ _a)
5268
+ }], {
5269
+ replaceUrl: true // remove the interaction from the history.
5270
+ });
5271
+ }
5272
+ else {
5273
+ /** @type {?} */
5274
+ var urlSnapshot = this.parseUrl(this.getCurrentRouterUrl());
5275
+ this.router.navigate(['.', {
5276
+ outlets: (_b = {},
5277
+ _b[UrlSnapshot.INTERACTION_ROUTER_OUTLET] = UrlSnapshot.createInteractionOutletRouterCommands(currentIds),
5278
+ _b)
5279
+ }]);
5280
+ }
5281
+ }
5197
5282
  };
5198
5283
  PlaceRouter.decorators = [
5199
5284
  { type: Injectable, args: [{
@@ -5206,9 +5291,15 @@ var PlaceRouter = /** @class */ (function (_super) {
5206
5291
  { type: UrlSerializer },
5207
5292
  { type: Location },
5208
5293
  { type: PlaceHistory },
5209
- { type: ModalInteractionService }
5294
+ { type: InteractionService }
5210
5295
  ]; };
5211
- /** @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" });
5296
+ /** @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" });
5297
+ __decorate([
5298
+ Trace(),
5299
+ __metadata("design:type", Function),
5300
+ __metadata("design:paramtypes", []),
5301
+ __metadata("design:returntype", void 0)
5302
+ ], PlaceRouter.prototype, "syncInteractionIdsWithRouter", null);
5212
5303
  return PlaceRouter;
5213
5304
  }(GarbageCollector));
5214
5305
  if (false) {
@@ -5216,26 +5307,26 @@ if (false) {
5216
5307
  * @type {?}
5217
5308
  * @private
5218
5309
  */
5219
- PlaceRouter.prototype.firstRoute;
5220
- /**
5221
- * @type {?}
5222
- * @private
5223
- */
5224
- PlaceRouter.prototype._navigationSessionModel;
5310
+ PlaceRouter.prototype._navigationStateModel;
5225
5311
  /**
5226
5312
  * @type {?}
5227
5313
  * @private
5228
5314
  */
5229
5315
  PlaceRouter.prototype._activeVisits;
5230
5316
  /** @type {?} */
5231
- PlaceRouter.prototype.navigationSessionActive;
5317
+ PlaceRouter.prototype.navigationInProgress;
5232
5318
  /** @type {?} */
5233
5319
  PlaceRouter.prototype.activeVisitIndex;
5234
5320
  /**
5235
5321
  * @type {?}
5236
5322
  * @private
5237
5323
  */
5238
- PlaceRouter.prototype._navigationSessionContext;
5324
+ PlaceRouter.prototype._navigationSessionContext;
5325
+ /**
5326
+ * @type {?}
5327
+ * @private
5328
+ */
5329
+ PlaceRouter.prototype._navigationStateTypeModel;
5239
5330
  /**
5240
5331
  * @type {?}
5241
5332
  * @private
@@ -5260,83 +5351,8 @@ if (false) {
5260
5351
  * @type {?}
5261
5352
  * @private
5262
5353
  */
5263
- PlaceRouter.prototype.modalInteractionService;
5354
+ PlaceRouter.prototype.interactionService;
5264
5355
  }
5265
- (function (PlaceRouter) {
5266
- PlaceRouter.INTERACTION_ROUTER_OUTLET = 'aup-interaction';
5267
- var InteractionRouteMediator = /** @class */ (function () {
5268
- function InteractionRouteMediator(navigationSessionModelActive, router) {
5269
- this.navigationSessionModelActive = navigationSessionModelActive;
5270
- this.router = router;
5271
- }
5272
- Object.defineProperty(InteractionRouteMediator.prototype, "isNavigating", {
5273
- get: /**
5274
- * @return {?}
5275
- */
5276
- function () {
5277
- return this.navigationSessionModelActive.value;
5278
- },
5279
- enumerable: true,
5280
- configurable: true
5281
- });
5282
- // If we're not in a navigation we push
5283
- // @Trace()
5284
- // If we're not in a navigation we push
5285
- // @Trace()
5286
- /**
5287
- * @return {?}
5288
- */
5289
- InteractionRouteMediator.prototype.onActivityStarted =
5290
- // If we're not in a navigation we push
5291
- // @Trace()
5292
- /**
5293
- * @return {?}
5294
- */
5295
- function () {
5296
- var _a;
5297
- if (!this.isNavigating) {
5298
- this.router.navigate(['.', {
5299
- outlets: (_a = {},
5300
- _a[PlaceRouter.INTERACTION_ROUTER_OUTLET] = ['modal'] // "open" must be a valid route for this outlet.
5301
- ,
5302
- _a)
5303
- }], {
5304
- replaceUrl: false
5305
- });
5306
- }
5307
- };
5308
- // @Trace()
5309
- // @Trace()
5310
- /**
5311
- * @return {?}
5312
- */
5313
- InteractionRouteMediator.prototype.onActivityFinished =
5314
- // @Trace()
5315
- /**
5316
- * @return {?}
5317
- */
5318
- function () {
5319
- var _a;
5320
- if (!this.isNavigating) {
5321
- this.router.navigate(['.', {
5322
- outlets: (_a = {},
5323
- _a[PlaceRouter.INTERACTION_ROUTER_OUTLET] = null,
5324
- _a)
5325
- }], {
5326
- replaceUrl: true // remove the interaction from the history.
5327
- });
5328
- }
5329
- };
5330
- return InteractionRouteMediator;
5331
- }());
5332
- PlaceRouter.InteractionRouteMediator = InteractionRouteMediator;
5333
- if (false) {
5334
- /** @type {?} */
5335
- InteractionRouteMediator.prototype.navigationSessionModelActive;
5336
- /** @type {?} */
5337
- InteractionRouteMediator.prototype.router;
5338
- }
5339
- })(PlaceRouter || (PlaceRouter = {}));
5340
5356
 
5341
5357
  /**
5342
5358
  * @fileoverview added by tsickle
@@ -5425,9 +5441,9 @@ var PlaceOutletComponent = /** @class */ (function (_super) {
5425
5441
  _this.placeChanged = new EventEmitter();
5426
5442
  _this._activePlace = new MutableValueModel();
5427
5443
  _this._activePlaceVisitModel = new DelegatingValueModel();
5428
- _this._inOutletActivation = new Guard$1();
5429
- _this._inOutletDeactivation = new Guard$1();
5430
- _this._inRouteVisitUpdate = new Guard$1();
5444
+ _this._inOutletActivation = new Guard();
5445
+ _this._inOutletDeactivation = new Guard();
5446
+ _this._inRouteVisitUpdate = new Guard();
5431
5447
  _this._activatedRouteModel = new MutableValueModel();
5432
5448
  _this._placeDefinition = new MutableValueModel();
5433
5449
  _this.initialPlaceIndex = null;
@@ -5487,10 +5503,10 @@ var PlaceOutletComponent = /** @class */ (function (_super) {
5487
5503
  function (next, previous) {
5488
5504
  _this.pushVisitChangesToRoute(next, previous);
5489
5505
  }), {
5490
- unless: _this.placeRouter.navigationSessionActive
5506
+ unless: _this.placeRouter.navigationInProgress
5491
5507
  });
5492
5508
  chain(_this._activePlace)
5493
- .postponeWhile(placeRouter.navigationSessionActive)
5509
+ .postponeWhile(placeRouter.navigationInProgress)
5494
5510
  .subscribe((/**
5495
5511
  * @param {?} place
5496
5512
  * @return {?}
@@ -6552,6 +6568,225 @@ if (false) {
6552
6568
  ActivityOutletContext.prototype.componentReady = function (component) { };
6553
6569
  }
6554
6570
 
6571
+ /**
6572
+ * @fileoverview added by tsickle
6573
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6574
+ */
6575
+ var DialogInteractionContext = /** @class */ (function (_super) {
6576
+ __extends(DialogInteractionContext, _super);
6577
+ function DialogInteractionContext(dialogService, config) {
6578
+ var _this = _super.call(this) || this;
6579
+ _this.dialogService = dialogService;
6580
+ _this.config = config;
6581
+ _this._activeModel = new MutableValueModel(false);
6582
+ assert$1.notNil(dialogService);
6583
+ _this.onDispose((/**
6584
+ * @return {?}
6585
+ */
6586
+ function () {
6587
+ if (_this.isActive()) {
6588
+ lang.illegalState('Dispose called while active.');
6589
+ }
6590
+ }));
6591
+ return _this;
6592
+ }
6593
+ Object.defineProperty(DialogInteractionContext.prototype, "active", {
6594
+ get: /**
6595
+ * @return {?}
6596
+ */
6597
+ function () {
6598
+ return this._activeModel.readonly;
6599
+ },
6600
+ enumerable: true,
6601
+ configurable: true
6602
+ });
6603
+ /**
6604
+ * @protected
6605
+ * @template D, R, E
6606
+ * @param {?} activityType
6607
+ * @param {?} data
6608
+ * @param {?=} disableClose
6609
+ * @return {?}
6610
+ */
6611
+ DialogInteractionContext.prototype._startActivity = /**
6612
+ * @protected
6613
+ * @template D, R, E
6614
+ * @param {?} activityType
6615
+ * @param {?} data
6616
+ * @param {?=} disableClose
6617
+ * @return {?}
6618
+ */
6619
+ function (activityType, data, disableClose) {
6620
+ var _this = this;
6621
+ if (disableClose === void 0) { disableClose = true; }
6622
+ if (this.isActive()) {
6623
+ lang.illegalState("Activity already in progress: " + this.activityList.value.map((/**
6624
+ * @param {?} a
6625
+ * @return {?}
6626
+ */
6627
+ function (a) { return a.constructor.name; })).join(', '));
6628
+ }
6629
+ this._activeModel.value = true;
6630
+ /** @type {?} */
6631
+ var config = __assign({}, this.config, {
6632
+ data: data,
6633
+ disableClose: disableClose,
6634
+ panelClass: 'dialog-interaction-context'
6635
+ });
6636
+ /** @type {?} */
6637
+ var self = this;
6638
+ /** @type {?} */
6639
+ var matDialogRef = (/** @type {?} */ (this.dialogService.open(ActivityContainerComponent, config)));
6640
+ return new Promise((/**
6641
+ * @param {?} resolve
6642
+ * @param {?} reject
6643
+ * @return {?}
6644
+ */
6645
+ function (resolve, reject) {
6646
+ /** @type {?} */
6647
+ var activityContainer = matDialogRef.componentInstance;
6648
+ self.safelyUpdateActivityListDelegate(activityContainer.activityList);
6649
+ activityContainer.initialActivityOutletContext = {
6650
+ activityClass: activityType,
6651
+ activityData: data,
6652
+ onDone: /**
6653
+ * @param {?} result
6654
+ * @return {?}
6655
+ */
6656
+ function (result) {
6657
+ resolve(result);
6658
+ matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
6659
+ },
6660
+ onCancel: /**
6661
+ * @param {?} error
6662
+ * @return {?}
6663
+ */
6664
+ function (error) {
6665
+ reject(error);
6666
+ matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
6667
+ }
6668
+ };
6669
+ // we need to check if our onDone/onCancel methods above we called or if we were
6670
+ // closed by the user clicking the backdrop. If the later then we need to reject
6671
+ // our promise.
6672
+ matDialogRef.afterClosed().subscribe((/**
6673
+ * @param {?} promiseAlreadyFinished
6674
+ * @return {?}
6675
+ */
6676
+ function (promiseAlreadyFinished) {
6677
+ if (!promiseAlreadyFinished) {
6678
+ reject('auto-closed');
6679
+ }
6680
+ }));
6681
+ matDialogRef.updateSize();
6682
+ matDialogRef.afterOpened().subscribe((/**
6683
+ * @param {?} promiseAlreadyFinished
6684
+ * @return {?}
6685
+ */
6686
+ function (promiseAlreadyFinished) {
6687
+ matDialogRef.updateSize();
6688
+ }));
6689
+ })).finally((/**
6690
+ * @return {?}
6691
+ */
6692
+ function () {
6693
+ self.safelyUpdateActivityListDelegate(null);
6694
+ _this._activeModel.value = false;
6695
+ }));
6696
+ };
6697
+ /**
6698
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
6699
+ * @param delegate
6700
+ */
6701
+ /**
6702
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
6703
+ * @param {?} delegate
6704
+ * @return {?}
6705
+ */
6706
+ DialogInteractionContext.prototype.safelyUpdateActivityListDelegate = /**
6707
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
6708
+ * @param {?} delegate
6709
+ * @return {?}
6710
+ */
6711
+ function (delegate) {
6712
+ var _this = this;
6713
+ setTimeout((/**
6714
+ * @return {?}
6715
+ */
6716
+ function () { return _this.setActivityList(delegate); }));
6717
+ };
6718
+ return DialogInteractionContext;
6719
+ }(InteractionContextBase));
6720
+ if (false) {
6721
+ /**
6722
+ * @type {?}
6723
+ * @private
6724
+ */
6725
+ DialogInteractionContext.prototype._activeModel;
6726
+ /**
6727
+ * @type {?}
6728
+ * @private
6729
+ */
6730
+ DialogInteractionContext.prototype.dialogService;
6731
+ /** @type {?} */
6732
+ DialogInteractionContext.prototype.config;
6733
+ }
6734
+
6735
+ /**
6736
+ * @fileoverview added by tsickle
6737
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6738
+ */
6739
+ /** @type {?} */
6740
+ var DIALOG_INTERACTION_SERVICE_DEFAULTS = new InjectionToken('DIALOG_INTERACTION_SERVICE_DEFAULTS');
6741
+ var DialogInteractionContextFactory = /** @class */ (function (_super) {
6742
+ __extends(DialogInteractionContextFactory, _super);
6743
+ function DialogInteractionContextFactory(dialogService, dialogServiceDefaults, matDialogDefaultConfig) {
6744
+ var _this = _super.call(this) || this;
6745
+ _this.dialogService = dialogService;
6746
+ _this.dialogServiceDefaults = dialogServiceDefaults;
6747
+ _this.matDialogDefaultConfig = matDialogDefaultConfig;
6748
+ assert$1.notNil(dialogService);
6749
+ return _this;
6750
+ }
6751
+ /**
6752
+ * @return {?}
6753
+ */
6754
+ DialogInteractionContextFactory.prototype.createInteractionContext = /**
6755
+ * @return {?}
6756
+ */
6757
+ function () {
6758
+ /** @type {?} */
6759
+ var config = __assign({ autoFocus: false, hasBackdrop: true, closeOnNavigation: false }, this.matDialogDefaultConfig, this.dialogServiceDefaults);
6760
+ return new DialogInteractionContext(this.dialogService, config);
6761
+ };
6762
+ DialogInteractionContextFactory.decorators = [
6763
+ { type: Injectable, args: [{
6764
+ providedIn: 'root'
6765
+ },] }
6766
+ ];
6767
+ /** @nocollapse */
6768
+ DialogInteractionContextFactory.ctorParameters = function () { return [
6769
+ { type: MatDialog },
6770
+ { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [DIALOG_INTERACTION_SERVICE_DEFAULTS,] }] },
6771
+ { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [MAT_DIALOG_DEFAULT_OPTIONS,] }] }
6772
+ ]; };
6773
+ /** @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" });
6774
+ return DialogInteractionContextFactory;
6775
+ }(ModalInteractionContextFactory));
6776
+ if (false) {
6777
+ /** @type {?} */
6778
+ DialogInteractionContextFactory.prototype.active;
6779
+ /**
6780
+ * @type {?}
6781
+ * @private
6782
+ */
6783
+ DialogInteractionContextFactory.prototype.dialogService;
6784
+ /** @type {?} */
6785
+ DialogInteractionContextFactory.prototype.dialogServiceDefaults;
6786
+ /** @type {?} */
6787
+ DialogInteractionContextFactory.prototype.matDialogDefaultConfig;
6788
+ }
6789
+
6555
6790
  /**
6556
6791
  * @fileoverview added by tsickle
6557
6792
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -6926,16 +7161,16 @@ var AbstractPlaceGuard = /** @class */ (function () {
6926
7161
  // Parse our route params.
6927
7162
  params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
6928
7163
  parsedParams = placeDefinition.parseRouteParams(params);
6929
- initialVisit = this.placeRouter.navigationSession.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
7164
+ initialVisit = this.placeRouter.navigationState.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
6930
7165
  sanitiser = new VisitSanitiser(activatedRoute, this.router, this.placeHistory, this.injector);
6931
7166
  return [4 /*yield*/, sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams))];
6932
7167
  case 1:
6933
7168
  sanitisedVisit = _a.sent();
6934
7169
  // Save the visit with any updated parameters. We need to save it so we remember any non route parameters
6935
- this.placeRouter.navigationSession.storeVisit(sanitisedVisit);
7170
+ this.placeRouter.navigationState.storeVisit(sanitisedVisit);
6936
7171
  if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
6937
7172
  // Regenerate the url
6938
- commands = this.placeRouter.parseUrl(state).createRedirectCommandsFor(sanitisedVisit);
7173
+ commands = this.placeRouter.parseUrl(state.url).createRedirectCommandsFor(sanitisedVisit);
6939
7174
  console.log('##### Place Guard Redirect', commands);
6940
7175
  return [2 /*return*/, this.router.createUrlTree(commands, {
6941
7176
  replaceUrl: true,
@@ -6969,7 +7204,7 @@ var AbstractPlaceGuard = /** @class */ (function () {
6969
7204
  function (component, currentRoute, currentState, nextState) {
6970
7205
  return __awaiter(this, void 0, void 0, function () {
6971
7206
  return __generator(this, function (_a) {
6972
- return [2 /*return*/, this.placeRouter.navigationSession.canDeactivatePlace(component, this.placeRouter.parseUrl(nextState))];
7207
+ return [2 /*return*/, this.placeRouter.navigationState.canDeactivatePlace(component, this.placeRouter.parseUrl(nextState.url))];
6973
7208
  });
6974
7209
  });
6975
7210
  };
@@ -6979,7 +7214,7 @@ var AbstractPlaceGuard = /** @class */ (function () {
6979
7214
  * @protected
6980
7215
  * @param {?} activatedRoute
6981
7216
  * @param {?} state
6982
- * @param {?} canActivate
7217
+ * @param {?} runPlaceGuards
6983
7218
  * @return {?}
6984
7219
  */
6985
7220
  AbstractPlaceGuard.prototype.authorisePlaceThen =
@@ -6988,12 +7223,12 @@ var AbstractPlaceGuard = /** @class */ (function () {
6988
7223
  * @protected
6989
7224
  * @param {?} activatedRoute
6990
7225
  * @param {?} state
6991
- * @param {?} canActivate
7226
+ * @param {?} runPlaceGuards
6992
7227
  * @return {?}
6993
7228
  */
6994
- function (activatedRoute, state, canActivate) {
7229
+ function (activatedRoute, state, runPlaceGuards) {
6995
7230
  return __awaiter(this, void 0, void 0, function () {
6996
- var placeDefinition, authorised, _a;
7231
+ var placeDefinition, authoriseResult, _a;
6997
7232
  return __generator(this, function (_b) {
6998
7233
  switch (_b.label) {
6999
7234
  case 0:
@@ -7008,13 +7243,14 @@ var AbstractPlaceGuard = /** @class */ (function () {
7008
7243
  _a = true;
7009
7244
  _b.label = 3;
7010
7245
  case 3:
7011
- authorised = _a;
7012
- if (authorised === true) {
7013
- return [2 /*return*/, canActivate(placeDefinition)];
7246
+ authoriseResult = _a;
7247
+ if (authoriseResult === true) {
7248
+ // we're authorised, now run the place guards.
7249
+ return [2 /*return*/, runPlaceGuards(placeDefinition)];
7014
7250
  }
7015
7251
  else {
7016
- console.log('not authorised result', authorised);
7017
- return [2 /*return*/, authorised];
7252
+ console.log('not authorised result', authoriseResult);
7253
+ return [2 /*return*/, authoriseResult];
7018
7254
  }
7019
7255
  return [3 /*break*/, 5];
7020
7256
  case 4: return [2 /*return*/, lang.illegalState("expected component to be an instance of PlaceComponent, got " + activatedRoute.component)];
@@ -7089,12 +7325,12 @@ if (false) {
7089
7325
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7090
7326
  */
7091
7327
  var InteractionGuard = /** @class */ (function () {
7092
- function InteractionGuard(router, injector, placeRouter, angularLocation, modalInteractionService) {
7328
+ function InteractionGuard(router, injector, placeRouter, angularLocation, interactionService) {
7093
7329
  this.router = router;
7094
7330
  this.injector = injector;
7095
7331
  this.placeRouter = placeRouter;
7096
7332
  this.angularLocation = angularLocation;
7097
- this.modalInteractionService = modalInteractionService;
7333
+ this.interactionService = interactionService;
7098
7334
  }
7099
7335
  /**
7100
7336
  * @param {?} route
@@ -7109,10 +7345,10 @@ var InteractionGuard = /** @class */ (function () {
7109
7345
  function (route, state) {
7110
7346
  /** @type {?} */
7111
7347
  var url = this.router.parseUrl(state.url);
7112
- if (!this.modalInteractionService.isActive() && url.root.children[PlaceRouter.INTERACTION_ROUTER_OUTLET]) {
7348
+ if (!this.interactionService.isActive() && url.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET]) {
7113
7349
  // This happens if we reload the page or the url was pasted as the route should only be activated
7114
7350
  // after the interaction context has become active.
7115
- delete url.root.children[PlaceRouter.INTERACTION_ROUTER_OUTLET];
7351
+ delete url.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET];
7116
7352
  return url;
7117
7353
  }
7118
7354
  else {
@@ -7135,20 +7371,26 @@ var InteractionGuard = /** @class */ (function () {
7135
7371
  */
7136
7372
  function (component, currentRoute, currentState, nextState) {
7137
7373
  return __awaiter(this, void 0, void 0, function () {
7138
- var popstateReturnUrl, activity;
7374
+ var currentIds, routeIds, activity;
7139
7375
  return __generator(this, function (_a) {
7140
7376
  switch (_a.label) {
7141
7377
  case 0:
7142
- popstateReturnUrl = this.placeRouter.navigationSession.startingUrl;
7143
- if (!this.modalInteractionService.isActive()) return [3 /*break*/, 2];
7378
+ if (!this.interactionService.isActive()) return [3 /*break*/, 2];
7379
+ currentIds = this.interactionService.activeInteractionContextIds.value;
7380
+ routeIds = this.placeRouter.getActiveInteractionIdsFromUrl(nextState.url);
7381
+ if (!!isEqual(currentIds, routeIds)) return [3 /*break*/, 2];
7144
7382
  // The activity is still active so the route change was triggered by the back button.
7145
- return [4 /*yield*/, this.modalInteractionService.getCurrentActivity()];
7383
+ return [4 /*yield*/, this.interactionService.getCurrentActivity()];
7146
7384
  case 1:
7147
7385
  activity = _a.sent();
7148
7386
  activity.cancel();
7149
- // See ModalInteractionSession#onStart() for the url updating.
7150
- return [2 /*return*/, false];
7151
- case 2: return [2 /*return*/, true];
7387
+ _a.label = 2;
7388
+ case 2:
7389
+ // IMPORTANT:
7390
+ // We always return true, the router state engine will redirect as required. Return false
7391
+ // during the guard causes all kinds of grief. It might be worth trying a redirect here
7392
+ // again now that our state engine is more thorough.
7393
+ return [2 /*return*/, true];
7152
7394
  }
7153
7395
  });
7154
7396
  });
@@ -7164,9 +7406,9 @@ var InteractionGuard = /** @class */ (function () {
7164
7406
  { type: Injector },
7165
7407
  { type: PlaceRouter },
7166
7408
  { type: Location },
7167
- { type: ModalInteractionService }
7409
+ { type: InteractionService }
7168
7410
  ]; };
7169
- /** @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" });
7411
+ /** @nocollapse */ InteractionGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function InteractionGuard_Factory() { return new InteractionGuard(ɵɵinject(Router), ɵɵinject(INJECTOR), ɵɵinject(PlaceRouter), ɵɵinject(Location), ɵɵinject(InteractionService)); }, token: InteractionGuard, providedIn: "root" });
7170
7412
  return InteractionGuard;
7171
7413
  }());
7172
7414
  if (false) {
@@ -7194,7 +7436,7 @@ if (false) {
7194
7436
  * @type {?}
7195
7437
  * @private
7196
7438
  */
7197
- InteractionGuard.prototype.modalInteractionService;
7439
+ InteractionGuard.prototype.interactionService;
7198
7440
  }
7199
7441
 
7200
7442
  /**
@@ -7512,5 +7754,5 @@ if (false) {
7512
7754
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7513
7755
  */
7514
7756
 
7515
- 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 };
7757
+ 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, DialogInteractionContextFactory, Dimension, DirectivesModule, DisposableComponent, EmptyStateComponent, FocusBindingDirective, Formatter, InplaceInteractionContextComponent, InteractionContext, InteractionContextBase, InteractionGuard, InteractionModule, InteractionOutletComponent, InteractionService, LEFT_RIGHT_PLACE_ANIMATION, ListPlaceNavComponent, ModalInteractionContextFactory, 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, 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 };
7516
7758
  //# sourceMappingURL=coolon-angular-ui-powerups.js.map