@angular/router 21.0.0-next.0 → 21.0.0-next.10

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.
@@ -0,0 +1,4991 @@
1
+ /**
2
+ * @license Angular v21.0.0-next.10
3
+ * (c) 2010-2025 Google LLC. https://angular.dev/
4
+ * License: MIT
5
+ */
6
+
7
+ import { DOCUMENT, Location } from '@angular/common';
8
+ import * as i0 from '@angular/core';
9
+ import { ɵisPromise as _isPromise, ɵRuntimeError as _RuntimeError, Injectable, ɵisNgModule as _isNgModule, isStandalone, createEnvironmentInjector, InjectionToken, EventEmitter, input, inject, ViewContainerRef, ChangeDetectorRef, Directive, Input, Output, reflectComponentType, Component, ɵisInjectable as _isInjectable, runInInjectionContext, makeEnvironmentProviders, Compiler, NgModuleFactory, ɵresolveComponentResources as _resolveComponentResources, afterNextRender, signal, EnvironmentInjector, DestroyRef, untracked, ɵConsole as _Console, ɵPendingTasksInternal as _PendingTasksInternal, ɵINTERNAL_APPLICATION_ERROR_HANDLER as _INTERNAL_APPLICATION_ERROR_HANDLER, ɵformatRuntimeError as _formatRuntimeError } from '@angular/core';
10
+ import { isObservable, from, of, BehaviorSubject, combineLatest, EmptyError, Observable, concat, defer, pipe, throwError, EMPTY, Subject, Subscription } from 'rxjs';
11
+ import { first, map, switchMap, take, startWith, filter, takeUntil, mergeMap, concatMap, tap, catchError, scan, defaultIfEmpty, last as last$1, takeLast, finalize } from 'rxjs/operators';
12
+ import * as i1 from '@angular/platform-browser';
13
+
14
+ const PRIMARY_OUTLET = 'primary';
15
+ const RouteTitleKey = /* @__PURE__ */Symbol('RouteTitle');
16
+ class ParamsAsMap {
17
+ params;
18
+ constructor(params) {
19
+ this.params = params || {};
20
+ }
21
+ has(name) {
22
+ return Object.prototype.hasOwnProperty.call(this.params, name);
23
+ }
24
+ get(name) {
25
+ if (this.has(name)) {
26
+ const v = this.params[name];
27
+ return Array.isArray(v) ? v[0] : v;
28
+ }
29
+ return null;
30
+ }
31
+ getAll(name) {
32
+ if (this.has(name)) {
33
+ const v = this.params[name];
34
+ return Array.isArray(v) ? v : [v];
35
+ }
36
+ return [];
37
+ }
38
+ get keys() {
39
+ return Object.keys(this.params);
40
+ }
41
+ }
42
+ function convertToParamMap(params) {
43
+ return new ParamsAsMap(params);
44
+ }
45
+ function defaultUrlMatcher(segments, segmentGroup, route) {
46
+ const parts = route.path.split('/');
47
+ if (parts.length > segments.length) {
48
+ return null;
49
+ }
50
+ if (route.pathMatch === 'full' && (segmentGroup.hasChildren() || parts.length < segments.length)) {
51
+ return null;
52
+ }
53
+ const posParams = {};
54
+ for (let index = 0; index < parts.length; index++) {
55
+ const part = parts[index];
56
+ const segment = segments[index];
57
+ const isParameter = part[0] === ':';
58
+ if (isParameter) {
59
+ posParams[part.substring(1)] = segment;
60
+ } else if (part !== segment.path) {
61
+ return null;
62
+ }
63
+ }
64
+ return {
65
+ consumed: segments.slice(0, parts.length),
66
+ posParams
67
+ };
68
+ }
69
+
70
+ function firstValueFrom(source) {
71
+ return new Promise((resolve, reject) => {
72
+ source.pipe(first()).subscribe({
73
+ next: value => resolve(value),
74
+ error: err => reject(err)
75
+ });
76
+ });
77
+ }
78
+
79
+ function shallowEqualArrays(a, b) {
80
+ if (a.length !== b.length) return false;
81
+ for (let i = 0; i < a.length; ++i) {
82
+ if (!shallowEqual(a[i], b[i])) return false;
83
+ }
84
+ return true;
85
+ }
86
+ function shallowEqual(a, b) {
87
+ const k1 = a ? getDataKeys(a) : undefined;
88
+ const k2 = b ? getDataKeys(b) : undefined;
89
+ if (!k1 || !k2 || k1.length != k2.length) {
90
+ return false;
91
+ }
92
+ let key;
93
+ for (let i = 0; i < k1.length; i++) {
94
+ key = k1[i];
95
+ if (!equalArraysOrString(a[key], b[key])) {
96
+ return false;
97
+ }
98
+ }
99
+ return true;
100
+ }
101
+ function getDataKeys(obj) {
102
+ return [...Object.keys(obj), ...Object.getOwnPropertySymbols(obj)];
103
+ }
104
+ function equalArraysOrString(a, b) {
105
+ if (Array.isArray(a) && Array.isArray(b)) {
106
+ if (a.length !== b.length) return false;
107
+ const aSorted = [...a].sort();
108
+ const bSorted = [...b].sort();
109
+ return aSorted.every((val, index) => bSorted[index] === val);
110
+ } else {
111
+ return a === b;
112
+ }
113
+ }
114
+ function last(a) {
115
+ return a.length > 0 ? a[a.length - 1] : null;
116
+ }
117
+ function wrapIntoObservable(value) {
118
+ if (isObservable(value)) {
119
+ return value;
120
+ }
121
+ if (_isPromise(value)) {
122
+ return from(Promise.resolve(value));
123
+ }
124
+ return of(value);
125
+ }
126
+ function wrapIntoPromise(value) {
127
+ if (isObservable(value)) {
128
+ return firstValueFrom(value);
129
+ }
130
+ return Promise.resolve(value);
131
+ }
132
+
133
+ const pathCompareMap = {
134
+ 'exact': equalSegmentGroups,
135
+ 'subset': containsSegmentGroup
136
+ };
137
+ const paramCompareMap = {
138
+ 'exact': equalParams,
139
+ 'subset': containsParams,
140
+ 'ignored': () => true
141
+ };
142
+ function containsTree(container, containee, options) {
143
+ return pathCompareMap[options.paths](container.root, containee.root, options.matrixParams) && paramCompareMap[options.queryParams](container.queryParams, containee.queryParams) && !(options.fragment === 'exact' && container.fragment !== containee.fragment);
144
+ }
145
+ function equalParams(container, containee) {
146
+ return shallowEqual(container, containee);
147
+ }
148
+ function equalSegmentGroups(container, containee, matrixParams) {
149
+ if (!equalPath(container.segments, containee.segments)) return false;
150
+ if (!matrixParamsMatch(container.segments, containee.segments, matrixParams)) {
151
+ return false;
152
+ }
153
+ if (container.numberOfChildren !== containee.numberOfChildren) return false;
154
+ for (const c in containee.children) {
155
+ if (!container.children[c]) return false;
156
+ if (!equalSegmentGroups(container.children[c], containee.children[c], matrixParams)) return false;
157
+ }
158
+ return true;
159
+ }
160
+ function containsParams(container, containee) {
161
+ return Object.keys(containee).length <= Object.keys(container).length && Object.keys(containee).every(key => equalArraysOrString(container[key], containee[key]));
162
+ }
163
+ function containsSegmentGroup(container, containee, matrixParams) {
164
+ return containsSegmentGroupHelper(container, containee, containee.segments, matrixParams);
165
+ }
166
+ function containsSegmentGroupHelper(container, containee, containeePaths, matrixParams) {
167
+ if (container.segments.length > containeePaths.length) {
168
+ const current = container.segments.slice(0, containeePaths.length);
169
+ if (!equalPath(current, containeePaths)) return false;
170
+ if (containee.hasChildren()) return false;
171
+ if (!matrixParamsMatch(current, containeePaths, matrixParams)) return false;
172
+ return true;
173
+ } else if (container.segments.length === containeePaths.length) {
174
+ if (!equalPath(container.segments, containeePaths)) return false;
175
+ if (!matrixParamsMatch(container.segments, containeePaths, matrixParams)) return false;
176
+ for (const c in containee.children) {
177
+ if (!container.children[c]) return false;
178
+ if (!containsSegmentGroup(container.children[c], containee.children[c], matrixParams)) {
179
+ return false;
180
+ }
181
+ }
182
+ return true;
183
+ } else {
184
+ const current = containeePaths.slice(0, container.segments.length);
185
+ const next = containeePaths.slice(container.segments.length);
186
+ if (!equalPath(container.segments, current)) return false;
187
+ if (!matrixParamsMatch(container.segments, current, matrixParams)) return false;
188
+ if (!container.children[PRIMARY_OUTLET]) return false;
189
+ return containsSegmentGroupHelper(container.children[PRIMARY_OUTLET], containee, next, matrixParams);
190
+ }
191
+ }
192
+ function matrixParamsMatch(containerPaths, containeePaths, options) {
193
+ return containeePaths.every((containeeSegment, i) => {
194
+ return paramCompareMap[options](containerPaths[i].parameters, containeeSegment.parameters);
195
+ });
196
+ }
197
+ class UrlTree {
198
+ root;
199
+ queryParams;
200
+ fragment;
201
+ _queryParamMap;
202
+ constructor(root = new UrlSegmentGroup([], {}), queryParams = {}, fragment = null) {
203
+ this.root = root;
204
+ this.queryParams = queryParams;
205
+ this.fragment = fragment;
206
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
207
+ if (root.segments.length > 0) {
208
+ throw new _RuntimeError(4015, 'The root `UrlSegmentGroup` should not contain `segments`. ' + 'Instead, these segments belong in the `children` so they can be associated with a named outlet.');
209
+ }
210
+ }
211
+ }
212
+ get queryParamMap() {
213
+ this._queryParamMap ??= convertToParamMap(this.queryParams);
214
+ return this._queryParamMap;
215
+ }
216
+ toString() {
217
+ return DEFAULT_SERIALIZER.serialize(this);
218
+ }
219
+ }
220
+ class UrlSegmentGroup {
221
+ segments;
222
+ children;
223
+ parent = null;
224
+ constructor(segments, children) {
225
+ this.segments = segments;
226
+ this.children = children;
227
+ Object.values(children).forEach(v => v.parent = this);
228
+ }
229
+ hasChildren() {
230
+ return this.numberOfChildren > 0;
231
+ }
232
+ get numberOfChildren() {
233
+ return Object.keys(this.children).length;
234
+ }
235
+ toString() {
236
+ return serializePaths(this);
237
+ }
238
+ }
239
+ class UrlSegment {
240
+ path;
241
+ parameters;
242
+ _parameterMap;
243
+ constructor(path, parameters) {
244
+ this.path = path;
245
+ this.parameters = parameters;
246
+ }
247
+ get parameterMap() {
248
+ this._parameterMap ??= convertToParamMap(this.parameters);
249
+ return this._parameterMap;
250
+ }
251
+ toString() {
252
+ return serializePath(this);
253
+ }
254
+ }
255
+ function equalSegments(as, bs) {
256
+ return equalPath(as, bs) && as.every((a, i) => shallowEqual(a.parameters, bs[i].parameters));
257
+ }
258
+ function equalPath(as, bs) {
259
+ if (as.length !== bs.length) return false;
260
+ return as.every((a, i) => a.path === bs[i].path);
261
+ }
262
+ function mapChildrenIntoArray(segment, fn) {
263
+ let res = [];
264
+ Object.entries(segment.children).forEach(([childOutlet, child]) => {
265
+ if (childOutlet === PRIMARY_OUTLET) {
266
+ res = res.concat(fn(child, childOutlet));
267
+ }
268
+ });
269
+ Object.entries(segment.children).forEach(([childOutlet, child]) => {
270
+ if (childOutlet !== PRIMARY_OUTLET) {
271
+ res = res.concat(fn(child, childOutlet));
272
+ }
273
+ });
274
+ return res;
275
+ }
276
+ class UrlSerializer {
277
+ static ɵfac = i0.ɵɵngDeclareFactory({
278
+ minVersion: "12.0.0",
279
+ version: "21.0.0-next.10",
280
+ ngImport: i0,
281
+ type: UrlSerializer,
282
+ deps: [],
283
+ target: i0.ɵɵFactoryTarget.Injectable
284
+ });
285
+ static ɵprov = i0.ɵɵngDeclareInjectable({
286
+ minVersion: "12.0.0",
287
+ version: "21.0.0-next.10",
288
+ ngImport: i0,
289
+ type: UrlSerializer,
290
+ providedIn: 'root',
291
+ useFactory: () => new DefaultUrlSerializer()
292
+ });
293
+ }
294
+ i0.ɵɵngDeclareClassMetadata({
295
+ minVersion: "12.0.0",
296
+ version: "21.0.0-next.10",
297
+ ngImport: i0,
298
+ type: UrlSerializer,
299
+ decorators: [{
300
+ type: Injectable,
301
+ args: [{
302
+ providedIn: 'root',
303
+ useFactory: () => new DefaultUrlSerializer()
304
+ }]
305
+ }]
306
+ });
307
+ class DefaultUrlSerializer {
308
+ parse(url) {
309
+ const p = new UrlParser(url);
310
+ return new UrlTree(p.parseRootSegment(), p.parseQueryParams(), p.parseFragment());
311
+ }
312
+ serialize(tree) {
313
+ const segment = `/${serializeSegment(tree.root, true)}`;
314
+ const query = serializeQueryParams(tree.queryParams);
315
+ const fragment = typeof tree.fragment === `string` ? `#${encodeUriFragment(tree.fragment)}` : '';
316
+ return `${segment}${query}${fragment}`;
317
+ }
318
+ }
319
+ const DEFAULT_SERIALIZER = new DefaultUrlSerializer();
320
+ function serializePaths(segment) {
321
+ return segment.segments.map(p => serializePath(p)).join('/');
322
+ }
323
+ function serializeSegment(segment, root) {
324
+ if (!segment.hasChildren()) {
325
+ return serializePaths(segment);
326
+ }
327
+ if (root) {
328
+ const primary = segment.children[PRIMARY_OUTLET] ? serializeSegment(segment.children[PRIMARY_OUTLET], false) : '';
329
+ const children = [];
330
+ Object.entries(segment.children).forEach(([k, v]) => {
331
+ if (k !== PRIMARY_OUTLET) {
332
+ children.push(`${k}:${serializeSegment(v, false)}`);
333
+ }
334
+ });
335
+ return children.length > 0 ? `${primary}(${children.join('//')})` : primary;
336
+ } else {
337
+ const children = mapChildrenIntoArray(segment, (v, k) => {
338
+ if (k === PRIMARY_OUTLET) {
339
+ return [serializeSegment(segment.children[PRIMARY_OUTLET], false)];
340
+ }
341
+ return [`${k}:${serializeSegment(v, false)}`];
342
+ });
343
+ if (Object.keys(segment.children).length === 1 && segment.children[PRIMARY_OUTLET] != null) {
344
+ return `${serializePaths(segment)}/${children[0]}`;
345
+ }
346
+ return `${serializePaths(segment)}/(${children.join('//')})`;
347
+ }
348
+ }
349
+ function encodeUriString(s) {
350
+ return encodeURIComponent(s).replace(/%40/g, '@').replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',');
351
+ }
352
+ function encodeUriQuery(s) {
353
+ return encodeUriString(s).replace(/%3B/gi, ';');
354
+ }
355
+ function encodeUriFragment(s) {
356
+ return encodeURI(s);
357
+ }
358
+ function encodeUriSegment(s) {
359
+ return encodeUriString(s).replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/%26/gi, '&');
360
+ }
361
+ function decode(s) {
362
+ return decodeURIComponent(s);
363
+ }
364
+ function decodeQuery(s) {
365
+ return decode(s.replace(/\+/g, '%20'));
366
+ }
367
+ function serializePath(path) {
368
+ return `${encodeUriSegment(path.path)}${serializeMatrixParams(path.parameters)}`;
369
+ }
370
+ function serializeMatrixParams(params) {
371
+ return Object.entries(params).map(([key, value]) => `;${encodeUriSegment(key)}=${encodeUriSegment(value)}`).join('');
372
+ }
373
+ function serializeQueryParams(params) {
374
+ const strParams = Object.entries(params).map(([name, value]) => {
375
+ return Array.isArray(value) ? value.map(v => `${encodeUriQuery(name)}=${encodeUriQuery(v)}`).join('&') : `${encodeUriQuery(name)}=${encodeUriQuery(value)}`;
376
+ }).filter(s => s);
377
+ return strParams.length ? `?${strParams.join('&')}` : '';
378
+ }
379
+ const SEGMENT_RE = /^[^\/()?;#]+/;
380
+ function matchSegments(str) {
381
+ const match = str.match(SEGMENT_RE);
382
+ return match ? match[0] : '';
383
+ }
384
+ const MATRIX_PARAM_SEGMENT_RE = /^[^\/()?;=#]+/;
385
+ function matchMatrixKeySegments(str) {
386
+ const match = str.match(MATRIX_PARAM_SEGMENT_RE);
387
+ return match ? match[0] : '';
388
+ }
389
+ const QUERY_PARAM_RE = /^[^=?&#]+/;
390
+ function matchQueryParams(str) {
391
+ const match = str.match(QUERY_PARAM_RE);
392
+ return match ? match[0] : '';
393
+ }
394
+ const QUERY_PARAM_VALUE_RE = /^[^&#]+/;
395
+ function matchUrlQueryParamValue(str) {
396
+ const match = str.match(QUERY_PARAM_VALUE_RE);
397
+ return match ? match[0] : '';
398
+ }
399
+ class UrlParser {
400
+ url;
401
+ remaining;
402
+ constructor(url) {
403
+ this.url = url;
404
+ this.remaining = url;
405
+ }
406
+ parseRootSegment() {
407
+ this.consumeOptional('/');
408
+ if (this.remaining === '' || this.peekStartsWith('?') || this.peekStartsWith('#')) {
409
+ return new UrlSegmentGroup([], {});
410
+ }
411
+ return new UrlSegmentGroup([], this.parseChildren());
412
+ }
413
+ parseQueryParams() {
414
+ const params = {};
415
+ if (this.consumeOptional('?')) {
416
+ do {
417
+ this.parseQueryParam(params);
418
+ } while (this.consumeOptional('&'));
419
+ }
420
+ return params;
421
+ }
422
+ parseFragment() {
423
+ return this.consumeOptional('#') ? decodeURIComponent(this.remaining) : null;
424
+ }
425
+ parseChildren() {
426
+ if (this.remaining === '') {
427
+ return {};
428
+ }
429
+ this.consumeOptional('/');
430
+ const segments = [];
431
+ if (!this.peekStartsWith('(')) {
432
+ segments.push(this.parseSegment());
433
+ }
434
+ while (this.peekStartsWith('/') && !this.peekStartsWith('//') && !this.peekStartsWith('/(')) {
435
+ this.capture('/');
436
+ segments.push(this.parseSegment());
437
+ }
438
+ let children = {};
439
+ if (this.peekStartsWith('/(')) {
440
+ this.capture('/');
441
+ children = this.parseParens(true);
442
+ }
443
+ let res = {};
444
+ if (this.peekStartsWith('(')) {
445
+ res = this.parseParens(false);
446
+ }
447
+ if (segments.length > 0 || Object.keys(children).length > 0) {
448
+ res[PRIMARY_OUTLET] = new UrlSegmentGroup(segments, children);
449
+ }
450
+ return res;
451
+ }
452
+ parseSegment() {
453
+ const path = matchSegments(this.remaining);
454
+ if (path === '' && this.peekStartsWith(';')) {
455
+ throw new _RuntimeError(4009, (typeof ngDevMode === 'undefined' || ngDevMode) && `Empty path url segment cannot have parameters: '${this.remaining}'.`);
456
+ }
457
+ this.capture(path);
458
+ return new UrlSegment(decode(path), this.parseMatrixParams());
459
+ }
460
+ parseMatrixParams() {
461
+ const params = {};
462
+ while (this.consumeOptional(';')) {
463
+ this.parseParam(params);
464
+ }
465
+ return params;
466
+ }
467
+ parseParam(params) {
468
+ const key = matchMatrixKeySegments(this.remaining);
469
+ if (!key) {
470
+ return;
471
+ }
472
+ this.capture(key);
473
+ let value = '';
474
+ if (this.consumeOptional('=')) {
475
+ const valueMatch = matchSegments(this.remaining);
476
+ if (valueMatch) {
477
+ value = valueMatch;
478
+ this.capture(value);
479
+ }
480
+ }
481
+ params[decode(key)] = decode(value);
482
+ }
483
+ parseQueryParam(params) {
484
+ const key = matchQueryParams(this.remaining);
485
+ if (!key) {
486
+ return;
487
+ }
488
+ this.capture(key);
489
+ let value = '';
490
+ if (this.consumeOptional('=')) {
491
+ const valueMatch = matchUrlQueryParamValue(this.remaining);
492
+ if (valueMatch) {
493
+ value = valueMatch;
494
+ this.capture(value);
495
+ }
496
+ }
497
+ const decodedKey = decodeQuery(key);
498
+ const decodedVal = decodeQuery(value);
499
+ if (params.hasOwnProperty(decodedKey)) {
500
+ let currentVal = params[decodedKey];
501
+ if (!Array.isArray(currentVal)) {
502
+ currentVal = [currentVal];
503
+ params[decodedKey] = currentVal;
504
+ }
505
+ currentVal.push(decodedVal);
506
+ } else {
507
+ params[decodedKey] = decodedVal;
508
+ }
509
+ }
510
+ parseParens(allowPrimary) {
511
+ const segments = {};
512
+ this.capture('(');
513
+ while (!this.consumeOptional(')') && this.remaining.length > 0) {
514
+ const path = matchSegments(this.remaining);
515
+ const next = this.remaining[path.length];
516
+ if (next !== '/' && next !== ')' && next !== ';') {
517
+ throw new _RuntimeError(4010, (typeof ngDevMode === 'undefined' || ngDevMode) && `Cannot parse url '${this.url}'`);
518
+ }
519
+ let outletName;
520
+ if (path.indexOf(':') > -1) {
521
+ outletName = path.slice(0, path.indexOf(':'));
522
+ this.capture(outletName);
523
+ this.capture(':');
524
+ } else if (allowPrimary) {
525
+ outletName = PRIMARY_OUTLET;
526
+ }
527
+ const children = this.parseChildren();
528
+ segments[outletName ?? PRIMARY_OUTLET] = Object.keys(children).length === 1 && children[PRIMARY_OUTLET] ? children[PRIMARY_OUTLET] : new UrlSegmentGroup([], children);
529
+ this.consumeOptional('//');
530
+ }
531
+ return segments;
532
+ }
533
+ peekStartsWith(str) {
534
+ return this.remaining.startsWith(str);
535
+ }
536
+ consumeOptional(str) {
537
+ if (this.peekStartsWith(str)) {
538
+ this.remaining = this.remaining.substring(str.length);
539
+ return true;
540
+ }
541
+ return false;
542
+ }
543
+ capture(str) {
544
+ if (!this.consumeOptional(str)) {
545
+ throw new _RuntimeError(4011, (typeof ngDevMode === 'undefined' || ngDevMode) && `Expected "${str}".`);
546
+ }
547
+ }
548
+ }
549
+ function createRoot(rootCandidate) {
550
+ return rootCandidate.segments.length > 0 ? new UrlSegmentGroup([], {
551
+ [PRIMARY_OUTLET]: rootCandidate
552
+ }) : rootCandidate;
553
+ }
554
+ function squashSegmentGroup(segmentGroup) {
555
+ const newChildren = {};
556
+ for (const [childOutlet, child] of Object.entries(segmentGroup.children)) {
557
+ const childCandidate = squashSegmentGroup(child);
558
+ if (childOutlet === PRIMARY_OUTLET && childCandidate.segments.length === 0 && childCandidate.hasChildren()) {
559
+ for (const [grandChildOutlet, grandChild] of Object.entries(childCandidate.children)) {
560
+ newChildren[grandChildOutlet] = grandChild;
561
+ }
562
+ } else if (childCandidate.segments.length > 0 || childCandidate.hasChildren()) {
563
+ newChildren[childOutlet] = childCandidate;
564
+ }
565
+ }
566
+ const s = new UrlSegmentGroup(segmentGroup.segments, newChildren);
567
+ return mergeTrivialChildren(s);
568
+ }
569
+ function mergeTrivialChildren(s) {
570
+ if (s.numberOfChildren === 1 && s.children[PRIMARY_OUTLET]) {
571
+ const c = s.children[PRIMARY_OUTLET];
572
+ return new UrlSegmentGroup(s.segments.concat(c.segments), c.children);
573
+ }
574
+ return s;
575
+ }
576
+ function isUrlTree(v) {
577
+ return v instanceof UrlTree;
578
+ }
579
+
580
+ function createUrlTreeFromSnapshot(relativeTo, commands, queryParams = null, fragment = null, urlSerializer = new DefaultUrlSerializer()) {
581
+ const relativeToUrlSegmentGroup = createSegmentGroupFromRoute(relativeTo);
582
+ return createUrlTreeFromSegmentGroup(relativeToUrlSegmentGroup, commands, queryParams, fragment, urlSerializer);
583
+ }
584
+ function createSegmentGroupFromRoute(route) {
585
+ let targetGroup;
586
+ function createSegmentGroupFromRouteRecursive(currentRoute) {
587
+ const childOutlets = {};
588
+ for (const childSnapshot of currentRoute.children) {
589
+ const root = createSegmentGroupFromRouteRecursive(childSnapshot);
590
+ childOutlets[childSnapshot.outlet] = root;
591
+ }
592
+ const segmentGroup = new UrlSegmentGroup(currentRoute.url, childOutlets);
593
+ if (currentRoute === route) {
594
+ targetGroup = segmentGroup;
595
+ }
596
+ return segmentGroup;
597
+ }
598
+ const rootCandidate = createSegmentGroupFromRouteRecursive(route.root);
599
+ const rootSegmentGroup = createRoot(rootCandidate);
600
+ return targetGroup ?? rootSegmentGroup;
601
+ }
602
+ function createUrlTreeFromSegmentGroup(relativeTo, commands, queryParams, fragment, urlSerializer) {
603
+ let root = relativeTo;
604
+ while (root.parent) {
605
+ root = root.parent;
606
+ }
607
+ if (commands.length === 0) {
608
+ return tree(root, root, root, queryParams, fragment, urlSerializer);
609
+ }
610
+ const nav = computeNavigation(commands);
611
+ if (nav.toRoot()) {
612
+ return tree(root, root, new UrlSegmentGroup([], {}), queryParams, fragment, urlSerializer);
613
+ }
614
+ const position = findStartingPositionForTargetGroup(nav, root, relativeTo);
615
+ const newSegmentGroup = position.processChildren ? updateSegmentGroupChildren(position.segmentGroup, position.index, nav.commands) : updateSegmentGroup(position.segmentGroup, position.index, nav.commands);
616
+ return tree(root, position.segmentGroup, newSegmentGroup, queryParams, fragment, urlSerializer);
617
+ }
618
+ function isMatrixParams(command) {
619
+ return typeof command === 'object' && command != null && !command.outlets && !command.segmentPath;
620
+ }
621
+ function isCommandWithOutlets(command) {
622
+ return typeof command === 'object' && command != null && command.outlets;
623
+ }
624
+ function normalizeQueryParams(k, v, urlSerializer) {
625
+ k ||= 'ɵ';
626
+ const tree = new UrlTree();
627
+ tree.queryParams = {
628
+ [k]: v
629
+ };
630
+ return urlSerializer.parse(urlSerializer.serialize(tree)).queryParams[k];
631
+ }
632
+ function tree(oldRoot, oldSegmentGroup, newSegmentGroup, queryParams, fragment, urlSerializer) {
633
+ const qp = {};
634
+ for (const [key, value] of Object.entries(queryParams ?? {})) {
635
+ qp[key] = Array.isArray(value) ? value.map(v => normalizeQueryParams(key, v, urlSerializer)) : normalizeQueryParams(key, value, urlSerializer);
636
+ }
637
+ let rootCandidate;
638
+ if (oldRoot === oldSegmentGroup) {
639
+ rootCandidate = newSegmentGroup;
640
+ } else {
641
+ rootCandidate = replaceSegment(oldRoot, oldSegmentGroup, newSegmentGroup);
642
+ }
643
+ const newRoot = createRoot(squashSegmentGroup(rootCandidate));
644
+ return new UrlTree(newRoot, qp, fragment);
645
+ }
646
+ function replaceSegment(current, oldSegment, newSegment) {
647
+ const children = {};
648
+ Object.entries(current.children).forEach(([outletName, c]) => {
649
+ if (c === oldSegment) {
650
+ children[outletName] = newSegment;
651
+ } else {
652
+ children[outletName] = replaceSegment(c, oldSegment, newSegment);
653
+ }
654
+ });
655
+ return new UrlSegmentGroup(current.segments, children);
656
+ }
657
+ class Navigation {
658
+ isAbsolute;
659
+ numberOfDoubleDots;
660
+ commands;
661
+ constructor(isAbsolute, numberOfDoubleDots, commands) {
662
+ this.isAbsolute = isAbsolute;
663
+ this.numberOfDoubleDots = numberOfDoubleDots;
664
+ this.commands = commands;
665
+ if (isAbsolute && commands.length > 0 && isMatrixParams(commands[0])) {
666
+ throw new _RuntimeError(4003, (typeof ngDevMode === 'undefined' || ngDevMode) && 'Root segment cannot have matrix parameters');
667
+ }
668
+ const cmdWithOutlet = commands.find(isCommandWithOutlets);
669
+ if (cmdWithOutlet && cmdWithOutlet !== last(commands)) {
670
+ throw new _RuntimeError(4004, (typeof ngDevMode === 'undefined' || ngDevMode) && '{outlets:{}} has to be the last command');
671
+ }
672
+ }
673
+ toRoot() {
674
+ return this.isAbsolute && this.commands.length === 1 && this.commands[0] == '/';
675
+ }
676
+ }
677
+ function computeNavigation(commands) {
678
+ if (typeof commands[0] === 'string' && commands.length === 1 && commands[0] === '/') {
679
+ return new Navigation(true, 0, commands);
680
+ }
681
+ let numberOfDoubleDots = 0;
682
+ let isAbsolute = false;
683
+ const res = commands.reduce((res, cmd, cmdIdx) => {
684
+ if (typeof cmd === 'object' && cmd != null) {
685
+ if (cmd.outlets) {
686
+ const outlets = {};
687
+ Object.entries(cmd.outlets).forEach(([name, commands]) => {
688
+ outlets[name] = typeof commands === 'string' ? commands.split('/') : commands;
689
+ });
690
+ return [...res, {
691
+ outlets
692
+ }];
693
+ }
694
+ if (cmd.segmentPath) {
695
+ return [...res, cmd.segmentPath];
696
+ }
697
+ }
698
+ if (!(typeof cmd === 'string')) {
699
+ return [...res, cmd];
700
+ }
701
+ if (cmdIdx === 0) {
702
+ cmd.split('/').forEach((urlPart, partIndex) => {
703
+ if (partIndex == 0 && urlPart === '.') ; else if (partIndex == 0 && urlPart === '') {
704
+ isAbsolute = true;
705
+ } else if (urlPart === '..') {
706
+ numberOfDoubleDots++;
707
+ } else if (urlPart != '') {
708
+ res.push(urlPart);
709
+ }
710
+ });
711
+ return res;
712
+ }
713
+ return [...res, cmd];
714
+ }, []);
715
+ return new Navigation(isAbsolute, numberOfDoubleDots, res);
716
+ }
717
+ class Position {
718
+ segmentGroup;
719
+ processChildren;
720
+ index;
721
+ constructor(segmentGroup, processChildren, index) {
722
+ this.segmentGroup = segmentGroup;
723
+ this.processChildren = processChildren;
724
+ this.index = index;
725
+ }
726
+ }
727
+ function findStartingPositionForTargetGroup(nav, root, target) {
728
+ if (nav.isAbsolute) {
729
+ return new Position(root, true, 0);
730
+ }
731
+ if (!target) {
732
+ return new Position(root, false, NaN);
733
+ }
734
+ if (target.parent === null) {
735
+ return new Position(target, true, 0);
736
+ }
737
+ const modifier = isMatrixParams(nav.commands[0]) ? 0 : 1;
738
+ const index = target.segments.length - 1 + modifier;
739
+ return createPositionApplyingDoubleDots(target, index, nav.numberOfDoubleDots);
740
+ }
741
+ function createPositionApplyingDoubleDots(group, index, numberOfDoubleDots) {
742
+ let g = group;
743
+ let ci = index;
744
+ let dd = numberOfDoubleDots;
745
+ while (dd > ci) {
746
+ dd -= ci;
747
+ g = g.parent;
748
+ if (!g) {
749
+ throw new _RuntimeError(4005, (typeof ngDevMode === 'undefined' || ngDevMode) && "Invalid number of '../'");
750
+ }
751
+ ci = g.segments.length;
752
+ }
753
+ return new Position(g, false, ci - dd);
754
+ }
755
+ function getOutlets(commands) {
756
+ if (isCommandWithOutlets(commands[0])) {
757
+ return commands[0].outlets;
758
+ }
759
+ return {
760
+ [PRIMARY_OUTLET]: commands
761
+ };
762
+ }
763
+ function updateSegmentGroup(segmentGroup, startIndex, commands) {
764
+ segmentGroup ??= new UrlSegmentGroup([], {});
765
+ if (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) {
766
+ return updateSegmentGroupChildren(segmentGroup, startIndex, commands);
767
+ }
768
+ const m = prefixedWith(segmentGroup, startIndex, commands);
769
+ const slicedCommands = commands.slice(m.commandIndex);
770
+ if (m.match && m.pathIndex < segmentGroup.segments.length) {
771
+ const g = new UrlSegmentGroup(segmentGroup.segments.slice(0, m.pathIndex), {});
772
+ g.children[PRIMARY_OUTLET] = new UrlSegmentGroup(segmentGroup.segments.slice(m.pathIndex), segmentGroup.children);
773
+ return updateSegmentGroupChildren(g, 0, slicedCommands);
774
+ } else if (m.match && slicedCommands.length === 0) {
775
+ return new UrlSegmentGroup(segmentGroup.segments, {});
776
+ } else if (m.match && !segmentGroup.hasChildren()) {
777
+ return createNewSegmentGroup(segmentGroup, startIndex, commands);
778
+ } else if (m.match) {
779
+ return updateSegmentGroupChildren(segmentGroup, 0, slicedCommands);
780
+ } else {
781
+ return createNewSegmentGroup(segmentGroup, startIndex, commands);
782
+ }
783
+ }
784
+ function updateSegmentGroupChildren(segmentGroup, startIndex, commands) {
785
+ if (commands.length === 0) {
786
+ return new UrlSegmentGroup(segmentGroup.segments, {});
787
+ } else {
788
+ const outlets = getOutlets(commands);
789
+ const children = {};
790
+ if (Object.keys(outlets).some(o => o !== PRIMARY_OUTLET) && segmentGroup.children[PRIMARY_OUTLET] && segmentGroup.numberOfChildren === 1 && segmentGroup.children[PRIMARY_OUTLET].segments.length === 0) {
791
+ const childrenOfEmptyChild = updateSegmentGroupChildren(segmentGroup.children[PRIMARY_OUTLET], startIndex, commands);
792
+ return new UrlSegmentGroup(segmentGroup.segments, childrenOfEmptyChild.children);
793
+ }
794
+ Object.entries(outlets).forEach(([outlet, commands]) => {
795
+ if (typeof commands === 'string') {
796
+ commands = [commands];
797
+ }
798
+ if (commands !== null) {
799
+ children[outlet] = updateSegmentGroup(segmentGroup.children[outlet], startIndex, commands);
800
+ }
801
+ });
802
+ Object.entries(segmentGroup.children).forEach(([childOutlet, child]) => {
803
+ if (outlets[childOutlet] === undefined) {
804
+ children[childOutlet] = child;
805
+ }
806
+ });
807
+ return new UrlSegmentGroup(segmentGroup.segments, children);
808
+ }
809
+ }
810
+ function prefixedWith(segmentGroup, startIndex, commands) {
811
+ let currentCommandIndex = 0;
812
+ let currentPathIndex = startIndex;
813
+ const noMatch = {
814
+ match: false,
815
+ pathIndex: 0,
816
+ commandIndex: 0
817
+ };
818
+ while (currentPathIndex < segmentGroup.segments.length) {
819
+ if (currentCommandIndex >= commands.length) return noMatch;
820
+ const path = segmentGroup.segments[currentPathIndex];
821
+ const command = commands[currentCommandIndex];
822
+ if (isCommandWithOutlets(command)) {
823
+ break;
824
+ }
825
+ const curr = `${command}`;
826
+ const next = currentCommandIndex < commands.length - 1 ? commands[currentCommandIndex + 1] : null;
827
+ if (currentPathIndex > 0 && curr === undefined) break;
828
+ if (curr && next && typeof next === 'object' && next.outlets === undefined) {
829
+ if (!compare(curr, next, path)) return noMatch;
830
+ currentCommandIndex += 2;
831
+ } else {
832
+ if (!compare(curr, {}, path)) return noMatch;
833
+ currentCommandIndex++;
834
+ }
835
+ currentPathIndex++;
836
+ }
837
+ return {
838
+ match: true,
839
+ pathIndex: currentPathIndex,
840
+ commandIndex: currentCommandIndex
841
+ };
842
+ }
843
+ function createNewSegmentGroup(segmentGroup, startIndex, commands) {
844
+ const paths = segmentGroup.segments.slice(0, startIndex);
845
+ let i = 0;
846
+ while (i < commands.length) {
847
+ const command = commands[i];
848
+ if (isCommandWithOutlets(command)) {
849
+ const children = createNewSegmentChildren(command.outlets);
850
+ return new UrlSegmentGroup(paths, children);
851
+ }
852
+ if (i === 0 && isMatrixParams(commands[0])) {
853
+ const p = segmentGroup.segments[startIndex];
854
+ paths.push(new UrlSegment(p.path, stringify(commands[0])));
855
+ i++;
856
+ continue;
857
+ }
858
+ const curr = isCommandWithOutlets(command) ? command.outlets[PRIMARY_OUTLET] : `${command}`;
859
+ const next = i < commands.length - 1 ? commands[i + 1] : null;
860
+ if (curr && next && isMatrixParams(next)) {
861
+ paths.push(new UrlSegment(curr, stringify(next)));
862
+ i += 2;
863
+ } else {
864
+ paths.push(new UrlSegment(curr, {}));
865
+ i++;
866
+ }
867
+ }
868
+ return new UrlSegmentGroup(paths, {});
869
+ }
870
+ function createNewSegmentChildren(outlets) {
871
+ const children = {};
872
+ Object.entries(outlets).forEach(([outlet, commands]) => {
873
+ if (typeof commands === 'string') {
874
+ commands = [commands];
875
+ }
876
+ if (commands !== null) {
877
+ children[outlet] = createNewSegmentGroup(new UrlSegmentGroup([], {}), 0, commands);
878
+ }
879
+ });
880
+ return children;
881
+ }
882
+ function stringify(params) {
883
+ const res = {};
884
+ Object.entries(params).forEach(([k, v]) => res[k] = `${v}`);
885
+ return res;
886
+ }
887
+ function compare(path, params, segment) {
888
+ return path == segment.path && shallowEqual(params, segment.parameters);
889
+ }
890
+
891
+ const IMPERATIVE_NAVIGATION = 'imperative';
892
+ var EventType;
893
+ (function (EventType) {
894
+ EventType[EventType["NavigationStart"] = 0] = "NavigationStart";
895
+ EventType[EventType["NavigationEnd"] = 1] = "NavigationEnd";
896
+ EventType[EventType["NavigationCancel"] = 2] = "NavigationCancel";
897
+ EventType[EventType["NavigationError"] = 3] = "NavigationError";
898
+ EventType[EventType["RoutesRecognized"] = 4] = "RoutesRecognized";
899
+ EventType[EventType["ResolveStart"] = 5] = "ResolveStart";
900
+ EventType[EventType["ResolveEnd"] = 6] = "ResolveEnd";
901
+ EventType[EventType["GuardsCheckStart"] = 7] = "GuardsCheckStart";
902
+ EventType[EventType["GuardsCheckEnd"] = 8] = "GuardsCheckEnd";
903
+ EventType[EventType["RouteConfigLoadStart"] = 9] = "RouteConfigLoadStart";
904
+ EventType[EventType["RouteConfigLoadEnd"] = 10] = "RouteConfigLoadEnd";
905
+ EventType[EventType["ChildActivationStart"] = 11] = "ChildActivationStart";
906
+ EventType[EventType["ChildActivationEnd"] = 12] = "ChildActivationEnd";
907
+ EventType[EventType["ActivationStart"] = 13] = "ActivationStart";
908
+ EventType[EventType["ActivationEnd"] = 14] = "ActivationEnd";
909
+ EventType[EventType["Scroll"] = 15] = "Scroll";
910
+ EventType[EventType["NavigationSkipped"] = 16] = "NavigationSkipped";
911
+ })(EventType || (EventType = {}));
912
+ class RouterEvent {
913
+ id;
914
+ url;
915
+ constructor(id, url) {
916
+ this.id = id;
917
+ this.url = url;
918
+ }
919
+ }
920
+ class NavigationStart extends RouterEvent {
921
+ type = EventType.NavigationStart;
922
+ navigationTrigger;
923
+ restoredState;
924
+ constructor(id, url, navigationTrigger = 'imperative', restoredState = null) {
925
+ super(id, url);
926
+ this.navigationTrigger = navigationTrigger;
927
+ this.restoredState = restoredState;
928
+ }
929
+ toString() {
930
+ return `NavigationStart(id: ${this.id}, url: '${this.url}')`;
931
+ }
932
+ }
933
+ class NavigationEnd extends RouterEvent {
934
+ urlAfterRedirects;
935
+ type = EventType.NavigationEnd;
936
+ constructor(id, url, urlAfterRedirects) {
937
+ super(id, url);
938
+ this.urlAfterRedirects = urlAfterRedirects;
939
+ }
940
+ toString() {
941
+ return `NavigationEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}')`;
942
+ }
943
+ }
944
+ var NavigationCancellationCode;
945
+ (function (NavigationCancellationCode) {
946
+ NavigationCancellationCode[NavigationCancellationCode["Redirect"] = 0] = "Redirect";
947
+ NavigationCancellationCode[NavigationCancellationCode["SupersededByNewNavigation"] = 1] = "SupersededByNewNavigation";
948
+ NavigationCancellationCode[NavigationCancellationCode["NoDataFromResolver"] = 2] = "NoDataFromResolver";
949
+ NavigationCancellationCode[NavigationCancellationCode["GuardRejected"] = 3] = "GuardRejected";
950
+ NavigationCancellationCode[NavigationCancellationCode["Aborted"] = 4] = "Aborted";
951
+ })(NavigationCancellationCode || (NavigationCancellationCode = {}));
952
+ var NavigationSkippedCode;
953
+ (function (NavigationSkippedCode) {
954
+ NavigationSkippedCode[NavigationSkippedCode["IgnoredSameUrlNavigation"] = 0] = "IgnoredSameUrlNavigation";
955
+ NavigationSkippedCode[NavigationSkippedCode["IgnoredByUrlHandlingStrategy"] = 1] = "IgnoredByUrlHandlingStrategy";
956
+ })(NavigationSkippedCode || (NavigationSkippedCode = {}));
957
+ class NavigationCancel extends RouterEvent {
958
+ reason;
959
+ code;
960
+ type = EventType.NavigationCancel;
961
+ constructor(id, url, reason, code) {
962
+ super(id, url);
963
+ this.reason = reason;
964
+ this.code = code;
965
+ }
966
+ toString() {
967
+ return `NavigationCancel(id: ${this.id}, url: '${this.url}')`;
968
+ }
969
+ }
970
+ class NavigationSkipped extends RouterEvent {
971
+ reason;
972
+ code;
973
+ type = EventType.NavigationSkipped;
974
+ constructor(id, url, reason, code) {
975
+ super(id, url);
976
+ this.reason = reason;
977
+ this.code = code;
978
+ }
979
+ }
980
+ class NavigationError extends RouterEvent {
981
+ error;
982
+ target;
983
+ type = EventType.NavigationError;
984
+ constructor(id, url, error, target) {
985
+ super(id, url);
986
+ this.error = error;
987
+ this.target = target;
988
+ }
989
+ toString() {
990
+ return `NavigationError(id: ${this.id}, url: '${this.url}', error: ${this.error})`;
991
+ }
992
+ }
993
+ class RoutesRecognized extends RouterEvent {
994
+ urlAfterRedirects;
995
+ state;
996
+ type = EventType.RoutesRecognized;
997
+ constructor(id, url, urlAfterRedirects, state) {
998
+ super(id, url);
999
+ this.urlAfterRedirects = urlAfterRedirects;
1000
+ this.state = state;
1001
+ }
1002
+ toString() {
1003
+ return `RoutesRecognized(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`;
1004
+ }
1005
+ }
1006
+ class GuardsCheckStart extends RouterEvent {
1007
+ urlAfterRedirects;
1008
+ state;
1009
+ type = EventType.GuardsCheckStart;
1010
+ constructor(id, url, urlAfterRedirects, state) {
1011
+ super(id, url);
1012
+ this.urlAfterRedirects = urlAfterRedirects;
1013
+ this.state = state;
1014
+ }
1015
+ toString() {
1016
+ return `GuardsCheckStart(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`;
1017
+ }
1018
+ }
1019
+ class GuardsCheckEnd extends RouterEvent {
1020
+ urlAfterRedirects;
1021
+ state;
1022
+ shouldActivate;
1023
+ type = EventType.GuardsCheckEnd;
1024
+ constructor(id, url, urlAfterRedirects, state, shouldActivate) {
1025
+ super(id, url);
1026
+ this.urlAfterRedirects = urlAfterRedirects;
1027
+ this.state = state;
1028
+ this.shouldActivate = shouldActivate;
1029
+ }
1030
+ toString() {
1031
+ return `GuardsCheckEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state}, shouldActivate: ${this.shouldActivate})`;
1032
+ }
1033
+ }
1034
+ class ResolveStart extends RouterEvent {
1035
+ urlAfterRedirects;
1036
+ state;
1037
+ type = EventType.ResolveStart;
1038
+ constructor(id, url, urlAfterRedirects, state) {
1039
+ super(id, url);
1040
+ this.urlAfterRedirects = urlAfterRedirects;
1041
+ this.state = state;
1042
+ }
1043
+ toString() {
1044
+ return `ResolveStart(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`;
1045
+ }
1046
+ }
1047
+ class ResolveEnd extends RouterEvent {
1048
+ urlAfterRedirects;
1049
+ state;
1050
+ type = EventType.ResolveEnd;
1051
+ constructor(id, url, urlAfterRedirects, state) {
1052
+ super(id, url);
1053
+ this.urlAfterRedirects = urlAfterRedirects;
1054
+ this.state = state;
1055
+ }
1056
+ toString() {
1057
+ return `ResolveEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`;
1058
+ }
1059
+ }
1060
+ class RouteConfigLoadStart {
1061
+ route;
1062
+ type = EventType.RouteConfigLoadStart;
1063
+ constructor(route) {
1064
+ this.route = route;
1065
+ }
1066
+ toString() {
1067
+ return `RouteConfigLoadStart(path: ${this.route.path})`;
1068
+ }
1069
+ }
1070
+ class RouteConfigLoadEnd {
1071
+ route;
1072
+ type = EventType.RouteConfigLoadEnd;
1073
+ constructor(route) {
1074
+ this.route = route;
1075
+ }
1076
+ toString() {
1077
+ return `RouteConfigLoadEnd(path: ${this.route.path})`;
1078
+ }
1079
+ }
1080
+ class ChildActivationStart {
1081
+ snapshot;
1082
+ type = EventType.ChildActivationStart;
1083
+ constructor(snapshot) {
1084
+ this.snapshot = snapshot;
1085
+ }
1086
+ toString() {
1087
+ const path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
1088
+ return `ChildActivationStart(path: '${path}')`;
1089
+ }
1090
+ }
1091
+ class ChildActivationEnd {
1092
+ snapshot;
1093
+ type = EventType.ChildActivationEnd;
1094
+ constructor(snapshot) {
1095
+ this.snapshot = snapshot;
1096
+ }
1097
+ toString() {
1098
+ const path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
1099
+ return `ChildActivationEnd(path: '${path}')`;
1100
+ }
1101
+ }
1102
+ class ActivationStart {
1103
+ snapshot;
1104
+ type = EventType.ActivationStart;
1105
+ constructor(snapshot) {
1106
+ this.snapshot = snapshot;
1107
+ }
1108
+ toString() {
1109
+ const path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
1110
+ return `ActivationStart(path: '${path}')`;
1111
+ }
1112
+ }
1113
+ class ActivationEnd {
1114
+ snapshot;
1115
+ type = EventType.ActivationEnd;
1116
+ constructor(snapshot) {
1117
+ this.snapshot = snapshot;
1118
+ }
1119
+ toString() {
1120
+ const path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
1121
+ return `ActivationEnd(path: '${path}')`;
1122
+ }
1123
+ }
1124
+ class Scroll {
1125
+ routerEvent;
1126
+ position;
1127
+ anchor;
1128
+ type = EventType.Scroll;
1129
+ constructor(routerEvent, position, anchor) {
1130
+ this.routerEvent = routerEvent;
1131
+ this.position = position;
1132
+ this.anchor = anchor;
1133
+ }
1134
+ toString() {
1135
+ const pos = this.position ? `${this.position[0]}, ${this.position[1]}` : null;
1136
+ return `Scroll(anchor: '${this.anchor}', position: '${pos}')`;
1137
+ }
1138
+ }
1139
+ class BeforeActivateRoutes {}
1140
+ class RedirectRequest {
1141
+ url;
1142
+ navigationBehaviorOptions;
1143
+ constructor(url, navigationBehaviorOptions) {
1144
+ this.url = url;
1145
+ this.navigationBehaviorOptions = navigationBehaviorOptions;
1146
+ }
1147
+ }
1148
+ function isPublicRouterEvent(e) {
1149
+ return !(e instanceof BeforeActivateRoutes) && !(e instanceof RedirectRequest);
1150
+ }
1151
+ function stringifyEvent(routerEvent) {
1152
+ switch (routerEvent.type) {
1153
+ case EventType.ActivationEnd:
1154
+ return `ActivationEnd(path: '${routerEvent.snapshot.routeConfig?.path || ''}')`;
1155
+ case EventType.ActivationStart:
1156
+ return `ActivationStart(path: '${routerEvent.snapshot.routeConfig?.path || ''}')`;
1157
+ case EventType.ChildActivationEnd:
1158
+ return `ChildActivationEnd(path: '${routerEvent.snapshot.routeConfig?.path || ''}')`;
1159
+ case EventType.ChildActivationStart:
1160
+ return `ChildActivationStart(path: '${routerEvent.snapshot.routeConfig?.path || ''}')`;
1161
+ case EventType.GuardsCheckEnd:
1162
+ return `GuardsCheckEnd(id: ${routerEvent.id}, url: '${routerEvent.url}', urlAfterRedirects: '${routerEvent.urlAfterRedirects}', state: ${routerEvent.state}, shouldActivate: ${routerEvent.shouldActivate})`;
1163
+ case EventType.GuardsCheckStart:
1164
+ return `GuardsCheckStart(id: ${routerEvent.id}, url: '${routerEvent.url}', urlAfterRedirects: '${routerEvent.urlAfterRedirects}', state: ${routerEvent.state})`;
1165
+ case EventType.NavigationCancel:
1166
+ return `NavigationCancel(id: ${routerEvent.id}, url: '${routerEvent.url}')`;
1167
+ case EventType.NavigationSkipped:
1168
+ return `NavigationSkipped(id: ${routerEvent.id}, url: '${routerEvent.url}')`;
1169
+ case EventType.NavigationEnd:
1170
+ return `NavigationEnd(id: ${routerEvent.id}, url: '${routerEvent.url}', urlAfterRedirects: '${routerEvent.urlAfterRedirects}')`;
1171
+ case EventType.NavigationError:
1172
+ return `NavigationError(id: ${routerEvent.id}, url: '${routerEvent.url}', error: ${routerEvent.error})`;
1173
+ case EventType.NavigationStart:
1174
+ return `NavigationStart(id: ${routerEvent.id}, url: '${routerEvent.url}')`;
1175
+ case EventType.ResolveEnd:
1176
+ return `ResolveEnd(id: ${routerEvent.id}, url: '${routerEvent.url}', urlAfterRedirects: '${routerEvent.urlAfterRedirects}', state: ${routerEvent.state})`;
1177
+ case EventType.ResolveStart:
1178
+ return `ResolveStart(id: ${routerEvent.id}, url: '${routerEvent.url}', urlAfterRedirects: '${routerEvent.urlAfterRedirects}', state: ${routerEvent.state})`;
1179
+ case EventType.RouteConfigLoadEnd:
1180
+ return `RouteConfigLoadEnd(path: ${routerEvent.route.path})`;
1181
+ case EventType.RouteConfigLoadStart:
1182
+ return `RouteConfigLoadStart(path: ${routerEvent.route.path})`;
1183
+ case EventType.RoutesRecognized:
1184
+ return `RoutesRecognized(id: ${routerEvent.id}, url: '${routerEvent.url}', urlAfterRedirects: '${routerEvent.urlAfterRedirects}', state: ${routerEvent.state})`;
1185
+ case EventType.Scroll:
1186
+ const pos = routerEvent.position ? `${routerEvent.position[0]}, ${routerEvent.position[1]}` : null;
1187
+ return `Scroll(anchor: '${routerEvent.anchor}', position: '${pos}')`;
1188
+ }
1189
+ }
1190
+
1191
+ function getOrCreateRouteInjectorIfNeeded(route, currentInjector) {
1192
+ if (route.providers && !route._injector) {
1193
+ route._injector = createEnvironmentInjector(route.providers, currentInjector, `Route: ${route.path}`);
1194
+ }
1195
+ return route._injector ?? currentInjector;
1196
+ }
1197
+ function validateConfig(config, parentPath = '', requireStandaloneComponents = false) {
1198
+ for (let i = 0; i < config.length; i++) {
1199
+ const route = config[i];
1200
+ const fullPath = getFullPath(parentPath, route);
1201
+ validateNode(route, fullPath, requireStandaloneComponents);
1202
+ }
1203
+ }
1204
+ function assertStandalone(fullPath, component) {
1205
+ if (component && _isNgModule(component)) {
1206
+ throw new _RuntimeError(4014, `Invalid configuration of route '${fullPath}'. You are using 'loadComponent' with a module, ` + `but it must be used with standalone components. Use 'loadChildren' instead.`);
1207
+ } else if (component && !isStandalone(component)) {
1208
+ throw new _RuntimeError(4014, `Invalid configuration of route '${fullPath}'. The component must be standalone.`);
1209
+ }
1210
+ }
1211
+ function validateNode(route, fullPath, requireStandaloneComponents) {
1212
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
1213
+ if (!route) {
1214
+ throw new _RuntimeError(4014, `
1215
+ Invalid configuration of route '${fullPath}': Encountered undefined route.
1216
+ The reason might be an extra comma.
1217
+
1218
+ Example:
1219
+ const routes: Routes = [
1220
+ { path: '', redirectTo: '/dashboard', pathMatch: 'full' },
1221
+ { path: 'dashboard', component: DashboardComponent },, << two commas
1222
+ { path: 'detail/:id', component: HeroDetailComponent }
1223
+ ];
1224
+ `);
1225
+ }
1226
+ if (Array.isArray(route)) {
1227
+ throw new _RuntimeError(4014, `Invalid configuration of route '${fullPath}': Array cannot be specified`);
1228
+ }
1229
+ if (!route.redirectTo && !route.component && !route.loadComponent && !route.children && !route.loadChildren && route.outlet && route.outlet !== PRIMARY_OUTLET) {
1230
+ throw new _RuntimeError(4014, `Invalid configuration of route '${fullPath}': a componentless route without children or loadChildren cannot have a named outlet set`);
1231
+ }
1232
+ if (route.redirectTo && route.children) {
1233
+ throw new _RuntimeError(4014, `Invalid configuration of route '${fullPath}': redirectTo and children cannot be used together`);
1234
+ }
1235
+ if (route.redirectTo && route.loadChildren) {
1236
+ throw new _RuntimeError(4014, `Invalid configuration of route '${fullPath}': redirectTo and loadChildren cannot be used together`);
1237
+ }
1238
+ if (route.children && route.loadChildren) {
1239
+ throw new _RuntimeError(4014, `Invalid configuration of route '${fullPath}': children and loadChildren cannot be used together`);
1240
+ }
1241
+ if (route.component && route.loadComponent) {
1242
+ throw new _RuntimeError(4014, `Invalid configuration of route '${fullPath}': component and loadComponent cannot be used together`);
1243
+ }
1244
+ if (route.redirectTo) {
1245
+ if (route.component || route.loadComponent) {
1246
+ throw new _RuntimeError(4014, `Invalid configuration of route '${fullPath}': redirectTo and component/loadComponent cannot be used together`);
1247
+ }
1248
+ if (route.canMatch || route.canActivate) {
1249
+ throw new _RuntimeError(4014, `Invalid configuration of route '${fullPath}': redirectTo and ${route.canMatch ? 'canMatch' : 'canActivate'} cannot be used together.` + `Redirects happen before guards are executed.`);
1250
+ }
1251
+ }
1252
+ if (route.path && route.matcher) {
1253
+ throw new _RuntimeError(4014, `Invalid configuration of route '${fullPath}': path and matcher cannot be used together`);
1254
+ }
1255
+ if (route.redirectTo === void 0 && !route.component && !route.loadComponent && !route.children && !route.loadChildren) {
1256
+ throw new _RuntimeError(4014, `Invalid configuration of route '${fullPath}'. One of the following must be provided: component, loadComponent, redirectTo, children or loadChildren`);
1257
+ }
1258
+ if (route.path === void 0 && route.matcher === void 0) {
1259
+ throw new _RuntimeError(4014, `Invalid configuration of route '${fullPath}': routes must have either a path or a matcher specified`);
1260
+ }
1261
+ if (typeof route.path === 'string' && route.path.charAt(0) === '/') {
1262
+ throw new _RuntimeError(4014, `Invalid configuration of route '${fullPath}': path cannot start with a slash`);
1263
+ }
1264
+ if (route.path === '' && route.redirectTo !== void 0 && route.pathMatch === void 0) {
1265
+ const exp = `The default value of 'pathMatch' is 'prefix', but often the intent is to use 'full'.`;
1266
+ throw new _RuntimeError(4014, `Invalid configuration of route '{path: "${fullPath}", redirectTo: "${route.redirectTo}"}': please provide 'pathMatch'. ${exp}`);
1267
+ }
1268
+ if (requireStandaloneComponents) {
1269
+ assertStandalone(fullPath, route.component);
1270
+ }
1271
+ }
1272
+ if (route.children) {
1273
+ validateConfig(route.children, fullPath, requireStandaloneComponents);
1274
+ }
1275
+ }
1276
+ function getFullPath(parentPath, currentRoute) {
1277
+ if (!currentRoute) {
1278
+ return parentPath;
1279
+ }
1280
+ if (!parentPath && !currentRoute.path) {
1281
+ return '';
1282
+ } else if (parentPath && !currentRoute.path) {
1283
+ return `${parentPath}/`;
1284
+ } else if (!parentPath && currentRoute.path) {
1285
+ return currentRoute.path;
1286
+ } else {
1287
+ return `${parentPath}/${currentRoute.path}`;
1288
+ }
1289
+ }
1290
+ function getOutlet(route) {
1291
+ return route.outlet || PRIMARY_OUTLET;
1292
+ }
1293
+ function sortByMatchingOutlets(routes, outletName) {
1294
+ const sortedConfig = routes.filter(r => getOutlet(r) === outletName);
1295
+ sortedConfig.push(...routes.filter(r => getOutlet(r) !== outletName));
1296
+ return sortedConfig;
1297
+ }
1298
+ function getClosestRouteInjector(snapshot) {
1299
+ if (!snapshot) return null;
1300
+ if (snapshot.routeConfig?._injector) {
1301
+ return snapshot.routeConfig._injector;
1302
+ }
1303
+ for (let s = snapshot.parent; s; s = s.parent) {
1304
+ const route = s.routeConfig;
1305
+ if (route?._loadedInjector) return route._loadedInjector;
1306
+ if (route?._injector) return route._injector;
1307
+ }
1308
+ return null;
1309
+ }
1310
+
1311
+ class OutletContext {
1312
+ rootInjector;
1313
+ outlet = null;
1314
+ route = null;
1315
+ children;
1316
+ attachRef = null;
1317
+ get injector() {
1318
+ return getClosestRouteInjector(this.route?.snapshot) ?? this.rootInjector;
1319
+ }
1320
+ constructor(rootInjector) {
1321
+ this.rootInjector = rootInjector;
1322
+ this.children = new ChildrenOutletContexts(this.rootInjector);
1323
+ }
1324
+ }
1325
+ class ChildrenOutletContexts {
1326
+ rootInjector;
1327
+ contexts = new Map();
1328
+ constructor(rootInjector) {
1329
+ this.rootInjector = rootInjector;
1330
+ }
1331
+ onChildOutletCreated(childName, outlet) {
1332
+ const context = this.getOrCreateContext(childName);
1333
+ context.outlet = outlet;
1334
+ this.contexts.set(childName, context);
1335
+ }
1336
+ onChildOutletDestroyed(childName) {
1337
+ const context = this.getContext(childName);
1338
+ if (context) {
1339
+ context.outlet = null;
1340
+ context.attachRef = null;
1341
+ }
1342
+ }
1343
+ onOutletDeactivated() {
1344
+ const contexts = this.contexts;
1345
+ this.contexts = new Map();
1346
+ return contexts;
1347
+ }
1348
+ onOutletReAttached(contexts) {
1349
+ this.contexts = contexts;
1350
+ }
1351
+ getOrCreateContext(childName) {
1352
+ let context = this.getContext(childName);
1353
+ if (!context) {
1354
+ context = new OutletContext(this.rootInjector);
1355
+ this.contexts.set(childName, context);
1356
+ }
1357
+ return context;
1358
+ }
1359
+ getContext(childName) {
1360
+ return this.contexts.get(childName) || null;
1361
+ }
1362
+ static ɵfac = i0.ɵɵngDeclareFactory({
1363
+ minVersion: "12.0.0",
1364
+ version: "21.0.0-next.10",
1365
+ ngImport: i0,
1366
+ type: ChildrenOutletContexts,
1367
+ deps: [{
1368
+ token: i0.EnvironmentInjector
1369
+ }],
1370
+ target: i0.ɵɵFactoryTarget.Injectable
1371
+ });
1372
+ static ɵprov = i0.ɵɵngDeclareInjectable({
1373
+ minVersion: "12.0.0",
1374
+ version: "21.0.0-next.10",
1375
+ ngImport: i0,
1376
+ type: ChildrenOutletContexts,
1377
+ providedIn: 'root'
1378
+ });
1379
+ }
1380
+ i0.ɵɵngDeclareClassMetadata({
1381
+ minVersion: "12.0.0",
1382
+ version: "21.0.0-next.10",
1383
+ ngImport: i0,
1384
+ type: ChildrenOutletContexts,
1385
+ decorators: [{
1386
+ type: Injectable,
1387
+ args: [{
1388
+ providedIn: 'root'
1389
+ }]
1390
+ }],
1391
+ ctorParameters: () => [{
1392
+ type: i0.EnvironmentInjector
1393
+ }]
1394
+ });
1395
+
1396
+ class Tree {
1397
+ _root;
1398
+ constructor(root) {
1399
+ this._root = root;
1400
+ }
1401
+ get root() {
1402
+ return this._root.value;
1403
+ }
1404
+ parent(t) {
1405
+ const p = this.pathFromRoot(t);
1406
+ return p.length > 1 ? p[p.length - 2] : null;
1407
+ }
1408
+ children(t) {
1409
+ const n = findNode(t, this._root);
1410
+ return n ? n.children.map(t => t.value) : [];
1411
+ }
1412
+ firstChild(t) {
1413
+ const n = findNode(t, this._root);
1414
+ return n && n.children.length > 0 ? n.children[0].value : null;
1415
+ }
1416
+ siblings(t) {
1417
+ const p = findPath(t, this._root);
1418
+ if (p.length < 2) return [];
1419
+ const c = p[p.length - 2].children.map(c => c.value);
1420
+ return c.filter(cc => cc !== t);
1421
+ }
1422
+ pathFromRoot(t) {
1423
+ return findPath(t, this._root).map(s => s.value);
1424
+ }
1425
+ }
1426
+ function findNode(value, node) {
1427
+ if (value === node.value) return node;
1428
+ for (const child of node.children) {
1429
+ const node = findNode(value, child);
1430
+ if (node) return node;
1431
+ }
1432
+ return null;
1433
+ }
1434
+ function findPath(value, node) {
1435
+ if (value === node.value) return [node];
1436
+ for (const child of node.children) {
1437
+ const path = findPath(value, child);
1438
+ if (path.length) {
1439
+ path.unshift(node);
1440
+ return path;
1441
+ }
1442
+ }
1443
+ return [];
1444
+ }
1445
+ class TreeNode {
1446
+ value;
1447
+ children;
1448
+ constructor(value, children) {
1449
+ this.value = value;
1450
+ this.children = children;
1451
+ }
1452
+ toString() {
1453
+ return `TreeNode(${this.value})`;
1454
+ }
1455
+ }
1456
+ function nodeChildrenAsMap(node) {
1457
+ const map = {};
1458
+ if (node) {
1459
+ node.children.forEach(child => map[child.value.outlet] = child);
1460
+ }
1461
+ return map;
1462
+ }
1463
+
1464
+ class RouterState extends Tree {
1465
+ snapshot;
1466
+ constructor(root, snapshot) {
1467
+ super(root);
1468
+ this.snapshot = snapshot;
1469
+ setRouterState(this, root);
1470
+ }
1471
+ toString() {
1472
+ return this.snapshot.toString();
1473
+ }
1474
+ }
1475
+ function createEmptyState(rootComponent) {
1476
+ const snapshot = createEmptyStateSnapshot(rootComponent);
1477
+ const emptyUrl = new BehaviorSubject([new UrlSegment('', {})]);
1478
+ const emptyParams = new BehaviorSubject({});
1479
+ const emptyData = new BehaviorSubject({});
1480
+ const emptyQueryParams = new BehaviorSubject({});
1481
+ const fragment = new BehaviorSubject('');
1482
+ const activated = new ActivatedRoute(emptyUrl, emptyParams, emptyQueryParams, fragment, emptyData, PRIMARY_OUTLET, rootComponent, snapshot.root);
1483
+ activated.snapshot = snapshot.root;
1484
+ return new RouterState(new TreeNode(activated, []), snapshot);
1485
+ }
1486
+ function createEmptyStateSnapshot(rootComponent) {
1487
+ const emptyParams = {};
1488
+ const emptyData = {};
1489
+ const emptyQueryParams = {};
1490
+ const fragment = '';
1491
+ const activated = new ActivatedRouteSnapshot([], emptyParams, emptyQueryParams, fragment, emptyData, PRIMARY_OUTLET, rootComponent, null, {});
1492
+ return new RouterStateSnapshot('', new TreeNode(activated, []));
1493
+ }
1494
+ class ActivatedRoute {
1495
+ urlSubject;
1496
+ paramsSubject;
1497
+ queryParamsSubject;
1498
+ fragmentSubject;
1499
+ dataSubject;
1500
+ outlet;
1501
+ component;
1502
+ snapshot;
1503
+ _futureSnapshot;
1504
+ _routerState;
1505
+ _paramMap;
1506
+ _queryParamMap;
1507
+ title;
1508
+ url;
1509
+ params;
1510
+ queryParams;
1511
+ fragment;
1512
+ data;
1513
+ constructor(urlSubject, paramsSubject, queryParamsSubject, fragmentSubject, dataSubject, outlet, component, futureSnapshot) {
1514
+ this.urlSubject = urlSubject;
1515
+ this.paramsSubject = paramsSubject;
1516
+ this.queryParamsSubject = queryParamsSubject;
1517
+ this.fragmentSubject = fragmentSubject;
1518
+ this.dataSubject = dataSubject;
1519
+ this.outlet = outlet;
1520
+ this.component = component;
1521
+ this._futureSnapshot = futureSnapshot;
1522
+ this.title = this.dataSubject?.pipe(map(d => d[RouteTitleKey])) ?? of(undefined);
1523
+ this.url = urlSubject;
1524
+ this.params = paramsSubject;
1525
+ this.queryParams = queryParamsSubject;
1526
+ this.fragment = fragmentSubject;
1527
+ this.data = dataSubject;
1528
+ }
1529
+ get routeConfig() {
1530
+ return this._futureSnapshot.routeConfig;
1531
+ }
1532
+ get root() {
1533
+ return this._routerState.root;
1534
+ }
1535
+ get parent() {
1536
+ return this._routerState.parent(this);
1537
+ }
1538
+ get firstChild() {
1539
+ return this._routerState.firstChild(this);
1540
+ }
1541
+ get children() {
1542
+ return this._routerState.children(this);
1543
+ }
1544
+ get pathFromRoot() {
1545
+ return this._routerState.pathFromRoot(this);
1546
+ }
1547
+ get paramMap() {
1548
+ this._paramMap ??= this.params.pipe(map(p => convertToParamMap(p)));
1549
+ return this._paramMap;
1550
+ }
1551
+ get queryParamMap() {
1552
+ this._queryParamMap ??= this.queryParams.pipe(map(p => convertToParamMap(p)));
1553
+ return this._queryParamMap;
1554
+ }
1555
+ toString() {
1556
+ return this.snapshot ? this.snapshot.toString() : `Future(${this._futureSnapshot})`;
1557
+ }
1558
+ }
1559
+ function getInherited(route, parent, paramsInheritanceStrategy = 'emptyOnly') {
1560
+ let inherited;
1561
+ const {
1562
+ routeConfig
1563
+ } = route;
1564
+ if (parent !== null && (paramsInheritanceStrategy === 'always' || routeConfig?.path === '' || !parent.component && !parent.routeConfig?.loadComponent)) {
1565
+ inherited = {
1566
+ params: {
1567
+ ...parent.params,
1568
+ ...route.params
1569
+ },
1570
+ data: {
1571
+ ...parent.data,
1572
+ ...route.data
1573
+ },
1574
+ resolve: {
1575
+ ...route.data,
1576
+ ...parent.data,
1577
+ ...routeConfig?.data,
1578
+ ...route._resolvedData
1579
+ }
1580
+ };
1581
+ } else {
1582
+ inherited = {
1583
+ params: {
1584
+ ...route.params
1585
+ },
1586
+ data: {
1587
+ ...route.data
1588
+ },
1589
+ resolve: {
1590
+ ...route.data,
1591
+ ...(route._resolvedData ?? {})
1592
+ }
1593
+ };
1594
+ }
1595
+ if (routeConfig && hasStaticTitle(routeConfig)) {
1596
+ inherited.resolve[RouteTitleKey] = routeConfig.title;
1597
+ }
1598
+ return inherited;
1599
+ }
1600
+ class ActivatedRouteSnapshot {
1601
+ url;
1602
+ params;
1603
+ queryParams;
1604
+ fragment;
1605
+ data;
1606
+ outlet;
1607
+ component;
1608
+ routeConfig;
1609
+ _resolve;
1610
+ _resolvedData;
1611
+ _routerState;
1612
+ _paramMap;
1613
+ _queryParamMap;
1614
+ get title() {
1615
+ return this.data?.[RouteTitleKey];
1616
+ }
1617
+ constructor(url, params, queryParams, fragment, data, outlet, component, routeConfig, resolve) {
1618
+ this.url = url;
1619
+ this.params = params;
1620
+ this.queryParams = queryParams;
1621
+ this.fragment = fragment;
1622
+ this.data = data;
1623
+ this.outlet = outlet;
1624
+ this.component = component;
1625
+ this.routeConfig = routeConfig;
1626
+ this._resolve = resolve;
1627
+ }
1628
+ get root() {
1629
+ return this._routerState.root;
1630
+ }
1631
+ get parent() {
1632
+ return this._routerState.parent(this);
1633
+ }
1634
+ get firstChild() {
1635
+ return this._routerState.firstChild(this);
1636
+ }
1637
+ get children() {
1638
+ return this._routerState.children(this);
1639
+ }
1640
+ get pathFromRoot() {
1641
+ return this._routerState.pathFromRoot(this);
1642
+ }
1643
+ get paramMap() {
1644
+ this._paramMap ??= convertToParamMap(this.params);
1645
+ return this._paramMap;
1646
+ }
1647
+ get queryParamMap() {
1648
+ this._queryParamMap ??= convertToParamMap(this.queryParams);
1649
+ return this._queryParamMap;
1650
+ }
1651
+ toString() {
1652
+ const url = this.url.map(segment => segment.toString()).join('/');
1653
+ const matched = this.routeConfig ? this.routeConfig.path : '';
1654
+ return `Route(url:'${url}', path:'${matched}')`;
1655
+ }
1656
+ }
1657
+ class RouterStateSnapshot extends Tree {
1658
+ url;
1659
+ constructor(url, root) {
1660
+ super(root);
1661
+ this.url = url;
1662
+ setRouterState(this, root);
1663
+ }
1664
+ toString() {
1665
+ return serializeNode(this._root);
1666
+ }
1667
+ }
1668
+ function setRouterState(state, node) {
1669
+ node.value._routerState = state;
1670
+ node.children.forEach(c => setRouterState(state, c));
1671
+ }
1672
+ function serializeNode(node) {
1673
+ const c = node.children.length > 0 ? ` { ${node.children.map(serializeNode).join(', ')} } ` : '';
1674
+ return `${node.value}${c}`;
1675
+ }
1676
+ function advanceActivatedRoute(route) {
1677
+ if (route.snapshot) {
1678
+ const currentSnapshot = route.snapshot;
1679
+ const nextSnapshot = route._futureSnapshot;
1680
+ route.snapshot = nextSnapshot;
1681
+ if (!shallowEqual(currentSnapshot.queryParams, nextSnapshot.queryParams)) {
1682
+ route.queryParamsSubject.next(nextSnapshot.queryParams);
1683
+ }
1684
+ if (currentSnapshot.fragment !== nextSnapshot.fragment) {
1685
+ route.fragmentSubject.next(nextSnapshot.fragment);
1686
+ }
1687
+ if (!shallowEqual(currentSnapshot.params, nextSnapshot.params)) {
1688
+ route.paramsSubject.next(nextSnapshot.params);
1689
+ }
1690
+ if (!shallowEqualArrays(currentSnapshot.url, nextSnapshot.url)) {
1691
+ route.urlSubject.next(nextSnapshot.url);
1692
+ }
1693
+ if (!shallowEqual(currentSnapshot.data, nextSnapshot.data)) {
1694
+ route.dataSubject.next(nextSnapshot.data);
1695
+ }
1696
+ } else {
1697
+ route.snapshot = route._futureSnapshot;
1698
+ route.dataSubject.next(route._futureSnapshot.data);
1699
+ }
1700
+ }
1701
+ function equalParamsAndUrlSegments(a, b) {
1702
+ const equalUrlParams = shallowEqual(a.params, b.params) && equalSegments(a.url, b.url);
1703
+ const parentsMismatch = !a.parent !== !b.parent;
1704
+ return equalUrlParams && !parentsMismatch && (!a.parent || equalParamsAndUrlSegments(a.parent, b.parent));
1705
+ }
1706
+ function hasStaticTitle(config) {
1707
+ return typeof config.title === 'string' || config.title === null;
1708
+ }
1709
+
1710
+ const ROUTER_OUTLET_DATA = new InjectionToken(typeof ngDevMode !== undefined && ngDevMode ? 'RouterOutlet data' : '');
1711
+ class RouterOutlet {
1712
+ activated = null;
1713
+ get activatedComponentRef() {
1714
+ return this.activated;
1715
+ }
1716
+ _activatedRoute = null;
1717
+ name = PRIMARY_OUTLET;
1718
+ activateEvents = new EventEmitter();
1719
+ deactivateEvents = new EventEmitter();
1720
+ attachEvents = new EventEmitter();
1721
+ detachEvents = new EventEmitter();
1722
+ routerOutletData = input(...(ngDevMode ? [undefined, {
1723
+ debugName: "routerOutletData"
1724
+ }] : []));
1725
+ parentContexts = inject(ChildrenOutletContexts);
1726
+ location = inject(ViewContainerRef);
1727
+ changeDetector = inject(ChangeDetectorRef);
1728
+ inputBinder = inject(INPUT_BINDER, {
1729
+ optional: true
1730
+ });
1731
+ supportsBindingToComponentInputs = true;
1732
+ ngOnChanges(changes) {
1733
+ if (changes['name']) {
1734
+ const {
1735
+ firstChange,
1736
+ previousValue
1737
+ } = changes['name'];
1738
+ if (firstChange) {
1739
+ return;
1740
+ }
1741
+ if (this.isTrackedInParentContexts(previousValue)) {
1742
+ this.deactivate();
1743
+ this.parentContexts.onChildOutletDestroyed(previousValue);
1744
+ }
1745
+ this.initializeOutletWithName();
1746
+ }
1747
+ }
1748
+ ngOnDestroy() {
1749
+ if (this.isTrackedInParentContexts(this.name)) {
1750
+ this.parentContexts.onChildOutletDestroyed(this.name);
1751
+ }
1752
+ this.inputBinder?.unsubscribeFromRouteData(this);
1753
+ }
1754
+ isTrackedInParentContexts(outletName) {
1755
+ return this.parentContexts.getContext(outletName)?.outlet === this;
1756
+ }
1757
+ ngOnInit() {
1758
+ this.initializeOutletWithName();
1759
+ }
1760
+ initializeOutletWithName() {
1761
+ this.parentContexts.onChildOutletCreated(this.name, this);
1762
+ if (this.activated) {
1763
+ return;
1764
+ }
1765
+ const context = this.parentContexts.getContext(this.name);
1766
+ if (context?.route) {
1767
+ if (context.attachRef) {
1768
+ this.attach(context.attachRef, context.route);
1769
+ } else {
1770
+ this.activateWith(context.route, context.injector);
1771
+ }
1772
+ }
1773
+ }
1774
+ get isActivated() {
1775
+ return !!this.activated;
1776
+ }
1777
+ get component() {
1778
+ if (!this.activated) throw new _RuntimeError(4012, (typeof ngDevMode === 'undefined' || ngDevMode) && 'Outlet is not activated');
1779
+ return this.activated.instance;
1780
+ }
1781
+ get activatedRoute() {
1782
+ if (!this.activated) throw new _RuntimeError(4012, (typeof ngDevMode === 'undefined' || ngDevMode) && 'Outlet is not activated');
1783
+ return this._activatedRoute;
1784
+ }
1785
+ get activatedRouteData() {
1786
+ if (this._activatedRoute) {
1787
+ return this._activatedRoute.snapshot.data;
1788
+ }
1789
+ return {};
1790
+ }
1791
+ detach() {
1792
+ if (!this.activated) throw new _RuntimeError(4012, (typeof ngDevMode === 'undefined' || ngDevMode) && 'Outlet is not activated');
1793
+ this.location.detach();
1794
+ const cmp = this.activated;
1795
+ this.activated = null;
1796
+ this._activatedRoute = null;
1797
+ this.detachEvents.emit(cmp.instance);
1798
+ return cmp;
1799
+ }
1800
+ attach(ref, activatedRoute) {
1801
+ this.activated = ref;
1802
+ this._activatedRoute = activatedRoute;
1803
+ this.location.insert(ref.hostView);
1804
+ this.inputBinder?.bindActivatedRouteToOutletComponent(this);
1805
+ this.attachEvents.emit(ref.instance);
1806
+ }
1807
+ deactivate() {
1808
+ if (this.activated) {
1809
+ const c = this.component;
1810
+ this.activated.destroy();
1811
+ this.activated = null;
1812
+ this._activatedRoute = null;
1813
+ this.deactivateEvents.emit(c);
1814
+ }
1815
+ }
1816
+ activateWith(activatedRoute, environmentInjector) {
1817
+ if (this.isActivated) {
1818
+ throw new _RuntimeError(4013, (typeof ngDevMode === 'undefined' || ngDevMode) && 'Cannot activate an already activated outlet');
1819
+ }
1820
+ this._activatedRoute = activatedRoute;
1821
+ const location = this.location;
1822
+ const snapshot = activatedRoute.snapshot;
1823
+ const component = snapshot.component;
1824
+ const childContexts = this.parentContexts.getOrCreateContext(this.name).children;
1825
+ const injector = new OutletInjector(activatedRoute, childContexts, location.injector, this.routerOutletData);
1826
+ this.activated = location.createComponent(component, {
1827
+ index: location.length,
1828
+ injector,
1829
+ environmentInjector: environmentInjector
1830
+ });
1831
+ this.changeDetector.markForCheck();
1832
+ this.inputBinder?.bindActivatedRouteToOutletComponent(this);
1833
+ this.activateEvents.emit(this.activated.instance);
1834
+ }
1835
+ static ɵfac = i0.ɵɵngDeclareFactory({
1836
+ minVersion: "12.0.0",
1837
+ version: "21.0.0-next.10",
1838
+ ngImport: i0,
1839
+ type: RouterOutlet,
1840
+ deps: [],
1841
+ target: i0.ɵɵFactoryTarget.Directive
1842
+ });
1843
+ static ɵdir = i0.ɵɵngDeclareDirective({
1844
+ minVersion: "17.1.0",
1845
+ version: "21.0.0-next.10",
1846
+ type: RouterOutlet,
1847
+ isStandalone: true,
1848
+ selector: "router-outlet",
1849
+ inputs: {
1850
+ name: {
1851
+ classPropertyName: "name",
1852
+ publicName: "name",
1853
+ isSignal: false,
1854
+ isRequired: false,
1855
+ transformFunction: null
1856
+ },
1857
+ routerOutletData: {
1858
+ classPropertyName: "routerOutletData",
1859
+ publicName: "routerOutletData",
1860
+ isSignal: true,
1861
+ isRequired: false,
1862
+ transformFunction: null
1863
+ }
1864
+ },
1865
+ outputs: {
1866
+ activateEvents: "activate",
1867
+ deactivateEvents: "deactivate",
1868
+ attachEvents: "attach",
1869
+ detachEvents: "detach"
1870
+ },
1871
+ exportAs: ["outlet"],
1872
+ usesOnChanges: true,
1873
+ ngImport: i0
1874
+ });
1875
+ }
1876
+ i0.ɵɵngDeclareClassMetadata({
1877
+ minVersion: "12.0.0",
1878
+ version: "21.0.0-next.10",
1879
+ ngImport: i0,
1880
+ type: RouterOutlet,
1881
+ decorators: [{
1882
+ type: Directive,
1883
+ args: [{
1884
+ selector: 'router-outlet',
1885
+ exportAs: 'outlet'
1886
+ }]
1887
+ }],
1888
+ propDecorators: {
1889
+ name: [{
1890
+ type: Input
1891
+ }],
1892
+ activateEvents: [{
1893
+ type: Output,
1894
+ args: ['activate']
1895
+ }],
1896
+ deactivateEvents: [{
1897
+ type: Output,
1898
+ args: ['deactivate']
1899
+ }],
1900
+ attachEvents: [{
1901
+ type: Output,
1902
+ args: ['attach']
1903
+ }],
1904
+ detachEvents: [{
1905
+ type: Output,
1906
+ args: ['detach']
1907
+ }],
1908
+ routerOutletData: [{
1909
+ type: i0.Input,
1910
+ args: [{
1911
+ isSignal: true,
1912
+ alias: "routerOutletData",
1913
+ required: false
1914
+ }]
1915
+ }]
1916
+ }
1917
+ });
1918
+ class OutletInjector {
1919
+ route;
1920
+ childContexts;
1921
+ parent;
1922
+ outletData;
1923
+ constructor(route, childContexts, parent, outletData) {
1924
+ this.route = route;
1925
+ this.childContexts = childContexts;
1926
+ this.parent = parent;
1927
+ this.outletData = outletData;
1928
+ }
1929
+ get(token, notFoundValue) {
1930
+ if (token === ActivatedRoute) {
1931
+ return this.route;
1932
+ }
1933
+ if (token === ChildrenOutletContexts) {
1934
+ return this.childContexts;
1935
+ }
1936
+ if (token === ROUTER_OUTLET_DATA) {
1937
+ return this.outletData;
1938
+ }
1939
+ return this.parent.get(token, notFoundValue);
1940
+ }
1941
+ }
1942
+ const INPUT_BINDER = new InjectionToken('');
1943
+ class RoutedComponentInputBinder {
1944
+ outletDataSubscriptions = new Map();
1945
+ bindActivatedRouteToOutletComponent(outlet) {
1946
+ this.unsubscribeFromRouteData(outlet);
1947
+ this.subscribeToRouteData(outlet);
1948
+ }
1949
+ unsubscribeFromRouteData(outlet) {
1950
+ this.outletDataSubscriptions.get(outlet)?.unsubscribe();
1951
+ this.outletDataSubscriptions.delete(outlet);
1952
+ }
1953
+ subscribeToRouteData(outlet) {
1954
+ const {
1955
+ activatedRoute
1956
+ } = outlet;
1957
+ const dataSubscription = combineLatest([activatedRoute.queryParams, activatedRoute.params, activatedRoute.data]).pipe(switchMap(([queryParams, params, data], index) => {
1958
+ data = {
1959
+ ...queryParams,
1960
+ ...params,
1961
+ ...data
1962
+ };
1963
+ if (index === 0) {
1964
+ return of(data);
1965
+ }
1966
+ return Promise.resolve(data);
1967
+ })).subscribe(data => {
1968
+ if (!outlet.isActivated || !outlet.activatedComponentRef || outlet.activatedRoute !== activatedRoute || activatedRoute.component === null) {
1969
+ this.unsubscribeFromRouteData(outlet);
1970
+ return;
1971
+ }
1972
+ const mirror = reflectComponentType(activatedRoute.component);
1973
+ if (!mirror) {
1974
+ this.unsubscribeFromRouteData(outlet);
1975
+ return;
1976
+ }
1977
+ for (const {
1978
+ templateName
1979
+ } of mirror.inputs) {
1980
+ outlet.activatedComponentRef.setInput(templateName, data[templateName]);
1981
+ }
1982
+ });
1983
+ this.outletDataSubscriptions.set(outlet, dataSubscription);
1984
+ }
1985
+ static ɵfac = i0.ɵɵngDeclareFactory({
1986
+ minVersion: "12.0.0",
1987
+ version: "21.0.0-next.10",
1988
+ ngImport: i0,
1989
+ type: RoutedComponentInputBinder,
1990
+ deps: [],
1991
+ target: i0.ɵɵFactoryTarget.Injectable
1992
+ });
1993
+ static ɵprov = i0.ɵɵngDeclareInjectable({
1994
+ minVersion: "12.0.0",
1995
+ version: "21.0.0-next.10",
1996
+ ngImport: i0,
1997
+ type: RoutedComponentInputBinder
1998
+ });
1999
+ }
2000
+ i0.ɵɵngDeclareClassMetadata({
2001
+ minVersion: "12.0.0",
2002
+ version: "21.0.0-next.10",
2003
+ ngImport: i0,
2004
+ type: RoutedComponentInputBinder,
2005
+ decorators: [{
2006
+ type: Injectable
2007
+ }]
2008
+ });
2009
+
2010
+ class ɵEmptyOutletComponent {
2011
+ static ɵfac = i0.ɵɵngDeclareFactory({
2012
+ minVersion: "12.0.0",
2013
+ version: "21.0.0-next.10",
2014
+ ngImport: i0,
2015
+ type: ɵEmptyOutletComponent,
2016
+ deps: [],
2017
+ target: i0.ɵɵFactoryTarget.Component
2018
+ });
2019
+ static ɵcmp = i0.ɵɵngDeclareComponent({
2020
+ minVersion: "14.0.0",
2021
+ version: "21.0.0-next.10",
2022
+ type: ɵEmptyOutletComponent,
2023
+ isStandalone: true,
2024
+ selector: "ng-component",
2025
+ exportAs: ["emptyRouterOutlet"],
2026
+ ngImport: i0,
2027
+ template: `<router-outlet/>`,
2028
+ isInline: true,
2029
+ dependencies: [{
2030
+ kind: "directive",
2031
+ type: RouterOutlet,
2032
+ selector: "router-outlet",
2033
+ inputs: ["name", "routerOutletData"],
2034
+ outputs: ["activate", "deactivate", "attach", "detach"],
2035
+ exportAs: ["outlet"]
2036
+ }]
2037
+ });
2038
+ }
2039
+ i0.ɵɵngDeclareClassMetadata({
2040
+ minVersion: "12.0.0",
2041
+ version: "21.0.0-next.10",
2042
+ ngImport: i0,
2043
+ type: ɵEmptyOutletComponent,
2044
+ decorators: [{
2045
+ type: Component,
2046
+ args: [{
2047
+ template: `<router-outlet/>`,
2048
+ imports: [RouterOutlet],
2049
+ exportAs: 'emptyRouterOutlet'
2050
+ }]
2051
+ }]
2052
+ });
2053
+ function standardizeConfig(r) {
2054
+ const children = r.children && r.children.map(standardizeConfig);
2055
+ const c = children ? {
2056
+ ...r,
2057
+ children
2058
+ } : {
2059
+ ...r
2060
+ };
2061
+ if (!c.component && !c.loadComponent && (children || c.loadChildren) && c.outlet && c.outlet !== PRIMARY_OUTLET) {
2062
+ c.component = ɵEmptyOutletComponent;
2063
+ }
2064
+ return c;
2065
+ }
2066
+
2067
+ function createRouterState(routeReuseStrategy, curr, prevState) {
2068
+ const root = createNode(routeReuseStrategy, curr._root, prevState ? prevState._root : undefined);
2069
+ return new RouterState(root, curr);
2070
+ }
2071
+ function createNode(routeReuseStrategy, curr, prevState) {
2072
+ if (prevState && routeReuseStrategy.shouldReuseRoute(curr.value, prevState.value.snapshot)) {
2073
+ const value = prevState.value;
2074
+ value._futureSnapshot = curr.value;
2075
+ const children = createOrReuseChildren(routeReuseStrategy, curr, prevState);
2076
+ return new TreeNode(value, children);
2077
+ } else {
2078
+ if (routeReuseStrategy.shouldAttach(curr.value)) {
2079
+ const detachedRouteHandle = routeReuseStrategy.retrieve(curr.value);
2080
+ if (detachedRouteHandle !== null) {
2081
+ const tree = detachedRouteHandle.route;
2082
+ tree.value._futureSnapshot = curr.value;
2083
+ tree.children = curr.children.map(c => createNode(routeReuseStrategy, c));
2084
+ return tree;
2085
+ }
2086
+ }
2087
+ const value = createActivatedRoute(curr.value);
2088
+ const children = curr.children.map(c => createNode(routeReuseStrategy, c));
2089
+ return new TreeNode(value, children);
2090
+ }
2091
+ }
2092
+ function createOrReuseChildren(routeReuseStrategy, curr, prevState) {
2093
+ return curr.children.map(child => {
2094
+ for (const p of prevState.children) {
2095
+ if (routeReuseStrategy.shouldReuseRoute(child.value, p.value.snapshot)) {
2096
+ return createNode(routeReuseStrategy, child, p);
2097
+ }
2098
+ }
2099
+ return createNode(routeReuseStrategy, child);
2100
+ });
2101
+ }
2102
+ function createActivatedRoute(c) {
2103
+ return new ActivatedRoute(new BehaviorSubject(c.url), new BehaviorSubject(c.params), new BehaviorSubject(c.queryParams), new BehaviorSubject(c.fragment), new BehaviorSubject(c.data), c.outlet, c.component, c);
2104
+ }
2105
+
2106
+ class RedirectCommand {
2107
+ redirectTo;
2108
+ navigationBehaviorOptions;
2109
+ constructor(redirectTo, navigationBehaviorOptions) {
2110
+ this.redirectTo = redirectTo;
2111
+ this.navigationBehaviorOptions = navigationBehaviorOptions;
2112
+ }
2113
+ }
2114
+
2115
+ const NAVIGATION_CANCELING_ERROR = 'ngNavigationCancelingError';
2116
+ function redirectingNavigationError(urlSerializer, redirect) {
2117
+ const {
2118
+ redirectTo,
2119
+ navigationBehaviorOptions
2120
+ } = isUrlTree(redirect) ? {
2121
+ redirectTo: redirect,
2122
+ navigationBehaviorOptions: undefined
2123
+ } : redirect;
2124
+ const error = navigationCancelingError(ngDevMode && `Redirecting to "${urlSerializer.serialize(redirectTo)}"`, NavigationCancellationCode.Redirect);
2125
+ error.url = redirectTo;
2126
+ error.navigationBehaviorOptions = navigationBehaviorOptions;
2127
+ return error;
2128
+ }
2129
+ function navigationCancelingError(message, code) {
2130
+ const error = new Error(`NavigationCancelingError: ${message || ''}`);
2131
+ error[NAVIGATION_CANCELING_ERROR] = true;
2132
+ error.cancellationCode = code;
2133
+ return error;
2134
+ }
2135
+ function isRedirectingNavigationCancelingError(error) {
2136
+ return isNavigationCancelingError(error) && isUrlTree(error.url);
2137
+ }
2138
+ function isNavigationCancelingError(error) {
2139
+ return !!error && error[NAVIGATION_CANCELING_ERROR];
2140
+ }
2141
+
2142
+ let warnedAboutUnsupportedInputBinding = false;
2143
+ const activateRoutes = (rootContexts, routeReuseStrategy, forwardEvent, inputBindingEnabled) => map(t => {
2144
+ new ActivateRoutes(routeReuseStrategy, t.targetRouterState, t.currentRouterState, forwardEvent, inputBindingEnabled).activate(rootContexts);
2145
+ return t;
2146
+ });
2147
+ class ActivateRoutes {
2148
+ routeReuseStrategy;
2149
+ futureState;
2150
+ currState;
2151
+ forwardEvent;
2152
+ inputBindingEnabled;
2153
+ constructor(routeReuseStrategy, futureState, currState, forwardEvent, inputBindingEnabled) {
2154
+ this.routeReuseStrategy = routeReuseStrategy;
2155
+ this.futureState = futureState;
2156
+ this.currState = currState;
2157
+ this.forwardEvent = forwardEvent;
2158
+ this.inputBindingEnabled = inputBindingEnabled;
2159
+ }
2160
+ activate(parentContexts) {
2161
+ const futureRoot = this.futureState._root;
2162
+ const currRoot = this.currState ? this.currState._root : null;
2163
+ this.deactivateChildRoutes(futureRoot, currRoot, parentContexts);
2164
+ advanceActivatedRoute(this.futureState.root);
2165
+ this.activateChildRoutes(futureRoot, currRoot, parentContexts);
2166
+ }
2167
+ deactivateChildRoutes(futureNode, currNode, contexts) {
2168
+ const children = nodeChildrenAsMap(currNode);
2169
+ futureNode.children.forEach(futureChild => {
2170
+ const childOutletName = futureChild.value.outlet;
2171
+ this.deactivateRoutes(futureChild, children[childOutletName], contexts);
2172
+ delete children[childOutletName];
2173
+ });
2174
+ Object.values(children).forEach(v => {
2175
+ this.deactivateRouteAndItsChildren(v, contexts);
2176
+ });
2177
+ }
2178
+ deactivateRoutes(futureNode, currNode, parentContext) {
2179
+ const future = futureNode.value;
2180
+ const curr = currNode ? currNode.value : null;
2181
+ if (future === curr) {
2182
+ if (future.component) {
2183
+ const context = parentContext.getContext(future.outlet);
2184
+ if (context) {
2185
+ this.deactivateChildRoutes(futureNode, currNode, context.children);
2186
+ }
2187
+ } else {
2188
+ this.deactivateChildRoutes(futureNode, currNode, parentContext);
2189
+ }
2190
+ } else {
2191
+ if (curr) {
2192
+ this.deactivateRouteAndItsChildren(currNode, parentContext);
2193
+ }
2194
+ }
2195
+ }
2196
+ deactivateRouteAndItsChildren(route, parentContexts) {
2197
+ if (route.value.component && this.routeReuseStrategy.shouldDetach(route.value.snapshot)) {
2198
+ this.detachAndStoreRouteSubtree(route, parentContexts);
2199
+ } else {
2200
+ this.deactivateRouteAndOutlet(route, parentContexts);
2201
+ }
2202
+ }
2203
+ detachAndStoreRouteSubtree(route, parentContexts) {
2204
+ const context = parentContexts.getContext(route.value.outlet);
2205
+ const contexts = context && route.value.component ? context.children : parentContexts;
2206
+ const children = nodeChildrenAsMap(route);
2207
+ for (const treeNode of Object.values(children)) {
2208
+ this.deactivateRouteAndItsChildren(treeNode, contexts);
2209
+ }
2210
+ if (context && context.outlet) {
2211
+ const componentRef = context.outlet.detach();
2212
+ const contexts = context.children.onOutletDeactivated();
2213
+ this.routeReuseStrategy.store(route.value.snapshot, {
2214
+ componentRef,
2215
+ route,
2216
+ contexts
2217
+ });
2218
+ }
2219
+ }
2220
+ deactivateRouteAndOutlet(route, parentContexts) {
2221
+ const context = parentContexts.getContext(route.value.outlet);
2222
+ const contexts = context && route.value.component ? context.children : parentContexts;
2223
+ const children = nodeChildrenAsMap(route);
2224
+ for (const treeNode of Object.values(children)) {
2225
+ this.deactivateRouteAndItsChildren(treeNode, contexts);
2226
+ }
2227
+ if (context) {
2228
+ if (context.outlet) {
2229
+ context.outlet.deactivate();
2230
+ context.children.onOutletDeactivated();
2231
+ }
2232
+ context.attachRef = null;
2233
+ context.route = null;
2234
+ }
2235
+ }
2236
+ activateChildRoutes(futureNode, currNode, contexts) {
2237
+ const children = nodeChildrenAsMap(currNode);
2238
+ futureNode.children.forEach(c => {
2239
+ this.activateRoutes(c, children[c.value.outlet], contexts);
2240
+ this.forwardEvent(new ActivationEnd(c.value.snapshot));
2241
+ });
2242
+ if (futureNode.children.length) {
2243
+ this.forwardEvent(new ChildActivationEnd(futureNode.value.snapshot));
2244
+ }
2245
+ }
2246
+ activateRoutes(futureNode, currNode, parentContexts) {
2247
+ const future = futureNode.value;
2248
+ const curr = currNode ? currNode.value : null;
2249
+ advanceActivatedRoute(future);
2250
+ if (future === curr) {
2251
+ if (future.component) {
2252
+ const context = parentContexts.getOrCreateContext(future.outlet);
2253
+ this.activateChildRoutes(futureNode, currNode, context.children);
2254
+ } else {
2255
+ this.activateChildRoutes(futureNode, currNode, parentContexts);
2256
+ }
2257
+ } else {
2258
+ if (future.component) {
2259
+ const context = parentContexts.getOrCreateContext(future.outlet);
2260
+ if (this.routeReuseStrategy.shouldAttach(future.snapshot)) {
2261
+ const stored = this.routeReuseStrategy.retrieve(future.snapshot);
2262
+ this.routeReuseStrategy.store(future.snapshot, null);
2263
+ context.children.onOutletReAttached(stored.contexts);
2264
+ context.attachRef = stored.componentRef;
2265
+ context.route = stored.route.value;
2266
+ if (context.outlet) {
2267
+ context.outlet.attach(stored.componentRef, stored.route.value);
2268
+ }
2269
+ advanceActivatedRoute(stored.route.value);
2270
+ this.activateChildRoutes(futureNode, null, context.children);
2271
+ } else {
2272
+ context.attachRef = null;
2273
+ context.route = future;
2274
+ if (context.outlet) {
2275
+ context.outlet.activateWith(future, context.injector);
2276
+ }
2277
+ this.activateChildRoutes(futureNode, null, context.children);
2278
+ }
2279
+ } else {
2280
+ this.activateChildRoutes(futureNode, null, parentContexts);
2281
+ }
2282
+ }
2283
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
2284
+ const context = parentContexts.getOrCreateContext(future.outlet);
2285
+ const outlet = context.outlet;
2286
+ if (outlet && this.inputBindingEnabled && !outlet.supportsBindingToComponentInputs && !warnedAboutUnsupportedInputBinding) {
2287
+ console.warn(`'withComponentInputBinding' feature is enabled but ` + `this application is using an outlet that may not support binding to component inputs.`);
2288
+ warnedAboutUnsupportedInputBinding = true;
2289
+ }
2290
+ }
2291
+ }
2292
+ }
2293
+
2294
+ class CanActivate {
2295
+ path;
2296
+ route;
2297
+ constructor(path) {
2298
+ this.path = path;
2299
+ this.route = this.path[this.path.length - 1];
2300
+ }
2301
+ }
2302
+ class CanDeactivate {
2303
+ component;
2304
+ route;
2305
+ constructor(component, route) {
2306
+ this.component = component;
2307
+ this.route = route;
2308
+ }
2309
+ }
2310
+ function getAllRouteGuards(future, curr, parentContexts) {
2311
+ const futureRoot = future._root;
2312
+ const currRoot = curr ? curr._root : null;
2313
+ return getChildRouteGuards(futureRoot, currRoot, parentContexts, [futureRoot.value]);
2314
+ }
2315
+ function getCanActivateChild(p) {
2316
+ const canActivateChild = p.routeConfig ? p.routeConfig.canActivateChild : null;
2317
+ if (!canActivateChild || canActivateChild.length === 0) return null;
2318
+ return {
2319
+ node: p,
2320
+ guards: canActivateChild
2321
+ };
2322
+ }
2323
+ function getTokenOrFunctionIdentity(tokenOrFunction, injector) {
2324
+ const NOT_FOUND = Symbol();
2325
+ const result = injector.get(tokenOrFunction, NOT_FOUND);
2326
+ if (result === NOT_FOUND) {
2327
+ if (typeof tokenOrFunction === 'function' && !_isInjectable(tokenOrFunction)) {
2328
+ return tokenOrFunction;
2329
+ } else {
2330
+ return injector.get(tokenOrFunction);
2331
+ }
2332
+ }
2333
+ return result;
2334
+ }
2335
+ function getChildRouteGuards(futureNode, currNode, contexts, futurePath, checks = {
2336
+ canDeactivateChecks: [],
2337
+ canActivateChecks: []
2338
+ }) {
2339
+ const prevChildren = nodeChildrenAsMap(currNode);
2340
+ futureNode.children.forEach(c => {
2341
+ getRouteGuards(c, prevChildren[c.value.outlet], contexts, futurePath.concat([c.value]), checks);
2342
+ delete prevChildren[c.value.outlet];
2343
+ });
2344
+ Object.entries(prevChildren).forEach(([k, v]) => deactivateRouteAndItsChildren(v, contexts.getContext(k), checks));
2345
+ return checks;
2346
+ }
2347
+ function getRouteGuards(futureNode, currNode, parentContexts, futurePath, checks = {
2348
+ canDeactivateChecks: [],
2349
+ canActivateChecks: []
2350
+ }) {
2351
+ const future = futureNode.value;
2352
+ const curr = currNode ? currNode.value : null;
2353
+ const context = parentContexts ? parentContexts.getContext(futureNode.value.outlet) : null;
2354
+ if (curr && future.routeConfig === curr.routeConfig) {
2355
+ const shouldRun = shouldRunGuardsAndResolvers(curr, future, future.routeConfig.runGuardsAndResolvers);
2356
+ if (shouldRun) {
2357
+ checks.canActivateChecks.push(new CanActivate(futurePath));
2358
+ } else {
2359
+ future.data = curr.data;
2360
+ future._resolvedData = curr._resolvedData;
2361
+ }
2362
+ if (future.component) {
2363
+ getChildRouteGuards(futureNode, currNode, context ? context.children : null, futurePath, checks);
2364
+ } else {
2365
+ getChildRouteGuards(futureNode, currNode, parentContexts, futurePath, checks);
2366
+ }
2367
+ if (shouldRun && context && context.outlet && context.outlet.isActivated) {
2368
+ checks.canDeactivateChecks.push(new CanDeactivate(context.outlet.component, curr));
2369
+ }
2370
+ } else {
2371
+ if (curr) {
2372
+ deactivateRouteAndItsChildren(currNode, context, checks);
2373
+ }
2374
+ checks.canActivateChecks.push(new CanActivate(futurePath));
2375
+ if (future.component) {
2376
+ getChildRouteGuards(futureNode, null, context ? context.children : null, futurePath, checks);
2377
+ } else {
2378
+ getChildRouteGuards(futureNode, null, parentContexts, futurePath, checks);
2379
+ }
2380
+ }
2381
+ return checks;
2382
+ }
2383
+ function shouldRunGuardsAndResolvers(curr, future, mode) {
2384
+ if (typeof mode === 'function') {
2385
+ return mode(curr, future);
2386
+ }
2387
+ switch (mode) {
2388
+ case 'pathParamsChange':
2389
+ return !equalPath(curr.url, future.url);
2390
+ case 'pathParamsOrQueryParamsChange':
2391
+ return !equalPath(curr.url, future.url) || !shallowEqual(curr.queryParams, future.queryParams);
2392
+ case 'always':
2393
+ return true;
2394
+ case 'paramsOrQueryParamsChange':
2395
+ return !equalParamsAndUrlSegments(curr, future) || !shallowEqual(curr.queryParams, future.queryParams);
2396
+ case 'paramsChange':
2397
+ default:
2398
+ return !equalParamsAndUrlSegments(curr, future);
2399
+ }
2400
+ }
2401
+ function deactivateRouteAndItsChildren(route, context, checks) {
2402
+ const children = nodeChildrenAsMap(route);
2403
+ const r = route.value;
2404
+ Object.entries(children).forEach(([childName, node]) => {
2405
+ if (!r.component) {
2406
+ deactivateRouteAndItsChildren(node, context, checks);
2407
+ } else if (context) {
2408
+ deactivateRouteAndItsChildren(node, context.children.getContext(childName), checks);
2409
+ } else {
2410
+ deactivateRouteAndItsChildren(node, null, checks);
2411
+ }
2412
+ });
2413
+ if (!r.component) {
2414
+ checks.canDeactivateChecks.push(new CanDeactivate(null, r));
2415
+ } else if (context && context.outlet && context.outlet.isActivated) {
2416
+ checks.canDeactivateChecks.push(new CanDeactivate(context.outlet.component, r));
2417
+ } else {
2418
+ checks.canDeactivateChecks.push(new CanDeactivate(null, r));
2419
+ }
2420
+ }
2421
+
2422
+ function isFunction(v) {
2423
+ return typeof v === 'function';
2424
+ }
2425
+ function isBoolean(v) {
2426
+ return typeof v === 'boolean';
2427
+ }
2428
+ function isCanLoad(guard) {
2429
+ return guard && isFunction(guard.canLoad);
2430
+ }
2431
+ function isCanActivate(guard) {
2432
+ return guard && isFunction(guard.canActivate);
2433
+ }
2434
+ function isCanActivateChild(guard) {
2435
+ return guard && isFunction(guard.canActivateChild);
2436
+ }
2437
+ function isCanDeactivate(guard) {
2438
+ return guard && isFunction(guard.canDeactivate);
2439
+ }
2440
+ function isCanMatch(guard) {
2441
+ return guard && isFunction(guard.canMatch);
2442
+ }
2443
+ function isEmptyError(e) {
2444
+ return e instanceof EmptyError || e?.name === 'EmptyError';
2445
+ }
2446
+
2447
+ const INITIAL_VALUE = /* @__PURE__ */Symbol('INITIAL_VALUE');
2448
+ function prioritizedGuardValue() {
2449
+ return switchMap(obs => {
2450
+ return combineLatest(obs.map(o => o.pipe(take(1), startWith(INITIAL_VALUE)))).pipe(map(results => {
2451
+ for (const result of results) {
2452
+ if (result === true) {
2453
+ continue;
2454
+ } else if (result === INITIAL_VALUE) {
2455
+ return INITIAL_VALUE;
2456
+ } else if (result === false || isRedirect(result)) {
2457
+ return result;
2458
+ }
2459
+ }
2460
+ return true;
2461
+ }), filter(item => item !== INITIAL_VALUE), take(1));
2462
+ });
2463
+ }
2464
+ function isRedirect(val) {
2465
+ return isUrlTree(val) || val instanceof RedirectCommand;
2466
+ }
2467
+
2468
+ function abortSignalToObservable(signal) {
2469
+ if (signal.aborted) {
2470
+ return of(undefined).pipe(take(1));
2471
+ }
2472
+ return new Observable(subscriber => {
2473
+ const handler = () => {
2474
+ subscriber.next();
2475
+ subscriber.complete();
2476
+ };
2477
+ signal.addEventListener('abort', handler);
2478
+ return () => signal.removeEventListener('abort', handler);
2479
+ });
2480
+ }
2481
+ function takeUntilAbort(signal) {
2482
+ return takeUntil(abortSignalToObservable(signal));
2483
+ }
2484
+
2485
+ function checkGuards(injector, forwardEvent) {
2486
+ return mergeMap(t => {
2487
+ const {
2488
+ targetSnapshot,
2489
+ currentSnapshot,
2490
+ guards: {
2491
+ canActivateChecks,
2492
+ canDeactivateChecks
2493
+ }
2494
+ } = t;
2495
+ if (canDeactivateChecks.length === 0 && canActivateChecks.length === 0) {
2496
+ return of({
2497
+ ...t,
2498
+ guardsResult: true
2499
+ });
2500
+ }
2501
+ return runCanDeactivateChecks(canDeactivateChecks, targetSnapshot, currentSnapshot, injector).pipe(mergeMap(canDeactivate => {
2502
+ return canDeactivate && isBoolean(canDeactivate) ? runCanActivateChecks(targetSnapshot, canActivateChecks, injector, forwardEvent) : of(canDeactivate);
2503
+ }), map(guardsResult => ({
2504
+ ...t,
2505
+ guardsResult
2506
+ })));
2507
+ });
2508
+ }
2509
+ function runCanDeactivateChecks(checks, futureRSS, currRSS, injector) {
2510
+ return from(checks).pipe(mergeMap(check => runCanDeactivate(check.component, check.route, currRSS, futureRSS, injector)), first(result => {
2511
+ return result !== true;
2512
+ }, true));
2513
+ }
2514
+ function runCanActivateChecks(futureSnapshot, checks, injector, forwardEvent) {
2515
+ return from(checks).pipe(concatMap(check => {
2516
+ return concat(fireChildActivationStart(check.route.parent, forwardEvent), fireActivationStart(check.route, forwardEvent), runCanActivateChild(futureSnapshot, check.path, injector), runCanActivate(futureSnapshot, check.route, injector));
2517
+ }), first(result => {
2518
+ return result !== true;
2519
+ }, true));
2520
+ }
2521
+ function fireActivationStart(snapshot, forwardEvent) {
2522
+ if (snapshot !== null && forwardEvent) {
2523
+ forwardEvent(new ActivationStart(snapshot));
2524
+ }
2525
+ return of(true);
2526
+ }
2527
+ function fireChildActivationStart(snapshot, forwardEvent) {
2528
+ if (snapshot !== null && forwardEvent) {
2529
+ forwardEvent(new ChildActivationStart(snapshot));
2530
+ }
2531
+ return of(true);
2532
+ }
2533
+ function runCanActivate(futureRSS, futureARS, injector) {
2534
+ const canActivate = futureARS.routeConfig ? futureARS.routeConfig.canActivate : null;
2535
+ if (!canActivate || canActivate.length === 0) return of(true);
2536
+ const canActivateObservables = canActivate.map(canActivate => {
2537
+ return defer(() => {
2538
+ const closestInjector = getClosestRouteInjector(futureARS) ?? injector;
2539
+ const guard = getTokenOrFunctionIdentity(canActivate, closestInjector);
2540
+ const guardVal = isCanActivate(guard) ? guard.canActivate(futureARS, futureRSS) : runInInjectionContext(closestInjector, () => guard(futureARS, futureRSS));
2541
+ return wrapIntoObservable(guardVal).pipe(first());
2542
+ });
2543
+ });
2544
+ return of(canActivateObservables).pipe(prioritizedGuardValue());
2545
+ }
2546
+ function runCanActivateChild(futureRSS, path, injector) {
2547
+ const futureARS = path[path.length - 1];
2548
+ const canActivateChildGuards = path.slice(0, path.length - 1).reverse().map(p => getCanActivateChild(p)).filter(_ => _ !== null);
2549
+ const canActivateChildGuardsMapped = canActivateChildGuards.map(d => {
2550
+ return defer(() => {
2551
+ const guardsMapped = d.guards.map(canActivateChild => {
2552
+ const closestInjector = getClosestRouteInjector(d.node) ?? injector;
2553
+ const guard = getTokenOrFunctionIdentity(canActivateChild, closestInjector);
2554
+ const guardVal = isCanActivateChild(guard) ? guard.canActivateChild(futureARS, futureRSS) : runInInjectionContext(closestInjector, () => guard(futureARS, futureRSS));
2555
+ return wrapIntoObservable(guardVal).pipe(first());
2556
+ });
2557
+ return of(guardsMapped).pipe(prioritizedGuardValue());
2558
+ });
2559
+ });
2560
+ return of(canActivateChildGuardsMapped).pipe(prioritizedGuardValue());
2561
+ }
2562
+ function runCanDeactivate(component, currARS, currRSS, futureRSS, injector) {
2563
+ const canDeactivate = currARS && currARS.routeConfig ? currARS.routeConfig.canDeactivate : null;
2564
+ if (!canDeactivate || canDeactivate.length === 0) return of(true);
2565
+ const canDeactivateObservables = canDeactivate.map(c => {
2566
+ const closestInjector = getClosestRouteInjector(currARS) ?? injector;
2567
+ const guard = getTokenOrFunctionIdentity(c, closestInjector);
2568
+ const guardVal = isCanDeactivate(guard) ? guard.canDeactivate(component, currARS, currRSS, futureRSS) : runInInjectionContext(closestInjector, () => guard(component, currARS, currRSS, futureRSS));
2569
+ return wrapIntoObservable(guardVal).pipe(first());
2570
+ });
2571
+ return of(canDeactivateObservables).pipe(prioritizedGuardValue());
2572
+ }
2573
+ function runCanLoadGuards(injector, route, segments, urlSerializer, abortSignal) {
2574
+ const canLoad = route.canLoad;
2575
+ if (canLoad === undefined || canLoad.length === 0) {
2576
+ return of(true);
2577
+ }
2578
+ const canLoadObservables = canLoad.map(injectionToken => {
2579
+ const guard = getTokenOrFunctionIdentity(injectionToken, injector);
2580
+ const guardVal = isCanLoad(guard) ? guard.canLoad(route, segments) : runInInjectionContext(injector, () => guard(route, segments));
2581
+ const obs$ = wrapIntoObservable(guardVal);
2582
+ return abortSignal ? obs$.pipe(takeUntilAbort(abortSignal)) : obs$;
2583
+ });
2584
+ return of(canLoadObservables).pipe(prioritizedGuardValue(), redirectIfUrlTree(urlSerializer));
2585
+ }
2586
+ function redirectIfUrlTree(urlSerializer) {
2587
+ return pipe(tap(result => {
2588
+ if (typeof result === 'boolean') return;
2589
+ throw redirectingNavigationError(urlSerializer, result);
2590
+ }), map(result => result === true));
2591
+ }
2592
+ function runCanMatchGuards(injector, route, segments, urlSerializer, abortSignal) {
2593
+ const canMatch = route.canMatch;
2594
+ if (!canMatch || canMatch.length === 0) return of(true);
2595
+ const canMatchObservables = canMatch.map(injectionToken => {
2596
+ const guard = getTokenOrFunctionIdentity(injectionToken, injector);
2597
+ const guardVal = isCanMatch(guard) ? guard.canMatch(route, segments) : runInInjectionContext(injector, () => guard(route, segments));
2598
+ let obs$ = wrapIntoObservable(guardVal);
2599
+ return abortSignal ? obs$.pipe(takeUntilAbort(abortSignal)) : obs$;
2600
+ });
2601
+ return of(canMatchObservables).pipe(prioritizedGuardValue(), redirectIfUrlTree(urlSerializer));
2602
+ }
2603
+
2604
+ let NoMatch$1 = class NoMatch extends Error {
2605
+ segmentGroup;
2606
+ constructor(segmentGroup) {
2607
+ super();
2608
+ this.segmentGroup = segmentGroup || null;
2609
+ Object.setPrototypeOf(this, NoMatch.prototype);
2610
+ }
2611
+ };
2612
+ let AbsoluteRedirect$1 = class AbsoluteRedirect extends Error {
2613
+ urlTree;
2614
+ constructor(urlTree) {
2615
+ super();
2616
+ this.urlTree = urlTree;
2617
+ Object.setPrototypeOf(this, AbsoluteRedirect.prototype);
2618
+ }
2619
+ };
2620
+ function namedOutletsRedirect$1(redirectTo) {
2621
+ throw new _RuntimeError(4000, (typeof ngDevMode === 'undefined' || ngDevMode) && `Only absolute redirects can have named outlets. redirectTo: '${redirectTo}'`);
2622
+ }
2623
+ function canLoadFails$1(route) {
2624
+ throw navigationCancelingError((typeof ngDevMode === 'undefined' || ngDevMode) && `Cannot load children because the guard of the route "path: '${route.path}'" returned false`, NavigationCancellationCode.GuardRejected);
2625
+ }
2626
+ let ApplyRedirects$1 = class ApplyRedirects {
2627
+ urlSerializer;
2628
+ urlTree;
2629
+ constructor(urlSerializer, urlTree) {
2630
+ this.urlSerializer = urlSerializer;
2631
+ this.urlTree = urlTree;
2632
+ }
2633
+ async lineralizeSegments(route, urlTree) {
2634
+ let res = [];
2635
+ let c = urlTree.root;
2636
+ while (true) {
2637
+ res = res.concat(c.segments);
2638
+ if (c.numberOfChildren === 0) {
2639
+ return res;
2640
+ }
2641
+ if (c.numberOfChildren > 1 || !c.children[PRIMARY_OUTLET]) {
2642
+ throw namedOutletsRedirect$1(`${route.redirectTo}`);
2643
+ }
2644
+ c = c.children[PRIMARY_OUTLET];
2645
+ }
2646
+ }
2647
+ async applyRedirectCommands(segments, redirectTo, posParams, currentSnapshot, injector) {
2648
+ const redirect = await getRedirectResult$1(redirectTo, currentSnapshot, injector);
2649
+ if (redirect instanceof UrlTree) {
2650
+ throw new AbsoluteRedirect$1(redirect);
2651
+ }
2652
+ const newTree = this.applyRedirectCreateUrlTree(redirect, this.urlSerializer.parse(redirect), segments, posParams);
2653
+ if (redirect[0] === '/') {
2654
+ throw new AbsoluteRedirect$1(newTree);
2655
+ }
2656
+ return newTree;
2657
+ }
2658
+ applyRedirectCreateUrlTree(redirectTo, urlTree, segments, posParams) {
2659
+ const newRoot = this.createSegmentGroup(redirectTo, urlTree.root, segments, posParams);
2660
+ return new UrlTree(newRoot, this.createQueryParams(urlTree.queryParams, this.urlTree.queryParams), urlTree.fragment);
2661
+ }
2662
+ createQueryParams(redirectToParams, actualParams) {
2663
+ const res = {};
2664
+ Object.entries(redirectToParams).forEach(([k, v]) => {
2665
+ const copySourceValue = typeof v === 'string' && v[0] === ':';
2666
+ if (copySourceValue) {
2667
+ const sourceName = v.substring(1);
2668
+ res[k] = actualParams[sourceName];
2669
+ } else {
2670
+ res[k] = v;
2671
+ }
2672
+ });
2673
+ return res;
2674
+ }
2675
+ createSegmentGroup(redirectTo, group, segments, posParams) {
2676
+ const updatedSegments = this.createSegments(redirectTo, group.segments, segments, posParams);
2677
+ let children = {};
2678
+ Object.entries(group.children).forEach(([name, child]) => {
2679
+ children[name] = this.createSegmentGroup(redirectTo, child, segments, posParams);
2680
+ });
2681
+ return new UrlSegmentGroup(updatedSegments, children);
2682
+ }
2683
+ createSegments(redirectTo, redirectToSegments, actualSegments, posParams) {
2684
+ return redirectToSegments.map(s => s.path[0] === ':' ? this.findPosParam(redirectTo, s, posParams) : this.findOrReturn(s, actualSegments));
2685
+ }
2686
+ findPosParam(redirectTo, redirectToUrlSegment, posParams) {
2687
+ const pos = posParams[redirectToUrlSegment.path.substring(1)];
2688
+ if (!pos) throw new _RuntimeError(4001, (typeof ngDevMode === 'undefined' || ngDevMode) && `Cannot redirect to '${redirectTo}'. Cannot find '${redirectToUrlSegment.path}'.`);
2689
+ return pos;
2690
+ }
2691
+ findOrReturn(redirectToUrlSegment, actualSegments) {
2692
+ let idx = 0;
2693
+ for (const s of actualSegments) {
2694
+ if (s.path === redirectToUrlSegment.path) {
2695
+ actualSegments.splice(idx);
2696
+ return s;
2697
+ }
2698
+ idx++;
2699
+ }
2700
+ return redirectToUrlSegment;
2701
+ }
2702
+ };
2703
+ function getRedirectResult$1(redirectTo, currentSnapshot, injector) {
2704
+ if (typeof redirectTo === 'string') {
2705
+ return Promise.resolve(redirectTo);
2706
+ }
2707
+ const redirectToFn = redirectTo;
2708
+ const {
2709
+ queryParams,
2710
+ fragment,
2711
+ routeConfig,
2712
+ url,
2713
+ outlet,
2714
+ params,
2715
+ data,
2716
+ title
2717
+ } = currentSnapshot;
2718
+ return firstValueFrom(wrapIntoObservable(runInInjectionContext(injector, () => redirectToFn({
2719
+ params,
2720
+ data,
2721
+ queryParams,
2722
+ fragment,
2723
+ routeConfig,
2724
+ url,
2725
+ outlet,
2726
+ title
2727
+ }))));
2728
+ }
2729
+
2730
+ const noMatch$1 = {
2731
+ matched: false,
2732
+ consumedSegments: [],
2733
+ remainingSegments: [],
2734
+ parameters: {},
2735
+ positionalParamSegments: {}
2736
+ };
2737
+ function matchWithChecks(segmentGroup, route, segments, injector, urlSerializer, abortSignal) {
2738
+ const result = match(segmentGroup, route, segments);
2739
+ if (!result.matched) {
2740
+ return of(result);
2741
+ }
2742
+ injector = getOrCreateRouteInjectorIfNeeded(route, injector);
2743
+ return runCanMatchGuards(injector, route, segments, urlSerializer, abortSignal).pipe(map(v => v === true ? result : {
2744
+ ...noMatch$1
2745
+ }));
2746
+ }
2747
+ function match(segmentGroup, route, segments) {
2748
+ if (route.path === '**') {
2749
+ return createWildcardMatchResult(segments);
2750
+ }
2751
+ if (route.path === '') {
2752
+ if (route.pathMatch === 'full' && (segmentGroup.hasChildren() || segments.length > 0)) {
2753
+ return {
2754
+ ...noMatch$1
2755
+ };
2756
+ }
2757
+ return {
2758
+ matched: true,
2759
+ consumedSegments: [],
2760
+ remainingSegments: segments,
2761
+ parameters: {},
2762
+ positionalParamSegments: {}
2763
+ };
2764
+ }
2765
+ const matcher = route.matcher || defaultUrlMatcher;
2766
+ const res = matcher(segments, segmentGroup, route);
2767
+ if (!res) return {
2768
+ ...noMatch$1
2769
+ };
2770
+ const posParams = {};
2771
+ Object.entries(res.posParams ?? {}).forEach(([k, v]) => {
2772
+ posParams[k] = v.path;
2773
+ });
2774
+ const parameters = res.consumed.length > 0 ? {
2775
+ ...posParams,
2776
+ ...res.consumed[res.consumed.length - 1].parameters
2777
+ } : posParams;
2778
+ return {
2779
+ matched: true,
2780
+ consumedSegments: res.consumed,
2781
+ remainingSegments: segments.slice(res.consumed.length),
2782
+ parameters,
2783
+ positionalParamSegments: res.posParams ?? {}
2784
+ };
2785
+ }
2786
+ function createWildcardMatchResult(segments) {
2787
+ return {
2788
+ matched: true,
2789
+ parameters: segments.length > 0 ? last(segments).parameters : {},
2790
+ consumedSegments: segments,
2791
+ remainingSegments: [],
2792
+ positionalParamSegments: {}
2793
+ };
2794
+ }
2795
+ function split(segmentGroup, consumedSegments, slicedSegments, config) {
2796
+ if (slicedSegments.length > 0 && containsEmptyPathMatchesWithNamedOutlets(segmentGroup, slicedSegments, config)) {
2797
+ const s = new UrlSegmentGroup(consumedSegments, createChildrenForEmptyPaths(config, new UrlSegmentGroup(slicedSegments, segmentGroup.children)));
2798
+ return {
2799
+ segmentGroup: s,
2800
+ slicedSegments: []
2801
+ };
2802
+ }
2803
+ if (slicedSegments.length === 0 && containsEmptyPathMatches(segmentGroup, slicedSegments, config)) {
2804
+ const s = new UrlSegmentGroup(segmentGroup.segments, addEmptyPathsToChildrenIfNeeded(segmentGroup, slicedSegments, config, segmentGroup.children));
2805
+ return {
2806
+ segmentGroup: s,
2807
+ slicedSegments
2808
+ };
2809
+ }
2810
+ const s = new UrlSegmentGroup(segmentGroup.segments, segmentGroup.children);
2811
+ return {
2812
+ segmentGroup: s,
2813
+ slicedSegments
2814
+ };
2815
+ }
2816
+ function addEmptyPathsToChildrenIfNeeded(segmentGroup, slicedSegments, routes, children) {
2817
+ const res = {};
2818
+ for (const r of routes) {
2819
+ if (emptyPathMatch(segmentGroup, slicedSegments, r) && !children[getOutlet(r)]) {
2820
+ const s = new UrlSegmentGroup([], {});
2821
+ res[getOutlet(r)] = s;
2822
+ }
2823
+ }
2824
+ return {
2825
+ ...children,
2826
+ ...res
2827
+ };
2828
+ }
2829
+ function createChildrenForEmptyPaths(routes, primarySegment) {
2830
+ const res = {};
2831
+ res[PRIMARY_OUTLET] = primarySegment;
2832
+ for (const r of routes) {
2833
+ if (r.path === '' && getOutlet(r) !== PRIMARY_OUTLET) {
2834
+ const s = new UrlSegmentGroup([], {});
2835
+ res[getOutlet(r)] = s;
2836
+ }
2837
+ }
2838
+ return res;
2839
+ }
2840
+ function containsEmptyPathMatchesWithNamedOutlets(segmentGroup, slicedSegments, routes) {
2841
+ return routes.some(r => emptyPathMatch(segmentGroup, slicedSegments, r) && getOutlet(r) !== PRIMARY_OUTLET);
2842
+ }
2843
+ function containsEmptyPathMatches(segmentGroup, slicedSegments, routes) {
2844
+ return routes.some(r => emptyPathMatch(segmentGroup, slicedSegments, r));
2845
+ }
2846
+ function emptyPathMatch(segmentGroup, slicedSegments, r) {
2847
+ if ((segmentGroup.hasChildren() || slicedSegments.length > 0) && r.pathMatch === 'full') {
2848
+ return false;
2849
+ }
2850
+ return r.path === '';
2851
+ }
2852
+ function noLeftoversInUrl(segmentGroup, segments, outlet) {
2853
+ return segments.length === 0 && !segmentGroup.children[outlet];
2854
+ }
2855
+
2856
+ let NoLeftoversInUrl$1 = class NoLeftoversInUrl {};
2857
+ async function recognize$2(injector, configLoader, rootComponentType, config, urlTree, urlSerializer, paramsInheritanceStrategy = 'emptyOnly', abortSignal) {
2858
+ return new Recognizer$1(injector, configLoader, rootComponentType, config, urlTree, paramsInheritanceStrategy, urlSerializer, abortSignal).recognize();
2859
+ }
2860
+ const MAX_ALLOWED_REDIRECTS$1 = 31;
2861
+ let Recognizer$1 = class Recognizer {
2862
+ injector;
2863
+ configLoader;
2864
+ rootComponentType;
2865
+ config;
2866
+ urlTree;
2867
+ paramsInheritanceStrategy;
2868
+ urlSerializer;
2869
+ abortSignal;
2870
+ applyRedirects;
2871
+ absoluteRedirectCount = 0;
2872
+ allowRedirects = true;
2873
+ constructor(injector, configLoader, rootComponentType, config, urlTree, paramsInheritanceStrategy, urlSerializer, abortSignal) {
2874
+ this.injector = injector;
2875
+ this.configLoader = configLoader;
2876
+ this.rootComponentType = rootComponentType;
2877
+ this.config = config;
2878
+ this.urlTree = urlTree;
2879
+ this.paramsInheritanceStrategy = paramsInheritanceStrategy;
2880
+ this.urlSerializer = urlSerializer;
2881
+ this.abortSignal = abortSignal;
2882
+ this.applyRedirects = new ApplyRedirects$1(this.urlSerializer, this.urlTree);
2883
+ }
2884
+ noMatchError(e) {
2885
+ return new _RuntimeError(4002, typeof ngDevMode === 'undefined' || ngDevMode ? `Cannot match any routes. URL Segment: '${e.segmentGroup}'` : `'${e.segmentGroup}'`);
2886
+ }
2887
+ async recognize() {
2888
+ const rootSegmentGroup = split(this.urlTree.root, [], [], this.config).segmentGroup;
2889
+ const {
2890
+ children,
2891
+ rootSnapshot
2892
+ } = await this.match(rootSegmentGroup);
2893
+ const rootNode = new TreeNode(rootSnapshot, children);
2894
+ const routeState = new RouterStateSnapshot('', rootNode);
2895
+ const tree = createUrlTreeFromSnapshot(rootSnapshot, [], this.urlTree.queryParams, this.urlTree.fragment);
2896
+ tree.queryParams = this.urlTree.queryParams;
2897
+ routeState.url = this.urlSerializer.serialize(tree);
2898
+ return {
2899
+ state: routeState,
2900
+ tree
2901
+ };
2902
+ }
2903
+ async match(rootSegmentGroup) {
2904
+ const rootSnapshot = new ActivatedRouteSnapshot([], Object.freeze({}), Object.freeze({
2905
+ ...this.urlTree.queryParams
2906
+ }), this.urlTree.fragment, Object.freeze({}), PRIMARY_OUTLET, this.rootComponentType, null, {});
2907
+ try {
2908
+ const children = await this.processSegmentGroup(this.injector, this.config, rootSegmentGroup, PRIMARY_OUTLET, rootSnapshot);
2909
+ return {
2910
+ children,
2911
+ rootSnapshot
2912
+ };
2913
+ } catch (e) {
2914
+ if (e instanceof AbsoluteRedirect$1) {
2915
+ this.urlTree = e.urlTree;
2916
+ return this.match(e.urlTree.root);
2917
+ }
2918
+ if (e instanceof NoMatch$1) {
2919
+ throw this.noMatchError(e);
2920
+ }
2921
+ throw e;
2922
+ }
2923
+ }
2924
+ async processSegmentGroup(injector, config, segmentGroup, outlet, parentRoute) {
2925
+ if (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) {
2926
+ return this.processChildren(injector, config, segmentGroup, parentRoute);
2927
+ }
2928
+ const child = await this.processSegment(injector, config, segmentGroup, segmentGroup.segments, outlet, true, parentRoute);
2929
+ return child instanceof TreeNode ? [child] : [];
2930
+ }
2931
+ async processChildren(injector, config, segmentGroup, parentRoute) {
2932
+ const childOutlets = [];
2933
+ for (const child of Object.keys(segmentGroup.children)) {
2934
+ if (child === 'primary') {
2935
+ childOutlets.unshift(child);
2936
+ } else {
2937
+ childOutlets.push(child);
2938
+ }
2939
+ }
2940
+ let children = [];
2941
+ for (const childOutlet of childOutlets) {
2942
+ const child = segmentGroup.children[childOutlet];
2943
+ const sortedConfig = sortByMatchingOutlets(config, childOutlet);
2944
+ const outletChildren = await this.processSegmentGroup(injector, sortedConfig, child, childOutlet, parentRoute);
2945
+ children.push(...outletChildren);
2946
+ }
2947
+ const mergedChildren = mergeEmptyPathMatches$1(children);
2948
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
2949
+ checkOutletNameUniqueness$1(mergedChildren);
2950
+ }
2951
+ sortActivatedRouteSnapshots$1(mergedChildren);
2952
+ return mergedChildren;
2953
+ }
2954
+ async processSegment(injector, routes, segmentGroup, segments, outlet, allowRedirects, parentRoute) {
2955
+ for (const r of routes) {
2956
+ try {
2957
+ return await this.processSegmentAgainstRoute(r._injector ?? injector, routes, r, segmentGroup, segments, outlet, allowRedirects, parentRoute);
2958
+ } catch (e) {
2959
+ if (e instanceof NoMatch$1 || isEmptyError(e)) {
2960
+ continue;
2961
+ }
2962
+ throw e;
2963
+ }
2964
+ }
2965
+ if (noLeftoversInUrl(segmentGroup, segments, outlet)) {
2966
+ return new NoLeftoversInUrl$1();
2967
+ }
2968
+ throw new NoMatch$1(segmentGroup);
2969
+ }
2970
+ async processSegmentAgainstRoute(injector, routes, route, rawSegment, segments, outlet, allowRedirects, parentRoute) {
2971
+ if (getOutlet(route) !== outlet && (outlet === PRIMARY_OUTLET || !emptyPathMatch(rawSegment, segments, route))) {
2972
+ throw new NoMatch$1(rawSegment);
2973
+ }
2974
+ if (route.redirectTo === undefined) {
2975
+ return this.matchSegmentAgainstRoute(injector, rawSegment, route, segments, outlet, parentRoute);
2976
+ }
2977
+ if (this.allowRedirects && allowRedirects) {
2978
+ return this.expandSegmentAgainstRouteUsingRedirect(injector, rawSegment, routes, route, segments, outlet, parentRoute);
2979
+ }
2980
+ throw new NoMatch$1(rawSegment);
2981
+ }
2982
+ async expandSegmentAgainstRouteUsingRedirect(injector, segmentGroup, routes, route, segments, outlet, parentRoute) {
2983
+ const {
2984
+ matched,
2985
+ parameters,
2986
+ consumedSegments,
2987
+ positionalParamSegments,
2988
+ remainingSegments
2989
+ } = match(segmentGroup, route, segments);
2990
+ if (!matched) throw new NoMatch$1(segmentGroup);
2991
+ if (typeof route.redirectTo === 'string' && route.redirectTo[0] === '/') {
2992
+ this.absoluteRedirectCount++;
2993
+ if (this.absoluteRedirectCount > MAX_ALLOWED_REDIRECTS$1) {
2994
+ if (ngDevMode) {
2995
+ throw new _RuntimeError(4016, `Detected possible infinite redirect when redirecting from '${this.urlTree}' to '${route.redirectTo}'.\n` + `This is currently a dev mode only error but will become a` + ` call stack size exceeded error in production in a future major version.`);
2996
+ }
2997
+ this.allowRedirects = false;
2998
+ }
2999
+ }
3000
+ const currentSnapshot = new ActivatedRouteSnapshot(segments, parameters, Object.freeze({
3001
+ ...this.urlTree.queryParams
3002
+ }), this.urlTree.fragment, getData$1(route), getOutlet(route), route.component ?? route._loadedComponent ?? null, route, getResolve$1(route));
3003
+ const inherited = getInherited(currentSnapshot, parentRoute, this.paramsInheritanceStrategy);
3004
+ currentSnapshot.params = Object.freeze(inherited.params);
3005
+ currentSnapshot.data = Object.freeze(inherited.data);
3006
+ if (this.abortSignal.aborted) {
3007
+ throw new Error(this.abortSignal.reason);
3008
+ }
3009
+ const newTree = await this.applyRedirects.applyRedirectCommands(consumedSegments, route.redirectTo, positionalParamSegments, currentSnapshot, injector);
3010
+ const newSegments = await this.applyRedirects.lineralizeSegments(route, newTree);
3011
+ return this.processSegment(injector, routes, segmentGroup, newSegments.concat(remainingSegments), outlet, false, parentRoute);
3012
+ }
3013
+ async matchSegmentAgainstRoute(injector, rawSegment, route, segments, outlet, parentRoute) {
3014
+ if (this.abortSignal.aborted) {
3015
+ throw new Error(this.abortSignal.reason);
3016
+ }
3017
+ const result = await firstValueFrom(matchWithChecks(rawSegment, route, segments, injector, this.urlSerializer, this.abortSignal));
3018
+ if (route.path === '**') {
3019
+ rawSegment.children = {};
3020
+ }
3021
+ if (!result?.matched) {
3022
+ throw new NoMatch$1(rawSegment);
3023
+ }
3024
+ injector = route._injector ?? injector;
3025
+ const {
3026
+ routes: childConfig
3027
+ } = await this.getChildConfig(injector, route, segments);
3028
+ const childInjector = route._loadedInjector ?? injector;
3029
+ const {
3030
+ parameters,
3031
+ consumedSegments,
3032
+ remainingSegments
3033
+ } = result;
3034
+ const snapshot = new ActivatedRouteSnapshot(consumedSegments, parameters, Object.freeze({
3035
+ ...this.urlTree.queryParams
3036
+ }), this.urlTree.fragment, getData$1(route), getOutlet(route), route.component ?? route._loadedComponent ?? null, route, getResolve$1(route));
3037
+ const inherited = getInherited(snapshot, parentRoute, this.paramsInheritanceStrategy);
3038
+ snapshot.params = Object.freeze(inherited.params);
3039
+ snapshot.data = Object.freeze(inherited.data);
3040
+ const {
3041
+ segmentGroup,
3042
+ slicedSegments
3043
+ } = split(rawSegment, consumedSegments, remainingSegments, childConfig);
3044
+ if (slicedSegments.length === 0 && segmentGroup.hasChildren()) {
3045
+ const children = await this.processChildren(childInjector, childConfig, segmentGroup, snapshot);
3046
+ return new TreeNode(snapshot, children);
3047
+ }
3048
+ if (childConfig.length === 0 && slicedSegments.length === 0) {
3049
+ return new TreeNode(snapshot, []);
3050
+ }
3051
+ const matchedOnOutlet = getOutlet(route) === outlet;
3052
+ const child = await this.processSegment(childInjector, childConfig, segmentGroup, slicedSegments, matchedOnOutlet ? PRIMARY_OUTLET : outlet, true, snapshot);
3053
+ return new TreeNode(snapshot, child instanceof TreeNode ? [child] : []);
3054
+ }
3055
+ async getChildConfig(injector, route, segments) {
3056
+ if (route.children) {
3057
+ return {
3058
+ routes: route.children,
3059
+ injector
3060
+ };
3061
+ }
3062
+ if (route.loadChildren) {
3063
+ if (route._loadedRoutes !== undefined) {
3064
+ return {
3065
+ routes: route._loadedRoutes,
3066
+ injector: route._loadedInjector
3067
+ };
3068
+ }
3069
+ if (this.abortSignal.aborted) {
3070
+ throw new Error(this.abortSignal.reason);
3071
+ }
3072
+ const shouldLoadResult = await firstValueFrom(runCanLoadGuards(injector, route, segments, this.urlSerializer, this.abortSignal));
3073
+ if (shouldLoadResult) {
3074
+ const cfg = await this.configLoader.loadChildren(injector, route);
3075
+ route._loadedRoutes = cfg.routes;
3076
+ route._loadedInjector = cfg.injector;
3077
+ return cfg;
3078
+ }
3079
+ throw canLoadFails$1(route);
3080
+ }
3081
+ return {
3082
+ routes: [],
3083
+ injector
3084
+ };
3085
+ }
3086
+ };
3087
+ function sortActivatedRouteSnapshots$1(nodes) {
3088
+ nodes.sort((a, b) => {
3089
+ if (a.value.outlet === PRIMARY_OUTLET) return -1;
3090
+ if (b.value.outlet === PRIMARY_OUTLET) return 1;
3091
+ return a.value.outlet.localeCompare(b.value.outlet);
3092
+ });
3093
+ }
3094
+ function hasEmptyPathConfig$1(node) {
3095
+ const config = node.value.routeConfig;
3096
+ return config && config.path === '';
3097
+ }
3098
+ function mergeEmptyPathMatches$1(nodes) {
3099
+ const result = [];
3100
+ const mergedNodes = new Set();
3101
+ for (const node of nodes) {
3102
+ if (!hasEmptyPathConfig$1(node)) {
3103
+ result.push(node);
3104
+ continue;
3105
+ }
3106
+ const duplicateEmptyPathNode = result.find(resultNode => node.value.routeConfig === resultNode.value.routeConfig);
3107
+ if (duplicateEmptyPathNode !== undefined) {
3108
+ duplicateEmptyPathNode.children.push(...node.children);
3109
+ mergedNodes.add(duplicateEmptyPathNode);
3110
+ } else {
3111
+ result.push(node);
3112
+ }
3113
+ }
3114
+ for (const mergedNode of mergedNodes) {
3115
+ const mergedChildren = mergeEmptyPathMatches$1(mergedNode.children);
3116
+ result.push(new TreeNode(mergedNode.value, mergedChildren));
3117
+ }
3118
+ return result.filter(n => !mergedNodes.has(n));
3119
+ }
3120
+ function checkOutletNameUniqueness$1(nodes) {
3121
+ const names = {};
3122
+ nodes.forEach(n => {
3123
+ const routeWithSameOutletName = names[n.value.outlet];
3124
+ if (routeWithSameOutletName) {
3125
+ const p = routeWithSameOutletName.url.map(s => s.toString()).join('/');
3126
+ const c = n.value.url.map(s => s.toString()).join('/');
3127
+ throw new _RuntimeError(4006, (typeof ngDevMode === 'undefined' || ngDevMode) && `Two segments cannot have the same outlet name: '${p}' and '${c}'.`);
3128
+ }
3129
+ names[n.value.outlet] = n.value;
3130
+ });
3131
+ }
3132
+ function getData$1(route) {
3133
+ return route.data || {};
3134
+ }
3135
+ function getResolve$1(route) {
3136
+ return route.resolve || {};
3137
+ }
3138
+
3139
+ class NoMatch {
3140
+ segmentGroup;
3141
+ constructor(segmentGroup) {
3142
+ this.segmentGroup = segmentGroup || null;
3143
+ }
3144
+ }
3145
+ class AbsoluteRedirect extends Error {
3146
+ urlTree;
3147
+ constructor(urlTree) {
3148
+ super();
3149
+ this.urlTree = urlTree;
3150
+ }
3151
+ }
3152
+ function noMatch(segmentGroup) {
3153
+ return throwError(new NoMatch(segmentGroup));
3154
+ }
3155
+ function namedOutletsRedirect(redirectTo) {
3156
+ return throwError(new _RuntimeError(4000, (typeof ngDevMode === 'undefined' || ngDevMode) && `Only absolute redirects can have named outlets. redirectTo: '${redirectTo}'`));
3157
+ }
3158
+ function canLoadFails(route) {
3159
+ return throwError(navigationCancelingError((typeof ngDevMode === 'undefined' || ngDevMode) && `Cannot load children because the guard of the route "path: '${route.path}'" returned false`, NavigationCancellationCode.GuardRejected));
3160
+ }
3161
+ class ApplyRedirects {
3162
+ urlSerializer;
3163
+ urlTree;
3164
+ constructor(urlSerializer, urlTree) {
3165
+ this.urlSerializer = urlSerializer;
3166
+ this.urlTree = urlTree;
3167
+ }
3168
+ lineralizeSegments(route, urlTree) {
3169
+ let res = [];
3170
+ let c = urlTree.root;
3171
+ while (true) {
3172
+ res = res.concat(c.segments);
3173
+ if (c.numberOfChildren === 0) {
3174
+ return of(res);
3175
+ }
3176
+ if (c.numberOfChildren > 1 || !c.children[PRIMARY_OUTLET]) {
3177
+ return namedOutletsRedirect(`${route.redirectTo}`);
3178
+ }
3179
+ c = c.children[PRIMARY_OUTLET];
3180
+ }
3181
+ }
3182
+ applyRedirectCommands(segments, redirectTo, posParams, currentSnapshot, injector) {
3183
+ return getRedirectResult(redirectTo, currentSnapshot, injector).pipe(map(redirect => {
3184
+ if (redirect instanceof UrlTree) {
3185
+ throw new AbsoluteRedirect(redirect);
3186
+ }
3187
+ const newTree = this.applyRedirectCreateUrlTree(redirect, this.urlSerializer.parse(redirect), segments, posParams);
3188
+ if (redirect[0] === '/') {
3189
+ throw new AbsoluteRedirect(newTree);
3190
+ }
3191
+ return newTree;
3192
+ }));
3193
+ }
3194
+ applyRedirectCreateUrlTree(redirectTo, urlTree, segments, posParams) {
3195
+ const newRoot = this.createSegmentGroup(redirectTo, urlTree.root, segments, posParams);
3196
+ return new UrlTree(newRoot, this.createQueryParams(urlTree.queryParams, this.urlTree.queryParams), urlTree.fragment);
3197
+ }
3198
+ createQueryParams(redirectToParams, actualParams) {
3199
+ const res = {};
3200
+ Object.entries(redirectToParams).forEach(([k, v]) => {
3201
+ const copySourceValue = typeof v === 'string' && v[0] === ':';
3202
+ if (copySourceValue) {
3203
+ const sourceName = v.substring(1);
3204
+ res[k] = actualParams[sourceName];
3205
+ } else {
3206
+ res[k] = v;
3207
+ }
3208
+ });
3209
+ return res;
3210
+ }
3211
+ createSegmentGroup(redirectTo, group, segments, posParams) {
3212
+ const updatedSegments = this.createSegments(redirectTo, group.segments, segments, posParams);
3213
+ let children = {};
3214
+ Object.entries(group.children).forEach(([name, child]) => {
3215
+ children[name] = this.createSegmentGroup(redirectTo, child, segments, posParams);
3216
+ });
3217
+ return new UrlSegmentGroup(updatedSegments, children);
3218
+ }
3219
+ createSegments(redirectTo, redirectToSegments, actualSegments, posParams) {
3220
+ return redirectToSegments.map(s => s.path[0] === ':' ? this.findPosParam(redirectTo, s, posParams) : this.findOrReturn(s, actualSegments));
3221
+ }
3222
+ findPosParam(redirectTo, redirectToUrlSegment, posParams) {
3223
+ const pos = posParams[redirectToUrlSegment.path.substring(1)];
3224
+ if (!pos) throw new _RuntimeError(4001, (typeof ngDevMode === 'undefined' || ngDevMode) && `Cannot redirect to '${redirectTo}'. Cannot find '${redirectToUrlSegment.path}'.`);
3225
+ return pos;
3226
+ }
3227
+ findOrReturn(redirectToUrlSegment, actualSegments) {
3228
+ let idx = 0;
3229
+ for (const s of actualSegments) {
3230
+ if (s.path === redirectToUrlSegment.path) {
3231
+ actualSegments.splice(idx);
3232
+ return s;
3233
+ }
3234
+ idx++;
3235
+ }
3236
+ return redirectToUrlSegment;
3237
+ }
3238
+ }
3239
+ function getRedirectResult(redirectTo, currentSnapshot, injector) {
3240
+ if (typeof redirectTo === 'string') {
3241
+ return of(redirectTo);
3242
+ }
3243
+ const redirectToFn = redirectTo;
3244
+ const {
3245
+ queryParams,
3246
+ fragment,
3247
+ routeConfig,
3248
+ url,
3249
+ outlet,
3250
+ params,
3251
+ data,
3252
+ title
3253
+ } = currentSnapshot;
3254
+ return wrapIntoObservable(runInInjectionContext(injector, () => redirectToFn({
3255
+ params,
3256
+ data,
3257
+ queryParams,
3258
+ fragment,
3259
+ routeConfig,
3260
+ url,
3261
+ outlet,
3262
+ title
3263
+ })));
3264
+ }
3265
+
3266
+ class NoLeftoversInUrl {}
3267
+ function recognize$1(injector, configLoader, rootComponentType, config, urlTree, urlSerializer, paramsInheritanceStrategy = 'emptyOnly', abortSignal) {
3268
+ return new Recognizer(injector, configLoader, rootComponentType, config, urlTree, paramsInheritanceStrategy, urlSerializer).recognize();
3269
+ }
3270
+ const MAX_ALLOWED_REDIRECTS = 31;
3271
+ class Recognizer {
3272
+ injector;
3273
+ configLoader;
3274
+ rootComponentType;
3275
+ config;
3276
+ urlTree;
3277
+ paramsInheritanceStrategy;
3278
+ urlSerializer;
3279
+ applyRedirects;
3280
+ absoluteRedirectCount = 0;
3281
+ allowRedirects = true;
3282
+ constructor(injector, configLoader, rootComponentType, config, urlTree, paramsInheritanceStrategy, urlSerializer) {
3283
+ this.injector = injector;
3284
+ this.configLoader = configLoader;
3285
+ this.rootComponentType = rootComponentType;
3286
+ this.config = config;
3287
+ this.urlTree = urlTree;
3288
+ this.paramsInheritanceStrategy = paramsInheritanceStrategy;
3289
+ this.urlSerializer = urlSerializer;
3290
+ this.applyRedirects = new ApplyRedirects(this.urlSerializer, this.urlTree);
3291
+ }
3292
+ noMatchError(e) {
3293
+ return new _RuntimeError(4002, typeof ngDevMode === 'undefined' || ngDevMode ? `Cannot match any routes. URL Segment: '${e.segmentGroup}'` : `'${e.segmentGroup}'`);
3294
+ }
3295
+ recognize() {
3296
+ const rootSegmentGroup = split(this.urlTree.root, [], [], this.config).segmentGroup;
3297
+ return this.match(rootSegmentGroup).pipe(map(({
3298
+ children,
3299
+ rootSnapshot
3300
+ }) => {
3301
+ const rootNode = new TreeNode(rootSnapshot, children);
3302
+ const routeState = new RouterStateSnapshot('', rootNode);
3303
+ const tree = createUrlTreeFromSnapshot(rootSnapshot, [], this.urlTree.queryParams, this.urlTree.fragment);
3304
+ tree.queryParams = this.urlTree.queryParams;
3305
+ routeState.url = this.urlSerializer.serialize(tree);
3306
+ return {
3307
+ state: routeState,
3308
+ tree
3309
+ };
3310
+ }));
3311
+ }
3312
+ match(rootSegmentGroup) {
3313
+ const rootSnapshot = new ActivatedRouteSnapshot([], Object.freeze({}), Object.freeze({
3314
+ ...this.urlTree.queryParams
3315
+ }), this.urlTree.fragment, Object.freeze({}), PRIMARY_OUTLET, this.rootComponentType, null, {});
3316
+ return this.processSegmentGroup(this.injector, this.config, rootSegmentGroup, PRIMARY_OUTLET, rootSnapshot).pipe(map(children => {
3317
+ return {
3318
+ children,
3319
+ rootSnapshot
3320
+ };
3321
+ }), catchError(e => {
3322
+ if (e instanceof AbsoluteRedirect) {
3323
+ this.urlTree = e.urlTree;
3324
+ return this.match(e.urlTree.root);
3325
+ }
3326
+ if (e instanceof NoMatch) {
3327
+ throw this.noMatchError(e);
3328
+ }
3329
+ throw e;
3330
+ }));
3331
+ }
3332
+ processSegmentGroup(injector, config, segmentGroup, outlet, parentRoute) {
3333
+ if (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) {
3334
+ return this.processChildren(injector, config, segmentGroup, parentRoute);
3335
+ }
3336
+ return this.processSegment(injector, config, segmentGroup, segmentGroup.segments, outlet, true, parentRoute).pipe(map(child => child instanceof TreeNode ? [child] : []));
3337
+ }
3338
+ processChildren(injector, config, segmentGroup, parentRoute) {
3339
+ const childOutlets = [];
3340
+ for (const child of Object.keys(segmentGroup.children)) {
3341
+ if (child === 'primary') {
3342
+ childOutlets.unshift(child);
3343
+ } else {
3344
+ childOutlets.push(child);
3345
+ }
3346
+ }
3347
+ return from(childOutlets).pipe(concatMap(childOutlet => {
3348
+ const child = segmentGroup.children[childOutlet];
3349
+ const sortedConfig = sortByMatchingOutlets(config, childOutlet);
3350
+ return this.processSegmentGroup(injector, sortedConfig, child, childOutlet, parentRoute);
3351
+ }), scan((children, outletChildren) => {
3352
+ children.push(...outletChildren);
3353
+ return children;
3354
+ }), defaultIfEmpty(null), last$1(), mergeMap(children => {
3355
+ if (children === null) return noMatch(segmentGroup);
3356
+ const mergedChildren = mergeEmptyPathMatches(children);
3357
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
3358
+ checkOutletNameUniqueness(mergedChildren);
3359
+ }
3360
+ sortActivatedRouteSnapshots(mergedChildren);
3361
+ return of(mergedChildren);
3362
+ }));
3363
+ }
3364
+ processSegment(injector, routes, segmentGroup, segments, outlet, allowRedirects, parentRoute) {
3365
+ return from(routes).pipe(concatMap(r => {
3366
+ return this.processSegmentAgainstRoute(r._injector ?? injector, routes, r, segmentGroup, segments, outlet, allowRedirects, parentRoute).pipe(catchError(e => {
3367
+ if (e instanceof NoMatch) {
3368
+ return of(null);
3369
+ }
3370
+ throw e;
3371
+ }));
3372
+ }), first(x => !!x), catchError(e => {
3373
+ if (isEmptyError(e)) {
3374
+ if (noLeftoversInUrl(segmentGroup, segments, outlet)) {
3375
+ return of(new NoLeftoversInUrl());
3376
+ }
3377
+ return noMatch(segmentGroup);
3378
+ }
3379
+ throw e;
3380
+ }));
3381
+ }
3382
+ processSegmentAgainstRoute(injector, routes, route, rawSegment, segments, outlet, allowRedirects, parentRoute) {
3383
+ if (getOutlet(route) !== outlet && (outlet === PRIMARY_OUTLET || !emptyPathMatch(rawSegment, segments, route))) {
3384
+ return noMatch(rawSegment);
3385
+ }
3386
+ if (route.redirectTo === undefined) {
3387
+ return this.matchSegmentAgainstRoute(injector, rawSegment, route, segments, outlet, parentRoute);
3388
+ }
3389
+ if (this.allowRedirects && allowRedirects) {
3390
+ return this.expandSegmentAgainstRouteUsingRedirect(injector, rawSegment, routes, route, segments, outlet, parentRoute);
3391
+ }
3392
+ return noMatch(rawSegment);
3393
+ }
3394
+ expandSegmentAgainstRouteUsingRedirect(injector, segmentGroup, routes, route, segments, outlet, parentRoute) {
3395
+ const {
3396
+ matched,
3397
+ parameters,
3398
+ consumedSegments,
3399
+ positionalParamSegments,
3400
+ remainingSegments
3401
+ } = match(segmentGroup, route, segments);
3402
+ if (!matched) return noMatch(segmentGroup);
3403
+ if (typeof route.redirectTo === 'string' && route.redirectTo[0] === '/') {
3404
+ this.absoluteRedirectCount++;
3405
+ if (this.absoluteRedirectCount > MAX_ALLOWED_REDIRECTS) {
3406
+ if (ngDevMode) {
3407
+ throw new _RuntimeError(4016, `Detected possible infinite redirect when redirecting from '${this.urlTree}' to '${route.redirectTo}'.\n` + `This is currently a dev mode only error but will become a` + ` call stack size exceeded error in production in a future major version.`);
3408
+ }
3409
+ this.allowRedirects = false;
3410
+ }
3411
+ }
3412
+ const currentSnapshot = new ActivatedRouteSnapshot(segments, parameters, Object.freeze({
3413
+ ...this.urlTree.queryParams
3414
+ }), this.urlTree.fragment, getData(route), getOutlet(route), route.component ?? route._loadedComponent ?? null, route, getResolve(route));
3415
+ const inherited = getInherited(currentSnapshot, parentRoute, this.paramsInheritanceStrategy);
3416
+ currentSnapshot.params = Object.freeze(inherited.params);
3417
+ currentSnapshot.data = Object.freeze(inherited.data);
3418
+ const newTree$ = this.applyRedirects.applyRedirectCommands(consumedSegments, route.redirectTo, positionalParamSegments, currentSnapshot, injector);
3419
+ return newTree$.pipe(switchMap(newTree => this.applyRedirects.lineralizeSegments(route, newTree)), mergeMap(newSegments => {
3420
+ return this.processSegment(injector, routes, segmentGroup, newSegments.concat(remainingSegments), outlet, false, parentRoute);
3421
+ }));
3422
+ }
3423
+ matchSegmentAgainstRoute(injector, rawSegment, route, segments, outlet, parentRoute) {
3424
+ const matchResult = matchWithChecks(rawSegment, route, segments, injector, this.urlSerializer);
3425
+ if (route.path === '**') {
3426
+ rawSegment.children = {};
3427
+ }
3428
+ return matchResult.pipe(switchMap(result => {
3429
+ if (!result.matched) {
3430
+ return noMatch(rawSegment);
3431
+ }
3432
+ injector = route._injector ?? injector;
3433
+ return this.getChildConfig(injector, route, segments).pipe(switchMap(({
3434
+ routes: childConfig
3435
+ }) => {
3436
+ const childInjector = route._loadedInjector ?? injector;
3437
+ const {
3438
+ parameters,
3439
+ consumedSegments,
3440
+ remainingSegments
3441
+ } = result;
3442
+ const snapshot = new ActivatedRouteSnapshot(consumedSegments, parameters, Object.freeze({
3443
+ ...this.urlTree.queryParams
3444
+ }), this.urlTree.fragment, getData(route), getOutlet(route), route.component ?? route._loadedComponent ?? null, route, getResolve(route));
3445
+ const inherited = getInherited(snapshot, parentRoute, this.paramsInheritanceStrategy);
3446
+ snapshot.params = Object.freeze(inherited.params);
3447
+ snapshot.data = Object.freeze(inherited.data);
3448
+ const {
3449
+ segmentGroup,
3450
+ slicedSegments
3451
+ } = split(rawSegment, consumedSegments, remainingSegments, childConfig);
3452
+ if (slicedSegments.length === 0 && segmentGroup.hasChildren()) {
3453
+ return this.processChildren(childInjector, childConfig, segmentGroup, snapshot).pipe(map(children => {
3454
+ return new TreeNode(snapshot, children);
3455
+ }));
3456
+ }
3457
+ if (childConfig.length === 0 && slicedSegments.length === 0) {
3458
+ return of(new TreeNode(snapshot, []));
3459
+ }
3460
+ const matchedOnOutlet = getOutlet(route) === outlet;
3461
+ return this.processSegment(childInjector, childConfig, segmentGroup, slicedSegments, matchedOnOutlet ? PRIMARY_OUTLET : outlet, true, snapshot).pipe(map(child => {
3462
+ return new TreeNode(snapshot, child instanceof TreeNode ? [child] : []);
3463
+ }));
3464
+ }));
3465
+ }));
3466
+ }
3467
+ getChildConfig(injector, route, segments) {
3468
+ if (route.children) {
3469
+ return of({
3470
+ routes: route.children,
3471
+ injector
3472
+ });
3473
+ }
3474
+ if (route.loadChildren) {
3475
+ if (route._loadedRoutes !== undefined) {
3476
+ return of({
3477
+ routes: route._loadedRoutes,
3478
+ injector: route._loadedInjector
3479
+ });
3480
+ }
3481
+ return runCanLoadGuards(injector, route, segments, this.urlSerializer).pipe(mergeMap(shouldLoadResult => {
3482
+ if (shouldLoadResult) {
3483
+ return from(this.configLoader.loadChildren(injector, route)).pipe(tap(cfg => {
3484
+ route._loadedRoutes = cfg.routes;
3485
+ route._loadedInjector = cfg.injector;
3486
+ }));
3487
+ }
3488
+ return canLoadFails(route);
3489
+ }));
3490
+ }
3491
+ return of({
3492
+ routes: [],
3493
+ injector
3494
+ });
3495
+ }
3496
+ }
3497
+ function sortActivatedRouteSnapshots(nodes) {
3498
+ nodes.sort((a, b) => {
3499
+ if (a.value.outlet === PRIMARY_OUTLET) return -1;
3500
+ if (b.value.outlet === PRIMARY_OUTLET) return 1;
3501
+ return a.value.outlet.localeCompare(b.value.outlet);
3502
+ });
3503
+ }
3504
+ function hasEmptyPathConfig(node) {
3505
+ const config = node.value.routeConfig;
3506
+ return config && config.path === '';
3507
+ }
3508
+ function mergeEmptyPathMatches(nodes) {
3509
+ const result = [];
3510
+ const mergedNodes = new Set();
3511
+ for (const node of nodes) {
3512
+ if (!hasEmptyPathConfig(node)) {
3513
+ result.push(node);
3514
+ continue;
3515
+ }
3516
+ const duplicateEmptyPathNode = result.find(resultNode => node.value.routeConfig === resultNode.value.routeConfig);
3517
+ if (duplicateEmptyPathNode !== undefined) {
3518
+ duplicateEmptyPathNode.children.push(...node.children);
3519
+ mergedNodes.add(duplicateEmptyPathNode);
3520
+ } else {
3521
+ result.push(node);
3522
+ }
3523
+ }
3524
+ for (const mergedNode of mergedNodes) {
3525
+ const mergedChildren = mergeEmptyPathMatches(mergedNode.children);
3526
+ result.push(new TreeNode(mergedNode.value, mergedChildren));
3527
+ }
3528
+ return result.filter(n => !mergedNodes.has(n));
3529
+ }
3530
+ function checkOutletNameUniqueness(nodes) {
3531
+ const names = {};
3532
+ nodes.forEach(n => {
3533
+ const routeWithSameOutletName = names[n.value.outlet];
3534
+ if (routeWithSameOutletName) {
3535
+ const p = routeWithSameOutletName.url.map(s => s.toString()).join('/');
3536
+ const c = n.value.url.map(s => s.toString()).join('/');
3537
+ throw new _RuntimeError(4006, (typeof ngDevMode === 'undefined' || ngDevMode) && `Two segments cannot have the same outlet name: '${p}' and '${c}'.`);
3538
+ }
3539
+ names[n.value.outlet] = n.value;
3540
+ });
3541
+ }
3542
+ function getData(route) {
3543
+ return route.data || {};
3544
+ }
3545
+ function getResolve(route) {
3546
+ return route.resolve || {};
3547
+ }
3548
+
3549
+ const RECOGNIZE_IMPL = new InjectionToken('RECOGNIZE_IMPL', {
3550
+ providedIn: 'root',
3551
+ factory: () => {
3552
+ return recognize$2;
3553
+ }
3554
+ });
3555
+ function provideSometimesSyncRecognize() {
3556
+ return makeEnvironmentProviders([{
3557
+ provide: RECOGNIZE_IMPL,
3558
+ useValue: recognize$1
3559
+ }]);
3560
+ }
3561
+ function recognize(injector, configLoader, rootComponentType, config, serializer, paramsInheritanceStrategy, abortSignal) {
3562
+ const recognizeImpl = injector.get(RECOGNIZE_IMPL);
3563
+ return mergeMap(t => of(t).pipe(switchMap(t => recognizeImpl(injector, configLoader, rootComponentType, config, t.extractedUrl, serializer, paramsInheritanceStrategy, abortSignal)), map(({
3564
+ state: targetSnapshot,
3565
+ tree: urlAfterRedirects
3566
+ }) => {
3567
+ return {
3568
+ ...t,
3569
+ targetSnapshot,
3570
+ urlAfterRedirects
3571
+ };
3572
+ })));
3573
+ }
3574
+
3575
+ function resolveData(paramsInheritanceStrategy, injector) {
3576
+ return mergeMap(t => {
3577
+ const {
3578
+ targetSnapshot,
3579
+ guards: {
3580
+ canActivateChecks
3581
+ }
3582
+ } = t;
3583
+ if (!canActivateChecks.length) {
3584
+ return of(t);
3585
+ }
3586
+ const routesWithResolversToRun = new Set(canActivateChecks.map(check => check.route));
3587
+ const routesNeedingDataUpdates = new Set();
3588
+ for (const route of routesWithResolversToRun) {
3589
+ if (routesNeedingDataUpdates.has(route)) {
3590
+ continue;
3591
+ }
3592
+ for (const newRoute of flattenRouteTree(route)) {
3593
+ routesNeedingDataUpdates.add(newRoute);
3594
+ }
3595
+ }
3596
+ let routesProcessed = 0;
3597
+ return from(routesNeedingDataUpdates).pipe(concatMap(route => {
3598
+ if (routesWithResolversToRun.has(route)) {
3599
+ return runResolve(route, targetSnapshot, paramsInheritanceStrategy, injector);
3600
+ } else {
3601
+ route.data = getInherited(route, route.parent, paramsInheritanceStrategy).resolve;
3602
+ return of(void 0);
3603
+ }
3604
+ }), tap(() => routesProcessed++), takeLast(1), mergeMap(_ => routesProcessed === routesNeedingDataUpdates.size ? of(t) : EMPTY));
3605
+ });
3606
+ }
3607
+ function flattenRouteTree(route) {
3608
+ const descendants = route.children.map(child => flattenRouteTree(child)).flat();
3609
+ return [route, ...descendants];
3610
+ }
3611
+ function runResolve(futureARS, futureRSS, paramsInheritanceStrategy, injector) {
3612
+ const config = futureARS.routeConfig;
3613
+ const resolve = futureARS._resolve;
3614
+ if (config?.title !== undefined && !hasStaticTitle(config)) {
3615
+ resolve[RouteTitleKey] = config.title;
3616
+ }
3617
+ return defer(() => {
3618
+ futureARS.data = getInherited(futureARS, futureARS.parent, paramsInheritanceStrategy).resolve;
3619
+ return resolveNode(resolve, futureARS, futureRSS, injector).pipe(map(resolvedData => {
3620
+ futureARS._resolvedData = resolvedData;
3621
+ futureARS.data = {
3622
+ ...futureARS.data,
3623
+ ...resolvedData
3624
+ };
3625
+ return null;
3626
+ }));
3627
+ });
3628
+ }
3629
+ function resolveNode(resolve, futureARS, futureRSS, injector) {
3630
+ const keys = getDataKeys(resolve);
3631
+ if (keys.length === 0) {
3632
+ return of({});
3633
+ }
3634
+ const data = {};
3635
+ return from(keys).pipe(mergeMap(key => getResolver(resolve[key], futureARS, futureRSS, injector).pipe(first(), tap(value => {
3636
+ if (value instanceof RedirectCommand) {
3637
+ throw redirectingNavigationError(new DefaultUrlSerializer(), value);
3638
+ }
3639
+ data[key] = value;
3640
+ }))), takeLast(1), map(() => data), catchError(e => isEmptyError(e) ? EMPTY : throwError(e)));
3641
+ }
3642
+ function getResolver(injectionToken, futureARS, futureRSS, injector) {
3643
+ const closestInjector = getClosestRouteInjector(futureARS) ?? injector;
3644
+ const resolver = getTokenOrFunctionIdentity(injectionToken, closestInjector);
3645
+ const resolverValue = resolver.resolve ? resolver.resolve(futureARS, futureRSS) : runInInjectionContext(closestInjector, () => resolver(futureARS, futureRSS));
3646
+ return wrapIntoObservable(resolverValue);
3647
+ }
3648
+
3649
+ function switchTap(next) {
3650
+ return switchMap(v => {
3651
+ const nextResult = next(v);
3652
+ if (nextResult) {
3653
+ return from(nextResult).pipe(map(() => v));
3654
+ }
3655
+ return of(v);
3656
+ });
3657
+ }
3658
+
3659
+ class TitleStrategy {
3660
+ buildTitle(snapshot) {
3661
+ let pageTitle;
3662
+ let route = snapshot.root;
3663
+ while (route !== undefined) {
3664
+ pageTitle = this.getResolvedTitleForRoute(route) ?? pageTitle;
3665
+ route = route.children.find(child => child.outlet === PRIMARY_OUTLET);
3666
+ }
3667
+ return pageTitle;
3668
+ }
3669
+ getResolvedTitleForRoute(snapshot) {
3670
+ return snapshot.data[RouteTitleKey];
3671
+ }
3672
+ static ɵfac = i0.ɵɵngDeclareFactory({
3673
+ minVersion: "12.0.0",
3674
+ version: "21.0.0-next.10",
3675
+ ngImport: i0,
3676
+ type: TitleStrategy,
3677
+ deps: [],
3678
+ target: i0.ɵɵFactoryTarget.Injectable
3679
+ });
3680
+ static ɵprov = i0.ɵɵngDeclareInjectable({
3681
+ minVersion: "12.0.0",
3682
+ version: "21.0.0-next.10",
3683
+ ngImport: i0,
3684
+ type: TitleStrategy,
3685
+ providedIn: 'root',
3686
+ useFactory: () => inject(DefaultTitleStrategy)
3687
+ });
3688
+ }
3689
+ i0.ɵɵngDeclareClassMetadata({
3690
+ minVersion: "12.0.0",
3691
+ version: "21.0.0-next.10",
3692
+ ngImport: i0,
3693
+ type: TitleStrategy,
3694
+ decorators: [{
3695
+ type: Injectable,
3696
+ args: [{
3697
+ providedIn: 'root',
3698
+ useFactory: () => inject(DefaultTitleStrategy)
3699
+ }]
3700
+ }]
3701
+ });
3702
+ class DefaultTitleStrategy extends TitleStrategy {
3703
+ title;
3704
+ constructor(title) {
3705
+ super();
3706
+ this.title = title;
3707
+ }
3708
+ updateTitle(snapshot) {
3709
+ const title = this.buildTitle(snapshot);
3710
+ if (title !== undefined) {
3711
+ this.title.setTitle(title);
3712
+ }
3713
+ }
3714
+ static ɵfac = i0.ɵɵngDeclareFactory({
3715
+ minVersion: "12.0.0",
3716
+ version: "21.0.0-next.10",
3717
+ ngImport: i0,
3718
+ type: DefaultTitleStrategy,
3719
+ deps: [{
3720
+ token: i1.Title
3721
+ }],
3722
+ target: i0.ɵɵFactoryTarget.Injectable
3723
+ });
3724
+ static ɵprov = i0.ɵɵngDeclareInjectable({
3725
+ minVersion: "12.0.0",
3726
+ version: "21.0.0-next.10",
3727
+ ngImport: i0,
3728
+ type: DefaultTitleStrategy,
3729
+ providedIn: 'root'
3730
+ });
3731
+ }
3732
+ i0.ɵɵngDeclareClassMetadata({
3733
+ minVersion: "12.0.0",
3734
+ version: "21.0.0-next.10",
3735
+ ngImport: i0,
3736
+ type: DefaultTitleStrategy,
3737
+ decorators: [{
3738
+ type: Injectable,
3739
+ args: [{
3740
+ providedIn: 'root'
3741
+ }]
3742
+ }],
3743
+ ctorParameters: () => [{
3744
+ type: i1.Title
3745
+ }]
3746
+ });
3747
+
3748
+ const ROUTER_CONFIGURATION = new InjectionToken(typeof ngDevMode === 'undefined' || ngDevMode ? 'router config' : '', {
3749
+ providedIn: 'root',
3750
+ factory: () => ({})
3751
+ });
3752
+
3753
+ const ROUTES = new InjectionToken(typeof ngDevMode !== undefined && ngDevMode ? 'ROUTES' : '');
3754
+ class RouterConfigLoader {
3755
+ componentLoaders = new WeakMap();
3756
+ childrenLoaders = new WeakMap();
3757
+ onLoadStartListener;
3758
+ onLoadEndListener;
3759
+ compiler = inject(Compiler);
3760
+ async loadComponent(injector, route) {
3761
+ if (this.componentLoaders.get(route)) {
3762
+ return this.componentLoaders.get(route);
3763
+ } else if (route._loadedComponent) {
3764
+ return Promise.resolve(route._loadedComponent);
3765
+ }
3766
+ if (this.onLoadStartListener) {
3767
+ this.onLoadStartListener(route);
3768
+ }
3769
+ const loader = (async () => {
3770
+ try {
3771
+ const loaded = await wrapIntoPromise(runInInjectionContext(injector, () => route.loadComponent()));
3772
+ const component = await maybeResolveResources(maybeUnwrapDefaultExport(loaded));
3773
+ if (this.onLoadEndListener) {
3774
+ this.onLoadEndListener(route);
3775
+ }
3776
+ (typeof ngDevMode === 'undefined' || ngDevMode) && assertStandalone(route.path ?? '', component);
3777
+ route._loadedComponent = component;
3778
+ return component;
3779
+ } finally {
3780
+ this.componentLoaders.delete(route);
3781
+ }
3782
+ })();
3783
+ this.componentLoaders.set(route, loader);
3784
+ return loader;
3785
+ }
3786
+ loadChildren(parentInjector, route) {
3787
+ if (this.childrenLoaders.get(route)) {
3788
+ return this.childrenLoaders.get(route);
3789
+ } else if (route._loadedRoutes) {
3790
+ return Promise.resolve({
3791
+ routes: route._loadedRoutes,
3792
+ injector: route._loadedInjector
3793
+ });
3794
+ }
3795
+ if (this.onLoadStartListener) {
3796
+ this.onLoadStartListener(route);
3797
+ }
3798
+ const loader = (async () => {
3799
+ try {
3800
+ const result = await loadChildren(route, this.compiler, parentInjector, this.onLoadEndListener);
3801
+ route._loadedRoutes = result.routes;
3802
+ route._loadedInjector = result.injector;
3803
+ return result;
3804
+ } finally {
3805
+ this.childrenLoaders.delete(route);
3806
+ }
3807
+ })();
3808
+ this.childrenLoaders.set(route, loader);
3809
+ return loader;
3810
+ }
3811
+ static ɵfac = i0.ɵɵngDeclareFactory({
3812
+ minVersion: "12.0.0",
3813
+ version: "21.0.0-next.10",
3814
+ ngImport: i0,
3815
+ type: RouterConfigLoader,
3816
+ deps: [],
3817
+ target: i0.ɵɵFactoryTarget.Injectable
3818
+ });
3819
+ static ɵprov = i0.ɵɵngDeclareInjectable({
3820
+ minVersion: "12.0.0",
3821
+ version: "21.0.0-next.10",
3822
+ ngImport: i0,
3823
+ type: RouterConfigLoader,
3824
+ providedIn: 'root'
3825
+ });
3826
+ }
3827
+ i0.ɵɵngDeclareClassMetadata({
3828
+ minVersion: "12.0.0",
3829
+ version: "21.0.0-next.10",
3830
+ ngImport: i0,
3831
+ type: RouterConfigLoader,
3832
+ decorators: [{
3833
+ type: Injectable,
3834
+ args: [{
3835
+ providedIn: 'root'
3836
+ }]
3837
+ }]
3838
+ });
3839
+ async function loadChildren(route, compiler, parentInjector, onLoadEndListener) {
3840
+ const loaded = await wrapIntoPromise(runInInjectionContext(parentInjector, () => route.loadChildren()));
3841
+ const t = await maybeResolveResources(maybeUnwrapDefaultExport(loaded));
3842
+ let factoryOrRoutes;
3843
+ if (t instanceof NgModuleFactory || Array.isArray(t)) {
3844
+ factoryOrRoutes = t;
3845
+ } else {
3846
+ factoryOrRoutes = await compiler.compileModuleAsync(t);
3847
+ }
3848
+ if (onLoadEndListener) {
3849
+ onLoadEndListener(route);
3850
+ }
3851
+ let injector;
3852
+ let rawRoutes;
3853
+ let requireStandaloneComponents = false;
3854
+ if (Array.isArray(factoryOrRoutes)) {
3855
+ rawRoutes = factoryOrRoutes;
3856
+ requireStandaloneComponents = true;
3857
+ } else {
3858
+ injector = factoryOrRoutes.create(parentInjector).injector;
3859
+ rawRoutes = injector.get(ROUTES, [], {
3860
+ optional: true,
3861
+ self: true
3862
+ }).flat();
3863
+ }
3864
+ const routes = rawRoutes.map(standardizeConfig);
3865
+ (typeof ngDevMode === 'undefined' || ngDevMode) && validateConfig(routes, route.path, requireStandaloneComponents);
3866
+ return {
3867
+ routes,
3868
+ injector
3869
+ };
3870
+ }
3871
+ function isWrappedDefaultExport(value) {
3872
+ return value && typeof value === 'object' && 'default' in value;
3873
+ }
3874
+ function maybeUnwrapDefaultExport(input) {
3875
+ return isWrappedDefaultExport(input) ? input['default'] : input;
3876
+ }
3877
+ function maybeResolveResources(value) {
3878
+ if ((typeof ngJitMode === 'undefined' || ngJitMode) && typeof fetch === 'function') {
3879
+ return _resolveComponentResources(fetch).catch(error => {
3880
+ console.error(error);
3881
+ return Promise.resolve();
3882
+ }).then(() => value);
3883
+ }
3884
+ return Promise.resolve(value);
3885
+ }
3886
+
3887
+ class UrlHandlingStrategy {
3888
+ static ɵfac = i0.ɵɵngDeclareFactory({
3889
+ minVersion: "12.0.0",
3890
+ version: "21.0.0-next.10",
3891
+ ngImport: i0,
3892
+ type: UrlHandlingStrategy,
3893
+ deps: [],
3894
+ target: i0.ɵɵFactoryTarget.Injectable
3895
+ });
3896
+ static ɵprov = i0.ɵɵngDeclareInjectable({
3897
+ minVersion: "12.0.0",
3898
+ version: "21.0.0-next.10",
3899
+ ngImport: i0,
3900
+ type: UrlHandlingStrategy,
3901
+ providedIn: 'root',
3902
+ useFactory: () => inject(DefaultUrlHandlingStrategy)
3903
+ });
3904
+ }
3905
+ i0.ɵɵngDeclareClassMetadata({
3906
+ minVersion: "12.0.0",
3907
+ version: "21.0.0-next.10",
3908
+ ngImport: i0,
3909
+ type: UrlHandlingStrategy,
3910
+ decorators: [{
3911
+ type: Injectable,
3912
+ args: [{
3913
+ providedIn: 'root',
3914
+ useFactory: () => inject(DefaultUrlHandlingStrategy)
3915
+ }]
3916
+ }]
3917
+ });
3918
+ class DefaultUrlHandlingStrategy {
3919
+ shouldProcessUrl(url) {
3920
+ return true;
3921
+ }
3922
+ extract(url) {
3923
+ return url;
3924
+ }
3925
+ merge(newUrlPart, wholeUrl) {
3926
+ return newUrlPart;
3927
+ }
3928
+ static ɵfac = i0.ɵɵngDeclareFactory({
3929
+ minVersion: "12.0.0",
3930
+ version: "21.0.0-next.10",
3931
+ ngImport: i0,
3932
+ type: DefaultUrlHandlingStrategy,
3933
+ deps: [],
3934
+ target: i0.ɵɵFactoryTarget.Injectable
3935
+ });
3936
+ static ɵprov = i0.ɵɵngDeclareInjectable({
3937
+ minVersion: "12.0.0",
3938
+ version: "21.0.0-next.10",
3939
+ ngImport: i0,
3940
+ type: DefaultUrlHandlingStrategy,
3941
+ providedIn: 'root'
3942
+ });
3943
+ }
3944
+ i0.ɵɵngDeclareClassMetadata({
3945
+ minVersion: "12.0.0",
3946
+ version: "21.0.0-next.10",
3947
+ ngImport: i0,
3948
+ type: DefaultUrlHandlingStrategy,
3949
+ decorators: [{
3950
+ type: Injectable,
3951
+ args: [{
3952
+ providedIn: 'root'
3953
+ }]
3954
+ }]
3955
+ });
3956
+
3957
+ const CREATE_VIEW_TRANSITION = new InjectionToken(typeof ngDevMode !== undefined && ngDevMode ? 'view transition helper' : '');
3958
+ const VIEW_TRANSITION_OPTIONS = new InjectionToken(typeof ngDevMode !== undefined && ngDevMode ? 'view transition options' : '');
3959
+ function createViewTransition(injector, from, to) {
3960
+ const transitionOptions = injector.get(VIEW_TRANSITION_OPTIONS);
3961
+ const document = injector.get(DOCUMENT);
3962
+ if (!document.startViewTransition || transitionOptions.skipNextTransition) {
3963
+ transitionOptions.skipNextTransition = false;
3964
+ return new Promise(resolve => setTimeout(resolve));
3965
+ }
3966
+ let resolveViewTransitionStarted;
3967
+ const viewTransitionStarted = new Promise(resolve => {
3968
+ resolveViewTransitionStarted = resolve;
3969
+ });
3970
+ const transition = document.startViewTransition(() => {
3971
+ resolveViewTransitionStarted();
3972
+ return createRenderPromise(injector);
3973
+ });
3974
+ transition.ready.catch(error => {
3975
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
3976
+ console.error(error);
3977
+ }
3978
+ });
3979
+ const {
3980
+ onViewTransitionCreated
3981
+ } = transitionOptions;
3982
+ if (onViewTransitionCreated) {
3983
+ runInInjectionContext(injector, () => onViewTransitionCreated({
3984
+ transition,
3985
+ from,
3986
+ to
3987
+ }));
3988
+ }
3989
+ return viewTransitionStarted;
3990
+ }
3991
+ function createRenderPromise(injector) {
3992
+ return new Promise(resolve => {
3993
+ afterNextRender({
3994
+ read: () => setTimeout(resolve)
3995
+ }, {
3996
+ injector
3997
+ });
3998
+ });
3999
+ }
4000
+
4001
+ const noop = () => {};
4002
+ const NAVIGATION_ERROR_HANDLER = new InjectionToken(typeof ngDevMode === 'undefined' || ngDevMode ? 'navigation error handler' : '');
4003
+ class NavigationTransitions {
4004
+ currentNavigation = signal(null, ...(ngDevMode ? [{
4005
+ debugName: "currentNavigation",
4006
+ equal: () => false
4007
+ }] : [{
4008
+ equal: () => false
4009
+ }]));
4010
+ currentTransition = null;
4011
+ lastSuccessfulNavigation = signal(null, ...(ngDevMode ? [{
4012
+ debugName: "lastSuccessfulNavigation"
4013
+ }] : []));
4014
+ events = new Subject();
4015
+ transitionAbortWithErrorSubject = new Subject();
4016
+ configLoader = inject(RouterConfigLoader);
4017
+ environmentInjector = inject(EnvironmentInjector);
4018
+ destroyRef = inject(DestroyRef);
4019
+ urlSerializer = inject(UrlSerializer);
4020
+ rootContexts = inject(ChildrenOutletContexts);
4021
+ location = inject(Location);
4022
+ inputBindingEnabled = inject(INPUT_BINDER, {
4023
+ optional: true
4024
+ }) !== null;
4025
+ titleStrategy = inject(TitleStrategy);
4026
+ options = inject(ROUTER_CONFIGURATION, {
4027
+ optional: true
4028
+ }) || {};
4029
+ paramsInheritanceStrategy = this.options.paramsInheritanceStrategy || 'emptyOnly';
4030
+ urlHandlingStrategy = inject(UrlHandlingStrategy);
4031
+ createViewTransition = inject(CREATE_VIEW_TRANSITION, {
4032
+ optional: true
4033
+ });
4034
+ navigationErrorHandler = inject(NAVIGATION_ERROR_HANDLER, {
4035
+ optional: true
4036
+ });
4037
+ navigationId = 0;
4038
+ get hasRequestedNavigation() {
4039
+ return this.navigationId !== 0;
4040
+ }
4041
+ transitions;
4042
+ afterPreactivation = () => of(void 0);
4043
+ rootComponentType = null;
4044
+ destroyed = false;
4045
+ constructor() {
4046
+ const onLoadStart = r => this.events.next(new RouteConfigLoadStart(r));
4047
+ const onLoadEnd = r => this.events.next(new RouteConfigLoadEnd(r));
4048
+ this.configLoader.onLoadEndListener = onLoadEnd;
4049
+ this.configLoader.onLoadStartListener = onLoadStart;
4050
+ this.destroyRef.onDestroy(() => {
4051
+ this.destroyed = true;
4052
+ });
4053
+ }
4054
+ complete() {
4055
+ this.transitions?.complete();
4056
+ }
4057
+ handleNavigationRequest(request) {
4058
+ const id = ++this.navigationId;
4059
+ untracked(() => {
4060
+ this.transitions?.next({
4061
+ ...request,
4062
+ extractedUrl: this.urlHandlingStrategy.extract(request.rawUrl),
4063
+ targetSnapshot: null,
4064
+ targetRouterState: null,
4065
+ guards: {
4066
+ canActivateChecks: [],
4067
+ canDeactivateChecks: []
4068
+ },
4069
+ guardsResult: null,
4070
+ id
4071
+ });
4072
+ });
4073
+ }
4074
+ setupNavigations(router) {
4075
+ this.transitions = new BehaviorSubject(null);
4076
+ return this.transitions.pipe(filter(t => t !== null), switchMap(overallTransitionState => {
4077
+ let completedOrAborted = false;
4078
+ const abortController = new AbortController();
4079
+ return of(overallTransitionState).pipe(switchMap(t => {
4080
+ if (this.navigationId > overallTransitionState.id) {
4081
+ const cancellationReason = typeof ngDevMode === 'undefined' || ngDevMode ? `Navigation ID ${overallTransitionState.id} is not equal to the current navigation id ${this.navigationId}` : '';
4082
+ this.cancelNavigationTransition(overallTransitionState, cancellationReason, NavigationCancellationCode.SupersededByNewNavigation);
4083
+ return EMPTY;
4084
+ }
4085
+ this.currentTransition = overallTransitionState;
4086
+ const lastSuccessfulNavigation = this.lastSuccessfulNavigation();
4087
+ this.currentNavigation.set({
4088
+ id: t.id,
4089
+ initialUrl: t.rawUrl,
4090
+ extractedUrl: t.extractedUrl,
4091
+ targetBrowserUrl: typeof t.extras.browserUrl === 'string' ? this.urlSerializer.parse(t.extras.browserUrl) : t.extras.browserUrl,
4092
+ trigger: t.source,
4093
+ extras: t.extras,
4094
+ previousNavigation: !lastSuccessfulNavigation ? null : {
4095
+ ...lastSuccessfulNavigation,
4096
+ previousNavigation: null
4097
+ },
4098
+ abort: () => abortController.abort()
4099
+ });
4100
+ const urlTransition = !router.navigated || this.isUpdatingInternalState() || this.isUpdatedBrowserUrl();
4101
+ const onSameUrlNavigation = t.extras.onSameUrlNavigation ?? router.onSameUrlNavigation;
4102
+ if (!urlTransition && onSameUrlNavigation !== 'reload') {
4103
+ const reason = typeof ngDevMode === 'undefined' || ngDevMode ? `Navigation to ${t.rawUrl} was ignored because it is the same as the current Router URL.` : '';
4104
+ this.events.next(new NavigationSkipped(t.id, this.urlSerializer.serialize(t.rawUrl), reason, NavigationSkippedCode.IgnoredSameUrlNavigation));
4105
+ t.resolve(false);
4106
+ return EMPTY;
4107
+ }
4108
+ if (this.urlHandlingStrategy.shouldProcessUrl(t.rawUrl)) {
4109
+ return of(t).pipe(switchMap(t => {
4110
+ this.events.next(new NavigationStart(t.id, this.urlSerializer.serialize(t.extractedUrl), t.source, t.restoredState));
4111
+ if (t.id !== this.navigationId) {
4112
+ return EMPTY;
4113
+ }
4114
+ return Promise.resolve(t);
4115
+ }), recognize(this.environmentInjector, this.configLoader, this.rootComponentType, router.config, this.urlSerializer, this.paramsInheritanceStrategy, abortController.signal), tap(t => {
4116
+ overallTransitionState.targetSnapshot = t.targetSnapshot;
4117
+ overallTransitionState.urlAfterRedirects = t.urlAfterRedirects;
4118
+ this.currentNavigation.update(nav => {
4119
+ nav.finalUrl = t.urlAfterRedirects;
4120
+ return nav;
4121
+ });
4122
+ const routesRecognized = new RoutesRecognized(t.id, this.urlSerializer.serialize(t.extractedUrl), this.urlSerializer.serialize(t.urlAfterRedirects), t.targetSnapshot);
4123
+ this.events.next(routesRecognized);
4124
+ }));
4125
+ } else if (urlTransition && this.urlHandlingStrategy.shouldProcessUrl(t.currentRawUrl)) {
4126
+ const {
4127
+ id,
4128
+ extractedUrl,
4129
+ source,
4130
+ restoredState,
4131
+ extras
4132
+ } = t;
4133
+ const navStart = new NavigationStart(id, this.urlSerializer.serialize(extractedUrl), source, restoredState);
4134
+ this.events.next(navStart);
4135
+ const targetSnapshot = createEmptyState(this.rootComponentType).snapshot;
4136
+ this.currentTransition = overallTransitionState = {
4137
+ ...t,
4138
+ targetSnapshot,
4139
+ urlAfterRedirects: extractedUrl,
4140
+ extras: {
4141
+ ...extras,
4142
+ skipLocationChange: false,
4143
+ replaceUrl: false
4144
+ }
4145
+ };
4146
+ this.currentNavigation.update(nav => {
4147
+ nav.finalUrl = extractedUrl;
4148
+ return nav;
4149
+ });
4150
+ return of(overallTransitionState);
4151
+ } else {
4152
+ const reason = typeof ngDevMode === 'undefined' || ngDevMode ? `Navigation was ignored because the UrlHandlingStrategy` + ` indicated neither the current URL ${t.currentRawUrl} nor target URL ${t.rawUrl} should be processed.` : '';
4153
+ this.events.next(new NavigationSkipped(t.id, this.urlSerializer.serialize(t.extractedUrl), reason, NavigationSkippedCode.IgnoredByUrlHandlingStrategy));
4154
+ t.resolve(false);
4155
+ return EMPTY;
4156
+ }
4157
+ }), tap(t => {
4158
+ const guardsStart = new GuardsCheckStart(t.id, this.urlSerializer.serialize(t.extractedUrl), this.urlSerializer.serialize(t.urlAfterRedirects), t.targetSnapshot);
4159
+ this.events.next(guardsStart);
4160
+ }), map(t => {
4161
+ this.currentTransition = overallTransitionState = {
4162
+ ...t,
4163
+ guards: getAllRouteGuards(t.targetSnapshot, t.currentSnapshot, this.rootContexts)
4164
+ };
4165
+ return overallTransitionState;
4166
+ }), checkGuards(this.environmentInjector, evt => this.events.next(evt)), tap(t => {
4167
+ overallTransitionState.guardsResult = t.guardsResult;
4168
+ if (t.guardsResult && typeof t.guardsResult !== 'boolean') {
4169
+ throw redirectingNavigationError(this.urlSerializer, t.guardsResult);
4170
+ }
4171
+ const guardsEnd = new GuardsCheckEnd(t.id, this.urlSerializer.serialize(t.extractedUrl), this.urlSerializer.serialize(t.urlAfterRedirects), t.targetSnapshot, !!t.guardsResult);
4172
+ this.events.next(guardsEnd);
4173
+ }), filter(t => {
4174
+ if (!t.guardsResult) {
4175
+ this.cancelNavigationTransition(t, '', NavigationCancellationCode.GuardRejected);
4176
+ return false;
4177
+ }
4178
+ return true;
4179
+ }), switchTap(t => {
4180
+ if (t.guards.canActivateChecks.length === 0) {
4181
+ return undefined;
4182
+ }
4183
+ return of(t).pipe(tap(t => {
4184
+ const resolveStart = new ResolveStart(t.id, this.urlSerializer.serialize(t.extractedUrl), this.urlSerializer.serialize(t.urlAfterRedirects), t.targetSnapshot);
4185
+ this.events.next(resolveStart);
4186
+ }), switchMap(t => {
4187
+ let dataResolved = false;
4188
+ return of(t).pipe(resolveData(this.paramsInheritanceStrategy, this.environmentInjector), tap({
4189
+ next: () => dataResolved = true,
4190
+ complete: () => {
4191
+ if (!dataResolved) {
4192
+ this.cancelNavigationTransition(t, typeof ngDevMode === 'undefined' || ngDevMode ? `At least one route resolver didn't emit any value.` : '', NavigationCancellationCode.NoDataFromResolver);
4193
+ }
4194
+ }
4195
+ }));
4196
+ }), tap(t => {
4197
+ const resolveEnd = new ResolveEnd(t.id, this.urlSerializer.serialize(t.extractedUrl), this.urlSerializer.serialize(t.urlAfterRedirects), t.targetSnapshot);
4198
+ this.events.next(resolveEnd);
4199
+ }));
4200
+ }), switchTap(t => {
4201
+ const loadComponents = route => {
4202
+ const loaders = [];
4203
+ if (route.routeConfig?._loadedComponent) {
4204
+ route.component = route.routeConfig?._loadedComponent;
4205
+ } else if (route.routeConfig?.loadComponent) {
4206
+ const injector = getClosestRouteInjector(route) ?? this.environmentInjector;
4207
+ loaders.push(this.configLoader.loadComponent(injector, route.routeConfig).then(loadedComponent => {
4208
+ route.component = loadedComponent;
4209
+ }));
4210
+ }
4211
+ for (const child of route.children) {
4212
+ loaders.push(...loadComponents(child));
4213
+ }
4214
+ return loaders;
4215
+ };
4216
+ const loaders = loadComponents(t.targetSnapshot.root);
4217
+ return loaders.length === 0 ? of(t) : from(Promise.all(loaders).then(() => t));
4218
+ }), switchTap(() => this.afterPreactivation()), switchMap(() => {
4219
+ const {
4220
+ currentSnapshot,
4221
+ targetSnapshot
4222
+ } = overallTransitionState;
4223
+ const viewTransitionStarted = this.createViewTransition?.(this.environmentInjector, currentSnapshot.root, targetSnapshot.root);
4224
+ return viewTransitionStarted ? from(viewTransitionStarted).pipe(map(() => overallTransitionState)) : of(overallTransitionState);
4225
+ }), map(t => {
4226
+ const targetRouterState = createRouterState(router.routeReuseStrategy, t.targetSnapshot, t.currentRouterState);
4227
+ this.currentTransition = overallTransitionState = {
4228
+ ...t,
4229
+ targetRouterState
4230
+ };
4231
+ this.currentNavigation.update(nav => {
4232
+ nav.targetRouterState = targetRouterState;
4233
+ return nav;
4234
+ });
4235
+ return overallTransitionState;
4236
+ }), tap(() => {
4237
+ this.events.next(new BeforeActivateRoutes());
4238
+ }), activateRoutes(this.rootContexts, router.routeReuseStrategy, evt => this.events.next(evt), this.inputBindingEnabled), take(1), takeUntil(abortSignalToObservable(abortController.signal).pipe(filter(() => !completedOrAborted && !overallTransitionState.targetRouterState), tap(() => {
4239
+ this.cancelNavigationTransition(overallTransitionState, abortController.signal.reason + '', NavigationCancellationCode.Aborted);
4240
+ }))), tap({
4241
+ next: t => {
4242
+ completedOrAborted = true;
4243
+ this.currentNavigation.update(nav => {
4244
+ nav.abort = noop;
4245
+ return nav;
4246
+ });
4247
+ this.lastSuccessfulNavigation.set(untracked(this.currentNavigation));
4248
+ this.events.next(new NavigationEnd(t.id, this.urlSerializer.serialize(t.extractedUrl), this.urlSerializer.serialize(t.urlAfterRedirects)));
4249
+ this.titleStrategy?.updateTitle(t.targetRouterState.snapshot);
4250
+ t.resolve(true);
4251
+ },
4252
+ complete: () => {
4253
+ completedOrAborted = true;
4254
+ }
4255
+ }), takeUntil(this.transitionAbortWithErrorSubject.pipe(tap(err => {
4256
+ throw err;
4257
+ }))), finalize(() => {
4258
+ abortController.abort();
4259
+ if (!completedOrAborted) {
4260
+ const cancelationReason = typeof ngDevMode === 'undefined' || ngDevMode ? `Navigation ID ${overallTransitionState.id} is not equal to the current navigation id ${this.navigationId}` : '';
4261
+ this.cancelNavigationTransition(overallTransitionState, cancelationReason, NavigationCancellationCode.SupersededByNewNavigation);
4262
+ }
4263
+ if (this.currentTransition?.id === overallTransitionState.id) {
4264
+ this.currentNavigation.set(null);
4265
+ this.currentTransition = null;
4266
+ }
4267
+ }), catchError(e => {
4268
+ if (this.destroyed) {
4269
+ overallTransitionState.resolve(false);
4270
+ return EMPTY;
4271
+ }
4272
+ completedOrAborted = true;
4273
+ if (isNavigationCancelingError(e)) {
4274
+ this.events.next(new NavigationCancel(overallTransitionState.id, this.urlSerializer.serialize(overallTransitionState.extractedUrl), e.message, e.cancellationCode));
4275
+ if (!isRedirectingNavigationCancelingError(e)) {
4276
+ overallTransitionState.resolve(false);
4277
+ } else {
4278
+ this.events.next(new RedirectRequest(e.url, e.navigationBehaviorOptions));
4279
+ }
4280
+ } else {
4281
+ const navigationError = new NavigationError(overallTransitionState.id, this.urlSerializer.serialize(overallTransitionState.extractedUrl), e, overallTransitionState.targetSnapshot ?? undefined);
4282
+ try {
4283
+ const navigationErrorHandlerResult = runInInjectionContext(this.environmentInjector, () => this.navigationErrorHandler?.(navigationError));
4284
+ if (navigationErrorHandlerResult instanceof RedirectCommand) {
4285
+ const {
4286
+ message,
4287
+ cancellationCode
4288
+ } = redirectingNavigationError(this.urlSerializer, navigationErrorHandlerResult);
4289
+ this.events.next(new NavigationCancel(overallTransitionState.id, this.urlSerializer.serialize(overallTransitionState.extractedUrl), message, cancellationCode));
4290
+ this.events.next(new RedirectRequest(navigationErrorHandlerResult.redirectTo, navigationErrorHandlerResult.navigationBehaviorOptions));
4291
+ } else {
4292
+ this.events.next(navigationError);
4293
+ throw e;
4294
+ }
4295
+ } catch (ee) {
4296
+ if (this.options.resolveNavigationPromiseOnError) {
4297
+ overallTransitionState.resolve(false);
4298
+ } else {
4299
+ overallTransitionState.reject(ee);
4300
+ }
4301
+ }
4302
+ }
4303
+ return EMPTY;
4304
+ }));
4305
+ }));
4306
+ }
4307
+ cancelNavigationTransition(t, reason, code) {
4308
+ const navCancel = new NavigationCancel(t.id, this.urlSerializer.serialize(t.extractedUrl), reason, code);
4309
+ this.events.next(navCancel);
4310
+ t.resolve(false);
4311
+ }
4312
+ isUpdatingInternalState() {
4313
+ return this.currentTransition?.extractedUrl.toString() !== this.currentTransition?.currentUrlTree.toString();
4314
+ }
4315
+ isUpdatedBrowserUrl() {
4316
+ const currentBrowserUrl = this.urlHandlingStrategy.extract(this.urlSerializer.parse(this.location.path(true)));
4317
+ const currentNavigation = untracked(this.currentNavigation);
4318
+ const targetBrowserUrl = currentNavigation?.targetBrowserUrl ?? currentNavigation?.extractedUrl;
4319
+ return currentBrowserUrl.toString() !== targetBrowserUrl?.toString() && !currentNavigation?.extras.skipLocationChange;
4320
+ }
4321
+ static ɵfac = i0.ɵɵngDeclareFactory({
4322
+ minVersion: "12.0.0",
4323
+ version: "21.0.0-next.10",
4324
+ ngImport: i0,
4325
+ type: NavigationTransitions,
4326
+ deps: [],
4327
+ target: i0.ɵɵFactoryTarget.Injectable
4328
+ });
4329
+ static ɵprov = i0.ɵɵngDeclareInjectable({
4330
+ minVersion: "12.0.0",
4331
+ version: "21.0.0-next.10",
4332
+ ngImport: i0,
4333
+ type: NavigationTransitions,
4334
+ providedIn: 'root'
4335
+ });
4336
+ }
4337
+ i0.ɵɵngDeclareClassMetadata({
4338
+ minVersion: "12.0.0",
4339
+ version: "21.0.0-next.10",
4340
+ ngImport: i0,
4341
+ type: NavigationTransitions,
4342
+ decorators: [{
4343
+ type: Injectable,
4344
+ args: [{
4345
+ providedIn: 'root'
4346
+ }]
4347
+ }],
4348
+ ctorParameters: () => []
4349
+ });
4350
+ function isBrowserTriggeredNavigation(source) {
4351
+ return source !== IMPERATIVE_NAVIGATION;
4352
+ }
4353
+
4354
+ class RouteReuseStrategy {
4355
+ static ɵfac = i0.ɵɵngDeclareFactory({
4356
+ minVersion: "12.0.0",
4357
+ version: "21.0.0-next.10",
4358
+ ngImport: i0,
4359
+ type: RouteReuseStrategy,
4360
+ deps: [],
4361
+ target: i0.ɵɵFactoryTarget.Injectable
4362
+ });
4363
+ static ɵprov = i0.ɵɵngDeclareInjectable({
4364
+ minVersion: "12.0.0",
4365
+ version: "21.0.0-next.10",
4366
+ ngImport: i0,
4367
+ type: RouteReuseStrategy,
4368
+ providedIn: 'root',
4369
+ useFactory: () => inject(DefaultRouteReuseStrategy)
4370
+ });
4371
+ }
4372
+ i0.ɵɵngDeclareClassMetadata({
4373
+ minVersion: "12.0.0",
4374
+ version: "21.0.0-next.10",
4375
+ ngImport: i0,
4376
+ type: RouteReuseStrategy,
4377
+ decorators: [{
4378
+ type: Injectable,
4379
+ args: [{
4380
+ providedIn: 'root',
4381
+ useFactory: () => inject(DefaultRouteReuseStrategy)
4382
+ }]
4383
+ }]
4384
+ });
4385
+ class BaseRouteReuseStrategy {
4386
+ shouldDetach(route) {
4387
+ return false;
4388
+ }
4389
+ store(route, detachedTree) {}
4390
+ shouldAttach(route) {
4391
+ return false;
4392
+ }
4393
+ retrieve(route) {
4394
+ return null;
4395
+ }
4396
+ shouldReuseRoute(future, curr) {
4397
+ return future.routeConfig === curr.routeConfig;
4398
+ }
4399
+ }
4400
+ class DefaultRouteReuseStrategy extends BaseRouteReuseStrategy {
4401
+ static ɵfac = i0.ɵɵngDeclareFactory({
4402
+ minVersion: "12.0.0",
4403
+ version: "21.0.0-next.10",
4404
+ ngImport: i0,
4405
+ type: DefaultRouteReuseStrategy,
4406
+ deps: null,
4407
+ target: i0.ɵɵFactoryTarget.Injectable
4408
+ });
4409
+ static ɵprov = i0.ɵɵngDeclareInjectable({
4410
+ minVersion: "12.0.0",
4411
+ version: "21.0.0-next.10",
4412
+ ngImport: i0,
4413
+ type: DefaultRouteReuseStrategy,
4414
+ providedIn: 'root'
4415
+ });
4416
+ }
4417
+ i0.ɵɵngDeclareClassMetadata({
4418
+ minVersion: "12.0.0",
4419
+ version: "21.0.0-next.10",
4420
+ ngImport: i0,
4421
+ type: DefaultRouteReuseStrategy,
4422
+ decorators: [{
4423
+ type: Injectable,
4424
+ args: [{
4425
+ providedIn: 'root'
4426
+ }]
4427
+ }]
4428
+ });
4429
+
4430
+ class StateManager {
4431
+ urlSerializer = inject(UrlSerializer);
4432
+ options = inject(ROUTER_CONFIGURATION, {
4433
+ optional: true
4434
+ }) || {};
4435
+ canceledNavigationResolution = this.options.canceledNavigationResolution || 'replace';
4436
+ location = inject(Location);
4437
+ urlHandlingStrategy = inject(UrlHandlingStrategy);
4438
+ urlUpdateStrategy = this.options.urlUpdateStrategy || 'deferred';
4439
+ currentUrlTree = new UrlTree();
4440
+ getCurrentUrlTree() {
4441
+ return this.currentUrlTree;
4442
+ }
4443
+ rawUrlTree = this.currentUrlTree;
4444
+ getRawUrlTree() {
4445
+ return this.rawUrlTree;
4446
+ }
4447
+ createBrowserPath({
4448
+ finalUrl,
4449
+ initialUrl,
4450
+ targetBrowserUrl
4451
+ }) {
4452
+ const rawUrl = finalUrl !== undefined ? this.urlHandlingStrategy.merge(finalUrl, initialUrl) : initialUrl;
4453
+ const url = targetBrowserUrl ?? rawUrl;
4454
+ const path = url instanceof UrlTree ? this.urlSerializer.serialize(url) : url;
4455
+ return path;
4456
+ }
4457
+ commitTransition({
4458
+ targetRouterState,
4459
+ finalUrl,
4460
+ initialUrl
4461
+ }) {
4462
+ if (finalUrl && targetRouterState) {
4463
+ this.currentUrlTree = finalUrl;
4464
+ this.rawUrlTree = this.urlHandlingStrategy.merge(finalUrl, initialUrl);
4465
+ this.routerState = targetRouterState;
4466
+ } else {
4467
+ this.rawUrlTree = initialUrl;
4468
+ }
4469
+ }
4470
+ routerState = createEmptyState(null);
4471
+ getRouterState() {
4472
+ return this.routerState;
4473
+ }
4474
+ stateMemento = this.createStateMemento();
4475
+ updateStateMemento() {
4476
+ this.stateMemento = this.createStateMemento();
4477
+ }
4478
+ createStateMemento() {
4479
+ return {
4480
+ rawUrlTree: this.rawUrlTree,
4481
+ currentUrlTree: this.currentUrlTree,
4482
+ routerState: this.routerState
4483
+ };
4484
+ }
4485
+ resetInternalState({
4486
+ finalUrl
4487
+ }) {
4488
+ this.routerState = this.stateMemento.routerState;
4489
+ this.currentUrlTree = this.stateMemento.currentUrlTree;
4490
+ this.rawUrlTree = this.urlHandlingStrategy.merge(this.currentUrlTree, finalUrl ?? this.rawUrlTree);
4491
+ }
4492
+ static ɵfac = i0.ɵɵngDeclareFactory({
4493
+ minVersion: "12.0.0",
4494
+ version: "21.0.0-next.10",
4495
+ ngImport: i0,
4496
+ type: StateManager,
4497
+ deps: [],
4498
+ target: i0.ɵɵFactoryTarget.Injectable
4499
+ });
4500
+ static ɵprov = i0.ɵɵngDeclareInjectable({
4501
+ minVersion: "12.0.0",
4502
+ version: "21.0.0-next.10",
4503
+ ngImport: i0,
4504
+ type: StateManager,
4505
+ providedIn: 'root',
4506
+ useFactory: () => inject(HistoryStateManager)
4507
+ });
4508
+ }
4509
+ i0.ɵɵngDeclareClassMetadata({
4510
+ minVersion: "12.0.0",
4511
+ version: "21.0.0-next.10",
4512
+ ngImport: i0,
4513
+ type: StateManager,
4514
+ decorators: [{
4515
+ type: Injectable,
4516
+ args: [{
4517
+ providedIn: 'root',
4518
+ useFactory: () => inject(HistoryStateManager)
4519
+ }]
4520
+ }]
4521
+ });
4522
+ class HistoryStateManager extends StateManager {
4523
+ currentPageId = 0;
4524
+ lastSuccessfulId = -1;
4525
+ restoredState() {
4526
+ return this.location.getState();
4527
+ }
4528
+ get browserPageId() {
4529
+ if (this.canceledNavigationResolution !== 'computed') {
4530
+ return this.currentPageId;
4531
+ }
4532
+ return this.restoredState()?.ɵrouterPageId ?? this.currentPageId;
4533
+ }
4534
+ registerNonRouterCurrentEntryChangeListener(listener) {
4535
+ return this.location.subscribe(event => {
4536
+ if (event['type'] === 'popstate') {
4537
+ setTimeout(() => {
4538
+ listener(event['url'], event.state, 'popstate');
4539
+ });
4540
+ }
4541
+ });
4542
+ }
4543
+ handleRouterEvent(e, currentTransition) {
4544
+ if (e instanceof NavigationStart) {
4545
+ this.updateStateMemento();
4546
+ } else if (e instanceof NavigationSkipped) {
4547
+ this.commitTransition(currentTransition);
4548
+ } else if (e instanceof RoutesRecognized) {
4549
+ if (this.urlUpdateStrategy === 'eager') {
4550
+ if (!currentTransition.extras.skipLocationChange) {
4551
+ this.setBrowserUrl(this.createBrowserPath(currentTransition), currentTransition);
4552
+ }
4553
+ }
4554
+ } else if (e instanceof BeforeActivateRoutes) {
4555
+ this.commitTransition(currentTransition);
4556
+ if (this.urlUpdateStrategy === 'deferred' && !currentTransition.extras.skipLocationChange) {
4557
+ this.setBrowserUrl(this.createBrowserPath(currentTransition), currentTransition);
4558
+ }
4559
+ } else if (e instanceof NavigationCancel && e.code !== NavigationCancellationCode.SupersededByNewNavigation && e.code !== NavigationCancellationCode.Redirect) {
4560
+ this.restoreHistory(currentTransition);
4561
+ } else if (e instanceof NavigationError) {
4562
+ this.restoreHistory(currentTransition, true);
4563
+ } else if (e instanceof NavigationEnd) {
4564
+ this.lastSuccessfulId = e.id;
4565
+ this.currentPageId = this.browserPageId;
4566
+ }
4567
+ }
4568
+ setBrowserUrl(path, {
4569
+ extras,
4570
+ id
4571
+ }) {
4572
+ const {
4573
+ replaceUrl,
4574
+ state
4575
+ } = extras;
4576
+ if (this.location.isCurrentPathEqualTo(path) || !!replaceUrl) {
4577
+ const currentBrowserPageId = this.browserPageId;
4578
+ const newState = {
4579
+ ...state,
4580
+ ...this.generateNgRouterState(id, currentBrowserPageId)
4581
+ };
4582
+ this.location.replaceState(path, '', newState);
4583
+ } else {
4584
+ const newState = {
4585
+ ...state,
4586
+ ...this.generateNgRouterState(id, this.browserPageId + 1)
4587
+ };
4588
+ this.location.go(path, '', newState);
4589
+ }
4590
+ }
4591
+ restoreHistory(navigation, restoringFromCaughtError = false) {
4592
+ if (this.canceledNavigationResolution === 'computed') {
4593
+ const currentBrowserPageId = this.browserPageId;
4594
+ const targetPagePosition = this.currentPageId - currentBrowserPageId;
4595
+ if (targetPagePosition !== 0) {
4596
+ this.location.historyGo(targetPagePosition);
4597
+ } else if (this.getCurrentUrlTree() === navigation.finalUrl && targetPagePosition === 0) {
4598
+ this.resetInternalState(navigation);
4599
+ this.resetUrlToCurrentUrlTree();
4600
+ } else ;
4601
+ } else if (this.canceledNavigationResolution === 'replace') {
4602
+ if (restoringFromCaughtError) {
4603
+ this.resetInternalState(navigation);
4604
+ }
4605
+ this.resetUrlToCurrentUrlTree();
4606
+ }
4607
+ }
4608
+ resetUrlToCurrentUrlTree() {
4609
+ this.location.replaceState(this.urlSerializer.serialize(this.getRawUrlTree()), '', this.generateNgRouterState(this.lastSuccessfulId, this.currentPageId));
4610
+ }
4611
+ generateNgRouterState(navigationId, routerPageId) {
4612
+ if (this.canceledNavigationResolution === 'computed') {
4613
+ return {
4614
+ navigationId,
4615
+ ɵrouterPageId: routerPageId
4616
+ };
4617
+ }
4618
+ return {
4619
+ navigationId
4620
+ };
4621
+ }
4622
+ static ɵfac = i0.ɵɵngDeclareFactory({
4623
+ minVersion: "12.0.0",
4624
+ version: "21.0.0-next.10",
4625
+ ngImport: i0,
4626
+ type: HistoryStateManager,
4627
+ deps: null,
4628
+ target: i0.ɵɵFactoryTarget.Injectable
4629
+ });
4630
+ static ɵprov = i0.ɵɵngDeclareInjectable({
4631
+ minVersion: "12.0.0",
4632
+ version: "21.0.0-next.10",
4633
+ ngImport: i0,
4634
+ type: HistoryStateManager,
4635
+ providedIn: 'root'
4636
+ });
4637
+ }
4638
+ i0.ɵɵngDeclareClassMetadata({
4639
+ minVersion: "12.0.0",
4640
+ version: "21.0.0-next.10",
4641
+ ngImport: i0,
4642
+ type: HistoryStateManager,
4643
+ decorators: [{
4644
+ type: Injectable,
4645
+ args: [{
4646
+ providedIn: 'root'
4647
+ }]
4648
+ }]
4649
+ });
4650
+
4651
+ function afterNextNavigation(router, action) {
4652
+ router.events.pipe(filter(e => e instanceof NavigationEnd || e instanceof NavigationCancel || e instanceof NavigationError || e instanceof NavigationSkipped), map(e => {
4653
+ if (e instanceof NavigationEnd || e instanceof NavigationSkipped) {
4654
+ return 0;
4655
+ }
4656
+ const redirecting = e instanceof NavigationCancel ? e.code === NavigationCancellationCode.Redirect || e.code === NavigationCancellationCode.SupersededByNewNavigation : false;
4657
+ return redirecting ? 2 : 1;
4658
+ }), filter(result => result !== 2), take(1)).subscribe(() => {
4659
+ action();
4660
+ });
4661
+ }
4662
+
4663
+ const exactMatchOptions = {
4664
+ paths: 'exact',
4665
+ fragment: 'ignored',
4666
+ matrixParams: 'ignored',
4667
+ queryParams: 'exact'
4668
+ };
4669
+ const subsetMatchOptions = {
4670
+ paths: 'subset',
4671
+ fragment: 'ignored',
4672
+ matrixParams: 'ignored',
4673
+ queryParams: 'subset'
4674
+ };
4675
+ class Router {
4676
+ get currentUrlTree() {
4677
+ return this.stateManager.getCurrentUrlTree();
4678
+ }
4679
+ get rawUrlTree() {
4680
+ return this.stateManager.getRawUrlTree();
4681
+ }
4682
+ disposed = false;
4683
+ nonRouterCurrentEntryChangeSubscription;
4684
+ console = inject(_Console);
4685
+ stateManager = inject(StateManager);
4686
+ options = inject(ROUTER_CONFIGURATION, {
4687
+ optional: true
4688
+ }) || {};
4689
+ pendingTasks = inject(_PendingTasksInternal);
4690
+ urlUpdateStrategy = this.options.urlUpdateStrategy || 'deferred';
4691
+ navigationTransitions = inject(NavigationTransitions);
4692
+ urlSerializer = inject(UrlSerializer);
4693
+ location = inject(Location);
4694
+ urlHandlingStrategy = inject(UrlHandlingStrategy);
4695
+ injector = inject(EnvironmentInjector);
4696
+ _events = new Subject();
4697
+ get events() {
4698
+ return this._events;
4699
+ }
4700
+ get routerState() {
4701
+ return this.stateManager.getRouterState();
4702
+ }
4703
+ navigated = false;
4704
+ routeReuseStrategy = inject(RouteReuseStrategy);
4705
+ onSameUrlNavigation = this.options.onSameUrlNavigation || 'ignore';
4706
+ config = inject(ROUTES, {
4707
+ optional: true
4708
+ })?.flat() ?? [];
4709
+ componentInputBindingEnabled = !!inject(INPUT_BINDER, {
4710
+ optional: true
4711
+ });
4712
+ currentNavigation = this.navigationTransitions.currentNavigation.asReadonly();
4713
+ constructor() {
4714
+ this.resetConfig(this.config);
4715
+ this.navigationTransitions.setupNavigations(this).subscribe({
4716
+ error: e => {
4717
+ this.console.warn(ngDevMode ? `Unhandled Navigation Error: ${e}` : e);
4718
+ }
4719
+ });
4720
+ this.subscribeToNavigationEvents();
4721
+ }
4722
+ eventsSubscription = new Subscription();
4723
+ subscribeToNavigationEvents() {
4724
+ const subscription = this.navigationTransitions.events.subscribe(e => {
4725
+ try {
4726
+ const currentTransition = this.navigationTransitions.currentTransition;
4727
+ const currentNavigation = untracked(this.navigationTransitions.currentNavigation);
4728
+ if (currentTransition !== null && currentNavigation !== null) {
4729
+ this.stateManager.handleRouterEvent(e, currentNavigation);
4730
+ if (e instanceof NavigationCancel && e.code !== NavigationCancellationCode.Redirect && e.code !== NavigationCancellationCode.SupersededByNewNavigation) {
4731
+ this.navigated = true;
4732
+ } else if (e instanceof NavigationEnd) {
4733
+ this.navigated = true;
4734
+ } else if (e instanceof RedirectRequest) {
4735
+ const opts = e.navigationBehaviorOptions;
4736
+ const mergedTree = this.urlHandlingStrategy.merge(e.url, currentTransition.currentRawUrl);
4737
+ const extras = {
4738
+ browserUrl: currentTransition.extras.browserUrl,
4739
+ info: currentTransition.extras.info,
4740
+ skipLocationChange: currentTransition.extras.skipLocationChange,
4741
+ replaceUrl: currentTransition.extras.replaceUrl || this.urlUpdateStrategy === 'eager' || isBrowserTriggeredNavigation(currentTransition.source),
4742
+ ...opts
4743
+ };
4744
+ this.scheduleNavigation(mergedTree, IMPERATIVE_NAVIGATION, null, extras, {
4745
+ resolve: currentTransition.resolve,
4746
+ reject: currentTransition.reject,
4747
+ promise: currentTransition.promise
4748
+ });
4749
+ }
4750
+ }
4751
+ if (isPublicRouterEvent(e)) {
4752
+ this._events.next(e);
4753
+ }
4754
+ } catch (e) {
4755
+ this.navigationTransitions.transitionAbortWithErrorSubject.next(e);
4756
+ }
4757
+ });
4758
+ this.eventsSubscription.add(subscription);
4759
+ }
4760
+ resetRootComponentType(rootComponentType) {
4761
+ this.routerState.root.component = rootComponentType;
4762
+ this.navigationTransitions.rootComponentType = rootComponentType;
4763
+ }
4764
+ initialNavigation() {
4765
+ this.setUpLocationChangeListener();
4766
+ if (!this.navigationTransitions.hasRequestedNavigation) {
4767
+ this.navigateToSyncWithBrowser(this.location.path(true), IMPERATIVE_NAVIGATION, this.stateManager.restoredState());
4768
+ }
4769
+ }
4770
+ setUpLocationChangeListener() {
4771
+ this.nonRouterCurrentEntryChangeSubscription ??= this.stateManager.registerNonRouterCurrentEntryChangeListener((url, state, source) => {
4772
+ this.navigateToSyncWithBrowser(url, source, state);
4773
+ });
4774
+ }
4775
+ navigateToSyncWithBrowser(url, source, state) {
4776
+ const extras = {
4777
+ replaceUrl: true
4778
+ };
4779
+ const restoredState = state?.navigationId ? state : null;
4780
+ if (state) {
4781
+ const stateCopy = {
4782
+ ...state
4783
+ };
4784
+ delete stateCopy.navigationId;
4785
+ delete stateCopy.ɵrouterPageId;
4786
+ if (Object.keys(stateCopy).length !== 0) {
4787
+ extras.state = stateCopy;
4788
+ }
4789
+ }
4790
+ const urlTree = this.parseUrl(url);
4791
+ this.scheduleNavigation(urlTree, source, restoredState, extras).catch(e => {
4792
+ if (this.disposed) {
4793
+ return;
4794
+ }
4795
+ this.injector.get(_INTERNAL_APPLICATION_ERROR_HANDLER)(e);
4796
+ });
4797
+ }
4798
+ get url() {
4799
+ return this.serializeUrl(this.currentUrlTree);
4800
+ }
4801
+ getCurrentNavigation() {
4802
+ return untracked(this.navigationTransitions.currentNavigation);
4803
+ }
4804
+ get lastSuccessfulNavigation() {
4805
+ return this.navigationTransitions.lastSuccessfulNavigation;
4806
+ }
4807
+ resetConfig(config) {
4808
+ (typeof ngDevMode === 'undefined' || ngDevMode) && validateConfig(config);
4809
+ this.config = config.map(standardizeConfig);
4810
+ this.navigated = false;
4811
+ }
4812
+ ngOnDestroy() {
4813
+ this.dispose();
4814
+ }
4815
+ dispose() {
4816
+ this._events.unsubscribe();
4817
+ this.navigationTransitions.complete();
4818
+ if (this.nonRouterCurrentEntryChangeSubscription) {
4819
+ this.nonRouterCurrentEntryChangeSubscription.unsubscribe();
4820
+ this.nonRouterCurrentEntryChangeSubscription = undefined;
4821
+ }
4822
+ this.disposed = true;
4823
+ this.eventsSubscription.unsubscribe();
4824
+ }
4825
+ createUrlTree(commands, navigationExtras = {}) {
4826
+ const {
4827
+ relativeTo,
4828
+ queryParams,
4829
+ fragment,
4830
+ queryParamsHandling,
4831
+ preserveFragment
4832
+ } = navigationExtras;
4833
+ const f = preserveFragment ? this.currentUrlTree.fragment : fragment;
4834
+ let q = null;
4835
+ switch (queryParamsHandling ?? this.options.defaultQueryParamsHandling) {
4836
+ case 'merge':
4837
+ q = {
4838
+ ...this.currentUrlTree.queryParams,
4839
+ ...queryParams
4840
+ };
4841
+ break;
4842
+ case 'preserve':
4843
+ q = this.currentUrlTree.queryParams;
4844
+ break;
4845
+ default:
4846
+ q = queryParams || null;
4847
+ }
4848
+ if (q !== null) {
4849
+ q = this.removeEmptyProps(q);
4850
+ }
4851
+ let relativeToUrlSegmentGroup;
4852
+ try {
4853
+ const relativeToSnapshot = relativeTo ? relativeTo.snapshot : this.routerState.snapshot.root;
4854
+ relativeToUrlSegmentGroup = createSegmentGroupFromRoute(relativeToSnapshot);
4855
+ } catch (e) {
4856
+ if (typeof commands[0] !== 'string' || commands[0][0] !== '/') {
4857
+ commands = [];
4858
+ }
4859
+ relativeToUrlSegmentGroup = this.currentUrlTree.root;
4860
+ }
4861
+ return createUrlTreeFromSegmentGroup(relativeToUrlSegmentGroup, commands, q, f ?? null, this.urlSerializer);
4862
+ }
4863
+ navigateByUrl(url, extras = {
4864
+ skipLocationChange: false
4865
+ }) {
4866
+ const urlTree = isUrlTree(url) ? url : this.parseUrl(url);
4867
+ const mergedTree = this.urlHandlingStrategy.merge(urlTree, this.rawUrlTree);
4868
+ return this.scheduleNavigation(mergedTree, IMPERATIVE_NAVIGATION, null, extras);
4869
+ }
4870
+ navigate(commands, extras = {
4871
+ skipLocationChange: false
4872
+ }) {
4873
+ validateCommands(commands);
4874
+ return this.navigateByUrl(this.createUrlTree(commands, extras), extras);
4875
+ }
4876
+ serializeUrl(url) {
4877
+ return this.urlSerializer.serialize(url);
4878
+ }
4879
+ parseUrl(url) {
4880
+ try {
4881
+ return this.urlSerializer.parse(url);
4882
+ } catch (e) {
4883
+ this.console.warn(_formatRuntimeError(4018, ngDevMode && `Error parsing URL ${url}. Falling back to '/' instead. \n` + e));
4884
+ return this.urlSerializer.parse('/');
4885
+ }
4886
+ }
4887
+ isActive(url, matchOptions) {
4888
+ let options;
4889
+ if (matchOptions === true) {
4890
+ options = {
4891
+ ...exactMatchOptions
4892
+ };
4893
+ } else if (matchOptions === false) {
4894
+ options = {
4895
+ ...subsetMatchOptions
4896
+ };
4897
+ } else {
4898
+ options = matchOptions;
4899
+ }
4900
+ if (isUrlTree(url)) {
4901
+ return containsTree(this.currentUrlTree, url, options);
4902
+ }
4903
+ const urlTree = this.parseUrl(url);
4904
+ return containsTree(this.currentUrlTree, urlTree, options);
4905
+ }
4906
+ removeEmptyProps(params) {
4907
+ return Object.entries(params).reduce((result, [key, value]) => {
4908
+ if (value !== null && value !== undefined) {
4909
+ result[key] = value;
4910
+ }
4911
+ return result;
4912
+ }, {});
4913
+ }
4914
+ scheduleNavigation(rawUrl, source, restoredState, extras, priorPromise) {
4915
+ if (this.disposed) {
4916
+ return Promise.resolve(false);
4917
+ }
4918
+ let resolve;
4919
+ let reject;
4920
+ let promise;
4921
+ if (priorPromise) {
4922
+ resolve = priorPromise.resolve;
4923
+ reject = priorPromise.reject;
4924
+ promise = priorPromise.promise;
4925
+ } else {
4926
+ promise = new Promise((res, rej) => {
4927
+ resolve = res;
4928
+ reject = rej;
4929
+ });
4930
+ }
4931
+ const taskId = this.pendingTasks.add();
4932
+ afterNextNavigation(this, () => {
4933
+ queueMicrotask(() => this.pendingTasks.remove(taskId));
4934
+ });
4935
+ this.navigationTransitions.handleNavigationRequest({
4936
+ source,
4937
+ restoredState,
4938
+ currentUrlTree: this.currentUrlTree,
4939
+ currentRawUrl: this.currentUrlTree,
4940
+ rawUrl,
4941
+ extras,
4942
+ resolve: resolve,
4943
+ reject: reject,
4944
+ promise,
4945
+ currentSnapshot: this.routerState.snapshot,
4946
+ currentRouterState: this.routerState
4947
+ });
4948
+ return promise.catch(e => {
4949
+ return Promise.reject(e);
4950
+ });
4951
+ }
4952
+ static ɵfac = i0.ɵɵngDeclareFactory({
4953
+ minVersion: "12.0.0",
4954
+ version: "21.0.0-next.10",
4955
+ ngImport: i0,
4956
+ type: Router,
4957
+ deps: [],
4958
+ target: i0.ɵɵFactoryTarget.Injectable
4959
+ });
4960
+ static ɵprov = i0.ɵɵngDeclareInjectable({
4961
+ minVersion: "12.0.0",
4962
+ version: "21.0.0-next.10",
4963
+ ngImport: i0,
4964
+ type: Router,
4965
+ providedIn: 'root'
4966
+ });
4967
+ }
4968
+ i0.ɵɵngDeclareClassMetadata({
4969
+ minVersion: "12.0.0",
4970
+ version: "21.0.0-next.10",
4971
+ ngImport: i0,
4972
+ type: Router,
4973
+ decorators: [{
4974
+ type: Injectable,
4975
+ args: [{
4976
+ providedIn: 'root'
4977
+ }]
4978
+ }],
4979
+ ctorParameters: () => []
4980
+ });
4981
+ function validateCommands(commands) {
4982
+ for (let i = 0; i < commands.length; i++) {
4983
+ const cmd = commands[i];
4984
+ if (cmd == null) {
4985
+ throw new _RuntimeError(4008, (typeof ngDevMode === 'undefined' || ngDevMode) && `The requested path contains ${cmd} segment at index ${i}`);
4986
+ }
4987
+ }
4988
+ }
4989
+
4990
+ export { ActivatedRoute, ActivatedRouteSnapshot, ActivationEnd, ActivationStart, BaseRouteReuseStrategy, CREATE_VIEW_TRANSITION, ChildActivationEnd, ChildActivationStart, ChildrenOutletContexts, DefaultTitleStrategy, DefaultUrlSerializer, EventType, GuardsCheckEnd, GuardsCheckStart, HistoryStateManager, IMPERATIVE_NAVIGATION, INPUT_BINDER, NAVIGATION_ERROR_HANDLER, NavigationCancel, NavigationCancellationCode, NavigationEnd, NavigationError, NavigationSkipped, NavigationSkippedCode, NavigationStart, NavigationTransitions, OutletContext, PRIMARY_OUTLET, ROUTER_CONFIGURATION, ROUTER_OUTLET_DATA, ROUTES, RedirectCommand, ResolveEnd, ResolveStart, RouteConfigLoadEnd, RouteConfigLoadStart, RouteReuseStrategy, RoutedComponentInputBinder, Router, RouterConfigLoader, RouterEvent, RouterOutlet, RouterState, RouterStateSnapshot, RoutesRecognized, Scroll, StateManager, TitleStrategy, UrlHandlingStrategy, UrlSegment, UrlSegmentGroup, UrlSerializer, UrlTree, VIEW_TRANSITION_OPTIONS, afterNextNavigation, convertToParamMap, createUrlTreeFromSnapshot, createViewTransition, defaultUrlMatcher, isUrlTree, loadChildren, provideSometimesSyncRecognize, stringifyEvent, ɵEmptyOutletComponent };
4991
+ //# sourceMappingURL=_router-chunk.mjs.map