@coolon/angular-ui-powerups 0.0.101 → 0.0.103

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 (64) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +885 -632
  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 +1 -2
  6. package/coolon-angular-ui-powerups.metadata.json +1 -1
  7. package/esm2015/coolon-angular-ui-powerups.js +3 -4
  8. package/esm2015/index.js +2 -2
  9. package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +2 -1
  10. package/esm2015/lib/interaction/index.js +1 -2
  11. package/esm2015/lib/interaction/interaction-context-base.js +21 -8
  12. package/esm2015/lib/interaction/interaction-context.js +56 -3
  13. package/esm2015/lib/interaction/interaction.module.js +1 -4
  14. package/esm2015/lib/interaction/services/interaction.service.js +11 -7
  15. package/esm2015/lib/place/guards/navigation-state.js +216 -135
  16. package/esm2015/lib/place/guards/place-component-deactivation-handler.js +63 -28
  17. package/esm2015/lib/place/guards/place.guard.js +215 -0
  18. package/esm2015/lib/place/index.js +2 -3
  19. package/esm2015/lib/place/place-router.js +34 -36
  20. package/esm2015/lib/place/place.decorator.js +2 -2
  21. package/esm2015/lib/place/url-snapshot.js +69 -53
  22. package/esm2015/public_api.js +3 -3
  23. package/esm5/coolon-angular-ui-powerups.js +3 -4
  24. package/esm5/index.js +2 -2
  25. package/esm5/lib/interaction/components/activity-container/activity-container.component.js +2 -1
  26. package/esm5/lib/interaction/index.js +1 -2
  27. package/esm5/lib/interaction/interaction-context-base.js +25 -8
  28. package/esm5/lib/interaction/interaction-context.js +88 -10
  29. package/esm5/lib/interaction/interaction.module.js +1 -4
  30. package/esm5/lib/interaction/services/interaction.service.js +17 -8
  31. package/esm5/lib/place/guards/navigation-state.js +280 -162
  32. package/esm5/lib/place/guards/place-component-deactivation-handler.js +73 -27
  33. package/esm5/lib/place/guards/place.guard.js +300 -0
  34. package/esm5/lib/place/index.js +2 -3
  35. package/esm5/lib/place/place-router.js +52 -39
  36. package/esm5/lib/place/place.decorator.js +2 -2
  37. package/esm5/lib/place/url-snapshot.js +85 -58
  38. package/esm5/public_api.js +3 -3
  39. package/fesm2015/coolon-angular-ui-powerups.js +661 -539
  40. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  41. package/fesm5/coolon-angular-ui-powerups.js +884 -628
  42. package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
  43. package/lib/interaction/index.d.ts +0 -1
  44. package/lib/interaction/interaction-context-base.d.ts +3 -1
  45. package/lib/interaction/interaction-context.d.ts +9 -2
  46. package/lib/interaction/services/interaction.service.d.ts +2 -2
  47. package/lib/place/guards/navigation-state.d.ts +44 -38
  48. package/lib/place/guards/place-component-deactivation-handler.d.ts +7 -4
  49. package/lib/place/guards/{abstract-place.guard.d.ts → place.guard.d.ts} +8 -3
  50. package/lib/place/index.d.ts +1 -2
  51. package/lib/place/place-router.d.ts +2 -0
  52. package/lib/place/url-snapshot.d.ts +14 -9
  53. package/package.json +1 -1
  54. package/schematics/place-routes/place-def.js +1 -0
  55. package/schematics/place-routes/place-def.js.map +1 -1
  56. package/schematics/place-routes/templates/place-routes.ts.template +10 -11
  57. package/esm2015/lib/interaction/components/interaction-outlet/interaction-outlet.component.js +0 -19
  58. package/esm2015/lib/place/guards/abstract-place.guard.js +0 -166
  59. package/esm2015/lib/place/guards/interaction.guard.js +0 -121
  60. package/esm5/lib/interaction/components/interaction-outlet/interaction-outlet.component.js +0 -21
  61. package/esm5/lib/place/guards/abstract-place.guard.js +0 -213
  62. package/esm5/lib/place/guards/interaction.guard.js +0 -133
  63. package/lib/interaction/components/interaction-outlet/interaction-outlet.component.d.ts +0 -3
  64. package/lib/place/guards/interaction.guard.d.ts +0 -17
@@ -1,14 +1,13 @@
1
1
  import { DOCUMENT, CommonModule, Location } from '@angular/common';
2
- import { Directive, ElementRef, Inject, Input, HostListener, NgZone, NgModule, EventEmitter, Output, Component, InjectionToken, Injector, ComponentFactoryResolver, ViewContainerRef, ViewChild, ViewChildren, Injectable, ɵɵdefineInjectable, ɵɵinject, Optional, SkipSelf, HostBinding, INJECTOR } from '@angular/core';
2
+ import { Directive, ElementRef, Inject, Input, HostListener, NgZone, NgModule, EventEmitter, Output, Component, InjectionToken, Injector, ComponentFactoryResolver, ViewContainerRef, ViewChild, ViewChildren, Injectable, ɵɵdefineInjectable, ɵɵinject, Optional, SkipSelf, HostBinding } from '@angular/core';
3
3
  import { FormsModule } from '@angular/forms';
4
4
  import { MatInputModule, MatFormFieldModule, MatSelectModule, MatButtonModule, MatDialogModule, MatTabsModule as MatTabsModule$1, MatProgressSpinnerModule, MatDialog } from '@angular/material';
5
5
  import { MatTabsModule } from '@angular/material/tabs';
6
6
  import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7
7
  import { __extends, __decorate, __metadata, __awaiter, __generator, __assign, __spread } from 'tslib';
8
- import { DelegatingValueModel, assert, UnaryCommand, lang, Dsl, GarbageCollector, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, DelegatingListModel, Deferred, MutableStream, MutableValueModel, MutableListModel, Binding, Trace, Guard, StoreInValueModel, Command, OptionsHelper, ValueHolder } from '@coolon/pectin';
8
+ import { DelegatingValueModel, assert, UnaryCommand, lang, Dsl, GarbageCollector, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, Trace, DelegatingListModel, Deferred, MutableStream, MutableValueModel, MutableListModel, Binding, Guard, StoreInValueModel, Command, OptionsHelper, ValueHolder } from '@coolon/pectin';
9
9
  import { PortalModule } from '@angular/cdk/portal';
10
- import { RouterModule, UrlSegment, UrlSegmentGroup, NavigationStart, NavigationEnd, NavigationError, NavigationCancel, Router, UrlSerializer, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
11
- import ___default, { last, isNil, isEqual } from 'lodash';
10
+ import { RouterModule, NavigationStart, NavigationCancel, UrlSegment, NavigationEnd, NavigationError, Router, UrlSerializer } from '@angular/router';
12
11
  import { assert as assert$1, Opts, Klass } from '@coolon/typescript-utilities';
13
12
  import { MatIconModule } from '@angular/material/icon';
14
13
  import { MatListModule } from '@angular/material/list';
@@ -16,6 +15,7 @@ import { MatTooltipModule } from '@angular/material/tooltip';
16
15
  import { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';
17
16
  import { Memoize as Memoize$1 } from '@typescript-plus/fast-memoize-decorator';
18
17
  import 'reflect-metadata';
18
+ import ___default, { isNil, isEqual } from 'lodash';
19
19
  import { style, query, group, animate, trigger, transition } from '@angular/animations';
20
20
  import ResizeObserver from 'resize-observer-polyfill';
21
21
  import { MatDialogConfig, MAT_DIALOG_DEFAULT_OPTIONS, MatDialog as MatDialog$1 } from '@angular/material/dialog';
@@ -1100,10 +1100,7 @@ if (false) {
1100
1100
  /**
1101
1101
  * @abstract
1102
1102
  */
1103
- var /**
1104
- * @abstract
1105
- */
1106
- InteractionContext = /** @class */ (function (_super) {
1103
+ var InteractionContext = /** @class */ (function (_super) {
1107
1104
  __extends(InteractionContext, _super);
1108
1105
  function InteractionContext() {
1109
1106
  return _super !== null && _super.apply(this, arguments) || this;
@@ -1134,17 +1131,101 @@ InteractionContext = /** @class */ (function (_super) {
1134
1131
  assert.isFalsey(this.isActive());
1135
1132
  _super.prototype.dispose.call(this);
1136
1133
  };
1134
+ /**
1135
+ * Cancels the current activity and returns true the context is no longer active, false if
1136
+ * there is still another activity running.
1137
+ */
1138
+ /**
1139
+ * Cancels the current activity and returns true the context is no longer active, false if
1140
+ * there is still another activity running.
1141
+ * @return {?}
1142
+ */
1143
+ InteractionContext.prototype.cancelCurrentActivity = /**
1144
+ * Cancels the current activity and returns true the context is no longer active, false if
1145
+ * there is still another activity running.
1146
+ * @return {?}
1147
+ */
1148
+ function () {
1149
+ return __awaiter(this, void 0, void 0, function () {
1150
+ var when, activity;
1151
+ var _this = this;
1152
+ return __generator(this, function (_a) {
1153
+ switch (_a.label) {
1154
+ case 0:
1155
+ when = Dsl.disposeWith(this).when;
1156
+ return [4 /*yield*/, this.getCurrentActivity()];
1157
+ case 1:
1158
+ activity = _a.sent();
1159
+ return [2 /*return*/, new Promise((/**
1160
+ * @param {?} resolve
1161
+ * @return {?}
1162
+ */
1163
+ function (resolve) {
1164
+ when.valueOf(_this.activeActivity)
1165
+ .changes((/**
1166
+ * @param {?} nextActivity
1167
+ * @return {?}
1168
+ */
1169
+ function (nextActivity) {
1170
+ resolve(!nextActivity);
1171
+ }), { once: true });
1172
+ activity.cancel();
1173
+ }))];
1174
+ }
1175
+ });
1176
+ });
1177
+ };
1178
+ /**
1179
+ * @return {?}
1180
+ */
1181
+ InteractionContext.prototype.abort = /**
1182
+ * @return {?}
1183
+ */
1184
+ function () {
1185
+ return __awaiter(this, void 0, void 0, function () {
1186
+ var count;
1187
+ return __generator(this, function (_a) {
1188
+ switch (_a.label) {
1189
+ case 0:
1190
+ assert.isTruthy(this.isActive());
1191
+ count = 1;
1192
+ return [4 /*yield*/, this.cancelCurrentActivity()];
1193
+ case 1:
1194
+ _a.sent();
1195
+ console.log("aborted -> " + count++);
1196
+ _a.label = 2;
1197
+ case 2:
1198
+ if (!this.isActive()) return [3 /*break*/, 4];
1199
+ return [4 /*yield*/, this.cancelCurrentActivity()];
1200
+ case 3:
1201
+ _a.sent();
1202
+ console.log("aborted -> " + count++);
1203
+ return [3 /*break*/, 2];
1204
+ case 4: return [2 /*return*/];
1205
+ }
1206
+ });
1207
+ });
1208
+ };
1209
+ __decorate([
1210
+ Trace(),
1211
+ __metadata("design:type", Function),
1212
+ __metadata("design:paramtypes", []),
1213
+ __metadata("design:returntype", Promise)
1214
+ ], InteractionContext.prototype, "abort", null);
1137
1215
  return InteractionContext;
1138
1216
  }(GarbageCollector));
1139
1217
  if (false) {
1218
+ /** @type {?} */
1219
+ InteractionContext.prototype.active;
1140
1220
  /** @type {?} */
1141
1221
  InteractionContext.prototype.activityList;
1142
1222
  /** @type {?} */
1143
- InteractionContext.prototype.active;
1223
+ InteractionContext.prototype.activeActivity;
1144
1224
  /**
1145
1225
  * Returns the activity that is currently active.
1146
1226
  * This model is only updated in the next tick after the view has been updated.
1147
1227
  * @abstract
1228
+ * @protected
1148
1229
  * @return {?}
1149
1230
  */
1150
1231
  InteractionContext.prototype.getCurrentActivity = function () { };
@@ -1353,13 +1434,14 @@ InteractionContextBase = /** @class */ (function (_super) {
1353
1434
  */
1354
1435
  _this._activityListDelegate = new DelegatingListModel();
1355
1436
  var _a = Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
1356
- when.listOf(_this.activityList).becomesPopulated((/**
1357
- * @param {?} activities
1437
+ _this._currentActivity = chain(_this.activityList).last();
1438
+ when.valueOf(_this._currentActivity).becomesTruthy((/**
1439
+ * @param {?} activity
1358
1440
  * @return {?}
1359
1441
  */
1360
- function (activities) {
1442
+ function (activity) {
1361
1443
  if (_this.deferredGetCurrentActivity) {
1362
- _this.deferredGetCurrentActivity.resolve(last(activities));
1444
+ _this.deferredGetCurrentActivity.resolve(activity);
1363
1445
  _this.deferredGetCurrentActivity = null;
1364
1446
  }
1365
1447
  }));
@@ -1388,6 +1470,16 @@ InteractionContextBase = /** @class */ (function (_super) {
1388
1470
  enumerable: true,
1389
1471
  configurable: true
1390
1472
  });
1473
+ Object.defineProperty(InteractionContextBase.prototype, "activeActivity", {
1474
+ get: /**
1475
+ * @return {?}
1476
+ */
1477
+ function () {
1478
+ return this._currentActivity;
1479
+ },
1480
+ enumerable: true,
1481
+ configurable: true
1482
+ });
1391
1483
  /**
1392
1484
  * Returns the activity that is currently active.
1393
1485
  * This model is only updated in the next tick after the view has been updated.
@@ -1414,12 +1506,14 @@ InteractionContextBase = /** @class */ (function (_super) {
1414
1506
  return [2 /*return*/, this.deferredGetCurrentActivity.promise];
1415
1507
  }
1416
1508
  else {
1417
- if (this.activityList.length < 1) {
1509
+ if (!this._currentActivity.value) {
1510
+ // we'be been asked before we've got any activities, create a deferred promise
1511
+ // that we resolve when the list populates.
1418
1512
  this.deferredGetCurrentActivity = Deferred.defer();
1419
1513
  return [2 /*return*/, this.deferredGetCurrentActivity.promise];
1420
1514
  }
1421
1515
  else {
1422
- return [2 /*return*/, last(this.activityList.value)];
1516
+ return [2 /*return*/, this._currentActivity.value];
1423
1517
  }
1424
1518
  }
1425
1519
  }
@@ -1521,6 +1615,11 @@ if (false) {
1521
1615
  * @private
1522
1616
  */
1523
1617
  InteractionContextBase.prototype.deferredGetCurrentActivity;
1618
+ /**
1619
+ * @type {?}
1620
+ * @private
1621
+ */
1622
+ InteractionContextBase.prototype._currentActivity;
1524
1623
  /**
1525
1624
  * @abstract
1526
1625
  * @protected
@@ -1947,6 +2046,7 @@ var ActivityContainerComponent = /** @class */ (function (_super) {
1947
2046
  * @return {?}
1948
2047
  */
1949
2048
  function () {
2049
+ this.updateActivityList();
1950
2050
  this._initialActivityOutletContext.value = null;
1951
2051
  this.initialActivityOutletContextEvent.emit(null);
1952
2052
  };
@@ -2182,6 +2282,15 @@ var InteractionService = /** @class */ (function () {
2182
2282
  function () {
2183
2283
  return this.active.value;
2184
2284
  };
2285
+ /**
2286
+ * @return {?}
2287
+ */
2288
+ InteractionService.prototype.isModalActive = /**
2289
+ * @return {?}
2290
+ */
2291
+ function () {
2292
+ return this.modelInteractionActive.value;
2293
+ };
2185
2294
  /**
2186
2295
  * @param {?} disposable
2187
2296
  * @return {?}
@@ -2207,19 +2316,19 @@ var InteractionService = /** @class */ (function () {
2207
2316
  function (interactionContext) {
2208
2317
  interactionContext.registerDisposable(new InteractionService.Monitor("ip" + ++inplaceMonitorCount, interactionContext, this._activeInlineInteractionContextModel, this.exclusiveContext));
2209
2318
  };
2319
+ // @Trace()
2320
+ // @Trace()
2210
2321
  /**
2211
2322
  * @return {?}
2212
2323
  */
2213
- InteractionService.prototype.getCurrentActivity = /**
2324
+ InteractionService.prototype.getActiveContext =
2325
+ // @Trace()
2326
+ /**
2214
2327
  * @return {?}
2215
2328
  */
2216
2329
  function () {
2217
- return __awaiter(this, void 0, void 0, function () {
2218
- return __generator(this, function (_a) {
2219
- assert$1.isTruthy(this.isActive());
2220
- return [2 /*return*/, this._activeInteractionContext.value.getCurrentActivity()];
2221
- });
2222
- });
2330
+ assert$1.isTruthy(this.isActive());
2331
+ return this._activeInteractionContext.value;
2223
2332
  };
2224
2333
  /**
2225
2334
  * Creates an interaction context that will prevent any other contexts from starting an
@@ -2521,25 +2630,6 @@ if (false) {
2521
2630
  InplaceInteractionContextComponent.prototype.interactionService;
2522
2631
  }
2523
2632
 
2524
- /**
2525
- * @fileoverview added by tsickle
2526
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2527
- */
2528
- var InteractionOutletComponent = /** @class */ (function () {
2529
- function InteractionOutletComponent() {
2530
- }
2531
- InteractionOutletComponent.decorators = [
2532
- { type: Component, args: [{
2533
- selector: 'aup-interaction-outlet',
2534
- template: "<router-outlet name=\"interaction-context\"></router-outlet>\n",
2535
- styles: [":host{display:block}"]
2536
- }] }
2537
- ];
2538
- /** @nocollapse */
2539
- InteractionOutletComponent.ctorParameters = function () { return []; };
2540
- return InteractionOutletComponent;
2541
- }());
2542
-
2543
2633
  /**
2544
2634
  * @fileoverview added by tsickle
2545
2635
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -2563,13 +2653,11 @@ var InteractionModule = /** @class */ (function () {
2563
2653
  ConfirmThenDialogComponent,
2564
2654
  AlertDialogComponent,
2565
2655
  ActivityOutletComponent,
2566
- InteractionOutletComponent,
2567
2656
  InplaceInteractionContextComponent
2568
2657
  ],
2569
2658
  exports: [
2570
2659
  ActivityContainerComponent,
2571
2660
  ActivityOutletComponent,
2572
- InteractionOutletComponent,
2573
2661
  InplaceInteractionContextComponent
2574
2662
  ],
2575
2663
  entryComponents: [
@@ -3552,67 +3640,110 @@ if (false) {
3552
3640
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3553
3641
  */
3554
3642
  var PlaceComponentDeactivationHandler = /** @class */ (function () {
3555
- function PlaceComponentDeactivationHandler(component, navigationSession) {
3643
+ function PlaceComponentDeactivationHandler(component, navigationState, isPrimaryComponent) {
3556
3644
  this.component = component;
3557
- this.navigationSession = navigationSession;
3645
+ this.navigationState = navigationState;
3646
+ this.isPrimaryComponent = isPrimaryComponent;
3558
3647
  }
3648
+ Object.defineProperty(PlaceComponentDeactivationHandler.prototype, "interactionService", {
3649
+ get: /**
3650
+ * @return {?}
3651
+ */
3652
+ function () {
3653
+ return this.navigationState.interactionService;
3654
+ },
3655
+ enumerable: true,
3656
+ configurable: true
3657
+ });
3658
+ Object.defineProperty(PlaceComponentDeactivationHandler.prototype, "placeRouter", {
3659
+ get: /**
3660
+ * @return {?}
3661
+ */
3662
+ function () {
3663
+ return this.navigationState.placeRouter;
3664
+ },
3665
+ enumerable: true,
3666
+ configurable: true
3667
+ });
3559
3668
  /**
3669
+ * @param {?} currentUrl
3560
3670
  * @param {?} nextState
3561
3671
  * @return {?}
3562
3672
  */
3563
3673
  PlaceComponentDeactivationHandler.prototype.canDeactivate = /**
3674
+ * @param {?} currentUrl
3564
3675
  * @param {?} nextState
3565
3676
  * @return {?}
3566
3677
  */
3567
- function (nextState) {
3678
+ function (currentUrl, nextState) {
3568
3679
  return __awaiter(this, void 0, void 0, function () {
3569
3680
  return __generator(this, function (_a) {
3570
3681
  // We'll get called multiple times if there's any parameter sanitisation so
3571
3682
  // we always return true if we accepted promise from a previous cycle of the current
3572
3683
  // navigation session.
3573
3684
  if (!this.canDeactivatePromise) {
3574
- this.canDeactivatePromise = this.canDeactivateComponent(nextState);
3685
+ console.log("creating deactivate promise for -> " + this.component.constructor.name);
3686
+ this.canDeactivatePromise = this.canDeactivateComponent(currentUrl, nextState);
3575
3687
  }
3576
3688
  return [2 /*return*/, this.canDeactivatePromise];
3577
3689
  });
3578
3690
  });
3579
3691
  };
3692
+ // @Trace()
3693
+ // @Trace()
3580
3694
  /**
3581
3695
  * @protected
3696
+ * @param {?} currentUrl
3582
3697
  * @param {?} nextState
3583
3698
  * @return {?}
3584
3699
  */
3585
- PlaceComponentDeactivationHandler.prototype.canDeactivateComponent = /**
3700
+ PlaceComponentDeactivationHandler.prototype.canDeactivateComponent =
3701
+ // @Trace()
3702
+ /**
3586
3703
  * @protected
3704
+ * @param {?} currentUrl
3587
3705
  * @param {?} nextState
3588
3706
  * @return {?}
3589
3707
  */
3590
- function (nextState) {
3708
+ function (currentUrl, nextState) {
3591
3709
  return __awaiter(this, void 0, void 0, function () {
3592
- var activity;
3710
+ var routeIds, currentIds;
3593
3711
  return __generator(this, function (_a) {
3594
3712
  switch (_a.label) {
3595
3713
  case 0:
3596
- if (!(this.navigationSession.isPopState && this.component.interactionContext && this.component.interactionContext.isActive())) return [3 /*break*/, 2];
3597
- // Note: Modal interactions are run in a different router outlet so we never get place deactivating while
3598
- // a model interaction is active. This is because:
3599
- // 1. the user can't click anything to navigate away
3600
- // 2. clicking the back button will only change the outlet route portion of the URL. This
3601
- // is all handled by the InteractionGuard and so the component guards will never run.
3602
- //
3603
- // Now we just cancel the current activity...
3604
- return [4 /*yield*/, this.component.interactionContext.getCurrentActivity()];
3714
+ console.log(this.navigationState.toString());
3715
+ if (!this.navigationState.isPopState) return [3 /*break*/, 5];
3716
+ if (!(this.isPrimaryComponent && this.interactionService.isModalActive())) return [3 /*break*/, 3];
3717
+ routeIds = this.placeRouter.getActiveInteractionIdsFromUrl(nextState.url);
3718
+ currentIds = this.interactionService.activeInteractionContextIds.value;
3719
+ if (!!isEqual(currentIds, routeIds)) return [3 /*break*/, 2];
3720
+ return [4 /*yield*/, this.interactionService.getActiveContext().cancelCurrentActivity()];
3605
3721
  case 1:
3606
- activity = _a.sent();
3607
- activity.cancel(null);
3608
- return [2 /*return*/, false]; // ..and stay where we are.
3609
- case 2:
3722
+ _a.sent();
3723
+ return [2 /*return*/, currentUrl.updateInteractionIds(this.interactionService.activeInteractionContextIds.value)];
3724
+ case 2: return [3 /*break*/, 5];
3725
+ case 3:
3726
+ if (!(this.component.interactionContext && this.component.interactionContext.isActive())) return [3 /*break*/, 5];
3727
+ return [4 /*yield*/, this.component.interactionContext.cancelCurrentActivity()];
3728
+ case 4:
3729
+ _a.sent();
3730
+ return [2 /*return*/, currentUrl
3731
+ .updateInteractionIds(this.interactionService.activeInteractionContextIds.value)];
3732
+ case 5:
3610
3733
  // Ok, so now we're really leaving, so we ask the component if we should.;
3611
- if (this.isNotJustAChangeInRouteId(nextState) && this.component.canDeactivate) {
3612
- // No interaction in progress, so ask the component .
3613
- // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
3614
- // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
3615
- return [2 /*return*/, this.component.canDeactivate(this.navigationSession.interactionContext)];
3734
+ if (this.isNotJustAChangeInRouteId(nextState)) {
3735
+ if (this.component.canDeactivate) {
3736
+ // No interaction in progress, so ask the component .
3737
+ // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
3738
+ // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
3739
+ return [2 /*return*/, this.component.canDeactivate(this.navigationState.interactionContext)];
3740
+ }
3741
+ // The component has an active interaction but no deactivation hook. Rather than guessing what to do
3742
+ // we'll just cancel the navigation and print a warning.
3743
+ if (this.component.interactionContext && this.component.interactionContext.isActive()) {
3744
+ console.warn('Route changed while component has active interaction, cancelling navigation');
3745
+ return [2 /*return*/, false];
3746
+ }
3616
3747
  }
3617
3748
  return [2 /*return*/, true];
3618
3749
  }
@@ -3646,7 +3777,9 @@ if (false) {
3646
3777
  /** @type {?} */
3647
3778
  PlaceComponentDeactivationHandler.prototype.component;
3648
3779
  /** @type {?} */
3649
- PlaceComponentDeactivationHandler.prototype.navigationSession;
3780
+ PlaceComponentDeactivationHandler.prototype.navigationState;
3781
+ /** @type {?} */
3782
+ PlaceComponentDeactivationHandler.prototype.isPrimaryComponent;
3650
3783
  }
3651
3784
 
3652
3785
  /**
@@ -3667,6 +3800,16 @@ NavigationState = /** @class */ (function (_super) {
3667
3800
  _this._visits = new Map();
3668
3801
  return _this;
3669
3802
  }
3803
+ Object.defineProperty(NavigationState.prototype, "name", {
3804
+ get: /**
3805
+ * @return {?}
3806
+ */
3807
+ function () {
3808
+ return this.constructor.name;
3809
+ },
3810
+ enumerable: true,
3811
+ configurable: true
3812
+ });
3670
3813
  Object.defineProperty(NavigationState.prototype, "idle", {
3671
3814
  get: /**
3672
3815
  * @return {?}
@@ -3729,6 +3872,19 @@ NavigationState = /** @class */ (function (_super) {
3729
3872
  function (placeDef) {
3730
3873
  return this._visits.get(placeDef);
3731
3874
  };
3875
+ /**
3876
+ * @param {?} visit
3877
+ * @param {?} initialUrl
3878
+ * @return {?}
3879
+ */
3880
+ NavigationState.prototype.onPlaceNavigationStart = /**
3881
+ * @param {?} visit
3882
+ * @param {?} initialUrl
3883
+ * @return {?}
3884
+ */
3885
+ function (visit, initialUrl) {
3886
+ return this.illegalTransition('onPlaceNavigationStart');
3887
+ };
3732
3888
  /**
3733
3889
  * @param {?} event
3734
3890
  * @return {?}
@@ -3744,7 +3900,7 @@ NavigationState = /** @class */ (function (_super) {
3744
3900
  * @param {?} event
3745
3901
  * @return {?}
3746
3902
  */
3747
- NavigationState.prototype.onStart = /**
3903
+ NavigationState.prototype.onRouterStarted = /**
3748
3904
  * @param {?} event
3749
3905
  * @return {?}
3750
3906
  */
@@ -3755,7 +3911,7 @@ NavigationState = /** @class */ (function (_super) {
3755
3911
  * @param {?} event
3756
3912
  * @return {?}
3757
3913
  */
3758
- NavigationState.prototype.onCancel = /**
3914
+ NavigationState.prototype.onRouterCancelled = /**
3759
3915
  * @param {?} event
3760
3916
  * @return {?}
3761
3917
  */
@@ -3766,7 +3922,7 @@ NavigationState = /** @class */ (function (_super) {
3766
3922
  * @param {?} event
3767
3923
  * @return {?}
3768
3924
  */
3769
- NavigationState.prototype.onError = /**
3925
+ NavigationState.prototype.onRouterError = /**
3770
3926
  * @param {?} event
3771
3927
  * @return {?}
3772
3928
  */
@@ -3777,7 +3933,7 @@ NavigationState = /** @class */ (function (_super) {
3777
3933
  * @param {?} event
3778
3934
  * @return {?}
3779
3935
  */
3780
- NavigationState.prototype.onEnd = /**
3936
+ NavigationState.prototype.onRouterEnd = /**
3781
3937
  * @param {?} event
3782
3938
  * @return {?}
3783
3939
  */
@@ -3797,15 +3953,17 @@ NavigationState = /** @class */ (function (_super) {
3797
3953
  };
3798
3954
  /**
3799
3955
  * @param {?} component
3800
- * @param {?} nextState
3956
+ * @param {?} currentUrl
3957
+ * @param {?} nextUrl
3801
3958
  * @return {?}
3802
3959
  */
3803
3960
  NavigationState.prototype.canDeactivatePlace = /**
3804
3961
  * @param {?} component
3805
- * @param {?} nextState
3962
+ * @param {?} currentUrl
3963
+ * @param {?} nextUrl
3806
3964
  * @return {?}
3807
3965
  */
3808
- function (component, nextState) {
3966
+ function (component, currentUrl, nextUrl) {
3809
3967
  return __awaiter(this, void 0, void 0, function () {
3810
3968
  return __generator(this, function (_a) {
3811
3969
  return [2 /*return*/, this.illegalTransition('canDeactivatePlace')];
@@ -3858,12 +4016,29 @@ NavigationState = /** @class */ (function (_super) {
3858
4016
  * @return {?}
3859
4017
  */
3860
4018
  function (event) {
3861
- // TODO: check if the event is purely for interaction context changes.
3862
4019
  /** @type {?} */
3863
4020
  var popstate = event.navigationTrigger === 'popstate';
3864
4021
  return popstate ?
3865
- new NavigationState.NavigationBackTransition(this.context, popstate, this.currentRouterUrl()) :
3866
- new NavigationState.NavigationTransition(this.context, popstate, this.currentRouterUrl());
4022
+ this.interactionService.isActive() ?
4023
+ new NavigationState.InteractionPopStateTransition(this.context, this.currentRouterUrl()) :
4024
+ new NavigationState.PopStateTransition(this.context, this.currentRouterUrl())
4025
+ :
4026
+ this.interactionService.isActive() ?
4027
+ new NavigationState.InteractionTransition(this.context, this.currentRouterUrl()) :
4028
+ new NavigationState.NavigationTransition(this.context, this.currentRouterUrl());
4029
+ };
4030
+ /**
4031
+ * @protected
4032
+ * @return {?}
4033
+ */
4034
+ NavigationState.prototype.createIdleState = /**
4035
+ * @protected
4036
+ * @return {?}
4037
+ */
4038
+ function () {
4039
+ return this.interactionService.isActive() ?
4040
+ new NavigationState.IdleDuringInteraction(this.context, this.currentRouterUrl()) :
4041
+ new NavigationState.Idle(this.context);
3867
4042
  };
3868
4043
  /**
3869
4044
  * @param {?} url
@@ -3874,12 +4049,7 @@ NavigationState = /** @class */ (function (_super) {
3874
4049
  * @return {?}
3875
4050
  */
3876
4051
  function (url) {
3877
- var _this = this;
3878
- // TODO: Should this be a navigate operation to avoid confusing the router...??
3879
- setTimeout((/**
3880
- * @return {?}
3881
- */
3882
- function () { return _this.placeRouter.resetBrowserLocation(url); }));
4052
+ this.placeRouter.resetBrowserLocation(url);
3883
4053
  };
3884
4054
  /**
3885
4055
  * @return {?}
@@ -3937,11 +4107,27 @@ if (false) {
3937
4107
  _this.isPopState = false;
3938
4108
  return _this;
3939
4109
  }
4110
+ /**
4111
+ * @param {?} visit
4112
+ * @param {?} initialUrl
4113
+ * @return {?}
4114
+ */
4115
+ Idle.prototype.onPlaceNavigationStart = /**
4116
+ * @param {?} visit
4117
+ * @param {?} initialUrl
4118
+ * @return {?}
4119
+ */
4120
+ function (visit, initialUrl) {
4121
+ /** @type {?} */
4122
+ var navigationTransition = new NavigationTransition(this.context, initialUrl);
4123
+ navigationTransition.storeVisit(visit);
4124
+ return navigationTransition;
4125
+ };
3940
4126
  /**
3941
4127
  * @param {?} event
3942
4128
  * @return {?}
3943
4129
  */
3944
- Idle.prototype.onStart = /**
4130
+ Idle.prototype.onRouterStarted = /**
3945
4131
  * @param {?} event
3946
4132
  * @return {?}
3947
4133
  */
@@ -3989,9 +4175,8 @@ if (false) {
3989
4175
  */
3990
4176
  AbstractNavigationTransition = /** @class */ (function (_super) {
3991
4177
  __extends(AbstractNavigationTransition, _super);
3992
- function AbstractNavigationTransition(context, isPopState, startingUrl) {
4178
+ function AbstractNavigationTransition(context, startingUrl) {
3993
4179
  var _this = _super.call(this, context) || this;
3994
- _this.isPopState = isPopState;
3995
4180
  _this.startingUrl = startingUrl;
3996
4181
  _this.isTransitional = true;
3997
4182
  _this.componentDeactivationHandlers = new Map();
@@ -4024,7 +4209,7 @@ if (false) {
4024
4209
  * @param {?} event
4025
4210
  * @return {?}
4026
4211
  */
4027
- AbstractNavigationTransition.prototype.onStart = /**
4212
+ AbstractNavigationTransition.prototype.onRouterStarted = /**
4028
4213
  * @param {?} event
4029
4214
  * @return {?}
4030
4215
  */
@@ -4037,7 +4222,7 @@ if (false) {
4037
4222
  * @param {?} event
4038
4223
  * @return {?}
4039
4224
  */
4040
- AbstractNavigationTransition.prototype.onEnd = /**
4225
+ AbstractNavigationTransition.prototype.onRouterEnd = /**
4041
4226
  * @param {?} event
4042
4227
  * @return {?}
4043
4228
  */
@@ -4055,37 +4240,38 @@ if (false) {
4055
4240
  * @return {?}
4056
4241
  */
4057
4242
  function (locationTriggerUrl) {
4058
- // detach the interactoin from the session so it doesn't get disposed until the activity
4059
- // has completed.
4243
+ Logger.get(this).info("back button pressed during navigation session interaction promise");
4244
+ // detach the interaction from the session so it doesn't get disposed until the activity has completed.
4060
4245
  /** @type {?} */
4061
- var context = this.detachInteractionContext();
4062
- var when = Dsl.disposeWith(context).when;
4246
+ var navigationInteraction = this.detachInteractionContext();
4247
+ var when = Dsl.disposeWith(navigationInteraction).when;
4063
4248
  // TODO: I need to make the exclusive interaction context disallow nested activities or
4064
- // that would mess things up entirely.
4065
- context.getCurrentActivity().then((/**
4066
- * @param {?} activity
4249
+ // that would mess things up entirely. Or, can I do a context.abortAll().then(..)
4250
+ navigationInteraction.cancelCurrentActivity().then((/**
4067
4251
  * @return {?}
4068
4252
  */
4069
- function (activity) {
4070
- when.valueOf(context.active).becomesFalsey((/**
4071
- * @return {?}
4072
- */
4073
- function () { return context.dispose(); }), { once: true });
4074
- activity.cancel(null);
4253
+ function () {
4254
+ navigationInteraction.dispose();
4075
4255
  }));
4076
- return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, locationTriggerUrl);
4256
+ return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, this.isPopState, locationTriggerUrl);
4077
4257
  };
4258
+ // @Trace()
4259
+ // @Trace()
4078
4260
  /**
4079
4261
  * @param {?} component
4080
- * @param {?} nextState
4262
+ * @param {?} currentUrl
4263
+ * @param {?} nextUrl
4081
4264
  * @return {?}
4082
4265
  */
4083
- AbstractNavigationTransition.prototype.canDeactivatePlace = /**
4266
+ AbstractNavigationTransition.prototype.canDeactivatePlace =
4267
+ // @Trace()
4268
+ /**
4084
4269
  * @param {?} component
4085
- * @param {?} nextState
4270
+ * @param {?} currentUrl
4271
+ * @param {?} nextUrl
4086
4272
  * @return {?}
4087
4273
  */
4088
- function (component, nextState) {
4274
+ function (component, currentUrl, nextUrl) {
4089
4275
  return __awaiter(this, void 0, void 0, function () {
4090
4276
  var handler, isPrimaryHandler;
4091
4277
  return __generator(this, function (_a) {
@@ -4093,10 +4279,10 @@ if (false) {
4093
4279
  handler = this.componentDeactivationHandlers.get(component);
4094
4280
  if (!handler) {
4095
4281
  isPrimaryHandler = this.componentDeactivationHandlers.size === 0;
4096
- handler = new PlaceComponentDeactivationHandler(component, this);
4282
+ handler = new PlaceComponentDeactivationHandler(component, this, isPrimaryHandler);
4097
4283
  this.componentDeactivationHandlers.set(component, handler);
4098
4284
  }
4099
- return [2 /*return*/, handler.canDeactivate(nextState)];
4285
+ return [2 /*return*/, handler.canDeactivate(currentUrl, nextUrl)];
4100
4286
  });
4101
4287
  });
4102
4288
  };
@@ -4131,8 +4317,6 @@ if (false) {
4131
4317
  */
4132
4318
  AbstractNavigationTransition.prototype._interactionContext;
4133
4319
  /** @type {?} */
4134
- AbstractNavigationTransition.prototype.isPopState;
4135
- /** @type {?} */
4136
4320
  AbstractNavigationTransition.prototype.startingUrl;
4137
4321
  }
4138
4322
  var NavigationTransition = /** @class */ (function (_super) {
@@ -4146,44 +4330,18 @@ if (false) {
4146
4330
  * @param {?} event
4147
4331
  * @return {?}
4148
4332
  */
4149
- NavigationTransition.prototype.onStart = /**
4333
+ NavigationTransition.prototype.onRouterCancelled = /**
4150
4334
  * @param {?} event
4151
4335
  * @return {?}
4152
4336
  */
4153
4337
  function (event) {
4154
- // active sessions can have many cancel start cycles due
4155
- // to place guard redirects
4156
4338
  return this;
4157
4339
  };
4158
4340
  /**
4159
4341
  * @param {?} event
4160
4342
  * @return {?}
4161
4343
  */
4162
- NavigationTransition.prototype.onEnd = /**
4163
- * @param {?} event
4164
- * @return {?}
4165
- */
4166
- function (event) {
4167
- // navigation succeeded
4168
- this.context.notifySuccess(this);
4169
- return new Idle(this.context);
4170
- };
4171
- /**
4172
- * @param {?} event
4173
- * @return {?}
4174
- */
4175
- NavigationTransition.prototype.onCancel = /**
4176
- * @param {?} event
4177
- * @return {?}
4178
- */
4179
- function (event) {
4180
- return new Idle(this.context);
4181
- };
4182
- /**
4183
- * @param {?} event
4184
- * @return {?}
4185
- */
4186
- NavigationTransition.prototype.onError = /**
4344
+ NavigationTransition.prototype.onRouterError = /**
4187
4345
  * @param {?} event
4188
4346
  * @return {?}
4189
4347
  */
@@ -4207,9 +4365,9 @@ if (false) {
4207
4365
  /** @type {?} */
4208
4366
  NavigationTransition.prototype.isPopState;
4209
4367
  }
4210
- var NavigationBackTransition = /** @class */ (function (_super) {
4211
- __extends(NavigationBackTransition, _super);
4212
- function NavigationBackTransition() {
4368
+ var PopStateTransition = /** @class */ (function (_super) {
4369
+ __extends(PopStateTransition, _super);
4370
+ function PopStateTransition() {
4213
4371
  var _this = _super !== null && _super.apply(this, arguments) || this;
4214
4372
  _this.isPopState = true;
4215
4373
  return _this;
@@ -4218,7 +4376,7 @@ if (false) {
4218
4376
  * @param {?} event
4219
4377
  * @return {?}
4220
4378
  */
4221
- NavigationBackTransition.prototype.onCancel = /**
4379
+ PopStateTransition.prototype.onRouterCancelled = /**
4222
4380
  * @param {?} event
4223
4381
  * @return {?}
4224
4382
  */
@@ -4233,7 +4391,7 @@ if (false) {
4233
4391
  * @param {?} event
4234
4392
  * @return {?}
4235
4393
  */
4236
- NavigationBackTransition.prototype.onError = /**
4394
+ PopStateTransition.prototype.onRouterError = /**
4237
4395
  * @param {?} event
4238
4396
  * @return {?}
4239
4397
  */
@@ -4247,90 +4405,105 @@ if (false) {
4247
4405
  }
4248
4406
  return new Idle(this.context);
4249
4407
  };
4250
- return NavigationBackTransition;
4408
+ return PopStateTransition;
4251
4409
  }(AbstractNavigationTransition));
4252
- NavigationState.NavigationBackTransition = NavigationBackTransition;
4410
+ NavigationState.PopStateTransition = PopStateTransition;
4253
4411
  if (false) {
4254
4412
  /** @type {?} */
4255
- NavigationBackTransition.prototype.isPopState;
4413
+ PopStateTransition.prototype.isPopState;
4256
4414
  }
4257
- /**
4258
- * @abstract
4259
- */
4260
- var /**
4261
- * @abstract
4262
- */
4263
- AbstractInteractionTransition = /** @class */ (function (_super) {
4264
- __extends(AbstractInteractionTransition, _super);
4265
- function AbstractInteractionTransition(context, startingUrl) {
4415
+ var IdleDuringInteraction = /** @class */ (function (_super) {
4416
+ __extends(IdleDuringInteraction, _super);
4417
+ function IdleDuringInteraction(context, startingUrl) {
4266
4418
  var _this = _super.call(this, context) || this;
4267
4419
  _this.startingUrl = startingUrl;
4268
- _this.isTransitional = true;
4420
+ _this.isTransitional = false;
4421
+ _this.isPopState = false;
4269
4422
  return _this;
4270
4423
  }
4271
4424
  /**
4272
- * @protected
4425
+ * @param {?} visit
4426
+ * @param {?} initialUrl
4273
4427
  * @return {?}
4274
4428
  */
4275
- AbstractInteractionTransition.prototype.reinstateInteractionRoute = /**
4276
- * @protected
4429
+ IdleDuringInteraction.prototype.onPlaceNavigationStart = /**
4430
+ * @param {?} visit
4431
+ * @param {?} initialUrl
4277
4432
  * @return {?}
4278
4433
  */
4279
- function () {
4280
- var _this = this;
4281
- console.log(this.startingUrl);
4282
- setTimeout((/**
4283
- * @return {?}
4284
- */
4285
- function () { return _this.placeRouter.syncInteractionIdsWithRouter(); }));
4434
+ function (visit, initialUrl) {
4435
+ /** @type {?} */
4436
+ var navigationTransition = new InteractionTransition(this.context, initialUrl);
4437
+ navigationTransition.storeVisit(visit);
4438
+ return navigationTransition;
4286
4439
  };
4287
- return AbstractInteractionTransition;
4288
- }(NavigationState));
4289
- NavigationState.AbstractInteractionTransition = AbstractInteractionTransition;
4290
- if (false) {
4291
- /** @type {?} */
4292
- AbstractInteractionTransition.prototype.isTransitional;
4293
- /** @type {?} */
4294
- AbstractInteractionTransition.prototype.startingUrl;
4295
- }
4296
- /**
4297
- * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4298
- * happily ignore interaction contexts.
4299
- */
4300
- var /**
4301
- * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4302
- * happily ignore interaction contexts.
4303
- */
4304
- InteractionTransition = /** @class */ (function (_super) {
4305
- __extends(InteractionTransition, _super);
4306
- function InteractionTransition() {
4307
- var _this = _super !== null && _super.apply(this, arguments) || this;
4308
- _this.isPopState = false;
4309
- return _this;
4310
- }
4311
4440
  /**
4312
4441
  * @param {?} event
4313
4442
  * @return {?}
4314
4443
  */
4315
- InteractionTransition.prototype.onEnd = /**
4444
+ IdleDuringInteraction.prototype.onRouterStarted = /**
4316
4445
  * @param {?} event
4317
4446
  * @return {?}
4318
4447
  */
4319
4448
  function (event) {
4320
- if (this.context.interactionService.isActive()) {
4321
- this.reinstateInteractionRoute();
4322
- return new IdleDuringInteraction(this.context, this.startingUrl);
4323
- }
4324
- else {
4325
- return new Idle(this.context);
4326
- }
4449
+ return new InteractionTransition(this.context, event.url);
4327
4450
  };
4328
- return InteractionTransition;
4329
- }(AbstractInteractionTransition));
4330
- NavigationState.InteractionTransition = InteractionTransition;
4451
+ /**
4452
+ * @param {?} event
4453
+ * @return {?}
4454
+ */
4455
+ IdleDuringInteraction.prototype.onPopState = /**
4456
+ * @param {?} event
4457
+ * @return {?}
4458
+ */
4459
+ function (event) {
4460
+ return new InteractionPopStateTransition(this.context, event.url);
4461
+ };
4462
+ __decorate([
4463
+ Trace(),
4464
+ __metadata("design:type", Function),
4465
+ __metadata("design:paramtypes", [NavigationStart]),
4466
+ __metadata("design:returntype", NavigationState)
4467
+ ], IdleDuringInteraction.prototype, "onRouterStarted", null);
4468
+ __decorate([
4469
+ Trace(),
4470
+ __metadata("design:type", Function),
4471
+ __metadata("design:paramtypes", [NavigationStart]),
4472
+ __metadata("design:returntype", NavigationState)
4473
+ ], IdleDuringInteraction.prototype, "onPopState", null);
4474
+ return IdleDuringInteraction;
4475
+ }(NavigationState));
4476
+ NavigationState.IdleDuringInteraction = IdleDuringInteraction;
4331
4477
  if (false) {
4332
4478
  /** @type {?} */
4333
- InteractionTransition.prototype.isPopState;
4479
+ IdleDuringInteraction.prototype.isTransitional;
4480
+ /** @type {?} */
4481
+ IdleDuringInteraction.prototype.isPopState;
4482
+ /** @type {?} */
4483
+ IdleDuringInteraction.prototype.startingUrl;
4484
+ }
4485
+ /**
4486
+ * @abstract
4487
+ */
4488
+ var /**
4489
+ * @abstract
4490
+ */
4491
+ AbstractInteractionTransition = /** @class */ (function (_super) {
4492
+ __extends(AbstractInteractionTransition, _super);
4493
+ function AbstractInteractionTransition(context, startingUrl) {
4494
+ var _this = _super.call(this, context, startingUrl) || this;
4495
+ _this.startingUrl = startingUrl;
4496
+ _this.isTransitional = true;
4497
+ return _this;
4498
+ }
4499
+ return AbstractInteractionTransition;
4500
+ }(AbstractNavigationTransition));
4501
+ NavigationState.AbstractInteractionTransition = AbstractInteractionTransition;
4502
+ if (false) {
4503
+ /** @type {?} */
4504
+ AbstractInteractionTransition.prototype.isTransitional;
4505
+ /** @type {?} */
4506
+ AbstractInteractionTransition.prototype.startingUrl;
4334
4507
  }
4335
4508
  /**
4336
4509
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
@@ -4340,87 +4513,133 @@ if (false) {
4340
4513
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4341
4514
  * happily ignore interaction contexts.
4342
4515
  */
4343
- InteractionBackTransition = /** @class */ (function (_super) {
4344
- __extends(InteractionBackTransition, _super);
4345
- function InteractionBackTransition() {
4516
+ InteractionTransition = /** @class */ (function (_super) {
4517
+ __extends(InteractionTransition, _super);
4518
+ function InteractionTransition() {
4346
4519
  var _this = _super !== null && _super.apply(this, arguments) || this;
4347
- _this.isPopState = true;
4520
+ _this.isPopState = false;
4348
4521
  return _this;
4349
4522
  }
4350
4523
  /**
4351
4524
  * @param {?} event
4352
4525
  * @return {?}
4353
4526
  */
4354
- InteractionBackTransition.prototype.onEnd = /**
4527
+ InteractionTransition.prototype.onRouterCancelled = /**
4355
4528
  * @param {?} event
4356
4529
  * @return {?}
4357
4530
  */
4358
4531
  function (event) {
4359
- if (this.interactionService.isActive()) {
4360
- this.reinstateInteractionRoute();
4532
+ if (this.context.interactionService.isActive()) {
4533
+ /** @type {?} */
4534
+ var interactionIds = this.interactionService.activeInteractionContextIds.value;
4535
+ this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
4536
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4537
+ }
4538
+ else {
4539
+ return new Idle(this.context);
4540
+ }
4541
+ };
4542
+ /**
4543
+ * @param {?} event
4544
+ * @return {?}
4545
+ */
4546
+ InteractionTransition.prototype.onRouterError = /**
4547
+ * @param {?} event
4548
+ * @return {?}
4549
+ */
4550
+ function (event) {
4551
+ // navigation was aborted.
4552
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4553
+ };
4554
+ /**
4555
+ * @param {?} event
4556
+ * @return {?}
4557
+ */
4558
+ InteractionTransition.prototype.onRouterEnd = /**
4559
+ * @param {?} event
4560
+ * @return {?}
4561
+ */
4562
+ function (event) {
4563
+ if (this.context.interactionService.isActive()) {
4361
4564
  return new IdleDuringInteraction(this.context, this.startingUrl);
4362
4565
  }
4363
4566
  else {
4364
4567
  return new Idle(this.context);
4365
4568
  }
4366
4569
  };
4367
- return InteractionBackTransition;
4570
+ return InteractionTransition;
4368
4571
  }(AbstractInteractionTransition));
4369
- NavigationState.InteractionBackTransition = InteractionBackTransition;
4572
+ NavigationState.InteractionTransition = InteractionTransition;
4370
4573
  if (false) {
4371
4574
  /** @type {?} */
4372
- InteractionBackTransition.prototype.isPopState;
4575
+ InteractionTransition.prototype.isPopState;
4373
4576
  }
4374
- var IdleDuringInteraction = /** @class */ (function (_super) {
4375
- __extends(IdleDuringInteraction, _super);
4376
- function IdleDuringInteraction(context, startingUrl) {
4377
- var _this = _super.call(this, context) || this;
4378
- _this.startingUrl = startingUrl;
4379
- _this.isTransitional = false;
4380
- _this.isPopState = false;
4577
+ /**
4578
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4579
+ * happily ignore interaction contexts.
4580
+ */
4581
+ var /**
4582
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4583
+ * happily ignore interaction contexts.
4584
+ */
4585
+ InteractionPopStateTransition = /** @class */ (function (_super) {
4586
+ __extends(InteractionPopStateTransition, _super);
4587
+ function InteractionPopStateTransition() {
4588
+ var _this = _super !== null && _super.apply(this, arguments) || this;
4589
+ _this.isPopState = true;
4381
4590
  return _this;
4382
4591
  }
4383
4592
  /**
4384
4593
  * @param {?} event
4385
4594
  * @return {?}
4386
4595
  */
4387
- IdleDuringInteraction.prototype.onStart = /**
4596
+ InteractionPopStateTransition.prototype.onRouterCancelled = /**
4388
4597
  * @param {?} event
4389
4598
  * @return {?}
4390
4599
  */
4391
4600
  function (event) {
4392
- return new InteractionTransition(this.context, event.url);
4601
+ if (this.interactionService.isActive()) {
4602
+ /** @type {?} */
4603
+ var interactionIds = this.interactionService.activeInteractionContextIds.value;
4604
+ this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
4605
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4606
+ }
4607
+ else {
4608
+ return new Idle(this.context);
4609
+ }
4393
4610
  };
4394
4611
  /**
4395
4612
  * @param {?} event
4396
4613
  * @return {?}
4397
4614
  */
4398
- IdleDuringInteraction.prototype.onPopState = /**
4615
+ InteractionPopStateTransition.prototype.onRouterEnd = /**
4399
4616
  * @param {?} event
4400
4617
  * @return {?}
4401
4618
  */
4402
4619
  function (event) {
4403
- return new InteractionBackTransition(this.context, event.url);
4620
+ if (this.context.interactionService.isActive()) {
4621
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4622
+ }
4623
+ else {
4624
+ return new Idle(this.context);
4625
+ }
4404
4626
  };
4405
- return IdleDuringInteraction;
4406
- }(NavigationState));
4407
- NavigationState.IdleDuringInteraction = IdleDuringInteraction;
4627
+ return InteractionPopStateTransition;
4628
+ }(AbstractInteractionTransition));
4629
+ NavigationState.InteractionPopStateTransition = InteractionPopStateTransition;
4408
4630
  if (false) {
4409
4631
  /** @type {?} */
4410
- IdleDuringInteraction.prototype.isTransitional;
4411
- /** @type {?} */
4412
- IdleDuringInteraction.prototype.isPopState;
4413
- /** @type {?} */
4414
- IdleDuringInteraction.prototype.startingUrl;
4632
+ InteractionPopStateTransition.prototype.isPopState;
4415
4633
  }
4416
4634
  var CancelledDuringNavigationInteraction = /** @class */ (function (_super) {
4417
4635
  __extends(CancelledDuringNavigationInteraction, _super);
4418
- function CancelledDuringNavigationInteraction(context, startingUrl, locationChangeTriggerUrl) {
4636
+ function CancelledDuringNavigationInteraction(context, startingUrl, startingEventWasAPopState, locationChangeTriggerUrl) {
4419
4637
  var _this = _super.call(this, context) || this;
4420
4638
  _this.startingUrl = startingUrl;
4639
+ _this.startingEventWasAPopState = startingEventWasAPopState;
4421
4640
  _this.locationChangeTriggerUrl = locationChangeTriggerUrl;
4422
4641
  _this.isPopState = false;
4423
- _this.capturedFauxRouterStart = false;
4642
+ _this.gotPopStateWithLeavingUrl = false;
4424
4643
  return _this;
4425
4644
  }
4426
4645
  Object.defineProperty(CancelledDuringNavigationInteraction.prototype, "isTransitional", {
@@ -4428,7 +4647,7 @@ if (false) {
4428
4647
  * @return {?}
4429
4648
  */
4430
4649
  function () {
4431
- return !this.capturedFauxRouterStart;
4650
+ return true;
4432
4651
  },
4433
4652
  enumerable: true,
4434
4653
  configurable: true
@@ -4437,35 +4656,34 @@ if (false) {
4437
4656
  * @param {?} event
4438
4657
  * @return {?}
4439
4658
  */
4440
- CancelledDuringNavigationInteraction.prototype.onStart = /**
4659
+ CancelledDuringNavigationInteraction.prototype.onRouterStarted = /**
4441
4660
  * @param {?} event
4442
4661
  * @return {?}
4443
4662
  */
4444
4663
  function (event) {
4445
- if (event.url === this.locationChangeTriggerUrl && !this.capturedFauxRouterStart) {
4446
- this.capturedFauxRouterStart = true;
4447
- return this.ignore(event, 'url matched back button location change');
4448
- }
4449
- else {
4450
- return this.createTransitionStateFor(event);
4451
- }
4664
+ return this.ignore(event);
4452
4665
  };
4453
4666
  /**
4454
4667
  * @param {?} event
4455
4668
  * @return {?}
4456
4669
  */
4457
- CancelledDuringNavigationInteraction.prototype.onCancel = /**
4670
+ CancelledDuringNavigationInteraction.prototype.onRouterCancelled = /**
4458
4671
  * @param {?} event
4459
4672
  * @return {?}
4460
4673
  */
4461
4674
  function (event) {
4462
- return this.ignore(event);
4675
+ // Depending on the state of the router and what was done we get a different
4676
+ // sequence of events. I.e. If they just clicked a link we'll get a cancel
4677
+ // with the locationChangeTriggerUrl as the final event. However the user
4678
+ // started the initial navigation with a pop state then we'll get one of
4679
+ // those with the locationChangeTriggerUrl but no cancel event with it.
4680
+ return this.gotPopStateWithLeavingUrl || this.locationChangeTriggerUrl === event.url ? this.createIdleState() : this.ignore(event);
4463
4681
  };
4464
4682
  /**
4465
4683
  * @param {?} event
4466
4684
  * @return {?}
4467
4685
  */
4468
- CancelledDuringNavigationInteraction.prototype.onEnd = /**
4686
+ CancelledDuringNavigationInteraction.prototype.onRouterEnd = /**
4469
4687
  * @param {?} event
4470
4688
  * @return {?}
4471
4689
  */
@@ -4476,7 +4694,7 @@ if (false) {
4476
4694
  * @param {?} event
4477
4695
  * @return {?}
4478
4696
  */
4479
- CancelledDuringNavigationInteraction.prototype.onError = /**
4697
+ CancelledDuringNavigationInteraction.prototype.onRouterError = /**
4480
4698
  * @param {?} event
4481
4699
  * @return {?}
4482
4700
  */
@@ -4492,7 +4710,31 @@ if (false) {
4492
4710
  * @return {?}
4493
4711
  */
4494
4712
  function (event) {
4495
- return this.createTransitionStateFor(event);
4713
+ this.gotPopStateWithLeavingUrl = this.gotPopStateWithLeavingUrl || event.url === this.locationChangeTriggerUrl;
4714
+ return this.ignore(event);
4715
+ };
4716
+ // @Trace()
4717
+ // @Trace()
4718
+ /**
4719
+ * @param {?} component
4720
+ * @param {?} currentUrl
4721
+ * @param {?} nextUrl
4722
+ * @return {?}
4723
+ */
4724
+ CancelledDuringNavigationInteraction.prototype.canDeactivatePlace =
4725
+ // @Trace()
4726
+ /**
4727
+ * @param {?} component
4728
+ * @param {?} currentUrl
4729
+ * @param {?} nextUrl
4730
+ * @return {?}
4731
+ */
4732
+ function (component, currentUrl, nextUrl) {
4733
+ return __awaiter(this, void 0, void 0, function () {
4734
+ return __generator(this, function (_a) {
4735
+ return [2 /*return*/, false];
4736
+ });
4737
+ });
4496
4738
  };
4497
4739
  /**
4498
4740
  * @param {?} event
@@ -4505,7 +4747,7 @@ if (false) {
4505
4747
  * @return {?}
4506
4748
  */
4507
4749
  function (event, reason) {
4508
- reason = reason ? " (" + reason + ")" : '';
4750
+ reason = reason ? " -> " + reason : '';
4509
4751
  Logger.get(this).info("ignoring router event" + reason + ": " + event.constructor.name + " -> " + event.url);
4510
4752
  return this;
4511
4753
  };
@@ -4516,8 +4758,14 @@ if (false) {
4516
4758
  * @return {?}
4517
4759
  */
4518
4760
  function () {
4519
- return this.constructor.name + "(startingUrl: " + this.startingUrl + ", locationChangeTriggerUrl:" + this.locationChangeTriggerUrl + ")";
4761
+ return this.constructor.name + "(isIdl: " + this.idle + ", startingUrl: " + this.startingUrl + ", locationChangeTriggerUrl:" + this.locationChangeTriggerUrl + ")";
4520
4762
  };
4763
+ __decorate([
4764
+ Trace(),
4765
+ __metadata("design:type", Function),
4766
+ __metadata("design:paramtypes", [NavigationCancel]),
4767
+ __metadata("design:returntype", NavigationState)
4768
+ ], CancelledDuringNavigationInteraction.prototype, "onRouterCancelled", null);
4521
4769
  return CancelledDuringNavigationInteraction;
4522
4770
  }(NavigationState));
4523
4771
  NavigationState.CancelledDuringNavigationInteraction = CancelledDuringNavigationInteraction;
@@ -4528,10 +4776,12 @@ if (false) {
4528
4776
  * @type {?}
4529
4777
  * @private
4530
4778
  */
4531
- CancelledDuringNavigationInteraction.prototype.capturedFauxRouterStart;
4779
+ CancelledDuringNavigationInteraction.prototype.gotPopStateWithLeavingUrl;
4532
4780
  /** @type {?} */
4533
4781
  CancelledDuringNavigationInteraction.prototype.startingUrl;
4534
4782
  /** @type {?} */
4783
+ CancelledDuringNavigationInteraction.prototype.startingEventWasAPopState;
4784
+ /** @type {?} */
4535
4785
  CancelledDuringNavigationInteraction.prototype.locationChangeTriggerUrl;
4536
4786
  }
4537
4787
  })(NavigationState || (NavigationState = {}));
@@ -4622,25 +4872,26 @@ if (false) {
4622
4872
  */
4623
4873
  var UrlSnapshot = /** @class */ (function () {
4624
4874
  // TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.
4625
- function UrlSnapshot(urlSerializer, url) {
4875
+ function UrlSnapshot(urlSerializer, url, options) {
4626
4876
  this.urlSerializer = urlSerializer;
4627
4877
  this.url = url;
4878
+ this.options = options;
4628
4879
  this.urlTree = urlSerializer.parse(url);
4629
4880
  }
4630
4881
  /**
4631
- * @protected
4632
4882
  * @param {?} visit
4633
4883
  * @return {?}
4634
4884
  */
4635
- UrlSnapshot.prototype.replaceExistingVisitSegmentsWith = /**
4636
- * @protected
4885
+ UrlSnapshot.prototype.updateVisitSegments = /**
4637
4886
  * @param {?} visit
4638
4887
  * @return {?}
4639
4888
  */
4640
4889
  function (visit) {
4890
+ /** @type {?} */
4891
+ var urlTree = this.urlSerializer.parse(this.url);
4641
4892
  // Ugly, but it works for now.
4642
4893
  /** @type {?} */
4643
- var segments = __spread(this.getPrimarySegments());
4894
+ var segments = __spread(this.getPrimarySegments(urlTree));
4644
4895
  /** @type {?} */
4645
4896
  var visitSegments = this.getSegmentsFor(visit);
4646
4897
  /** @type {?} */
@@ -4651,17 +4902,20 @@ var UrlSnapshot = /** @class */ (function () {
4651
4902
  function (segment) { return segment.path === visitSegments[0].path; }));
4652
4903
  // do not use the return value, it's the items that were removed!
4653
4904
  segments.splice.apply(segments, __spread([replaceAt, visitSegments.length], visitSegments));
4654
- return segments;
4905
+ urlTree.root.children.primary.segments = segments;
4906
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
4655
4907
  };
4656
4908
  /**
4657
4909
  * @private
4910
+ * @param {?} urlTree
4658
4911
  * @return {?}
4659
4912
  */
4660
4913
  UrlSnapshot.prototype.getPrimarySegments = /**
4661
4914
  * @private
4915
+ * @param {?} urlTree
4662
4916
  * @return {?}
4663
4917
  */
4664
- function () {
4918
+ function (urlTree) {
4665
4919
  return this.urlTree.root.children.primary.segments;
4666
4920
  };
4667
4921
  /**
@@ -4694,31 +4948,6 @@ var UrlSnapshot = /** @class */ (function () {
4694
4948
  new UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit))
4695
4949
  ];
4696
4950
  };
4697
- /**
4698
- * @param {?} visit
4699
- * @return {?}
4700
- */
4701
- UrlSnapshot.prototype.createRedirectCommandsFor = /**
4702
- * @param {?} visit
4703
- * @return {?}
4704
- */
4705
- function (visit) {
4706
- /** @type {?} */
4707
- var segments = this.replaceExistingVisitSegmentsWith(visit);
4708
- /** @type {?} */
4709
- var commands = [];
4710
- segments.forEach((/**
4711
- * @param {?} s
4712
- * @return {?}
4713
- */
4714
- function (s) {
4715
- commands.push(s.path);
4716
- if (s.parameterMap.keys.length > 0) {
4717
- commands.push(s.parameters);
4718
- }
4719
- }));
4720
- return commands;
4721
- };
4722
4951
  /**
4723
4952
  * @param {?} placeDef
4724
4953
  * @return {?}
@@ -4728,7 +4957,7 @@ var UrlSnapshot = /** @class */ (function () {
4728
4957
  * @return {?}
4729
4958
  */
4730
4959
  function (placeDef) {
4731
- return this.getPrimarySegments().find((/**
4960
+ return this.getPrimarySegments(this.urlTree).find((/**
4732
4961
  * @param {?} s
4733
4962
  * @return {?}
4734
4963
  */
@@ -4742,53 +4971,101 @@ var UrlSnapshot = /** @class */ (function () {
4742
4971
  */
4743
4972
  function () {
4744
4973
  /** @type {?} */
4745
- var interactionOutlet = this.urlTree.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET];
4746
- if (interactionOutlet) {
4747
- assert.isTruthy(interactionOutlet.segments.length === 2);
4748
- assert.isTruthy(interactionOutlet.segments[0].path === UrlSnapshot.INTERACTION_ROUTER_PATH);
4749
- return UrlSnapshot.parseInteractionIds(interactionOutlet.segments[1].path);
4974
+ var queryParam = this.urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM];
4975
+ if (queryParam) {
4976
+ return UrlSnapshot.parseInteractionIds(queryParam);
4750
4977
  }
4751
4978
  else {
4752
4979
  return [];
4753
4980
  }
4754
4981
  };
4982
+ /**
4983
+ * @return {?}
4984
+ */
4985
+ UrlSnapshot.prototype.hasInteractionIds = /**
4986
+ * @return {?}
4987
+ */
4988
+ function () {
4989
+ return this.getInteractionIds().length > 0;
4990
+ };
4755
4991
  // @Trace()
4756
4992
  // @Trace()
4757
4993
  /**
4758
4994
  * @param {?} ids
4759
4995
  * @return {?}
4760
4996
  */
4761
- UrlSnapshot.prototype.addOrReplaceInteractionIds =
4997
+ UrlSnapshot.prototype.updateInteractionIds =
4762
4998
  // @Trace()
4763
4999
  /**
4764
5000
  * @param {?} ids
4765
5001
  * @return {?}
4766
5002
  */
4767
5003
  function (ids) {
5004
+ if (ids.length === 0) {
5005
+ return this.removeInteractionIds();
5006
+ }
5007
+ else {
5008
+ /** @type {?} */
5009
+ var urlTree = this.urlSerializer.parse(this.url);
5010
+ urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM] = UrlSnapshot.createPathIdFor(ids);
5011
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
5012
+ }
5013
+ };
5014
+ // @Trace()
5015
+ // @Trace()
5016
+ /**
5017
+ * @return {?}
5018
+ */
5019
+ UrlSnapshot.prototype.removeInteractionIds =
5020
+ // @Trace()
5021
+ /**
5022
+ * @return {?}
5023
+ */
5024
+ function () {
4768
5025
  /** @type {?} */
4769
5026
  var urlTree = this.urlSerializer.parse(this.url);
4770
- urlTree.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET] = new UrlSegmentGroup([
4771
- new UrlSegment(UrlSnapshot.INTERACTION_ROUTER_PATH, {}),
4772
- new UrlSegment(UrlSnapshot.createPathIdFor(ids), {})
4773
- ], {});
4774
- return new UrlSnapshot(this.urlSerializer, urlTree.toString());
5027
+ if (urlTree.queryParams && urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM]) {
5028
+ urlTree.queryParams = {}; //[UrlSnapshot.INTERACTION_ROUTER_OUTLET]
5029
+ }
5030
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
5031
+ };
5032
+ /**
5033
+ * @param {?} options
5034
+ * @return {?}
5035
+ */
5036
+ UrlSnapshot.prototype.withOptions = /**
5037
+ * @param {?} options
5038
+ * @return {?}
5039
+ */
5040
+ function (options) {
5041
+ return new UrlSnapshot(this.urlSerializer, this.url, options);
5042
+ };
5043
+ /**
5044
+ * @return {?}
5045
+ */
5046
+ UrlSnapshot.prototype.getNavigationExtras = /**
5047
+ * @return {?}
5048
+ */
5049
+ function () {
5050
+ return this.options;
4775
5051
  };
4776
5052
  return UrlSnapshot;
4777
5053
  }());
4778
5054
  if (false) {
4779
- /**
4780
- * @type {?}
4781
- * @private
4782
- */
5055
+ /** @type {?} */
4783
5056
  UrlSnapshot.prototype.urlTree;
4784
5057
  /** @type {?} */
4785
5058
  UrlSnapshot.prototype.urlSerializer;
4786
5059
  /** @type {?} */
4787
5060
  UrlSnapshot.prototype.url;
5061
+ /**
5062
+ * @type {?}
5063
+ * @private
5064
+ */
5065
+ UrlSnapshot.prototype.options;
4788
5066
  }
4789
5067
  (function (UrlSnapshot) {
4790
- UrlSnapshot.INTERACTION_ROUTER_OUTLET = 'aup-interactions';
4791
- UrlSnapshot.INTERACTION_ROUTER_PATH = 'active';
5068
+ UrlSnapshot.INTERACTION_QUERY_PARAM = 'aup-interactions';
4792
5069
  UrlSnapshot.INTERACTION_ID_SEPARATOR = '--';
4793
5070
  /**
4794
5071
  * @param {?} path
@@ -4807,13 +5084,14 @@ if (false) {
4807
5084
  }
4808
5085
  UrlSnapshot.createPathIdFor = createPathIdFor;
4809
5086
  /**
4810
- * @param {?} interactionIds
4811
- * @return {?}
5087
+ * @record
4812
5088
  */
4813
- function createInteractionOutletRouterCommands(interactionIds) {
4814
- return [UrlSnapshot.INTERACTION_ROUTER_PATH, createPathIdFor(interactionIds)];
5089
+ function NavigationOptions() { }
5090
+ UrlSnapshot.NavigationOptions = NavigationOptions;
5091
+ if (false) {
5092
+ /** @type {?|undefined} */
5093
+ NavigationOptions.prototype.replaceUrl;
4815
5094
  }
4816
- UrlSnapshot.createInteractionOutletRouterCommands = createInteractionOutletRouterCommands;
4817
5095
  })(UrlSnapshot || (UrlSnapshot = {}));
4818
5096
 
4819
5097
  /**
@@ -4860,7 +5138,6 @@ var PlaceRouter = /** @class */ (function (_super) {
4860
5138
  // NavigationStart -> .... -> NavigationError --> navigation aborted, end session.
4861
5139
  // =======================
4862
5140
  if (event instanceof NavigationStart) {
4863
- console.log(event);
4864
5141
  if (event.navigationTrigger === 'popstate') {
4865
5142
  _this.runStateTransition((/**
4866
5143
  * @param {?} state
@@ -4873,7 +5150,7 @@ var PlaceRouter = /** @class */ (function (_super) {
4873
5150
  * @param {?} state
4874
5151
  * @return {?}
4875
5152
  */
4876
- function (state) { return state.onStart(event); }));
5153
+ function (state) { return state.onRouterStarted(event); }));
4877
5154
  }
4878
5155
  }
4879
5156
  if (event instanceof NavigationEnd) {
@@ -4882,7 +5159,7 @@ var PlaceRouter = /** @class */ (function (_super) {
4882
5159
  * @param {?} state
4883
5160
  * @return {?}
4884
5161
  */
4885
- function (state) { return state.onEnd(event); }));
5162
+ function (state) { return state.onRouterEnd(event); }));
4886
5163
  }
4887
5164
  if (event instanceof NavigationError) {
4888
5165
  console.log(event);
@@ -4890,7 +5167,7 @@ var PlaceRouter = /** @class */ (function (_super) {
4890
5167
  * @param {?} state
4891
5168
  * @return {?}
4892
5169
  */
4893
- function (state) { return state.onError(event); }));
5170
+ function (state) { return state.onRouterError(event); }));
4894
5171
  }
4895
5172
  if (event instanceof NavigationCancel) {
4896
5173
  console.log(event);
@@ -4898,7 +5175,7 @@ var PlaceRouter = /** @class */ (function (_super) {
4898
5175
  * @param {?} state
4899
5176
  * @return {?}
4900
5177
  */
4901
- function (state) { return state.onCancel(event); }));
5178
+ function (state) { return state.onRouterCancelled(event); }));
4902
5179
  }
4903
5180
  }));
4904
5181
  // Push dialog state to the url so we can capture the back button.
@@ -4927,12 +5204,11 @@ var PlaceRouter = /** @class */ (function (_super) {
4927
5204
  var navigationState = _this._navigationStateModel.value;
4928
5205
  console.log("URLChange -> " + url, { state: navigationState });
4929
5206
  urlChanges.publish({ url: url, state: navigationState });
4930
- // We've entered a navigation transition
4931
- if (navigationState instanceof NavigationState.NavigationTransition) {
5207
+ // The url has changed while we're in a transitional state
5208
+ if (navigationState.isTransitional) {
4932
5209
  /** @type {?} */
4933
5210
  var navigationInteraction = _this.navigationState.interactionContext;
4934
5211
  if (navigationInteraction && navigationInteraction.isActive()) {
4935
- Logger.get(_this).info("back button pressed during navigation session interaction promise");
4936
5212
  _this.runStateTransition((/**
4937
5213
  * @param {?} state
4938
5214
  * @return {?}
@@ -5073,9 +5349,9 @@ var PlaceRouter = /** @class */ (function (_super) {
5073
5349
  */
5074
5350
  function (router) {
5075
5351
  /** @type {?} */
5076
- var commands = _this.parseUrl(_this.router.routerState.snapshot.url).createRedirectCommandsFor(next);
5077
- console.log('### Push Changes to route Redirect', { commands: commands });
5078
- return router.navigate(commands);
5352
+ var urlSnapshot = _this.parseUrl(_this.router.routerState.snapshot.url).updateVisitSegments(next);
5353
+ console.log('### Push Changes to route Redirect', { commands: urlSnapshot.url });
5354
+ return _this.navigateByUrl(urlSnapshot);
5079
5355
  }))];
5080
5356
  }
5081
5357
  return [2 /*return*/];
@@ -5107,7 +5383,7 @@ var PlaceRouter = /** @class */ (function (_super) {
5107
5383
  */
5108
5384
  function (current) {
5109
5385
  /** @type {?} */
5110
- var session = new NavigationState.NavigationTransition(_this._navigationSessionContext, false, _this.router.routerState.snapshot.url);
5386
+ var session = _this.navigationState.onPlaceNavigationStart(visit, _this.getCurrentRouterUrl());
5111
5387
  session.storeVisit(visit);
5112
5388
  return session;
5113
5389
  }));
@@ -5126,7 +5402,7 @@ var PlaceRouter = /** @class */ (function (_super) {
5126
5402
  * @param {?} session
5127
5403
  * @return {?}
5128
5404
  */
5129
- function (session) { return session.onEnd(new NavigationEnd(-1, '', '')); }));
5405
+ function (session) { return session.onRouterEnd(new NavigationEnd(-1, '', '')); }));
5130
5406
  }
5131
5407
  return [7 /*endfinally*/];
5132
5408
  case 4: return [2 /*return*/];
@@ -5134,12 +5410,16 @@ var PlaceRouter = /** @class */ (function (_super) {
5134
5410
  });
5135
5411
  });
5136
5412
  };
5413
+ // @Trace()
5414
+ // @Trace()
5137
5415
  /**
5138
5416
  * @protected
5139
5417
  * @param {?} transition
5140
5418
  * @return {?}
5141
5419
  */
5142
- PlaceRouter.prototype.runStateTransition = /**
5420
+ PlaceRouter.prototype.runStateTransition =
5421
+ // @Trace()
5422
+ /**
5143
5423
  * @protected
5144
5424
  * @param {?} transition
5145
5425
  * @return {?}
@@ -5196,7 +5476,7 @@ var PlaceRouter = /** @class */ (function (_super) {
5196
5476
  * @return {?}
5197
5477
  */
5198
5478
  function (url) {
5199
- return new UrlSnapshot(this.urlSerializer, url);
5479
+ return new UrlSnapshot(this.urlSerializer, url, {});
5200
5480
  };
5201
5481
  /**
5202
5482
  * @param {?} url
@@ -5218,6 +5498,15 @@ var PlaceRouter = /** @class */ (function (_super) {
5218
5498
  function () {
5219
5499
  return this.router.routerState ? this.router.routerState.snapshot.url : null;
5220
5500
  };
5501
+ /**
5502
+ * @return {?}
5503
+ */
5504
+ PlaceRouter.prototype.getCurrentRouteSnapshot = /**
5505
+ * @return {?}
5506
+ */
5507
+ function () {
5508
+ return this.parseUrl(this.getCurrentRouterUrl());
5509
+ };
5221
5510
  /**
5222
5511
  * @param {?} url
5223
5512
  * @return {?}
@@ -5244,14 +5533,32 @@ var PlaceRouter = /** @class */ (function (_super) {
5244
5533
  function (url) {
5245
5534
  return this.getActiveInteractionIdsFromUrl(url).length > 0;
5246
5535
  };
5536
+ // @Trace()
5537
+ // @Trace()
5538
+ /**
5539
+ * @param {?} urlSnapshot
5540
+ * @return {?}
5541
+ */
5542
+ PlaceRouter.prototype.navigateByUrl =
5543
+ // @Trace()
5544
+ /**
5545
+ * @param {?} urlSnapshot
5546
+ * @return {?}
5547
+ */
5548
+ function (urlSnapshot) {
5549
+ this.router.navigateByUrl(urlSnapshot.urlTree, urlSnapshot.getNavigationExtras());
5550
+ };
5551
+ // @Trace()
5552
+ // @Trace()
5247
5553
  /**
5248
5554
  * @return {?}
5249
5555
  */
5250
- PlaceRouter.prototype.syncInteractionIdsWithRouter = /**
5556
+ PlaceRouter.prototype.syncInteractionIdsWithRouter =
5557
+ // @Trace()
5558
+ /**
5251
5559
  * @return {?}
5252
5560
  */
5253
5561
  function () {
5254
- var _a, _b;
5255
5562
  assert.isFalsey(this.navigationInProgress.value); // Updating interaction routes during an existing navigation breaks all the things.
5256
5563
  // Updating interaction routes during an existing navigation breaks all the things.
5257
5564
  /** @type {?} */
@@ -5261,22 +5568,12 @@ var PlaceRouter = /** @class */ (function (_super) {
5261
5568
  }
5262
5569
  else {
5263
5570
  if (currentIds.length < 1) {
5264
- this.router.navigate(['.', {
5265
- outlets: (_a = {},
5266
- _a[UrlSnapshot.INTERACTION_ROUTER_OUTLET] = null,
5267
- _a)
5268
- }], {
5269
- replaceUrl: true // remove the interaction from the history.
5270
- });
5571
+ // no more interactions to remove from history.
5572
+ this.navigateByUrl(this.getCurrentRouteSnapshot().removeInteractionIds());
5271
5573
  }
5272
5574
  else {
5273
- /** @type {?} */
5274
- var urlSnapshot = this.parseUrl(this.getCurrentRouterUrl());
5275
- this.router.navigate(['.', {
5276
- outlets: (_b = {},
5277
- _b[UrlSnapshot.INTERACTION_ROUTER_OUTLET] = UrlSnapshot.createInteractionOutletRouterCommands(currentIds),
5278
- _b)
5279
- }]);
5575
+ // todo was or is...
5576
+ this.navigateByUrl(this.getCurrentRouteSnapshot().updateInteractionIds(currentIds));
5280
5577
  }
5281
5578
  }
5282
5579
  };
@@ -5294,12 +5591,6 @@ var PlaceRouter = /** @class */ (function (_super) {
5294
5591
  { type: InteractionService }
5295
5592
  ]; };
5296
5593
  /** @nocollapse */ PlaceRouter.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(ɵɵinject(Router), ɵɵinject(UrlSerializer), ɵɵinject(Location), ɵɵinject(PlaceHistory), ɵɵinject(InteractionService)); }, token: PlaceRouter, providedIn: "root" });
5297
- __decorate([
5298
- Trace(),
5299
- __metadata("design:type", Function),
5300
- __metadata("design:paramtypes", []),
5301
- __metadata("design:returntype", void 0)
5302
- ], PlaceRouter.prototype, "syncInteractionIdsWithRouter", null);
5303
5594
  return PlaceRouter;
5304
5595
  }(GarbageCollector));
5305
5596
  if (false) {
@@ -6830,7 +7121,7 @@ function Place(options) {
6830
7121
  */
6831
7122
  function (target) {
6832
7123
  if (PlaceComponent.isPlaceComponentConstructor(target)) {
6833
- PlaceComponent.injectDefinition(target, new PlaceDefinition(target, options.path, isNil(options.authenticate) ? false : options.authenticate, options.data, PlaceComponent.getRouteParameters(target), (options.children || []).map((/**
7124
+ PlaceComponent.injectDefinition(target, new PlaceDefinition(target, options.path, isNil(options.authenticate) ? true : options.authenticate, options.data, PlaceComponent.getRouteParameters(target), (options.children || []).map((/**
6834
7125
  * @param {?} c
6835
7126
  * @return {?}
6836
7127
  */
@@ -6861,103 +7152,6 @@ function Place(options) {
6861
7152
  }
6862
7153
  })(Place || (Place = {}));
6863
7154
 
6864
- /**
6865
- * @fileoverview added by tsickle
6866
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6867
- */
6868
- var VisitSanitiser = /** @class */ (function () {
6869
- function VisitSanitiser(activatedRoute, router, placeHistory, injector) {
6870
- this.activatedRoute = activatedRoute;
6871
- this.router = router;
6872
- this.placeHistory = placeHistory;
6873
- this.injector = injector;
6874
- }
6875
- // @Trace()
6876
- // @Trace()
6877
- /**
6878
- * @param {?} visit
6879
- * @return {?}
6880
- */
6881
- VisitSanitiser.prototype.sanitise =
6882
- // @Trace()
6883
- /**
6884
- * @param {?} visit
6885
- * @return {?}
6886
- */
6887
- function (visit) {
6888
- return __awaiter(this, void 0, void 0, function () {
6889
- var placeDef, routeIdDef, routeId, sanitisedValue, parameterDefs, sanitisedVisit, i, def, value, sanitisedValue;
6890
- return __generator(this, function (_a) {
6891
- switch (_a.label) {
6892
- case 0:
6893
- placeDef = visit.placeDefinition;
6894
- if (!placeDef.hasRouteId()) return [3 /*break*/, 2];
6895
- routeIdDef = placeDef.getRouteIdParameterDef();
6896
- routeId = visit.getRouteId();
6897
- return [4 /*yield*/, routeIdDef.sanitise(routeId, visit, this.placeHistory, this.injector)];
6898
- case 1:
6899
- sanitisedValue = _a.sent();
6900
- // console.log({routeId, sanitisedValue});
6901
- // ###------- EARLY EXIT --------###
6902
- if (routeIdDef.hasChanged(routeId, sanitisedValue)) {
6903
- // if the route id has changed we redirect immediately as other
6904
- // parameter sanitisers might use it.
6905
- return [2 /*return*/, visit.replace(routeIdDef, sanitisedValue)];
6906
- }
6907
- _a.label = 2;
6908
- case 2:
6909
- // if we didn't replace the routeId we continue the url present parameters.
6910
- parameterDefs = placeDef.getVisitParameterDefs({
6911
- includeRouteParameters: true,
6912
- includeNonRouteParameters: true
6913
- });
6914
- sanitisedVisit = visit;
6915
- i = 0;
6916
- _a.label = 3;
6917
- case 3:
6918
- if (!(i < parameterDefs.length)) return [3 /*break*/, 6];
6919
- def = parameterDefs[i];
6920
- value = visit.getParameter(def.name);
6921
- return [4 /*yield*/, def.sanitise(value, sanitisedVisit, this.placeHistory, this.injector)];
6922
- case 4:
6923
- sanitisedValue = _a.sent();
6924
- if (def.hasChanged(value, sanitisedValue)) {
6925
- sanitisedVisit = sanitisedVisit.replace(def, sanitisedValue);
6926
- }
6927
- _a.label = 5;
6928
- case 5:
6929
- i++;
6930
- return [3 /*break*/, 3];
6931
- case 6: return [2 /*return*/, sanitisedVisit.hasChangedFrom(visit) ? sanitisedVisit : visit];
6932
- }
6933
- });
6934
- });
6935
- };
6936
- return VisitSanitiser;
6937
- }());
6938
- if (false) {
6939
- /**
6940
- * @type {?}
6941
- * @private
6942
- */
6943
- VisitSanitiser.prototype.activatedRoute;
6944
- /**
6945
- * @type {?}
6946
- * @private
6947
- */
6948
- VisitSanitiser.prototype.router;
6949
- /**
6950
- * @type {?}
6951
- * @private
6952
- */
6953
- VisitSanitiser.prototype.placeHistory;
6954
- /**
6955
- * @type {?}
6956
- * @private
6957
- */
6958
- VisitSanitiser.prototype.injector;
6959
- }
6960
-
6961
7155
  /**
6962
7156
  * @fileoverview added by tsickle
6963
7157
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -7120,15 +7314,151 @@ if (false) {
7120
7314
  * @fileoverview added by tsickle
7121
7315
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7122
7316
  */
7317
+ var NoopAuthGuard = /** @class */ (function () {
7318
+ function NoopAuthGuard() {
7319
+ }
7320
+ /**
7321
+ * @param {?} activatedRoute
7322
+ * @param {?} state
7323
+ * @return {?}
7324
+ */
7325
+ NoopAuthGuard.prototype.canActivate = /**
7326
+ * @param {?} activatedRoute
7327
+ * @param {?} state
7328
+ * @return {?}
7329
+ */
7330
+ function (activatedRoute, state) {
7331
+ return __awaiter(this, void 0, void 0, function () {
7332
+ return __generator(this, function (_a) {
7333
+ return [2 /*return*/, true];
7334
+ });
7335
+ });
7336
+ };
7337
+ NoopAuthGuard.decorators = [
7338
+ { type: Injectable, args: [{
7339
+ providedIn: 'root'
7340
+ },] }
7341
+ ];
7342
+ /** @nocollapse */
7343
+ NoopAuthGuard.ctorParameters = function () { return []; };
7344
+ /** @nocollapse */ NoopAuthGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function NoopAuthGuard_Factory() { return new NoopAuthGuard(); }, token: NoopAuthGuard, providedIn: "root" });
7345
+ return NoopAuthGuard;
7346
+ }());
7347
+
7123
7348
  /**
7349
+ * @fileoverview added by tsickle
7350
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7351
+ */
7352
+ var VisitSanitiser = /** @class */ (function () {
7353
+ function VisitSanitiser(activatedRoute, router, placeHistory, injector) {
7354
+ this.activatedRoute = activatedRoute;
7355
+ this.router = router;
7356
+ this.placeHistory = placeHistory;
7357
+ this.injector = injector;
7358
+ }
7359
+ // @Trace()
7360
+ // @Trace()
7361
+ /**
7362
+ * @param {?} visit
7363
+ * @return {?}
7364
+ */
7365
+ VisitSanitiser.prototype.sanitise =
7366
+ // @Trace()
7367
+ /**
7368
+ * @param {?} visit
7369
+ * @return {?}
7370
+ */
7371
+ function (visit) {
7372
+ return __awaiter(this, void 0, void 0, function () {
7373
+ var placeDef, routeIdDef, routeId, sanitisedValue, parameterDefs, sanitisedVisit, i, def, value, sanitisedValue;
7374
+ return __generator(this, function (_a) {
7375
+ switch (_a.label) {
7376
+ case 0:
7377
+ placeDef = visit.placeDefinition;
7378
+ if (!placeDef.hasRouteId()) return [3 /*break*/, 2];
7379
+ routeIdDef = placeDef.getRouteIdParameterDef();
7380
+ routeId = visit.getRouteId();
7381
+ return [4 /*yield*/, routeIdDef.sanitise(routeId, visit, this.placeHistory, this.injector)];
7382
+ case 1:
7383
+ sanitisedValue = _a.sent();
7384
+ // console.log({routeId, sanitisedValue});
7385
+ // ###------- EARLY EXIT --------###
7386
+ if (routeIdDef.hasChanged(routeId, sanitisedValue)) {
7387
+ // if the route id has changed we redirect immediately as other
7388
+ // parameter sanitisers might use it.
7389
+ return [2 /*return*/, visit.replace(routeIdDef, sanitisedValue)];
7390
+ }
7391
+ _a.label = 2;
7392
+ case 2:
7393
+ // if we didn't replace the routeId we continue the url present parameters.
7394
+ parameterDefs = placeDef.getVisitParameterDefs({
7395
+ includeRouteParameters: true,
7396
+ includeNonRouteParameters: true
7397
+ });
7398
+ sanitisedVisit = visit;
7399
+ i = 0;
7400
+ _a.label = 3;
7401
+ case 3:
7402
+ if (!(i < parameterDefs.length)) return [3 /*break*/, 6];
7403
+ def = parameterDefs[i];
7404
+ value = visit.getParameter(def.name);
7405
+ return [4 /*yield*/, def.sanitise(value, sanitisedVisit, this.placeHistory, this.injector)];
7406
+ case 4:
7407
+ sanitisedValue = _a.sent();
7408
+ if (def.hasChanged(value, sanitisedValue)) {
7409
+ sanitisedVisit = sanitisedVisit.replace(def, sanitisedValue);
7410
+ }
7411
+ _a.label = 5;
7412
+ case 5:
7413
+ i++;
7414
+ return [3 /*break*/, 3];
7415
+ case 6: return [2 /*return*/, sanitisedVisit.hasChangedFrom(visit) ? sanitisedVisit : visit];
7416
+ }
7417
+ });
7418
+ });
7419
+ };
7420
+ return VisitSanitiser;
7421
+ }());
7422
+ if (false) {
7423
+ /**
7424
+ * @type {?}
7425
+ * @private
7426
+ */
7427
+ VisitSanitiser.prototype.activatedRoute;
7428
+ /**
7429
+ * @type {?}
7430
+ * @private
7431
+ */
7432
+ VisitSanitiser.prototype.router;
7433
+ /**
7434
+ * @type {?}
7435
+ * @private
7436
+ */
7437
+ VisitSanitiser.prototype.placeHistory;
7438
+ /**
7439
+ * @type {?}
7440
+ * @private
7441
+ */
7442
+ VisitSanitiser.prototype.injector;
7443
+ }
7444
+
7445
+ /**
7446
+ * @fileoverview added by tsickle
7447
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7448
+ */
7449
+ /**
7450
+ * @abstract
7451
+ */
7452
+ var /**
7124
7453
  * @abstract
7125
7454
  */
7126
- var AbstractPlaceGuard = /** @class */ (function () {
7127
- function AbstractPlaceGuard(router, urlSerializer, placeRouter, placeHistory, injector) {
7455
+ PlaceGuard = /** @class */ (function () {
7456
+ function PlaceGuard(router, urlSerializer, placeRouter, placeHistory, interactionService, injector) {
7128
7457
  this.router = router;
7129
7458
  this.urlSerializer = urlSerializer;
7130
7459
  this.placeRouter = placeRouter;
7131
7460
  this.placeHistory = placeHistory;
7461
+ this.interactionService = interactionService;
7132
7462
  this.injector = injector;
7133
7463
  }
7134
7464
  // @Trace()
@@ -7138,7 +7468,7 @@ var AbstractPlaceGuard = /** @class */ (function () {
7138
7468
  * @param {?} state
7139
7469
  * @return {?}
7140
7470
  */
7141
- AbstractPlaceGuard.prototype.canActivate =
7471
+ PlaceGuard.prototype.canActivate =
7142
7472
  // @Trace()
7143
7473
  /**
7144
7474
  * @param {?} activatedRoute
@@ -7149,44 +7479,59 @@ var AbstractPlaceGuard = /** @class */ (function () {
7149
7479
  return __awaiter(this, void 0, void 0, function () {
7150
7480
  var _this = this;
7151
7481
  return __generator(this, function (_a) {
7482
+ // TODO: this is ugly now that I'm return UrlSnapshots and not UrlTrees. It'd be better if the functions
7483
+ // weren't nested or if I implemented a handler chain.
7152
7484
  return [2 /*return*/, this.authorisePlaceThen(activatedRoute, state, (/**
7153
7485
  * @param {?} placeDefinition
7154
7486
  * @return {?}
7155
7487
  */
7156
7488
  function (placeDefinition) { return __awaiter(_this, void 0, void 0, function () {
7157
- var params, parsedParams, initialVisit, sanitiser, sanitisedVisit, commands;
7489
+ var result;
7490
+ var _this = this;
7158
7491
  return __generator(this, function (_a) {
7159
7492
  switch (_a.label) {
7160
- case 0:
7161
- // Parse our route params.
7162
- params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
7163
- parsedParams = placeDefinition.parseRouteParams(params);
7164
- initialVisit = this.placeRouter.navigationState.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
7165
- sanitiser = new VisitSanitiser(activatedRoute, this.router, this.placeHistory, this.injector);
7166
- return [4 /*yield*/, sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams))];
7493
+ case 0: return [4 /*yield*/, this.cleanInteractionState(activatedRoute, state, (/**
7494
+ * @return {?}
7495
+ */
7496
+ function () { return __awaiter(_this, void 0, void 0, function () {
7497
+ var params, parsedParams, initialVisit, sanitiser, sanitisedVisit, urlSnapshot;
7498
+ return __generator(this, function (_a) {
7499
+ switch (_a.label) {
7500
+ case 0:
7501
+ // Parse our route params.
7502
+ params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
7503
+ parsedParams = placeDefinition.parseRouteParams(params);
7504
+ initialVisit = this.placeRouter.navigationState.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
7505
+ sanitiser = new VisitSanitiser(activatedRoute, this.router, this.placeHistory, this.injector);
7506
+ return [4 /*yield*/, sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams))];
7507
+ case 1:
7508
+ sanitisedVisit = _a.sent();
7509
+ // Save the visit with any updated parameters. We need to save it so we remember any non route parameters
7510
+ this.placeRouter.navigationState.storeVisit(sanitisedVisit);
7511
+ if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
7512
+ // Regenerate the url
7513
+ urlSnapshot = this.placeRouter.parseUrl(state.url).updateVisitSegments(sanitisedVisit);
7514
+ console.log('##### Place Guard Redirect', urlSnapshot);
7515
+ return [2 /*return*/, urlSnapshot];
7516
+ }
7517
+ else {
7518
+ return [2 /*return*/, true];
7519
+ }
7520
+ return [2 /*return*/];
7521
+ }
7522
+ });
7523
+ }); }))];
7167
7524
  case 1:
7168
- sanitisedVisit = _a.sent();
7169
- // Save the visit with any updated parameters. We need to save it so we remember any non route parameters
7170
- this.placeRouter.navigationState.storeVisit(sanitisedVisit);
7171
- if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
7172
- // Regenerate the url
7173
- commands = this.placeRouter.parseUrl(state.url).createRedirectCommandsFor(sanitisedVisit);
7174
- console.log('##### Place Guard Redirect', commands);
7175
- return [2 /*return*/, this.router.createUrlTree(commands, {
7176
- replaceUrl: true,
7177
- skipLocationChange: false
7178
- })];
7179
- }
7180
- else {
7181
- return [2 /*return*/, true];
7182
- }
7183
- return [2 /*return*/];
7525
+ result = _a.sent();
7526
+ return [2 /*return*/, this.handleGuardResult(result)];
7184
7527
  }
7185
7528
  });
7186
7529
  }); }))];
7187
7530
  });
7188
7531
  });
7189
7532
  };
7533
+ // @Trace()
7534
+ // @Trace()
7190
7535
  /**
7191
7536
  * @param {?} component
7192
7537
  * @param {?} currentRoute
@@ -7194,7 +7539,9 @@ var AbstractPlaceGuard = /** @class */ (function () {
7194
7539
  * @param {?=} nextState
7195
7540
  * @return {?}
7196
7541
  */
7197
- AbstractPlaceGuard.prototype.canDeactivate = /**
7542
+ PlaceGuard.prototype.canDeactivate =
7543
+ // @Trace()
7544
+ /**
7198
7545
  * @param {?} component
7199
7546
  * @param {?} currentRoute
7200
7547
  * @param {?} currentState
@@ -7203,11 +7550,38 @@ var AbstractPlaceGuard = /** @class */ (function () {
7203
7550
  */
7204
7551
  function (component, currentRoute, currentState, nextState) {
7205
7552
  return __awaiter(this, void 0, void 0, function () {
7553
+ var currentUrl, nextUrl, result;
7206
7554
  return __generator(this, function (_a) {
7207
- return [2 /*return*/, this.placeRouter.navigationState.canDeactivatePlace(component, this.placeRouter.parseUrl(nextState.url))];
7555
+ switch (_a.label) {
7556
+ case 0:
7557
+ currentUrl = this.placeRouter.parseUrl(currentState.url);
7558
+ nextUrl = this.placeRouter.parseUrl(nextState.url);
7559
+ return [4 /*yield*/, this.placeRouter.navigationState.canDeactivatePlace(component, currentUrl, nextUrl)];
7560
+ case 1:
7561
+ result = _a.sent();
7562
+ return [2 /*return*/, this.handleGuardResult(result)];
7563
+ }
7208
7564
  });
7209
7565
  });
7210
7566
  };
7567
+ /**
7568
+ * @private
7569
+ * @param {?} result
7570
+ * @return {?}
7571
+ */
7572
+ PlaceGuard.prototype.handleGuardResult = /**
7573
+ * @private
7574
+ * @param {?} result
7575
+ * @return {?}
7576
+ */
7577
+ function (result) {
7578
+ if (result instanceof UrlSnapshot) {
7579
+ return result.urlTree;
7580
+ }
7581
+ else {
7582
+ return result;
7583
+ }
7584
+ };
7211
7585
  // @Trace()
7212
7586
  // @Trace()
7213
7587
  /**
@@ -7217,7 +7591,7 @@ var AbstractPlaceGuard = /** @class */ (function () {
7217
7591
  * @param {?} runPlaceGuards
7218
7592
  * @return {?}
7219
7593
  */
7220
- AbstractPlaceGuard.prototype.authorisePlaceThen =
7594
+ PlaceGuard.prototype.authorisePlaceThen =
7221
7595
  // @Trace()
7222
7596
  /**
7223
7597
  * @protected
@@ -7259,12 +7633,16 @@ var AbstractPlaceGuard = /** @class */ (function () {
7259
7633
  });
7260
7634
  });
7261
7635
  };
7636
+ // @Trace()
7637
+ // @Trace()
7262
7638
  /**
7263
7639
  * @param {?} activatedRoute
7264
7640
  * @param {?} state
7265
7641
  * @return {?}
7266
7642
  */
7267
- AbstractPlaceGuard.prototype.isAuthorised = /**
7643
+ PlaceGuard.prototype.isAuthorised =
7644
+ // @Trace()
7645
+ /**
7268
7646
  * @param {?} activatedRoute
7269
7647
  * @param {?} state
7270
7648
  * @return {?}
@@ -7278,201 +7656,79 @@ var AbstractPlaceGuard = /** @class */ (function () {
7278
7656
  });
7279
7657
  });
7280
7658
  };
7281
- __decorate([
7282
- Trace(),
7283
- __metadata("design:type", Function),
7284
- __metadata("design:paramtypes", [ActivatedRouteSnapshot, RouterStateSnapshot]),
7285
- __metadata("design:returntype", Promise)
7286
- ], AbstractPlaceGuard.prototype, "isAuthorised", null);
7287
- return AbstractPlaceGuard;
7288
- }());
7289
- if (false) {
7290
- /**
7291
- * @type {?}
7292
- * @private
7293
- */
7294
- AbstractPlaceGuard.prototype.router;
7295
- /**
7296
- * @type {?}
7297
- * @private
7298
- */
7299
- AbstractPlaceGuard.prototype.urlSerializer;
7300
- /**
7301
- * @type {?}
7302
- * @private
7303
- */
7304
- AbstractPlaceGuard.prototype.placeRouter;
7305
- /**
7306
- * @type {?}
7307
- * @private
7308
- */
7309
- AbstractPlaceGuard.prototype.placeHistory;
7310
- /**
7311
- * @type {?}
7312
- * @private
7313
- */
7314
- AbstractPlaceGuard.prototype.injector;
7315
- /**
7316
- * @abstract
7317
- * @param {?} injector
7318
- * @return {?}
7319
- */
7320
- AbstractPlaceGuard.prototype.getAuthGuard = function (injector) { };
7321
- }
7322
-
7323
- /**
7324
- * @fileoverview added by tsickle
7325
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7326
- */
7327
- var InteractionGuard = /** @class */ (function () {
7328
- function InteractionGuard(router, injector, placeRouter, angularLocation, interactionService) {
7329
- this.router = router;
7330
- this.injector = injector;
7331
- this.placeRouter = placeRouter;
7332
- this.angularLocation = angularLocation;
7333
- this.interactionService = interactionService;
7334
- }
7659
+ // @Trace()
7660
+ // @Trace()
7335
7661
  /**
7336
7662
  * @param {?} route
7337
7663
  * @param {?} state
7664
+ * @param {?} then
7338
7665
  * @return {?}
7339
7666
  */
7340
- InteractionGuard.prototype.canActivate = /**
7667
+ PlaceGuard.prototype.cleanInteractionState =
7668
+ // @Trace()
7669
+ /**
7341
7670
  * @param {?} route
7342
7671
  * @param {?} state
7672
+ * @param {?} then
7343
7673
  * @return {?}
7344
7674
  */
7345
- function (route, state) {
7346
- /** @type {?} */
7347
- var url = this.router.parseUrl(state.url);
7348
- if (!this.interactionService.isActive() && url.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET]) {
7349
- // This happens if we reload the page or the url was pasted as the route should only be activated
7350
- // after the interaction context has become active.
7351
- delete url.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET];
7352
- return url;
7353
- }
7354
- else {
7355
- return true;
7356
- }
7357
- };
7358
- /**
7359
- * @param {?} component
7360
- * @param {?} currentRoute
7361
- * @param {?} currentState
7362
- * @param {?=} nextState
7363
- * @return {?}
7364
- */
7365
- InteractionGuard.prototype.canDeactivate = /**
7366
- * @param {?} component
7367
- * @param {?} currentRoute
7368
- * @param {?} currentState
7369
- * @param {?=} nextState
7370
- * @return {?}
7371
- */
7372
- function (component, currentRoute, currentState, nextState) {
7675
+ function (route, state, then) {
7373
7676
  return __awaiter(this, void 0, void 0, function () {
7374
- var currentIds, routeIds, activity;
7677
+ var url;
7375
7678
  return __generator(this, function (_a) {
7376
- switch (_a.label) {
7377
- case 0:
7378
- if (!this.interactionService.isActive()) return [3 /*break*/, 2];
7379
- currentIds = this.interactionService.activeInteractionContextIds.value;
7380
- routeIds = this.placeRouter.getActiveInteractionIdsFromUrl(nextState.url);
7381
- if (!!isEqual(currentIds, routeIds)) return [3 /*break*/, 2];
7382
- // The activity is still active so the route change was triggered by the back button.
7383
- return [4 /*yield*/, this.interactionService.getCurrentActivity()];
7384
- case 1:
7385
- activity = _a.sent();
7386
- activity.cancel();
7387
- _a.label = 2;
7388
- case 2:
7389
- // IMPORTANT:
7390
- // We always return true, the router state engine will redirect as required. Return false
7391
- // during the guard causes all kinds of grief. It might be worth trying a redirect here
7392
- // again now that our state engine is more thorough.
7393
- return [2 /*return*/, true];
7679
+ url = this.placeRouter.parseUrl(state.url);
7680
+ if (!this.interactionService.isActive() && url.hasInteractionIds()) {
7681
+ // This happens if we reload the page or the url was pasted as the route should only be activated
7682
+ // after the interaction context has become active.
7683
+ return [2 /*return*/, url.removeInteractionIds()];
7394
7684
  }
7685
+ else {
7686
+ return [2 /*return*/, then()];
7687
+ }
7688
+ return [2 /*return*/];
7395
7689
  });
7396
7690
  });
7397
7691
  };
7398
- InteractionGuard.decorators = [
7399
- { type: Injectable, args: [{
7400
- providedIn: 'root'
7401
- },] }
7402
- ];
7403
- /** @nocollapse */
7404
- InteractionGuard.ctorParameters = function () { return [
7405
- { type: Router },
7406
- { type: Injector },
7407
- { type: PlaceRouter },
7408
- { type: Location },
7409
- { type: InteractionService }
7410
- ]; };
7411
- /** @nocollapse */ InteractionGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function InteractionGuard_Factory() { return new InteractionGuard(ɵɵinject(Router), ɵɵinject(INJECTOR), ɵɵinject(PlaceRouter), ɵɵinject(Location), ɵɵinject(InteractionService)); }, token: InteractionGuard, providedIn: "root" });
7412
- return InteractionGuard;
7692
+ return PlaceGuard;
7413
7693
  }());
7414
7694
  if (false) {
7415
7695
  /**
7416
7696
  * @type {?}
7417
7697
  * @private
7418
7698
  */
7419
- InteractionGuard.prototype.router;
7699
+ PlaceGuard.prototype.router;
7420
7700
  /**
7421
7701
  * @type {?}
7422
7702
  * @private
7423
7703
  */
7424
- InteractionGuard.prototype.injector;
7704
+ PlaceGuard.prototype.urlSerializer;
7425
7705
  /**
7426
7706
  * @type {?}
7427
7707
  * @private
7428
7708
  */
7429
- InteractionGuard.prototype.placeRouter;
7709
+ PlaceGuard.prototype.placeRouter;
7430
7710
  /**
7431
7711
  * @type {?}
7432
7712
  * @private
7433
7713
  */
7434
- InteractionGuard.prototype.angularLocation;
7714
+ PlaceGuard.prototype.placeHistory;
7435
7715
  /**
7436
7716
  * @type {?}
7437
7717
  * @private
7438
7718
  */
7439
- InteractionGuard.prototype.interactionService;
7440
- }
7441
-
7442
- /**
7443
- * @fileoverview added by tsickle
7444
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7445
- */
7446
- var NoopAuthGuard = /** @class */ (function () {
7447
- function NoopAuthGuard() {
7448
- }
7719
+ PlaceGuard.prototype.interactionService;
7449
7720
  /**
7450
- * @param {?} activatedRoute
7451
- * @param {?} state
7452
- * @return {?}
7721
+ * @type {?}
7722
+ * @private
7453
7723
  */
7454
- NoopAuthGuard.prototype.canActivate = /**
7455
- * @param {?} activatedRoute
7456
- * @param {?} state
7724
+ PlaceGuard.prototype.injector;
7725
+ /**
7726
+ * @abstract
7727
+ * @param {?} injector
7457
7728
  * @return {?}
7458
7729
  */
7459
- function (activatedRoute, state) {
7460
- return __awaiter(this, void 0, void 0, function () {
7461
- return __generator(this, function (_a) {
7462
- return [2 /*return*/, true];
7463
- });
7464
- });
7465
- };
7466
- NoopAuthGuard.decorators = [
7467
- { type: Injectable, args: [{
7468
- providedIn: 'root'
7469
- },] }
7470
- ];
7471
- /** @nocollapse */
7472
- NoopAuthGuard.ctorParameters = function () { return []; };
7473
- /** @nocollapse */ NoopAuthGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function NoopAuthGuard_Factory() { return new NoopAuthGuard(); }, token: NoopAuthGuard, providedIn: "root" });
7474
- return NoopAuthGuard;
7475
- }());
7730
+ PlaceGuard.prototype.getAuthGuard = function (injector) { };
7731
+ }
7476
7732
 
7477
7733
  /**
7478
7734
  * @fileoverview added by tsickle
@@ -7754,5 +8010,5 @@ if (false) {
7754
8010
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7755
8011
  */
7756
8012
 
7757
- export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractActivity, AbstractInputComponent, AbstractPlaceGuard, AbstractPlaceNavigationComponent, Activity, ActivityContainerComponent, ActivityOutletComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CommandDirective, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DialogInteractionContext, DialogInteractionContextFactory, Dimension, DirectivesModule, DisposableComponent, EmptyStateComponent, FocusBindingDirective, Formatter, InplaceInteractionContextComponent, InteractionContext, InteractionContextBase, InteractionGuard, InteractionModule, InteractionOutletComponent, InteractionService, LEFT_RIGHT_PLACE_ANIMATION, ListPlaceNavComponent, ModalInteractionContextFactory, NavigationState, NoopAuthGuard, NoopComponent, NumberInputComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, ROUTE_PARAMETER_LIST_KEY, ResizeAwareComponent, RouteId, SelectInputComponent, StringInputComponent, TabbedPlaceNavigationComponent, UrlSnapshot, Visit, VisitParameter, VisitParameterList, VisitSanitiser, leftRightPlaceAnimation, slideDownAndUpAnimation, DirectivesModule as ɵa, CommandDirective as ɵb, InteractionModule as ɵba, ActivityContainerComponent as ɵbb, InteractionContextBase as ɵbc, InteractionContext as ɵbd, ActivityOutletComponent as ɵbe, ConfirmationDialogComponent as ɵbf, AbstractActivity as ɵbg, ACTIVITY_DATA as ɵbh, Activity as ɵbi, ConfirmThenDialogComponent as ɵbk, AlertDialogComponent as ɵbl, InteractionOutletComponent as ɵbn, InplaceInteractionContextComponent as ɵbo, FocusBindingDirective as ɵc, DisposableComponent as ɵd, ComponentsModule as ɵe, NumberInputComponent as ɵf, AbstractInputComponent as ɵg, StringInputComponent as ɵh, PasswordInputComponent as ɵi, SelectInputComponent as ɵj, NoopComponent as ɵk, PlaceModule as ɵl, EmptyStateComponent as ɵm, BusyOverlayComponent as ɵn, PlaceOutletComponent as ɵo, leftRightPlaceAnimation as ɵp, LEFT_RIGHT_PLACE_ANIMATION as ɵq, AUP_PLACE_CONFIG as ɵr, PlaceRouter as ɵt, PlaceHistory as ɵu, InteractionService as ɵv, ModalInteractionContextFactory as ɵw, TabbedPlaceNavigationComponent as ɵx, AbstractPlaceNavigationComponent as ɵy, ListPlaceNavComponent as ɵz };
8013
+ export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractActivity, AbstractInputComponent, AbstractPlaceNavigationComponent, Activity, ActivityContainerComponent, ActivityOutletComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CommandDirective, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DialogInteractionContext, DialogInteractionContextFactory, Dimension, DirectivesModule, DisposableComponent, EmptyStateComponent, FocusBindingDirective, Formatter, InplaceInteractionContextComponent, InteractionContext, InteractionContextBase, InteractionModule, InteractionService, LEFT_RIGHT_PLACE_ANIMATION, ListPlaceNavComponent, ModalInteractionContextFactory, NavigationState, NoopAuthGuard, NoopComponent, NumberInputComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceGuard, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, ROUTE_PARAMETER_LIST_KEY, ResizeAwareComponent, RouteId, SelectInputComponent, StringInputComponent, TabbedPlaceNavigationComponent, UrlSnapshot, Visit, VisitParameter, VisitParameterList, VisitSanitiser, leftRightPlaceAnimation, slideDownAndUpAnimation, DirectivesModule as ɵa, CommandDirective as ɵb, InteractionModule as ɵba, ActivityContainerComponent as ɵbb, InteractionContextBase as ɵbc, InteractionContext as ɵbd, ActivityOutletComponent as ɵbe, ConfirmationDialogComponent as ɵbf, AbstractActivity as ɵbg, ACTIVITY_DATA as ɵbh, Activity as ɵbi, ConfirmThenDialogComponent as ɵbk, AlertDialogComponent as ɵbl, InplaceInteractionContextComponent as ɵbn, FocusBindingDirective as ɵc, DisposableComponent as ɵd, ComponentsModule as ɵe, NumberInputComponent as ɵf, AbstractInputComponent as ɵg, StringInputComponent as ɵh, PasswordInputComponent as ɵi, SelectInputComponent as ɵj, NoopComponent as ɵk, PlaceModule as ɵl, EmptyStateComponent as ɵm, BusyOverlayComponent as ɵn, PlaceOutletComponent as ɵo, leftRightPlaceAnimation as ɵp, LEFT_RIGHT_PLACE_ANIMATION as ɵq, AUP_PLACE_CONFIG as ɵr, PlaceRouter as ɵt, PlaceHistory as ɵu, InteractionService as ɵv, ModalInteractionContextFactory as ɵw, TabbedPlaceNavigationComponent as ɵx, AbstractPlaceNavigationComponent as ɵy, ListPlaceNavComponent as ɵz };
7758
8014
  //# sourceMappingURL=coolon-angular-ui-powerups.js.map