@coolon/angular-ui-powerups 0.0.115 → 0.0.117

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.
@@ -3305,6 +3305,7 @@ var PlaceComponent = /** @class */ (function (_super) {
3305
3305
  var _this = this;
3306
3306
  assert.isNil(this.visit);
3307
3307
  this.visit = visit;
3308
+ // DebugContext.get(this.visit).tag(`${this.placeDefinition.component.name}.visit`);
3308
3309
  this.placeDefinition.getVisitParameterDefs().forEach((/**
3309
3310
  * @param {?} parameterDef
3310
3311
  * @return {?}
@@ -3785,6 +3786,7 @@ NavigationState = /** @class */ (function (_super) {
3785
3786
  var _this = _super.call(this) || this;
3786
3787
  _this.context = context;
3787
3788
  _this._visits = new Map();
3789
+ _this.debugPropertyKeys = [];
3788
3790
  return _this;
3789
3791
  }
3790
3792
  Object.defineProperty(NavigationState.prototype, "name", {
@@ -4005,14 +4007,18 @@ NavigationState = /** @class */ (function (_super) {
4005
4007
  function (event) {
4006
4008
  /** @type {?} */
4007
4009
  var popstate = event.navigationTrigger === 'popstate';
4008
- return popstate ?
4009
- this.interactionService.isActive() ?
4010
- new NavigationState.InteractionPopStateTransition(this.context, this.currentRouterUrl()) :
4011
- new NavigationState.PopStateTransition(this.context, this.currentRouterUrl())
4012
- :
4013
- this.interactionService.isActive() ?
4014
- new NavigationState.InteractionTransition(this.context, this.currentRouterUrl()) :
4015
- 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
+ }
4016
4022
  };
4017
4023
  /**
4018
4024
  * @protected
@@ -4027,17 +4033,36 @@ NavigationState = /** @class */ (function (_super) {
4027
4033
  new NavigationState.IdleDuringInteraction(this.context, this.currentRouterUrl()) :
4028
4034
  new NavigationState.Idle(this.context);
4029
4035
  };
4036
+ //
4037
+ //
4030
4038
  /**
4031
4039
  * @param {?} url
4032
4040
  * @return {?}
4033
4041
  */
4034
- NavigationState.prototype.resetBrowserLocation = /**
4042
+ NavigationState.prototype.resetBrowserLocation =
4043
+ //
4044
+ /**
4035
4045
  * @param {?} url
4036
4046
  * @return {?}
4037
4047
  */
4038
4048
  function (url) {
4039
4049
  this.placeRouter.resetBrowserLocation(url);
4040
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
+ };
4041
4066
  /**
4042
4067
  * @return {?}
4043
4068
  */
@@ -4045,7 +4070,27 @@ NavigationState = /** @class */ (function (_super) {
4045
4070
  * @return {?}
4046
4071
  */
4047
4072
  function () {
4048
- 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(', ');
4049
4094
  };
4050
4095
  return NavigationState;
4051
4096
  }(GarbageCollector));
@@ -4061,6 +4106,8 @@ if (false) {
4061
4106
  NavigationState.prototype.startingUrl;
4062
4107
  /** @type {?} */
4063
4108
  NavigationState.prototype.isPopState;
4109
+ /** @type {?} */
4110
+ NavigationState.prototype.debugPropertyKeys;
4064
4111
  /**
4065
4112
  * @type {?}
4066
4113
  * @protected
@@ -4126,7 +4173,7 @@ if (false) {
4126
4173
  }
4127
4174
  if (this.placeRouter.hasActiveInteractionIds(event.url)) {
4128
4175
  Logger.get(this).info("navigation started with interaction outlet -> " + event.url);
4129
- return new InteractionTransition(this.context, event.url);
4176
+ return new StartingInteractionTransition(this.context, event.url);
4130
4177
  }
4131
4178
  else {
4132
4179
  return this.createTransitionStateFor(event);
@@ -4219,14 +4266,14 @@ if (false) {
4219
4266
  return new Idle(this.context);
4220
4267
  };
4221
4268
  /**
4222
- * @param {?} locationTriggerUrl
4269
+ * @param {?} newUrl
4223
4270
  * @return {?}
4224
4271
  */
4225
4272
  AbstractNavigationTransition.prototype.onBackClickedDuringNavigationInteraction = /**
4226
- * @param {?} locationTriggerUrl
4273
+ * @param {?} newUrl
4227
4274
  * @return {?}
4228
4275
  */
4229
- function (locationTriggerUrl) {
4276
+ function (newUrl) {
4230
4277
  Logger.get(this).info("back button pressed during navigation session interaction promise");
4231
4278
  // detach the interaction from the session so it doesn't get disposed until the activity has completed.
4232
4279
  /** @type {?} */
@@ -4234,25 +4281,22 @@ if (false) {
4234
4281
  var when = Dsl.disposeWith(navigationInteraction).when;
4235
4282
  // TODO: I need to make the exclusive interaction context disallow nested activities or
4236
4283
  // that would mess things up entirely. Or, can I do a context.abortAll().then(..)
4284
+ Logger.get(this).info('cancelling current navigation activity..');
4237
4285
  navigationInteraction.cancelActiveActivity().then((/**
4238
4286
  * @return {?}
4239
4287
  */
4240
4288
  function () {
4241
4289
  navigationInteraction.dispose();
4242
4290
  }));
4243
- return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, this.isPopState, locationTriggerUrl);
4291
+ return this.createNavigationInteractionCancelledState(newUrl);
4244
4292
  };
4245
- // @Trace()
4246
- // @Trace()
4247
4293
  /**
4248
4294
  * @param {?} component
4249
4295
  * @param {?} currentUrl
4250
4296
  * @param {?} nextUrl
4251
4297
  * @return {?}
4252
4298
  */
4253
- AbstractNavigationTransition.prototype.canDeactivatePlace =
4254
- // @Trace()
4255
- /**
4299
+ AbstractNavigationTransition.prototype.canDeactivatePlace = /**
4256
4300
  * @param {?} component
4257
4301
  * @param {?} currentUrl
4258
4302
  * @param {?} nextUrl
@@ -4274,11 +4318,11 @@ if (false) {
4274
4318
  });
4275
4319
  };
4276
4320
  /**
4277
- * @private
4321
+ * @protected
4278
4322
  * @return {?}
4279
4323
  */
4280
4324
  AbstractNavigationTransition.prototype.detachInteractionContext = /**
4281
- * @private
4325
+ * @protected
4282
4326
  * @return {?}
4283
4327
  */
4284
4328
  function () {
@@ -4305,12 +4349,19 @@ if (false) {
4305
4349
  AbstractNavigationTransition.prototype._interactionContext;
4306
4350
  /** @type {?} */
4307
4351
  AbstractNavigationTransition.prototype.startingUrl;
4352
+ /**
4353
+ * @abstract
4354
+ * @param {?} newUrl
4355
+ * @return {?}
4356
+ */
4357
+ AbstractNavigationTransition.prototype.createNavigationInteractionCancelledState = function (newUrl) { };
4308
4358
  }
4309
4359
  var NavigationTransition = /** @class */ (function (_super) {
4310
4360
  __extends(NavigationTransition, _super);
4311
4361
  function NavigationTransition() {
4312
4362
  var _this = _super !== null && _super.apply(this, arguments) || this;
4313
4363
  _this.isPopState = false;
4364
+ _this.debugPropertyKeys = ['startingUrl'];
4314
4365
  return _this;
4315
4366
  }
4316
4367
  /**
@@ -4337,13 +4388,15 @@ if (false) {
4337
4388
  return new Idle(this.context);
4338
4389
  };
4339
4390
  /**
4391
+ * @param {?} newUrl
4340
4392
  * @return {?}
4341
4393
  */
4342
- NavigationTransition.prototype.toString = /**
4394
+ NavigationTransition.prototype.createNavigationInteractionCancelledState = /**
4395
+ * @param {?} newUrl
4343
4396
  * @return {?}
4344
4397
  */
4345
- function () {
4346
- return this.constructor.name + "(startingUrl: " + this.startingUrl + ")";
4398
+ function (newUrl) {
4399
+ return new LinkTriggeredNavigationInteractionCancelled(this.context, this.startingUrl, newUrl);
4347
4400
  };
4348
4401
  return NavigationTransition;
4349
4402
  }(AbstractNavigationTransition));
@@ -4351,12 +4404,16 @@ if (false) {
4351
4404
  if (false) {
4352
4405
  /** @type {?} */
4353
4406
  NavigationTransition.prototype.isPopState;
4407
+ /** @type {?} */
4408
+ NavigationTransition.prototype.debugPropertyKeys;
4354
4409
  }
4355
4410
  var PopStateTransition = /** @class */ (function (_super) {
4356
4411
  __extends(PopStateTransition, _super);
4357
- function PopStateTransition() {
4358
- 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;
4359
4415
  _this.isPopState = true;
4416
+ _this.debugPropertyKeys = ['startingUrl', 'poppedHistoryUrl'];
4360
4417
  return _this;
4361
4418
  }
4362
4419
  /**
@@ -4371,7 +4428,8 @@ if (false) {
4371
4428
  // Angular doesn't preserve the url when a guard cancels the back button.
4372
4429
  // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4373
4430
  Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4374
- 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.
4375
4433
  return new Idle(this.context);
4376
4434
  };
4377
4435
  /**
@@ -4388,24 +4446,75 @@ if (false) {
4388
4446
  // Angular doesn't preserve the url when a guard cancels the back button.
4389
4447
  // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4390
4448
  Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4391
- 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.
4392
4451
  }
4393
4452
  return new Idle(this.context);
4394
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
+ };
4395
4465
  return PopStateTransition;
4396
4466
  }(AbstractNavigationTransition));
4397
4467
  NavigationState.PopStateTransition = PopStateTransition;
4398
4468
  if (false) {
4399
4469
  /** @type {?} */
4400
4470
  PopStateTransition.prototype.isPopState;
4471
+ /** @type {?} */
4472
+ PopStateTransition.prototype.debugPropertyKeys;
4473
+ /** @type {?} */
4474
+ PopStateTransition.prototype.poppedHistoryUrl;
4401
4475
  }
4402
- var IdleDuringInteraction = /** @class */ (function (_super) {
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;
4498
+ }
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) {
4403
4511
  __extends(IdleDuringInteraction, _super);
4404
4512
  function IdleDuringInteraction(context, startingUrl) {
4405
4513
  var _this = _super.call(this, context) || this;
4406
4514
  _this.startingUrl = startingUrl;
4407
4515
  _this.isTransitional = false;
4408
4516
  _this.isPopState = false;
4517
+ _this.debugPropertyKeys = ['startingUrl'];
4409
4518
  return _this;
4410
4519
  }
4411
4520
  /**
@@ -4419,40 +4528,34 @@ if (false) {
4419
4528
  * @return {?}
4420
4529
  */
4421
4530
  function (visit, initialUrl) {
4531
+ // we're in an interaction and the user clicked back
4422
4532
  /** @type {?} */
4423
- var navigationTransition = new InteractionTransition(this.context, initialUrl);
4533
+ var navigationTransition = new StartingInteractionTransition(this.context, initialUrl);
4424
4534
  navigationTransition.storeVisit(visit);
4425
4535
  return navigationTransition;
4426
4536
  };
4427
- // @Trace()
4428
- // @Trace()
4429
4537
  /**
4430
4538
  * @param {?} event
4431
4539
  * @return {?}
4432
4540
  */
4433
- IdleDuringInteraction.prototype.onRouterStarted =
4434
- // @Trace()
4435
- /**
4541
+ IdleDuringInteraction.prototype.onRouterStarted = /**
4436
4542
  * @param {?} event
4437
4543
  * @return {?}
4438
4544
  */
4439
4545
  function (event) {
4440
- return new InteractionTransition(this.context, event.url);
4546
+ return new StartingInteractionTransition(this.context, event.url);
4441
4547
  };
4442
- // @Trace()
4443
- // @Trace()
4444
4548
  /**
4445
4549
  * @param {?} event
4446
4550
  * @return {?}
4447
4551
  */
4448
- IdleDuringInteraction.prototype.onPopState =
4449
- // @Trace()
4450
- /**
4552
+ IdleDuringInteraction.prototype.onPopState = /**
4451
4553
  * @param {?} event
4452
4554
  * @return {?}
4453
4555
  */
4454
4556
  function (event) {
4455
- 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);
4456
4559
  };
4457
4560
  return IdleDuringInteraction;
4458
4561
  }(NavigationState));
@@ -4463,55 +4566,34 @@ if (false) {
4463
4566
  /** @type {?} */
4464
4567
  IdleDuringInteraction.prototype.isPopState;
4465
4568
  /** @type {?} */
4466
- IdleDuringInteraction.prototype.startingUrl;
4467
- }
4468
- /**
4469
- * @abstract
4470
- */
4471
- var /**
4472
- * @abstract
4473
- */
4474
- AbstractInteractionTransition = /** @class */ (function (_super) {
4475
- __extends(AbstractInteractionTransition, _super);
4476
- function AbstractInteractionTransition(context, startingUrl) {
4477
- var _this = _super.call(this, context, startingUrl) || this;
4478
- _this.startingUrl = startingUrl;
4479
- _this.isTransitional = true;
4480
- return _this;
4481
- }
4482
- return AbstractInteractionTransition;
4483
- }(AbstractNavigationTransition));
4484
- NavigationState.AbstractInteractionTransition = AbstractInteractionTransition;
4485
- if (false) {
4486
- /** @type {?} */
4487
- AbstractInteractionTransition.prototype.isTransitional;
4569
+ IdleDuringInteraction.prototype.debugPropertyKeys;
4488
4570
  /** @type {?} */
4489
- AbstractInteractionTransition.prototype.startingUrl;
4571
+ IdleDuringInteraction.prototype.startingUrl;
4490
4572
  }
4491
4573
  /**
4492
4574
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4493
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.
4494
4578
  */
4495
4579
  var /**
4496
4580
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4497
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.
4498
4584
  */
4499
- InteractionTransition = /** @class */ (function (_super) {
4500
- __extends(InteractionTransition, _super);
4501
- function InteractionTransition() {
4585
+ StartingInteractionTransition = /** @class */ (function (_super) {
4586
+ __extends(StartingInteractionTransition, _super);
4587
+ function StartingInteractionTransition() {
4502
4588
  var _this = _super !== null && _super.apply(this, arguments) || this;
4503
4589
  _this.isPopState = false;
4504
4590
  return _this;
4505
4591
  }
4506
- // @Trace()
4507
- // @Trace()
4508
4592
  /**
4509
4593
  * @param {?} event
4510
4594
  * @return {?}
4511
4595
  */
4512
- InteractionTransition.prototype.onRouterCancelled =
4513
- // @Trace()
4514
- /**
4596
+ StartingInteractionTransition.prototype.onRouterCancelled = /**
4515
4597
  * @param {?} event
4516
4598
  * @return {?}
4517
4599
  */
@@ -4526,15 +4608,11 @@ if (false) {
4526
4608
  return new Idle(this.context);
4527
4609
  }
4528
4610
  };
4529
- // @Trace()
4530
- // @Trace()
4531
4611
  /**
4532
4612
  * @param {?} event
4533
4613
  * @return {?}
4534
4614
  */
4535
- InteractionTransition.prototype.onRouterError =
4536
- // @Trace()
4537
- /**
4615
+ StartingInteractionTransition.prototype.onRouterError = /**
4538
4616
  * @param {?} event
4539
4617
  * @return {?}
4540
4618
  */
@@ -4542,15 +4620,11 @@ if (false) {
4542
4620
  // navigation was aborted.
4543
4621
  return new IdleDuringInteraction(this.context, this.startingUrl);
4544
4622
  };
4545
- // @Trace()
4546
- // @Trace()
4547
4623
  /**
4548
4624
  * @param {?} event
4549
4625
  * @return {?}
4550
4626
  */
4551
- InteractionTransition.prototype.onRouterEnd =
4552
- // @Trace()
4553
- /**
4627
+ StartingInteractionTransition.prototype.onRouterEnd = /**
4554
4628
  * @param {?} event
4555
4629
  * @return {?}
4556
4630
  */
@@ -4562,12 +4636,163 @@ if (false) {
4562
4636
  return new Idle(this.context);
4563
4637
  }
4564
4638
  };
4565
- 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;
4566
4651
  }(AbstractInteractionTransition));
4567
- 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;
4568
4781
  if (false) {
4569
4782
  /** @type {?} */
4570
- 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;
4571
4796
  }
4572
4797
  /**
4573
4798
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
@@ -4577,22 +4802,19 @@ if (false) {
4577
4802
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4578
4803
  * happily ignore interaction contexts.
4579
4804
  */
4580
- InteractionPopStateTransition = /** @class */ (function (_super) {
4581
- __extends(InteractionPopStateTransition, _super);
4582
- function InteractionPopStateTransition() {
4583
- 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;
4584
4810
  _this.isPopState = true;
4585
4811
  return _this;
4586
4812
  }
4587
- // @Trace()
4588
- // @Trace()
4589
4813
  /**
4590
4814
  * @param {?} event
4591
4815
  * @return {?}
4592
4816
  */
4593
- InteractionPopStateTransition.prototype.onRouterCancelled =
4594
- // @Trace()
4595
- /**
4817
+ LeavingInteractionAfterPopStateTransition.prototype.onRouterCancelled = /**
4596
4818
  * @param {?} event
4597
4819
  * @return {?}
4598
4820
  */
@@ -4607,15 +4829,11 @@ if (false) {
4607
4829
  return new Idle(this.context);
4608
4830
  }
4609
4831
  };
4610
- // @Trace()
4611
- // @Trace()
4612
4832
  /**
4613
4833
  * @param {?} event
4614
4834
  * @return {?}
4615
4835
  */
4616
- InteractionPopStateTransition.prototype.onRouterEnd =
4617
- // @Trace()
4618
- /**
4836
+ LeavingInteractionAfterPopStateTransition.prototype.onRouterEnd = /**
4619
4837
  * @param {?} event
4620
4838
  * @return {?}
4621
4839
  */
@@ -4627,25 +4845,219 @@ if (false) {
4627
4845
  return new Idle(this.context);
4628
4846
  }
4629
4847
  };
4630
- 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;
4631
4860
  }(AbstractInteractionTransition));
4632
- NavigationState.InteractionPopStateTransition = InteractionPopStateTransition;
4861
+ NavigationState.LeavingInteractionAfterPopStateTransition = LeavingInteractionAfterPopStateTransition;
4633
4862
  if (false) {
4634
4863
  /** @type {?} */
4635
- InteractionPopStateTransition.prototype.isPopState;
4864
+ LeavingInteractionAfterPopStateTransition.prototype.isPopState;
4865
+ /** @type {?} */
4866
+ LeavingInteractionAfterPopStateTransition.prototype.poppedHistoryUrl;
4636
4867
  }
4637
- var CancelledDuringNavigationInteraction = /** @class */ (function (_super) {
4638
- __extends(CancelledDuringNavigationInteraction, _super);
4639
- 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) {
4640
5052
  var _this = _super.call(this, context) || this;
4641
5053
  _this.startingUrl = startingUrl;
4642
- _this.startingEventWasAPopState = startingEventWasAPopState;
4643
- _this.locationChangeTriggerUrl = locationChangeTriggerUrl;
5054
+ _this.clickedLinkUrl = clickedLinkUrl;
4644
5055
  _this.isPopState = false;
4645
- _this.gotPopStateWithLeavingUrl = false;
5056
+ _this.clickedLinkMatchedBackButtonUrl = false;
5057
+ _this.debugPropertyKeys = ['idle', 'startingUrl', 'clickedLinkUrl', 'firstCancelEventUrl', 'clickedLinkMatchedBackButtonUrl', 'popStateEventUrl'];
4646
5058
  return _this;
4647
5059
  }
4648
- Object.defineProperty(CancelledDuringNavigationInteraction.prototype, "isTransitional", {
5060
+ Object.defineProperty(LinkTriggeredNavigationInteractionCancelled.prototype, "isTransitional", {
4649
5061
  get: /**
4650
5062
  * @return {?}
4651
5063
  */
@@ -4659,53 +5071,56 @@ if (false) {
4659
5071
  * @param {?} event
4660
5072
  * @return {?}
4661
5073
  */
4662
- CancelledDuringNavigationInteraction.prototype.onRouterStarted = /**
5074
+ LinkTriggeredNavigationInteractionCancelled.prototype.onRouterStarted = /**
4663
5075
  * @param {?} event
4664
5076
  * @return {?}
4665
5077
  */
4666
5078
  function (event) {
4667
5079
  return this.ignore(event);
4668
5080
  };
4669
- // @Trace()
4670
- // @Trace()
4671
5081
  /**
4672
5082
  * @param {?} event
4673
5083
  * @return {?}
4674
5084
  */
4675
- CancelledDuringNavigationInteraction.prototype.onRouterCancelled =
4676
- // @Trace()
4677
- /**
5085
+ LinkTriggeredNavigationInteractionCancelled.prototype.onRouterCancelled = /**
4678
5086
  * @param {?} event
4679
5087
  * @return {?}
4680
5088
  */
4681
5089
  function (event) {
4682
- // Depending on the state of the router and what was done we get a different
4683
- // sequence of events.
4684
- // If the navigation change was triggered by clicking a link we'll get a cancel with the locationChangeTriggerUrl as the final event.
4685
- // 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.
4686
- if (this.gotPopStateWithLeavingUrl && this.interactionService.isActive()) {
4687
- /** @type {?} */
4688
- var interactionIds = this.interactionService.activeInteractionContextIds.value;
4689
- 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
+ }
4690
5101
  }
4691
- return this.gotPopStateWithLeavingUrl || this.locationChangeTriggerUrl === event.url ? this.createIdleState() : this.ignore(event);
4692
5102
  };
4693
5103
  /**
4694
5104
  * @param {?} event
4695
5105
  * @return {?}
4696
5106
  */
4697
- CancelledDuringNavigationInteraction.prototype.onRouterEnd = /**
5107
+ LinkTriggeredNavigationInteractionCancelled.prototype.onRouterEnd = /**
4698
5108
  * @param {?} event
4699
5109
  * @return {?}
4700
5110
  */
4701
5111
  function (event) {
4702
- return this.ignore(event);
5112
+ if (this.clickedLinkMatchedBackButtonUrl) {
5113
+ return this.finaliseRouting();
5114
+ }
5115
+ else {
5116
+ return this.ignore(event);
5117
+ }
4703
5118
  };
4704
5119
  /**
4705
5120
  * @param {?} event
4706
5121
  * @return {?}
4707
5122
  */
4708
- CancelledDuringNavigationInteraction.prototype.onRouterError = /**
5123
+ LinkTriggeredNavigationInteractionCancelled.prototype.onRouterError = /**
4709
5124
  * @param {?} event
4710
5125
  * @return {?}
4711
5126
  */
@@ -4716,25 +5131,42 @@ if (false) {
4716
5131
  * @param {?} event
4717
5132
  * @return {?}
4718
5133
  */
4719
- CancelledDuringNavigationInteraction.prototype.onPopState = /**
5134
+ LinkTriggeredNavigationInteractionCancelled.prototype.onPopState = /**
4720
5135
  * @param {?} event
4721
5136
  * @return {?}
4722
5137
  */
4723
5138
  function (event) {
4724
- this.gotPopStateWithLeavingUrl = this.gotPopStateWithLeavingUrl || event.url === this.locationChangeTriggerUrl;
5139
+ this.popStateEventUrl = event.url;
4725
5140
  return this.ignore(event);
4726
5141
  };
4727
- // @Trace()
4728
- // @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
+ };
4729
5163
  /**
4730
5164
  * @param {?} component
4731
5165
  * @param {?} currentUrl
4732
5166
  * @param {?} nextUrl
4733
5167
  * @return {?}
4734
5168
  */
4735
- CancelledDuringNavigationInteraction.prototype.canDeactivatePlace =
4736
- // @Trace()
4737
- /**
5169
+ LinkTriggeredNavigationInteractionCancelled.prototype.canDeactivatePlace = /**
4738
5170
  * @param {?} component
4739
5171
  * @param {?} currentUrl
4740
5172
  * @param {?} nextUrl
@@ -4747,47 +5179,185 @@ if (false) {
4747
5179
  });
4748
5180
  });
4749
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
+ });
5246
+ /**
5247
+ * @param {?} event
5248
+ * @return {?}
5249
+ */
5250
+ PopStateTriggeredNavigationInteractionCancelled.prototype.onRouterStarted = /**
5251
+ * @param {?} event
5252
+ * @return {?}
5253
+ */
5254
+ function (event) {
5255
+ return this.ignore(event);
5256
+ };
4750
5257
  /**
4751
5258
  * @param {?} event
4752
- * @param {?=} reason
4753
5259
  * @return {?}
4754
5260
  */
4755
- CancelledDuringNavigationInteraction.prototype.ignore = /**
5261
+ PopStateTriggeredNavigationInteractionCancelled.prototype.onRouterCancelled = /**
4756
5262
  * @param {?} event
4757
- * @param {?=} reason
4758
5263
  * @return {?}
4759
5264
  */
4760
- function (event, reason) {
4761
- reason = reason ? " -> " + reason : '';
4762
- Logger.get(this).info("ignoring router event" + reason + ": " + event.constructor.name + " -> " + event.url);
4763
- return this;
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
+ }
4764
5286
  };
4765
5287
  /**
5288
+ * @param {?} event
4766
5289
  * @return {?}
4767
5290
  */
4768
- CancelledDuringNavigationInteraction.prototype.toString = /**
5291
+ PopStateTriggeredNavigationInteractionCancelled.prototype.onRouterEnd = /**
5292
+ * @param {?} event
4769
5293
  * @return {?}
4770
5294
  */
4771
- function () {
4772
- return this.constructor.name + "(isIdl: " + this.idle + ", startingUrl: " + this.startingUrl + ", locationChangeTriggerUrl:" + this.locationChangeTriggerUrl + ")";
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);
4773
5308
  };
4774
- return CancelledDuringNavigationInteraction;
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;
4775
5342
  }(NavigationState));
4776
- NavigationState.CancelledDuringNavigationInteraction = CancelledDuringNavigationInteraction;
5343
+ NavigationState.PopStateTriggeredNavigationInteractionCancelled = PopStateTriggeredNavigationInteractionCancelled;
4777
5344
  if (false) {
4778
5345
  /** @type {?} */
4779
- CancelledDuringNavigationInteraction.prototype.isPopState;
4780
- /**
4781
- * @type {?}
4782
- * @private
4783
- */
4784
- CancelledDuringNavigationInteraction.prototype.gotPopStateWithLeavingUrl;
5346
+ PopStateTriggeredNavigationInteractionCancelled.prototype.isPopState;
5347
+ /** @type {?} */
5348
+ PopStateTriggeredNavigationInteractionCancelled.prototype.firstCancelHandled;
5349
+ /** @type {?} */
5350
+ PopStateTriggeredNavigationInteractionCancelled.prototype.popStateHandled;
5351
+ /** @type {?} */
5352
+ PopStateTriggeredNavigationInteractionCancelled.prototype.popStateEventUrl;
5353
+ /** @type {?} */
5354
+ PopStateTriggeredNavigationInteractionCancelled.prototype.debugPropertyKeys;
4785
5355
  /** @type {?} */
4786
- CancelledDuringNavigationInteraction.prototype.startingUrl;
5356
+ PopStateTriggeredNavigationInteractionCancelled.prototype.startingUrl;
4787
5357
  /** @type {?} */
4788
- CancelledDuringNavigationInteraction.prototype.startingEventWasAPopState;
5358
+ PopStateTriggeredNavigationInteractionCancelled.prototype.locationChangeTriggerUrl;
4789
5359
  /** @type {?} */
4790
- CancelledDuringNavigationInteraction.prototype.locationChangeTriggerUrl;
5360
+ PopStateTriggeredNavigationInteractionCancelled.prototype.poppedHistoryUrl;
4791
5361
  }
4792
5362
  })(NavigationState || (NavigationState = {}));
4793
5363
 
@@ -7947,7 +8517,8 @@ function RouteId(type, options) {
7947
8517
  /** @type {?} */
7948
8518
  var param = new ParameterDefinition.RouteId(propertyKey.toString(), options, type);
7949
8519
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
7950
- UseDelegate({ tag: "@RouteId(" + prototype.constructor.name + "." + propertyKey.toString() + ")" })(prototype, propertyKey);
8520
+ // UseDelegate({tag: `@RouteId(${prototype.constructor.name}.${propertyKey.toString()})`})(prototype, propertyKey);
8521
+ UseDelegate()(prototype, propertyKey);
7951
8522
  });
7952
8523
  }
7953
8524
  /**
@@ -7967,7 +8538,8 @@ function VisitParameter(options) {
7967
8538
  /** @type {?} */
7968
8539
  var param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional("storeInUrl", null));
7969
8540
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
7970
- UseDelegate({ tag: "@VisitParameter(" + prototype.constructor.name + "." + propertyKey.toString() + ")" })(prototype, propertyKey);
8541
+ // UseDelegate({tag: `@VisitParameter(${prototype.constructor.name}.${propertyKey.toString()})`})(prototype, propertyKey);
8542
+ UseDelegate()(prototype, propertyKey);
7971
8543
  });
7972
8544
  }
7973
8545
  /**
@@ -7987,7 +8559,8 @@ function VisitParameterList(options) {
7987
8559
  /** @type {?} */
7988
8560
  var param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional("storeInUrl", null));
7989
8561
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
7990
- UseDelegate({ tag: "@VisitParameterList(" + prototype.constructor.name + "." + propertyKey.toString() + ")" })(prototype, propertyKey);
8562
+ UseDelegate()(prototype, propertyKey);
8563
+ // UseDelegate({tag: `@VisitParameterList(${prototype.constructor.name}.${propertyKey.toString()})`})(prototype, propertyKey);
7991
8564
  });
7992
8565
  }
7993
8566