@coolon/angular-ui-powerups 0.0.116 → 0.0.118

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.
@@ -3786,6 +3786,7 @@ NavigationState = /** @class */ (function (_super) {
3786
3786
  var _this = _super.call(this) || this;
3787
3787
  _this.context = context;
3788
3788
  _this._visits = new Map();
3789
+ _this.debugPropertyKeys = [];
3789
3790
  return _this;
3790
3791
  }
3791
3792
  Object.defineProperty(NavigationState.prototype, "name", {
@@ -4006,14 +4007,18 @@ NavigationState = /** @class */ (function (_super) {
4006
4007
  function (event) {
4007
4008
  /** @type {?} */
4008
4009
  var popstate = event.navigationTrigger === 'popstate';
4009
- return popstate ?
4010
- this.interactionService.isActive() ?
4011
- new NavigationState.InteractionPopStateTransition(this.context, this.currentRouterUrl()) :
4012
- new NavigationState.PopStateTransition(this.context, this.currentRouterUrl())
4013
- :
4014
- this.interactionService.isActive() ?
4015
- new NavigationState.InteractionTransition(this.context, this.currentRouterUrl()) :
4016
- new NavigationState.NavigationTransition(this.context, this.currentRouterUrl());
4010
+ /** @type {?} */
4011
+ var inInteraction = this.interactionService.isActive();
4012
+ if (popstate) {
4013
+ return inInteraction ?
4014
+ new NavigationState.LeavingInteractionAfterPopStateTransition(this.context, this.currentRouterUrl(), event.url) :
4015
+ new NavigationState.PopStateTransition(this.context, this.currentRouterUrl(), event.url);
4016
+ }
4017
+ else {
4018
+ return inInteraction ?
4019
+ new NavigationState.StartingInteractionTransition(this.context, this.currentRouterUrl()) :
4020
+ new NavigationState.NavigationTransition(this.context, this.currentRouterUrl());
4021
+ }
4017
4022
  };
4018
4023
  /**
4019
4024
  * @protected
@@ -4028,17 +4033,36 @@ NavigationState = /** @class */ (function (_super) {
4028
4033
  new NavigationState.IdleDuringInteraction(this.context, this.currentRouterUrl()) :
4029
4034
  new NavigationState.Idle(this.context);
4030
4035
  };
4036
+ //
4037
+ //
4031
4038
  /**
4032
4039
  * @param {?} url
4033
4040
  * @return {?}
4034
4041
  */
4035
- NavigationState.prototype.resetBrowserLocation = /**
4042
+ NavigationState.prototype.resetBrowserLocation =
4043
+ //
4044
+ /**
4036
4045
  * @param {?} url
4037
4046
  * @return {?}
4038
4047
  */
4039
4048
  function (url) {
4040
4049
  this.placeRouter.resetBrowserLocation(url);
4041
4050
  };
4051
+ /**
4052
+ * @param {?} event
4053
+ * @param {?=} reason
4054
+ * @return {?}
4055
+ */
4056
+ NavigationState.prototype.ignore = /**
4057
+ * @param {?} event
4058
+ * @param {?=} reason
4059
+ * @return {?}
4060
+ */
4061
+ function (event, reason) {
4062
+ reason = reason ? " -> " + reason : '';
4063
+ Logger.get(this).info("Ignoring router event" + reason + ": " + event.constructor.name + " -> " + event.url + " :: " + this.toString());
4064
+ return this;
4065
+ };
4042
4066
  /**
4043
4067
  * @return {?}
4044
4068
  */
@@ -4046,7 +4070,27 @@ NavigationState = /** @class */ (function (_super) {
4046
4070
  * @return {?}
4047
4071
  */
4048
4072
  function () {
4049
- return this.constructor.name;
4073
+ return this.constructor.name + "(" + this.debugState() + ")";
4074
+ };
4075
+ /**
4076
+ * @protected
4077
+ * @param {?=} properties
4078
+ * @return {?}
4079
+ */
4080
+ NavigationState.prototype.debugState = /**
4081
+ * @protected
4082
+ * @param {?=} properties
4083
+ * @return {?}
4084
+ */
4085
+ function (properties) {
4086
+ var _this = this;
4087
+ return (properties || this.debugPropertyKeys).map((/**
4088
+ * @param {?} p
4089
+ * @return {?}
4090
+ */
4091
+ function (p) {
4092
+ return p + ": " + _this[p];
4093
+ })).join(', ');
4050
4094
  };
4051
4095
  return NavigationState;
4052
4096
  }(GarbageCollector));
@@ -4062,6 +4106,8 @@ if (false) {
4062
4106
  NavigationState.prototype.startingUrl;
4063
4107
  /** @type {?} */
4064
4108
  NavigationState.prototype.isPopState;
4109
+ /** @type {?} */
4110
+ NavigationState.prototype.debugPropertyKeys;
4065
4111
  /**
4066
4112
  * @type {?}
4067
4113
  * @protected
@@ -4127,7 +4173,7 @@ if (false) {
4127
4173
  }
4128
4174
  if (this.placeRouter.hasActiveInteractionIds(event.url)) {
4129
4175
  Logger.get(this).info("navigation started with interaction outlet -> " + event.url);
4130
- return new InteractionTransition(this.context, event.url);
4176
+ return new StartingInteractionTransition(this.context, event.url);
4131
4177
  }
4132
4178
  else {
4133
4179
  return this.createTransitionStateFor(event);
@@ -4220,14 +4266,14 @@ if (false) {
4220
4266
  return new Idle(this.context);
4221
4267
  };
4222
4268
  /**
4223
- * @param {?} locationTriggerUrl
4269
+ * @param {?} newUrl
4224
4270
  * @return {?}
4225
4271
  */
4226
4272
  AbstractNavigationTransition.prototype.onBackClickedDuringNavigationInteraction = /**
4227
- * @param {?} locationTriggerUrl
4273
+ * @param {?} newUrl
4228
4274
  * @return {?}
4229
4275
  */
4230
- function (locationTriggerUrl) {
4276
+ function (newUrl) {
4231
4277
  Logger.get(this).info("back button pressed during navigation session interaction promise");
4232
4278
  // detach the interaction from the session so it doesn't get disposed until the activity has completed.
4233
4279
  /** @type {?} */
@@ -4235,25 +4281,22 @@ if (false) {
4235
4281
  var when = Dsl.disposeWith(navigationInteraction).when;
4236
4282
  // TODO: I need to make the exclusive interaction context disallow nested activities or
4237
4283
  // that would mess things up entirely. Or, can I do a context.abortAll().then(..)
4284
+ Logger.get(this).info('cancelling current navigation activity..');
4238
4285
  navigationInteraction.cancelActiveActivity().then((/**
4239
4286
  * @return {?}
4240
4287
  */
4241
4288
  function () {
4242
4289
  navigationInteraction.dispose();
4243
4290
  }));
4244
- return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, this.isPopState, locationTriggerUrl);
4291
+ return this.createNavigationInteractionCancelledState(newUrl);
4245
4292
  };
4246
- // @Trace()
4247
- // @Trace()
4248
4293
  /**
4249
4294
  * @param {?} component
4250
4295
  * @param {?} currentUrl
4251
4296
  * @param {?} nextUrl
4252
4297
  * @return {?}
4253
4298
  */
4254
- AbstractNavigationTransition.prototype.canDeactivatePlace =
4255
- // @Trace()
4256
- /**
4299
+ AbstractNavigationTransition.prototype.canDeactivatePlace = /**
4257
4300
  * @param {?} component
4258
4301
  * @param {?} currentUrl
4259
4302
  * @param {?} nextUrl
@@ -4275,11 +4318,11 @@ if (false) {
4275
4318
  });
4276
4319
  };
4277
4320
  /**
4278
- * @private
4321
+ * @protected
4279
4322
  * @return {?}
4280
4323
  */
4281
4324
  AbstractNavigationTransition.prototype.detachInteractionContext = /**
4282
- * @private
4325
+ * @protected
4283
4326
  * @return {?}
4284
4327
  */
4285
4328
  function () {
@@ -4306,12 +4349,19 @@ if (false) {
4306
4349
  AbstractNavigationTransition.prototype._interactionContext;
4307
4350
  /** @type {?} */
4308
4351
  AbstractNavigationTransition.prototype.startingUrl;
4352
+ /**
4353
+ * @abstract
4354
+ * @param {?} newUrl
4355
+ * @return {?}
4356
+ */
4357
+ AbstractNavigationTransition.prototype.createNavigationInteractionCancelledState = function (newUrl) { };
4309
4358
  }
4310
4359
  var NavigationTransition = /** @class */ (function (_super) {
4311
4360
  __extends(NavigationTransition, _super);
4312
4361
  function NavigationTransition() {
4313
4362
  var _this = _super !== null && _super.apply(this, arguments) || this;
4314
4363
  _this.isPopState = false;
4364
+ _this.debugPropertyKeys = ['startingUrl'];
4315
4365
  return _this;
4316
4366
  }
4317
4367
  /**
@@ -4338,13 +4388,15 @@ if (false) {
4338
4388
  return new Idle(this.context);
4339
4389
  };
4340
4390
  /**
4391
+ * @param {?} newUrl
4341
4392
  * @return {?}
4342
4393
  */
4343
- NavigationTransition.prototype.toString = /**
4394
+ NavigationTransition.prototype.createNavigationInteractionCancelledState = /**
4395
+ * @param {?} newUrl
4344
4396
  * @return {?}
4345
4397
  */
4346
- function () {
4347
- return this.constructor.name + "(startingUrl: " + this.startingUrl + ")";
4398
+ function (newUrl) {
4399
+ return new LinkTriggeredNavigationInteractionCancelled(this.context, this.startingUrl, newUrl);
4348
4400
  };
4349
4401
  return NavigationTransition;
4350
4402
  }(AbstractNavigationTransition));
@@ -4352,12 +4404,16 @@ if (false) {
4352
4404
  if (false) {
4353
4405
  /** @type {?} */
4354
4406
  NavigationTransition.prototype.isPopState;
4407
+ /** @type {?} */
4408
+ NavigationTransition.prototype.debugPropertyKeys;
4355
4409
  }
4356
4410
  var PopStateTransition = /** @class */ (function (_super) {
4357
4411
  __extends(PopStateTransition, _super);
4358
- function PopStateTransition() {
4359
- var _this = _super !== null && _super.apply(this, arguments) || this;
4412
+ function PopStateTransition(context, startingUrl, poppedHistoryUrl) {
4413
+ var _this = _super.call(this, context, startingUrl) || this;
4414
+ _this.poppedHistoryUrl = poppedHistoryUrl;
4360
4415
  _this.isPopState = true;
4416
+ _this.debugPropertyKeys = ['startingUrl', 'poppedHistoryUrl'];
4361
4417
  return _this;
4362
4418
  }
4363
4419
  /**
@@ -4372,7 +4428,8 @@ if (false) {
4372
4428
  // Angular doesn't preserve the url when a guard cancels the back button.
4373
4429
  // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4374
4430
  Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4375
- this.resetBrowserLocation(this.startingUrl);
4431
+ this.resetBrowserLocation(this.poppedHistoryUrl); // put the popped history item back in.
4432
+ this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
4376
4433
  return new Idle(this.context);
4377
4434
  };
4378
4435
  /**
@@ -4389,24 +4446,75 @@ if (false) {
4389
4446
  // Angular doesn't preserve the url when a guard cancels the back button.
4390
4447
  // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4391
4448
  Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4392
- this.resetBrowserLocation(this.startingUrl);
4449
+ this.resetBrowserLocation(this.poppedHistoryUrl); // put the popped history item back in.
4450
+ this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
4393
4451
  }
4394
4452
  return new Idle(this.context);
4395
4453
  };
4454
+ /**
4455
+ * @param {?} locationTriggerUrl
4456
+ * @return {?}
4457
+ */
4458
+ PopStateTransition.prototype.createNavigationInteractionCancelledState = /**
4459
+ * @param {?} locationTriggerUrl
4460
+ * @return {?}
4461
+ */
4462
+ function (locationTriggerUrl) {
4463
+ return new PopStateTriggeredNavigationInteractionCancelled(this.context, this.startingUrl, locationTriggerUrl, this.poppedHistoryUrl);
4464
+ };
4396
4465
  return PopStateTransition;
4397
4466
  }(AbstractNavigationTransition));
4398
4467
  NavigationState.PopStateTransition = PopStateTransition;
4399
4468
  if (false) {
4400
4469
  /** @type {?} */
4401
4470
  PopStateTransition.prototype.isPopState;
4471
+ /** @type {?} */
4472
+ PopStateTransition.prototype.debugPropertyKeys;
4473
+ /** @type {?} */
4474
+ PopStateTransition.prototype.poppedHistoryUrl;
4475
+ }
4476
+ /**
4477
+ * @abstract
4478
+ */
4479
+ var /**
4480
+ * @abstract
4481
+ */
4482
+ AbstractInteractionTransition = /** @class */ (function (_super) {
4483
+ __extends(AbstractInteractionTransition, _super);
4484
+ function AbstractInteractionTransition(context, startingUrl) {
4485
+ var _this = _super.call(this, context, startingUrl) || this;
4486
+ _this.startingUrl = startingUrl;
4487
+ _this.isTransitional = true;
4488
+ return _this;
4489
+ }
4490
+ return AbstractInteractionTransition;
4491
+ }(AbstractNavigationTransition));
4492
+ NavigationState.AbstractInteractionTransition = AbstractInteractionTransition;
4493
+ if (false) {
4494
+ /** @type {?} */
4495
+ AbstractInteractionTransition.prototype.isTransitional;
4496
+ /** @type {?} */
4497
+ AbstractInteractionTransition.prototype.startingUrl;
4402
4498
  }
4403
- var IdleDuringInteraction = /** @class */ (function (_super) {
4499
+ // The following states exist to handle all events while any kind of navigation is in progress. That way all other states can
4500
+ // happily ignore interaction contexts.
4501
+ /**
4502
+ * This is the non transitional (i.e. rest) state that is used whenever an interaction context is active.
4503
+ */
4504
+ var
4505
+ // The following states exist to handle all events while any kind of navigation is in progress. That way all other states can
4506
+ // happily ignore interaction contexts.
4507
+ /**
4508
+ * This is the non transitional (i.e. rest) state that is used whenever an interaction context is active.
4509
+ */
4510
+ IdleDuringInteraction = /** @class */ (function (_super) {
4404
4511
  __extends(IdleDuringInteraction, _super);
4405
4512
  function IdleDuringInteraction(context, startingUrl) {
4406
4513
  var _this = _super.call(this, context) || this;
4407
4514
  _this.startingUrl = startingUrl;
4408
4515
  _this.isTransitional = false;
4409
4516
  _this.isPopState = false;
4517
+ _this.debugPropertyKeys = ['startingUrl'];
4410
4518
  return _this;
4411
4519
  }
4412
4520
  /**
@@ -4420,40 +4528,34 @@ if (false) {
4420
4528
  * @return {?}
4421
4529
  */
4422
4530
  function (visit, initialUrl) {
4531
+ // we're in an interaction and the user clicked back
4423
4532
  /** @type {?} */
4424
- var navigationTransition = new InteractionTransition(this.context, initialUrl);
4533
+ var navigationTransition = new StartingInteractionTransition(this.context, initialUrl);
4425
4534
  navigationTransition.storeVisit(visit);
4426
4535
  return navigationTransition;
4427
4536
  };
4428
- // @Trace()
4429
- // @Trace()
4430
4537
  /**
4431
4538
  * @param {?} event
4432
4539
  * @return {?}
4433
4540
  */
4434
- IdleDuringInteraction.prototype.onRouterStarted =
4435
- // @Trace()
4436
- /**
4541
+ IdleDuringInteraction.prototype.onRouterStarted = /**
4437
4542
  * @param {?} event
4438
4543
  * @return {?}
4439
4544
  */
4440
4545
  function (event) {
4441
- return new InteractionTransition(this.context, event.url);
4546
+ return new StartingInteractionTransition(this.context, event.url);
4442
4547
  };
4443
- // @Trace()
4444
- // @Trace()
4445
4548
  /**
4446
4549
  * @param {?} event
4447
4550
  * @return {?}
4448
4551
  */
4449
- IdleDuringInteraction.prototype.onPopState =
4450
- // @Trace()
4451
- /**
4552
+ IdleDuringInteraction.prototype.onPopState = /**
4452
4553
  * @param {?} event
4453
4554
  * @return {?}
4454
4555
  */
4455
4556
  function (event) {
4456
- return new InteractionPopStateTransition(this.context, event.url);
4557
+ // we're in an interaction and the user clicked back
4558
+ return new LeavingInteractionAfterPopStateTransition(this.context, event.url, event.url);
4457
4559
  };
4458
4560
  return IdleDuringInteraction;
4459
4561
  }(NavigationState));
@@ -4464,55 +4566,34 @@ if (false) {
4464
4566
  /** @type {?} */
4465
4567
  IdleDuringInteraction.prototype.isPopState;
4466
4568
  /** @type {?} */
4467
- IdleDuringInteraction.prototype.startingUrl;
4468
- }
4469
- /**
4470
- * @abstract
4471
- */
4472
- var /**
4473
- * @abstract
4474
- */
4475
- AbstractInteractionTransition = /** @class */ (function (_super) {
4476
- __extends(AbstractInteractionTransition, _super);
4477
- function AbstractInteractionTransition(context, startingUrl) {
4478
- var _this = _super.call(this, context, startingUrl) || this;
4479
- _this.startingUrl = startingUrl;
4480
- _this.isTransitional = true;
4481
- return _this;
4482
- }
4483
- return AbstractInteractionTransition;
4484
- }(AbstractNavigationTransition));
4485
- NavigationState.AbstractInteractionTransition = AbstractInteractionTransition;
4486
- if (false) {
4569
+ IdleDuringInteraction.prototype.debugPropertyKeys;
4487
4570
  /** @type {?} */
4488
- AbstractInteractionTransition.prototype.isTransitional;
4489
- /** @type {?} */
4490
- AbstractInteractionTransition.prototype.startingUrl;
4571
+ IdleDuringInteraction.prototype.startingUrl;
4491
4572
  }
4492
4573
  /**
4493
4574
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4494
4575
  * happily ignore interaction contexts.
4576
+ * NOTE: This state is activated when ever an interaction is started. It might be better to split it into
4577
+ * different states for different scenarios, e.g. starting model, starting model during route guard etc.
4495
4578
  */
4496
4579
  var /**
4497
4580
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4498
4581
  * happily ignore interaction contexts.
4582
+ * NOTE: This state is activated when ever an interaction is started. It might be better to split it into
4583
+ * different states for different scenarios, e.g. starting model, starting model during route guard etc.
4499
4584
  */
4500
- InteractionTransition = /** @class */ (function (_super) {
4501
- __extends(InteractionTransition, _super);
4502
- function InteractionTransition() {
4585
+ StartingInteractionTransition = /** @class */ (function (_super) {
4586
+ __extends(StartingInteractionTransition, _super);
4587
+ function StartingInteractionTransition() {
4503
4588
  var _this = _super !== null && _super.apply(this, arguments) || this;
4504
4589
  _this.isPopState = false;
4505
4590
  return _this;
4506
4591
  }
4507
- // @Trace()
4508
- // @Trace()
4509
4592
  /**
4510
4593
  * @param {?} event
4511
4594
  * @return {?}
4512
4595
  */
4513
- InteractionTransition.prototype.onRouterCancelled =
4514
- // @Trace()
4515
- /**
4596
+ StartingInteractionTransition.prototype.onRouterCancelled = /**
4516
4597
  * @param {?} event
4517
4598
  * @return {?}
4518
4599
  */
@@ -4527,15 +4608,11 @@ if (false) {
4527
4608
  return new Idle(this.context);
4528
4609
  }
4529
4610
  };
4530
- // @Trace()
4531
- // @Trace()
4532
4611
  /**
4533
4612
  * @param {?} event
4534
4613
  * @return {?}
4535
4614
  */
4536
- InteractionTransition.prototype.onRouterError =
4537
- // @Trace()
4538
- /**
4615
+ StartingInteractionTransition.prototype.onRouterError = /**
4539
4616
  * @param {?} event
4540
4617
  * @return {?}
4541
4618
  */
@@ -4543,15 +4620,11 @@ if (false) {
4543
4620
  // navigation was aborted.
4544
4621
  return new IdleDuringInteraction(this.context, this.startingUrl);
4545
4622
  };
4546
- // @Trace()
4547
- // @Trace()
4548
4623
  /**
4549
4624
  * @param {?} event
4550
4625
  * @return {?}
4551
4626
  */
4552
- InteractionTransition.prototype.onRouterEnd =
4553
- // @Trace()
4554
- /**
4627
+ StartingInteractionTransition.prototype.onRouterEnd = /**
4555
4628
  * @param {?} event
4556
4629
  * @return {?}
4557
4630
  */
@@ -4563,12 +4636,163 @@ if (false) {
4563
4636
  return new Idle(this.context);
4564
4637
  }
4565
4638
  };
4566
- return InteractionTransition;
4639
+ /**
4640
+ * @param {?} locationTriggerUrl
4641
+ * @return {?}
4642
+ */
4643
+ StartingInteractionTransition.prototype.createNavigationInteractionCancelledState = /**
4644
+ * @param {?} locationTriggerUrl
4645
+ * @return {?}
4646
+ */
4647
+ function (locationTriggerUrl) {
4648
+ return new LeavingInteractionTransitionCancelled(this.context, this.startingUrl, locationTriggerUrl);
4649
+ };
4650
+ return StartingInteractionTransition;
4567
4651
  }(AbstractInteractionTransition));
4568
- NavigationState.InteractionTransition = InteractionTransition;
4652
+ NavigationState.StartingInteractionTransition = StartingInteractionTransition;
4653
+ if (false) {
4654
+ /** @type {?} */
4655
+ StartingInteractionTransition.prototype.isPopState;
4656
+ }
4657
+ /**
4658
+ * The sequence of router events are:
4659
+ * Error -> url = url of navigation link
4660
+ * End
4661
+ * onPopState url = current intereaction url sans the query params
4662
+ * Cancel url == same as above.
4663
+ */
4664
+ var /**
4665
+ * The sequence of router events are:
4666
+ * Error -> url = url of navigation link
4667
+ * End
4668
+ * onPopState url = current intereaction url sans the query params
4669
+ * Cancel url == same as above.
4670
+ */
4671
+ LeavingInteractionTransitionCancelled = /** @class */ (function (_super) {
4672
+ __extends(LeavingInteractionTransitionCancelled, _super);
4673
+ function LeavingInteractionTransitionCancelled(context, startingUrl, locationChangeTriggerUrl) {
4674
+ var _this = _super.call(this, context) || this;
4675
+ _this.startingUrl = startingUrl;
4676
+ _this.locationChangeTriggerUrl = locationChangeTriggerUrl;
4677
+ _this.isPopState = false;
4678
+ _this.firstCancelHandled = false;
4679
+ _this.popStateHandled = false;
4680
+ _this.debugPropertyKeys = ['idle', 'startingUrl', 'poppedHistoryUrl', 'locationChangeTriggerUrl', 'popStateEventUrl', 'firstCancelHandled', 'popStateHandled'];
4681
+ return _this;
4682
+ }
4683
+ Object.defineProperty(LeavingInteractionTransitionCancelled.prototype, "isTransitional", {
4684
+ get: /**
4685
+ * @return {?}
4686
+ */
4687
+ function () {
4688
+ return true;
4689
+ },
4690
+ enumerable: true,
4691
+ configurable: true
4692
+ });
4693
+ /**
4694
+ * @param {?} event
4695
+ * @return {?}
4696
+ */
4697
+ LeavingInteractionTransitionCancelled.prototype.onRouterStarted = /**
4698
+ * @param {?} event
4699
+ * @return {?}
4700
+ */
4701
+ function (event) {
4702
+ return this.ignore(event);
4703
+ };
4704
+ /**
4705
+ * @param {?} event
4706
+ * @return {?}
4707
+ */
4708
+ LeavingInteractionTransitionCancelled.prototype.onRouterCancelled = /**
4709
+ * @param {?} event
4710
+ * @return {?}
4711
+ */
4712
+ function (event) {
4713
+ // Angular doesn't preserve the url when a guard cancels the back button.
4714
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4715
+ Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4716
+ if (this.interactionService.isActive()) {
4717
+ /** @type {?} */
4718
+ var interactionIds = this.interactionService.activeInteractionContextIds.value;
4719
+ this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
4720
+ }
4721
+ else {
4722
+ this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
4723
+ }
4724
+ return this.createIdleState();
4725
+ };
4726
+ /**
4727
+ * @param {?} event
4728
+ * @return {?}
4729
+ */
4730
+ LeavingInteractionTransitionCancelled.prototype.onRouterEnd = /**
4731
+ * @param {?} event
4732
+ * @return {?}
4733
+ */
4734
+ function (event) {
4735
+ return this.ignore(event);
4736
+ };
4737
+ /**
4738
+ * @param {?} event
4739
+ * @return {?}
4740
+ */
4741
+ LeavingInteractionTransitionCancelled.prototype.onRouterError = /**
4742
+ * @param {?} event
4743
+ * @return {?}
4744
+ */
4745
+ function (event) {
4746
+ return this.ignore(event);
4747
+ };
4748
+ /**
4749
+ * @param {?} event
4750
+ * @return {?}
4751
+ */
4752
+ LeavingInteractionTransitionCancelled.prototype.onPopState = /**
4753
+ * @param {?} event
4754
+ * @return {?}
4755
+ */
4756
+ function (event) {
4757
+ return this.ignore(event);
4758
+ };
4759
+ /**
4760
+ * @param {?} component
4761
+ * @param {?} currentUrl
4762
+ * @param {?} nextUrl
4763
+ * @return {?}
4764
+ */
4765
+ LeavingInteractionTransitionCancelled.prototype.canDeactivatePlace = /**
4766
+ * @param {?} component
4767
+ * @param {?} currentUrl
4768
+ * @param {?} nextUrl
4769
+ * @return {?}
4770
+ */
4771
+ function (component, currentUrl, nextUrl) {
4772
+ return __awaiter(this, void 0, void 0, function () {
4773
+ return __generator(this, function (_a) {
4774
+ return [2 /*return*/, false];
4775
+ });
4776
+ });
4777
+ };
4778
+ return LeavingInteractionTransitionCancelled;
4779
+ }(NavigationState));
4780
+ NavigationState.LeavingInteractionTransitionCancelled = LeavingInteractionTransitionCancelled;
4569
4781
  if (false) {
4570
4782
  /** @type {?} */
4571
- InteractionTransition.prototype.isPopState;
4783
+ LeavingInteractionTransitionCancelled.prototype.isPopState;
4784
+ /** @type {?} */
4785
+ LeavingInteractionTransitionCancelled.prototype.firstCancelHandled;
4786
+ /** @type {?} */
4787
+ LeavingInteractionTransitionCancelled.prototype.popStateHandled;
4788
+ /** @type {?} */
4789
+ LeavingInteractionTransitionCancelled.prototype.popStateEventUrl;
4790
+ /** @type {?} */
4791
+ LeavingInteractionTransitionCancelled.prototype.debugPropertyKeys;
4792
+ /** @type {?} */
4793
+ LeavingInteractionTransitionCancelled.prototype.startingUrl;
4794
+ /** @type {?} */
4795
+ LeavingInteractionTransitionCancelled.prototype.locationChangeTriggerUrl;
4572
4796
  }
4573
4797
  /**
4574
4798
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
@@ -4578,22 +4802,19 @@ if (false) {
4578
4802
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4579
4803
  * happily ignore interaction contexts.
4580
4804
  */
4581
- InteractionPopStateTransition = /** @class */ (function (_super) {
4582
- __extends(InteractionPopStateTransition, _super);
4583
- function InteractionPopStateTransition() {
4584
- var _this = _super !== null && _super.apply(this, arguments) || this;
4805
+ LeavingInteractionAfterPopStateTransition = /** @class */ (function (_super) {
4806
+ __extends(LeavingInteractionAfterPopStateTransition, _super);
4807
+ function LeavingInteractionAfterPopStateTransition(context, startingUrl, poppedHistoryUrl) {
4808
+ var _this = _super.call(this, context, startingUrl) || this;
4809
+ _this.poppedHistoryUrl = poppedHistoryUrl;
4585
4810
  _this.isPopState = true;
4586
4811
  return _this;
4587
4812
  }
4588
- // @Trace()
4589
- // @Trace()
4590
4813
  /**
4591
4814
  * @param {?} event
4592
4815
  * @return {?}
4593
4816
  */
4594
- InteractionPopStateTransition.prototype.onRouterCancelled =
4595
- // @Trace()
4596
- /**
4817
+ LeavingInteractionAfterPopStateTransition.prototype.onRouterCancelled = /**
4597
4818
  * @param {?} event
4598
4819
  * @return {?}
4599
4820
  */
@@ -4608,15 +4829,11 @@ if (false) {
4608
4829
  return new Idle(this.context);
4609
4830
  }
4610
4831
  };
4611
- // @Trace()
4612
- // @Trace()
4613
4832
  /**
4614
4833
  * @param {?} event
4615
4834
  * @return {?}
4616
4835
  */
4617
- InteractionPopStateTransition.prototype.onRouterEnd =
4618
- // @Trace()
4619
- /**
4836
+ LeavingInteractionAfterPopStateTransition.prototype.onRouterEnd = /**
4620
4837
  * @param {?} event
4621
4838
  * @return {?}
4622
4839
  */
@@ -4628,25 +4845,219 @@ if (false) {
4628
4845
  return new Idle(this.context);
4629
4846
  }
4630
4847
  };
4631
- return InteractionPopStateTransition;
4848
+ /**
4849
+ * @param {?} newUrl
4850
+ * @return {?}
4851
+ */
4852
+ LeavingInteractionAfterPopStateTransition.prototype.createNavigationInteractionCancelledState = /**
4853
+ * @param {?} newUrl
4854
+ * @return {?}
4855
+ */
4856
+ function (newUrl) {
4857
+ return this.illegalTransition("Leaving interaction after pop-state should't block so should never see a back button click");
4858
+ };
4859
+ return LeavingInteractionAfterPopStateTransition;
4632
4860
  }(AbstractInteractionTransition));
4633
- NavigationState.InteractionPopStateTransition = InteractionPopStateTransition;
4861
+ NavigationState.LeavingInteractionAfterPopStateTransition = LeavingInteractionAfterPopStateTransition;
4634
4862
  if (false) {
4635
4863
  /** @type {?} */
4636
- InteractionPopStateTransition.prototype.isPopState;
4864
+ LeavingInteractionAfterPopStateTransition.prototype.isPopState;
4865
+ /** @type {?} */
4866
+ LeavingInteractionAfterPopStateTransition.prototype.poppedHistoryUrl;
4637
4867
  }
4638
- var CancelledDuringNavigationInteraction = /** @class */ (function (_super) {
4639
- __extends(CancelledDuringNavigationInteraction, _super);
4640
- function CancelledDuringNavigationInteraction(context, startingUrl, startingEventWasAPopState, locationChangeTriggerUrl) {
4868
+ // See LeavingInteractionAfterPopStateTransition.createNavigationInteractionCancelledState(...) above.
4869
+ //
4870
+ // export class LeavingInteractionAfterPopStateCancelled extends NavigationState {
4871
+ //
4872
+ // readonly isPopState = false;
4873
+ // firstCancelHandled = false;
4874
+ // popStateHandled = false;
4875
+ // popStateEventUrl: string;
4876
+ // debugPropertyKeys = ['idle', 'startingUrl', 'poppedHistoryUrl', 'locationChangeTriggerUrl', 'popStateEventUrl', 'firstCancelHandled', 'popStateHandled'];
4877
+ //
4878
+ // constructor(context: Context,
4879
+ // readonly startingUrl: string,
4880
+ // readonly locationChangeTriggerUrl: string,
4881
+ // readonly poppedHistoryUrl: string) {
4882
+ // super(context);
4883
+ // }
4884
+ //
4885
+ // get isTransitional() {
4886
+ // return true;
4887
+ // }
4888
+ //
4889
+ // onRouterStarted(event: NavigationStart): NavigationState {
4890
+ // return this.ignore(event);
4891
+ // }
4892
+ //
4893
+ //
4894
+ // onRouterCancelled(event: NavigationCancel): NavigationState {
4895
+ //
4896
+ // // if (this.firstCancelHandled && this.popStateHandled) {
4897
+ // // // Angular doesn't preserve the url when a guard cancels the back button.
4898
+ // // // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4899
+ // // Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4900
+ // // this.resetBrowserLocation(this.locationChangeTriggerUrl); // put the second back click one back in.
4901
+ // // this.resetBrowserLocation(this.poppedHistoryUrl); // put the first back click one back in.
4902
+ // // if (this.interactionService.isActive()) {
4903
+ // // const interactionIds = this.interactionService.activeInteractionContextIds.value;
4904
+ // // this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
4905
+ // // } else {
4906
+ // // this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
4907
+ // // }
4908
+ // // return this.createIdleState();
4909
+ // // } else {
4910
+ // // this.firstCancelHandled = true;
4911
+ // return this.ignore(event);
4912
+ // // }
4913
+ // }
4914
+ //
4915
+ //
4916
+ // onRouterEnd(event: NavigationEnd): NavigationState {
4917
+ // return this.ignore(event);
4918
+ // }
4919
+ //
4920
+ //
4921
+ // onRouterError(event: NavigationError): NavigationState {
4922
+ // return this.ignore(event);
4923
+ // }
4924
+ //
4925
+ //
4926
+ // onPopState(event: NavigationStart): NavigationState {
4927
+ // // this.popStateHandled = true;
4928
+ // // this.popStateEventUrl = event.url;
4929
+ // return this.ignore(event);
4930
+ // }
4931
+ //
4932
+ // async canDeactivatePlace(component: PlaceComponent, currentUrl: UrlSnapshot, nextUrl: UrlSnapshot): Promise<boolean | UrlSnapshot> {
4933
+ // return false;
4934
+ // }
4935
+ // }
4936
+ /**
4937
+ * This state handles the scenario where a link navigation triggered an interaction and the user clicked back a to cancel it.
4938
+ * The routing event sequence is different depending on the link that was clicked.
4939
+ *
4940
+ * If the link was the same as the previous history location (i.e. they've gone back via a link rather than clicking back) then the sequence is:
4941
+ *
4942
+ * -> Idle -> NavigationTransition
4943
+ * -> confirm dialog shown.
4944
+ * -> click back
4945
+ * -> NavigationCancel -> clickedLinkUrl === cancel.url
4946
+ * -> NavigationEnd
4947
+ *
4948
+ * Otherwise if the link is different from teh history location then the sequence is:
4949
+ *
4950
+ * -> Idle -> NavigationTransition
4951
+ * -> confirm dialog shown.
4952
+ * -> click back
4953
+ * -> NavigationCancel -> clickedLinkUrl !== cancel.url
4954
+ * -> NavigationEnd
4955
+ * -> PopState
4956
+ * -> NavigationCancel
4957
+ */
4958
+ var
4959
+ // See LeavingInteractionAfterPopStateTransition.createNavigationInteractionCancelledState(...) above.
4960
+ //
4961
+ // export class LeavingInteractionAfterPopStateCancelled extends NavigationState {
4962
+ //
4963
+ // readonly isPopState = false;
4964
+ // firstCancelHandled = false;
4965
+ // popStateHandled = false;
4966
+ // popStateEventUrl: string;
4967
+ // debugPropertyKeys = ['idle', 'startingUrl', 'poppedHistoryUrl', 'locationChangeTriggerUrl', 'popStateEventUrl', 'firstCancelHandled', 'popStateHandled'];
4968
+ //
4969
+ // constructor(context: Context,
4970
+ // readonly startingUrl: string,
4971
+ // readonly locationChangeTriggerUrl: string,
4972
+ // readonly poppedHistoryUrl: string) {
4973
+ // super(context);
4974
+ // }
4975
+ //
4976
+ // get isTransitional() {
4977
+ // return true;
4978
+ // }
4979
+ //
4980
+ // onRouterStarted(event: NavigationStart): NavigationState {
4981
+ // return this.ignore(event);
4982
+ // }
4983
+ //
4984
+ //
4985
+ // onRouterCancelled(event: NavigationCancel): NavigationState {
4986
+ //
4987
+ // // if (this.firstCancelHandled && this.popStateHandled) {
4988
+ // // // Angular doesn't preserve the url when a guard cancels the back button.
4989
+ // // // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4990
+ // // Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4991
+ // // this.resetBrowserLocation(this.locationChangeTriggerUrl); // put the second back click one back in.
4992
+ // // this.resetBrowserLocation(this.poppedHistoryUrl); // put the first back click one back in.
4993
+ // // if (this.interactionService.isActive()) {
4994
+ // // const interactionIds = this.interactionService.activeInteractionContextIds.value;
4995
+ // // this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
4996
+ // // } else {
4997
+ // // this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
4998
+ // // }
4999
+ // // return this.createIdleState();
5000
+ // // } else {
5001
+ // // this.firstCancelHandled = true;
5002
+ // return this.ignore(event);
5003
+ // // }
5004
+ // }
5005
+ //
5006
+ //
5007
+ // onRouterEnd(event: NavigationEnd): NavigationState {
5008
+ // return this.ignore(event);
5009
+ // }
5010
+ //
5011
+ //
5012
+ // onRouterError(event: NavigationError): NavigationState {
5013
+ // return this.ignore(event);
5014
+ // }
5015
+ //
5016
+ //
5017
+ // onPopState(event: NavigationStart): NavigationState {
5018
+ // // this.popStateHandled = true;
5019
+ // // this.popStateEventUrl = event.url;
5020
+ // return this.ignore(event);
5021
+ // }
5022
+ //
5023
+ // async canDeactivatePlace(component: PlaceComponent, currentUrl: UrlSnapshot, nextUrl: UrlSnapshot): Promise<boolean | UrlSnapshot> {
5024
+ // return false;
5025
+ // }
5026
+ // }
5027
+ /**
5028
+ * This state handles the scenario where a link navigation triggered an interaction and the user clicked back a to cancel it.
5029
+ * The routing event sequence is different depending on the link that was clicked.
5030
+ *
5031
+ * If the link was the same as the previous history location (i.e. they've gone back via a link rather than clicking back) then the sequence is:
5032
+ *
5033
+ * -> Idle -> NavigationTransition
5034
+ * -> confirm dialog shown.
5035
+ * -> click back
5036
+ * -> NavigationCancel -> clickedLinkUrl === cancel.url
5037
+ * -> NavigationEnd
5038
+ *
5039
+ * Otherwise if the link is different from teh history location then the sequence is:
5040
+ *
5041
+ * -> Idle -> NavigationTransition
5042
+ * -> confirm dialog shown.
5043
+ * -> click back
5044
+ * -> NavigationCancel -> clickedLinkUrl !== cancel.url
5045
+ * -> NavigationEnd
5046
+ * -> PopState
5047
+ * -> NavigationCancel
5048
+ */
5049
+ LinkTriggeredNavigationInteractionCancelled = /** @class */ (function (_super) {
5050
+ __extends(LinkTriggeredNavigationInteractionCancelled, _super);
5051
+ function LinkTriggeredNavigationInteractionCancelled(context, startingUrl, clickedLinkUrl) {
4641
5052
  var _this = _super.call(this, context) || this;
4642
5053
  _this.startingUrl = startingUrl;
4643
- _this.startingEventWasAPopState = startingEventWasAPopState;
4644
- _this.locationChangeTriggerUrl = locationChangeTriggerUrl;
5054
+ _this.clickedLinkUrl = clickedLinkUrl;
4645
5055
  _this.isPopState = false;
4646
- _this.gotPopStateWithLeavingUrl = false;
5056
+ _this.clickedLinkMatchedBackButtonUrl = false;
5057
+ _this.debugPropertyKeys = ['idle', 'startingUrl', 'clickedLinkUrl', 'firstCancelEventUrl', 'clickedLinkMatchedBackButtonUrl', 'popStateEventUrl'];
4647
5058
  return _this;
4648
5059
  }
4649
- Object.defineProperty(CancelledDuringNavigationInteraction.prototype, "isTransitional", {
5060
+ Object.defineProperty(LinkTriggeredNavigationInteractionCancelled.prototype, "isTransitional", {
4650
5061
  get: /**
4651
5062
  * @return {?}
4652
5063
  */
@@ -4660,53 +5071,56 @@ if (false) {
4660
5071
  * @param {?} event
4661
5072
  * @return {?}
4662
5073
  */
4663
- CancelledDuringNavigationInteraction.prototype.onRouterStarted = /**
5074
+ LinkTriggeredNavigationInteractionCancelled.prototype.onRouterStarted = /**
4664
5075
  * @param {?} event
4665
5076
  * @return {?}
4666
5077
  */
4667
5078
  function (event) {
4668
5079
  return this.ignore(event);
4669
5080
  };
4670
- // @Trace()
4671
- // @Trace()
4672
5081
  /**
4673
5082
  * @param {?} event
4674
5083
  * @return {?}
4675
5084
  */
4676
- CancelledDuringNavigationInteraction.prototype.onRouterCancelled =
4677
- // @Trace()
4678
- /**
5085
+ LinkTriggeredNavigationInteractionCancelled.prototype.onRouterCancelled = /**
4679
5086
  * @param {?} event
4680
5087
  * @return {?}
4681
5088
  */
4682
5089
  function (event) {
4683
- // Depending on the state of the router and what was done we get a different
4684
- // sequence of events.
4685
- // If the navigation change was triggered by clicking a link we'll get a cancel with the locationChangeTriggerUrl as the final event.
4686
- // If the navigation change was triggered with a pop state then we'll get an onPopState with the locationChangeTriggerUrl but no cancel event with it.
4687
- if (this.gotPopStateWithLeavingUrl && this.interactionService.isActive()) {
4688
- /** @type {?} */
4689
- var interactionIds = this.interactionService.activeInteractionContextIds.value;
4690
- this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
5090
+ // TODO: should really split this into two sub states in the first cancel event.
5091
+ if (!this.firstCancelEventUrl) {
5092
+ this.firstCancelEventUrl = event.url;
5093
+ this.clickedLinkMatchedBackButtonUrl = event.url === this.clickedLinkUrl;
5094
+ return this.ignore(event);
5095
+ }
5096
+ else {
5097
+ // we wait for our popped state to come in.
5098
+ if (!this.clickedLinkMatchedBackButtonUrl && this.popStateEventUrl) {
5099
+ return this.finaliseRouting();
5100
+ }
4691
5101
  }
4692
- return this.gotPopStateWithLeavingUrl || this.locationChangeTriggerUrl === event.url ? this.createIdleState() : this.ignore(event);
4693
5102
  };
4694
5103
  /**
4695
5104
  * @param {?} event
4696
5105
  * @return {?}
4697
5106
  */
4698
- CancelledDuringNavigationInteraction.prototype.onRouterEnd = /**
5107
+ LinkTriggeredNavigationInteractionCancelled.prototype.onRouterEnd = /**
4699
5108
  * @param {?} event
4700
5109
  * @return {?}
4701
5110
  */
4702
5111
  function (event) {
4703
- return this.ignore(event);
5112
+ if (this.clickedLinkMatchedBackButtonUrl) {
5113
+ return this.finaliseRouting();
5114
+ }
5115
+ else {
5116
+ return this.ignore(event);
5117
+ }
4704
5118
  };
4705
5119
  /**
4706
5120
  * @param {?} event
4707
5121
  * @return {?}
4708
5122
  */
4709
- CancelledDuringNavigationInteraction.prototype.onRouterError = /**
5123
+ LinkTriggeredNavigationInteractionCancelled.prototype.onRouterError = /**
4710
5124
  * @param {?} event
4711
5125
  * @return {?}
4712
5126
  */
@@ -4717,25 +5131,42 @@ if (false) {
4717
5131
  * @param {?} event
4718
5132
  * @return {?}
4719
5133
  */
4720
- CancelledDuringNavigationInteraction.prototype.onPopState = /**
5134
+ LinkTriggeredNavigationInteractionCancelled.prototype.onPopState = /**
4721
5135
  * @param {?} event
4722
5136
  * @return {?}
4723
5137
  */
4724
5138
  function (event) {
4725
- this.gotPopStateWithLeavingUrl = this.gotPopStateWithLeavingUrl || event.url === this.locationChangeTriggerUrl;
5139
+ this.popStateEventUrl = event.url;
4726
5140
  return this.ignore(event);
4727
5141
  };
4728
- // @Trace()
4729
- // @Trace()
5142
+ /**
5143
+ * @return {?}
5144
+ */
5145
+ LinkTriggeredNavigationInteractionCancelled.prototype.finaliseRouting = /**
5146
+ * @return {?}
5147
+ */
5148
+ function () {
5149
+ Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
5150
+ this.resetBrowserLocation(this.clickedLinkUrl); // put the back click one back in.
5151
+ if (this.interactionService.isActive()) {
5152
+ /** @type {?} */
5153
+ var interactionIds = this.interactionService.activeInteractionContextIds.value;
5154
+ // Angular doesn't preserve the url when a guard cancels the back button.
5155
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
5156
+ this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
5157
+ }
5158
+ else {
5159
+ this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
5160
+ }
5161
+ return this.createIdleState();
5162
+ };
4730
5163
  /**
4731
5164
  * @param {?} component
4732
5165
  * @param {?} currentUrl
4733
5166
  * @param {?} nextUrl
4734
5167
  * @return {?}
4735
5168
  */
4736
- CancelledDuringNavigationInteraction.prototype.canDeactivatePlace =
4737
- // @Trace()
4738
- /**
5169
+ LinkTriggeredNavigationInteractionCancelled.prototype.canDeactivatePlace = /**
4739
5170
  * @param {?} component
4740
5171
  * @param {?} currentUrl
4741
5172
  * @param {?} nextUrl
@@ -4748,47 +5179,185 @@ if (false) {
4748
5179
  });
4749
5180
  });
4750
5181
  };
5182
+ return LinkTriggeredNavigationInteractionCancelled;
5183
+ }(NavigationState));
5184
+ NavigationState.LinkTriggeredNavigationInteractionCancelled = LinkTriggeredNavigationInteractionCancelled;
5185
+ if (false) {
5186
+ /** @type {?} */
5187
+ LinkTriggeredNavigationInteractionCancelled.prototype.isPopState;
5188
+ /** @type {?} */
5189
+ LinkTriggeredNavigationInteractionCancelled.prototype.firstCancelEventUrl;
5190
+ /** @type {?} */
5191
+ LinkTriggeredNavigationInteractionCancelled.prototype.popStateEventUrl;
5192
+ /** @type {?} */
5193
+ LinkTriggeredNavigationInteractionCancelled.prototype.clickedLinkMatchedBackButtonUrl;
5194
+ /** @type {?} */
5195
+ LinkTriggeredNavigationInteractionCancelled.prototype.debugPropertyKeys;
5196
+ /** @type {?} */
5197
+ LinkTriggeredNavigationInteractionCancelled.prototype.startingUrl;
5198
+ /** @type {?} */
5199
+ LinkTriggeredNavigationInteractionCancelled.prototype.clickedLinkUrl;
5200
+ }
5201
+ /**
5202
+ * This state handles the scenario where a pop state triggered and interaction and the user clickeb back a second time to cancel it.
5203
+ * The sequence of routing events/state transitions is as follows.
5204
+ * -> Idle -> PopStateTransition (poppedHistoryUrl == page to go to, startingUrl = page to stay on )
5205
+ * -> confirm dialog shown.
5206
+ * -> click back
5207
+ * -> PopStateTransition -> CancelledDuringBackButtonNavigationInteraction(trigger url is the page before the popped history url)
5208
+ * -> NavigationCancel (for the previous back)
5209
+ * -> PopState
5210
+ * -> NavigationCancel
5211
+ */
5212
+ var /**
5213
+ * This state handles the scenario where a pop state triggered and interaction and the user clickeb back a second time to cancel it.
5214
+ * The sequence of routing events/state transitions is as follows.
5215
+ * -> Idle -> PopStateTransition (poppedHistoryUrl == page to go to, startingUrl = page to stay on )
5216
+ * -> confirm dialog shown.
5217
+ * -> click back
5218
+ * -> PopStateTransition -> CancelledDuringBackButtonNavigationInteraction(trigger url is the page before the popped history url)
5219
+ * -> NavigationCancel (for the previous back)
5220
+ * -> PopState
5221
+ * -> NavigationCancel
5222
+ */
5223
+ PopStateTriggeredNavigationInteractionCancelled = /** @class */ (function (_super) {
5224
+ __extends(PopStateTriggeredNavigationInteractionCancelled, _super);
5225
+ function PopStateTriggeredNavigationInteractionCancelled(context, startingUrl, locationChangeTriggerUrl, poppedHistoryUrl) {
5226
+ var _this = _super.call(this, context) || this;
5227
+ _this.startingUrl = startingUrl;
5228
+ _this.locationChangeTriggerUrl = locationChangeTriggerUrl;
5229
+ _this.poppedHistoryUrl = poppedHistoryUrl;
5230
+ _this.isPopState = false;
5231
+ _this.firstCancelHandled = false;
5232
+ _this.popStateHandled = false;
5233
+ _this.debugPropertyKeys = ['idle', 'startingUrl', 'poppedHistoryUrl', 'locationChangeTriggerUrl', 'popStateEventUrl', 'firstCancelHandled', 'popStateHandled'];
5234
+ return _this;
5235
+ }
5236
+ Object.defineProperty(PopStateTriggeredNavigationInteractionCancelled.prototype, "isTransitional", {
5237
+ get: /**
5238
+ * @return {?}
5239
+ */
5240
+ function () {
5241
+ return true;
5242
+ },
5243
+ enumerable: true,
5244
+ configurable: true
5245
+ });
4751
5246
  /**
4752
5247
  * @param {?} event
4753
- * @param {?=} reason
4754
5248
  * @return {?}
4755
5249
  */
4756
- CancelledDuringNavigationInteraction.prototype.ignore = /**
5250
+ PopStateTriggeredNavigationInteractionCancelled.prototype.onRouterStarted = /**
4757
5251
  * @param {?} event
4758
- * @param {?=} reason
4759
5252
  * @return {?}
4760
5253
  */
4761
- function (event, reason) {
4762
- reason = reason ? " -> " + reason : '';
4763
- Logger.get(this).info("ignoring router event" + reason + ": " + event.constructor.name + " -> " + event.url);
4764
- return this;
5254
+ function (event) {
5255
+ return this.ignore(event);
4765
5256
  };
4766
5257
  /**
5258
+ * @param {?} event
4767
5259
  * @return {?}
4768
5260
  */
4769
- CancelledDuringNavigationInteraction.prototype.toString = /**
5261
+ PopStateTriggeredNavigationInteractionCancelled.prototype.onRouterCancelled = /**
5262
+ * @param {?} event
4770
5263
  * @return {?}
4771
5264
  */
4772
- function () {
4773
- return this.constructor.name + "(isIdl: " + this.idle + ", startingUrl: " + this.startingUrl + ", locationChangeTriggerUrl:" + this.locationChangeTriggerUrl + ")";
5265
+ function (event) {
5266
+ if (this.firstCancelHandled && this.popStateHandled) {
5267
+ // Angular doesn't preserve the url when a guard cancels the back button.
5268
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
5269
+ Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
5270
+ this.resetBrowserLocation(this.locationChangeTriggerUrl); // put the second back click one back in.
5271
+ this.resetBrowserLocation(this.poppedHistoryUrl); // put the first back click one back in.
5272
+ if (this.interactionService.isActive()) {
5273
+ /** @type {?} */
5274
+ var interactionIds = this.interactionService.activeInteractionContextIds.value;
5275
+ this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
5276
+ }
5277
+ else {
5278
+ this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
5279
+ }
5280
+ return this.createIdleState();
5281
+ }
5282
+ else {
5283
+ this.firstCancelHandled = true;
5284
+ return this.ignore(event);
5285
+ }
4774
5286
  };
4775
- return CancelledDuringNavigationInteraction;
5287
+ /**
5288
+ * @param {?} event
5289
+ * @return {?}
5290
+ */
5291
+ PopStateTriggeredNavigationInteractionCancelled.prototype.onRouterEnd = /**
5292
+ * @param {?} event
5293
+ * @return {?}
5294
+ */
5295
+ function (event) {
5296
+ return this.ignore(event);
5297
+ };
5298
+ /**
5299
+ * @param {?} event
5300
+ * @return {?}
5301
+ */
5302
+ PopStateTriggeredNavigationInteractionCancelled.prototype.onRouterError = /**
5303
+ * @param {?} event
5304
+ * @return {?}
5305
+ */
5306
+ function (event) {
5307
+ return this.ignore(event);
5308
+ };
5309
+ /**
5310
+ * @param {?} event
5311
+ * @return {?}
5312
+ */
5313
+ PopStateTriggeredNavigationInteractionCancelled.prototype.onPopState = /**
5314
+ * @param {?} event
5315
+ * @return {?}
5316
+ */
5317
+ function (event) {
5318
+ this.popStateHandled = true;
5319
+ this.popStateEventUrl = event.url;
5320
+ return this.ignore(event);
5321
+ };
5322
+ /**
5323
+ * @param {?} component
5324
+ * @param {?} currentUrl
5325
+ * @param {?} nextUrl
5326
+ * @return {?}
5327
+ */
5328
+ PopStateTriggeredNavigationInteractionCancelled.prototype.canDeactivatePlace = /**
5329
+ * @param {?} component
5330
+ * @param {?} currentUrl
5331
+ * @param {?} nextUrl
5332
+ * @return {?}
5333
+ */
5334
+ function (component, currentUrl, nextUrl) {
5335
+ return __awaiter(this, void 0, void 0, function () {
5336
+ return __generator(this, function (_a) {
5337
+ return [2 /*return*/, false];
5338
+ });
5339
+ });
5340
+ };
5341
+ return PopStateTriggeredNavigationInteractionCancelled;
4776
5342
  }(NavigationState));
4777
- NavigationState.CancelledDuringNavigationInteraction = CancelledDuringNavigationInteraction;
5343
+ NavigationState.PopStateTriggeredNavigationInteractionCancelled = PopStateTriggeredNavigationInteractionCancelled;
4778
5344
  if (false) {
4779
5345
  /** @type {?} */
4780
- CancelledDuringNavigationInteraction.prototype.isPopState;
4781
- /**
4782
- * @type {?}
4783
- * @private
4784
- */
4785
- CancelledDuringNavigationInteraction.prototype.gotPopStateWithLeavingUrl;
5346
+ PopStateTriggeredNavigationInteractionCancelled.prototype.isPopState;
4786
5347
  /** @type {?} */
4787
- CancelledDuringNavigationInteraction.prototype.startingUrl;
5348
+ PopStateTriggeredNavigationInteractionCancelled.prototype.firstCancelHandled;
4788
5349
  /** @type {?} */
4789
- CancelledDuringNavigationInteraction.prototype.startingEventWasAPopState;
5350
+ PopStateTriggeredNavigationInteractionCancelled.prototype.popStateHandled;
4790
5351
  /** @type {?} */
4791
- CancelledDuringNavigationInteraction.prototype.locationChangeTriggerUrl;
5352
+ PopStateTriggeredNavigationInteractionCancelled.prototype.popStateEventUrl;
5353
+ /** @type {?} */
5354
+ PopStateTriggeredNavigationInteractionCancelled.prototype.debugPropertyKeys;
5355
+ /** @type {?} */
5356
+ PopStateTriggeredNavigationInteractionCancelled.prototype.startingUrl;
5357
+ /** @type {?} */
5358
+ PopStateTriggeredNavigationInteractionCancelled.prototype.locationChangeTriggerUrl;
5359
+ /** @type {?} */
5360
+ PopStateTriggeredNavigationInteractionCancelled.prototype.poppedHistoryUrl;
4792
5361
  }
4793
5362
  })(NavigationState || (NavigationState = {}));
4794
5363
 
@@ -7949,6 +8518,7 @@ function RouteId(type, options) {
7949
8518
  var param = new ParameterDefinition.RouteId(propertyKey.toString(), options, type);
7950
8519
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
7951
8520
  UseDelegate({ tag: "@RouteId(" + prototype.constructor.name + "." + propertyKey.toString() + ")" })(prototype, propertyKey);
8521
+ // UseDelegate()(prototype, propertyKey);
7952
8522
  });
7953
8523
  }
7954
8524
  /**
@@ -7969,6 +8539,7 @@ function VisitParameter(options) {
7969
8539
  var param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional("storeInUrl", null));
7970
8540
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
7971
8541
  UseDelegate({ tag: "@VisitParameter(" + prototype.constructor.name + "." + propertyKey.toString() + ")" })(prototype, propertyKey);
8542
+ // UseDelegate()(prototype, propertyKey);
7972
8543
  });
7973
8544
  }
7974
8545
  /**
@@ -7987,8 +8558,9 @@ function VisitParameterList(options) {
7987
8558
  function (prototype, propertyKey) {
7988
8559
  /** @type {?} */
7989
8560
  var param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional("storeInUrl", null));
7990
- Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
8561
+ // UseDelegate()(prototype, propertyKey);
7991
8562
  UseDelegate({ tag: "@VisitParameterList(" + prototype.constructor.name + "." + propertyKey.toString() + ")" })(prototype, propertyKey);
8563
+ Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
7992
8564
  });
7993
8565
  }
7994
8566