@coolon/angular-ui-powerups 0.0.97 → 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 (79) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +1405 -1305
  2. package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
  3. package/bundles/coolon-angular-ui-powerups.umd.min.js +1 -1
  4. package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
  5. package/coolon-angular-ui-powerups.d.ts +19 -19
  6. package/coolon-angular-ui-powerups.metadata.json +1 -1
  7. package/esm2015/coolon-angular-ui-powerups.js +19 -19
  8. package/esm2015/index.js +2 -2
  9. package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +20 -6
  10. package/esm2015/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.js +18 -7
  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 +676 -0
  22. package/esm2015/lib/place/guards/place-component-deactivation-handler.js +14 -37
  23. package/esm2015/lib/place/index.js +2 -2
  24. package/esm2015/lib/place/place-router.js +163 -161
  25. package/esm2015/lib/place/url-snapshot.js +91 -19
  26. package/esm2015/public_api.js +3 -3
  27. package/esm5/coolon-angular-ui-powerups.js +19 -19
  28. package/esm5/index.js +2 -2
  29. package/esm5/lib/interaction/components/activity-container/activity-container.component.js +24 -15
  30. package/esm5/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.js +15 -7
  31. package/esm5/lib/interaction/index.js +5 -4
  32. package/esm5/lib/interaction/interaction-context.js +8 -61
  33. package/esm5/lib/interaction/interaction.module.js +3 -3
  34. package/esm5/lib/interaction/services/interaction.service.js +271 -0
  35. package/esm5/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context-factory.js +65 -0
  36. package/esm5/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context.js +170 -0
  37. package/esm5/lib/interaction/services/modal-interaction-context.factory.js +27 -0
  38. package/esm5/lib/place/components/place-outlet/place-outlet.component.js +3 -3
  39. package/esm5/lib/place/guards/abstract-place.guard.js +15 -14
  40. package/esm5/lib/place/guards/interaction.guard.js +25 -17
  41. package/esm5/lib/place/guards/navigation-state.js +894 -0
  42. package/esm5/lib/place/guards/place-component-deactivation-handler.js +21 -55
  43. package/esm5/lib/place/index.js +2 -2
  44. package/esm5/lib/place/place-router.js +186 -269
  45. package/esm5/lib/place/url-snapshot.js +105 -21
  46. package/esm5/public_api.js +3 -3
  47. package/fesm2015/coolon-angular-ui-powerups.js +1142 -990
  48. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  49. package/fesm5/coolon-angular-ui-powerups.js +1350 -1250
  50. package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
  51. package/lib/interaction/components/activity-container/activity-container.component.d.ts +2 -1
  52. package/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.d.ts +3 -1
  53. package/lib/interaction/index.d.ts +4 -3
  54. package/lib/interaction/interaction-context.d.ts +2 -11
  55. package/lib/interaction/services/interaction.service.d.ts +46 -0
  56. package/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context-factory.d.ts +15 -0
  57. package/lib/interaction/services/{dialog-interaction-context.d.ts → mat-dialog-interaction/dialog-interaction-context.d.ts} +2 -2
  58. package/lib/interaction/services/modal-interaction-context.factory.d.ts +4 -0
  59. package/lib/place/guards/abstract-place.guard.d.ts +1 -1
  60. package/lib/place/guards/interaction.guard.d.ts +3 -3
  61. package/lib/place/guards/navigation-state.d.ts +124 -0
  62. package/lib/place/guards/place-component-deactivation-handler.d.ts +3 -5
  63. package/lib/place/index.d.ts +1 -1
  64. package/lib/place/place-router.d.ts +17 -24
  65. package/lib/place/url-snapshot.d.ts +18 -6
  66. package/package.json +1 -1
  67. package/schematics/place-routes/templates/place-routes.ts.template +3 -3
  68. package/styles/styles.scss +1 -1
  69. package/esm2015/lib/interaction/services/dialog-interaction-context.js +0 -163
  70. package/esm2015/lib/interaction/services/dialog-interaction.service.js +0 -151
  71. package/esm2015/lib/interaction/services/modal-interaction.service.js +0 -109
  72. package/esm2015/lib/place/guards/navigation-session.js +0 -590
  73. package/esm5/lib/interaction/services/dialog-interaction-context.js +0 -188
  74. package/esm5/lib/interaction/services/dialog-interaction.service.js +0 -179
  75. package/esm5/lib/interaction/services/modal-interaction.service.js +0 -153
  76. package/esm5/lib/place/guards/navigation-session.js +0 -741
  77. package/lib/interaction/services/dialog-interaction.service.d.ts +0 -24
  78. package/lib/interaction/services/modal-interaction.service.d.ts +0 -15
  79. package/lib/place/guards/navigation-session.d.ts +0 -96
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/forms'), require('@angular/material'), require('@angular/material/tabs'), require('@angular/platform-browser/animations'), require('@coolon/pectin'), require('@angular/cdk/portal'), require('@angular/router'), require('lodash'), require('@coolon/typescript-utilities'), require('@angular/material/dialog'), require('@angular/material/icon'), require('@angular/material/list'), require('@angular/material/tooltip'), require('@typescript-plus/fast-memoize-decorator/dist/src'), require('@typescript-plus/fast-memoize-decorator'), require('reflect-metadata'), require('@angular/animations'), require('resize-observer-polyfill'), require('rxjs')) :
3
- typeof define === 'function' && define.amd ? define('@coolon/angular-ui-powerups', ['exports', '@angular/common', '@angular/core', '@angular/forms', '@angular/material', '@angular/material/tabs', '@angular/platform-browser/animations', '@coolon/pectin', '@angular/cdk/portal', '@angular/router', 'lodash', '@coolon/typescript-utilities', '@angular/material/dialog', '@angular/material/icon', '@angular/material/list', '@angular/material/tooltip', '@typescript-plus/fast-memoize-decorator/dist/src', '@typescript-plus/fast-memoize-decorator', 'reflect-metadata', '@angular/animations', 'resize-observer-polyfill', 'rxjs'], factory) :
4
- (global = global || self, factory((global.coolon = global.coolon || {}, global.coolon['angular-ui-powerups'] = {}), global.ng.common, global.ng.core, global.ng.forms, global.ng.material, global.ng.material.tabs, global.ng.platformBrowser.animations, global.pectin, global.ng.cdk.portal, global.ng.router, global.___default, global.typescriptUtilities, global.ng.material.dialog, global.ng.material.icon, global.ng.material.list, global.ng.material.tooltip, global.src, global.fastMemoizeDecorator, null, global.ng.animations, global.ResizeObserver, global.rxjs));
5
- }(this, function (exports, common, core, forms, material, tabs, animations, pectin, portal, router, ___default, typescriptUtilities, dialog, icon, list, tooltip, src, fastMemoizeDecorator, reflectMetadata, animations$1, ResizeObserver, rxjs) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/forms'), require('@angular/material'), require('@angular/material/tabs'), require('@angular/platform-browser/animations'), require('@coolon/pectin'), require('@angular/cdk/portal'), require('@angular/router'), require('lodash'), require('@coolon/typescript-utilities'), require('@angular/material/icon'), require('@angular/material/list'), require('@angular/material/tooltip'), require('@typescript-plus/fast-memoize-decorator/dist/src'), require('@typescript-plus/fast-memoize-decorator'), require('reflect-metadata'), require('@angular/animations'), require('resize-observer-polyfill'), require('@angular/material/dialog'), require('rxjs')) :
3
+ typeof define === 'function' && define.amd ? define('@coolon/angular-ui-powerups', ['exports', '@angular/common', '@angular/core', '@angular/forms', '@angular/material', '@angular/material/tabs', '@angular/platform-browser/animations', '@coolon/pectin', '@angular/cdk/portal', '@angular/router', 'lodash', '@coolon/typescript-utilities', '@angular/material/icon', '@angular/material/list', '@angular/material/tooltip', '@typescript-plus/fast-memoize-decorator/dist/src', '@typescript-plus/fast-memoize-decorator', 'reflect-metadata', '@angular/animations', 'resize-observer-polyfill', '@angular/material/dialog', 'rxjs'], factory) :
4
+ (global = global || self, factory((global.coolon = global.coolon || {}, global.coolon['angular-ui-powerups'] = {}), global.ng.common, global.ng.core, global.ng.forms, global.ng.material, global.ng.material.tabs, global.ng.platformBrowser.animations, global.pectin, global.ng.cdk.portal, global.ng.router, global.___default, global.typescriptUtilities, global.ng.material.icon, global.ng.material.list, global.ng.material.tooltip, global.src, global.fastMemoizeDecorator, null, global.ng.animations, global.ResizeObserver, global.ng.material.dialog, global.rxjs));
5
+ }(this, function (exports, common, core, forms, material, tabs, animations, pectin, portal, router, ___default, typescriptUtilities, icon, list, tooltip, src, fastMemoizeDecorator, reflectMetadata, animations$1, ResizeObserver, dialog, rxjs) { 'use strict';
6
6
 
7
7
  var ___default__default = 'default' in ___default ? ___default['default'] : ___default;
8
8
  ResizeObserver = ResizeObserver && ResizeObserver.hasOwnProperty('default') ? ResizeObserver['default'] : ResizeObserver;
@@ -1105,7 +1105,7 @@
1105
1105
  * @abstract
1106
1106
  * @template D, R, E
1107
1107
  */
1108
- exports.ɵbh = /** @class */ (function (_super) {
1108
+ exports.ɵbi = /** @class */ (function (_super) {
1109
1109
  __extends(Activity, _super);
1110
1110
  function Activity() {
1111
1111
  var _this = _super !== null && _super.apply(this, arguments) || this;
@@ -1195,12 +1195,12 @@
1195
1195
  * @type {?}
1196
1196
  * @private
1197
1197
  */
1198
- exports.ɵbh.prototype._busyModel;
1198
+ exports.ɵbi.prototype._busyModel;
1199
1199
  /**
1200
1200
  * @type {?}
1201
1201
  * @private
1202
1202
  */
1203
- exports.ɵbh.prototype._activityContext;
1203
+ exports.ɵbi.prototype._activityContext;
1204
1204
  }
1205
1205
  (function (Activity) {
1206
1206
  /**
@@ -1215,7 +1215,7 @@
1215
1215
  /** @type {?} */
1216
1216
  Callbacks.prototype.onCancel;
1217
1217
  }
1218
- })(exports.ɵbh || (exports.ɵbh = {}));
1218
+ })(exports.ɵbi || (exports.ɵbi = {}));
1219
1219
 
1220
1220
  /**
1221
1221
  * @fileoverview added by tsickle
@@ -1237,7 +1237,7 @@
1237
1237
  return _super !== null && _super.apply(this, arguments) || this;
1238
1238
  }
1239
1239
  return AbstractActivity;
1240
- }(exports.ɵbh));
1240
+ }(exports.ɵbi));
1241
1241
 
1242
1242
  /**
1243
1243
  * @fileoverview added by tsickle
@@ -1283,15 +1283,13 @@
1283
1283
  /**
1284
1284
  * @abstract
1285
1285
  */
1286
- /**
1286
+ var /**
1287
1287
  * @abstract
1288
1288
  */
1289
- exports.ɵbc = /** @class */ (function (_super) {
1289
+ InteractionContext = /** @class */ (function (_super) {
1290
1290
  __extends(InteractionContext, _super);
1291
1291
  function InteractionContext() {
1292
- var _this = _super !== null && _super.apply(this, arguments) || this;
1293
- _this.activityListeners = new pectin.EventListenerList();
1294
- return _this;
1292
+ return _super !== null && _super.apply(this, arguments) || this;
1295
1293
  }
1296
1294
  /**
1297
1295
  * Returns true if an activity is currently running.
@@ -1308,65 +1306,31 @@
1308
1306
  return this.active.value;
1309
1307
  };
1310
1308
  /**
1311
- * @param {?} listener
1312
- * @return {?}
1313
- */
1314
- InteractionContext.prototype.addActivityListener = /**
1315
- * @param {?} listener
1316
- * @return {?}
1317
- */
1318
- function (listener) {
1319
- return this.activityListeners.add(listener);
1320
- };
1321
- /**
1322
- * @protected
1323
- * @return {?}
1324
- */
1325
- InteractionContext.prototype.notifyActivityStarted = /**
1326
- * @protected
1327
- * @return {?}
1328
- */
1329
- function () {
1330
- this.activityListeners.fire((/**
1331
- * @param {?} l
1332
- * @return {?}
1333
- */
1334
- function (l) { return l.onActivityStarted(); }));
1335
- };
1336
- /**
1337
- * @protected
1338
1309
  * @return {?}
1339
1310
  */
1340
- InteractionContext.prototype.notifyActivityFinished = /**
1341
- * @protected
1311
+ InteractionContext.prototype.dispose = /**
1342
1312
  * @return {?}
1343
1313
  */
1344
1314
  function () {
1345
- this.activityListeners.fire((/**
1346
- * @param {?} l
1347
- * @return {?}
1348
- */
1349
- function (l) { return l.onActivityFinished(); }));
1315
+ // TODO: think about auto cancelling any outstanding activity on dispose.
1316
+ // See NavigationState.Navigating for a use-case.
1317
+ pectin.assert.isFalsey(this.isActive());
1318
+ _super.prototype.dispose.call(this);
1350
1319
  };
1351
1320
  return InteractionContext;
1352
1321
  }(pectin.GarbageCollector));
1353
1322
  if (false) {
1354
- /**
1355
- * @type {?}
1356
- * @private
1357
- */
1358
- exports.ɵbc.prototype.activityListeners;
1359
1323
  /** @type {?} */
1360
- exports.ɵbc.prototype.activityList;
1324
+ InteractionContext.prototype.activityList;
1361
1325
  /** @type {?} */
1362
- exports.ɵbc.prototype.active;
1326
+ InteractionContext.prototype.active;
1363
1327
  /**
1364
1328
  * Returns the activity that is currently active.
1365
1329
  * This model is only updated in the next tick after the view has been updated.
1366
1330
  * @abstract
1367
1331
  * @return {?}
1368
1332
  */
1369
- exports.ɵbc.prototype.getCurrentActivity = function () { };
1333
+ InteractionContext.prototype.getCurrentActivity = function () { };
1370
1334
  /**
1371
1335
  * @abstract
1372
1336
  * @template D, R, E
@@ -1374,25 +1338,25 @@
1374
1338
  * @param {?=} data
1375
1339
  * @return {?}
1376
1340
  */
1377
- exports.ɵbc.prototype.startActivity = function (activityType, data) { };
1341
+ InteractionContext.prototype.startActivity = function (activityType, data) { };
1378
1342
  /**
1379
1343
  * @abstract
1380
1344
  * @param {?} alert
1381
1345
  * @return {?}
1382
1346
  */
1383
- exports.ɵbc.prototype.alert = function (alert) { };
1347
+ InteractionContext.prototype.alert = function (alert) { };
1384
1348
  /**
1385
1349
  * @abstract
1386
1350
  * @param {?} confirm
1387
1351
  * @return {?}
1388
1352
  */
1389
- exports.ɵbc.prototype.confirm = function (confirm) { };
1353
+ InteractionContext.prototype.confirm = function (confirm) { };
1390
1354
  /**
1391
1355
  * @abstract
1392
1356
  * @param {?} confirm
1393
1357
  * @return {?}
1394
1358
  */
1395
- exports.ɵbc.prototype.confirmOrReject = function (confirm) { };
1359
+ InteractionContext.prototype.confirmOrReject = function (confirm) { };
1396
1360
  /**
1397
1361
  * Presents the confirmation to the user and runs the activity only if the user confirms.
1398
1362
  * @abstract
@@ -1402,25 +1366,8 @@
1402
1366
  * @param {?=} data the activity data.
1403
1367
  * @return {?}
1404
1368
  */
1405
- exports.ɵbc.prototype.confirmThen = function (confirm, activityType, data) { };
1369
+ InteractionContext.prototype.confirmThen = function (confirm, activityType, data) { };
1406
1370
  }
1407
- (function (InteractionContext) {
1408
- /**
1409
- * @record
1410
- */
1411
- function Listener() { }
1412
- InteractionContext.Listener = Listener;
1413
- if (false) {
1414
- /**
1415
- * @return {?}
1416
- */
1417
- Listener.prototype.onActivityStarted = function () { };
1418
- /**
1419
- * @return {?}
1420
- */
1421
- Listener.prototype.onActivityFinished = function () { };
1422
- }
1423
- })(exports.ɵbc || (exports.ɵbc = {}));
1424
1371
 
1425
1372
  /**
1426
1373
  * @fileoverview added by tsickle
@@ -1429,7 +1376,7 @@
1429
1376
  /**
1430
1377
  * @template D, R, E
1431
1378
  */
1432
- exports.ɵbj = /** @class */ (function (_super) {
1379
+ exports.ɵbk = /** @class */ (function (_super) {
1433
1380
  __extends(ConfirmThenDialogComponent, _super);
1434
1381
  function ConfirmThenDialogComponent(config, interactionContext) {
1435
1382
  var _this = _super.call(this) || this;
@@ -1495,15 +1442,15 @@
1495
1442
  /** @nocollapse */
1496
1443
  ConfirmThenDialogComponent.ctorParameters = function () { return [
1497
1444
  { type: undefined, decorators: [{ type: core.Inject, args: [ACTIVITY_DATA,] }] },
1498
- { type: exports.ɵbc }
1445
+ { type: InteractionContext }
1499
1446
  ]; };
1500
1447
  return ConfirmThenDialogComponent;
1501
1448
  }(AbstractActivity));
1502
1449
  if (false) {
1503
1450
  /** @type {?} */
1504
- exports.ɵbj.prototype.config;
1451
+ exports.ɵbk.prototype.config;
1505
1452
  /** @type {?} */
1506
- exports.ɵbj.prototype.interactionContext;
1453
+ exports.ɵbk.prototype.interactionContext;
1507
1454
  }
1508
1455
  (function (ConfirmThenDialogComponent) {
1509
1456
  /**
@@ -1520,7 +1467,7 @@
1520
1467
  /** @type {?} */
1521
1468
  Data.prototype.data;
1522
1469
  }
1523
- })(exports.ɵbj || (exports.ɵbj = {}));
1470
+ })(exports.ɵbk || (exports.ɵbk = {}));
1524
1471
 
1525
1472
  /**
1526
1473
  * @fileoverview added by tsickle
@@ -1736,14 +1683,14 @@
1736
1683
  * @return {?}
1737
1684
  */
1738
1685
  function (confirm, activityType, data) {
1739
- return this._startActivity(exports.ɵbj, {
1686
+ return this._startActivity(exports.ɵbk, {
1740
1687
  confirm: confirm,
1741
1688
  activityType: activityType,
1742
1689
  data: data
1743
1690
  }, true);
1744
1691
  };
1745
1692
  return InteractionContextBase;
1746
- }(exports.ɵbc));
1693
+ }(InteractionContext));
1747
1694
  if (false) {
1748
1695
  /**
1749
1696
  * Returns the current list of activities that are in progress.
@@ -1828,7 +1775,7 @@
1828
1775
  var injector = core.Injector.create({
1829
1776
  providers: [
1830
1777
  {
1831
- provide: exports.ɵbc,
1778
+ provide: InteractionContext,
1832
1779
  useValue: this.interactionContext
1833
1780
  },
1834
1781
  { provide: ACTIVITY_DATA, useValue: activityContext.activityData }
@@ -2000,6 +1947,15 @@
2000
1947
  this._complete = true;
2001
1948
  this.activityCallbacks.onCancel(error);
2002
1949
  };
1950
+ /**
1951
+ * @return {?}
1952
+ */
1953
+ TabContext.prototype.dispose = /**
1954
+ * @return {?}
1955
+ */
1956
+ function () {
1957
+ this.component.dispose();
1958
+ };
2003
1959
  return TabContext;
2004
1960
  }());
2005
1961
  if (false) {
@@ -2089,20 +2045,10 @@
2089
2045
  enumerable: true,
2090
2046
  configurable: true
2091
2047
  });
2092
- // get isFinished() {
2093
- // return !this._initialActivityOutletContext;
2094
- // }
2095
- // get isFinished() {
2096
- // return !this._initialActivityOutletContext;
2097
- // }
2098
2048
  /**
2099
2049
  * @return {?}
2100
2050
  */
2101
- ActivityContainerComponent.prototype.ngOnInit =
2102
- // get isFinished() {
2103
- // return !this._initialActivityOutletContext;
2104
- // }
2105
- /**
2051
+ ActivityContainerComponent.prototype.ngOnInit = /**
2106
2052
  * @return {?}
2107
2053
  */
2108
2054
  function () {
@@ -2184,7 +2130,7 @@
2184
2130
  * @return {?}
2185
2131
  */
2186
2132
  function () {
2187
- this._initialActivityOutletContext = null;
2133
+ this._initialActivityOutletContext.value = null;
2188
2134
  this.initialActivityOutletContextEvent.emit(null);
2189
2135
  };
2190
2136
  // @Trace()
@@ -2216,14 +2162,24 @@
2216
2162
  * @return {?}
2217
2163
  */
2218
2164
  function () {
2219
- var _this = this;
2220
2165
  if (this.tabs.selectedIndex < this.activityTabs.length - 1) {
2166
+ /** @type {?} */
2167
+ var tabs = this.activityTabs.value;
2168
+ /** @type {?} */
2169
+ var remainingActivities_1 = tabs.slice(0, 1 + this.tabs.selectedIndex);
2170
+ /** @type {?} */
2171
+ var finishedActivityTabs = tabs.slice(1 + this.tabs.selectedIndex);
2172
+ finishedActivityTabs.forEach((/**
2173
+ * @param {?} a
2174
+ * @return {?}
2175
+ */
2176
+ function (a) { return a.dispose(); }));
2221
2177
  this.activityTabs.runInTransaction((/**
2222
2178
  * @param {?} draft
2223
2179
  * @return {?}
2224
2180
  */
2225
2181
  function (draft) {
2226
- draft.value = draft.value.slice(0, 1 + _this.tabs.selectedIndex);
2182
+ draft.value = remainingActivities_1;
2227
2183
  }));
2228
2184
  }
2229
2185
  };
@@ -2350,6 +2306,292 @@
2350
2306
  ActivityContainerComponent.prototype._activityList;
2351
2307
  }
2352
2308
 
2309
+ /**
2310
+ * @fileoverview added by tsickle
2311
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2312
+ */
2313
+ /**
2314
+ * @abstract
2315
+ */
2316
+ var /**
2317
+ * @abstract
2318
+ */
2319
+ ModalInteractionContextFactory = /** @class */ (function () {
2320
+ function ModalInteractionContextFactory() {
2321
+ }
2322
+ return ModalInteractionContextFactory;
2323
+ }());
2324
+ if (false) {
2325
+ /**
2326
+ * @abstract
2327
+ * @return {?}
2328
+ */
2329
+ ModalInteractionContextFactory.prototype.createInteractionContext = function () { };
2330
+ }
2331
+
2332
+ /**
2333
+ * @fileoverview added by tsickle
2334
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2335
+ */
2336
+ /** @type {?} */
2337
+ var inplaceMonitorCount = 0;
2338
+ exports.ɵv = /** @class */ (function () {
2339
+ function InteractionService(modelInteractionContextFactory) {
2340
+ this.modelInteractionContextFactory = modelInteractionContextFactory;
2341
+ this.garbage = new pectin.GarbageCollector();
2342
+ this.exclusiveContext = new pectin.MutableValueModel();
2343
+ this._activeModalInteractionContextModel = new pectin.MutableValueModel();
2344
+ this._activeInlineInteractionContextModel = new pectin.MutableValueModel();
2345
+ var _a = pectin.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;
2346
+ this._activeInteractionContext = chain(this._activeModalInteractionContextModel)
2347
+ .otherwise(this._activeInlineInteractionContextModel)
2348
+ .pluck('interactionContext');
2349
+ this.active = chain(this._activeInteractionContext).isNotNil();
2350
+ this.modelInteractionActive = chain(this._activeModalInteractionContextModel).isNotNil();
2351
+ this.inlineInteractionActive = chain(this._activeInlineInteractionContextModel).isNotNil();
2352
+ // TODO: chain.concat(listOrValueModels) would be nice.
2353
+ this.activeInteractionContextIds = chain(new pectin.MutableListModel())
2354
+ .append(this._activeInlineInteractionContextModel)
2355
+ .append(this._activeModalInteractionContextModel)
2356
+ .rejectNil()
2357
+ .pluck('id');
2358
+ }
2359
+ /**
2360
+ * @return {?}
2361
+ */
2362
+ InteractionService.prototype.isActive = /**
2363
+ * @return {?}
2364
+ */
2365
+ function () {
2366
+ return this.active.value;
2367
+ };
2368
+ /**
2369
+ * @param {?} disposable
2370
+ * @return {?}
2371
+ */
2372
+ InteractionService.prototype.createModalInteractionContextFor = /**
2373
+ * @param {?} disposable
2374
+ * @return {?}
2375
+ */
2376
+ function (disposable) {
2377
+ /** @type {?} */
2378
+ var context = this.modelInteractionContextFactory.createInteractionContext();
2379
+ disposable.registerDisposable(new InteractionService.Monitor('modal', context, this._activeModalInteractionContextModel, this.exclusiveContext));
2380
+ return context;
2381
+ };
2382
+ /**
2383
+ * @param {?} interactionContext
2384
+ * @return {?}
2385
+ */
2386
+ InteractionService.prototype._registerInplaceInteractionContext = /**
2387
+ * @param {?} interactionContext
2388
+ * @return {?}
2389
+ */
2390
+ function (interactionContext) {
2391
+ interactionContext.registerDisposable(new InteractionService.Monitor("ip" + ++inplaceMonitorCount, interactionContext, this._activeInlineInteractionContextModel, this.exclusiveContext));
2392
+ };
2393
+ /**
2394
+ * @return {?}
2395
+ */
2396
+ InteractionService.prototype.getCurrentActivity = /**
2397
+ * @return {?}
2398
+ */
2399
+ function () {
2400
+ return __awaiter(this, void 0, void 0, function () {
2401
+ return __generator(this, function (_a) {
2402
+ typescriptUtilities.assert.isTruthy(this.isActive());
2403
+ return [2 /*return*/, this._activeInteractionContext.value.getCurrentActivity()];
2404
+ });
2405
+ });
2406
+ };
2407
+ /**
2408
+ * Creates an interaction context that will prevent any other contexts from starting an
2409
+ * activity until it is disposed. This is intended for use by the router for passing
2410
+ * to PlaceComponent.canDeactivate(interactionContext). This ensures components don't
2411
+ * try and interact in a way that we can't track and synchronise with the browser back
2412
+ * button.
2413
+ */
2414
+ /**
2415
+ * Creates an interaction context that will prevent any other contexts from starting an
2416
+ * activity until it is disposed. This is intended for use by the router for passing
2417
+ * to PlaceComponent.canDeactivate(interactionContext). This ensures components don't
2418
+ * try and interact in a way that we can't track and synchronise with the browser back
2419
+ * button.
2420
+ * @return {?}
2421
+ */
2422
+ InteractionService.prototype._createExclusiveModalInteractionContext = /**
2423
+ * Creates an interaction context that will prevent any other contexts from starting an
2424
+ * activity until it is disposed. This is intended for use by the router for passing
2425
+ * to PlaceComponent.canDeactivate(interactionContext). This ensures components don't
2426
+ * try and interact in a way that we can't track and synchronise with the browser back
2427
+ * button.
2428
+ * @return {?}
2429
+ */
2430
+ function () {
2431
+ this.exclusiveContext.value = this.modelInteractionContextFactory.createInteractionContext();
2432
+ /** @type {?} */
2433
+ var self = this;
2434
+ this.exclusiveContext.value.registerDisposable({
2435
+ dispose: /**
2436
+ * @return {?}
2437
+ */
2438
+ function () {
2439
+ self.exclusiveContext.value = null;
2440
+ }
2441
+ });
2442
+ return this.exclusiveContext.value;
2443
+ };
2444
+ InteractionService.decorators = [
2445
+ { type: core.Injectable, args: [{
2446
+ providedIn: 'root'
2447
+ },] }
2448
+ ];
2449
+ /** @nocollapse */
2450
+ InteractionService.ctorParameters = function () { return [
2451
+ { type: ModalInteractionContextFactory }
2452
+ ]; };
2453
+ /** @nocollapse */ InteractionService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function InteractionService_Factory() { return new InteractionService(core.ɵɵinject(ModalInteractionContextFactory)); }, token: InteractionService, providedIn: "root" });
2454
+ return InteractionService;
2455
+ }());
2456
+ if (false) {
2457
+ /**
2458
+ * @type {?}
2459
+ * @private
2460
+ */
2461
+ exports.ɵv.prototype.garbage;
2462
+ /** @type {?} */
2463
+ exports.ɵv.prototype.active;
2464
+ /**
2465
+ * @type {?}
2466
+ * @private
2467
+ */
2468
+ exports.ɵv.prototype.exclusiveContext;
2469
+ /**
2470
+ * @type {?}
2471
+ * @private
2472
+ */
2473
+ exports.ɵv.prototype._activeModalInteractionContextModel;
2474
+ /**
2475
+ * @type {?}
2476
+ * @private
2477
+ */
2478
+ exports.ɵv.prototype._activeInlineInteractionContextModel;
2479
+ /**
2480
+ * @type {?}
2481
+ * @private
2482
+ */
2483
+ exports.ɵv.prototype._activeInteractionContext;
2484
+ /** @type {?} */
2485
+ exports.ɵv.prototype.activeInteractionContextIds;
2486
+ /** @type {?} */
2487
+ exports.ɵv.prototype.modelInteractionActive;
2488
+ /** @type {?} */
2489
+ exports.ɵv.prototype.inlineInteractionActive;
2490
+ /** @type {?} */
2491
+ exports.ɵv.prototype.modelInteractionContextFactory;
2492
+ }
2493
+ (function (InteractionService) {
2494
+ /**
2495
+ * @record
2496
+ */
2497
+ function Callback() { }
2498
+ InteractionService.Callback = Callback;
2499
+ if (false) {
2500
+ /**
2501
+ * @param {?} monitor
2502
+ * @return {?}
2503
+ */
2504
+ Callback.prototype.onStarted = function (monitor) { };
2505
+ /**
2506
+ * @param {?} monitor
2507
+ * @return {?}
2508
+ */
2509
+ Callback.prototype.onFinished = function (monitor) { };
2510
+ }
2511
+ var Monitor = /** @class */ (function (_super) {
2512
+ __extends(Monitor, _super);
2513
+ function Monitor(id, interactionContext, currentActiveMonitor, exclusiveContext) {
2514
+ var _this = _super.call(this) || this;
2515
+ _this.id = id;
2516
+ _this.interactionContext = interactionContext;
2517
+ _this.currentActiveMonitor = currentActiveMonitor;
2518
+ _this.exclusiveContext = exclusiveContext;
2519
+ var _a = pectin.Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
2520
+ when.valueOf(interactionContext.active).becomesTruthy((/**
2521
+ * @return {?}
2522
+ */
2523
+ function () { return _this.onStarted(); }));
2524
+ when.valueOf(interactionContext.active).becomesFalsey((/**
2525
+ * @return {?}
2526
+ */
2527
+ function () { return _this.onFinished(); }));
2528
+ interactionContext.registerDisposable(_this);
2529
+ return _this;
2530
+ }
2531
+ /**
2532
+ * @protected
2533
+ * @return {?}
2534
+ */
2535
+ Monitor.prototype.onStarted = /**
2536
+ * @protected
2537
+ * @return {?}
2538
+ */
2539
+ function () {
2540
+ this.assertCanStart();
2541
+ this.currentActiveMonitor.value = this;
2542
+ };
2543
+ /**
2544
+ * @private
2545
+ * @return {?}
2546
+ */
2547
+ Monitor.prototype.assertCanStart = /**
2548
+ * @private
2549
+ * @return {?}
2550
+ */
2551
+ function () {
2552
+ typescriptUtilities.assert.isFalsey(this.currentActiveMonitor.value);
2553
+ if (this.exclusiveContext.value && this.interactionContext !== this.exclusiveContext.value) {
2554
+ pectin.lang.illegalState('Interaction started while exclusive lock active. This is usually because you using a different context during place.canDeactivate(interactionContext)');
2555
+ }
2556
+ };
2557
+ /**
2558
+ * @protected
2559
+ * @return {?}
2560
+ */
2561
+ Monitor.prototype.onFinished = /**
2562
+ * @protected
2563
+ * @return {?}
2564
+ */
2565
+ function () {
2566
+ this.assertCurrentlyActive();
2567
+ this.currentActiveMonitor.value = null;
2568
+ };
2569
+ /**
2570
+ * @private
2571
+ * @return {?}
2572
+ */
2573
+ Monitor.prototype.assertCurrentlyActive = /**
2574
+ * @private
2575
+ * @return {?}
2576
+ */
2577
+ function () {
2578
+ typescriptUtilities.assert.isTruthy(this.currentActiveMonitor.value === this);
2579
+ };
2580
+ return Monitor;
2581
+ }(pectin.GarbageCollector));
2582
+ InteractionService.Monitor = Monitor;
2583
+ if (false) {
2584
+ /** @type {?} */
2585
+ Monitor.prototype.id;
2586
+ /** @type {?} */
2587
+ Monitor.prototype.interactionContext;
2588
+ /** @type {?} */
2589
+ Monitor.prototype.currentActiveMonitor;
2590
+ /** @type {?} */
2591
+ Monitor.prototype.exclusiveContext;
2592
+ }
2593
+ })(exports.ɵv || (exports.ɵv = {}));
2594
+
2353
2595
  /**
2354
2596
  * @fileoverview added by tsickle
2355
2597
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -2359,10 +2601,11 @@
2359
2601
  */
2360
2602
  var InplaceInteractionContextComponent = /** @class */ (function (_super) {
2361
2603
  __extends(InplaceInteractionContextComponent, _super);
2362
- function InplaceInteractionContextComponent() {
2604
+ function InplaceInteractionContextComponent(interactionService) {
2363
2605
  var _this = _super.call(this) || this;
2364
- _this._active = new pectin.DelegatingValueModel().withDefault(false);
2365
- var _a = pectin.Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
2606
+ _this.interactionService = interactionService;
2607
+ _this._active = new pectin.MutableValueModel(false);
2608
+ _this.interactionService._registerInplaceInteractionContext(_this);
2366
2609
  return _this;
2367
2610
  }
2368
2611
  /**
@@ -2373,7 +2616,6 @@
2373
2616
  */
2374
2617
  function () {
2375
2618
  this.setActivityList(this.interactionContext.activityList);
2376
- this._active.setDelegate(this.interactionContext.active);
2377
2619
  };
2378
2620
  Object.defineProperty(InplaceInteractionContextComponent.prototype, "active", {
2379
2621
  get: /**
@@ -2401,6 +2643,7 @@
2401
2643
  */
2402
2644
  function (activityType, data) {
2403
2645
  var _this = this;
2646
+ this._active.value = true;
2404
2647
  /** @type {?} */
2405
2648
  var self = this;
2406
2649
  return new Promise((/**
@@ -2417,6 +2660,7 @@
2417
2660
  * @return {?}
2418
2661
  */
2419
2662
  function (result) {
2663
+ self._active.value = false;
2420
2664
  resolve(result);
2421
2665
  },
2422
2666
  onCancel: /**
@@ -2424,6 +2668,7 @@
2424
2668
  * @return {?}
2425
2669
  */
2426
2670
  function (error) {
2671
+ self._active.value = false;
2427
2672
  reject(error);
2428
2673
  }
2429
2674
  };
@@ -2437,7 +2682,9 @@
2437
2682
  }] }
2438
2683
  ];
2439
2684
  /** @nocollapse */
2440
- InplaceInteractionContextComponent.ctorParameters = function () { return []; };
2685
+ InplaceInteractionContextComponent.ctorParameters = function () { return [
2686
+ { type: exports.ɵv }
2687
+ ]; };
2441
2688
  InplaceInteractionContextComponent.propDecorators = {
2442
2689
  interactionContext: [{ type: core.ViewChild, args: ['activityContainer', { static: true },] }]
2443
2690
  };
@@ -2453,6 +2700,8 @@
2453
2700
  * @private
2454
2701
  */
2455
2702
  InplaceInteractionContextComponent.prototype._active;
2703
+ /** @type {?} */
2704
+ InplaceInteractionContextComponent.prototype.interactionService;
2456
2705
  }
2457
2706
 
2458
2707
  /**
@@ -2478,500 +2727,8 @@
2478
2727
  * @fileoverview added by tsickle
2479
2728
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2480
2729
  */
2481
- var DialogInteractionContext = /** @class */ (function (_super) {
2482
- __extends(DialogInteractionContext, _super);
2483
- function DialogInteractionContext(dialogService, config) {
2484
- var _this = _super.call(this) || this;
2485
- _this.dialogService = dialogService;
2486
- _this.config = config;
2487
- _this._activeModel = new pectin.MutableValueModel(false);
2488
- typescriptUtilities.assert.notNil(dialogService);
2489
- _this.onDispose((/**
2490
- * @return {?}
2491
- */
2492
- function () {
2493
- if (_this.isActive()) {
2494
- pectin.lang.illegalState('Dispose called while active.');
2495
- }
2496
- }));
2497
- return _this;
2498
- }
2499
- Object.defineProperty(DialogInteractionContext.prototype, "active", {
2500
- get: /**
2501
- * @return {?}
2502
- */
2503
- function () {
2504
- return this._activeModel.readonly;
2505
- },
2506
- enumerable: true,
2507
- configurable: true
2508
- });
2509
- /**
2510
- * @protected
2511
- * @template D, R, E
2512
- * @param {?} activityType
2513
- * @param {?} data
2514
- * @param {?=} disableClose
2515
- * @return {?}
2516
- */
2517
- DialogInteractionContext.prototype._startActivity = /**
2518
- * @protected
2519
- * @template D, R, E
2520
- * @param {?} activityType
2521
- * @param {?} data
2522
- * @param {?=} disableClose
2523
- * @return {?}
2524
- */
2525
- function (activityType, data, disableClose) {
2526
- var _this = this;
2527
- if (disableClose === void 0) { disableClose = true; }
2528
- if (this.isActive()) {
2529
- pectin.lang.illegalState("Activity already in progress: " + this.activityList.value.map((/**
2530
- * @param {?} a
2531
- * @return {?}
2532
- */
2533
- function (a) { return a.constructor.name; })).join(', '));
2534
- }
2535
- this._activeModel.value = true;
2536
- this.notifyActivityStarted();
2537
- /** @type {?} */
2538
- var config = __assign({}, this.config, {
2539
- data: data,
2540
- disableClose: disableClose,
2541
- panelClass: 'dialog-interaction-service'
2542
- });
2543
- /** @type {?} */
2544
- var self = this;
2545
- /** @type {?} */
2546
- var matDialogRef = (/** @type {?} */ (this.dialogService.open(ActivityContainerComponent, config)));
2547
- return new Promise((/**
2548
- * @param {?} resolve
2549
- * @param {?} reject
2550
- * @return {?}
2551
- */
2552
- function (resolve, reject) {
2553
- /** @type {?} */
2554
- var activityContainer = matDialogRef.componentInstance;
2555
- self.safelyUpdateActivityListDelegate(activityContainer.activityList);
2556
- activityContainer.initialActivityOutletContext = {
2557
- activityClass: activityType,
2558
- activityData: data,
2559
- onDone: /**
2560
- * @param {?} result
2561
- * @return {?}
2562
- */
2563
- function (result) {
2564
- resolve(result);
2565
- matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
2566
- },
2567
- onCancel: /**
2568
- * @param {?} error
2569
- * @return {?}
2570
- */
2571
- function (error) {
2572
- reject(error);
2573
- matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
2574
- }
2575
- };
2576
- // we need to check if our onDone/onCancel methods above we called or if we were
2577
- // closed by the user clicking the backdrop. If the later then we need to reject
2578
- // our promise.
2579
- matDialogRef.afterClosed().subscribe((/**
2580
- * @param {?} promiseAlreadyFinished
2581
- * @return {?}
2582
- */
2583
- function (promiseAlreadyFinished) {
2584
- if (!promiseAlreadyFinished) {
2585
- reject('auto-closed');
2586
- }
2587
- }));
2588
- matDialogRef.updateSize();
2589
- matDialogRef.afterOpened().subscribe((/**
2590
- * @param {?} promiseAlreadyFinished
2591
- * @return {?}
2592
- */
2593
- function (promiseAlreadyFinished) {
2594
- matDialogRef.updateSize();
2595
- }));
2596
- })).finally((/**
2597
- * @return {?}
2598
- */
2599
- function () {
2600
- _this._activeModel.value = false;
2601
- _this.notifyActivityFinished();
2602
- self.safelyUpdateActivityListDelegate(null);
2603
- }));
2604
- };
2605
- /**
2606
- * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
2607
- * @param delegate
2608
- */
2609
- /**
2610
- * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
2611
- * @param {?} delegate
2612
- * @return {?}
2613
- */
2614
- DialogInteractionContext.prototype.safelyUpdateActivityListDelegate = /**
2615
- * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
2616
- * @param {?} delegate
2617
- * @return {?}
2618
- */
2619
- function (delegate) {
2620
- var _this = this;
2621
- setTimeout((/**
2622
- * @return {?}
2623
- */
2624
- function () { return _this.setActivityList(delegate); }));
2625
- };
2626
- DialogInteractionContext.decorators = [
2627
- { type: core.Injectable, args: [{
2628
- providedIn: 'root'
2629
- },] }
2630
- ];
2631
- /** @nocollapse */
2632
- DialogInteractionContext.ctorParameters = function () { return [
2633
- { type: material.MatDialog },
2634
- { type: dialog.MatDialogConfig }
2635
- ]; };
2636
- /** @nocollapse */ DialogInteractionContext.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function DialogInteractionContext_Factory() { return new DialogInteractionContext(core.ɵɵinject(dialog.MatDialog), core.ɵɵinject(dialog.MatDialogConfig)); }, token: DialogInteractionContext, providedIn: "root" });
2637
- return DialogInteractionContext;
2638
- }(InteractionContextBase));
2639
- if (false) {
2640
- /**
2641
- * @type {?}
2642
- * @private
2643
- */
2644
- DialogInteractionContext.prototype._activeModel;
2645
- /**
2646
- * @type {?}
2647
- * @private
2648
- */
2649
- DialogInteractionContext.prototype.dialogService;
2650
- /** @type {?} */
2651
- DialogInteractionContext.prototype.config;
2652
- }
2653
-
2654
- /**
2655
- * @fileoverview added by tsickle
2656
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2657
- */
2658
- var Guard = /** @class */ (function (_super) {
2659
- __extends(Guard, _super);
2660
- function Guard() {
2661
- return _super.call(this, { initialValue: false }) || this;
2662
- }
2663
- Object.defineProperty(Guard.prototype, "value", {
2664
- get: /**
2665
- * @return {?}
2666
- */
2667
- function () {
2668
- return this.store.read();
2669
- },
2670
- enumerable: true,
2671
- configurable: true
2672
- });
2673
- /**
2674
- * @template R
2675
- * @param {?} fun
2676
- * @return {?}
2677
- */
2678
- Guard.prototype.whileTrue = /**
2679
- * @template R
2680
- * @param {?} fun
2681
- * @return {?}
2682
- */
2683
- function (fun) {
2684
- this.startTransaction().commit(true);
2685
- try {
2686
- return fun();
2687
- }
2688
- finally {
2689
- this.startTransaction().commit(false);
2690
- }
2691
- };
2692
- /**
2693
- * @template R
2694
- * @param {?} fun
2695
- * @param {?=} defaultValue
2696
- * @return {?}
2697
- */
2698
- Guard.prototype.runIfFalse = /**
2699
- * @template R
2700
- * @param {?} fun
2701
- * @param {?=} defaultValue
2702
- * @return {?}
2703
- */
2704
- function (fun, defaultValue) {
2705
- if (defaultValue === void 0) { defaultValue = null; }
2706
- return !this.value ? fun() : defaultValue;
2707
- };
2708
- return Guard;
2709
- }(pectin.ValueModel));
2710
- /**
2711
- * @abstract
2712
- */
2713
- var /**
2714
- * @abstract
2715
- */
2716
- ModalInteractionService = /** @class */ (function (_super) {
2717
- __extends(ModalInteractionService, _super);
2718
- function ModalInteractionService() {
2719
- var _this = _super.call(this) || this;
2720
- _this._activityListeners = new pectin.EventListenerList();
2721
- return _this;
2722
- }
2723
- /**
2724
- * @return {?}
2725
- */
2726
- ModalInteractionService.prototype.isActive = /**
2727
- * @return {?}
2728
- */
2729
- function () {
2730
- return this.active.value;
2731
- };
2732
- /**
2733
- * @param {?} listener
2734
- * @return {?}
2735
- */
2736
- ModalInteractionService.prototype.addActivityListener = /**
2737
- * @param {?} listener
2738
- * @return {?}
2739
- */
2740
- function (listener) {
2741
- return this._activityListeners.add(listener);
2742
- };
2743
- /**
2744
- * @protected
2745
- * @return {?}
2746
- */
2747
- ModalInteractionService.prototype.notifyActivityStarted = /**
2748
- * @protected
2749
- * @return {?}
2750
- */
2751
- function () {
2752
- this._activityListeners.fire((/**
2753
- * @param {?} l
2754
- * @return {?}
2755
- */
2756
- function (l) { return l.onActivityStarted(); }));
2757
- };
2758
- /**
2759
- * @protected
2760
- * @return {?}
2761
- */
2762
- ModalInteractionService.prototype.notifyActivityFinished = /**
2763
- * @protected
2764
- * @return {?}
2765
- */
2766
- function () {
2767
- this._activityListeners.fire((/**
2768
- * @param {?} l
2769
- * @return {?}
2770
- */
2771
- function (l) { return l.onActivityFinished(); }));
2772
- };
2773
- return ModalInteractionService;
2774
- }(pectin.GarbageCollector));
2775
- if (false) {
2776
- /**
2777
- * @type {?}
2778
- * @private
2779
- */
2780
- ModalInteractionService.prototype._activityListeners;
2781
- /** @type {?} */
2782
- ModalInteractionService.prototype.active;
2783
- /**
2784
- * @abstract
2785
- * @param {?} disposable
2786
- * @return {?}
2787
- */
2788
- ModalInteractionService.prototype.createInteractionContextFor = function (disposable) { };
2789
- /**
2790
- * @abstract
2791
- * @return {?}
2792
- */
2793
- ModalInteractionService.prototype.createExclusiveInteractionContext = function () { };
2794
- /**
2795
- * @abstract
2796
- * @return {?}
2797
- */
2798
- ModalInteractionService.prototype.getCurrentActivity = function () { };
2799
- }
2800
-
2801
- /**
2802
- * @fileoverview added by tsickle
2803
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2804
- */
2805
- /** @type {?} */
2806
- var DIALOG_INTERACTION_SERVICE_DEFAULTS = new core.InjectionToken('DIALOG_INTERACTION_SERVICE_DEFAULTS');
2807
- var DialogInteractionService = /** @class */ (function (_super) {
2808
- __extends(DialogInteractionService, _super);
2809
- function DialogInteractionService(dialogService, dialogServiceDefaults, matDialogDefaultConfig) {
2810
- var _this = _super.call(this) || this;
2811
- _this.dialogService = dialogService;
2812
- _this.dialogServiceDefaults = dialogServiceDefaults;
2813
- _this.matDialogDefaultConfig = matDialogDefaultConfig;
2814
- _this._activeInteractionContextModel = new pectin.MutableValueModel();
2815
- typescriptUtilities.assert.notNil(dialogService);
2816
- var _a = pectin.Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
2817
- _this.active = chain(_this._activeInteractionContextModel).isNotNil();
2818
- return _this;
2819
- }
2820
- /**
2821
- * @param {?} disposable
2822
- * @return {?}
2823
- */
2824
- DialogInteractionService.prototype.createInteractionContextFor = /**
2825
- * @param {?} disposable
2826
- * @return {?}
2827
- */
2828
- function (disposable) {
2829
- return disposable.registerDisposable(this._createInteractionContext());
2830
- };
2831
- /**
2832
- * @return {?}
2833
- */
2834
- DialogInteractionService.prototype._createInteractionContext = /**
2835
- * @return {?}
2836
- */
2837
- function () {
2838
- /** @type {?} */
2839
- var config = __assign({ autoFocus: false, hasBackdrop: true, closeOnNavigation: false }, this.matDialogDefaultConfig, this.dialogServiceDefaults);
2840
- /** @type {?} */
2841
- var self = this;
2842
- /** @type {?} */
2843
- var dialogInteractionContext = new DialogInteractionContext(this.dialogService, config);
2844
- dialogInteractionContext.registerDisposable(dialogInteractionContext.addActivityListener({
2845
- onActivityStarted: /**
2846
- * @return {?}
2847
- */
2848
- function () {
2849
- self.onActivityStarted(dialogInteractionContext);
2850
- },
2851
- onActivityFinished: /**
2852
- * @return {?}
2853
- */
2854
- function () {
2855
- self.onActivityFinished(dialogInteractionContext);
2856
- }
2857
- }));
2858
- return dialogInteractionContext;
2859
- };
2860
- /**
2861
- * @return {?}
2862
- */
2863
- DialogInteractionService.prototype.createExclusiveInteractionContext = /**
2864
- * @return {?}
2865
- */
2866
- function () {
2867
- this.exclusiveContext = this._createInteractionContext();
2868
- /** @type {?} */
2869
- var self = this;
2870
- this.exclusiveContext.registerDisposable({
2871
- dispose: /**
2872
- * @return {?}
2873
- */
2874
- function () {
2875
- self.exclusiveContext = null;
2876
- }
2877
- });
2878
- return this.exclusiveContext;
2879
- };
2880
- // @Trace()
2881
- // @Trace()
2882
- /**
2883
- * @param {?} dialogInteractionContext
2884
- * @return {?}
2885
- */
2886
- DialogInteractionService.prototype.onActivityStarted =
2887
- // @Trace()
2888
- /**
2889
- * @param {?} dialogInteractionContext
2890
- * @return {?}
2891
- */
2892
- function (dialogInteractionContext) {
2893
- typescriptUtilities.assert.isFalsey(this.isActive());
2894
- if (this.exclusiveContext && dialogInteractionContext !== this.exclusiveContext) {
2895
- pectin.lang.illegalState("Interaction started while exclusive lock active. This is usually because you using a different context during place.canDeactivate(interactionContext)");
2896
- }
2897
- this._activeInteractionContextModel.value = dialogInteractionContext;
2898
- this.notifyActivityStarted();
2899
- };
2900
- // @Trace()
2901
- // @Trace()
2902
- /**
2903
- * @param {?} dialogInteractionContext
2904
- * @return {?}
2905
- */
2906
- DialogInteractionService.prototype.onActivityFinished =
2907
- // @Trace()
2908
- /**
2909
- * @param {?} dialogInteractionContext
2910
- * @return {?}
2911
- */
2912
- function (dialogInteractionContext) {
2913
- typescriptUtilities.assert.isTruthy(this._activeInteractionContextModel.value === dialogInteractionContext);
2914
- this._activeInteractionContextModel.value = null;
2915
- this.notifyActivityFinished();
2916
- };
2917
- /**
2918
- * @return {?}
2919
- */
2920
- DialogInteractionService.prototype.getCurrentActivity = /**
2921
- * @return {?}
2922
- */
2923
- function () {
2924
- return __awaiter(this, void 0, void 0, function () {
2925
- return __generator(this, function (_a) {
2926
- typescriptUtilities.assert.isTruthy(this.isActive());
2927
- return [2 /*return*/, this._activeInteractionContextModel.value.getCurrentActivity()];
2928
- });
2929
- });
2930
- };
2931
- DialogInteractionService.decorators = [
2932
- { type: core.Injectable, args: [{
2933
- providedIn: 'root'
2934
- },] }
2935
- ];
2936
- /** @nocollapse */
2937
- DialogInteractionService.ctorParameters = function () { return [
2938
- { type: material.MatDialog },
2939
- { type: dialog.MatDialogConfig, decorators: [{ type: core.Optional }, { type: core.Inject, args: [DIALOG_INTERACTION_SERVICE_DEFAULTS,] }] },
2940
- { type: dialog.MatDialogConfig, decorators: [{ type: core.Optional }, { type: core.Inject, args: [dialog.MAT_DIALOG_DEFAULT_OPTIONS,] }] }
2941
- ]; };
2942
- /** @nocollapse */ DialogInteractionService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function DialogInteractionService_Factory() { return new DialogInteractionService(core.ɵɵinject(dialog.MatDialog), core.ɵɵinject(DIALOG_INTERACTION_SERVICE_DEFAULTS, 8), core.ɵɵinject(dialog.MAT_DIALOG_DEFAULT_OPTIONS, 8)); }, token: DialogInteractionService, providedIn: "root" });
2943
- return DialogInteractionService;
2944
- }(ModalInteractionService));
2945
- if (false) {
2946
- /**
2947
- * @type {?}
2948
- * @private
2949
- */
2950
- DialogInteractionService.prototype._activeInteractionContextModel;
2951
- /** @type {?} */
2952
- DialogInteractionService.prototype.active;
2953
- /**
2954
- * @type {?}
2955
- * @private
2956
- */
2957
- DialogInteractionService.prototype.exclusiveContext;
2958
- /**
2959
- * @type {?}
2960
- * @private
2961
- */
2962
- DialogInteractionService.prototype.dialogService;
2963
- /** @type {?} */
2964
- DialogInteractionService.prototype.dialogServiceDefaults;
2965
- /** @type {?} */
2966
- DialogInteractionService.prototype.matDialogDefaultConfig;
2967
- }
2968
-
2969
- /**
2970
- * @fileoverview added by tsickle
2971
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2972
- */
2973
- var InteractionModule = /** @class */ (function () {
2974
- function InteractionModule() {
2730
+ var InteractionModule = /** @class */ (function () {
2731
+ function InteractionModule() {
2975
2732
  }
2976
2733
  InteractionModule.decorators = [
2977
2734
  { type: core.NgModule, args: [{
@@ -2986,7 +2743,7 @@
2986
2743
  declarations: [
2987
2744
  ActivityContainerComponent,
2988
2745
  ConfirmationDialogComponent,
2989
- exports.ɵbj,
2746
+ exports.ɵbk,
2990
2747
  AlertDialogComponent,
2991
2748
  ActivityOutletComponent,
2992
2749
  InteractionOutletComponent,
@@ -3001,11 +2758,11 @@
3001
2758
  entryComponents: [
3002
2759
  ActivityContainerComponent,
3003
2760
  ConfirmationDialogComponent,
3004
- exports.ɵbj,
2761
+ exports.ɵbk,
3005
2762
  AlertDialogComponent
3006
2763
  ],
3007
2764
  providers: [
3008
- DialogInteractionService,
2765
+ exports.ɵv,
3009
2766
  ]
3010
2767
  },] }
3011
2768
  ];
@@ -4014,67 +3771,33 @@
4014
3771
  * @return {?}
4015
3772
  */
4016
3773
  function (nextState) {
4017
- return __awaiter(this, void 0, void 0, function () {
4018
- return __generator(this, function (_a) {
4019
- // Automatically cancel any active activities if the navigation session was triggered
4020
- // by the back button.
4021
- if (this.navigationSession.isPopState && this.component.interactionContext && this.component.interactionContext.isActive()) {
4022
- // Note: any modal interactions run in a different router outlet so we should never get place deactivated while
4023
- // one is active. This is because:
4024
- // 1. the user can't click anything to navigate away
4025
- // 2. clicking the back button will only change the outlet route and will leave the component route alone. This
4026
- // is all handled by the InteractionGuard and so the component guards will never run.
4027
- // TODO: how will I handle this now??
4028
- // BUT: activities could call navigate while they're still active.. but we'll barf and tell them
4029
- // to call activity.done(newVisitToNavigateTo) and let the caller do the navigate after the
4030
- // dialog has closed.
4031
- // Can I capture this in placeRouter.navigate(..) ? i.e. navigationSession && navigationSession.interactionContext.isActive()
4032
- // Or can I just ignore it altogether?
4033
- // 1. I no longer have a singleton dialog interaction that can be returned from any component in the deactivation cycle.
4034
- // 2. We only ever check the component once per nav cycle
4035
- // 3. The navigation session interaction context will barf if multiple components try and use it at once.
4036
- // if (this.component.interactionContext instanceof DialogInteractionContext) {
4037
- // // BUT: activities could call navigate while they're still active.. but we'll barf and tell them
4038
- // // to call activity.done(newVisitToNavigateTo) and let the caller do the navigate after the
4039
- // // dialog has closed.
4040
- // lang.illegalState('Navigation started from an activity in a modal dialog. Have your activity return a Visit instead and navigate after the activity has finished');
4041
- // }
4042
- // Now we just cancel the current activity and stay where we are
4043
- this.cancelCurrentActivityOf(this.component.interactionContext);
4044
- return [2 /*return*/, false];
4045
- }
4046
- // Ok, so now we're really leaving, so we ask the component if we should.;
4047
- if (this.isNotJustAChangeInRouteId(nextState) && this.component.canDeactivate) {
4048
- // No interaction in progress, so ask the component .
4049
- // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
4050
- // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
4051
- return [2 /*return*/, this.component.canDeactivate(this.navigationSession.interactionContext)];
4052
- }
4053
- return [2 /*return*/, true];
4054
- });
4055
- });
4056
- };
4057
- /**
4058
- * @protected
4059
- * @param {?} interactionContext
4060
- * @return {?}
4061
- */
4062
- PlaceComponentDeactivationHandler.prototype.cancelCurrentActivityOf = /**
4063
- * @protected
4064
- * @param {?} interactionContext
4065
- * @return {?}
4066
- */
4067
- function (interactionContext) {
4068
3774
  return __awaiter(this, void 0, void 0, function () {
4069
3775
  var activity;
4070
3776
  return __generator(this, function (_a) {
4071
3777
  switch (_a.label) {
4072
- case 0: return [4 /*yield*/, interactionContext.getCurrentActivity()];
3778
+ case 0:
3779
+ if (!(this.navigationSession.isPopState && this.component.interactionContext && this.component.interactionContext.isActive())) return [3 /*break*/, 2];
3780
+ // Note: Modal interactions are run in a different router outlet so we never get place deactivating while
3781
+ // a model interaction is active. This is because:
3782
+ // 1. the user can't click anything to navigate away
3783
+ // 2. clicking the back button will only change the outlet route portion of the URL. This
3784
+ // is all handled by the InteractionGuard and so the component guards will never run.
3785
+ //
3786
+ // Now we just cancel the current activity...
3787
+ return [4 /*yield*/, this.component.interactionContext.getCurrentActivity()];
4073
3788
  case 1:
4074
3789
  activity = _a.sent();
4075
- console.log('cancelling', { activity: activity });
4076
3790
  activity.cancel(null);
4077
- return [2 /*return*/];
3791
+ return [2 /*return*/, false]; // ..and stay where we are.
3792
+ case 2:
3793
+ // Ok, so now we're really leaving, so we ask the component if we should.;
3794
+ if (this.isNotJustAChangeInRouteId(nextState) && this.component.canDeactivate) {
3795
+ // No interaction in progress, so ask the component .
3796
+ // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
3797
+ // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
3798
+ return [2 /*return*/, this.component.canDeactivate(this.navigationSession.interactionContext)];
3799
+ }
3800
+ return [2 /*return*/, true];
4078
3801
  }
4079
3802
  });
4080
3803
  });
@@ -4116,15 +3839,48 @@
4116
3839
  /**
4117
3840
  * @abstract
4118
3841
  */
4119
- exports.NavigationSession = /** @class */ (function (_super) {
4120
- __extends(NavigationSession, _super);
4121
- function NavigationSession(context) {
3842
+ /**
3843
+ * @abstract
3844
+ */
3845
+ exports.NavigationState = /** @class */ (function (_super) {
3846
+ __extends(NavigationState, _super);
3847
+ function NavigationState(context) {
4122
3848
  var _this = _super.call(this) || this;
4123
3849
  _this.context = context;
4124
3850
  _this._visits = new Map();
4125
3851
  return _this;
4126
3852
  }
4127
- Object.defineProperty(NavigationSession.prototype, "interactionContext", {
3853
+ Object.defineProperty(NavigationState.prototype, "idle", {
3854
+ get: /**
3855
+ * @return {?}
3856
+ */
3857
+ function () {
3858
+ return !this.isTransitional;
3859
+ },
3860
+ enumerable: true,
3861
+ configurable: true
3862
+ });
3863
+ Object.defineProperty(NavigationState.prototype, "placeRouter", {
3864
+ get: /**
3865
+ * @return {?}
3866
+ */
3867
+ function () {
3868
+ return this.context.placeRouter;
3869
+ },
3870
+ enumerable: true,
3871
+ configurable: true
3872
+ });
3873
+ Object.defineProperty(NavigationState.prototype, "interactionService", {
3874
+ get: /**
3875
+ * @return {?}
3876
+ */
3877
+ function () {
3878
+ return this.context.interactionService;
3879
+ },
3880
+ enumerable: true,
3881
+ configurable: true
3882
+ });
3883
+ Object.defineProperty(NavigationState.prototype, "interactionContext", {
4128
3884
  get: /**
4129
3885
  * @return {?}
4130
3886
  */
@@ -4138,7 +3894,7 @@
4138
3894
  * @param {?} visit
4139
3895
  * @return {?}
4140
3896
  */
4141
- NavigationSession.prototype.storeVisit = /**
3897
+ NavigationState.prototype.storeVisit = /**
4142
3898
  * @param {?} visit
4143
3899
  * @return {?}
4144
3900
  */
@@ -4146,31 +3902,103 @@
4146
3902
  this._visits.set(visit.placeDefinition, visit);
4147
3903
  };
4148
3904
  /**
4149
- * @param {?} placeDef
3905
+ * @param {?} placeDef
3906
+ * @return {?}
3907
+ */
3908
+ NavigationState.prototype.getVisitFor = /**
3909
+ * @param {?} placeDef
3910
+ * @return {?}
3911
+ */
3912
+ function (placeDef) {
3913
+ return this._visits.get(placeDef);
3914
+ };
3915
+ /**
3916
+ * @param {?} event
3917
+ * @return {?}
3918
+ */
3919
+ NavigationState.prototype.onPopState = /**
3920
+ * @param {?} event
3921
+ * @return {?}
3922
+ */
3923
+ function (event) {
3924
+ return this.illegalTransition(event);
3925
+ };
3926
+ /**
3927
+ * @param {?} event
3928
+ * @return {?}
3929
+ */
3930
+ NavigationState.prototype.onStart = /**
3931
+ * @param {?} event
3932
+ * @return {?}
3933
+ */
3934
+ function (event) {
3935
+ return this.illegalTransition(event);
3936
+ };
3937
+ /**
3938
+ * @param {?} event
3939
+ * @return {?}
3940
+ */
3941
+ NavigationState.prototype.onCancel = /**
3942
+ * @param {?} event
3943
+ * @return {?}
3944
+ */
3945
+ function (event) {
3946
+ return this.illegalTransition(event);
3947
+ };
3948
+ /**
3949
+ * @param {?} event
3950
+ * @return {?}
3951
+ */
3952
+ NavigationState.prototype.onError = /**
3953
+ * @param {?} event
3954
+ * @return {?}
3955
+ */
3956
+ function (event) {
3957
+ return this.illegalTransition(event);
3958
+ };
3959
+ /**
3960
+ * @param {?} event
4150
3961
  * @return {?}
4151
3962
  */
4152
- NavigationSession.prototype.getVisitFor = /**
4153
- * @param {?} placeDef
3963
+ NavigationState.prototype.onEnd = /**
3964
+ * @param {?} event
4154
3965
  * @return {?}
4155
3966
  */
4156
- function (placeDef) {
4157
- return this._visits.get(placeDef);
3967
+ function (event) {
3968
+ return this.illegalTransition(event);
4158
3969
  };
4159
3970
  /**
4160
3971
  * @param {?} newUrl
4161
3972
  * @return {?}
4162
3973
  */
4163
- NavigationSession.prototype.onBackClickedDuringNavigationInteraction = /**
3974
+ NavigationState.prototype.onBackClickedDuringNavigationInteraction = /**
4164
3975
  * @param {?} newUrl
4165
3976
  * @return {?}
4166
3977
  */
4167
3978
  function (newUrl) {
4168
3979
  return this.illegalTransition('onBackClickedDuringNavigationInteraction');
4169
3980
  };
3981
+ /**
3982
+ * @param {?} component
3983
+ * @param {?} nextState
3984
+ * @return {?}
3985
+ */
3986
+ NavigationState.prototype.canDeactivatePlace = /**
3987
+ * @param {?} component
3988
+ * @param {?} nextState
3989
+ * @return {?}
3990
+ */
3991
+ function (component, nextState) {
3992
+ return __awaiter(this, void 0, void 0, function () {
3993
+ return __generator(this, function (_a) {
3994
+ return [2 /*return*/, this.illegalTransition('canDeactivatePlace')];
3995
+ });
3996
+ });
3997
+ };
4170
3998
  /**
4171
3999
  * @return {?}
4172
4000
  */
4173
- NavigationSession.prototype.getVisits = /**
4001
+ NavigationState.prototype.getVisits = /**
4174
4002
  * @return {?}
4175
4003
  */
4176
4004
  function () {
@@ -4182,7 +4010,7 @@
4182
4010
  * @param {?} message
4183
4011
  * @return {?}
4184
4012
  */
4185
- NavigationSession.prototype.illegalTransition = /**
4013
+ NavigationState.prototype.illegalTransition = /**
4186
4014
  * @protected
4187
4015
  * @template R
4188
4016
  * @param {?} message
@@ -4195,124 +4023,91 @@
4195
4023
  * @protected
4196
4024
  * @return {?}
4197
4025
  */
4198
- NavigationSession.prototype.currentRouterUrl = /**
4026
+ NavigationState.prototype.currentRouterUrl = /**
4199
4027
  * @protected
4200
4028
  * @return {?}
4201
4029
  */
4202
4030
  function () {
4203
- return this.context.router.routerState ? this.context.router.routerState.snapshot.url : null;
4031
+ return this.placeRouter.getCurrentRouterUrl();
4204
4032
  };
4205
4033
  /**
4206
4034
  * @protected
4207
4035
  * @param {?} event
4208
4036
  * @return {?}
4209
4037
  */
4210
- NavigationSession.prototype.createActiveSession = /**
4038
+ NavigationState.prototype.createTransitionStateFor = /**
4211
4039
  * @protected
4212
4040
  * @param {?} event
4213
4041
  * @return {?}
4214
4042
  */
4215
4043
  function (event) {
4216
4044
  // TODO: check if the event is purely for interaction context changes.
4217
- return new NavigationSession.Active(this.context, event.navigationTrigger === 'popstate', this.currentRouterUrl());
4045
+ /** @type {?} */
4046
+ var popstate = event.navigationTrigger === 'popstate';
4047
+ return popstate ?
4048
+ new NavigationState.NavigationBackTransition(this.context, popstate, this.currentRouterUrl()) :
4049
+ new NavigationState.NavigationTransition(this.context, popstate, this.currentRouterUrl());
4218
4050
  };
4219
4051
  /**
4220
- * @protected
4221
4052
  * @param {?} url
4222
4053
  * @return {?}
4223
4054
  */
4224
- NavigationSession.prototype.updateLocation = /**
4225
- * @protected
4055
+ NavigationState.prototype.resetBrowserLocation = /**
4226
4056
  * @param {?} url
4227
4057
  * @return {?}
4228
4058
  */
4229
4059
  function (url) {
4230
- this.context.angularLocation.go(url);
4060
+ var _this = this;
4061
+ // TODO: Should this be a navigate operation to avoid confusing the router...??
4062
+ setTimeout((/**
4063
+ * @return {?}
4064
+ */
4065
+ function () { return _this.placeRouter.resetBrowserLocation(url); }));
4231
4066
  };
4232
4067
  /**
4233
4068
  * @return {?}
4234
4069
  */
4235
- NavigationSession.prototype.toString = /**
4070
+ NavigationState.prototype.toString = /**
4236
4071
  * @return {?}
4237
4072
  */
4238
4073
  function () {
4239
4074
  return this.constructor.name;
4240
4075
  };
4241
- __decorate([
4242
- pectin.Trace(),
4243
- __metadata("design:type", Function),
4244
- __metadata("design:paramtypes", [Object]),
4245
- __metadata("design:returntype", void 0)
4246
- ], NavigationSession.prototype, "updateLocation", null);
4247
- return NavigationSession;
4076
+ return NavigationState;
4248
4077
  }(pectin.GarbageCollector));
4249
4078
  if (false) {
4250
4079
  /**
4251
4080
  * @type {?}
4252
4081
  * @private
4253
4082
  */
4254
- exports.NavigationSession.prototype._visits;
4083
+ exports.NavigationState.prototype._visits;
4255
4084
  /** @type {?} */
4256
- exports.NavigationSession.prototype.isPopState;
4085
+ exports.NavigationState.prototype.isTransitional;
4257
4086
  /** @type {?} */
4258
- exports.NavigationSession.prototype.active;
4087
+ exports.NavigationState.prototype.startingUrl;
4259
4088
  /** @type {?} */
4260
- exports.NavigationSession.prototype.startingUrl;
4089
+ exports.NavigationState.prototype.isPopState;
4261
4090
  /**
4262
4091
  * @type {?}
4263
4092
  * @protected
4264
4093
  */
4265
- exports.NavigationSession.prototype.context;
4266
- /**
4267
- * @abstract
4268
- * @param {?} event
4269
- * @return {?}
4270
- */
4271
- exports.NavigationSession.prototype.onStart = function (event) { };
4272
- /**
4273
- * @abstract
4274
- * @param {?} event
4275
- * @return {?}
4276
- */
4277
- exports.NavigationSession.prototype.onCancel = function (event) { };
4278
- /**
4279
- * @abstract
4280
- * @param {?} event
4281
- * @return {?}
4282
- */
4283
- exports.NavigationSession.prototype.onError = function (event) { };
4284
- /**
4285
- * @abstract
4286
- * @param {?} event
4287
- * @return {?}
4288
- */
4289
- exports.NavigationSession.prototype.onEnd = function (event) { };
4290
- /**
4291
- * @abstract
4292
- * @param {?} component
4293
- * @param {?} nextState
4294
- * @return {?}
4295
- */
4296
- exports.NavigationSession.prototype.canDeactivatePlace = function (component, nextState) { };
4094
+ exports.NavigationState.prototype.context;
4297
4095
  }
4298
- (function (NavigationSession) {
4096
+ (function (NavigationState) {
4299
4097
  var Context = /** @class */ (function () {
4300
- function Context(router, modalInteractionService, angularLocation, notifySuccess) {
4301
- this.router = router;
4302
- this.modalInteractionService = modalInteractionService;
4303
- this.angularLocation = angularLocation;
4098
+ function Context(placeRouter, interactionService, notifySuccess) {
4099
+ this.placeRouter = placeRouter;
4100
+ this.interactionService = interactionService;
4304
4101
  this.notifySuccess = notifySuccess;
4305
4102
  }
4306
4103
  return Context;
4307
4104
  }());
4308
- NavigationSession.Context = Context;
4105
+ NavigationState.Context = Context;
4309
4106
  if (false) {
4310
4107
  /** @type {?} */
4311
- Context.prototype.router;
4312
- /** @type {?} */
4313
- Context.prototype.modalInteractionService;
4108
+ Context.prototype.placeRouter;
4314
4109
  /** @type {?} */
4315
- Context.prototype.angularLocation;
4110
+ Context.prototype.interactionService;
4316
4111
  /** @type {?} */
4317
4112
  Context.prototype.notifySuccess;
4318
4113
  }
@@ -4320,27 +4115,11 @@
4320
4115
  __extends(Idle, _super);
4321
4116
  function Idle(context) {
4322
4117
  var _this = _super.call(this, context) || this;
4323
- _this.active = false;
4118
+ _this.isTransitional = false;
4324
4119
  _this.startingUrl = null;
4120
+ _this.isPopState = false;
4325
4121
  return _this;
4326
4122
  }
4327
- /**
4328
- * @param {?} component
4329
- * @param {?} nextState
4330
- * @return {?}
4331
- */
4332
- Idle.prototype.canDeactivatePlace = /**
4333
- * @param {?} component
4334
- * @param {?} nextState
4335
- * @return {?}
4336
- */
4337
- function (component, nextState) {
4338
- return __awaiter(this, void 0, void 0, function () {
4339
- return __generator(this, function (_a) {
4340
- return [2 /*return*/, this.illegalTransition('canDeactivatePlace')];
4341
- });
4342
- });
4343
- };
4344
4123
  /**
4345
4124
  * @param {?} event
4346
4125
  * @return {?}
@@ -4355,65 +4134,51 @@
4355
4134
  pectin.Logger.get(this).info("navigation started to same url -> " + event.url);
4356
4135
  return this;
4357
4136
  }
4358
- if (event.url === (this.currentRouterUrl() + "(aup-interaction:modal)")) {
4137
+ if (this.placeRouter.hasActiveInteractionIds(event.url)) {
4359
4138
  pectin.Logger.get(this).info("navigation started with interaction outlet -> " + event.url);
4360
- return new ModalInteractionSession(this.context, event.url);
4139
+ return new InteractionTransition(this.context, event.url);
4140
+ }
4141
+ else {
4142
+ return this.createTransitionStateFor(event);
4361
4143
  }
4362
- return this.createActiveSession(event);
4363
- };
4364
- /**
4365
- * @param {?} event
4366
- * @return {?}
4367
- */
4368
- Idle.prototype.onCancel = /**
4369
- * @param {?} event
4370
- * @return {?}
4371
- */
4372
- function (event) {
4373
- return this.illegalTransition(event);
4374
- };
4375
- /**
4376
- * @param {?} event
4377
- * @return {?}
4378
- */
4379
- Idle.prototype.onEnd = /**
4380
- * @param {?} event
4381
- * @return {?}
4382
- */
4383
- function (event) {
4384
- return this.illegalTransition(event);
4385
4144
  };
4386
4145
  /**
4387
4146
  * @param {?} event
4388
4147
  * @return {?}
4389
4148
  */
4390
- Idle.prototype.onError = /**
4149
+ Idle.prototype.onPopState = /**
4391
4150
  * @param {?} event
4392
4151
  * @return {?}
4393
4152
  */
4394
4153
  function (event) {
4395
- return this.illegalTransition(event);
4154
+ return this.createTransitionStateFor(event);
4396
4155
  };
4397
4156
  return Idle;
4398
- }(NavigationSession));
4399
- NavigationSession.Idle = Idle;
4157
+ }(NavigationState));
4158
+ NavigationState.Idle = Idle;
4400
4159
  if (false) {
4401
4160
  /** @type {?} */
4402
- Idle.prototype.isPopState;
4403
- /** @type {?} */
4404
- Idle.prototype.active;
4161
+ Idle.prototype.isTransitional;
4405
4162
  /** @type {?} */
4406
4163
  Idle.prototype.startingUrl;
4164
+ /** @type {?} */
4165
+ Idle.prototype.isPopState;
4407
4166
  }
4408
- var Active = /** @class */ (function (_super) {
4409
- __extends(Active, _super);
4410
- function Active(context, isPopState, startingUrl) {
4167
+ /**
4168
+ * @abstract
4169
+ */
4170
+ var /**
4171
+ * @abstract
4172
+ */
4173
+ AbstractNavigationTransition = /** @class */ (function (_super) {
4174
+ __extends(AbstractNavigationTransition, _super);
4175
+ function AbstractNavigationTransition(context, isPopState, startingUrl) {
4411
4176
  var _this = _super.call(this, context) || this;
4412
4177
  _this.isPopState = isPopState;
4413
4178
  _this.startingUrl = startingUrl;
4414
- _this.active = true;
4179
+ _this.isTransitional = true;
4415
4180
  _this.componentDeactivationHandlers = new Map();
4416
- _this._interactionContext = _this.context.modalInteractionService.createExclusiveInteractionContext();
4181
+ _this._interactionContext = _this.interactionService._createExclusiveModalInteractionContext();
4417
4182
  _this.onDispose((/**
4418
4183
  * @return {?}
4419
4184
  */
@@ -4421,14 +4186,14 @@
4421
4186
  // the interaction context can be detached during the back button cancellation state transition
4422
4187
  // as the transition is synchronous and activityCancellation isn't. Otherwise dispose will be
4423
4188
  // called before the context has been cancelled. It might be work having the interaction context
4424
- // automatically cancel if the context is disposed.
4189
+ // automatically cancel if the context is disposed so we don't have worry about detaching etc.
4425
4190
  if (_this._interactionContext) {
4426
- _this._interactionContext.dispose();
4191
+ _this._interactionContext.dispose(); // or do something like cancelAndDispose?
4427
4192
  }
4428
4193
  }));
4429
4194
  return _this;
4430
4195
  }
4431
- Object.defineProperty(Active.prototype, "interactionContext", {
4196
+ Object.defineProperty(AbstractNavigationTransition.prototype, "interactionContext", {
4432
4197
  get: /**
4433
4198
  * @return {?}
4434
4199
  */
@@ -4442,19 +4207,20 @@
4442
4207
  * @param {?} event
4443
4208
  * @return {?}
4444
4209
  */
4445
- Active.prototype.onStart = /**
4210
+ AbstractNavigationTransition.prototype.onStart = /**
4446
4211
  * @param {?} event
4447
4212
  * @return {?}
4448
4213
  */
4449
4214
  function (event) {
4450
- // active sessions can have many cancel start cycles.
4215
+ // active sessions can have many cancel start cycles due
4216
+ // to place guard redirects
4451
4217
  return this;
4452
4218
  };
4453
4219
  /**
4454
4220
  * @param {?} event
4455
4221
  * @return {?}
4456
4222
  */
4457
- Active.prototype.onEnd = /**
4223
+ AbstractNavigationTransition.prototype.onEnd = /**
4458
4224
  * @param {?} event
4459
4225
  * @return {?}
4460
4226
  */
@@ -4463,65 +4229,31 @@
4463
4229
  this.context.notifySuccess(this);
4464
4230
  return new Idle(this.context);
4465
4231
  };
4466
- /**
4467
- * @param {?} event
4468
- * @return {?}
4469
- */
4470
- Active.prototype.onCancel = /**
4471
- * @param {?} event
4472
- * @return {?}
4473
- */
4474
- function (event) {
4475
- // active sessions can have many cancel start cycles.
4476
- return this;
4477
- };
4478
- /**
4479
- * @param {?} event
4480
- * @return {?}
4481
- */
4482
- Active.prototype.onError = /**
4483
- * @param {?} event
4484
- * @return {?}
4485
- */
4486
- function (event) {
4487
- // navigation was aborted.
4488
- if (this.isPopState && this.currentRouterUrl() !== this.startingUrl) {
4489
- // Angular doesn't preserve the url when a guard cancels the back button.
4490
- // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4491
- pectin.Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4492
- this.updateLocation(this.startingUrl);
4493
- }
4494
- return new Idle(this.context);
4495
- };
4496
4232
  /**
4497
4233
  * @param {?} locationTriggerUrl
4498
4234
  * @return {?}
4499
4235
  */
4500
- Active.prototype.onBackClickedDuringNavigationInteraction = /**
4236
+ AbstractNavigationTransition.prototype.onBackClickedDuringNavigationInteraction = /**
4501
4237
  * @param {?} locationTriggerUrl
4502
4238
  * @return {?}
4503
4239
  */
4504
4240
  function (locationTriggerUrl) {
4241
+ // detach the interactoin from the session so it doesn't get disposed until the activity
4242
+ // has completed.
4505
4243
  /** @type {?} */
4506
4244
  var context = this.detachInteractionContext();
4245
+ var when = pectin.Dsl.disposeWith(context).when;
4246
+ // TODO: I need to make the exclusive interaction context disallow nested activities or
4247
+ // that would mess things up entirely.
4507
4248
  context.getCurrentActivity().then((/**
4508
4249
  * @param {?} activity
4509
4250
  * @return {?}
4510
4251
  */
4511
4252
  function (activity) {
4512
- context.addActivityListener({
4513
- onActivityFinished: /**
4514
- * @return {?}
4515
- */
4516
- function () {
4517
- context.dispose();
4518
- },
4519
- onActivityStarted: /**
4520
- * @return {?}
4521
- */
4522
- function () {
4523
- }
4524
- });
4253
+ when.valueOf(context.active).becomesFalsey((/**
4254
+ * @return {?}
4255
+ */
4256
+ function () { return context.dispose(); }), { once: true });
4525
4257
  activity.cancel(null);
4526
4258
  }));
4527
4259
  return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, locationTriggerUrl);
@@ -4531,7 +4263,7 @@
4531
4263
  * @param {?} nextState
4532
4264
  * @return {?}
4533
4265
  */
4534
- Active.prototype.canDeactivatePlace = /**
4266
+ AbstractNavigationTransition.prototype.canDeactivatePlace = /**
4535
4267
  * @param {?} component
4536
4268
  * @param {?} nextState
4537
4269
  * @return {?}
@@ -4555,7 +4287,7 @@
4555
4287
  * @private
4556
4288
  * @return {?}
4557
4289
  */
4558
- Active.prototype.detachInteractionContext = /**
4290
+ AbstractNavigationTransition.prototype.detachInteractionContext = /**
4559
4291
  * @private
4560
4292
  * @return {?}
4561
4293
  */
@@ -4565,162 +4297,304 @@
4565
4297
  this._interactionContext = null;
4566
4298
  return context;
4567
4299
  };
4300
+ return AbstractNavigationTransition;
4301
+ }(NavigationState));
4302
+ NavigationState.AbstractNavigationTransition = AbstractNavigationTransition;
4303
+ if (false) {
4304
+ /** @type {?} */
4305
+ AbstractNavigationTransition.prototype.isTransitional;
4306
+ /**
4307
+ * @type {?}
4308
+ * @private
4309
+ */
4310
+ AbstractNavigationTransition.prototype.componentDeactivationHandlers;
4311
+ /**
4312
+ * @type {?}
4313
+ * @private
4314
+ */
4315
+ AbstractNavigationTransition.prototype._interactionContext;
4316
+ /** @type {?} */
4317
+ AbstractNavigationTransition.prototype.isPopState;
4318
+ /** @type {?} */
4319
+ AbstractNavigationTransition.prototype.startingUrl;
4320
+ }
4321
+ var NavigationTransition = /** @class */ (function (_super) {
4322
+ __extends(NavigationTransition, _super);
4323
+ function NavigationTransition() {
4324
+ var _this = _super !== null && _super.apply(this, arguments) || this;
4325
+ _this.isPopState = false;
4326
+ return _this;
4327
+ }
4328
+ /**
4329
+ * @param {?} event
4330
+ * @return {?}
4331
+ */
4332
+ NavigationTransition.prototype.onStart = /**
4333
+ * @param {?} event
4334
+ * @return {?}
4335
+ */
4336
+ function (event) {
4337
+ // active sessions can have many cancel start cycles due
4338
+ // to place guard redirects
4339
+ return this;
4340
+ };
4341
+ /**
4342
+ * @param {?} event
4343
+ * @return {?}
4344
+ */
4345
+ NavigationTransition.prototype.onEnd = /**
4346
+ * @param {?} event
4347
+ * @return {?}
4348
+ */
4349
+ function (event) {
4350
+ // navigation succeeded
4351
+ this.context.notifySuccess(this);
4352
+ return new Idle(this.context);
4353
+ };
4354
+ /**
4355
+ * @param {?} event
4356
+ * @return {?}
4357
+ */
4358
+ NavigationTransition.prototype.onCancel = /**
4359
+ * @param {?} event
4360
+ * @return {?}
4361
+ */
4362
+ function (event) {
4363
+ return new Idle(this.context);
4364
+ };
4365
+ /**
4366
+ * @param {?} event
4367
+ * @return {?}
4368
+ */
4369
+ NavigationTransition.prototype.onError = /**
4370
+ * @param {?} event
4371
+ * @return {?}
4372
+ */
4373
+ function (event) {
4374
+ // navigation was aborted.
4375
+ return new Idle(this.context);
4376
+ };
4568
4377
  /**
4569
4378
  * @return {?}
4570
4379
  */
4571
- Active.prototype.toString = /**
4380
+ NavigationTransition.prototype.toString = /**
4572
4381
  * @return {?}
4573
4382
  */
4574
4383
  function () {
4575
- return this.constructor.name + "(startingUrl: " + this.startingUrl + ", isPopState:" + this.isPopState + ")";
4384
+ return this.constructor.name + "(startingUrl: " + this.startingUrl + ")";
4576
4385
  };
4577
- return Active;
4578
- }(NavigationSession));
4579
- NavigationSession.Active = Active;
4386
+ return NavigationTransition;
4387
+ }(AbstractNavigationTransition));
4388
+ NavigationState.NavigationTransition = NavigationTransition;
4580
4389
  if (false) {
4581
4390
  /** @type {?} */
4582
- Active.prototype.active;
4391
+ NavigationTransition.prototype.isPopState;
4392
+ }
4393
+ var NavigationBackTransition = /** @class */ (function (_super) {
4394
+ __extends(NavigationBackTransition, _super);
4395
+ function NavigationBackTransition() {
4396
+ var _this = _super !== null && _super.apply(this, arguments) || this;
4397
+ _this.isPopState = true;
4398
+ return _this;
4399
+ }
4583
4400
  /**
4584
- * @type {?}
4585
- * @private
4401
+ * @param {?} event
4402
+ * @return {?}
4403
+ */
4404
+ NavigationBackTransition.prototype.onCancel = /**
4405
+ * @param {?} event
4406
+ * @return {?}
4586
4407
  */
4587
- Active.prototype.componentDeactivationHandlers;
4408
+ function (event) {
4409
+ // Angular doesn't preserve the url when a guard cancels the back button.
4410
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4411
+ pectin.Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4412
+ this.resetBrowserLocation(this.startingUrl);
4413
+ return new Idle(this.context);
4414
+ };
4588
4415
  /**
4589
- * @type {?}
4590
- * @private
4416
+ * @param {?} event
4417
+ * @return {?}
4418
+ */
4419
+ NavigationBackTransition.prototype.onError = /**
4420
+ * @param {?} event
4421
+ * @return {?}
4591
4422
  */
4592
- Active.prototype._interactionContext;
4423
+ function (event) {
4424
+ // navigation was aborted.
4425
+ if (this.currentRouterUrl() !== this.startingUrl) {
4426
+ // Angular doesn't preserve the url when a guard cancels the back button.
4427
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4428
+ pectin.Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4429
+ this.resetBrowserLocation(this.startingUrl);
4430
+ }
4431
+ return new Idle(this.context);
4432
+ };
4433
+ return NavigationBackTransition;
4434
+ }(AbstractNavigationTransition));
4435
+ NavigationState.NavigationBackTransition = NavigationBackTransition;
4436
+ if (false) {
4437
+ /** @type {?} */
4438
+ NavigationBackTransition.prototype.isPopState;
4439
+ }
4440
+ /**
4441
+ * @abstract
4442
+ */
4443
+ var /**
4444
+ * @abstract
4445
+ */
4446
+ AbstractInteractionTransition = /** @class */ (function (_super) {
4447
+ __extends(AbstractInteractionTransition, _super);
4448
+ function AbstractInteractionTransition(context, startingUrl) {
4449
+ var _this = _super.call(this, context) || this;
4450
+ _this.startingUrl = startingUrl;
4451
+ _this.isTransitional = true;
4452
+ return _this;
4453
+ }
4454
+ /**
4455
+ * @protected
4456
+ * @return {?}
4457
+ */
4458
+ AbstractInteractionTransition.prototype.reinstateInteractionRoute = /**
4459
+ * @protected
4460
+ * @return {?}
4461
+ */
4462
+ function () {
4463
+ var _this = this;
4464
+ console.log(this.startingUrl);
4465
+ setTimeout((/**
4466
+ * @return {?}
4467
+ */
4468
+ function () { return _this.placeRouter.syncInteractionIdsWithRouter(); }));
4469
+ };
4470
+ return AbstractInteractionTransition;
4471
+ }(NavigationState));
4472
+ NavigationState.AbstractInteractionTransition = AbstractInteractionTransition;
4473
+ if (false) {
4593
4474
  /** @type {?} */
4594
- Active.prototype.isPopState;
4475
+ AbstractInteractionTransition.prototype.isTransitional;
4595
4476
  /** @type {?} */
4596
- Active.prototype.startingUrl;
4477
+ AbstractInteractionTransition.prototype.startingUrl;
4597
4478
  }
4598
- var ModalInteractionSession = /** @class */ (function (_super) {
4599
- __extends(ModalInteractionSession, _super);
4600
- function ModalInteractionSession(context, startingUrl) {
4601
- var _this = _super.call(this, context) || this;
4602
- _this.startingUrl = startingUrl;
4603
- _this.active = false;
4479
+ /**
4480
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4481
+ * happily ignore interaction contexts.
4482
+ */
4483
+ var /**
4484
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4485
+ * happily ignore interaction contexts.
4486
+ */
4487
+ InteractionTransition = /** @class */ (function (_super) {
4488
+ __extends(InteractionTransition, _super);
4489
+ function InteractionTransition() {
4490
+ var _this = _super !== null && _super.apply(this, arguments) || this;
4604
4491
  _this.isPopState = false;
4605
4492
  return _this;
4606
4493
  }
4607
- /**
4608
- * @param {?} url
4609
- * @return {?}
4610
- */
4611
- ModalInteractionSession.hasInteraction = /**
4612
- * @param {?} url
4613
- * @return {?}
4614
- */
4615
- function (url) {
4616
- return url.endsWith('(aup-interaction:modal)');
4617
- };
4618
4494
  /**
4619
4495
  * @param {?} event
4620
4496
  * @return {?}
4621
4497
  */
4622
- ModalInteractionSession.prototype.onStart = /**
4498
+ InteractionTransition.prototype.onEnd = /**
4623
4499
  * @param {?} event
4624
4500
  * @return {?}
4625
4501
  */
4626
4502
  function (event) {
4627
- // VERY VERY IMPORTANT BACK BUTTON NOTE:
4628
- // When the back button is clicked we'll enter here first, and push the url
4629
- // back to the browser. Angular seems to ignore it from a routing perspective
4630
- // and then the InteractionGuard will cancel the navigation. This process seems
4631
- // to keep the brower history in a sane state.
4632
- if (this.context.modalInteractionService.isActive()) {
4633
- if (!ModalInteractionSession.hasInteraction(event.url)) {
4634
- // this capture the case where
4635
- this.updateLocation(this.startingUrl);
4636
- }
4503
+ if (this.context.interactionService.isActive()) {
4504
+ this.reinstateInteractionRoute();
4505
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4506
+ }
4507
+ else {
4508
+ return new Idle(this.context);
4637
4509
  }
4638
- return this;
4639
- };
4640
- /**
4641
- * @param {?} event
4642
- * @return {?}
4643
- */
4644
- ModalInteractionSession.prototype.onCancel = /**
4645
- * @param {?} event
4646
- * @return {?}
4647
- */
4648
- function (event) {
4649
- // this.updateLocation(this.startingUrl);
4650
- return this;
4651
4510
  };
4511
+ return InteractionTransition;
4512
+ }(AbstractInteractionTransition));
4513
+ NavigationState.InteractionTransition = InteractionTransition;
4514
+ if (false) {
4515
+ /** @type {?} */
4516
+ InteractionTransition.prototype.isPopState;
4517
+ }
4518
+ /**
4519
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4520
+ * happily ignore interaction contexts.
4521
+ */
4522
+ var /**
4523
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4524
+ * happily ignore interaction contexts.
4525
+ */
4526
+ InteractionBackTransition = /** @class */ (function (_super) {
4527
+ __extends(InteractionBackTransition, _super);
4528
+ function InteractionBackTransition() {
4529
+ var _this = _super !== null && _super.apply(this, arguments) || this;
4530
+ _this.isPopState = true;
4531
+ return _this;
4532
+ }
4652
4533
  /**
4653
4534
  * @param {?} event
4654
4535
  * @return {?}
4655
4536
  */
4656
- ModalInteractionSession.prototype.onEnd = /**
4537
+ InteractionBackTransition.prototype.onEnd = /**
4657
4538
  * @param {?} event
4658
4539
  * @return {?}
4659
4540
  */
4660
4541
  function (event) {
4661
- if (this.context.modalInteractionService.isActive()) {
4662
- return this;
4542
+ if (this.interactionService.isActive()) {
4543
+ this.reinstateInteractionRoute();
4544
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4663
4545
  }
4664
4546
  else {
4665
4547
  return new Idle(this.context);
4666
4548
  }
4667
4549
  };
4550
+ return InteractionBackTransition;
4551
+ }(AbstractInteractionTransition));
4552
+ NavigationState.InteractionBackTransition = InteractionBackTransition;
4553
+ if (false) {
4554
+ /** @type {?} */
4555
+ InteractionBackTransition.prototype.isPopState;
4556
+ }
4557
+ var IdleDuringInteraction = /** @class */ (function (_super) {
4558
+ __extends(IdleDuringInteraction, _super);
4559
+ function IdleDuringInteraction(context, startingUrl) {
4560
+ var _this = _super.call(this, context) || this;
4561
+ _this.startingUrl = startingUrl;
4562
+ _this.isTransitional = false;
4563
+ _this.isPopState = false;
4564
+ return _this;
4565
+ }
4668
4566
  /**
4669
4567
  * @param {?} event
4670
4568
  * @return {?}
4671
4569
  */
4672
- ModalInteractionSession.prototype.onError = /**
4570
+ IdleDuringInteraction.prototype.onStart = /**
4673
4571
  * @param {?} event
4674
4572
  * @return {?}
4675
4573
  */
4676
4574
  function (event) {
4677
- return this.illegalTransition(event);
4575
+ return new InteractionTransition(this.context, event.url);
4678
4576
  };
4679
4577
  /**
4680
- * @param {?} component
4681
- * @param {?} nextState
4578
+ * @param {?} event
4682
4579
  * @return {?}
4683
4580
  */
4684
- ModalInteractionSession.prototype.canDeactivatePlace = /**
4685
- * @param {?} component
4686
- * @param {?} nextState
4581
+ IdleDuringInteraction.prototype.onPopState = /**
4582
+ * @param {?} event
4687
4583
  * @return {?}
4688
4584
  */
4689
- function (component, nextState) {
4690
- return __awaiter(this, void 0, void 0, function () {
4691
- return __generator(this, function (_a) {
4692
- return [2 /*return*/, true];
4693
- });
4694
- });
4585
+ function (event) {
4586
+ return new InteractionBackTransition(this.context, event.url);
4695
4587
  };
4696
- __decorate([
4697
- pectin.Trace(),
4698
- __metadata("design:type", Function),
4699
- __metadata("design:paramtypes", [router.NavigationStart]),
4700
- __metadata("design:returntype", NavigationSession)
4701
- ], ModalInteractionSession.prototype, "onStart", null);
4702
- __decorate([
4703
- pectin.Trace(),
4704
- __metadata("design:type", Function),
4705
- __metadata("design:paramtypes", [router.NavigationCancel]),
4706
- __metadata("design:returntype", NavigationSession)
4707
- ], ModalInteractionSession.prototype, "onCancel", null);
4708
- __decorate([
4709
- pectin.Trace(),
4710
- __metadata("design:type", Function),
4711
- __metadata("design:paramtypes", [router.NavigationEnd]),
4712
- __metadata("design:returntype", NavigationSession)
4713
- ], ModalInteractionSession.prototype, "onEnd", null);
4714
- return ModalInteractionSession;
4715
- }(NavigationSession));
4716
- NavigationSession.ModalInteractionSession = ModalInteractionSession;
4588
+ return IdleDuringInteraction;
4589
+ }(NavigationState));
4590
+ NavigationState.IdleDuringInteraction = IdleDuringInteraction;
4717
4591
  if (false) {
4718
4592
  /** @type {?} */
4719
- ModalInteractionSession.prototype.active;
4593
+ IdleDuringInteraction.prototype.isTransitional;
4720
4594
  /** @type {?} */
4721
- ModalInteractionSession.prototype.isPopState;
4595
+ IdleDuringInteraction.prototype.isPopState;
4722
4596
  /** @type {?} */
4723
- ModalInteractionSession.prototype.startingUrl;
4597
+ IdleDuringInteraction.prototype.startingUrl;
4724
4598
  }
4725
4599
  var CancelledDuringNavigationInteraction = /** @class */ (function (_super) {
4726
4600
  __extends(CancelledDuringNavigationInteraction, _super);
@@ -4728,28 +4602,36 @@
4728
4602
  var _this = _super.call(this, context) || this;
4729
4603
  _this.startingUrl = startingUrl;
4730
4604
  _this.locationChangeTriggerUrl = locationChangeTriggerUrl;
4731
- _this.active = false;
4605
+ _this.isPopState = false;
4732
4606
  _this.capturedFauxRouterStart = false;
4733
4607
  return _this;
4734
- // This will trigger a return to the route we originally started with.
4735
- // this.angularLocation.go(this.startingUrl);
4736
4608
  }
4609
+ Object.defineProperty(CancelledDuringNavigationInteraction.prototype, "isTransitional", {
4610
+ get: /**
4611
+ * @return {?}
4612
+ */
4613
+ function () {
4614
+ return !this.capturedFauxRouterStart;
4615
+ },
4616
+ enumerable: true,
4617
+ configurable: true
4618
+ });
4737
4619
  /**
4738
- * @param {?} component
4739
- * @param {?} nextState
4620
+ * @param {?} event
4740
4621
  * @return {?}
4741
4622
  */
4742
- CancelledDuringNavigationInteraction.prototype.canDeactivatePlace = /**
4743
- * @param {?} component
4744
- * @param {?} nextState
4623
+ CancelledDuringNavigationInteraction.prototype.onStart = /**
4624
+ * @param {?} event
4745
4625
  * @return {?}
4746
4626
  */
4747
- function (component, nextState) {
4748
- return __awaiter(this, void 0, void 0, function () {
4749
- return __generator(this, function (_a) {
4750
- return [2 /*return*/, false];
4751
- });
4752
- });
4627
+ function (event) {
4628
+ if (event.url === this.locationChangeTriggerUrl && !this.capturedFauxRouterStart) {
4629
+ this.capturedFauxRouterStart = true;
4630
+ return this.ignore(event, 'url matched back button location change');
4631
+ }
4632
+ else {
4633
+ return this.createTransitionStateFor(event);
4634
+ }
4753
4635
  };
4754
4636
  /**
4755
4637
  * @param {?} event
@@ -4788,18 +4670,12 @@
4788
4670
  * @param {?} event
4789
4671
  * @return {?}
4790
4672
  */
4791
- CancelledDuringNavigationInteraction.prototype.onStart = /**
4673
+ CancelledDuringNavigationInteraction.prototype.onPopState = /**
4792
4674
  * @param {?} event
4793
4675
  * @return {?}
4794
4676
  */
4795
4677
  function (event) {
4796
- if (event.url === this.locationChangeTriggerUrl && !this.capturedFauxRouterStart) {
4797
- this.capturedFauxRouterStart = true;
4798
- return this.ignore(event, 'url matched back button location change');
4799
- }
4800
- else {
4801
- return this.createActiveSession(event);
4802
- }
4678
+ return this.createTransitionStateFor(event);
4803
4679
  };
4804
4680
  /**
4805
4681
  * @param {?} event
@@ -4826,11 +4702,9 @@
4826
4702
  return this.constructor.name + "(startingUrl: " + this.startingUrl + ", locationChangeTriggerUrl:" + this.locationChangeTriggerUrl + ")";
4827
4703
  };
4828
4704
  return CancelledDuringNavigationInteraction;
4829
- }(NavigationSession));
4830
- NavigationSession.CancelledDuringNavigationInteraction = CancelledDuringNavigationInteraction;
4705
+ }(NavigationState));
4706
+ NavigationState.CancelledDuringNavigationInteraction = CancelledDuringNavigationInteraction;
4831
4707
  if (false) {
4832
- /** @type {?} */
4833
- CancelledDuringNavigationInteraction.prototype.active;
4834
4708
  /** @type {?} */
4835
4709
  CancelledDuringNavigationInteraction.prototype.isPopState;
4836
4710
  /**
@@ -4843,7 +4717,7 @@
4843
4717
  /** @type {?} */
4844
4718
  CancelledDuringNavigationInteraction.prototype.locationChangeTriggerUrl;
4845
4719
  }
4846
- })(exports.NavigationSession || (exports.NavigationSession = {}));
4720
+ })(exports.NavigationState || (exports.NavigationState = {}));
4847
4721
 
4848
4722
  /**
4849
4723
  * @fileoverview added by tsickle
@@ -4929,34 +4803,29 @@
4929
4803
  * @fileoverview added by tsickle
4930
4804
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4931
4805
  */
4932
- var UrlSnapshot = /** @class */ (function () {
4933
- function UrlSnapshot(urlTree) {
4934
- this.urlTree = urlTree;
4935
- // console.log({ segments: this.urlTree.root.children.primary.segments });
4806
+ exports.UrlSnapshot = /** @class */ (function () {
4807
+ // TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.
4808
+ function UrlSnapshot(urlSerializer, url) {
4809
+ this.urlSerializer = urlSerializer;
4810
+ this.url = url;
4811
+ this.urlTree = urlSerializer.parse(url);
4936
4812
  }
4937
4813
  /**
4938
- * @return {?}
4939
- */
4940
- UrlSnapshot.prototype.cloneUrlSegmentList = /**
4941
- * @return {?}
4942
- */
4943
- function () {
4944
- return __spread(this.urlTree.root.children.primary.segments);
4945
- };
4946
- /**
4814
+ * @protected
4947
4815
  * @param {?} visit
4948
4816
  * @return {?}
4949
4817
  */
4950
- UrlSnapshot.prototype.updateVisitSegments = /**
4818
+ UrlSnapshot.prototype.replaceExistingVisitSegmentsWith = /**
4819
+ * @protected
4951
4820
  * @param {?} visit
4952
4821
  * @return {?}
4953
4822
  */
4954
4823
  function (visit) {
4955
4824
  // Ugly, but it works for now.
4956
4825
  /** @type {?} */
4957
- var segments = this.cloneUrlSegmentList();
4826
+ var segments = __spread(this.getPrimarySegments());
4958
4827
  /** @type {?} */
4959
- var visitSegments = this.convertToUrlSegments(visit);
4828
+ var visitSegments = this.getSegmentsFor(visit);
4960
4829
  /** @type {?} */
4961
4830
  var replaceAt = segments.findIndex((/**
4962
4831
  * @param {?} segment
@@ -4967,17 +4836,30 @@
4967
4836
  segments.splice.apply(segments, __spread([replaceAt, visitSegments.length], visitSegments));
4968
4837
  return segments;
4969
4838
  };
4839
+ /**
4840
+ * @private
4841
+ * @return {?}
4842
+ */
4843
+ UrlSnapshot.prototype.getPrimarySegments = /**
4844
+ * @private
4845
+ * @return {?}
4846
+ */
4847
+ function () {
4848
+ return this.urlTree.root.children.primary.segments;
4849
+ };
4970
4850
  /**
4971
4851
  * Converts the visit into segments. Please not that these segments are not e
4972
4852
  * @param visit
4973
4853
  */
4974
4854
  /**
4975
4855
  * Converts the visit into segments. Please not that these segments are not e
4856
+ * @protected
4976
4857
  * @param {?} visit
4977
4858
  * @return {?}
4978
4859
  */
4979
- UrlSnapshot.prototype.convertToUrlSegments = /**
4860
+ UrlSnapshot.prototype.getSegmentsFor = /**
4980
4861
  * Converts the visit into segments. Please not that these segments are not e
4862
+ * @protected
4981
4863
  * @param {?} visit
4982
4864
  * @return {?}
4983
4865
  */
@@ -5005,7 +4887,7 @@
5005
4887
  */
5006
4888
  function (visit) {
5007
4889
  /** @type {?} */
5008
- var segments = this.updateVisitSegments(visit);
4890
+ var segments = this.replaceExistingVisitSegmentsWith(visit);
5009
4891
  /** @type {?} */
5010
4892
  var commands = [];
5011
4893
  segments.forEach((/**
@@ -5029,46 +4911,125 @@
5029
4911
  * @return {?}
5030
4912
  */
5031
4913
  function (placeDef) {
5032
- return this.cloneUrlSegmentList().find((/**
4914
+ return this.getPrimarySegments().find((/**
5033
4915
  * @param {?} s
5034
4916
  * @return {?}
5035
4917
  */
5036
4918
  function (s) { return s.path === placeDef.path; }));
5037
4919
  };
4920
+ /**
4921
+ * @return {?}
4922
+ */
4923
+ UrlSnapshot.prototype.getInteractionIds = /**
4924
+ * @return {?}
4925
+ */
4926
+ function () {
4927
+ /** @type {?} */
4928
+ var interactionOutlet = this.urlTree.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET];
4929
+ if (interactionOutlet) {
4930
+ pectin.assert.isTruthy(interactionOutlet.segments.length === 2);
4931
+ pectin.assert.isTruthy(interactionOutlet.segments[0].path === UrlSnapshot.INTERACTION_ROUTER_PATH);
4932
+ return UrlSnapshot.parseInteractionIds(interactionOutlet.segments[1].path);
4933
+ }
4934
+ else {
4935
+ return [];
4936
+ }
4937
+ };
4938
+ // @Trace()
4939
+ // @Trace()
4940
+ /**
4941
+ * @param {?} ids
4942
+ * @return {?}
4943
+ */
4944
+ UrlSnapshot.prototype.addOrReplaceInteractionIds =
4945
+ // @Trace()
4946
+ /**
4947
+ * @param {?} ids
4948
+ * @return {?}
4949
+ */
4950
+ function (ids) {
4951
+ /** @type {?} */
4952
+ var urlTree = this.urlSerializer.parse(this.url);
4953
+ urlTree.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET] = new router.UrlSegmentGroup([
4954
+ new router.UrlSegment(UrlSnapshot.INTERACTION_ROUTER_PATH, {}),
4955
+ new router.UrlSegment(UrlSnapshot.createPathIdFor(ids), {})
4956
+ ], {});
4957
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString());
4958
+ };
5038
4959
  return UrlSnapshot;
5039
4960
  }());
5040
4961
  if (false) {
4962
+ /**
4963
+ * @type {?}
4964
+ * @private
4965
+ */
4966
+ exports.UrlSnapshot.prototype.urlTree;
5041
4967
  /** @type {?} */
5042
- UrlSnapshot.prototype.urlTree;
4968
+ exports.UrlSnapshot.prototype.urlSerializer;
4969
+ /** @type {?} */
4970
+ exports.UrlSnapshot.prototype.url;
5043
4971
  }
4972
+ (function (UrlSnapshot) {
4973
+ UrlSnapshot.INTERACTION_ROUTER_OUTLET = 'aup-interactions';
4974
+ UrlSnapshot.INTERACTION_ROUTER_PATH = 'active';
4975
+ UrlSnapshot.INTERACTION_ID_SEPARATOR = '--';
4976
+ /**
4977
+ * @param {?} path
4978
+ * @return {?}
4979
+ */
4980
+ function parseInteractionIds(path) {
4981
+ return path.split(UrlSnapshot.INTERACTION_ID_SEPARATOR);
4982
+ }
4983
+ UrlSnapshot.parseInteractionIds = parseInteractionIds;
4984
+ /**
4985
+ * @param {?} interactionIds
4986
+ * @return {?}
4987
+ */
4988
+ function createPathIdFor(interactionIds) {
4989
+ return interactionIds.join(UrlSnapshot.INTERACTION_ID_SEPARATOR);
4990
+ }
4991
+ UrlSnapshot.createPathIdFor = createPathIdFor;
4992
+ /**
4993
+ * @param {?} interactionIds
4994
+ * @return {?}
4995
+ */
4996
+ function createInteractionOutletRouterCommands(interactionIds) {
4997
+ return [UrlSnapshot.INTERACTION_ROUTER_PATH, createPathIdFor(interactionIds)];
4998
+ }
4999
+ UrlSnapshot.createInteractionOutletRouterCommands = createInteractionOutletRouterCommands;
5000
+ })(exports.UrlSnapshot || (exports.UrlSnapshot = {}));
5044
5001
 
5045
5002
  /**
5046
5003
  * @fileoverview added by tsickle
5047
5004
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5048
5005
  */
5049
- exports.ɵt = /** @class */ (function (_super) {
5006
+ var PlaceRouter = /** @class */ (function (_super) {
5050
5007
  __extends(PlaceRouter, _super);
5051
- function PlaceRouter(router$1, urlSerializer, angularLocation, placeHistory, modalInteractionService) {
5008
+ function PlaceRouter(router$1, urlSerializer, angularLocation, placeHistory, interactionService) {
5052
5009
  var _this = _super.call(this) || this;
5053
5010
  _this.router = router$1;
5054
5011
  _this.urlSerializer = urlSerializer;
5055
5012
  _this.angularLocation = angularLocation;
5056
5013
  _this.placeHistory = placeHistory;
5057
- _this.modalInteractionService = modalInteractionService;
5058
- _this.firstRoute = true;
5059
- _this._navigationSessionModel = new pectin.MutableValueModel();
5014
+ _this.interactionService = interactionService;
5015
+ _this._navigationStateModel = new pectin.MutableValueModel();
5060
5016
  _this._activeVisits = new pectin.MutableListModel();
5061
5017
  var _a = pectin.Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
5062
5018
  _this.activeVisitIndex = chain(_this._activeVisits).indexBy('placeDefinition');
5063
- _this.navigationSessionActive = chain(_this.navigationSessionModel).pluck('active');
5064
- _this._navigationSessionContext = new exports.NavigationSession.Context(_this.router, _this.modalInteractionService, _this.angularLocation, (/**
5019
+ _this.navigationInProgress = chain(_this.navigationStateModel).pluck('isTransitional');
5020
+ _this._navigationSessionContext = new exports.NavigationState.Context(_this, _this.interactionService, (/**
5065
5021
  * @param {?} session
5066
5022
  * @return {?}
5067
5023
  */
5068
5024
  function (session) {
5069
5025
  _this.processNavigationSuccess(session);
5070
5026
  }));
5071
- _this._navigationSessionModel.value = new exports.NavigationSession.Idle(_this._navigationSessionContext);
5027
+ _this._navigationStateModel.value = new exports.NavigationState.Idle(_this._navigationSessionContext);
5028
+ _this._navigationStateTypeModel = chain(_this._navigationStateModel).map((/**
5029
+ * @param {?} state
5030
+ * @return {?}
5031
+ */
5032
+ function (state) { return (/** @type {?} */ (state.constructor)); }));
5072
5033
  // TODO: make setup the callbacks in during module initiation to make this testable.
5073
5034
  _this.router.events.subscribe((/**
5074
5035
  * @param {?} event
@@ -5082,53 +5043,85 @@
5082
5043
  // NavigationStart -> .... -> NavigationError --> navigation aborted, end session.
5083
5044
  // =======================
5084
5045
  if (event instanceof router.NavigationStart) {
5085
- _this.runStateTransition((/**
5086
- * @param {?} session
5087
- * @return {?}
5088
- */
5089
- function (session) { return session.onStart(event); }));
5046
+ console.log(event);
5047
+ if (event.navigationTrigger === 'popstate') {
5048
+ _this.runStateTransition((/**
5049
+ * @param {?} state
5050
+ * @return {?}
5051
+ */
5052
+ function (state) { return state.onPopState(event); }));
5053
+ }
5054
+ else {
5055
+ _this.runStateTransition((/**
5056
+ * @param {?} state
5057
+ * @return {?}
5058
+ */
5059
+ function (state) { return state.onStart(event); }));
5060
+ }
5090
5061
  }
5091
5062
  if (event instanceof router.NavigationEnd) {
5063
+ console.log(event);
5092
5064
  _this.runStateTransition((/**
5093
- * @param {?} session
5065
+ * @param {?} state
5094
5066
  * @return {?}
5095
5067
  */
5096
- function (session) { return session.onEnd(event); }));
5068
+ function (state) { return state.onEnd(event); }));
5097
5069
  }
5098
5070
  if (event instanceof router.NavigationError) {
5071
+ console.log(event);
5099
5072
  _this.runStateTransition((/**
5100
- * @param {?} session
5073
+ * @param {?} state
5101
5074
  * @return {?}
5102
5075
  */
5103
- function (session) { return session.onError(event); }));
5076
+ function (state) { return state.onError(event); }));
5104
5077
  }
5105
5078
  if (event instanceof router.NavigationCancel) {
5079
+ console.log(event);
5106
5080
  _this.runStateTransition((/**
5107
- * @param {?} session
5081
+ * @param {?} state
5108
5082
  * @return {?}
5109
5083
  */
5110
- function (session) { return session.onCancel(event); }));
5084
+ function (state) { return state.onCancel(event); }));
5111
5085
  }
5112
5086
  }));
5113
5087
  // Push dialog state to the url so we can capture the back button.
5114
- _this.modalInteractionService.addActivityListener(new PlaceRouter.InteractionRouteMediator(_this.navigationSessionActive, _this.router));
5088
+ when.listOf(_this.interactionService.activeInteractionContextIds).changes((/**
5089
+ * @param {?} ids
5090
+ * @param {?} previous
5091
+ * @return {?}
5092
+ */
5093
+ function (ids, previous) {
5094
+ _this.syncInteractionIdsWithRouter();
5095
+ }), { unless: _this.navigationInProgress }); // TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
5096
+ // TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
5097
+ /** @type {?} */
5098
+ var urlChanges = new pectin.MutableStream();
5115
5099
  // The angular router doesn't always fire router events when the back button is pushed while a navigation
5116
5100
  // session is in progress. Sometimes we only know about it from the url change.
5101
+ // IMPORTANT ORDER DEPENDENCY
5102
+ // This only works because we're notified of the change after the router has started reacting to it. This
5103
+ // we can can use our navigationState to determine things.
5117
5104
  angularLocation.onUrlChange((/**
5118
5105
  * @param {?} url
5119
5106
  * @return {?}
5120
5107
  */
5121
5108
  function (url) {
5122
- console.log("#### url changed -> " + url);
5123
5109
  /** @type {?} */
5124
- var interactionContext = _this.navigationSessionActive.value && _this.navigationSession.interactionContext;
5125
- if (interactionContext && interactionContext.isActive()) {
5126
- pectin.Logger.get(_this).info("back button pressed during navigation session interaction");
5127
- _this.runStateTransition((/**
5128
- * @param {?} navigationSession
5129
- * @return {?}
5130
- */
5131
- function (navigationSession) { return navigationSession.onBackClickedDuringNavigationInteraction(url); }));
5110
+ var navigationState = _this._navigationStateModel.value;
5111
+ console.log("URLChange -> " + url, { state: navigationState });
5112
+ urlChanges.publish({ url: url, state: navigationState });
5113
+ // We've entered a navigation transition
5114
+ if (navigationState instanceof exports.NavigationState.NavigationTransition) {
5115
+ /** @type {?} */
5116
+ var navigationInteraction = _this.navigationState.interactionContext;
5117
+ if (navigationInteraction && navigationInteraction.isActive()) {
5118
+ pectin.Logger.get(_this).info("back button pressed during navigation session interaction promise");
5119
+ _this.runStateTransition((/**
5120
+ * @param {?} state
5121
+ * @return {?}
5122
+ */
5123
+ function (state) { return state.onBackClickedDuringNavigationInteraction(url); }));
5124
+ }
5132
5125
  }
5133
5126
  }));
5134
5127
  return _this;
@@ -5145,6 +5138,9 @@
5145
5138
  */
5146
5139
  function (session) {
5147
5140
  var _this = this;
5141
+ // We need to update the visits before the session finishes. This allows the placeOutets to ignore visit
5142
+ // changes that occur while routerNavigationActive is true.
5143
+ pectin.assert.isTruthy(this.navigationInProgress.value);
5148
5144
  /** @type {?} */
5149
5145
  var visits = session.getVisits();
5150
5146
  visits.forEach((/**
@@ -5152,26 +5148,24 @@
5152
5148
  * @return {?}
5153
5149
  */
5154
5150
  function (v) { return _this.placeHistory.add(v); }));
5155
- // Update visits before we end the navigation session. This allows the placeOutets to
5156
- // ignore visit changes that occur while the navigation is in progress
5157
5151
  this._activeVisits.value = visits;
5158
5152
  };
5159
- Object.defineProperty(PlaceRouter.prototype, "navigationSession", {
5153
+ Object.defineProperty(PlaceRouter.prototype, "navigationState", {
5160
5154
  get: /**
5161
5155
  * @return {?}
5162
5156
  */
5163
5157
  function () {
5164
- return this._navigationSessionModel.value;
5158
+ return this._navigationStateModel.value;
5165
5159
  },
5166
5160
  enumerable: true,
5167
5161
  configurable: true
5168
5162
  });
5169
- Object.defineProperty(PlaceRouter.prototype, "navigationSessionModel", {
5163
+ Object.defineProperty(PlaceRouter.prototype, "navigationStateModel", {
5170
5164
  get: /**
5171
5165
  * @return {?}
5172
5166
  */
5173
5167
  function () {
5174
- return this._navigationSessionModel.readonly;
5168
+ return this._navigationStateModel.readonly;
5175
5169
  },
5176
5170
  enumerable: true,
5177
5171
  configurable: true
@@ -5262,7 +5256,7 @@
5262
5256
  */
5263
5257
  function (router) {
5264
5258
  /** @type {?} */
5265
- var commands = _this.parseUrl(_this.router.routerState.snapshot).createRedirectCommandsFor(next);
5259
+ var commands = _this.parseUrl(_this.router.routerState.snapshot.url).createRedirectCommandsFor(next);
5266
5260
  console.log('### Push Changes to route Redirect', { commands: commands });
5267
5261
  return router.navigate(commands);
5268
5262
  }))];
@@ -5287,7 +5281,7 @@
5287
5281
  return __generator(this, function (_a) {
5288
5282
  switch (_a.label) {
5289
5283
  case 0:
5290
- if (this.navigationSessionActive.value) {
5284
+ if (this.navigationInProgress.value) {
5291
5285
  pectin.lang.illegalState('Navigation already in progress');
5292
5286
  }
5293
5287
  this.runStateTransition((/**
@@ -5296,7 +5290,7 @@
5296
5290
  */
5297
5291
  function (current) {
5298
5292
  /** @type {?} */
5299
- var session = new exports.NavigationSession.Active(_this._navigationSessionContext, false, _this.router.routerState.snapshot.url);
5293
+ var session = new exports.NavigationState.NavigationTransition(_this._navigationSessionContext, false, _this.router.routerState.snapshot.url);
5300
5294
  session.storeVisit(visit);
5301
5295
  return session;
5302
5296
  }));
@@ -5310,7 +5304,7 @@
5310
5304
  case 3:
5311
5305
  // Router has finished (since there was no router change required) so we
5312
5306
  // need to end the navigation session.
5313
- if (this.navigationSession.active && !this.router.getCurrentNavigation()) {
5307
+ if (this.navigationState.isTransitional && !this.router.getCurrentNavigation()) {
5314
5308
  this.runStateTransition((/**
5315
5309
  * @param {?} session
5316
5310
  * @return {?}
@@ -5335,10 +5329,10 @@
5335
5329
  */
5336
5330
  function (transition) {
5337
5331
  /** @type {?} */
5338
- var previous = this._navigationSessionModel.value;
5332
+ var previous = this._navigationStateModel.value;
5339
5333
  /** @type {?} */
5340
- var next = transition(this.navigationSession);
5341
- this._navigationSessionModel.value = next;
5334
+ var next = transition(this.navigationState);
5335
+ this._navigationStateModel.value = next;
5342
5336
  if (next !== previous) {
5343
5337
  previous.dispose();
5344
5338
  pectin.Logger.get(this).info("Router State Transition: " + previous.toString() + " -> " + next.toString());
@@ -5361,144 +5355,11 @@
5361
5355
  [def.getFormattedRouteId(visit), def.getFormattedRouteParameters(visit)] :
5362
5356
  [def.getFormattedRouteParameters(visit)];
5363
5357
  };
5364
- // private onAngularRouterStarted(event: NavigationStart) {
5365
- // if (!this.navigationSession) {
5366
- // // We been activated by an external route rather than placeRouter.go(visit)
5367
- // this._navigationSessionModel.value = this.createExternalNavigationSession(event);
5368
- // }
5369
- // this.firstRoute = false;
5370
- // }
5371
- //
5372
- // private createExternalNavigationSession(event: NavigationStart) {
5373
- // return new NavigationSession.Active(
5374
- // this.modalInteractionService,
5375
- // this.angularLocation,
5376
- // // event.url,
5377
- // event.navigationTrigger === 'popstate'
5378
- // );
5379
- // }
5380
- // private onAngularRouterFinished(cancelled: boolean) {
5381
- // const session = this._navigationSessionModel.value;
5382
- // if (session.backClickedDuringCanDeactivateInteraction) {
5383
- // // we swallow this finished event but keep the session alive as we're going to
5384
- // // get another route started event, which will trigger anohter canDeactivate dialog
5385
- // // if we start a new session.
5386
- // // session.resetInteractionSession()
5387
- // } else {
5388
- // if (!cancelled) {
5389
- // const visits = session.getVisits();
5390
- // visits.forEach(v => this.placeHistory.add(v));
5391
- // // Update visits before we end the navigation session. This allows the placeOutets to
5392
- // // ignore visit changes that occur while the navigation is in progress
5393
- // this._activeVisits.value = visits;
5394
- // } else {
5395
- // // TODO: move this to the navigation session
5396
- // // Angular doesn't preserve the url when a guard cancels the back button.
5397
- // // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
5398
- // // session.rememberPopStateReturnUrl(this.router.routerState.snapshot.url);
5399
- // if (session.isPopState) {
5400
- // console.log('cancelled during popstate');
5401
- // // this.angularLocation.go(session.previousUrl);
5402
- // }
5403
- // }
5404
- // session.dispose();
5405
- // this._navigationSessionModel.value = null;
5406
- // }
5407
- // }
5408
- // private onAngularRouterStarted(event: NavigationStart) {
5409
- // if (!this.navigationSession) {
5410
- // // We been activated by an external route rather than placeRouter.go(visit)
5411
- // this._navigationSessionModel.value = this.createExternalNavigationSession(event);
5412
- // }
5413
- // this.firstRoute = false;
5414
- // }
5415
- //
5416
- // private createExternalNavigationSession(event: NavigationStart) {
5417
- // return new NavigationSession.Active(
5418
- // this.modalInteractionService,
5419
- // this.angularLocation,
5420
- // // event.url,
5421
- // event.navigationTrigger === 'popstate'
5422
- // );
5423
- // }
5424
- // private onAngularRouterFinished(cancelled: boolean) {
5425
- // const session = this._navigationSessionModel.value;
5426
- // if (session.backClickedDuringCanDeactivateInteraction) {
5427
- // // we swallow this finished event but keep the session alive as we're going to
5428
- // // get another route started event, which will trigger anohter canDeactivate dialog
5429
- // // if we start a new session.
5430
- // // session.resetInteractionSession()
5431
- // } else {
5432
- // if (!cancelled) {
5433
- // const visits = session.getVisits();
5434
- // visits.forEach(v => this.placeHistory.add(v));
5435
- // // Update visits before we end the navigation session. This allows the placeOutets to
5436
- // // ignore visit changes that occur while the navigation is in progress
5437
- // this._activeVisits.value = visits;
5438
- // } else {
5439
- // // TODO: move this to the navigation session
5440
- // // Angular doesn't preserve the url when a guard cancels the back button.
5441
- // // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
5442
- // // session.rememberPopStateReturnUrl(this.router.routerState.snapshot.url);
5443
- // if (session.isPopState) {
5444
- // console.log('cancelled during popstate');
5445
- // // this.angularLocation.go(session.previousUrl);
5446
- // }
5447
- // }
5448
- // session.dispose();
5449
- // this._navigationSessionModel.value = null;
5450
- // }
5451
- // }
5452
5358
  /**
5453
5359
  * @param {?} activatedRoute
5454
5360
  * @return {?}
5455
5361
  */
5456
- PlaceRouter.prototype.extractChildPath =
5457
- // private onAngularRouterStarted(event: NavigationStart) {
5458
- // if (!this.navigationSession) {
5459
- // // We been activated by an external route rather than placeRouter.go(visit)
5460
- // this._navigationSessionModel.value = this.createExternalNavigationSession(event);
5461
- // }
5462
- // this.firstRoute = false;
5463
- // }
5464
- //
5465
- // private createExternalNavigationSession(event: NavigationStart) {
5466
- // return new NavigationSession.Active(
5467
- // this.modalInteractionService,
5468
- // this.angularLocation,
5469
- // // event.url,
5470
- // event.navigationTrigger === 'popstate'
5471
- // );
5472
- // }
5473
- // private onAngularRouterFinished(cancelled: boolean) {
5474
- // const session = this._navigationSessionModel.value;
5475
- // if (session.backClickedDuringCanDeactivateInteraction) {
5476
- // // we swallow this finished event but keep the session alive as we're going to
5477
- // // get another route started event, which will trigger anohter canDeactivate dialog
5478
- // // if we start a new session.
5479
- // // session.resetInteractionSession()
5480
- // } else {
5481
- // if (!cancelled) {
5482
- // const visits = session.getVisits();
5483
- // visits.forEach(v => this.placeHistory.add(v));
5484
- // // Update visits before we end the navigation session. This allows the placeOutets to
5485
- // // ignore visit changes that occur while the navigation is in progress
5486
- // this._activeVisits.value = visits;
5487
- // } else {
5488
- // // TODO: move this to the navigation session
5489
- // // Angular doesn't preserve the url when a guard cancels the back button.
5490
- // // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
5491
- // // session.rememberPopStateReturnUrl(this.router.routerState.snapshot.url);
5492
- // if (session.isPopState) {
5493
- // console.log('cancelled during popstate');
5494
- // // this.angularLocation.go(session.previousUrl);
5495
- // }
5496
- // }
5497
- // session.dispose();
5498
- // this._navigationSessionModel.value = null;
5499
- // }
5500
- // }
5501
- /**
5362
+ PlaceRouter.prototype.extractChildPath = /**
5502
5363
  * @param {?} activatedRoute
5503
5364
  * @return {?}
5504
5365
  */
@@ -5510,15 +5371,97 @@
5510
5371
  function (child) { return child.url; })));
5511
5372
  };
5512
5373
  /**
5513
- * @param {?} snapshot
5374
+ * @param {?} url
5514
5375
  * @return {?}
5515
5376
  */
5516
5377
  PlaceRouter.prototype.parseUrl = /**
5517
- * @param {?} snapshot
5378
+ * @param {?} url
5379
+ * @return {?}
5380
+ */
5381
+ function (url) {
5382
+ return new exports.UrlSnapshot(this.urlSerializer, url);
5383
+ };
5384
+ /**
5385
+ * @param {?} url
5386
+ * @return {?}
5387
+ */
5388
+ PlaceRouter.prototype.resetBrowserLocation = /**
5389
+ * @param {?} url
5390
+ * @return {?}
5391
+ */
5392
+ function (url) {
5393
+ this.angularLocation.go(url);
5394
+ };
5395
+ /**
5396
+ * @return {?}
5397
+ */
5398
+ PlaceRouter.prototype.getCurrentRouterUrl = /**
5399
+ * @return {?}
5400
+ */
5401
+ function () {
5402
+ return this.router.routerState ? this.router.routerState.snapshot.url : null;
5403
+ };
5404
+ /**
5405
+ * @param {?} url
5406
+ * @return {?}
5407
+ */
5408
+ PlaceRouter.prototype.getActiveInteractionIdsFromUrl = /**
5409
+ * @param {?} url
5410
+ * @return {?}
5411
+ */
5412
+ function (url) {
5413
+ return this.parseUrl(url).getInteractionIds();
5414
+ };
5415
+ // @Trace()
5416
+ // @Trace()
5417
+ /**
5418
+ * @param {?} url
5419
+ * @return {?}
5420
+ */
5421
+ PlaceRouter.prototype.hasActiveInteractionIds =
5422
+ // @Trace()
5423
+ /**
5424
+ * @param {?} url
5425
+ * @return {?}
5426
+ */
5427
+ function (url) {
5428
+ return this.getActiveInteractionIdsFromUrl(url).length > 0;
5429
+ };
5430
+ /**
5518
5431
  * @return {?}
5519
5432
  */
5520
- function (snapshot) {
5521
- return new UrlSnapshot(this.urlSerializer.parse(snapshot.url));
5433
+ PlaceRouter.prototype.syncInteractionIdsWithRouter = /**
5434
+ * @return {?}
5435
+ */
5436
+ function () {
5437
+ var _a, _b;
5438
+ pectin.assert.isFalsey(this.navigationInProgress.value); // Updating interaction routes during an existing navigation breaks all the things.
5439
+ // Updating interaction routes during an existing navigation breaks all the things.
5440
+ /** @type {?} */
5441
+ var currentIds = this.interactionService.activeInteractionContextIds.value;
5442
+ if (___default__default.isEqual(currentIds, this.getActiveInteractionIdsFromUrl(this.getCurrentRouterUrl()))) {
5443
+ console.log('activity ids were the same, skipping');
5444
+ }
5445
+ else {
5446
+ if (currentIds.length < 1) {
5447
+ this.router.navigate(['.', {
5448
+ outlets: (_a = {},
5449
+ _a[exports.UrlSnapshot.INTERACTION_ROUTER_OUTLET] = null,
5450
+ _a)
5451
+ }], {
5452
+ replaceUrl: true // remove the interaction from the history.
5453
+ });
5454
+ }
5455
+ else {
5456
+ /** @type {?} */
5457
+ var urlSnapshot = this.parseUrl(this.getCurrentRouterUrl());
5458
+ this.router.navigate(['.', {
5459
+ outlets: (_b = {},
5460
+ _b[exports.UrlSnapshot.INTERACTION_ROUTER_OUTLET] = exports.UrlSnapshot.createInteractionOutletRouterCommands(currentIds),
5461
+ _b)
5462
+ }]);
5463
+ }
5464
+ }
5522
5465
  };
5523
5466
  PlaceRouter.decorators = [
5524
5467
  { type: core.Injectable, args: [{
@@ -5531,9 +5474,15 @@
5531
5474
  { type: router.UrlSerializer },
5532
5475
  { type: common.Location },
5533
5476
  { type: PlaceHistory },
5534
- { type: ModalInteractionService }
5477
+ { type: exports.ɵv }
5535
5478
  ]; };
5536
- /** @nocollapse */ PlaceRouter.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(core.ɵɵinject(router.Router), core.ɵɵinject(router.UrlSerializer), core.ɵɵinject(common.Location), core.ɵɵinject(PlaceHistory), core.ɵɵinject(ModalInteractionService)); }, token: PlaceRouter, providedIn: "root" });
5479
+ /** @nocollapse */ PlaceRouter.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(core.ɵɵinject(router.Router), core.ɵɵinject(router.UrlSerializer), core.ɵɵinject(common.Location), core.ɵɵinject(PlaceHistory), core.ɵɵinject(exports.ɵv)); }, token: PlaceRouter, providedIn: "root" });
5480
+ __decorate([
5481
+ pectin.Trace(),
5482
+ __metadata("design:type", Function),
5483
+ __metadata("design:paramtypes", []),
5484
+ __metadata("design:returntype", void 0)
5485
+ ], PlaceRouter.prototype, "syncInteractionIdsWithRouter", null);
5537
5486
  return PlaceRouter;
5538
5487
  }(pectin.GarbageCollector));
5539
5488
  if (false) {
@@ -5541,127 +5490,52 @@
5541
5490
  * @type {?}
5542
5491
  * @private
5543
5492
  */
5544
- exports.ɵt.prototype.firstRoute;
5493
+ PlaceRouter.prototype._navigationStateModel;
5545
5494
  /**
5546
5495
  * @type {?}
5547
5496
  * @private
5548
5497
  */
5549
- exports.ɵt.prototype._navigationSessionModel;
5498
+ PlaceRouter.prototype._activeVisits;
5499
+ /** @type {?} */
5500
+ PlaceRouter.prototype.navigationInProgress;
5501
+ /** @type {?} */
5502
+ PlaceRouter.prototype.activeVisitIndex;
5550
5503
  /**
5551
5504
  * @type {?}
5552
5505
  * @private
5553
- */
5554
- exports.ɵt.prototype._activeVisits;
5555
- /** @type {?} */
5556
- exports.ɵt.prototype.navigationSessionActive;
5557
- /** @type {?} */
5558
- exports.ɵt.prototype.activeVisitIndex;
5506
+ */
5507
+ PlaceRouter.prototype._navigationSessionContext;
5559
5508
  /**
5560
5509
  * @type {?}
5561
5510
  * @private
5562
5511
  */
5563
- exports.ɵt.prototype._navigationSessionContext;
5512
+ PlaceRouter.prototype._navigationStateTypeModel;
5564
5513
  /**
5565
5514
  * @type {?}
5566
5515
  * @private
5567
5516
  */
5568
- exports.ɵt.prototype.router;
5517
+ PlaceRouter.prototype.router;
5569
5518
  /**
5570
5519
  * @type {?}
5571
5520
  * @private
5572
5521
  */
5573
- exports.ɵt.prototype.urlSerializer;
5522
+ PlaceRouter.prototype.urlSerializer;
5574
5523
  /**
5575
5524
  * @type {?}
5576
5525
  * @private
5577
5526
  */
5578
- exports.ɵt.prototype.angularLocation;
5527
+ PlaceRouter.prototype.angularLocation;
5579
5528
  /**
5580
5529
  * @type {?}
5581
5530
  * @private
5582
5531
  */
5583
- exports.ɵt.prototype.placeHistory;
5532
+ PlaceRouter.prototype.placeHistory;
5584
5533
  /**
5585
5534
  * @type {?}
5586
5535
  * @private
5587
5536
  */
5588
- exports.ɵt.prototype.modalInteractionService;
5537
+ PlaceRouter.prototype.interactionService;
5589
5538
  }
5590
- (function (PlaceRouter) {
5591
- PlaceRouter.INTERACTION_ROUTER_OUTLET = 'aup-interaction';
5592
- var InteractionRouteMediator = /** @class */ (function () {
5593
- function InteractionRouteMediator(navigationSessionModelActive, router) {
5594
- this.navigationSessionModelActive = navigationSessionModelActive;
5595
- this.router = router;
5596
- }
5597
- Object.defineProperty(InteractionRouteMediator.prototype, "isNavigating", {
5598
- get: /**
5599
- * @return {?}
5600
- */
5601
- function () {
5602
- return this.navigationSessionModelActive.value;
5603
- },
5604
- enumerable: true,
5605
- configurable: true
5606
- });
5607
- // If we're not in a navigation we push
5608
- // @Trace()
5609
- // If we're not in a navigation we push
5610
- // @Trace()
5611
- /**
5612
- * @return {?}
5613
- */
5614
- InteractionRouteMediator.prototype.onActivityStarted =
5615
- // If we're not in a navigation we push
5616
- // @Trace()
5617
- /**
5618
- * @return {?}
5619
- */
5620
- function () {
5621
- var _a;
5622
- if (!this.isNavigating) {
5623
- this.router.navigate(['.', {
5624
- outlets: (_a = {},
5625
- _a[PlaceRouter.INTERACTION_ROUTER_OUTLET] = ['modal'] // "open" must be a valid route for this outlet.
5626
- ,
5627
- _a)
5628
- }], {
5629
- replaceUrl: false,
5630
- });
5631
- }
5632
- };
5633
- // @Trace()
5634
- // @Trace()
5635
- /**
5636
- * @return {?}
5637
- */
5638
- InteractionRouteMediator.prototype.onActivityFinished =
5639
- // @Trace()
5640
- /**
5641
- * @return {?}
5642
- */
5643
- function () {
5644
- var _a;
5645
- if (!this.isNavigating) {
5646
- this.router.navigate(['.', {
5647
- outlets: (_a = {},
5648
- _a[PlaceRouter.INTERACTION_ROUTER_OUTLET] = null,
5649
- _a)
5650
- }], {
5651
- replaceUrl: true // remove the interaction from the history.
5652
- });
5653
- }
5654
- };
5655
- return InteractionRouteMediator;
5656
- }());
5657
- PlaceRouter.InteractionRouteMediator = InteractionRouteMediator;
5658
- if (false) {
5659
- /** @type {?} */
5660
- InteractionRouteMediator.prototype.navigationSessionModelActive;
5661
- /** @type {?} */
5662
- InteractionRouteMediator.prototype.router;
5663
- }
5664
- })(exports.ɵt || (exports.ɵt = {}));
5665
5539
 
5666
5540
  /**
5667
5541
  * @fileoverview added by tsickle
@@ -5812,10 +5686,10 @@
5812
5686
  function (next, previous) {
5813
5687
  _this.pushVisitChangesToRoute(next, previous);
5814
5688
  }), {
5815
- unless: _this.placeRouter.navigationSessionActive
5689
+ unless: _this.placeRouter.navigationInProgress
5816
5690
  });
5817
5691
  chain(_this._activePlace)
5818
- .postponeWhile(placeRouter.navigationSessionActive)
5692
+ .postponeWhile(placeRouter.navigationInProgress)
5819
5693
  .subscribe((/**
5820
5694
  * @param {?} place
5821
5695
  * @return {?}
@@ -6045,7 +5919,7 @@
6045
5919
  /** @nocollapse */
6046
5920
  PlaceOutletComponent.ctorParameters = function () { return [
6047
5921
  { type: router.Router },
6048
- { type: exports.ɵt },
5922
+ { type: PlaceRouter },
6049
5923
  { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [AUP_PLACE_CONFIG,] }] },
6050
5924
  { type: PlaceOutletComponent, decorators: [{ type: core.SkipSelf }, { type: core.Optional }] }
6051
5925
  ]; };
@@ -6877,6 +6751,225 @@
6877
6751
  ActivityOutletContext.prototype.componentReady = function (component) { };
6878
6752
  }
6879
6753
 
6754
+ /**
6755
+ * @fileoverview added by tsickle
6756
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6757
+ */
6758
+ var DialogInteractionContext = /** @class */ (function (_super) {
6759
+ __extends(DialogInteractionContext, _super);
6760
+ function DialogInteractionContext(dialogService, config) {
6761
+ var _this = _super.call(this) || this;
6762
+ _this.dialogService = dialogService;
6763
+ _this.config = config;
6764
+ _this._activeModel = new pectin.MutableValueModel(false);
6765
+ typescriptUtilities.assert.notNil(dialogService);
6766
+ _this.onDispose((/**
6767
+ * @return {?}
6768
+ */
6769
+ function () {
6770
+ if (_this.isActive()) {
6771
+ pectin.lang.illegalState('Dispose called while active.');
6772
+ }
6773
+ }));
6774
+ return _this;
6775
+ }
6776
+ Object.defineProperty(DialogInteractionContext.prototype, "active", {
6777
+ get: /**
6778
+ * @return {?}
6779
+ */
6780
+ function () {
6781
+ return this._activeModel.readonly;
6782
+ },
6783
+ enumerable: true,
6784
+ configurable: true
6785
+ });
6786
+ /**
6787
+ * @protected
6788
+ * @template D, R, E
6789
+ * @param {?} activityType
6790
+ * @param {?} data
6791
+ * @param {?=} disableClose
6792
+ * @return {?}
6793
+ */
6794
+ DialogInteractionContext.prototype._startActivity = /**
6795
+ * @protected
6796
+ * @template D, R, E
6797
+ * @param {?} activityType
6798
+ * @param {?} data
6799
+ * @param {?=} disableClose
6800
+ * @return {?}
6801
+ */
6802
+ function (activityType, data, disableClose) {
6803
+ var _this = this;
6804
+ if (disableClose === void 0) { disableClose = true; }
6805
+ if (this.isActive()) {
6806
+ pectin.lang.illegalState("Activity already in progress: " + this.activityList.value.map((/**
6807
+ * @param {?} a
6808
+ * @return {?}
6809
+ */
6810
+ function (a) { return a.constructor.name; })).join(', '));
6811
+ }
6812
+ this._activeModel.value = true;
6813
+ /** @type {?} */
6814
+ var config = __assign({}, this.config, {
6815
+ data: data,
6816
+ disableClose: disableClose,
6817
+ panelClass: 'dialog-interaction-context'
6818
+ });
6819
+ /** @type {?} */
6820
+ var self = this;
6821
+ /** @type {?} */
6822
+ var matDialogRef = (/** @type {?} */ (this.dialogService.open(ActivityContainerComponent, config)));
6823
+ return new Promise((/**
6824
+ * @param {?} resolve
6825
+ * @param {?} reject
6826
+ * @return {?}
6827
+ */
6828
+ function (resolve, reject) {
6829
+ /** @type {?} */
6830
+ var activityContainer = matDialogRef.componentInstance;
6831
+ self.safelyUpdateActivityListDelegate(activityContainer.activityList);
6832
+ activityContainer.initialActivityOutletContext = {
6833
+ activityClass: activityType,
6834
+ activityData: data,
6835
+ onDone: /**
6836
+ * @param {?} result
6837
+ * @return {?}
6838
+ */
6839
+ function (result) {
6840
+ resolve(result);
6841
+ matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
6842
+ },
6843
+ onCancel: /**
6844
+ * @param {?} error
6845
+ * @return {?}
6846
+ */
6847
+ function (error) {
6848
+ reject(error);
6849
+ matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
6850
+ }
6851
+ };
6852
+ // we need to check if our onDone/onCancel methods above we called or if we were
6853
+ // closed by the user clicking the backdrop. If the later then we need to reject
6854
+ // our promise.
6855
+ matDialogRef.afterClosed().subscribe((/**
6856
+ * @param {?} promiseAlreadyFinished
6857
+ * @return {?}
6858
+ */
6859
+ function (promiseAlreadyFinished) {
6860
+ if (!promiseAlreadyFinished) {
6861
+ reject('auto-closed');
6862
+ }
6863
+ }));
6864
+ matDialogRef.updateSize();
6865
+ matDialogRef.afterOpened().subscribe((/**
6866
+ * @param {?} promiseAlreadyFinished
6867
+ * @return {?}
6868
+ */
6869
+ function (promiseAlreadyFinished) {
6870
+ matDialogRef.updateSize();
6871
+ }));
6872
+ })).finally((/**
6873
+ * @return {?}
6874
+ */
6875
+ function () {
6876
+ self.safelyUpdateActivityListDelegate(null);
6877
+ _this._activeModel.value = false;
6878
+ }));
6879
+ };
6880
+ /**
6881
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
6882
+ * @param delegate
6883
+ */
6884
+ /**
6885
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
6886
+ * @param {?} delegate
6887
+ * @return {?}
6888
+ */
6889
+ DialogInteractionContext.prototype.safelyUpdateActivityListDelegate = /**
6890
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
6891
+ * @param {?} delegate
6892
+ * @return {?}
6893
+ */
6894
+ function (delegate) {
6895
+ var _this = this;
6896
+ setTimeout((/**
6897
+ * @return {?}
6898
+ */
6899
+ function () { return _this.setActivityList(delegate); }));
6900
+ };
6901
+ return DialogInteractionContext;
6902
+ }(InteractionContextBase));
6903
+ if (false) {
6904
+ /**
6905
+ * @type {?}
6906
+ * @private
6907
+ */
6908
+ DialogInteractionContext.prototype._activeModel;
6909
+ /**
6910
+ * @type {?}
6911
+ * @private
6912
+ */
6913
+ DialogInteractionContext.prototype.dialogService;
6914
+ /** @type {?} */
6915
+ DialogInteractionContext.prototype.config;
6916
+ }
6917
+
6918
+ /**
6919
+ * @fileoverview added by tsickle
6920
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6921
+ */
6922
+ /** @type {?} */
6923
+ var DIALOG_INTERACTION_SERVICE_DEFAULTS = new core.InjectionToken('DIALOG_INTERACTION_SERVICE_DEFAULTS');
6924
+ var DialogInteractionContextFactory = /** @class */ (function (_super) {
6925
+ __extends(DialogInteractionContextFactory, _super);
6926
+ function DialogInteractionContextFactory(dialogService, dialogServiceDefaults, matDialogDefaultConfig) {
6927
+ var _this = _super.call(this) || this;
6928
+ _this.dialogService = dialogService;
6929
+ _this.dialogServiceDefaults = dialogServiceDefaults;
6930
+ _this.matDialogDefaultConfig = matDialogDefaultConfig;
6931
+ typescriptUtilities.assert.notNil(dialogService);
6932
+ return _this;
6933
+ }
6934
+ /**
6935
+ * @return {?}
6936
+ */
6937
+ DialogInteractionContextFactory.prototype.createInteractionContext = /**
6938
+ * @return {?}
6939
+ */
6940
+ function () {
6941
+ /** @type {?} */
6942
+ var config = __assign({ autoFocus: false, hasBackdrop: true, closeOnNavigation: false }, this.matDialogDefaultConfig, this.dialogServiceDefaults);
6943
+ return new DialogInteractionContext(this.dialogService, config);
6944
+ };
6945
+ DialogInteractionContextFactory.decorators = [
6946
+ { type: core.Injectable, args: [{
6947
+ providedIn: 'root'
6948
+ },] }
6949
+ ];
6950
+ /** @nocollapse */
6951
+ DialogInteractionContextFactory.ctorParameters = function () { return [
6952
+ { type: material.MatDialog },
6953
+ { type: dialog.MatDialogConfig, decorators: [{ type: core.Optional }, { type: core.Inject, args: [DIALOG_INTERACTION_SERVICE_DEFAULTS,] }] },
6954
+ { type: dialog.MatDialogConfig, decorators: [{ type: core.Optional }, { type: core.Inject, args: [dialog.MAT_DIALOG_DEFAULT_OPTIONS,] }] }
6955
+ ]; };
6956
+ /** @nocollapse */ DialogInteractionContextFactory.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function DialogInteractionContextFactory_Factory() { return new DialogInteractionContextFactory(core.ɵɵinject(dialog.MatDialog), core.ɵɵinject(DIALOG_INTERACTION_SERVICE_DEFAULTS, 8), core.ɵɵinject(dialog.MAT_DIALOG_DEFAULT_OPTIONS, 8)); }, token: DialogInteractionContextFactory, providedIn: "root" });
6957
+ return DialogInteractionContextFactory;
6958
+ }(ModalInteractionContextFactory));
6959
+ if (false) {
6960
+ /** @type {?} */
6961
+ DialogInteractionContextFactory.prototype.active;
6962
+ /**
6963
+ * @type {?}
6964
+ * @private
6965
+ */
6966
+ DialogInteractionContextFactory.prototype.dialogService;
6967
+ /** @type {?} */
6968
+ DialogInteractionContextFactory.prototype.dialogServiceDefaults;
6969
+ /** @type {?} */
6970
+ DialogInteractionContextFactory.prototype.matDialogDefaultConfig;
6971
+ }
6972
+
6880
6973
  /**
6881
6974
  * @fileoverview added by tsickle
6882
6975
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -7251,16 +7344,16 @@
7251
7344
  // Parse our route params.
7252
7345
  params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
7253
7346
  parsedParams = placeDefinition.parseRouteParams(params);
7254
- initialVisit = this.placeRouter.navigationSession.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
7347
+ initialVisit = this.placeRouter.navigationState.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
7255
7348
  sanitiser = new VisitSanitiser(activatedRoute, this.router, this.placeHistory, this.injector);
7256
7349
  return [4 /*yield*/, sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams))];
7257
7350
  case 1:
7258
7351
  sanitisedVisit = _a.sent();
7259
7352
  // Save the visit with any updated parameters. We need to save it so we remember any non route parameters
7260
- this.placeRouter.navigationSession.storeVisit(sanitisedVisit);
7353
+ this.placeRouter.navigationState.storeVisit(sanitisedVisit);
7261
7354
  if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
7262
7355
  // Regenerate the url
7263
- commands = this.placeRouter.parseUrl(state).createRedirectCommandsFor(sanitisedVisit);
7356
+ commands = this.placeRouter.parseUrl(state.url).createRedirectCommandsFor(sanitisedVisit);
7264
7357
  console.log('##### Place Guard Redirect', commands);
7265
7358
  return [2 /*return*/, this.router.createUrlTree(commands, {
7266
7359
  replaceUrl: true,
@@ -7294,7 +7387,7 @@
7294
7387
  function (component, currentRoute, currentState, nextState) {
7295
7388
  return __awaiter(this, void 0, void 0, function () {
7296
7389
  return __generator(this, function (_a) {
7297
- return [2 /*return*/, this.placeRouter.navigationSession.canDeactivatePlace(component, this.placeRouter.parseUrl(nextState))];
7390
+ return [2 /*return*/, this.placeRouter.navigationState.canDeactivatePlace(component, this.placeRouter.parseUrl(nextState.url))];
7298
7391
  });
7299
7392
  });
7300
7393
  };
@@ -7304,7 +7397,7 @@
7304
7397
  * @protected
7305
7398
  * @param {?} activatedRoute
7306
7399
  * @param {?} state
7307
- * @param {?} canActivate
7400
+ * @param {?} runPlaceGuards
7308
7401
  * @return {?}
7309
7402
  */
7310
7403
  AbstractPlaceGuard.prototype.authorisePlaceThen =
@@ -7313,12 +7406,12 @@
7313
7406
  * @protected
7314
7407
  * @param {?} activatedRoute
7315
7408
  * @param {?} state
7316
- * @param {?} canActivate
7409
+ * @param {?} runPlaceGuards
7317
7410
  * @return {?}
7318
7411
  */
7319
- function (activatedRoute, state, canActivate) {
7412
+ function (activatedRoute, state, runPlaceGuards) {
7320
7413
  return __awaiter(this, void 0, void 0, function () {
7321
- var placeDefinition, authorised, _a;
7414
+ var placeDefinition, authoriseResult, _a;
7322
7415
  return __generator(this, function (_b) {
7323
7416
  switch (_b.label) {
7324
7417
  case 0:
@@ -7333,13 +7426,14 @@
7333
7426
  _a = true;
7334
7427
  _b.label = 3;
7335
7428
  case 3:
7336
- authorised = _a;
7337
- if (authorised === true) {
7338
- return [2 /*return*/, canActivate(placeDefinition)];
7429
+ authoriseResult = _a;
7430
+ if (authoriseResult === true) {
7431
+ // we're authorised, now run the place guards.
7432
+ return [2 /*return*/, runPlaceGuards(placeDefinition)];
7339
7433
  }
7340
7434
  else {
7341
- console.log('not authorised result', authorised);
7342
- return [2 /*return*/, authorised];
7435
+ console.log('not authorised result', authoriseResult);
7436
+ return [2 /*return*/, authoriseResult];
7343
7437
  }
7344
7438
  return [3 /*break*/, 5];
7345
7439
  case 4: return [2 /*return*/, pectin.lang.illegalState("expected component to be an instance of PlaceComponent, got " + activatedRoute.component)];
@@ -7414,12 +7508,12 @@
7414
7508
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7415
7509
  */
7416
7510
  var InteractionGuard = /** @class */ (function () {
7417
- function InteractionGuard(router, injector, placeRouter, angularLocation, modalInteractionService) {
7511
+ function InteractionGuard(router, injector, placeRouter, angularLocation, interactionService) {
7418
7512
  this.router = router;
7419
7513
  this.injector = injector;
7420
7514
  this.placeRouter = placeRouter;
7421
7515
  this.angularLocation = angularLocation;
7422
- this.modalInteractionService = modalInteractionService;
7516
+ this.interactionService = interactionService;
7423
7517
  }
7424
7518
  /**
7425
7519
  * @param {?} route
@@ -7434,10 +7528,10 @@
7434
7528
  function (route, state) {
7435
7529
  /** @type {?} */
7436
7530
  var url = this.router.parseUrl(state.url);
7437
- if (!this.modalInteractionService.isActive() && url.root.children[exports.ɵt.INTERACTION_ROUTER_OUTLET]) {
7531
+ if (!this.interactionService.isActive() && url.root.children[exports.UrlSnapshot.INTERACTION_ROUTER_OUTLET]) {
7438
7532
  // This happens if we reload the page or the url was pasted as the route should only be activated
7439
7533
  // after the interaction context has become active.
7440
- delete url.root.children[exports.ɵt.INTERACTION_ROUTER_OUTLET];
7534
+ delete url.root.children[exports.UrlSnapshot.INTERACTION_ROUTER_OUTLET];
7441
7535
  return url;
7442
7536
  }
7443
7537
  else {
@@ -7460,20 +7554,26 @@
7460
7554
  */
7461
7555
  function (component, currentRoute, currentState, nextState) {
7462
7556
  return __awaiter(this, void 0, void 0, function () {
7463
- var popstateReturnUrl, activity;
7557
+ var currentIds, routeIds, activity;
7464
7558
  return __generator(this, function (_a) {
7465
7559
  switch (_a.label) {
7466
7560
  case 0:
7467
- popstateReturnUrl = this.placeRouter.navigationSession.startingUrl;
7468
- if (!this.modalInteractionService.isActive()) return [3 /*break*/, 2];
7561
+ if (!this.interactionService.isActive()) return [3 /*break*/, 2];
7562
+ currentIds = this.interactionService.activeInteractionContextIds.value;
7563
+ routeIds = this.placeRouter.getActiveInteractionIdsFromUrl(nextState.url);
7564
+ if (!!___default.isEqual(currentIds, routeIds)) return [3 /*break*/, 2];
7469
7565
  // The activity is still active so the route change was triggered by the back button.
7470
- return [4 /*yield*/, this.modalInteractionService.getCurrentActivity()];
7566
+ return [4 /*yield*/, this.interactionService.getCurrentActivity()];
7471
7567
  case 1:
7472
7568
  activity = _a.sent();
7473
7569
  activity.cancel();
7474
- // See ModalInteractionSession#onStart() for the url updating.
7475
- return [2 /*return*/, false];
7476
- case 2: return [2 /*return*/, true];
7570
+ _a.label = 2;
7571
+ case 2:
7572
+ // IMPORTANT:
7573
+ // We always return true, the router state engine will redirect as required. Return false
7574
+ // during the guard causes all kinds of grief. It might be worth trying a redirect here
7575
+ // again now that our state engine is more thorough.
7576
+ return [2 /*return*/, true];
7477
7577
  }
7478
7578
  });
7479
7579
  });
@@ -7487,11 +7587,11 @@
7487
7587
  InteractionGuard.ctorParameters = function () { return [
7488
7588
  { type: router.Router },
7489
7589
  { type: core.Injector },
7490
- { type: exports.ɵt },
7590
+ { type: PlaceRouter },
7491
7591
  { type: common.Location },
7492
- { type: ModalInteractionService }
7592
+ { type: exports.ɵv }
7493
7593
  ]; };
7494
- /** @nocollapse */ InteractionGuard.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function InteractionGuard_Factory() { return new InteractionGuard(core.ɵɵinject(router.Router), core.ɵɵinject(core.INJECTOR), core.ɵɵinject(exports.ɵt), core.ɵɵinject(common.Location), core.ɵɵinject(ModalInteractionService)); }, token: InteractionGuard, providedIn: "root" });
7594
+ /** @nocollapse */ InteractionGuard.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function InteractionGuard_Factory() { return new InteractionGuard(core.ɵɵinject(router.Router), core.ɵɵinject(core.INJECTOR), core.ɵɵinject(PlaceRouter), core.ɵɵinject(common.Location), core.ɵɵinject(exports.ɵv)); }, token: InteractionGuard, providedIn: "root" });
7495
7595
  return InteractionGuard;
7496
7596
  }());
7497
7597
  if (false) {
@@ -7519,7 +7619,7 @@
7519
7619
  * @type {?}
7520
7620
  * @private
7521
7621
  */
7522
- InteractionGuard.prototype.modalInteractionService;
7622
+ InteractionGuard.prototype.interactionService;
7523
7623
  }
7524
7624
 
7525
7625
  /**
@@ -7823,7 +7923,7 @@
7823
7923
  exports.AbstractInputComponent = AbstractInputComponent;
7824
7924
  exports.AbstractPlaceGuard = AbstractPlaceGuard;
7825
7925
  exports.AbstractPlaceNavigationComponent = AbstractPlaceNavigationComponent;
7826
- exports.Activity = exports.ɵbh;
7926
+ exports.Activity = exports.ɵbi;
7827
7927
  exports.ActivityContainerComponent = ActivityContainerComponent;
7828
7928
  exports.ActivityOutletComponent = ActivityOutletComponent;
7829
7929
  exports.AlertDialogComponent = AlertDialogComponent;
@@ -7831,27 +7931,28 @@
7831
7931
  exports.BusyOverlayComponent = BusyOverlayComponent;
7832
7932
  exports.CommandDirective = CommandDirective;
7833
7933
  exports.ComponentsModule = ComponentsModule;
7834
- exports.ConfirmThenDialogComponent = exports.ɵbj;
7934
+ exports.ConfirmThenDialogComponent = exports.ɵbk;
7835
7935
  exports.ConfirmationDialogComponent = ConfirmationDialogComponent;
7836
7936
  exports.ConsolidatedParameterMap = ConsolidatedParameterMap;
7837
7937
  exports.DEFINITION_META_DATA_KEY = DEFINITION_META_DATA_KEY;
7838
7938
  exports.DIALOG_INTERACTION_SERVICE_DEFAULTS = DIALOG_INTERACTION_SERVICE_DEFAULTS;
7839
7939
  exports.DialogInteractionContext = DialogInteractionContext;
7840
- exports.DialogInteractionService = DialogInteractionService;
7940
+ exports.DialogInteractionContextFactory = DialogInteractionContextFactory;
7841
7941
  exports.Dimension = Dimension;
7842
7942
  exports.DirectivesModule = DirectivesModule;
7843
7943
  exports.DisposableComponent = DisposableComponent;
7844
7944
  exports.EmptyStateComponent = EmptyStateComponent;
7845
7945
  exports.FocusBindingDirective = FocusBindingDirective;
7846
7946
  exports.InplaceInteractionContextComponent = InplaceInteractionContextComponent;
7847
- exports.InteractionContext = exports.ɵbc;
7947
+ exports.InteractionContext = InteractionContext;
7848
7948
  exports.InteractionContextBase = InteractionContextBase;
7849
7949
  exports.InteractionGuard = InteractionGuard;
7850
7950
  exports.InteractionModule = InteractionModule;
7851
7951
  exports.InteractionOutletComponent = InteractionOutletComponent;
7952
+ exports.InteractionService = exports.ɵv;
7852
7953
  exports.LEFT_RIGHT_PLACE_ANIMATION = LEFT_RIGHT_PLACE_ANIMATION;
7853
7954
  exports.ListPlaceNavComponent = ListPlaceNavComponent;
7854
- exports.ModalInteractionService = ModalInteractionService;
7955
+ exports.ModalInteractionContextFactory = ModalInteractionContextFactory;
7855
7956
  exports.NoopAuthGuard = NoopAuthGuard;
7856
7957
  exports.NoopComponent = NoopComponent;
7857
7958
  exports.NumberInputComponent = NumberInputComponent;
@@ -7861,7 +7962,7 @@
7861
7962
  exports.PlaceHistory = PlaceHistory;
7862
7963
  exports.PlaceModule = PlaceModule;
7863
7964
  exports.PlaceOutletComponent = PlaceOutletComponent;
7864
- exports.PlaceRouter = exports.ɵt;
7965
+ exports.PlaceRouter = PlaceRouter;
7865
7966
  exports.Point = Point;
7866
7967
  exports.ROUTE_PARAMETER_LIST_KEY = ROUTE_PARAMETER_LIST_KEY;
7867
7968
  exports.ResizeAwareComponent = ResizeAwareComponent;
@@ -7869,7 +7970,6 @@
7869
7970
  exports.SelectInputComponent = SelectInputComponent;
7870
7971
  exports.StringInputComponent = StringInputComponent;
7871
7972
  exports.TabbedPlaceNavigationComponent = TabbedPlaceNavigationComponent;
7872
- exports.UrlSnapshot = UrlSnapshot;
7873
7973
  exports.Visit = Visit;
7874
7974
  exports.VisitParameter = VisitParameter;
7875
7975
  exports.VisitParameterList = VisitParameterList;
@@ -7878,17 +7978,17 @@
7878
7978
  exports.slideDownAndUpAnimation = slideDownAndUpAnimation;
7879
7979
  exports.ɵa = DirectivesModule;
7880
7980
  exports.ɵb = CommandDirective;
7881
- exports.ɵba = ActivityContainerComponent;
7882
- exports.ɵbb = InteractionContextBase;
7883
- exports.ɵbd = ActivityOutletComponent;
7884
- exports.ɵbe = ConfirmationDialogComponent;
7885
- exports.ɵbf = AbstractActivity;
7886
- exports.ɵbg = ACTIVITY_DATA;
7887
- exports.ɵbk = AlertDialogComponent;
7888
- exports.ɵbm = InteractionOutletComponent;
7889
- exports.ɵbn = InplaceInteractionContextComponent;
7890
- exports.ɵbo = DIALOG_INTERACTION_SERVICE_DEFAULTS;
7891
- exports.ɵbp = DialogInteractionService;
7981
+ exports.ɵba = InteractionModule;
7982
+ exports.ɵbb = ActivityContainerComponent;
7983
+ exports.ɵbc = InteractionContextBase;
7984
+ exports.ɵbd = InteractionContext;
7985
+ exports.ɵbe = ActivityOutletComponent;
7986
+ exports.ɵbf = ConfirmationDialogComponent;
7987
+ exports.ɵbg = AbstractActivity;
7988
+ exports.ɵbh = ACTIVITY_DATA;
7989
+ exports.ɵbl = AlertDialogComponent;
7990
+ exports.ɵbn = InteractionOutletComponent;
7991
+ exports.ɵbo = InplaceInteractionContextComponent;
7892
7992
  exports.ɵc = FocusBindingDirective;
7893
7993
  exports.ɵd = DisposableComponent;
7894
7994
  exports.ɵe = ComponentsModule;
@@ -7905,12 +8005,12 @@
7905
8005
  exports.ɵp = leftRightPlaceAnimation;
7906
8006
  exports.ɵq = LEFT_RIGHT_PLACE_ANIMATION;
7907
8007
  exports.ɵr = AUP_PLACE_CONFIG;
8008
+ exports.ɵt = PlaceRouter;
7908
8009
  exports.ɵu = PlaceHistory;
7909
- exports.ɵv = ModalInteractionService;
7910
- exports.ɵw = TabbedPlaceNavigationComponent;
7911
- exports.ɵx = AbstractPlaceNavigationComponent;
7912
- exports.ɵy = ListPlaceNavComponent;
7913
- exports.ɵz = InteractionModule;
8010
+ exports.ɵw = ModalInteractionContextFactory;
8011
+ exports.ɵx = TabbedPlaceNavigationComponent;
8012
+ exports.ɵy = AbstractPlaceNavigationComponent;
8013
+ exports.ɵz = ListPlaceNavComponent;
7914
8014
 
7915
8015
  Object.defineProperty(exports, '__esModule', { value: true });
7916
8016