@everymatrix/stage-dm-input-text 1.0.0

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,4533 @@
1
+ import {
2
+ ANIMATION_MODULE_TYPE,
3
+ DOCUMENT,
4
+ Inject,
5
+ Injectable,
6
+ RendererFactory2,
7
+ RuntimeError,
8
+ ViewEncapsulation,
9
+ __objRest,
10
+ __spreadValues,
11
+ inject,
12
+ setClassMetadata,
13
+ ɵɵdefineInjectable,
14
+ ɵɵinject
15
+ } from "./chunk-ONYTYTRU.js";
16
+
17
+ // node_modules/@angular/animations/fesm2022/animations.mjs
18
+ var AnimationMetadataType;
19
+ (function(AnimationMetadataType2) {
20
+ AnimationMetadataType2[AnimationMetadataType2["State"] = 0] = "State";
21
+ AnimationMetadataType2[AnimationMetadataType2["Transition"] = 1] = "Transition";
22
+ AnimationMetadataType2[AnimationMetadataType2["Sequence"] = 2] = "Sequence";
23
+ AnimationMetadataType2[AnimationMetadataType2["Group"] = 3] = "Group";
24
+ AnimationMetadataType2[AnimationMetadataType2["Animate"] = 4] = "Animate";
25
+ AnimationMetadataType2[AnimationMetadataType2["Keyframes"] = 5] = "Keyframes";
26
+ AnimationMetadataType2[AnimationMetadataType2["Style"] = 6] = "Style";
27
+ AnimationMetadataType2[AnimationMetadataType2["Trigger"] = 7] = "Trigger";
28
+ AnimationMetadataType2[AnimationMetadataType2["Reference"] = 8] = "Reference";
29
+ AnimationMetadataType2[AnimationMetadataType2["AnimateChild"] = 9] = "AnimateChild";
30
+ AnimationMetadataType2[AnimationMetadataType2["AnimateRef"] = 10] = "AnimateRef";
31
+ AnimationMetadataType2[AnimationMetadataType2["Query"] = 11] = "Query";
32
+ AnimationMetadataType2[AnimationMetadataType2["Stagger"] = 12] = "Stagger";
33
+ })(AnimationMetadataType || (AnimationMetadataType = {}));
34
+ var AUTO_STYLE = "*";
35
+ function sequence(steps, options = null) {
36
+ return {
37
+ type: AnimationMetadataType.Sequence,
38
+ steps,
39
+ options
40
+ };
41
+ }
42
+ function style(tokens) {
43
+ return {
44
+ type: AnimationMetadataType.Style,
45
+ styles: tokens,
46
+ offset: null
47
+ };
48
+ }
49
+ var AnimationBuilder = class _AnimationBuilder {
50
+ static \u0275fac = function AnimationBuilder_Factory(__ngFactoryType__) {
51
+ return new (__ngFactoryType__ || _AnimationBuilder)();
52
+ };
53
+ static \u0275prov = /* @__PURE__ */ \u0275\u0275defineInjectable({
54
+ token: _AnimationBuilder,
55
+ factory: () => (() => inject(BrowserAnimationBuilder))(),
56
+ providedIn: "root"
57
+ });
58
+ };
59
+ (() => {
60
+ (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(AnimationBuilder, [{
61
+ type: Injectable,
62
+ args: [{
63
+ providedIn: "root",
64
+ useFactory: () => inject(BrowserAnimationBuilder)
65
+ }]
66
+ }], null, null);
67
+ })();
68
+ var AnimationFactory = class {
69
+ };
70
+ var BrowserAnimationBuilder = class _BrowserAnimationBuilder extends AnimationBuilder {
71
+ animationModuleType = inject(ANIMATION_MODULE_TYPE, {
72
+ optional: true
73
+ });
74
+ _nextAnimationId = 0;
75
+ _renderer;
76
+ constructor(rootRenderer, doc) {
77
+ super();
78
+ const typeData = {
79
+ id: "0",
80
+ encapsulation: ViewEncapsulation.None,
81
+ styles: [],
82
+ data: {
83
+ animation: []
84
+ }
85
+ };
86
+ this._renderer = rootRenderer.createRenderer(doc.body, typeData);
87
+ if (this.animationModuleType === null && !isAnimationRenderer(this._renderer)) {
88
+ throw new RuntimeError(3600, (typeof ngDevMode === "undefined" || ngDevMode) && "Angular detected that the `AnimationBuilder` was injected, but animation support was not enabled. Please make sure that you enable animations in your application by calling `provideAnimations()` or `provideAnimationsAsync()` function.");
89
+ }
90
+ }
91
+ build(animation) {
92
+ const id = this._nextAnimationId;
93
+ this._nextAnimationId++;
94
+ const entry = Array.isArray(animation) ? sequence(animation) : animation;
95
+ issueAnimationCommand(this._renderer, null, id, "register", [entry]);
96
+ return new BrowserAnimationFactory(id, this._renderer);
97
+ }
98
+ static \u0275fac = function BrowserAnimationBuilder_Factory(__ngFactoryType__) {
99
+ return new (__ngFactoryType__ || _BrowserAnimationBuilder)(\u0275\u0275inject(RendererFactory2), \u0275\u0275inject(DOCUMENT));
100
+ };
101
+ static \u0275prov = /* @__PURE__ */ \u0275\u0275defineInjectable({
102
+ token: _BrowserAnimationBuilder,
103
+ factory: _BrowserAnimationBuilder.\u0275fac,
104
+ providedIn: "root"
105
+ });
106
+ };
107
+ (() => {
108
+ (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(BrowserAnimationBuilder, [{
109
+ type: Injectable,
110
+ args: [{
111
+ providedIn: "root"
112
+ }]
113
+ }], () => [{
114
+ type: RendererFactory2
115
+ }, {
116
+ type: Document,
117
+ decorators: [{
118
+ type: Inject,
119
+ args: [DOCUMENT]
120
+ }]
121
+ }], null);
122
+ })();
123
+ var BrowserAnimationFactory = class extends AnimationFactory {
124
+ _id;
125
+ _renderer;
126
+ constructor(_id, _renderer) {
127
+ super();
128
+ this._id = _id;
129
+ this._renderer = _renderer;
130
+ }
131
+ create(element, options) {
132
+ return new RendererAnimationPlayer(this._id, element, options || {}, this._renderer);
133
+ }
134
+ };
135
+ var RendererAnimationPlayer = class {
136
+ id;
137
+ element;
138
+ _renderer;
139
+ parentPlayer = null;
140
+ _started = false;
141
+ constructor(id, element, options, _renderer) {
142
+ this.id = id;
143
+ this.element = element;
144
+ this._renderer = _renderer;
145
+ this._command("create", options);
146
+ }
147
+ _listen(eventName, callback) {
148
+ return this._renderer.listen(this.element, `@@${this.id}:${eventName}`, callback);
149
+ }
150
+ _command(command, ...args) {
151
+ issueAnimationCommand(this._renderer, this.element, this.id, command, args);
152
+ }
153
+ onDone(fn) {
154
+ this._listen("done", fn);
155
+ }
156
+ onStart(fn) {
157
+ this._listen("start", fn);
158
+ }
159
+ onDestroy(fn) {
160
+ this._listen("destroy", fn);
161
+ }
162
+ init() {
163
+ this._command("init");
164
+ }
165
+ hasStarted() {
166
+ return this._started;
167
+ }
168
+ play() {
169
+ this._command("play");
170
+ this._started = true;
171
+ }
172
+ pause() {
173
+ this._command("pause");
174
+ }
175
+ restart() {
176
+ this._command("restart");
177
+ }
178
+ finish() {
179
+ this._command("finish");
180
+ }
181
+ destroy() {
182
+ this._command("destroy");
183
+ }
184
+ reset() {
185
+ this._command("reset");
186
+ this._started = false;
187
+ }
188
+ setPosition(p) {
189
+ this._command("setPosition", p);
190
+ }
191
+ getPosition() {
192
+ return unwrapAnimationRenderer(this._renderer)?.engine?.players[this.id]?.getPosition() ?? 0;
193
+ }
194
+ totalTime = 0;
195
+ };
196
+ function issueAnimationCommand(renderer, element, id, command, args) {
197
+ renderer.setProperty(element, `@@${id}:${command}`, args);
198
+ }
199
+ function unwrapAnimationRenderer(renderer) {
200
+ const type = renderer.\u0275type;
201
+ if (type === 0) {
202
+ return renderer;
203
+ } else if (type === 1) {
204
+ return renderer.animationRenderer;
205
+ }
206
+ return null;
207
+ }
208
+ function isAnimationRenderer(renderer) {
209
+ const type = renderer.\u0275type;
210
+ return type === 0 || type === 1;
211
+ }
212
+ var NoopAnimationPlayer = class {
213
+ _onDoneFns = [];
214
+ _onStartFns = [];
215
+ _onDestroyFns = [];
216
+ _originalOnDoneFns = [];
217
+ _originalOnStartFns = [];
218
+ _started = false;
219
+ _destroyed = false;
220
+ _finished = false;
221
+ _position = 0;
222
+ parentPlayer = null;
223
+ totalTime;
224
+ constructor(duration = 0, delay = 0) {
225
+ this.totalTime = duration + delay;
226
+ }
227
+ _onFinish() {
228
+ if (!this._finished) {
229
+ this._finished = true;
230
+ this._onDoneFns.forEach((fn) => fn());
231
+ this._onDoneFns = [];
232
+ }
233
+ }
234
+ onStart(fn) {
235
+ this._originalOnStartFns.push(fn);
236
+ this._onStartFns.push(fn);
237
+ }
238
+ onDone(fn) {
239
+ this._originalOnDoneFns.push(fn);
240
+ this._onDoneFns.push(fn);
241
+ }
242
+ onDestroy(fn) {
243
+ this._onDestroyFns.push(fn);
244
+ }
245
+ hasStarted() {
246
+ return this._started;
247
+ }
248
+ init() {
249
+ }
250
+ play() {
251
+ if (!this.hasStarted()) {
252
+ this._onStart();
253
+ this.triggerMicrotask();
254
+ }
255
+ this._started = true;
256
+ }
257
+ /** @internal */
258
+ triggerMicrotask() {
259
+ queueMicrotask(() => this._onFinish());
260
+ }
261
+ _onStart() {
262
+ this._onStartFns.forEach((fn) => fn());
263
+ this._onStartFns = [];
264
+ }
265
+ pause() {
266
+ }
267
+ restart() {
268
+ }
269
+ finish() {
270
+ this._onFinish();
271
+ }
272
+ destroy() {
273
+ if (!this._destroyed) {
274
+ this._destroyed = true;
275
+ if (!this.hasStarted()) {
276
+ this._onStart();
277
+ }
278
+ this.finish();
279
+ this._onDestroyFns.forEach((fn) => fn());
280
+ this._onDestroyFns = [];
281
+ }
282
+ }
283
+ reset() {
284
+ this._started = false;
285
+ this._finished = false;
286
+ this._onStartFns = this._originalOnStartFns;
287
+ this._onDoneFns = this._originalOnDoneFns;
288
+ }
289
+ setPosition(position) {
290
+ this._position = this.totalTime ? position * this.totalTime : 1;
291
+ }
292
+ getPosition() {
293
+ return this.totalTime ? this._position / this.totalTime : 1;
294
+ }
295
+ /** @internal */
296
+ triggerCallback(phaseName) {
297
+ const methods = phaseName == "start" ? this._onStartFns : this._onDoneFns;
298
+ methods.forEach((fn) => fn());
299
+ methods.length = 0;
300
+ }
301
+ };
302
+ var AnimationGroupPlayer = class {
303
+ _onDoneFns = [];
304
+ _onStartFns = [];
305
+ _finished = false;
306
+ _started = false;
307
+ _destroyed = false;
308
+ _onDestroyFns = [];
309
+ parentPlayer = null;
310
+ totalTime = 0;
311
+ players;
312
+ constructor(_players) {
313
+ this.players = _players;
314
+ let doneCount = 0;
315
+ let destroyCount = 0;
316
+ let startCount = 0;
317
+ const total = this.players.length;
318
+ if (total == 0) {
319
+ queueMicrotask(() => this._onFinish());
320
+ } else {
321
+ this.players.forEach((player) => {
322
+ player.onDone(() => {
323
+ if (++doneCount == total) {
324
+ this._onFinish();
325
+ }
326
+ });
327
+ player.onDestroy(() => {
328
+ if (++destroyCount == total) {
329
+ this._onDestroy();
330
+ }
331
+ });
332
+ player.onStart(() => {
333
+ if (++startCount == total) {
334
+ this._onStart();
335
+ }
336
+ });
337
+ });
338
+ }
339
+ this.totalTime = this.players.reduce((time, player) => Math.max(time, player.totalTime), 0);
340
+ }
341
+ _onFinish() {
342
+ if (!this._finished) {
343
+ this._finished = true;
344
+ this._onDoneFns.forEach((fn) => fn());
345
+ this._onDoneFns = [];
346
+ }
347
+ }
348
+ init() {
349
+ this.players.forEach((player) => player.init());
350
+ }
351
+ onStart(fn) {
352
+ this._onStartFns.push(fn);
353
+ }
354
+ _onStart() {
355
+ if (!this.hasStarted()) {
356
+ this._started = true;
357
+ this._onStartFns.forEach((fn) => fn());
358
+ this._onStartFns = [];
359
+ }
360
+ }
361
+ onDone(fn) {
362
+ this._onDoneFns.push(fn);
363
+ }
364
+ onDestroy(fn) {
365
+ this._onDestroyFns.push(fn);
366
+ }
367
+ hasStarted() {
368
+ return this._started;
369
+ }
370
+ play() {
371
+ if (!this.parentPlayer) {
372
+ this.init();
373
+ }
374
+ this._onStart();
375
+ this.players.forEach((player) => player.play());
376
+ }
377
+ pause() {
378
+ this.players.forEach((player) => player.pause());
379
+ }
380
+ restart() {
381
+ this.players.forEach((player) => player.restart());
382
+ }
383
+ finish() {
384
+ this._onFinish();
385
+ this.players.forEach((player) => player.finish());
386
+ }
387
+ destroy() {
388
+ this._onDestroy();
389
+ }
390
+ _onDestroy() {
391
+ if (!this._destroyed) {
392
+ this._destroyed = true;
393
+ this._onFinish();
394
+ this.players.forEach((player) => player.destroy());
395
+ this._onDestroyFns.forEach((fn) => fn());
396
+ this._onDestroyFns = [];
397
+ }
398
+ }
399
+ reset() {
400
+ this.players.forEach((player) => player.reset());
401
+ this._destroyed = false;
402
+ this._finished = false;
403
+ this._started = false;
404
+ }
405
+ setPosition(p) {
406
+ const timeAtPosition = p * this.totalTime;
407
+ this.players.forEach((player) => {
408
+ const position = player.totalTime ? Math.min(1, timeAtPosition / player.totalTime) : 1;
409
+ player.setPosition(position);
410
+ });
411
+ }
412
+ getPosition() {
413
+ const longestPlayer = this.players.reduce((longestSoFar, player) => {
414
+ const newPlayerIsLongest = longestSoFar === null || player.totalTime > longestSoFar.totalTime;
415
+ return newPlayerIsLongest ? player : longestSoFar;
416
+ }, null);
417
+ return longestPlayer != null ? longestPlayer.getPosition() : 0;
418
+ }
419
+ beforeDestroy() {
420
+ this.players.forEach((player) => {
421
+ if (player.beforeDestroy) {
422
+ player.beforeDestroy();
423
+ }
424
+ });
425
+ }
426
+ /** @internal */
427
+ triggerCallback(phaseName) {
428
+ const methods = phaseName == "start" ? this._onStartFns : this._onDoneFns;
429
+ methods.forEach((fn) => fn());
430
+ methods.length = 0;
431
+ }
432
+ };
433
+ var \u0275PRE_STYLE = "!";
434
+
435
+ // node_modules/@angular/animations/fesm2022/browser.mjs
436
+ var LINE_START = "\n - ";
437
+ function invalidTimingValue(exp) {
438
+ return new RuntimeError(3e3, ngDevMode && `The provided timing value "${exp}" is invalid.`);
439
+ }
440
+ function negativeStepValue() {
441
+ return new RuntimeError(3100, ngDevMode && "Duration values below 0 are not allowed for this animation step.");
442
+ }
443
+ function negativeDelayValue() {
444
+ return new RuntimeError(3101, ngDevMode && "Delay values below 0 are not allowed for this animation step.");
445
+ }
446
+ function invalidStyleParams(varName) {
447
+ return new RuntimeError(3001, ngDevMode && `Unable to resolve the local animation param ${varName} in the given list of values`);
448
+ }
449
+ function invalidParamValue(varName) {
450
+ return new RuntimeError(3003, ngDevMode && `Please provide a value for the animation param ${varName}`);
451
+ }
452
+ function invalidNodeType(nodeType) {
453
+ return new RuntimeError(3004, ngDevMode && `Unable to resolve animation metadata node #${nodeType}`);
454
+ }
455
+ function invalidCssUnitValue(userProvidedProperty, value) {
456
+ return new RuntimeError(3005, ngDevMode && `Please provide a CSS unit value for ${userProvidedProperty}:${value}`);
457
+ }
458
+ function invalidTrigger() {
459
+ return new RuntimeError(3006, ngDevMode && "animation triggers cannot be prefixed with an `@` sign (e.g. trigger('@foo', [...]))");
460
+ }
461
+ function invalidDefinition() {
462
+ return new RuntimeError(3007, ngDevMode && "only state() and transition() definitions can sit inside of a trigger()");
463
+ }
464
+ function invalidState(metadataName, missingSubs) {
465
+ return new RuntimeError(3008, ngDevMode && `state("${metadataName}", ...) must define default values for all the following style substitutions: ${missingSubs.join(", ")}`);
466
+ }
467
+ function invalidStyleValue(value) {
468
+ return new RuntimeError(3002, ngDevMode && `The provided style string value ${value} is not allowed.`);
469
+ }
470
+ function invalidParallelAnimation(prop, firstStart, firstEnd, secondStart, secondEnd) {
471
+ return new RuntimeError(3010, ngDevMode && `The CSS property "${prop}" that exists between the times of "${firstStart}ms" and "${firstEnd}ms" is also being animated in a parallel animation between the times of "${secondStart}ms" and "${secondEnd}ms"`);
472
+ }
473
+ function invalidKeyframes() {
474
+ return new RuntimeError(3011, ngDevMode && `keyframes() must be placed inside of a call to animate()`);
475
+ }
476
+ function invalidOffset() {
477
+ return new RuntimeError(3012, ngDevMode && `Please ensure that all keyframe offsets are between 0 and 1`);
478
+ }
479
+ function keyframeOffsetsOutOfOrder() {
480
+ return new RuntimeError(3200, ngDevMode && `Please ensure that all keyframe offsets are in order`);
481
+ }
482
+ function keyframesMissingOffsets() {
483
+ return new RuntimeError(3202, ngDevMode && `Not all style() steps within the declared keyframes() contain offsets`);
484
+ }
485
+ function invalidStagger() {
486
+ return new RuntimeError(3013, ngDevMode && `stagger() can only be used inside of query()`);
487
+ }
488
+ function invalidQuery(selector) {
489
+ return new RuntimeError(3014, ngDevMode && `\`query("${selector}")\` returned zero elements. (Use \`query("${selector}", { optional: true })\` if you wish to allow this.)`);
490
+ }
491
+ function invalidExpression(expr) {
492
+ return new RuntimeError(3015, ngDevMode && `The provided transition expression "${expr}" is not supported`);
493
+ }
494
+ function invalidTransitionAlias(alias) {
495
+ return new RuntimeError(3016, ngDevMode && `The transition alias value "${alias}" is not supported`);
496
+ }
497
+ function validationFailed(errors) {
498
+ return new RuntimeError(3500, ngDevMode && `animation validation failed:
499
+ ${errors.map((err) => err.message).join("\n")}`);
500
+ }
501
+ function buildingFailed(errors) {
502
+ return new RuntimeError(3501, ngDevMode && `animation building failed:
503
+ ${errors.map((err) => err.message).join("\n")}`);
504
+ }
505
+ function triggerBuildFailed(name, errors) {
506
+ return new RuntimeError(3404, ngDevMode && `The animation trigger "${name}" has failed to build due to the following errors:
507
+ - ${errors.map((err) => err.message).join("\n - ")}`);
508
+ }
509
+ function animationFailed(errors) {
510
+ return new RuntimeError(3502, ngDevMode && `Unable to animate due to the following errors:${LINE_START}${errors.map((err) => err.message).join(LINE_START)}`);
511
+ }
512
+ function registerFailed(errors) {
513
+ return new RuntimeError(3503, ngDevMode && `Unable to build the animation due to the following errors: ${errors.map((err) => err.message).join("\n")}`);
514
+ }
515
+ function missingOrDestroyedAnimation() {
516
+ return new RuntimeError(3300, ngDevMode && "The requested animation doesn't exist or has already been destroyed");
517
+ }
518
+ function createAnimationFailed(errors) {
519
+ return new RuntimeError(3504, ngDevMode && `Unable to create the animation due to the following errors:${errors.map((err) => err.message).join("\n")}`);
520
+ }
521
+ function missingPlayer(id) {
522
+ return new RuntimeError(3301, ngDevMode && `Unable to find the timeline player referenced by ${id}`);
523
+ }
524
+ function missingTrigger(phase, name) {
525
+ return new RuntimeError(3302, ngDevMode && `Unable to listen on the animation trigger event "${phase}" because the animation trigger "${name}" doesn't exist!`);
526
+ }
527
+ function missingEvent(name) {
528
+ return new RuntimeError(3303, ngDevMode && `Unable to listen on the animation trigger "${name}" because the provided event is undefined!`);
529
+ }
530
+ function unsupportedTriggerEvent(phase, name) {
531
+ return new RuntimeError(3400, ngDevMode && `The provided animation trigger event "${phase}" for the animation trigger "${name}" is not supported!`);
532
+ }
533
+ function unregisteredTrigger(name) {
534
+ return new RuntimeError(3401, ngDevMode && `The provided animation trigger "${name}" has not been registered!`);
535
+ }
536
+ function triggerTransitionsFailed(errors) {
537
+ return new RuntimeError(3402, ngDevMode && `Unable to process animations due to the following failed trigger transitions
538
+ ${errors.map((err) => err.message).join("\n")}`);
539
+ }
540
+ function transitionFailed(name, errors) {
541
+ return new RuntimeError(3505, ngDevMode && `@${name} has failed due to:
542
+ ${errors.map((err) => err.message).join("\n- ")}`);
543
+ }
544
+ var ANIMATABLE_PROP_SET = /* @__PURE__ */ new Set(["-moz-outline-radius", "-moz-outline-radius-bottomleft", "-moz-outline-radius-bottomright", "-moz-outline-radius-topleft", "-moz-outline-radius-topright", "-ms-grid-columns", "-ms-grid-rows", "-webkit-line-clamp", "-webkit-text-fill-color", "-webkit-text-stroke", "-webkit-text-stroke-color", "accent-color", "all", "backdrop-filter", "background", "background-color", "background-position", "background-size", "block-size", "border", "border-block-end", "border-block-end-color", "border-block-end-width", "border-block-start", "border-block-start-color", "border-block-start-width", "border-bottom", "border-bottom-color", "border-bottom-left-radius", "border-bottom-right-radius", "border-bottom-width", "border-color", "border-end-end-radius", "border-end-start-radius", "border-image-outset", "border-image-slice", "border-image-width", "border-inline-end", "border-inline-end-color", "border-inline-end-width", "border-inline-start", "border-inline-start-color", "border-inline-start-width", "border-left", "border-left-color", "border-left-width", "border-radius", "border-right", "border-right-color", "border-right-width", "border-start-end-radius", "border-start-start-radius", "border-top", "border-top-color", "border-top-left-radius", "border-top-right-radius", "border-top-width", "border-width", "bottom", "box-shadow", "caret-color", "clip", "clip-path", "color", "column-count", "column-gap", "column-rule", "column-rule-color", "column-rule-width", "column-width", "columns", "filter", "flex", "flex-basis", "flex-grow", "flex-shrink", "font", "font-size", "font-size-adjust", "font-stretch", "font-variation-settings", "font-weight", "gap", "grid-column-gap", "grid-gap", "grid-row-gap", "grid-template-columns", "grid-template-rows", "height", "inline-size", "input-security", "inset", "inset-block", "inset-block-end", "inset-block-start", "inset-inline", "inset-inline-end", "inset-inline-start", "left", "letter-spacing", "line-clamp", "line-height", "margin", "margin-block-end", "margin-block-start", "margin-bottom", "margin-inline-end", "margin-inline-start", "margin-left", "margin-right", "margin-top", "mask", "mask-border", "mask-position", "mask-size", "max-block-size", "max-height", "max-inline-size", "max-lines", "max-width", "min-block-size", "min-height", "min-inline-size", "min-width", "object-position", "offset", "offset-anchor", "offset-distance", "offset-path", "offset-position", "offset-rotate", "opacity", "order", "outline", "outline-color", "outline-offset", "outline-width", "padding", "padding-block-end", "padding-block-start", "padding-bottom", "padding-inline-end", "padding-inline-start", "padding-left", "padding-right", "padding-top", "perspective", "perspective-origin", "right", "rotate", "row-gap", "scale", "scroll-margin", "scroll-margin-block", "scroll-margin-block-end", "scroll-margin-block-start", "scroll-margin-bottom", "scroll-margin-inline", "scroll-margin-inline-end", "scroll-margin-inline-start", "scroll-margin-left", "scroll-margin-right", "scroll-margin-top", "scroll-padding", "scroll-padding-block", "scroll-padding-block-end", "scroll-padding-block-start", "scroll-padding-bottom", "scroll-padding-inline", "scroll-padding-inline-end", "scroll-padding-inline-start", "scroll-padding-left", "scroll-padding-right", "scroll-padding-top", "scroll-snap-coordinate", "scroll-snap-destination", "scrollbar-color", "shape-image-threshold", "shape-margin", "shape-outside", "tab-size", "text-decoration", "text-decoration-color", "text-decoration-thickness", "text-emphasis", "text-emphasis-color", "text-indent", "text-shadow", "text-underline-offset", "top", "transform", "transform-origin", "translate", "vertical-align", "visibility", "width", "word-spacing", "z-index", "zoom"]);
545
+ function optimizeGroupPlayer(players) {
546
+ switch (players.length) {
547
+ case 0:
548
+ return new NoopAnimationPlayer();
549
+ case 1:
550
+ return players[0];
551
+ default:
552
+ return new AnimationGroupPlayer(players);
553
+ }
554
+ }
555
+ function normalizeKeyframes$1(normalizer, keyframes, preStyles = /* @__PURE__ */ new Map(), postStyles = /* @__PURE__ */ new Map()) {
556
+ const errors = [];
557
+ const normalizedKeyframes = [];
558
+ let previousOffset = -1;
559
+ let previousKeyframe = null;
560
+ keyframes.forEach((kf) => {
561
+ const offset = kf.get("offset");
562
+ const isSameOffset = offset == previousOffset;
563
+ const normalizedKeyframe = isSameOffset && previousKeyframe || /* @__PURE__ */ new Map();
564
+ kf.forEach((val, prop) => {
565
+ let normalizedProp = prop;
566
+ let normalizedValue = val;
567
+ if (prop !== "offset") {
568
+ normalizedProp = normalizer.normalizePropertyName(normalizedProp, errors);
569
+ switch (normalizedValue) {
570
+ case \u0275PRE_STYLE:
571
+ normalizedValue = preStyles.get(prop);
572
+ break;
573
+ case AUTO_STYLE:
574
+ normalizedValue = postStyles.get(prop);
575
+ break;
576
+ default:
577
+ normalizedValue = normalizer.normalizeStyleValue(prop, normalizedProp, normalizedValue, errors);
578
+ break;
579
+ }
580
+ }
581
+ normalizedKeyframe.set(normalizedProp, normalizedValue);
582
+ });
583
+ if (!isSameOffset) {
584
+ normalizedKeyframes.push(normalizedKeyframe);
585
+ }
586
+ previousKeyframe = normalizedKeyframe;
587
+ previousOffset = offset;
588
+ });
589
+ if (errors.length) {
590
+ throw animationFailed(errors);
591
+ }
592
+ return normalizedKeyframes;
593
+ }
594
+ function listenOnPlayer(player, eventName, event, callback) {
595
+ switch (eventName) {
596
+ case "start":
597
+ player.onStart(() => callback(event && copyAnimationEvent(event, "start", player)));
598
+ break;
599
+ case "done":
600
+ player.onDone(() => callback(event && copyAnimationEvent(event, "done", player)));
601
+ break;
602
+ case "destroy":
603
+ player.onDestroy(() => callback(event && copyAnimationEvent(event, "destroy", player)));
604
+ break;
605
+ }
606
+ }
607
+ function copyAnimationEvent(e, phaseName, player) {
608
+ const totalTime = player.totalTime;
609
+ const disabled = player.disabled ? true : false;
610
+ const event = makeAnimationEvent(e.element, e.triggerName, e.fromState, e.toState, phaseName || e.phaseName, totalTime == void 0 ? e.totalTime : totalTime, disabled);
611
+ const data = e["_data"];
612
+ if (data != null) {
613
+ event["_data"] = data;
614
+ }
615
+ return event;
616
+ }
617
+ function makeAnimationEvent(element, triggerName, fromState, toState, phaseName = "", totalTime = 0, disabled) {
618
+ return {
619
+ element,
620
+ triggerName,
621
+ fromState,
622
+ toState,
623
+ phaseName,
624
+ totalTime,
625
+ disabled: !!disabled
626
+ };
627
+ }
628
+ function getOrSetDefaultValue(map, key, defaultValue) {
629
+ let value = map.get(key);
630
+ if (!value) {
631
+ map.set(key, value = defaultValue);
632
+ }
633
+ return value;
634
+ }
635
+ function parseTimelineCommand(command) {
636
+ const separatorPos = command.indexOf(":");
637
+ const id = command.substring(1, separatorPos);
638
+ const action = command.slice(separatorPos + 1);
639
+ return [id, action];
640
+ }
641
+ var documentElement = /* @__PURE__ */ (() => typeof document === "undefined" ? null : document.documentElement)();
642
+ function getParentElement(element) {
643
+ const parent = element.parentNode || element.host || null;
644
+ if (parent === documentElement) {
645
+ return null;
646
+ }
647
+ return parent;
648
+ }
649
+ function containsVendorPrefix(prop) {
650
+ return prop.substring(1, 6) == "ebkit";
651
+ }
652
+ var _CACHED_BODY = null;
653
+ var _IS_WEBKIT = false;
654
+ function validateStyleProperty(prop) {
655
+ if (!_CACHED_BODY) {
656
+ _CACHED_BODY = getBodyNode() || {};
657
+ _IS_WEBKIT = _CACHED_BODY.style ? "WebkitAppearance" in _CACHED_BODY.style : false;
658
+ }
659
+ let result = true;
660
+ if (_CACHED_BODY.style && !containsVendorPrefix(prop)) {
661
+ result = prop in _CACHED_BODY.style;
662
+ if (!result && _IS_WEBKIT) {
663
+ const camelProp = "Webkit" + prop.charAt(0).toUpperCase() + prop.slice(1);
664
+ result = camelProp in _CACHED_BODY.style;
665
+ }
666
+ }
667
+ return result;
668
+ }
669
+ function validateWebAnimatableStyleProperty(prop) {
670
+ return ANIMATABLE_PROP_SET.has(prop);
671
+ }
672
+ function getBodyNode() {
673
+ if (typeof document != "undefined") {
674
+ return document.body;
675
+ }
676
+ return null;
677
+ }
678
+ function containsElement(elm1, elm2) {
679
+ while (elm2) {
680
+ if (elm2 === elm1) {
681
+ return true;
682
+ }
683
+ elm2 = getParentElement(elm2);
684
+ }
685
+ return false;
686
+ }
687
+ function invokeQuery(element, selector, multi) {
688
+ if (multi) {
689
+ return Array.from(element.querySelectorAll(selector));
690
+ }
691
+ const elem = element.querySelector(selector);
692
+ return elem ? [elem] : [];
693
+ }
694
+ var NoopAnimationDriver = class _NoopAnimationDriver {
695
+ /**
696
+ * @returns Whether `prop` is a valid CSS property
697
+ */
698
+ validateStyleProperty(prop) {
699
+ return validateStyleProperty(prop);
700
+ }
701
+ /**
702
+ *
703
+ * @returns Whether elm1 contains elm2.
704
+ */
705
+ containsElement(elm1, elm2) {
706
+ return containsElement(elm1, elm2);
707
+ }
708
+ /**
709
+ * @returns Rhe parent of the given element or `null` if the element is the `document`
710
+ */
711
+ getParentElement(element) {
712
+ return getParentElement(element);
713
+ }
714
+ /**
715
+ * @returns The result of the query selector on the element. The array will contain up to 1 item
716
+ * if `multi` is `false`.
717
+ */
718
+ query(element, selector, multi) {
719
+ return invokeQuery(element, selector, multi);
720
+ }
721
+ /**
722
+ * @returns The `defaultValue` or empty string
723
+ */
724
+ computeStyle(element, prop, defaultValue) {
725
+ return defaultValue || "";
726
+ }
727
+ /**
728
+ * @returns An `NoopAnimationPlayer`
729
+ */
730
+ animate(element, keyframes, duration, delay, easing, previousPlayers = [], scrubberAccessRequested) {
731
+ return new NoopAnimationPlayer(duration, delay);
732
+ }
733
+ static \u0275fac = function NoopAnimationDriver_Factory(__ngFactoryType__) {
734
+ return new (__ngFactoryType__ || _NoopAnimationDriver)();
735
+ };
736
+ static \u0275prov = /* @__PURE__ */ \u0275\u0275defineInjectable({
737
+ token: _NoopAnimationDriver,
738
+ factory: _NoopAnimationDriver.\u0275fac
739
+ });
740
+ };
741
+ (() => {
742
+ (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(NoopAnimationDriver, [{
743
+ type: Injectable
744
+ }], null, null);
745
+ })();
746
+ var AnimationDriver = class {
747
+ /**
748
+ * @deprecated Use the NoopAnimationDriver class.
749
+ */
750
+ static NOOP = new NoopAnimationDriver();
751
+ };
752
+ var AnimationStyleNormalizer = class {
753
+ };
754
+ var NoopAnimationStyleNormalizer = class {
755
+ normalizePropertyName(propertyName, errors) {
756
+ return propertyName;
757
+ }
758
+ normalizeStyleValue(userProvidedProperty, normalizedProperty, value, errors) {
759
+ return value;
760
+ }
761
+ };
762
+ var ONE_SECOND = 1e3;
763
+ var SUBSTITUTION_EXPR_START = "{{";
764
+ var SUBSTITUTION_EXPR_END = "}}";
765
+ var ENTER_CLASSNAME = "ng-enter";
766
+ var LEAVE_CLASSNAME = "ng-leave";
767
+ var NG_TRIGGER_CLASSNAME = "ng-trigger";
768
+ var NG_TRIGGER_SELECTOR = ".ng-trigger";
769
+ var NG_ANIMATING_CLASSNAME = "ng-animating";
770
+ var NG_ANIMATING_SELECTOR = ".ng-animating";
771
+ function resolveTimingValue(value) {
772
+ if (typeof value == "number") return value;
773
+ const matches = value.match(/^(-?[\.\d]+)(m?s)/);
774
+ if (!matches || matches.length < 2) return 0;
775
+ return _convertTimeValueToMS(parseFloat(matches[1]), matches[2]);
776
+ }
777
+ function _convertTimeValueToMS(value, unit) {
778
+ switch (unit) {
779
+ case "s":
780
+ return value * ONE_SECOND;
781
+ default:
782
+ return value;
783
+ }
784
+ }
785
+ function resolveTiming(timings, errors, allowNegativeValues) {
786
+ return timings.hasOwnProperty("duration") ? timings : parseTimeExpression(timings, errors, allowNegativeValues);
787
+ }
788
+ function parseTimeExpression(exp, errors, allowNegativeValues) {
789
+ const regex = /^(-?[\.\d]+)(m?s)(?:\s+(-?[\.\d]+)(m?s))?(?:\s+([-a-z]+(?:\(.+?\))?))?$/i;
790
+ let duration;
791
+ let delay = 0;
792
+ let easing = "";
793
+ if (typeof exp === "string") {
794
+ const matches = exp.match(regex);
795
+ if (matches === null) {
796
+ errors.push(invalidTimingValue(exp));
797
+ return {
798
+ duration: 0,
799
+ delay: 0,
800
+ easing: ""
801
+ };
802
+ }
803
+ duration = _convertTimeValueToMS(parseFloat(matches[1]), matches[2]);
804
+ const delayMatch = matches[3];
805
+ if (delayMatch != null) {
806
+ delay = _convertTimeValueToMS(parseFloat(delayMatch), matches[4]);
807
+ }
808
+ const easingVal = matches[5];
809
+ if (easingVal) {
810
+ easing = easingVal;
811
+ }
812
+ } else {
813
+ duration = exp;
814
+ }
815
+ if (!allowNegativeValues) {
816
+ let containsErrors = false;
817
+ let startIndex = errors.length;
818
+ if (duration < 0) {
819
+ errors.push(negativeStepValue());
820
+ containsErrors = true;
821
+ }
822
+ if (delay < 0) {
823
+ errors.push(negativeDelayValue());
824
+ containsErrors = true;
825
+ }
826
+ if (containsErrors) {
827
+ errors.splice(startIndex, 0, invalidTimingValue(exp));
828
+ }
829
+ }
830
+ return {
831
+ duration,
832
+ delay,
833
+ easing
834
+ };
835
+ }
836
+ function normalizeKeyframes(keyframes) {
837
+ if (!keyframes.length) {
838
+ return [];
839
+ }
840
+ if (keyframes[0] instanceof Map) {
841
+ return keyframes;
842
+ }
843
+ return keyframes.map((kf) => new Map(Object.entries(kf)));
844
+ }
845
+ function normalizeStyles(styles) {
846
+ return Array.isArray(styles) ? new Map(...styles) : new Map(styles);
847
+ }
848
+ function setStyles(element, styles, formerStyles) {
849
+ styles.forEach((val, prop) => {
850
+ const camelProp = dashCaseToCamelCase(prop);
851
+ if (formerStyles && !formerStyles.has(prop)) {
852
+ formerStyles.set(prop, element.style[camelProp]);
853
+ }
854
+ element.style[camelProp] = val;
855
+ });
856
+ }
857
+ function eraseStyles(element, styles) {
858
+ styles.forEach((_, prop) => {
859
+ const camelProp = dashCaseToCamelCase(prop);
860
+ element.style[camelProp] = "";
861
+ });
862
+ }
863
+ function normalizeAnimationEntry(steps) {
864
+ if (Array.isArray(steps)) {
865
+ if (steps.length == 1) return steps[0];
866
+ return sequence(steps);
867
+ }
868
+ return steps;
869
+ }
870
+ function validateStyleParams(value, options, errors) {
871
+ const params = options.params || {};
872
+ const matches = extractStyleParams(value);
873
+ if (matches.length) {
874
+ matches.forEach((varName) => {
875
+ if (!params.hasOwnProperty(varName)) {
876
+ errors.push(invalidStyleParams(varName));
877
+ }
878
+ });
879
+ }
880
+ }
881
+ var PARAM_REGEX = new RegExp(`${SUBSTITUTION_EXPR_START}\\s*(.+?)\\s*${SUBSTITUTION_EXPR_END}`, "g");
882
+ function extractStyleParams(value) {
883
+ let params = [];
884
+ if (typeof value === "string") {
885
+ let match;
886
+ while (match = PARAM_REGEX.exec(value)) {
887
+ params.push(match[1]);
888
+ }
889
+ PARAM_REGEX.lastIndex = 0;
890
+ }
891
+ return params;
892
+ }
893
+ function interpolateParams(value, params, errors) {
894
+ const original = `${value}`;
895
+ const str = original.replace(PARAM_REGEX, (_, varName) => {
896
+ let localVal = params[varName];
897
+ if (localVal == null) {
898
+ errors.push(invalidParamValue(varName));
899
+ localVal = "";
900
+ }
901
+ return localVal.toString();
902
+ });
903
+ return str == original ? value : str;
904
+ }
905
+ var DASH_CASE_REGEXP = /-+([a-z0-9])/g;
906
+ function dashCaseToCamelCase(input) {
907
+ return input.replace(DASH_CASE_REGEXP, (...m) => m[1].toUpperCase());
908
+ }
909
+ function camelCaseToDashCase(input) {
910
+ return input.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
911
+ }
912
+ function allowPreviousPlayerStylesMerge(duration, delay) {
913
+ return duration === 0 || delay === 0;
914
+ }
915
+ function balancePreviousStylesIntoKeyframes(element, keyframes, previousStyles) {
916
+ if (previousStyles.size && keyframes.length) {
917
+ let startingKeyframe = keyframes[0];
918
+ let missingStyleProps = [];
919
+ previousStyles.forEach((val, prop) => {
920
+ if (!startingKeyframe.has(prop)) {
921
+ missingStyleProps.push(prop);
922
+ }
923
+ startingKeyframe.set(prop, val);
924
+ });
925
+ if (missingStyleProps.length) {
926
+ for (let i = 1; i < keyframes.length; i++) {
927
+ let kf = keyframes[i];
928
+ missingStyleProps.forEach((prop) => kf.set(prop, computeStyle(element, prop)));
929
+ }
930
+ }
931
+ }
932
+ return keyframes;
933
+ }
934
+ function visitDslNode(visitor, node, context) {
935
+ switch (node.type) {
936
+ case AnimationMetadataType.Trigger:
937
+ return visitor.visitTrigger(node, context);
938
+ case AnimationMetadataType.State:
939
+ return visitor.visitState(node, context);
940
+ case AnimationMetadataType.Transition:
941
+ return visitor.visitTransition(node, context);
942
+ case AnimationMetadataType.Sequence:
943
+ return visitor.visitSequence(node, context);
944
+ case AnimationMetadataType.Group:
945
+ return visitor.visitGroup(node, context);
946
+ case AnimationMetadataType.Animate:
947
+ return visitor.visitAnimate(node, context);
948
+ case AnimationMetadataType.Keyframes:
949
+ return visitor.visitKeyframes(node, context);
950
+ case AnimationMetadataType.Style:
951
+ return visitor.visitStyle(node, context);
952
+ case AnimationMetadataType.Reference:
953
+ return visitor.visitReference(node, context);
954
+ case AnimationMetadataType.AnimateChild:
955
+ return visitor.visitAnimateChild(node, context);
956
+ case AnimationMetadataType.AnimateRef:
957
+ return visitor.visitAnimateRef(node, context);
958
+ case AnimationMetadataType.Query:
959
+ return visitor.visitQuery(node, context);
960
+ case AnimationMetadataType.Stagger:
961
+ return visitor.visitStagger(node, context);
962
+ default:
963
+ throw invalidNodeType(node.type);
964
+ }
965
+ }
966
+ function computeStyle(element, prop) {
967
+ return window.getComputedStyle(element)[prop];
968
+ }
969
+ var DIMENSIONAL_PROP_SET = /* @__PURE__ */ new Set(["width", "height", "minWidth", "minHeight", "maxWidth", "maxHeight", "left", "top", "bottom", "right", "fontSize", "outlineWidth", "outlineOffset", "paddingTop", "paddingLeft", "paddingBottom", "paddingRight", "marginTop", "marginLeft", "marginBottom", "marginRight", "borderRadius", "borderWidth", "borderTopWidth", "borderLeftWidth", "borderRightWidth", "borderBottomWidth", "textIndent", "perspective"]);
970
+ var WebAnimationsStyleNormalizer = class extends AnimationStyleNormalizer {
971
+ normalizePropertyName(propertyName, errors) {
972
+ return dashCaseToCamelCase(propertyName);
973
+ }
974
+ normalizeStyleValue(userProvidedProperty, normalizedProperty, value, errors) {
975
+ let unit = "";
976
+ const strVal = value.toString().trim();
977
+ if (DIMENSIONAL_PROP_SET.has(normalizedProperty) && value !== 0 && value !== "0") {
978
+ if (typeof value === "number") {
979
+ unit = "px";
980
+ } else {
981
+ const valAndSuffixMatch = value.match(/^[+-]?[\d\.]+([a-z]*)$/);
982
+ if (valAndSuffixMatch && valAndSuffixMatch[1].length == 0) {
983
+ errors.push(invalidCssUnitValue(userProvidedProperty, value));
984
+ }
985
+ }
986
+ }
987
+ return strVal + unit;
988
+ }
989
+ };
990
+ function createListOfWarnings(warnings) {
991
+ const LINE_START2 = "\n - ";
992
+ return `${LINE_START2}${warnings.filter(Boolean).map((warning) => warning).join(LINE_START2)}`;
993
+ }
994
+ function warnValidation(warnings) {
995
+ console.warn(`animation validation warnings:${createListOfWarnings(warnings)}`);
996
+ }
997
+ function warnTriggerBuild(name, warnings) {
998
+ console.warn(`The animation trigger "${name}" has built with the following warnings:${createListOfWarnings(warnings)}`);
999
+ }
1000
+ function warnRegister(warnings) {
1001
+ console.warn(`Animation built with the following warnings:${createListOfWarnings(warnings)}`);
1002
+ }
1003
+ function pushUnrecognizedPropertiesWarning(warnings, props) {
1004
+ if (props.length) {
1005
+ warnings.push(`The following provided properties are not recognized: ${props.join(", ")}`);
1006
+ }
1007
+ }
1008
+ var ANY_STATE = "*";
1009
+ function parseTransitionExpr(transitionValue, errors) {
1010
+ const expressions = [];
1011
+ if (typeof transitionValue == "string") {
1012
+ transitionValue.split(/\s*,\s*/).forEach((str) => parseInnerTransitionStr(str, expressions, errors));
1013
+ } else {
1014
+ expressions.push(transitionValue);
1015
+ }
1016
+ return expressions;
1017
+ }
1018
+ function parseInnerTransitionStr(eventStr, expressions, errors) {
1019
+ if (eventStr[0] == ":") {
1020
+ const result = parseAnimationAlias(eventStr, errors);
1021
+ if (typeof result == "function") {
1022
+ expressions.push(result);
1023
+ return;
1024
+ }
1025
+ eventStr = result;
1026
+ }
1027
+ const match = eventStr.match(/^(\*|[-\w]+)\s*(<?[=-]>)\s*(\*|[-\w]+)$/);
1028
+ if (match == null || match.length < 4) {
1029
+ errors.push(invalidExpression(eventStr));
1030
+ return expressions;
1031
+ }
1032
+ const fromState = match[1];
1033
+ const separator = match[2];
1034
+ const toState = match[3];
1035
+ expressions.push(makeLambdaFromStates(fromState, toState));
1036
+ const isFullAnyStateExpr = fromState == ANY_STATE && toState == ANY_STATE;
1037
+ if (separator[0] == "<" && !isFullAnyStateExpr) {
1038
+ expressions.push(makeLambdaFromStates(toState, fromState));
1039
+ }
1040
+ return;
1041
+ }
1042
+ function parseAnimationAlias(alias, errors) {
1043
+ switch (alias) {
1044
+ case ":enter":
1045
+ return "void => *";
1046
+ case ":leave":
1047
+ return "* => void";
1048
+ case ":increment":
1049
+ return (fromState, toState) => parseFloat(toState) > parseFloat(fromState);
1050
+ case ":decrement":
1051
+ return (fromState, toState) => parseFloat(toState) < parseFloat(fromState);
1052
+ default:
1053
+ errors.push(invalidTransitionAlias(alias));
1054
+ return "* => *";
1055
+ }
1056
+ }
1057
+ var TRUE_BOOLEAN_VALUES = /* @__PURE__ */ new Set(["true", "1"]);
1058
+ var FALSE_BOOLEAN_VALUES = /* @__PURE__ */ new Set(["false", "0"]);
1059
+ function makeLambdaFromStates(lhs, rhs) {
1060
+ const LHS_MATCH_BOOLEAN = TRUE_BOOLEAN_VALUES.has(lhs) || FALSE_BOOLEAN_VALUES.has(lhs);
1061
+ const RHS_MATCH_BOOLEAN = TRUE_BOOLEAN_VALUES.has(rhs) || FALSE_BOOLEAN_VALUES.has(rhs);
1062
+ return (fromState, toState) => {
1063
+ let lhsMatch = lhs == ANY_STATE || lhs == fromState;
1064
+ let rhsMatch = rhs == ANY_STATE || rhs == toState;
1065
+ if (!lhsMatch && LHS_MATCH_BOOLEAN && typeof fromState === "boolean") {
1066
+ lhsMatch = fromState ? TRUE_BOOLEAN_VALUES.has(lhs) : FALSE_BOOLEAN_VALUES.has(lhs);
1067
+ }
1068
+ if (!rhsMatch && RHS_MATCH_BOOLEAN && typeof toState === "boolean") {
1069
+ rhsMatch = toState ? TRUE_BOOLEAN_VALUES.has(rhs) : FALSE_BOOLEAN_VALUES.has(rhs);
1070
+ }
1071
+ return lhsMatch && rhsMatch;
1072
+ };
1073
+ }
1074
+ var SELF_TOKEN = ":self";
1075
+ var SELF_TOKEN_REGEX = new RegExp(`s*${SELF_TOKEN}s*,?`, "g");
1076
+ function buildAnimationAst(driver, metadata, errors, warnings) {
1077
+ return new AnimationAstBuilderVisitor(driver).build(metadata, errors, warnings);
1078
+ }
1079
+ var ROOT_SELECTOR = "";
1080
+ var AnimationAstBuilderVisitor = class {
1081
+ _driver;
1082
+ constructor(_driver) {
1083
+ this._driver = _driver;
1084
+ }
1085
+ build(metadata, errors, warnings) {
1086
+ const context = new AnimationAstBuilderContext(errors);
1087
+ this._resetContextStyleTimingState(context);
1088
+ const ast = visitDslNode(this, normalizeAnimationEntry(metadata), context);
1089
+ if (typeof ngDevMode === "undefined" || ngDevMode) {
1090
+ if (context.unsupportedCSSPropertiesFound.size) {
1091
+ pushUnrecognizedPropertiesWarning(warnings, [...context.unsupportedCSSPropertiesFound.keys()]);
1092
+ }
1093
+ }
1094
+ return ast;
1095
+ }
1096
+ _resetContextStyleTimingState(context) {
1097
+ context.currentQuerySelector = ROOT_SELECTOR;
1098
+ context.collectedStyles = /* @__PURE__ */ new Map();
1099
+ context.collectedStyles.set(ROOT_SELECTOR, /* @__PURE__ */ new Map());
1100
+ context.currentTime = 0;
1101
+ }
1102
+ visitTrigger(metadata, context) {
1103
+ let queryCount = context.queryCount = 0;
1104
+ let depCount = context.depCount = 0;
1105
+ const states = [];
1106
+ const transitions = [];
1107
+ if (metadata.name.charAt(0) == "@") {
1108
+ context.errors.push(invalidTrigger());
1109
+ }
1110
+ metadata.definitions.forEach((def) => {
1111
+ this._resetContextStyleTimingState(context);
1112
+ if (def.type == AnimationMetadataType.State) {
1113
+ const stateDef = def;
1114
+ const name = stateDef.name;
1115
+ name.toString().split(/\s*,\s*/).forEach((n) => {
1116
+ stateDef.name = n;
1117
+ states.push(this.visitState(stateDef, context));
1118
+ });
1119
+ stateDef.name = name;
1120
+ } else if (def.type == AnimationMetadataType.Transition) {
1121
+ const transition = this.visitTransition(def, context);
1122
+ queryCount += transition.queryCount;
1123
+ depCount += transition.depCount;
1124
+ transitions.push(transition);
1125
+ } else {
1126
+ context.errors.push(invalidDefinition());
1127
+ }
1128
+ });
1129
+ return {
1130
+ type: AnimationMetadataType.Trigger,
1131
+ name: metadata.name,
1132
+ states,
1133
+ transitions,
1134
+ queryCount,
1135
+ depCount,
1136
+ options: null
1137
+ };
1138
+ }
1139
+ visitState(metadata, context) {
1140
+ const styleAst = this.visitStyle(metadata.styles, context);
1141
+ const astParams = metadata.options && metadata.options.params || null;
1142
+ if (styleAst.containsDynamicStyles) {
1143
+ const missingSubs = /* @__PURE__ */ new Set();
1144
+ const params = astParams || {};
1145
+ styleAst.styles.forEach((style2) => {
1146
+ if (style2 instanceof Map) {
1147
+ style2.forEach((value) => {
1148
+ extractStyleParams(value).forEach((sub) => {
1149
+ if (!params.hasOwnProperty(sub)) {
1150
+ missingSubs.add(sub);
1151
+ }
1152
+ });
1153
+ });
1154
+ }
1155
+ });
1156
+ if (missingSubs.size) {
1157
+ context.errors.push(invalidState(metadata.name, [...missingSubs.values()]));
1158
+ }
1159
+ }
1160
+ return {
1161
+ type: AnimationMetadataType.State,
1162
+ name: metadata.name,
1163
+ style: styleAst,
1164
+ options: astParams ? {
1165
+ params: astParams
1166
+ } : null
1167
+ };
1168
+ }
1169
+ visitTransition(metadata, context) {
1170
+ context.queryCount = 0;
1171
+ context.depCount = 0;
1172
+ const animation = visitDslNode(this, normalizeAnimationEntry(metadata.animation), context);
1173
+ const matchers = parseTransitionExpr(metadata.expr, context.errors);
1174
+ return {
1175
+ type: AnimationMetadataType.Transition,
1176
+ matchers,
1177
+ animation,
1178
+ queryCount: context.queryCount,
1179
+ depCount: context.depCount,
1180
+ options: normalizeAnimationOptions(metadata.options)
1181
+ };
1182
+ }
1183
+ visitSequence(metadata, context) {
1184
+ return {
1185
+ type: AnimationMetadataType.Sequence,
1186
+ steps: metadata.steps.map((s) => visitDslNode(this, s, context)),
1187
+ options: normalizeAnimationOptions(metadata.options)
1188
+ };
1189
+ }
1190
+ visitGroup(metadata, context) {
1191
+ const currentTime = context.currentTime;
1192
+ let furthestTime = 0;
1193
+ const steps = metadata.steps.map((step) => {
1194
+ context.currentTime = currentTime;
1195
+ const innerAst = visitDslNode(this, step, context);
1196
+ furthestTime = Math.max(furthestTime, context.currentTime);
1197
+ return innerAst;
1198
+ });
1199
+ context.currentTime = furthestTime;
1200
+ return {
1201
+ type: AnimationMetadataType.Group,
1202
+ steps,
1203
+ options: normalizeAnimationOptions(metadata.options)
1204
+ };
1205
+ }
1206
+ visitAnimate(metadata, context) {
1207
+ const timingAst = constructTimingAst(metadata.timings, context.errors);
1208
+ context.currentAnimateTimings = timingAst;
1209
+ let styleAst;
1210
+ let styleMetadata = metadata.styles ? metadata.styles : style({});
1211
+ if (styleMetadata.type == AnimationMetadataType.Keyframes) {
1212
+ styleAst = this.visitKeyframes(styleMetadata, context);
1213
+ } else {
1214
+ let styleMetadata2 = metadata.styles;
1215
+ let isEmpty = false;
1216
+ if (!styleMetadata2) {
1217
+ isEmpty = true;
1218
+ const newStyleData = {};
1219
+ if (timingAst.easing) {
1220
+ newStyleData["easing"] = timingAst.easing;
1221
+ }
1222
+ styleMetadata2 = style(newStyleData);
1223
+ }
1224
+ context.currentTime += timingAst.duration + timingAst.delay;
1225
+ const _styleAst = this.visitStyle(styleMetadata2, context);
1226
+ _styleAst.isEmptyStep = isEmpty;
1227
+ styleAst = _styleAst;
1228
+ }
1229
+ context.currentAnimateTimings = null;
1230
+ return {
1231
+ type: AnimationMetadataType.Animate,
1232
+ timings: timingAst,
1233
+ style: styleAst,
1234
+ options: null
1235
+ };
1236
+ }
1237
+ visitStyle(metadata, context) {
1238
+ const ast = this._makeStyleAst(metadata, context);
1239
+ this._validateStyleAst(ast, context);
1240
+ return ast;
1241
+ }
1242
+ _makeStyleAst(metadata, context) {
1243
+ const styles = [];
1244
+ const metadataStyles = Array.isArray(metadata.styles) ? metadata.styles : [metadata.styles];
1245
+ for (let styleTuple of metadataStyles) {
1246
+ if (typeof styleTuple === "string") {
1247
+ if (styleTuple === AUTO_STYLE) {
1248
+ styles.push(styleTuple);
1249
+ } else {
1250
+ context.errors.push(invalidStyleValue(styleTuple));
1251
+ }
1252
+ } else {
1253
+ styles.push(new Map(Object.entries(styleTuple)));
1254
+ }
1255
+ }
1256
+ let containsDynamicStyles = false;
1257
+ let collectedEasing = null;
1258
+ styles.forEach((styleData) => {
1259
+ if (styleData instanceof Map) {
1260
+ if (styleData.has("easing")) {
1261
+ collectedEasing = styleData.get("easing");
1262
+ styleData.delete("easing");
1263
+ }
1264
+ if (!containsDynamicStyles) {
1265
+ for (let value of styleData.values()) {
1266
+ if (value.toString().indexOf(SUBSTITUTION_EXPR_START) >= 0) {
1267
+ containsDynamicStyles = true;
1268
+ break;
1269
+ }
1270
+ }
1271
+ }
1272
+ }
1273
+ });
1274
+ return {
1275
+ type: AnimationMetadataType.Style,
1276
+ styles,
1277
+ easing: collectedEasing,
1278
+ offset: metadata.offset,
1279
+ containsDynamicStyles,
1280
+ options: null
1281
+ };
1282
+ }
1283
+ _validateStyleAst(ast, context) {
1284
+ const timings = context.currentAnimateTimings;
1285
+ let endTime = context.currentTime;
1286
+ let startTime = context.currentTime;
1287
+ if (timings && startTime > 0) {
1288
+ startTime -= timings.duration + timings.delay;
1289
+ }
1290
+ ast.styles.forEach((tuple) => {
1291
+ if (typeof tuple === "string") return;
1292
+ tuple.forEach((value, prop) => {
1293
+ if (typeof ngDevMode === "undefined" || ngDevMode) {
1294
+ if (!this._driver.validateStyleProperty(prop)) {
1295
+ tuple.delete(prop);
1296
+ context.unsupportedCSSPropertiesFound.add(prop);
1297
+ return;
1298
+ }
1299
+ }
1300
+ const collectedStyles = context.collectedStyles.get(context.currentQuerySelector);
1301
+ const collectedEntry = collectedStyles.get(prop);
1302
+ let updateCollectedStyle = true;
1303
+ if (collectedEntry) {
1304
+ if (startTime != endTime && startTime >= collectedEntry.startTime && endTime <= collectedEntry.endTime) {
1305
+ context.errors.push(invalidParallelAnimation(prop, collectedEntry.startTime, collectedEntry.endTime, startTime, endTime));
1306
+ updateCollectedStyle = false;
1307
+ }
1308
+ startTime = collectedEntry.startTime;
1309
+ }
1310
+ if (updateCollectedStyle) {
1311
+ collectedStyles.set(prop, {
1312
+ startTime,
1313
+ endTime
1314
+ });
1315
+ }
1316
+ if (context.options) {
1317
+ validateStyleParams(value, context.options, context.errors);
1318
+ }
1319
+ });
1320
+ });
1321
+ }
1322
+ visitKeyframes(metadata, context) {
1323
+ const ast = {
1324
+ type: AnimationMetadataType.Keyframes,
1325
+ styles: [],
1326
+ options: null
1327
+ };
1328
+ if (!context.currentAnimateTimings) {
1329
+ context.errors.push(invalidKeyframes());
1330
+ return ast;
1331
+ }
1332
+ const MAX_KEYFRAME_OFFSET = 1;
1333
+ let totalKeyframesWithOffsets = 0;
1334
+ const offsets = [];
1335
+ let offsetsOutOfOrder = false;
1336
+ let keyframesOutOfRange = false;
1337
+ let previousOffset = 0;
1338
+ const keyframes = metadata.steps.map((styles) => {
1339
+ const style2 = this._makeStyleAst(styles, context);
1340
+ let offsetVal = style2.offset != null ? style2.offset : consumeOffset(style2.styles);
1341
+ let offset = 0;
1342
+ if (offsetVal != null) {
1343
+ totalKeyframesWithOffsets++;
1344
+ offset = style2.offset = offsetVal;
1345
+ }
1346
+ keyframesOutOfRange = keyframesOutOfRange || offset < 0 || offset > 1;
1347
+ offsetsOutOfOrder = offsetsOutOfOrder || offset < previousOffset;
1348
+ previousOffset = offset;
1349
+ offsets.push(offset);
1350
+ return style2;
1351
+ });
1352
+ if (keyframesOutOfRange) {
1353
+ context.errors.push(invalidOffset());
1354
+ }
1355
+ if (offsetsOutOfOrder) {
1356
+ context.errors.push(keyframeOffsetsOutOfOrder());
1357
+ }
1358
+ const length = metadata.steps.length;
1359
+ let generatedOffset = 0;
1360
+ if (totalKeyframesWithOffsets > 0 && totalKeyframesWithOffsets < length) {
1361
+ context.errors.push(keyframesMissingOffsets());
1362
+ } else if (totalKeyframesWithOffsets == 0) {
1363
+ generatedOffset = MAX_KEYFRAME_OFFSET / (length - 1);
1364
+ }
1365
+ const limit = length - 1;
1366
+ const currentTime = context.currentTime;
1367
+ const currentAnimateTimings = context.currentAnimateTimings;
1368
+ const animateDuration = currentAnimateTimings.duration;
1369
+ keyframes.forEach((kf, i) => {
1370
+ const offset = generatedOffset > 0 ? i == limit ? 1 : generatedOffset * i : offsets[i];
1371
+ const durationUpToThisFrame = offset * animateDuration;
1372
+ context.currentTime = currentTime + currentAnimateTimings.delay + durationUpToThisFrame;
1373
+ currentAnimateTimings.duration = durationUpToThisFrame;
1374
+ this._validateStyleAst(kf, context);
1375
+ kf.offset = offset;
1376
+ ast.styles.push(kf);
1377
+ });
1378
+ return ast;
1379
+ }
1380
+ visitReference(metadata, context) {
1381
+ return {
1382
+ type: AnimationMetadataType.Reference,
1383
+ animation: visitDslNode(this, normalizeAnimationEntry(metadata.animation), context),
1384
+ options: normalizeAnimationOptions(metadata.options)
1385
+ };
1386
+ }
1387
+ visitAnimateChild(metadata, context) {
1388
+ context.depCount++;
1389
+ return {
1390
+ type: AnimationMetadataType.AnimateChild,
1391
+ options: normalizeAnimationOptions(metadata.options)
1392
+ };
1393
+ }
1394
+ visitAnimateRef(metadata, context) {
1395
+ return {
1396
+ type: AnimationMetadataType.AnimateRef,
1397
+ animation: this.visitReference(metadata.animation, context),
1398
+ options: normalizeAnimationOptions(metadata.options)
1399
+ };
1400
+ }
1401
+ visitQuery(metadata, context) {
1402
+ const parentSelector = context.currentQuerySelector;
1403
+ const options = metadata.options || {};
1404
+ context.queryCount++;
1405
+ context.currentQuery = metadata;
1406
+ const [selector, includeSelf] = normalizeSelector(metadata.selector);
1407
+ context.currentQuerySelector = parentSelector.length ? parentSelector + " " + selector : selector;
1408
+ getOrSetDefaultValue(context.collectedStyles, context.currentQuerySelector, /* @__PURE__ */ new Map());
1409
+ const animation = visitDslNode(this, normalizeAnimationEntry(metadata.animation), context);
1410
+ context.currentQuery = null;
1411
+ context.currentQuerySelector = parentSelector;
1412
+ return {
1413
+ type: AnimationMetadataType.Query,
1414
+ selector,
1415
+ limit: options.limit || 0,
1416
+ optional: !!options.optional,
1417
+ includeSelf,
1418
+ animation,
1419
+ originalSelector: metadata.selector,
1420
+ options: normalizeAnimationOptions(metadata.options)
1421
+ };
1422
+ }
1423
+ visitStagger(metadata, context) {
1424
+ if (!context.currentQuery) {
1425
+ context.errors.push(invalidStagger());
1426
+ }
1427
+ const timings = metadata.timings === "full" ? {
1428
+ duration: 0,
1429
+ delay: 0,
1430
+ easing: "full"
1431
+ } : resolveTiming(metadata.timings, context.errors, true);
1432
+ return {
1433
+ type: AnimationMetadataType.Stagger,
1434
+ animation: visitDslNode(this, normalizeAnimationEntry(metadata.animation), context),
1435
+ timings,
1436
+ options: null
1437
+ };
1438
+ }
1439
+ };
1440
+ function normalizeSelector(selector) {
1441
+ const hasAmpersand = selector.split(/\s*,\s*/).find((token) => token == SELF_TOKEN) ? true : false;
1442
+ if (hasAmpersand) {
1443
+ selector = selector.replace(SELF_TOKEN_REGEX, "");
1444
+ }
1445
+ selector = selector.replace(/@\*/g, NG_TRIGGER_SELECTOR).replace(/@\w+/g, (match) => NG_TRIGGER_SELECTOR + "-" + match.slice(1)).replace(/:animating/g, NG_ANIMATING_SELECTOR);
1446
+ return [selector, hasAmpersand];
1447
+ }
1448
+ function normalizeParams(obj) {
1449
+ return obj ? __spreadValues({}, obj) : null;
1450
+ }
1451
+ var AnimationAstBuilderContext = class {
1452
+ errors;
1453
+ queryCount = 0;
1454
+ depCount = 0;
1455
+ currentTransition = null;
1456
+ currentQuery = null;
1457
+ currentQuerySelector = null;
1458
+ currentAnimateTimings = null;
1459
+ currentTime = 0;
1460
+ collectedStyles = /* @__PURE__ */ new Map();
1461
+ options = null;
1462
+ unsupportedCSSPropertiesFound = /* @__PURE__ */ new Set();
1463
+ constructor(errors) {
1464
+ this.errors = errors;
1465
+ }
1466
+ };
1467
+ function consumeOffset(styles) {
1468
+ if (typeof styles == "string") return null;
1469
+ let offset = null;
1470
+ if (Array.isArray(styles)) {
1471
+ styles.forEach((styleTuple) => {
1472
+ if (styleTuple instanceof Map && styleTuple.has("offset")) {
1473
+ const obj = styleTuple;
1474
+ offset = parseFloat(obj.get("offset"));
1475
+ obj.delete("offset");
1476
+ }
1477
+ });
1478
+ } else if (styles instanceof Map && styles.has("offset")) {
1479
+ const obj = styles;
1480
+ offset = parseFloat(obj.get("offset"));
1481
+ obj.delete("offset");
1482
+ }
1483
+ return offset;
1484
+ }
1485
+ function constructTimingAst(value, errors) {
1486
+ if (value.hasOwnProperty("duration")) {
1487
+ return value;
1488
+ }
1489
+ if (typeof value == "number") {
1490
+ const duration = resolveTiming(value, errors).duration;
1491
+ return makeTimingAst(duration, 0, "");
1492
+ }
1493
+ const strValue = value;
1494
+ const isDynamic = strValue.split(/\s+/).some((v) => v.charAt(0) == "{" && v.charAt(1) == "{");
1495
+ if (isDynamic) {
1496
+ const ast = makeTimingAst(0, 0, "");
1497
+ ast.dynamic = true;
1498
+ ast.strValue = strValue;
1499
+ return ast;
1500
+ }
1501
+ const timings = resolveTiming(strValue, errors);
1502
+ return makeTimingAst(timings.duration, timings.delay, timings.easing);
1503
+ }
1504
+ function normalizeAnimationOptions(options) {
1505
+ if (options) {
1506
+ options = __spreadValues({}, options);
1507
+ if (options["params"]) {
1508
+ options["params"] = normalizeParams(options["params"]);
1509
+ }
1510
+ } else {
1511
+ options = {};
1512
+ }
1513
+ return options;
1514
+ }
1515
+ function makeTimingAst(duration, delay, easing) {
1516
+ return {
1517
+ duration,
1518
+ delay,
1519
+ easing
1520
+ };
1521
+ }
1522
+ function createTimelineInstruction(element, keyframes, preStyleProps, postStyleProps, duration, delay, easing = null, subTimeline = false) {
1523
+ return {
1524
+ type: 1,
1525
+ element,
1526
+ keyframes,
1527
+ preStyleProps,
1528
+ postStyleProps,
1529
+ duration,
1530
+ delay,
1531
+ totalTime: duration + delay,
1532
+ easing,
1533
+ subTimeline
1534
+ };
1535
+ }
1536
+ var ElementInstructionMap = class {
1537
+ _map = /* @__PURE__ */ new Map();
1538
+ get(element) {
1539
+ return this._map.get(element) || [];
1540
+ }
1541
+ append(element, instructions) {
1542
+ let existingInstructions = this._map.get(element);
1543
+ if (!existingInstructions) {
1544
+ this._map.set(element, existingInstructions = []);
1545
+ }
1546
+ existingInstructions.push(...instructions);
1547
+ }
1548
+ has(element) {
1549
+ return this._map.has(element);
1550
+ }
1551
+ clear() {
1552
+ this._map.clear();
1553
+ }
1554
+ };
1555
+ var ONE_FRAME_IN_MILLISECONDS = 1;
1556
+ var ENTER_TOKEN = ":enter";
1557
+ var ENTER_TOKEN_REGEX = new RegExp(ENTER_TOKEN, "g");
1558
+ var LEAVE_TOKEN = ":leave";
1559
+ var LEAVE_TOKEN_REGEX = new RegExp(LEAVE_TOKEN, "g");
1560
+ function buildAnimationTimelines(driver, rootElement, ast, enterClassName, leaveClassName, startingStyles = /* @__PURE__ */ new Map(), finalStyles = /* @__PURE__ */ new Map(), options, subInstructions, errors = []) {
1561
+ return new AnimationTimelineBuilderVisitor().buildKeyframes(driver, rootElement, ast, enterClassName, leaveClassName, startingStyles, finalStyles, options, subInstructions, errors);
1562
+ }
1563
+ var AnimationTimelineBuilderVisitor = class {
1564
+ buildKeyframes(driver, rootElement, ast, enterClassName, leaveClassName, startingStyles, finalStyles, options, subInstructions, errors = []) {
1565
+ subInstructions = subInstructions || new ElementInstructionMap();
1566
+ const context = new AnimationTimelineContext(driver, rootElement, subInstructions, enterClassName, leaveClassName, errors, []);
1567
+ context.options = options;
1568
+ const delay = options.delay ? resolveTimingValue(options.delay) : 0;
1569
+ context.currentTimeline.delayNextStep(delay);
1570
+ context.currentTimeline.setStyles([startingStyles], null, context.errors, options);
1571
+ visitDslNode(this, ast, context);
1572
+ const timelines = context.timelines.filter((timeline) => timeline.containsAnimation());
1573
+ if (timelines.length && finalStyles.size) {
1574
+ let lastRootTimeline;
1575
+ for (let i = timelines.length - 1; i >= 0; i--) {
1576
+ const timeline = timelines[i];
1577
+ if (timeline.element === rootElement) {
1578
+ lastRootTimeline = timeline;
1579
+ break;
1580
+ }
1581
+ }
1582
+ if (lastRootTimeline && !lastRootTimeline.allowOnlyTimelineStyles()) {
1583
+ lastRootTimeline.setStyles([finalStyles], null, context.errors, options);
1584
+ }
1585
+ }
1586
+ return timelines.length ? timelines.map((timeline) => timeline.buildKeyframes()) : [createTimelineInstruction(rootElement, [], [], [], 0, delay, "", false)];
1587
+ }
1588
+ visitTrigger(ast, context) {
1589
+ }
1590
+ visitState(ast, context) {
1591
+ }
1592
+ visitTransition(ast, context) {
1593
+ }
1594
+ visitAnimateChild(ast, context) {
1595
+ const elementInstructions = context.subInstructions.get(context.element);
1596
+ if (elementInstructions) {
1597
+ const innerContext = context.createSubContext(ast.options);
1598
+ const startTime = context.currentTimeline.currentTime;
1599
+ const endTime = this._visitSubInstructions(elementInstructions, innerContext, innerContext.options);
1600
+ if (startTime != endTime) {
1601
+ context.transformIntoNewTimeline(endTime);
1602
+ }
1603
+ }
1604
+ context.previousNode = ast;
1605
+ }
1606
+ visitAnimateRef(ast, context) {
1607
+ const innerContext = context.createSubContext(ast.options);
1608
+ innerContext.transformIntoNewTimeline();
1609
+ this._applyAnimationRefDelays([ast.options, ast.animation.options], context, innerContext);
1610
+ this.visitReference(ast.animation, innerContext);
1611
+ context.transformIntoNewTimeline(innerContext.currentTimeline.currentTime);
1612
+ context.previousNode = ast;
1613
+ }
1614
+ _applyAnimationRefDelays(animationsRefsOptions, context, innerContext) {
1615
+ for (const animationRefOptions of animationsRefsOptions) {
1616
+ const animationDelay = animationRefOptions?.delay;
1617
+ if (animationDelay) {
1618
+ const animationDelayValue = typeof animationDelay === "number" ? animationDelay : resolveTimingValue(interpolateParams(animationDelay, animationRefOptions?.params ?? {}, context.errors));
1619
+ innerContext.delayNextStep(animationDelayValue);
1620
+ }
1621
+ }
1622
+ }
1623
+ _visitSubInstructions(instructions, context, options) {
1624
+ const startTime = context.currentTimeline.currentTime;
1625
+ let furthestTime = startTime;
1626
+ const duration = options.duration != null ? resolveTimingValue(options.duration) : null;
1627
+ const delay = options.delay != null ? resolveTimingValue(options.delay) : null;
1628
+ if (duration !== 0) {
1629
+ instructions.forEach((instruction) => {
1630
+ const instructionTimings = context.appendInstructionToTimeline(instruction, duration, delay);
1631
+ furthestTime = Math.max(furthestTime, instructionTimings.duration + instructionTimings.delay);
1632
+ });
1633
+ }
1634
+ return furthestTime;
1635
+ }
1636
+ visitReference(ast, context) {
1637
+ context.updateOptions(ast.options, true);
1638
+ visitDslNode(this, ast.animation, context);
1639
+ context.previousNode = ast;
1640
+ }
1641
+ visitSequence(ast, context) {
1642
+ const subContextCount = context.subContextCount;
1643
+ let ctx = context;
1644
+ const options = ast.options;
1645
+ if (options && (options.params || options.delay)) {
1646
+ ctx = context.createSubContext(options);
1647
+ ctx.transformIntoNewTimeline();
1648
+ if (options.delay != null) {
1649
+ if (ctx.previousNode.type == AnimationMetadataType.Style) {
1650
+ ctx.currentTimeline.snapshotCurrentStyles();
1651
+ ctx.previousNode = DEFAULT_NOOP_PREVIOUS_NODE;
1652
+ }
1653
+ const delay = resolveTimingValue(options.delay);
1654
+ ctx.delayNextStep(delay);
1655
+ }
1656
+ }
1657
+ if (ast.steps.length) {
1658
+ ast.steps.forEach((s) => visitDslNode(this, s, ctx));
1659
+ ctx.currentTimeline.applyStylesToKeyframe();
1660
+ if (ctx.subContextCount > subContextCount) {
1661
+ ctx.transformIntoNewTimeline();
1662
+ }
1663
+ }
1664
+ context.previousNode = ast;
1665
+ }
1666
+ visitGroup(ast, context) {
1667
+ const innerTimelines = [];
1668
+ let furthestTime = context.currentTimeline.currentTime;
1669
+ const delay = ast.options && ast.options.delay ? resolveTimingValue(ast.options.delay) : 0;
1670
+ ast.steps.forEach((s) => {
1671
+ const innerContext = context.createSubContext(ast.options);
1672
+ if (delay) {
1673
+ innerContext.delayNextStep(delay);
1674
+ }
1675
+ visitDslNode(this, s, innerContext);
1676
+ furthestTime = Math.max(furthestTime, innerContext.currentTimeline.currentTime);
1677
+ innerTimelines.push(innerContext.currentTimeline);
1678
+ });
1679
+ innerTimelines.forEach((timeline) => context.currentTimeline.mergeTimelineCollectedStyles(timeline));
1680
+ context.transformIntoNewTimeline(furthestTime);
1681
+ context.previousNode = ast;
1682
+ }
1683
+ _visitTiming(ast, context) {
1684
+ if (ast.dynamic) {
1685
+ const strValue = ast.strValue;
1686
+ const timingValue = context.params ? interpolateParams(strValue, context.params, context.errors) : strValue;
1687
+ return resolveTiming(timingValue, context.errors);
1688
+ } else {
1689
+ return {
1690
+ duration: ast.duration,
1691
+ delay: ast.delay,
1692
+ easing: ast.easing
1693
+ };
1694
+ }
1695
+ }
1696
+ visitAnimate(ast, context) {
1697
+ const timings = context.currentAnimateTimings = this._visitTiming(ast.timings, context);
1698
+ const timeline = context.currentTimeline;
1699
+ if (timings.delay) {
1700
+ context.incrementTime(timings.delay);
1701
+ timeline.snapshotCurrentStyles();
1702
+ }
1703
+ const style2 = ast.style;
1704
+ if (style2.type == AnimationMetadataType.Keyframes) {
1705
+ this.visitKeyframes(style2, context);
1706
+ } else {
1707
+ context.incrementTime(timings.duration);
1708
+ this.visitStyle(style2, context);
1709
+ timeline.applyStylesToKeyframe();
1710
+ }
1711
+ context.currentAnimateTimings = null;
1712
+ context.previousNode = ast;
1713
+ }
1714
+ visitStyle(ast, context) {
1715
+ const timeline = context.currentTimeline;
1716
+ const timings = context.currentAnimateTimings;
1717
+ if (!timings && timeline.hasCurrentStyleProperties()) {
1718
+ timeline.forwardFrame();
1719
+ }
1720
+ const easing = timings && timings.easing || ast.easing;
1721
+ if (ast.isEmptyStep) {
1722
+ timeline.applyEmptyStep(easing);
1723
+ } else {
1724
+ timeline.setStyles(ast.styles, easing, context.errors, context.options);
1725
+ }
1726
+ context.previousNode = ast;
1727
+ }
1728
+ visitKeyframes(ast, context) {
1729
+ const currentAnimateTimings = context.currentAnimateTimings;
1730
+ const startTime = context.currentTimeline.duration;
1731
+ const duration = currentAnimateTimings.duration;
1732
+ const innerContext = context.createSubContext();
1733
+ const innerTimeline = innerContext.currentTimeline;
1734
+ innerTimeline.easing = currentAnimateTimings.easing;
1735
+ ast.styles.forEach((step) => {
1736
+ const offset = step.offset || 0;
1737
+ innerTimeline.forwardTime(offset * duration);
1738
+ innerTimeline.setStyles(step.styles, step.easing, context.errors, context.options);
1739
+ innerTimeline.applyStylesToKeyframe();
1740
+ });
1741
+ context.currentTimeline.mergeTimelineCollectedStyles(innerTimeline);
1742
+ context.transformIntoNewTimeline(startTime + duration);
1743
+ context.previousNode = ast;
1744
+ }
1745
+ visitQuery(ast, context) {
1746
+ const startTime = context.currentTimeline.currentTime;
1747
+ const options = ast.options || {};
1748
+ const delay = options.delay ? resolveTimingValue(options.delay) : 0;
1749
+ if (delay && (context.previousNode.type === AnimationMetadataType.Style || startTime == 0 && context.currentTimeline.hasCurrentStyleProperties())) {
1750
+ context.currentTimeline.snapshotCurrentStyles();
1751
+ context.previousNode = DEFAULT_NOOP_PREVIOUS_NODE;
1752
+ }
1753
+ let furthestTime = startTime;
1754
+ const elms = context.invokeQuery(ast.selector, ast.originalSelector, ast.limit, ast.includeSelf, options.optional ? true : false, context.errors);
1755
+ context.currentQueryTotal = elms.length;
1756
+ let sameElementTimeline = null;
1757
+ elms.forEach((element, i) => {
1758
+ context.currentQueryIndex = i;
1759
+ const innerContext = context.createSubContext(ast.options, element);
1760
+ if (delay) {
1761
+ innerContext.delayNextStep(delay);
1762
+ }
1763
+ if (element === context.element) {
1764
+ sameElementTimeline = innerContext.currentTimeline;
1765
+ }
1766
+ visitDslNode(this, ast.animation, innerContext);
1767
+ innerContext.currentTimeline.applyStylesToKeyframe();
1768
+ const endTime = innerContext.currentTimeline.currentTime;
1769
+ furthestTime = Math.max(furthestTime, endTime);
1770
+ });
1771
+ context.currentQueryIndex = 0;
1772
+ context.currentQueryTotal = 0;
1773
+ context.transformIntoNewTimeline(furthestTime);
1774
+ if (sameElementTimeline) {
1775
+ context.currentTimeline.mergeTimelineCollectedStyles(sameElementTimeline);
1776
+ context.currentTimeline.snapshotCurrentStyles();
1777
+ }
1778
+ context.previousNode = ast;
1779
+ }
1780
+ visitStagger(ast, context) {
1781
+ const parentContext = context.parentContext;
1782
+ const tl = context.currentTimeline;
1783
+ const timings = ast.timings;
1784
+ const duration = Math.abs(timings.duration);
1785
+ const maxTime = duration * (context.currentQueryTotal - 1);
1786
+ let delay = duration * context.currentQueryIndex;
1787
+ let staggerTransformer = timings.duration < 0 ? "reverse" : timings.easing;
1788
+ switch (staggerTransformer) {
1789
+ case "reverse":
1790
+ delay = maxTime - delay;
1791
+ break;
1792
+ case "full":
1793
+ delay = parentContext.currentStaggerTime;
1794
+ break;
1795
+ }
1796
+ const timeline = context.currentTimeline;
1797
+ if (delay) {
1798
+ timeline.delayNextStep(delay);
1799
+ }
1800
+ const startingTime = timeline.currentTime;
1801
+ visitDslNode(this, ast.animation, context);
1802
+ context.previousNode = ast;
1803
+ parentContext.currentStaggerTime = tl.currentTime - startingTime + (tl.startTime - parentContext.currentTimeline.startTime);
1804
+ }
1805
+ };
1806
+ var DEFAULT_NOOP_PREVIOUS_NODE = {};
1807
+ var AnimationTimelineContext = class _AnimationTimelineContext {
1808
+ _driver;
1809
+ element;
1810
+ subInstructions;
1811
+ _enterClassName;
1812
+ _leaveClassName;
1813
+ errors;
1814
+ timelines;
1815
+ parentContext = null;
1816
+ currentTimeline;
1817
+ currentAnimateTimings = null;
1818
+ previousNode = DEFAULT_NOOP_PREVIOUS_NODE;
1819
+ subContextCount = 0;
1820
+ options = {};
1821
+ currentQueryIndex = 0;
1822
+ currentQueryTotal = 0;
1823
+ currentStaggerTime = 0;
1824
+ constructor(_driver, element, subInstructions, _enterClassName, _leaveClassName, errors, timelines, initialTimeline) {
1825
+ this._driver = _driver;
1826
+ this.element = element;
1827
+ this.subInstructions = subInstructions;
1828
+ this._enterClassName = _enterClassName;
1829
+ this._leaveClassName = _leaveClassName;
1830
+ this.errors = errors;
1831
+ this.timelines = timelines;
1832
+ this.currentTimeline = initialTimeline || new TimelineBuilder(this._driver, element, 0);
1833
+ timelines.push(this.currentTimeline);
1834
+ }
1835
+ get params() {
1836
+ return this.options.params;
1837
+ }
1838
+ updateOptions(options, skipIfExists) {
1839
+ if (!options) return;
1840
+ const newOptions = options;
1841
+ let optionsToUpdate = this.options;
1842
+ if (newOptions.duration != null) {
1843
+ optionsToUpdate.duration = resolveTimingValue(newOptions.duration);
1844
+ }
1845
+ if (newOptions.delay != null) {
1846
+ optionsToUpdate.delay = resolveTimingValue(newOptions.delay);
1847
+ }
1848
+ const newParams = newOptions.params;
1849
+ if (newParams) {
1850
+ let paramsToUpdate = optionsToUpdate.params;
1851
+ if (!paramsToUpdate) {
1852
+ paramsToUpdate = this.options.params = {};
1853
+ }
1854
+ Object.keys(newParams).forEach((name) => {
1855
+ if (!skipIfExists || !paramsToUpdate.hasOwnProperty(name)) {
1856
+ paramsToUpdate[name] = interpolateParams(newParams[name], paramsToUpdate, this.errors);
1857
+ }
1858
+ });
1859
+ }
1860
+ }
1861
+ _copyOptions() {
1862
+ const options = {};
1863
+ if (this.options) {
1864
+ const oldParams = this.options.params;
1865
+ if (oldParams) {
1866
+ const params = options["params"] = {};
1867
+ Object.keys(oldParams).forEach((name) => {
1868
+ params[name] = oldParams[name];
1869
+ });
1870
+ }
1871
+ }
1872
+ return options;
1873
+ }
1874
+ createSubContext(options = null, element, newTime) {
1875
+ const target = element || this.element;
1876
+ const context = new _AnimationTimelineContext(this._driver, target, this.subInstructions, this._enterClassName, this._leaveClassName, this.errors, this.timelines, this.currentTimeline.fork(target, newTime || 0));
1877
+ context.previousNode = this.previousNode;
1878
+ context.currentAnimateTimings = this.currentAnimateTimings;
1879
+ context.options = this._copyOptions();
1880
+ context.updateOptions(options);
1881
+ context.currentQueryIndex = this.currentQueryIndex;
1882
+ context.currentQueryTotal = this.currentQueryTotal;
1883
+ context.parentContext = this;
1884
+ this.subContextCount++;
1885
+ return context;
1886
+ }
1887
+ transformIntoNewTimeline(newTime) {
1888
+ this.previousNode = DEFAULT_NOOP_PREVIOUS_NODE;
1889
+ this.currentTimeline = this.currentTimeline.fork(this.element, newTime);
1890
+ this.timelines.push(this.currentTimeline);
1891
+ return this.currentTimeline;
1892
+ }
1893
+ appendInstructionToTimeline(instruction, duration, delay) {
1894
+ const updatedTimings = {
1895
+ duration: duration != null ? duration : instruction.duration,
1896
+ delay: this.currentTimeline.currentTime + (delay != null ? delay : 0) + instruction.delay,
1897
+ easing: ""
1898
+ };
1899
+ const builder = new SubTimelineBuilder(this._driver, instruction.element, instruction.keyframes, instruction.preStyleProps, instruction.postStyleProps, updatedTimings, instruction.stretchStartingKeyframe);
1900
+ this.timelines.push(builder);
1901
+ return updatedTimings;
1902
+ }
1903
+ incrementTime(time) {
1904
+ this.currentTimeline.forwardTime(this.currentTimeline.duration + time);
1905
+ }
1906
+ delayNextStep(delay) {
1907
+ if (delay > 0) {
1908
+ this.currentTimeline.delayNextStep(delay);
1909
+ }
1910
+ }
1911
+ invokeQuery(selector, originalSelector, limit, includeSelf, optional, errors) {
1912
+ let results = [];
1913
+ if (includeSelf) {
1914
+ results.push(this.element);
1915
+ }
1916
+ if (selector.length > 0) {
1917
+ selector = selector.replace(ENTER_TOKEN_REGEX, "." + this._enterClassName);
1918
+ selector = selector.replace(LEAVE_TOKEN_REGEX, "." + this._leaveClassName);
1919
+ const multi = limit != 1;
1920
+ let elements = this._driver.query(this.element, selector, multi);
1921
+ if (limit !== 0) {
1922
+ elements = limit < 0 ? elements.slice(elements.length + limit, elements.length) : elements.slice(0, limit);
1923
+ }
1924
+ results.push(...elements);
1925
+ }
1926
+ if (!optional && results.length == 0) {
1927
+ errors.push(invalidQuery(originalSelector));
1928
+ }
1929
+ return results;
1930
+ }
1931
+ };
1932
+ var TimelineBuilder = class _TimelineBuilder {
1933
+ _driver;
1934
+ element;
1935
+ startTime;
1936
+ _elementTimelineStylesLookup;
1937
+ duration = 0;
1938
+ easing = null;
1939
+ _previousKeyframe = /* @__PURE__ */ new Map();
1940
+ _currentKeyframe = /* @__PURE__ */ new Map();
1941
+ _keyframes = /* @__PURE__ */ new Map();
1942
+ _styleSummary = /* @__PURE__ */ new Map();
1943
+ _localTimelineStyles = /* @__PURE__ */ new Map();
1944
+ _globalTimelineStyles;
1945
+ _pendingStyles = /* @__PURE__ */ new Map();
1946
+ _backFill = /* @__PURE__ */ new Map();
1947
+ _currentEmptyStepKeyframe = null;
1948
+ constructor(_driver, element, startTime, _elementTimelineStylesLookup) {
1949
+ this._driver = _driver;
1950
+ this.element = element;
1951
+ this.startTime = startTime;
1952
+ this._elementTimelineStylesLookup = _elementTimelineStylesLookup;
1953
+ if (!this._elementTimelineStylesLookup) {
1954
+ this._elementTimelineStylesLookup = /* @__PURE__ */ new Map();
1955
+ }
1956
+ this._globalTimelineStyles = this._elementTimelineStylesLookup.get(element);
1957
+ if (!this._globalTimelineStyles) {
1958
+ this._globalTimelineStyles = this._localTimelineStyles;
1959
+ this._elementTimelineStylesLookup.set(element, this._localTimelineStyles);
1960
+ }
1961
+ this._loadKeyframe();
1962
+ }
1963
+ containsAnimation() {
1964
+ switch (this._keyframes.size) {
1965
+ case 0:
1966
+ return false;
1967
+ case 1:
1968
+ return this.hasCurrentStyleProperties();
1969
+ default:
1970
+ return true;
1971
+ }
1972
+ }
1973
+ hasCurrentStyleProperties() {
1974
+ return this._currentKeyframe.size > 0;
1975
+ }
1976
+ get currentTime() {
1977
+ return this.startTime + this.duration;
1978
+ }
1979
+ delayNextStep(delay) {
1980
+ const hasPreStyleStep = this._keyframes.size === 1 && this._pendingStyles.size;
1981
+ if (this.duration || hasPreStyleStep) {
1982
+ this.forwardTime(this.currentTime + delay);
1983
+ if (hasPreStyleStep) {
1984
+ this.snapshotCurrentStyles();
1985
+ }
1986
+ } else {
1987
+ this.startTime += delay;
1988
+ }
1989
+ }
1990
+ fork(element, currentTime) {
1991
+ this.applyStylesToKeyframe();
1992
+ return new _TimelineBuilder(this._driver, element, currentTime || this.currentTime, this._elementTimelineStylesLookup);
1993
+ }
1994
+ _loadKeyframe() {
1995
+ if (this._currentKeyframe) {
1996
+ this._previousKeyframe = this._currentKeyframe;
1997
+ }
1998
+ this._currentKeyframe = this._keyframes.get(this.duration);
1999
+ if (!this._currentKeyframe) {
2000
+ this._currentKeyframe = /* @__PURE__ */ new Map();
2001
+ this._keyframes.set(this.duration, this._currentKeyframe);
2002
+ }
2003
+ }
2004
+ forwardFrame() {
2005
+ this.duration += ONE_FRAME_IN_MILLISECONDS;
2006
+ this._loadKeyframe();
2007
+ }
2008
+ forwardTime(time) {
2009
+ this.applyStylesToKeyframe();
2010
+ this.duration = time;
2011
+ this._loadKeyframe();
2012
+ }
2013
+ _updateStyle(prop, value) {
2014
+ this._localTimelineStyles.set(prop, value);
2015
+ this._globalTimelineStyles.set(prop, value);
2016
+ this._styleSummary.set(prop, {
2017
+ time: this.currentTime,
2018
+ value
2019
+ });
2020
+ }
2021
+ allowOnlyTimelineStyles() {
2022
+ return this._currentEmptyStepKeyframe !== this._currentKeyframe;
2023
+ }
2024
+ applyEmptyStep(easing) {
2025
+ if (easing) {
2026
+ this._previousKeyframe.set("easing", easing);
2027
+ }
2028
+ for (let [prop, value] of this._globalTimelineStyles) {
2029
+ this._backFill.set(prop, value || AUTO_STYLE);
2030
+ this._currentKeyframe.set(prop, AUTO_STYLE);
2031
+ }
2032
+ this._currentEmptyStepKeyframe = this._currentKeyframe;
2033
+ }
2034
+ setStyles(input, easing, errors, options) {
2035
+ if (easing) {
2036
+ this._previousKeyframe.set("easing", easing);
2037
+ }
2038
+ const params = options && options.params || {};
2039
+ const styles = flattenStyles(input, this._globalTimelineStyles);
2040
+ for (let [prop, value] of styles) {
2041
+ const val = interpolateParams(value, params, errors);
2042
+ this._pendingStyles.set(prop, val);
2043
+ if (!this._localTimelineStyles.has(prop)) {
2044
+ this._backFill.set(prop, this._globalTimelineStyles.get(prop) ?? AUTO_STYLE);
2045
+ }
2046
+ this._updateStyle(prop, val);
2047
+ }
2048
+ }
2049
+ applyStylesToKeyframe() {
2050
+ if (this._pendingStyles.size == 0) return;
2051
+ this._pendingStyles.forEach((val, prop) => {
2052
+ this._currentKeyframe.set(prop, val);
2053
+ });
2054
+ this._pendingStyles.clear();
2055
+ this._localTimelineStyles.forEach((val, prop) => {
2056
+ if (!this._currentKeyframe.has(prop)) {
2057
+ this._currentKeyframe.set(prop, val);
2058
+ }
2059
+ });
2060
+ }
2061
+ snapshotCurrentStyles() {
2062
+ for (let [prop, val] of this._localTimelineStyles) {
2063
+ this._pendingStyles.set(prop, val);
2064
+ this._updateStyle(prop, val);
2065
+ }
2066
+ }
2067
+ getFinalKeyframe() {
2068
+ return this._keyframes.get(this.duration);
2069
+ }
2070
+ get properties() {
2071
+ const properties = [];
2072
+ for (let prop in this._currentKeyframe) {
2073
+ properties.push(prop);
2074
+ }
2075
+ return properties;
2076
+ }
2077
+ mergeTimelineCollectedStyles(timeline) {
2078
+ timeline._styleSummary.forEach((details1, prop) => {
2079
+ const details0 = this._styleSummary.get(prop);
2080
+ if (!details0 || details1.time > details0.time) {
2081
+ this._updateStyle(prop, details1.value);
2082
+ }
2083
+ });
2084
+ }
2085
+ buildKeyframes() {
2086
+ this.applyStylesToKeyframe();
2087
+ const preStyleProps = /* @__PURE__ */ new Set();
2088
+ const postStyleProps = /* @__PURE__ */ new Set();
2089
+ const isEmpty = this._keyframes.size === 1 && this.duration === 0;
2090
+ let finalKeyframes = [];
2091
+ this._keyframes.forEach((keyframe, time) => {
2092
+ const finalKeyframe = new Map([...this._backFill, ...keyframe]);
2093
+ finalKeyframe.forEach((value, prop) => {
2094
+ if (value === \u0275PRE_STYLE) {
2095
+ preStyleProps.add(prop);
2096
+ } else if (value === AUTO_STYLE) {
2097
+ postStyleProps.add(prop);
2098
+ }
2099
+ });
2100
+ if (!isEmpty) {
2101
+ finalKeyframe.set("offset", time / this.duration);
2102
+ }
2103
+ finalKeyframes.push(finalKeyframe);
2104
+ });
2105
+ const preProps = [...preStyleProps.values()];
2106
+ const postProps = [...postStyleProps.values()];
2107
+ if (isEmpty) {
2108
+ const kf0 = finalKeyframes[0];
2109
+ const kf1 = new Map(kf0);
2110
+ kf0.set("offset", 0);
2111
+ kf1.set("offset", 1);
2112
+ finalKeyframes = [kf0, kf1];
2113
+ }
2114
+ return createTimelineInstruction(this.element, finalKeyframes, preProps, postProps, this.duration, this.startTime, this.easing, false);
2115
+ }
2116
+ };
2117
+ var SubTimelineBuilder = class extends TimelineBuilder {
2118
+ keyframes;
2119
+ preStyleProps;
2120
+ postStyleProps;
2121
+ _stretchStartingKeyframe;
2122
+ timings;
2123
+ constructor(driver, element, keyframes, preStyleProps, postStyleProps, timings, _stretchStartingKeyframe = false) {
2124
+ super(driver, element, timings.delay);
2125
+ this.keyframes = keyframes;
2126
+ this.preStyleProps = preStyleProps;
2127
+ this.postStyleProps = postStyleProps;
2128
+ this._stretchStartingKeyframe = _stretchStartingKeyframe;
2129
+ this.timings = {
2130
+ duration: timings.duration,
2131
+ delay: timings.delay,
2132
+ easing: timings.easing
2133
+ };
2134
+ }
2135
+ containsAnimation() {
2136
+ return this.keyframes.length > 1;
2137
+ }
2138
+ buildKeyframes() {
2139
+ let keyframes = this.keyframes;
2140
+ let {
2141
+ delay,
2142
+ duration,
2143
+ easing
2144
+ } = this.timings;
2145
+ if (this._stretchStartingKeyframe && delay) {
2146
+ const newKeyframes = [];
2147
+ const totalTime = duration + delay;
2148
+ const startingGap = delay / totalTime;
2149
+ const newFirstKeyframe = new Map(keyframes[0]);
2150
+ newFirstKeyframe.set("offset", 0);
2151
+ newKeyframes.push(newFirstKeyframe);
2152
+ const oldFirstKeyframe = new Map(keyframes[0]);
2153
+ oldFirstKeyframe.set("offset", roundOffset(startingGap));
2154
+ newKeyframes.push(oldFirstKeyframe);
2155
+ const limit = keyframes.length - 1;
2156
+ for (let i = 1; i <= limit; i++) {
2157
+ let kf = new Map(keyframes[i]);
2158
+ const oldOffset = kf.get("offset");
2159
+ const timeAtKeyframe = delay + oldOffset * duration;
2160
+ kf.set("offset", roundOffset(timeAtKeyframe / totalTime));
2161
+ newKeyframes.push(kf);
2162
+ }
2163
+ duration = totalTime;
2164
+ delay = 0;
2165
+ easing = "";
2166
+ keyframes = newKeyframes;
2167
+ }
2168
+ return createTimelineInstruction(this.element, keyframes, this.preStyleProps, this.postStyleProps, duration, delay, easing, true);
2169
+ }
2170
+ };
2171
+ function roundOffset(offset, decimalPoints = 3) {
2172
+ const mult = Math.pow(10, decimalPoints - 1);
2173
+ return Math.round(offset * mult) / mult;
2174
+ }
2175
+ function flattenStyles(input, allStyles) {
2176
+ const styles = /* @__PURE__ */ new Map();
2177
+ let allProperties;
2178
+ input.forEach((token) => {
2179
+ if (token === "*") {
2180
+ allProperties ??= allStyles.keys();
2181
+ for (let prop of allProperties) {
2182
+ styles.set(prop, AUTO_STYLE);
2183
+ }
2184
+ } else {
2185
+ for (let [prop, val] of token) {
2186
+ styles.set(prop, val);
2187
+ }
2188
+ }
2189
+ });
2190
+ return styles;
2191
+ }
2192
+ function createTransitionInstruction(element, triggerName, fromState, toState, isRemovalTransition, fromStyles, toStyles, timelines, queriedElements, preStyleProps, postStyleProps, totalTime, errors) {
2193
+ return {
2194
+ type: 0,
2195
+ element,
2196
+ triggerName,
2197
+ isRemovalTransition,
2198
+ fromState,
2199
+ fromStyles,
2200
+ toState,
2201
+ toStyles,
2202
+ timelines,
2203
+ queriedElements,
2204
+ preStyleProps,
2205
+ postStyleProps,
2206
+ totalTime,
2207
+ errors
2208
+ };
2209
+ }
2210
+ var EMPTY_OBJECT = {};
2211
+ var AnimationTransitionFactory = class {
2212
+ _triggerName;
2213
+ ast;
2214
+ _stateStyles;
2215
+ constructor(_triggerName, ast, _stateStyles) {
2216
+ this._triggerName = _triggerName;
2217
+ this.ast = ast;
2218
+ this._stateStyles = _stateStyles;
2219
+ }
2220
+ match(currentState, nextState, element, params) {
2221
+ return oneOrMoreTransitionsMatch(this.ast.matchers, currentState, nextState, element, params);
2222
+ }
2223
+ buildStyles(stateName, params, errors) {
2224
+ let styler = this._stateStyles.get("*");
2225
+ if (stateName !== void 0) {
2226
+ styler = this._stateStyles.get(stateName?.toString()) || styler;
2227
+ }
2228
+ return styler ? styler.buildStyles(params, errors) : /* @__PURE__ */ new Map();
2229
+ }
2230
+ build(driver, element, currentState, nextState, enterClassName, leaveClassName, currentOptions, nextOptions, subInstructions, skipAstBuild) {
2231
+ const errors = [];
2232
+ const transitionAnimationParams = this.ast.options && this.ast.options.params || EMPTY_OBJECT;
2233
+ const currentAnimationParams = currentOptions && currentOptions.params || EMPTY_OBJECT;
2234
+ const currentStateStyles = this.buildStyles(currentState, currentAnimationParams, errors);
2235
+ const nextAnimationParams = nextOptions && nextOptions.params || EMPTY_OBJECT;
2236
+ const nextStateStyles = this.buildStyles(nextState, nextAnimationParams, errors);
2237
+ const queriedElements = /* @__PURE__ */ new Set();
2238
+ const preStyleMap = /* @__PURE__ */ new Map();
2239
+ const postStyleMap = /* @__PURE__ */ new Map();
2240
+ const isRemoval = nextState === "void";
2241
+ const animationOptions = {
2242
+ params: applyParamDefaults(nextAnimationParams, transitionAnimationParams),
2243
+ delay: this.ast.options?.delay
2244
+ };
2245
+ const timelines = skipAstBuild ? [] : buildAnimationTimelines(driver, element, this.ast.animation, enterClassName, leaveClassName, currentStateStyles, nextStateStyles, animationOptions, subInstructions, errors);
2246
+ let totalTime = 0;
2247
+ timelines.forEach((tl) => {
2248
+ totalTime = Math.max(tl.duration + tl.delay, totalTime);
2249
+ });
2250
+ if (errors.length) {
2251
+ return createTransitionInstruction(element, this._triggerName, currentState, nextState, isRemoval, currentStateStyles, nextStateStyles, [], [], preStyleMap, postStyleMap, totalTime, errors);
2252
+ }
2253
+ timelines.forEach((tl) => {
2254
+ const elm = tl.element;
2255
+ const preProps = getOrSetDefaultValue(preStyleMap, elm, /* @__PURE__ */ new Set());
2256
+ tl.preStyleProps.forEach((prop) => preProps.add(prop));
2257
+ const postProps = getOrSetDefaultValue(postStyleMap, elm, /* @__PURE__ */ new Set());
2258
+ tl.postStyleProps.forEach((prop) => postProps.add(prop));
2259
+ if (elm !== element) {
2260
+ queriedElements.add(elm);
2261
+ }
2262
+ });
2263
+ if (typeof ngDevMode === "undefined" || ngDevMode) {
2264
+ checkNonAnimatableInTimelines(timelines, this._triggerName, driver);
2265
+ }
2266
+ return createTransitionInstruction(element, this._triggerName, currentState, nextState, isRemoval, currentStateStyles, nextStateStyles, timelines, [...queriedElements.values()], preStyleMap, postStyleMap, totalTime);
2267
+ }
2268
+ };
2269
+ function checkNonAnimatableInTimelines(timelines, triggerName, driver) {
2270
+ if (!driver.validateAnimatableStyleProperty) {
2271
+ return;
2272
+ }
2273
+ const allowedNonAnimatableProps = /* @__PURE__ */ new Set([
2274
+ // 'easing' is a utility/synthetic prop we use to represent
2275
+ // easing functions, it represents a property of the animation
2276
+ // which is not animatable but different values can be used
2277
+ // in different steps
2278
+ "easing"
2279
+ ]);
2280
+ const invalidNonAnimatableProps = /* @__PURE__ */ new Set();
2281
+ timelines.forEach(({
2282
+ keyframes
2283
+ }) => {
2284
+ const nonAnimatablePropsInitialValues = /* @__PURE__ */ new Map();
2285
+ keyframes.forEach((keyframe) => {
2286
+ const entriesToCheck = Array.from(keyframe.entries()).filter(([prop]) => !allowedNonAnimatableProps.has(prop));
2287
+ for (const [prop, value] of entriesToCheck) {
2288
+ if (!driver.validateAnimatableStyleProperty(prop)) {
2289
+ if (nonAnimatablePropsInitialValues.has(prop) && !invalidNonAnimatableProps.has(prop)) {
2290
+ const propInitialValue = nonAnimatablePropsInitialValues.get(prop);
2291
+ if (propInitialValue !== value) {
2292
+ invalidNonAnimatableProps.add(prop);
2293
+ }
2294
+ } else {
2295
+ nonAnimatablePropsInitialValues.set(prop, value);
2296
+ }
2297
+ }
2298
+ }
2299
+ });
2300
+ });
2301
+ if (invalidNonAnimatableProps.size > 0) {
2302
+ console.warn(`Warning: The animation trigger "${triggerName}" is attempting to animate the following not animatable properties: ` + Array.from(invalidNonAnimatableProps).join(", ") + "\n(to check the list of all animatable properties visit https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_animated_properties)");
2303
+ }
2304
+ }
2305
+ function oneOrMoreTransitionsMatch(matchFns, currentState, nextState, element, params) {
2306
+ return matchFns.some((fn) => fn(currentState, nextState, element, params));
2307
+ }
2308
+ function applyParamDefaults(userParams, defaults) {
2309
+ const result = __spreadValues({}, defaults);
2310
+ Object.entries(userParams).forEach(([key, value]) => {
2311
+ if (value != null) {
2312
+ result[key] = value;
2313
+ }
2314
+ });
2315
+ return result;
2316
+ }
2317
+ var AnimationStateStyles = class {
2318
+ styles;
2319
+ defaultParams;
2320
+ normalizer;
2321
+ constructor(styles, defaultParams, normalizer) {
2322
+ this.styles = styles;
2323
+ this.defaultParams = defaultParams;
2324
+ this.normalizer = normalizer;
2325
+ }
2326
+ buildStyles(params, errors) {
2327
+ const finalStyles = /* @__PURE__ */ new Map();
2328
+ const combinedParams = applyParamDefaults(params, this.defaultParams);
2329
+ this.styles.styles.forEach((value) => {
2330
+ if (typeof value !== "string") {
2331
+ value.forEach((val, prop) => {
2332
+ if (val) {
2333
+ val = interpolateParams(val, combinedParams, errors);
2334
+ }
2335
+ const normalizedProp = this.normalizer.normalizePropertyName(prop, errors);
2336
+ val = this.normalizer.normalizeStyleValue(prop, normalizedProp, val, errors);
2337
+ finalStyles.set(prop, val);
2338
+ });
2339
+ }
2340
+ });
2341
+ return finalStyles;
2342
+ }
2343
+ };
2344
+ function buildTrigger(name, ast, normalizer) {
2345
+ return new AnimationTrigger(name, ast, normalizer);
2346
+ }
2347
+ var AnimationTrigger = class {
2348
+ name;
2349
+ ast;
2350
+ _normalizer;
2351
+ transitionFactories = [];
2352
+ fallbackTransition;
2353
+ states = /* @__PURE__ */ new Map();
2354
+ constructor(name, ast, _normalizer) {
2355
+ this.name = name;
2356
+ this.ast = ast;
2357
+ this._normalizer = _normalizer;
2358
+ ast.states.forEach((ast2) => {
2359
+ const defaultParams = ast2.options && ast2.options.params || {};
2360
+ this.states.set(ast2.name, new AnimationStateStyles(ast2.style, defaultParams, _normalizer));
2361
+ });
2362
+ balanceProperties(this.states, "true", "1");
2363
+ balanceProperties(this.states, "false", "0");
2364
+ ast.transitions.forEach((ast2) => {
2365
+ this.transitionFactories.push(new AnimationTransitionFactory(name, ast2, this.states));
2366
+ });
2367
+ this.fallbackTransition = createFallbackTransition(name, this.states, this._normalizer);
2368
+ }
2369
+ get containsQueries() {
2370
+ return this.ast.queryCount > 0;
2371
+ }
2372
+ matchTransition(currentState, nextState, element, params) {
2373
+ const entry = this.transitionFactories.find((f) => f.match(currentState, nextState, element, params));
2374
+ return entry || null;
2375
+ }
2376
+ matchStyles(currentState, params, errors) {
2377
+ return this.fallbackTransition.buildStyles(currentState, params, errors);
2378
+ }
2379
+ };
2380
+ function createFallbackTransition(triggerName, states, normalizer) {
2381
+ const matchers = [(fromState, toState) => true];
2382
+ const animation = {
2383
+ type: AnimationMetadataType.Sequence,
2384
+ steps: [],
2385
+ options: null
2386
+ };
2387
+ const transition = {
2388
+ type: AnimationMetadataType.Transition,
2389
+ animation,
2390
+ matchers,
2391
+ options: null,
2392
+ queryCount: 0,
2393
+ depCount: 0
2394
+ };
2395
+ return new AnimationTransitionFactory(triggerName, transition, states);
2396
+ }
2397
+ function balanceProperties(stateMap, key1, key2) {
2398
+ if (stateMap.has(key1)) {
2399
+ if (!stateMap.has(key2)) {
2400
+ stateMap.set(key2, stateMap.get(key1));
2401
+ }
2402
+ } else if (stateMap.has(key2)) {
2403
+ stateMap.set(key1, stateMap.get(key2));
2404
+ }
2405
+ }
2406
+ var EMPTY_INSTRUCTION_MAP = new ElementInstructionMap();
2407
+ var TimelineAnimationEngine = class {
2408
+ bodyNode;
2409
+ _driver;
2410
+ _normalizer;
2411
+ _animations = /* @__PURE__ */ new Map();
2412
+ _playersById = /* @__PURE__ */ new Map();
2413
+ players = [];
2414
+ constructor(bodyNode, _driver, _normalizer) {
2415
+ this.bodyNode = bodyNode;
2416
+ this._driver = _driver;
2417
+ this._normalizer = _normalizer;
2418
+ }
2419
+ register(id, metadata) {
2420
+ const errors = [];
2421
+ const warnings = [];
2422
+ const ast = buildAnimationAst(this._driver, metadata, errors, warnings);
2423
+ if (errors.length) {
2424
+ throw registerFailed(errors);
2425
+ } else {
2426
+ if (typeof ngDevMode === "undefined" || ngDevMode) {
2427
+ if (warnings.length) {
2428
+ warnRegister(warnings);
2429
+ }
2430
+ }
2431
+ this._animations.set(id, ast);
2432
+ }
2433
+ }
2434
+ _buildPlayer(i, preStyles, postStyles) {
2435
+ const element = i.element;
2436
+ const keyframes = normalizeKeyframes$1(this._normalizer, i.keyframes, preStyles, postStyles);
2437
+ return this._driver.animate(element, keyframes, i.duration, i.delay, i.easing, [], true);
2438
+ }
2439
+ create(id, element, options = {}) {
2440
+ const errors = [];
2441
+ const ast = this._animations.get(id);
2442
+ let instructions;
2443
+ const autoStylesMap = /* @__PURE__ */ new Map();
2444
+ if (ast) {
2445
+ instructions = buildAnimationTimelines(this._driver, element, ast, ENTER_CLASSNAME, LEAVE_CLASSNAME, /* @__PURE__ */ new Map(), /* @__PURE__ */ new Map(), options, EMPTY_INSTRUCTION_MAP, errors);
2446
+ instructions.forEach((inst) => {
2447
+ const styles = getOrSetDefaultValue(autoStylesMap, inst.element, /* @__PURE__ */ new Map());
2448
+ inst.postStyleProps.forEach((prop) => styles.set(prop, null));
2449
+ });
2450
+ } else {
2451
+ errors.push(missingOrDestroyedAnimation());
2452
+ instructions = [];
2453
+ }
2454
+ if (errors.length) {
2455
+ throw createAnimationFailed(errors);
2456
+ }
2457
+ autoStylesMap.forEach((styles, element2) => {
2458
+ styles.forEach((_, prop) => {
2459
+ styles.set(prop, this._driver.computeStyle(element2, prop, AUTO_STYLE));
2460
+ });
2461
+ });
2462
+ const players = instructions.map((i) => {
2463
+ const styles = autoStylesMap.get(i.element);
2464
+ return this._buildPlayer(i, /* @__PURE__ */ new Map(), styles);
2465
+ });
2466
+ const player = optimizeGroupPlayer(players);
2467
+ this._playersById.set(id, player);
2468
+ player.onDestroy(() => this.destroy(id));
2469
+ this.players.push(player);
2470
+ return player;
2471
+ }
2472
+ destroy(id) {
2473
+ const player = this._getPlayer(id);
2474
+ player.destroy();
2475
+ this._playersById.delete(id);
2476
+ const index = this.players.indexOf(player);
2477
+ if (index >= 0) {
2478
+ this.players.splice(index, 1);
2479
+ }
2480
+ }
2481
+ _getPlayer(id) {
2482
+ const player = this._playersById.get(id);
2483
+ if (!player) {
2484
+ throw missingPlayer(id);
2485
+ }
2486
+ return player;
2487
+ }
2488
+ listen(id, element, eventName, callback) {
2489
+ const baseEvent = makeAnimationEvent(element, "", "", "");
2490
+ listenOnPlayer(this._getPlayer(id), eventName, baseEvent, callback);
2491
+ return () => {
2492
+ };
2493
+ }
2494
+ command(id, element, command, args) {
2495
+ if (command == "register") {
2496
+ this.register(id, args[0]);
2497
+ return;
2498
+ }
2499
+ if (command == "create") {
2500
+ const options = args[0] || {};
2501
+ this.create(id, element, options);
2502
+ return;
2503
+ }
2504
+ const player = this._getPlayer(id);
2505
+ switch (command) {
2506
+ case "play":
2507
+ player.play();
2508
+ break;
2509
+ case "pause":
2510
+ player.pause();
2511
+ break;
2512
+ case "reset":
2513
+ player.reset();
2514
+ break;
2515
+ case "restart":
2516
+ player.restart();
2517
+ break;
2518
+ case "finish":
2519
+ player.finish();
2520
+ break;
2521
+ case "init":
2522
+ player.init();
2523
+ break;
2524
+ case "setPosition":
2525
+ player.setPosition(parseFloat(args[0]));
2526
+ break;
2527
+ case "destroy":
2528
+ this.destroy(id);
2529
+ break;
2530
+ }
2531
+ }
2532
+ };
2533
+ var QUEUED_CLASSNAME = "ng-animate-queued";
2534
+ var QUEUED_SELECTOR = ".ng-animate-queued";
2535
+ var DISABLED_CLASSNAME = "ng-animate-disabled";
2536
+ var DISABLED_SELECTOR = ".ng-animate-disabled";
2537
+ var STAR_CLASSNAME = "ng-star-inserted";
2538
+ var STAR_SELECTOR = ".ng-star-inserted";
2539
+ var EMPTY_PLAYER_ARRAY = [];
2540
+ var NULL_REMOVAL_STATE = {
2541
+ namespaceId: "",
2542
+ setForRemoval: false,
2543
+ setForMove: false,
2544
+ hasAnimation: false,
2545
+ removedBeforeQueried: false
2546
+ };
2547
+ var NULL_REMOVED_QUERIED_STATE = {
2548
+ namespaceId: "",
2549
+ setForMove: false,
2550
+ setForRemoval: false,
2551
+ hasAnimation: false,
2552
+ removedBeforeQueried: true
2553
+ };
2554
+ var REMOVAL_FLAG = "__ng_removed";
2555
+ var StateValue = class {
2556
+ namespaceId;
2557
+ value;
2558
+ options;
2559
+ get params() {
2560
+ return this.options.params;
2561
+ }
2562
+ constructor(input, namespaceId = "") {
2563
+ this.namespaceId = namespaceId;
2564
+ const isObj = input && input.hasOwnProperty("value");
2565
+ const value = isObj ? input["value"] : input;
2566
+ this.value = normalizeTriggerValue(value);
2567
+ if (isObj) {
2568
+ const _a = input, {
2569
+ value: value2
2570
+ } = _a, options = __objRest(_a, [
2571
+ "value"
2572
+ ]);
2573
+ this.options = options;
2574
+ } else {
2575
+ this.options = {};
2576
+ }
2577
+ if (!this.options.params) {
2578
+ this.options.params = {};
2579
+ }
2580
+ }
2581
+ absorbOptions(options) {
2582
+ const newParams = options.params;
2583
+ if (newParams) {
2584
+ const oldParams = this.options.params;
2585
+ Object.keys(newParams).forEach((prop) => {
2586
+ if (oldParams[prop] == null) {
2587
+ oldParams[prop] = newParams[prop];
2588
+ }
2589
+ });
2590
+ }
2591
+ }
2592
+ };
2593
+ var VOID_VALUE = "void";
2594
+ var DEFAULT_STATE_VALUE = new StateValue(VOID_VALUE);
2595
+ var AnimationTransitionNamespace = class {
2596
+ id;
2597
+ hostElement;
2598
+ _engine;
2599
+ players = [];
2600
+ _triggers = /* @__PURE__ */ new Map();
2601
+ _queue = [];
2602
+ _elementListeners = /* @__PURE__ */ new Map();
2603
+ _hostClassName;
2604
+ constructor(id, hostElement, _engine) {
2605
+ this.id = id;
2606
+ this.hostElement = hostElement;
2607
+ this._engine = _engine;
2608
+ this._hostClassName = "ng-tns-" + id;
2609
+ addClass(hostElement, this._hostClassName);
2610
+ }
2611
+ listen(element, name, phase, callback) {
2612
+ if (!this._triggers.has(name)) {
2613
+ throw missingTrigger(phase, name);
2614
+ }
2615
+ if (phase == null || phase.length == 0) {
2616
+ throw missingEvent(name);
2617
+ }
2618
+ if (!isTriggerEventValid(phase)) {
2619
+ throw unsupportedTriggerEvent(phase, name);
2620
+ }
2621
+ const listeners = getOrSetDefaultValue(this._elementListeners, element, []);
2622
+ const data = {
2623
+ name,
2624
+ phase,
2625
+ callback
2626
+ };
2627
+ listeners.push(data);
2628
+ const triggersWithStates = getOrSetDefaultValue(this._engine.statesByElement, element, /* @__PURE__ */ new Map());
2629
+ if (!triggersWithStates.has(name)) {
2630
+ addClass(element, NG_TRIGGER_CLASSNAME);
2631
+ addClass(element, NG_TRIGGER_CLASSNAME + "-" + name);
2632
+ triggersWithStates.set(name, DEFAULT_STATE_VALUE);
2633
+ }
2634
+ return () => {
2635
+ this._engine.afterFlush(() => {
2636
+ const index = listeners.indexOf(data);
2637
+ if (index >= 0) {
2638
+ listeners.splice(index, 1);
2639
+ }
2640
+ if (!this._triggers.has(name)) {
2641
+ triggersWithStates.delete(name);
2642
+ }
2643
+ });
2644
+ };
2645
+ }
2646
+ register(name, ast) {
2647
+ if (this._triggers.has(name)) {
2648
+ return false;
2649
+ } else {
2650
+ this._triggers.set(name, ast);
2651
+ return true;
2652
+ }
2653
+ }
2654
+ _getTrigger(name) {
2655
+ const trigger = this._triggers.get(name);
2656
+ if (!trigger) {
2657
+ throw unregisteredTrigger(name);
2658
+ }
2659
+ return trigger;
2660
+ }
2661
+ trigger(element, triggerName, value, defaultToFallback = true) {
2662
+ const trigger = this._getTrigger(triggerName);
2663
+ const player = new TransitionAnimationPlayer(this.id, triggerName, element);
2664
+ let triggersWithStates = this._engine.statesByElement.get(element);
2665
+ if (!triggersWithStates) {
2666
+ addClass(element, NG_TRIGGER_CLASSNAME);
2667
+ addClass(element, NG_TRIGGER_CLASSNAME + "-" + triggerName);
2668
+ this._engine.statesByElement.set(element, triggersWithStates = /* @__PURE__ */ new Map());
2669
+ }
2670
+ let fromState = triggersWithStates.get(triggerName);
2671
+ const toState = new StateValue(value, this.id);
2672
+ const isObj = value && value.hasOwnProperty("value");
2673
+ if (!isObj && fromState) {
2674
+ toState.absorbOptions(fromState.options);
2675
+ }
2676
+ triggersWithStates.set(triggerName, toState);
2677
+ if (!fromState) {
2678
+ fromState = DEFAULT_STATE_VALUE;
2679
+ }
2680
+ const isRemoval = toState.value === VOID_VALUE;
2681
+ if (!isRemoval && fromState.value === toState.value) {
2682
+ if (!objEquals(fromState.params, toState.params)) {
2683
+ const errors = [];
2684
+ const fromStyles = trigger.matchStyles(fromState.value, fromState.params, errors);
2685
+ const toStyles = trigger.matchStyles(toState.value, toState.params, errors);
2686
+ if (errors.length) {
2687
+ this._engine.reportError(errors);
2688
+ } else {
2689
+ this._engine.afterFlush(() => {
2690
+ eraseStyles(element, fromStyles);
2691
+ setStyles(element, toStyles);
2692
+ });
2693
+ }
2694
+ }
2695
+ return;
2696
+ }
2697
+ const playersOnElement = getOrSetDefaultValue(this._engine.playersByElement, element, []);
2698
+ playersOnElement.forEach((player2) => {
2699
+ if (player2.namespaceId == this.id && player2.triggerName == triggerName && player2.queued) {
2700
+ player2.destroy();
2701
+ }
2702
+ });
2703
+ let transition = trigger.matchTransition(fromState.value, toState.value, element, toState.params);
2704
+ let isFallbackTransition = false;
2705
+ if (!transition) {
2706
+ if (!defaultToFallback) return;
2707
+ transition = trigger.fallbackTransition;
2708
+ isFallbackTransition = true;
2709
+ }
2710
+ this._engine.totalQueuedPlayers++;
2711
+ this._queue.push({
2712
+ element,
2713
+ triggerName,
2714
+ transition,
2715
+ fromState,
2716
+ toState,
2717
+ player,
2718
+ isFallbackTransition
2719
+ });
2720
+ if (!isFallbackTransition) {
2721
+ addClass(element, QUEUED_CLASSNAME);
2722
+ player.onStart(() => {
2723
+ removeClass(element, QUEUED_CLASSNAME);
2724
+ });
2725
+ }
2726
+ player.onDone(() => {
2727
+ let index = this.players.indexOf(player);
2728
+ if (index >= 0) {
2729
+ this.players.splice(index, 1);
2730
+ }
2731
+ const players = this._engine.playersByElement.get(element);
2732
+ if (players) {
2733
+ let index2 = players.indexOf(player);
2734
+ if (index2 >= 0) {
2735
+ players.splice(index2, 1);
2736
+ }
2737
+ }
2738
+ });
2739
+ this.players.push(player);
2740
+ playersOnElement.push(player);
2741
+ return player;
2742
+ }
2743
+ deregister(name) {
2744
+ this._triggers.delete(name);
2745
+ this._engine.statesByElement.forEach((stateMap) => stateMap.delete(name));
2746
+ this._elementListeners.forEach((listeners, element) => {
2747
+ this._elementListeners.set(element, listeners.filter((entry) => {
2748
+ return entry.name != name;
2749
+ }));
2750
+ });
2751
+ }
2752
+ clearElementCache(element) {
2753
+ this._engine.statesByElement.delete(element);
2754
+ this._elementListeners.delete(element);
2755
+ const elementPlayers = this._engine.playersByElement.get(element);
2756
+ if (elementPlayers) {
2757
+ elementPlayers.forEach((player) => player.destroy());
2758
+ this._engine.playersByElement.delete(element);
2759
+ }
2760
+ }
2761
+ _signalRemovalForInnerTriggers(rootElement, context) {
2762
+ const elements = this._engine.driver.query(rootElement, NG_TRIGGER_SELECTOR, true);
2763
+ elements.forEach((elm) => {
2764
+ if (elm[REMOVAL_FLAG]) return;
2765
+ const namespaces = this._engine.fetchNamespacesByElement(elm);
2766
+ if (namespaces.size) {
2767
+ namespaces.forEach((ns) => ns.triggerLeaveAnimation(elm, context, false, true));
2768
+ } else {
2769
+ this.clearElementCache(elm);
2770
+ }
2771
+ });
2772
+ this._engine.afterFlushAnimationsDone(() => elements.forEach((elm) => this.clearElementCache(elm)));
2773
+ }
2774
+ triggerLeaveAnimation(element, context, destroyAfterComplete, defaultToFallback) {
2775
+ const triggerStates = this._engine.statesByElement.get(element);
2776
+ const previousTriggersValues = /* @__PURE__ */ new Map();
2777
+ if (triggerStates) {
2778
+ const players = [];
2779
+ triggerStates.forEach((state, triggerName) => {
2780
+ previousTriggersValues.set(triggerName, state.value);
2781
+ if (this._triggers.has(triggerName)) {
2782
+ const player = this.trigger(element, triggerName, VOID_VALUE, defaultToFallback);
2783
+ if (player) {
2784
+ players.push(player);
2785
+ }
2786
+ }
2787
+ });
2788
+ if (players.length) {
2789
+ this._engine.markElementAsRemoved(this.id, element, true, context, previousTriggersValues);
2790
+ if (destroyAfterComplete) {
2791
+ optimizeGroupPlayer(players).onDone(() => this._engine.processLeaveNode(element));
2792
+ }
2793
+ return true;
2794
+ }
2795
+ }
2796
+ return false;
2797
+ }
2798
+ prepareLeaveAnimationListeners(element) {
2799
+ const listeners = this._elementListeners.get(element);
2800
+ const elementStates = this._engine.statesByElement.get(element);
2801
+ if (listeners && elementStates) {
2802
+ const visitedTriggers = /* @__PURE__ */ new Set();
2803
+ listeners.forEach((listener) => {
2804
+ const triggerName = listener.name;
2805
+ if (visitedTriggers.has(triggerName)) return;
2806
+ visitedTriggers.add(triggerName);
2807
+ const trigger = this._triggers.get(triggerName);
2808
+ const transition = trigger.fallbackTransition;
2809
+ const fromState = elementStates.get(triggerName) || DEFAULT_STATE_VALUE;
2810
+ const toState = new StateValue(VOID_VALUE);
2811
+ const player = new TransitionAnimationPlayer(this.id, triggerName, element);
2812
+ this._engine.totalQueuedPlayers++;
2813
+ this._queue.push({
2814
+ element,
2815
+ triggerName,
2816
+ transition,
2817
+ fromState,
2818
+ toState,
2819
+ player,
2820
+ isFallbackTransition: true
2821
+ });
2822
+ });
2823
+ }
2824
+ }
2825
+ removeNode(element, context) {
2826
+ const engine = this._engine;
2827
+ if (element.childElementCount) {
2828
+ this._signalRemovalForInnerTriggers(element, context);
2829
+ }
2830
+ if (this.triggerLeaveAnimation(element, context, true)) return;
2831
+ let containsPotentialParentTransition = false;
2832
+ if (engine.totalAnimations) {
2833
+ const currentPlayers = engine.players.length ? engine.playersByQueriedElement.get(element) : [];
2834
+ if (currentPlayers && currentPlayers.length) {
2835
+ containsPotentialParentTransition = true;
2836
+ } else {
2837
+ let parent = element;
2838
+ while (parent = parent.parentNode) {
2839
+ const triggers = engine.statesByElement.get(parent);
2840
+ if (triggers) {
2841
+ containsPotentialParentTransition = true;
2842
+ break;
2843
+ }
2844
+ }
2845
+ }
2846
+ }
2847
+ this.prepareLeaveAnimationListeners(element);
2848
+ if (containsPotentialParentTransition) {
2849
+ engine.markElementAsRemoved(this.id, element, false, context);
2850
+ } else {
2851
+ const removalFlag = element[REMOVAL_FLAG];
2852
+ if (!removalFlag || removalFlag === NULL_REMOVAL_STATE) {
2853
+ engine.afterFlush(() => this.clearElementCache(element));
2854
+ engine.destroyInnerAnimations(element);
2855
+ engine._onRemovalComplete(element, context);
2856
+ }
2857
+ }
2858
+ }
2859
+ insertNode(element, parent) {
2860
+ addClass(element, this._hostClassName);
2861
+ }
2862
+ drainQueuedTransitions(microtaskId) {
2863
+ const instructions = [];
2864
+ this._queue.forEach((entry) => {
2865
+ const player = entry.player;
2866
+ if (player.destroyed) return;
2867
+ const element = entry.element;
2868
+ const listeners = this._elementListeners.get(element);
2869
+ if (listeners) {
2870
+ listeners.forEach((listener) => {
2871
+ if (listener.name == entry.triggerName) {
2872
+ const baseEvent = makeAnimationEvent(element, entry.triggerName, entry.fromState.value, entry.toState.value);
2873
+ baseEvent["_data"] = microtaskId;
2874
+ listenOnPlayer(entry.player, listener.phase, baseEvent, listener.callback);
2875
+ }
2876
+ });
2877
+ }
2878
+ if (player.markedForDestroy) {
2879
+ this._engine.afterFlush(() => {
2880
+ player.destroy();
2881
+ });
2882
+ } else {
2883
+ instructions.push(entry);
2884
+ }
2885
+ });
2886
+ this._queue = [];
2887
+ return instructions.sort((a, b) => {
2888
+ const d0 = a.transition.ast.depCount;
2889
+ const d1 = b.transition.ast.depCount;
2890
+ if (d0 == 0 || d1 == 0) {
2891
+ return d0 - d1;
2892
+ }
2893
+ return this._engine.driver.containsElement(a.element, b.element) ? 1 : -1;
2894
+ });
2895
+ }
2896
+ destroy(context) {
2897
+ this.players.forEach((p) => p.destroy());
2898
+ this._signalRemovalForInnerTriggers(this.hostElement, context);
2899
+ }
2900
+ };
2901
+ var TransitionAnimationEngine = class {
2902
+ bodyNode;
2903
+ driver;
2904
+ _normalizer;
2905
+ players = [];
2906
+ newHostElements = /* @__PURE__ */ new Map();
2907
+ playersByElement = /* @__PURE__ */ new Map();
2908
+ playersByQueriedElement = /* @__PURE__ */ new Map();
2909
+ statesByElement = /* @__PURE__ */ new Map();
2910
+ disabledNodes = /* @__PURE__ */ new Set();
2911
+ totalAnimations = 0;
2912
+ totalQueuedPlayers = 0;
2913
+ _namespaceLookup = {};
2914
+ _namespaceList = [];
2915
+ _flushFns = [];
2916
+ _whenQuietFns = [];
2917
+ namespacesByHostElement = /* @__PURE__ */ new Map();
2918
+ collectedEnterElements = [];
2919
+ collectedLeaveElements = [];
2920
+ // this method is designed to be overridden by the code that uses this engine
2921
+ onRemovalComplete = (element, context) => {
2922
+ };
2923
+ /** @internal */
2924
+ _onRemovalComplete(element, context) {
2925
+ this.onRemovalComplete(element, context);
2926
+ }
2927
+ constructor(bodyNode, driver, _normalizer) {
2928
+ this.bodyNode = bodyNode;
2929
+ this.driver = driver;
2930
+ this._normalizer = _normalizer;
2931
+ }
2932
+ get queuedPlayers() {
2933
+ const players = [];
2934
+ this._namespaceList.forEach((ns) => {
2935
+ ns.players.forEach((player) => {
2936
+ if (player.queued) {
2937
+ players.push(player);
2938
+ }
2939
+ });
2940
+ });
2941
+ return players;
2942
+ }
2943
+ createNamespace(namespaceId, hostElement) {
2944
+ const ns = new AnimationTransitionNamespace(namespaceId, hostElement, this);
2945
+ if (this.bodyNode && this.driver.containsElement(this.bodyNode, hostElement)) {
2946
+ this._balanceNamespaceList(ns, hostElement);
2947
+ } else {
2948
+ this.newHostElements.set(hostElement, ns);
2949
+ this.collectEnterElement(hostElement);
2950
+ }
2951
+ return this._namespaceLookup[namespaceId] = ns;
2952
+ }
2953
+ _balanceNamespaceList(ns, hostElement) {
2954
+ const namespaceList = this._namespaceList;
2955
+ const namespacesByHostElement = this.namespacesByHostElement;
2956
+ const limit = namespaceList.length - 1;
2957
+ if (limit >= 0) {
2958
+ let found = false;
2959
+ let ancestor = this.driver.getParentElement(hostElement);
2960
+ while (ancestor) {
2961
+ const ancestorNs = namespacesByHostElement.get(ancestor);
2962
+ if (ancestorNs) {
2963
+ const index = namespaceList.indexOf(ancestorNs);
2964
+ namespaceList.splice(index + 1, 0, ns);
2965
+ found = true;
2966
+ break;
2967
+ }
2968
+ ancestor = this.driver.getParentElement(ancestor);
2969
+ }
2970
+ if (!found) {
2971
+ namespaceList.unshift(ns);
2972
+ }
2973
+ } else {
2974
+ namespaceList.push(ns);
2975
+ }
2976
+ namespacesByHostElement.set(hostElement, ns);
2977
+ return ns;
2978
+ }
2979
+ register(namespaceId, hostElement) {
2980
+ let ns = this._namespaceLookup[namespaceId];
2981
+ if (!ns) {
2982
+ ns = this.createNamespace(namespaceId, hostElement);
2983
+ }
2984
+ return ns;
2985
+ }
2986
+ registerTrigger(namespaceId, name, trigger) {
2987
+ let ns = this._namespaceLookup[namespaceId];
2988
+ if (ns && ns.register(name, trigger)) {
2989
+ this.totalAnimations++;
2990
+ }
2991
+ }
2992
+ destroy(namespaceId, context) {
2993
+ if (!namespaceId) return;
2994
+ this.afterFlush(() => {
2995
+ });
2996
+ this.afterFlushAnimationsDone(() => {
2997
+ const ns = this._fetchNamespace(namespaceId);
2998
+ this.namespacesByHostElement.delete(ns.hostElement);
2999
+ const index = this._namespaceList.indexOf(ns);
3000
+ if (index >= 0) {
3001
+ this._namespaceList.splice(index, 1);
3002
+ }
3003
+ ns.destroy(context);
3004
+ delete this._namespaceLookup[namespaceId];
3005
+ });
3006
+ }
3007
+ _fetchNamespace(id) {
3008
+ return this._namespaceLookup[id];
3009
+ }
3010
+ fetchNamespacesByElement(element) {
3011
+ const namespaces = /* @__PURE__ */ new Set();
3012
+ const elementStates = this.statesByElement.get(element);
3013
+ if (elementStates) {
3014
+ for (let stateValue of elementStates.values()) {
3015
+ if (stateValue.namespaceId) {
3016
+ const ns = this._fetchNamespace(stateValue.namespaceId);
3017
+ if (ns) {
3018
+ namespaces.add(ns);
3019
+ }
3020
+ }
3021
+ }
3022
+ }
3023
+ return namespaces;
3024
+ }
3025
+ trigger(namespaceId, element, name, value) {
3026
+ if (isElementNode(element)) {
3027
+ const ns = this._fetchNamespace(namespaceId);
3028
+ if (ns) {
3029
+ ns.trigger(element, name, value);
3030
+ return true;
3031
+ }
3032
+ }
3033
+ return false;
3034
+ }
3035
+ insertNode(namespaceId, element, parent, insertBefore) {
3036
+ if (!isElementNode(element)) return;
3037
+ const details = element[REMOVAL_FLAG];
3038
+ if (details && details.setForRemoval) {
3039
+ details.setForRemoval = false;
3040
+ details.setForMove = true;
3041
+ const index = this.collectedLeaveElements.indexOf(element);
3042
+ if (index >= 0) {
3043
+ this.collectedLeaveElements.splice(index, 1);
3044
+ }
3045
+ }
3046
+ if (namespaceId) {
3047
+ const ns = this._fetchNamespace(namespaceId);
3048
+ if (ns) {
3049
+ ns.insertNode(element, parent);
3050
+ }
3051
+ }
3052
+ if (insertBefore) {
3053
+ this.collectEnterElement(element);
3054
+ }
3055
+ }
3056
+ collectEnterElement(element) {
3057
+ this.collectedEnterElements.push(element);
3058
+ }
3059
+ markElementAsDisabled(element, value) {
3060
+ if (value) {
3061
+ if (!this.disabledNodes.has(element)) {
3062
+ this.disabledNodes.add(element);
3063
+ addClass(element, DISABLED_CLASSNAME);
3064
+ }
3065
+ } else if (this.disabledNodes.has(element)) {
3066
+ this.disabledNodes.delete(element);
3067
+ removeClass(element, DISABLED_CLASSNAME);
3068
+ }
3069
+ }
3070
+ removeNode(namespaceId, element, context) {
3071
+ if (isElementNode(element)) {
3072
+ const ns = namespaceId ? this._fetchNamespace(namespaceId) : null;
3073
+ if (ns) {
3074
+ ns.removeNode(element, context);
3075
+ } else {
3076
+ this.markElementAsRemoved(namespaceId, element, false, context);
3077
+ }
3078
+ const hostNS = this.namespacesByHostElement.get(element);
3079
+ if (hostNS && hostNS.id !== namespaceId) {
3080
+ hostNS.removeNode(element, context);
3081
+ }
3082
+ } else {
3083
+ this._onRemovalComplete(element, context);
3084
+ }
3085
+ }
3086
+ markElementAsRemoved(namespaceId, element, hasAnimation, context, previousTriggersValues) {
3087
+ this.collectedLeaveElements.push(element);
3088
+ element[REMOVAL_FLAG] = {
3089
+ namespaceId,
3090
+ setForRemoval: context,
3091
+ hasAnimation,
3092
+ removedBeforeQueried: false,
3093
+ previousTriggersValues
3094
+ };
3095
+ }
3096
+ listen(namespaceId, element, name, phase, callback) {
3097
+ if (isElementNode(element)) {
3098
+ return this._fetchNamespace(namespaceId).listen(element, name, phase, callback);
3099
+ }
3100
+ return () => {
3101
+ };
3102
+ }
3103
+ _buildInstruction(entry, subTimelines, enterClassName, leaveClassName, skipBuildAst) {
3104
+ return entry.transition.build(this.driver, entry.element, entry.fromState.value, entry.toState.value, enterClassName, leaveClassName, entry.fromState.options, entry.toState.options, subTimelines, skipBuildAst);
3105
+ }
3106
+ destroyInnerAnimations(containerElement) {
3107
+ let elements = this.driver.query(containerElement, NG_TRIGGER_SELECTOR, true);
3108
+ elements.forEach((element) => this.destroyActiveAnimationsForElement(element));
3109
+ if (this.playersByQueriedElement.size == 0) return;
3110
+ elements = this.driver.query(containerElement, NG_ANIMATING_SELECTOR, true);
3111
+ elements.forEach((element) => this.finishActiveQueriedAnimationOnElement(element));
3112
+ }
3113
+ destroyActiveAnimationsForElement(element) {
3114
+ const players = this.playersByElement.get(element);
3115
+ if (players) {
3116
+ players.forEach((player) => {
3117
+ if (player.queued) {
3118
+ player.markedForDestroy = true;
3119
+ } else {
3120
+ player.destroy();
3121
+ }
3122
+ });
3123
+ }
3124
+ }
3125
+ finishActiveQueriedAnimationOnElement(element) {
3126
+ const players = this.playersByQueriedElement.get(element);
3127
+ if (players) {
3128
+ players.forEach((player) => player.finish());
3129
+ }
3130
+ }
3131
+ whenRenderingDone() {
3132
+ return new Promise((resolve) => {
3133
+ if (this.players.length) {
3134
+ return optimizeGroupPlayer(this.players).onDone(() => resolve());
3135
+ } else {
3136
+ resolve();
3137
+ }
3138
+ });
3139
+ }
3140
+ processLeaveNode(element) {
3141
+ const details = element[REMOVAL_FLAG];
3142
+ if (details && details.setForRemoval) {
3143
+ element[REMOVAL_FLAG] = NULL_REMOVAL_STATE;
3144
+ if (details.namespaceId) {
3145
+ this.destroyInnerAnimations(element);
3146
+ const ns = this._fetchNamespace(details.namespaceId);
3147
+ if (ns) {
3148
+ ns.clearElementCache(element);
3149
+ }
3150
+ }
3151
+ this._onRemovalComplete(element, details.setForRemoval);
3152
+ }
3153
+ if (element.classList?.contains(DISABLED_CLASSNAME)) {
3154
+ this.markElementAsDisabled(element, false);
3155
+ }
3156
+ this.driver.query(element, DISABLED_SELECTOR, true).forEach((node) => {
3157
+ this.markElementAsDisabled(node, false);
3158
+ });
3159
+ }
3160
+ flush(microtaskId = -1) {
3161
+ let players = [];
3162
+ if (this.newHostElements.size) {
3163
+ this.newHostElements.forEach((ns, element) => this._balanceNamespaceList(ns, element));
3164
+ this.newHostElements.clear();
3165
+ }
3166
+ if (this.totalAnimations && this.collectedEnterElements.length) {
3167
+ for (let i = 0; i < this.collectedEnterElements.length; i++) {
3168
+ const elm = this.collectedEnterElements[i];
3169
+ addClass(elm, STAR_CLASSNAME);
3170
+ }
3171
+ }
3172
+ if (this._namespaceList.length && (this.totalQueuedPlayers || this.collectedLeaveElements.length)) {
3173
+ const cleanupFns = [];
3174
+ try {
3175
+ players = this._flushAnimations(cleanupFns, microtaskId);
3176
+ } finally {
3177
+ for (let i = 0; i < cleanupFns.length; i++) {
3178
+ cleanupFns[i]();
3179
+ }
3180
+ }
3181
+ } else {
3182
+ for (let i = 0; i < this.collectedLeaveElements.length; i++) {
3183
+ const element = this.collectedLeaveElements[i];
3184
+ this.processLeaveNode(element);
3185
+ }
3186
+ }
3187
+ this.totalQueuedPlayers = 0;
3188
+ this.collectedEnterElements.length = 0;
3189
+ this.collectedLeaveElements.length = 0;
3190
+ this._flushFns.forEach((fn) => fn());
3191
+ this._flushFns = [];
3192
+ if (this._whenQuietFns.length) {
3193
+ const quietFns = this._whenQuietFns;
3194
+ this._whenQuietFns = [];
3195
+ if (players.length) {
3196
+ optimizeGroupPlayer(players).onDone(() => {
3197
+ quietFns.forEach((fn) => fn());
3198
+ });
3199
+ } else {
3200
+ quietFns.forEach((fn) => fn());
3201
+ }
3202
+ }
3203
+ }
3204
+ reportError(errors) {
3205
+ throw triggerTransitionsFailed(errors);
3206
+ }
3207
+ _flushAnimations(cleanupFns, microtaskId) {
3208
+ const subTimelines = new ElementInstructionMap();
3209
+ const skippedPlayers = [];
3210
+ const skippedPlayersMap = /* @__PURE__ */ new Map();
3211
+ const queuedInstructions = [];
3212
+ const queriedElements = /* @__PURE__ */ new Map();
3213
+ const allPreStyleElements = /* @__PURE__ */ new Map();
3214
+ const allPostStyleElements = /* @__PURE__ */ new Map();
3215
+ const disabledElementsSet = /* @__PURE__ */ new Set();
3216
+ this.disabledNodes.forEach((node) => {
3217
+ disabledElementsSet.add(node);
3218
+ const nodesThatAreDisabled = this.driver.query(node, QUEUED_SELECTOR, true);
3219
+ for (let i2 = 0; i2 < nodesThatAreDisabled.length; i2++) {
3220
+ disabledElementsSet.add(nodesThatAreDisabled[i2]);
3221
+ }
3222
+ });
3223
+ const bodyNode = this.bodyNode;
3224
+ const allTriggerElements = Array.from(this.statesByElement.keys());
3225
+ const enterNodeMap = buildRootMap(allTriggerElements, this.collectedEnterElements);
3226
+ const enterNodeMapIds = /* @__PURE__ */ new Map();
3227
+ let i = 0;
3228
+ enterNodeMap.forEach((nodes, root) => {
3229
+ const className = ENTER_CLASSNAME + i++;
3230
+ enterNodeMapIds.set(root, className);
3231
+ nodes.forEach((node) => addClass(node, className));
3232
+ });
3233
+ const allLeaveNodes = [];
3234
+ const mergedLeaveNodes = /* @__PURE__ */ new Set();
3235
+ const leaveNodesWithoutAnimations = /* @__PURE__ */ new Set();
3236
+ for (let i2 = 0; i2 < this.collectedLeaveElements.length; i2++) {
3237
+ const element = this.collectedLeaveElements[i2];
3238
+ const details = element[REMOVAL_FLAG];
3239
+ if (details && details.setForRemoval) {
3240
+ allLeaveNodes.push(element);
3241
+ mergedLeaveNodes.add(element);
3242
+ if (details.hasAnimation) {
3243
+ this.driver.query(element, STAR_SELECTOR, true).forEach((elm) => mergedLeaveNodes.add(elm));
3244
+ } else {
3245
+ leaveNodesWithoutAnimations.add(element);
3246
+ }
3247
+ }
3248
+ }
3249
+ const leaveNodeMapIds = /* @__PURE__ */ new Map();
3250
+ const leaveNodeMap = buildRootMap(allTriggerElements, Array.from(mergedLeaveNodes));
3251
+ leaveNodeMap.forEach((nodes, root) => {
3252
+ const className = LEAVE_CLASSNAME + i++;
3253
+ leaveNodeMapIds.set(root, className);
3254
+ nodes.forEach((node) => addClass(node, className));
3255
+ });
3256
+ cleanupFns.push(() => {
3257
+ enterNodeMap.forEach((nodes, root) => {
3258
+ const className = enterNodeMapIds.get(root);
3259
+ nodes.forEach((node) => removeClass(node, className));
3260
+ });
3261
+ leaveNodeMap.forEach((nodes, root) => {
3262
+ const className = leaveNodeMapIds.get(root);
3263
+ nodes.forEach((node) => removeClass(node, className));
3264
+ });
3265
+ allLeaveNodes.forEach((element) => {
3266
+ this.processLeaveNode(element);
3267
+ });
3268
+ });
3269
+ const allPlayers = [];
3270
+ const erroneousTransitions = [];
3271
+ for (let i2 = this._namespaceList.length - 1; i2 >= 0; i2--) {
3272
+ const ns = this._namespaceList[i2];
3273
+ ns.drainQueuedTransitions(microtaskId).forEach((entry) => {
3274
+ const player = entry.player;
3275
+ const element = entry.element;
3276
+ allPlayers.push(player);
3277
+ if (this.collectedEnterElements.length) {
3278
+ const details = element[REMOVAL_FLAG];
3279
+ if (details && details.setForMove) {
3280
+ if (details.previousTriggersValues && details.previousTriggersValues.has(entry.triggerName)) {
3281
+ const previousValue = details.previousTriggersValues.get(entry.triggerName);
3282
+ const triggersWithStates = this.statesByElement.get(entry.element);
3283
+ if (triggersWithStates && triggersWithStates.has(entry.triggerName)) {
3284
+ const state = triggersWithStates.get(entry.triggerName);
3285
+ state.value = previousValue;
3286
+ triggersWithStates.set(entry.triggerName, state);
3287
+ }
3288
+ }
3289
+ player.destroy();
3290
+ return;
3291
+ }
3292
+ }
3293
+ const nodeIsOrphaned = !bodyNode || !this.driver.containsElement(bodyNode, element);
3294
+ const leaveClassName = leaveNodeMapIds.get(element);
3295
+ const enterClassName = enterNodeMapIds.get(element);
3296
+ const instruction = this._buildInstruction(entry, subTimelines, enterClassName, leaveClassName, nodeIsOrphaned);
3297
+ if (instruction.errors && instruction.errors.length) {
3298
+ erroneousTransitions.push(instruction);
3299
+ return;
3300
+ }
3301
+ if (nodeIsOrphaned) {
3302
+ player.onStart(() => eraseStyles(element, instruction.fromStyles));
3303
+ player.onDestroy(() => setStyles(element, instruction.toStyles));
3304
+ skippedPlayers.push(player);
3305
+ return;
3306
+ }
3307
+ if (entry.isFallbackTransition) {
3308
+ player.onStart(() => eraseStyles(element, instruction.fromStyles));
3309
+ player.onDestroy(() => setStyles(element, instruction.toStyles));
3310
+ skippedPlayers.push(player);
3311
+ return;
3312
+ }
3313
+ const timelines = [];
3314
+ instruction.timelines.forEach((tl) => {
3315
+ tl.stretchStartingKeyframe = true;
3316
+ if (!this.disabledNodes.has(tl.element)) {
3317
+ timelines.push(tl);
3318
+ }
3319
+ });
3320
+ instruction.timelines = timelines;
3321
+ subTimelines.append(element, instruction.timelines);
3322
+ const tuple = {
3323
+ instruction,
3324
+ player,
3325
+ element
3326
+ };
3327
+ queuedInstructions.push(tuple);
3328
+ instruction.queriedElements.forEach((element2) => getOrSetDefaultValue(queriedElements, element2, []).push(player));
3329
+ instruction.preStyleProps.forEach((stringMap, element2) => {
3330
+ if (stringMap.size) {
3331
+ let setVal = allPreStyleElements.get(element2);
3332
+ if (!setVal) {
3333
+ allPreStyleElements.set(element2, setVal = /* @__PURE__ */ new Set());
3334
+ }
3335
+ stringMap.forEach((_, prop) => setVal.add(prop));
3336
+ }
3337
+ });
3338
+ instruction.postStyleProps.forEach((stringMap, element2) => {
3339
+ let setVal = allPostStyleElements.get(element2);
3340
+ if (!setVal) {
3341
+ allPostStyleElements.set(element2, setVal = /* @__PURE__ */ new Set());
3342
+ }
3343
+ stringMap.forEach((_, prop) => setVal.add(prop));
3344
+ });
3345
+ });
3346
+ }
3347
+ if (erroneousTransitions.length) {
3348
+ const errors = [];
3349
+ erroneousTransitions.forEach((instruction) => {
3350
+ errors.push(transitionFailed(instruction.triggerName, instruction.errors));
3351
+ });
3352
+ allPlayers.forEach((player) => player.destroy());
3353
+ this.reportError(errors);
3354
+ }
3355
+ const allPreviousPlayersMap = /* @__PURE__ */ new Map();
3356
+ const animationElementMap = /* @__PURE__ */ new Map();
3357
+ queuedInstructions.forEach((entry) => {
3358
+ const element = entry.element;
3359
+ if (subTimelines.has(element)) {
3360
+ animationElementMap.set(element, element);
3361
+ this._beforeAnimationBuild(entry.player.namespaceId, entry.instruction, allPreviousPlayersMap);
3362
+ }
3363
+ });
3364
+ skippedPlayers.forEach((player) => {
3365
+ const element = player.element;
3366
+ const previousPlayers = this._getPreviousPlayers(element, false, player.namespaceId, player.triggerName, null);
3367
+ previousPlayers.forEach((prevPlayer) => {
3368
+ getOrSetDefaultValue(allPreviousPlayersMap, element, []).push(prevPlayer);
3369
+ prevPlayer.destroy();
3370
+ });
3371
+ });
3372
+ const replaceNodes = allLeaveNodes.filter((node) => {
3373
+ return replacePostStylesAsPre(node, allPreStyleElements, allPostStyleElements);
3374
+ });
3375
+ const postStylesMap = /* @__PURE__ */ new Map();
3376
+ const allLeaveQueriedNodes = cloakAndComputeStyles(postStylesMap, this.driver, leaveNodesWithoutAnimations, allPostStyleElements, AUTO_STYLE);
3377
+ allLeaveQueriedNodes.forEach((node) => {
3378
+ if (replacePostStylesAsPre(node, allPreStyleElements, allPostStyleElements)) {
3379
+ replaceNodes.push(node);
3380
+ }
3381
+ });
3382
+ const preStylesMap = /* @__PURE__ */ new Map();
3383
+ enterNodeMap.forEach((nodes, root) => {
3384
+ cloakAndComputeStyles(preStylesMap, this.driver, new Set(nodes), allPreStyleElements, \u0275PRE_STYLE);
3385
+ });
3386
+ replaceNodes.forEach((node) => {
3387
+ const post = postStylesMap.get(node);
3388
+ const pre = preStylesMap.get(node);
3389
+ postStylesMap.set(node, new Map([...post?.entries() ?? [], ...pre?.entries() ?? []]));
3390
+ });
3391
+ const rootPlayers = [];
3392
+ const subPlayers = [];
3393
+ const NO_PARENT_ANIMATION_ELEMENT_DETECTED = {};
3394
+ queuedInstructions.forEach((entry) => {
3395
+ const {
3396
+ element,
3397
+ player,
3398
+ instruction
3399
+ } = entry;
3400
+ if (subTimelines.has(element)) {
3401
+ if (disabledElementsSet.has(element)) {
3402
+ player.onDestroy(() => setStyles(element, instruction.toStyles));
3403
+ player.disabled = true;
3404
+ player.overrideTotalTime(instruction.totalTime);
3405
+ skippedPlayers.push(player);
3406
+ return;
3407
+ }
3408
+ let parentWithAnimation = NO_PARENT_ANIMATION_ELEMENT_DETECTED;
3409
+ if (animationElementMap.size > 1) {
3410
+ let elm = element;
3411
+ const parentsToAdd = [];
3412
+ while (elm = elm.parentNode) {
3413
+ const detectedParent = animationElementMap.get(elm);
3414
+ if (detectedParent) {
3415
+ parentWithAnimation = detectedParent;
3416
+ break;
3417
+ }
3418
+ parentsToAdd.push(elm);
3419
+ }
3420
+ parentsToAdd.forEach((parent) => animationElementMap.set(parent, parentWithAnimation));
3421
+ }
3422
+ const innerPlayer = this._buildAnimation(player.namespaceId, instruction, allPreviousPlayersMap, skippedPlayersMap, preStylesMap, postStylesMap);
3423
+ player.setRealPlayer(innerPlayer);
3424
+ if (parentWithAnimation === NO_PARENT_ANIMATION_ELEMENT_DETECTED) {
3425
+ rootPlayers.push(player);
3426
+ } else {
3427
+ const parentPlayers = this.playersByElement.get(parentWithAnimation);
3428
+ if (parentPlayers && parentPlayers.length) {
3429
+ player.parentPlayer = optimizeGroupPlayer(parentPlayers);
3430
+ }
3431
+ skippedPlayers.push(player);
3432
+ }
3433
+ } else {
3434
+ eraseStyles(element, instruction.fromStyles);
3435
+ player.onDestroy(() => setStyles(element, instruction.toStyles));
3436
+ subPlayers.push(player);
3437
+ if (disabledElementsSet.has(element)) {
3438
+ skippedPlayers.push(player);
3439
+ }
3440
+ }
3441
+ });
3442
+ subPlayers.forEach((player) => {
3443
+ const playersForElement = skippedPlayersMap.get(player.element);
3444
+ if (playersForElement && playersForElement.length) {
3445
+ const innerPlayer = optimizeGroupPlayer(playersForElement);
3446
+ player.setRealPlayer(innerPlayer);
3447
+ }
3448
+ });
3449
+ skippedPlayers.forEach((player) => {
3450
+ if (player.parentPlayer) {
3451
+ player.syncPlayerEvents(player.parentPlayer);
3452
+ } else {
3453
+ player.destroy();
3454
+ }
3455
+ });
3456
+ for (let i2 = 0; i2 < allLeaveNodes.length; i2++) {
3457
+ const element = allLeaveNodes[i2];
3458
+ const details = element[REMOVAL_FLAG];
3459
+ removeClass(element, LEAVE_CLASSNAME);
3460
+ if (details && details.hasAnimation) continue;
3461
+ let players = [];
3462
+ if (queriedElements.size) {
3463
+ let queriedPlayerResults = queriedElements.get(element);
3464
+ if (queriedPlayerResults && queriedPlayerResults.length) {
3465
+ players.push(...queriedPlayerResults);
3466
+ }
3467
+ let queriedInnerElements = this.driver.query(element, NG_ANIMATING_SELECTOR, true);
3468
+ for (let j = 0; j < queriedInnerElements.length; j++) {
3469
+ let queriedPlayers = queriedElements.get(queriedInnerElements[j]);
3470
+ if (queriedPlayers && queriedPlayers.length) {
3471
+ players.push(...queriedPlayers);
3472
+ }
3473
+ }
3474
+ }
3475
+ const activePlayers = players.filter((p) => !p.destroyed);
3476
+ if (activePlayers.length) {
3477
+ removeNodesAfterAnimationDone(this, element, activePlayers);
3478
+ } else {
3479
+ this.processLeaveNode(element);
3480
+ }
3481
+ }
3482
+ allLeaveNodes.length = 0;
3483
+ rootPlayers.forEach((player) => {
3484
+ this.players.push(player);
3485
+ player.onDone(() => {
3486
+ player.destroy();
3487
+ const index = this.players.indexOf(player);
3488
+ this.players.splice(index, 1);
3489
+ });
3490
+ player.play();
3491
+ });
3492
+ return rootPlayers;
3493
+ }
3494
+ afterFlush(callback) {
3495
+ this._flushFns.push(callback);
3496
+ }
3497
+ afterFlushAnimationsDone(callback) {
3498
+ this._whenQuietFns.push(callback);
3499
+ }
3500
+ _getPreviousPlayers(element, isQueriedElement, namespaceId, triggerName, toStateValue) {
3501
+ let players = [];
3502
+ if (isQueriedElement) {
3503
+ const queriedElementPlayers = this.playersByQueriedElement.get(element);
3504
+ if (queriedElementPlayers) {
3505
+ players = queriedElementPlayers;
3506
+ }
3507
+ } else {
3508
+ const elementPlayers = this.playersByElement.get(element);
3509
+ if (elementPlayers) {
3510
+ const isRemovalAnimation = !toStateValue || toStateValue == VOID_VALUE;
3511
+ elementPlayers.forEach((player) => {
3512
+ if (player.queued) return;
3513
+ if (!isRemovalAnimation && player.triggerName != triggerName) return;
3514
+ players.push(player);
3515
+ });
3516
+ }
3517
+ }
3518
+ if (namespaceId || triggerName) {
3519
+ players = players.filter((player) => {
3520
+ if (namespaceId && namespaceId != player.namespaceId) return false;
3521
+ if (triggerName && triggerName != player.triggerName) return false;
3522
+ return true;
3523
+ });
3524
+ }
3525
+ return players;
3526
+ }
3527
+ _beforeAnimationBuild(namespaceId, instruction, allPreviousPlayersMap) {
3528
+ const triggerName = instruction.triggerName;
3529
+ const rootElement = instruction.element;
3530
+ const targetNameSpaceId = instruction.isRemovalTransition ? void 0 : namespaceId;
3531
+ const targetTriggerName = instruction.isRemovalTransition ? void 0 : triggerName;
3532
+ for (const timelineInstruction of instruction.timelines) {
3533
+ const element = timelineInstruction.element;
3534
+ const isQueriedElement = element !== rootElement;
3535
+ const players = getOrSetDefaultValue(allPreviousPlayersMap, element, []);
3536
+ const previousPlayers = this._getPreviousPlayers(element, isQueriedElement, targetNameSpaceId, targetTriggerName, instruction.toState);
3537
+ previousPlayers.forEach((player) => {
3538
+ const realPlayer = player.getRealPlayer();
3539
+ if (realPlayer.beforeDestroy) {
3540
+ realPlayer.beforeDestroy();
3541
+ }
3542
+ player.destroy();
3543
+ players.push(player);
3544
+ });
3545
+ }
3546
+ eraseStyles(rootElement, instruction.fromStyles);
3547
+ }
3548
+ _buildAnimation(namespaceId, instruction, allPreviousPlayersMap, skippedPlayersMap, preStylesMap, postStylesMap) {
3549
+ const triggerName = instruction.triggerName;
3550
+ const rootElement = instruction.element;
3551
+ const allQueriedPlayers = [];
3552
+ const allConsumedElements = /* @__PURE__ */ new Set();
3553
+ const allSubElements = /* @__PURE__ */ new Set();
3554
+ const allNewPlayers = instruction.timelines.map((timelineInstruction) => {
3555
+ const element = timelineInstruction.element;
3556
+ allConsumedElements.add(element);
3557
+ const details = element[REMOVAL_FLAG];
3558
+ if (details && details.removedBeforeQueried) return new NoopAnimationPlayer(timelineInstruction.duration, timelineInstruction.delay);
3559
+ const isQueriedElement = element !== rootElement;
3560
+ const previousPlayers = flattenGroupPlayers((allPreviousPlayersMap.get(element) || EMPTY_PLAYER_ARRAY).map((p) => p.getRealPlayer())).filter((p) => {
3561
+ const pp = p;
3562
+ return pp.element ? pp.element === element : false;
3563
+ });
3564
+ const preStyles = preStylesMap.get(element);
3565
+ const postStyles = postStylesMap.get(element);
3566
+ const keyframes = normalizeKeyframes$1(this._normalizer, timelineInstruction.keyframes, preStyles, postStyles);
3567
+ const player2 = this._buildPlayer(timelineInstruction, keyframes, previousPlayers);
3568
+ if (timelineInstruction.subTimeline && skippedPlayersMap) {
3569
+ allSubElements.add(element);
3570
+ }
3571
+ if (isQueriedElement) {
3572
+ const wrappedPlayer = new TransitionAnimationPlayer(namespaceId, triggerName, element);
3573
+ wrappedPlayer.setRealPlayer(player2);
3574
+ allQueriedPlayers.push(wrappedPlayer);
3575
+ }
3576
+ return player2;
3577
+ });
3578
+ allQueriedPlayers.forEach((player2) => {
3579
+ getOrSetDefaultValue(this.playersByQueriedElement, player2.element, []).push(player2);
3580
+ player2.onDone(() => deleteOrUnsetInMap(this.playersByQueriedElement, player2.element, player2));
3581
+ });
3582
+ allConsumedElements.forEach((element) => addClass(element, NG_ANIMATING_CLASSNAME));
3583
+ const player = optimizeGroupPlayer(allNewPlayers);
3584
+ player.onDestroy(() => {
3585
+ allConsumedElements.forEach((element) => removeClass(element, NG_ANIMATING_CLASSNAME));
3586
+ setStyles(rootElement, instruction.toStyles);
3587
+ });
3588
+ allSubElements.forEach((element) => {
3589
+ getOrSetDefaultValue(skippedPlayersMap, element, []).push(player);
3590
+ });
3591
+ return player;
3592
+ }
3593
+ _buildPlayer(instruction, keyframes, previousPlayers) {
3594
+ if (keyframes.length > 0) {
3595
+ return this.driver.animate(instruction.element, keyframes, instruction.duration, instruction.delay, instruction.easing, previousPlayers);
3596
+ }
3597
+ return new NoopAnimationPlayer(instruction.duration, instruction.delay);
3598
+ }
3599
+ };
3600
+ var TransitionAnimationPlayer = class {
3601
+ namespaceId;
3602
+ triggerName;
3603
+ element;
3604
+ _player = new NoopAnimationPlayer();
3605
+ _containsRealPlayer = false;
3606
+ _queuedCallbacks = /* @__PURE__ */ new Map();
3607
+ destroyed = false;
3608
+ parentPlayer = null;
3609
+ markedForDestroy = false;
3610
+ disabled = false;
3611
+ queued = true;
3612
+ totalTime = 0;
3613
+ constructor(namespaceId, triggerName, element) {
3614
+ this.namespaceId = namespaceId;
3615
+ this.triggerName = triggerName;
3616
+ this.element = element;
3617
+ }
3618
+ setRealPlayer(player) {
3619
+ if (this._containsRealPlayer) return;
3620
+ this._player = player;
3621
+ this._queuedCallbacks.forEach((callbacks, phase) => {
3622
+ callbacks.forEach((callback) => listenOnPlayer(player, phase, void 0, callback));
3623
+ });
3624
+ this._queuedCallbacks.clear();
3625
+ this._containsRealPlayer = true;
3626
+ this.overrideTotalTime(player.totalTime);
3627
+ this.queued = false;
3628
+ }
3629
+ getRealPlayer() {
3630
+ return this._player;
3631
+ }
3632
+ overrideTotalTime(totalTime) {
3633
+ this.totalTime = totalTime;
3634
+ }
3635
+ syncPlayerEvents(player) {
3636
+ const p = this._player;
3637
+ if (p.triggerCallback) {
3638
+ player.onStart(() => p.triggerCallback("start"));
3639
+ }
3640
+ player.onDone(() => this.finish());
3641
+ player.onDestroy(() => this.destroy());
3642
+ }
3643
+ _queueEvent(name, callback) {
3644
+ getOrSetDefaultValue(this._queuedCallbacks, name, []).push(callback);
3645
+ }
3646
+ onDone(fn) {
3647
+ if (this.queued) {
3648
+ this._queueEvent("done", fn);
3649
+ }
3650
+ this._player.onDone(fn);
3651
+ }
3652
+ onStart(fn) {
3653
+ if (this.queued) {
3654
+ this._queueEvent("start", fn);
3655
+ }
3656
+ this._player.onStart(fn);
3657
+ }
3658
+ onDestroy(fn) {
3659
+ if (this.queued) {
3660
+ this._queueEvent("destroy", fn);
3661
+ }
3662
+ this._player.onDestroy(fn);
3663
+ }
3664
+ init() {
3665
+ this._player.init();
3666
+ }
3667
+ hasStarted() {
3668
+ return this.queued ? false : this._player.hasStarted();
3669
+ }
3670
+ play() {
3671
+ !this.queued && this._player.play();
3672
+ }
3673
+ pause() {
3674
+ !this.queued && this._player.pause();
3675
+ }
3676
+ restart() {
3677
+ !this.queued && this._player.restart();
3678
+ }
3679
+ finish() {
3680
+ this._player.finish();
3681
+ }
3682
+ destroy() {
3683
+ this.destroyed = true;
3684
+ this._player.destroy();
3685
+ }
3686
+ reset() {
3687
+ !this.queued && this._player.reset();
3688
+ }
3689
+ setPosition(p) {
3690
+ if (!this.queued) {
3691
+ this._player.setPosition(p);
3692
+ }
3693
+ }
3694
+ getPosition() {
3695
+ return this.queued ? 0 : this._player.getPosition();
3696
+ }
3697
+ /** @internal */
3698
+ triggerCallback(phaseName) {
3699
+ const p = this._player;
3700
+ if (p.triggerCallback) {
3701
+ p.triggerCallback(phaseName);
3702
+ }
3703
+ }
3704
+ };
3705
+ function deleteOrUnsetInMap(map, key, value) {
3706
+ let currentValues = map.get(key);
3707
+ if (currentValues) {
3708
+ if (currentValues.length) {
3709
+ const index = currentValues.indexOf(value);
3710
+ currentValues.splice(index, 1);
3711
+ }
3712
+ if (currentValues.length == 0) {
3713
+ map.delete(key);
3714
+ }
3715
+ }
3716
+ return currentValues;
3717
+ }
3718
+ function normalizeTriggerValue(value) {
3719
+ return value != null ? value : null;
3720
+ }
3721
+ function isElementNode(node) {
3722
+ return node && node["nodeType"] === 1;
3723
+ }
3724
+ function isTriggerEventValid(eventName) {
3725
+ return eventName == "start" || eventName == "done";
3726
+ }
3727
+ function cloakElement(element, value) {
3728
+ const oldValue = element.style.display;
3729
+ element.style.display = value != null ? value : "none";
3730
+ return oldValue;
3731
+ }
3732
+ function cloakAndComputeStyles(valuesMap, driver, elements, elementPropsMap, defaultStyle) {
3733
+ const cloakVals = [];
3734
+ elements.forEach((element) => cloakVals.push(cloakElement(element)));
3735
+ const failedElements = [];
3736
+ elementPropsMap.forEach((props, element) => {
3737
+ const styles = /* @__PURE__ */ new Map();
3738
+ props.forEach((prop) => {
3739
+ const value = driver.computeStyle(element, prop, defaultStyle);
3740
+ styles.set(prop, value);
3741
+ if (!value || value.length == 0) {
3742
+ element[REMOVAL_FLAG] = NULL_REMOVED_QUERIED_STATE;
3743
+ failedElements.push(element);
3744
+ }
3745
+ });
3746
+ valuesMap.set(element, styles);
3747
+ });
3748
+ let i = 0;
3749
+ elements.forEach((element) => cloakElement(element, cloakVals[i++]));
3750
+ return failedElements;
3751
+ }
3752
+ function buildRootMap(roots, nodes) {
3753
+ const rootMap = /* @__PURE__ */ new Map();
3754
+ roots.forEach((root) => rootMap.set(root, []));
3755
+ if (nodes.length == 0) return rootMap;
3756
+ const NULL_NODE = 1;
3757
+ const nodeSet = new Set(nodes);
3758
+ const localRootMap = /* @__PURE__ */ new Map();
3759
+ function getRoot(node) {
3760
+ if (!node) return NULL_NODE;
3761
+ let root = localRootMap.get(node);
3762
+ if (root) return root;
3763
+ const parent = node.parentNode;
3764
+ if (rootMap.has(parent)) {
3765
+ root = parent;
3766
+ } else if (nodeSet.has(parent)) {
3767
+ root = NULL_NODE;
3768
+ } else {
3769
+ root = getRoot(parent);
3770
+ }
3771
+ localRootMap.set(node, root);
3772
+ return root;
3773
+ }
3774
+ nodes.forEach((node) => {
3775
+ const root = getRoot(node);
3776
+ if (root !== NULL_NODE) {
3777
+ rootMap.get(root).push(node);
3778
+ }
3779
+ });
3780
+ return rootMap;
3781
+ }
3782
+ function addClass(element, className) {
3783
+ element.classList?.add(className);
3784
+ }
3785
+ function removeClass(element, className) {
3786
+ element.classList?.remove(className);
3787
+ }
3788
+ function removeNodesAfterAnimationDone(engine, element, players) {
3789
+ optimizeGroupPlayer(players).onDone(() => engine.processLeaveNode(element));
3790
+ }
3791
+ function flattenGroupPlayers(players) {
3792
+ const finalPlayers = [];
3793
+ _flattenGroupPlayersRecur(players, finalPlayers);
3794
+ return finalPlayers;
3795
+ }
3796
+ function _flattenGroupPlayersRecur(players, finalPlayers) {
3797
+ for (let i = 0; i < players.length; i++) {
3798
+ const player = players[i];
3799
+ if (player instanceof AnimationGroupPlayer) {
3800
+ _flattenGroupPlayersRecur(player.players, finalPlayers);
3801
+ } else {
3802
+ finalPlayers.push(player);
3803
+ }
3804
+ }
3805
+ }
3806
+ function objEquals(a, b) {
3807
+ const k1 = Object.keys(a);
3808
+ const k2 = Object.keys(b);
3809
+ if (k1.length != k2.length) return false;
3810
+ for (let i = 0; i < k1.length; i++) {
3811
+ const prop = k1[i];
3812
+ if (!b.hasOwnProperty(prop) || a[prop] !== b[prop]) return false;
3813
+ }
3814
+ return true;
3815
+ }
3816
+ function replacePostStylesAsPre(element, allPreStyleElements, allPostStyleElements) {
3817
+ const postEntry = allPostStyleElements.get(element);
3818
+ if (!postEntry) return false;
3819
+ let preEntry = allPreStyleElements.get(element);
3820
+ if (preEntry) {
3821
+ postEntry.forEach((data) => preEntry.add(data));
3822
+ } else {
3823
+ allPreStyleElements.set(element, postEntry);
3824
+ }
3825
+ allPostStyleElements.delete(element);
3826
+ return true;
3827
+ }
3828
+ var AnimationEngine = class {
3829
+ _driver;
3830
+ _normalizer;
3831
+ _transitionEngine;
3832
+ _timelineEngine;
3833
+ _triggerCache = {};
3834
+ // this method is designed to be overridden by the code that uses this engine
3835
+ onRemovalComplete = (element, context) => {
3836
+ };
3837
+ constructor(doc, _driver, _normalizer) {
3838
+ this._driver = _driver;
3839
+ this._normalizer = _normalizer;
3840
+ this._transitionEngine = new TransitionAnimationEngine(doc.body, _driver, _normalizer);
3841
+ this._timelineEngine = new TimelineAnimationEngine(doc.body, _driver, _normalizer);
3842
+ this._transitionEngine.onRemovalComplete = (element, context) => this.onRemovalComplete(element, context);
3843
+ }
3844
+ registerTrigger(componentId, namespaceId, hostElement, name, metadata) {
3845
+ const cacheKey = componentId + "-" + name;
3846
+ let trigger = this._triggerCache[cacheKey];
3847
+ if (!trigger) {
3848
+ const errors = [];
3849
+ const warnings = [];
3850
+ const ast = buildAnimationAst(this._driver, metadata, errors, warnings);
3851
+ if (errors.length) {
3852
+ throw triggerBuildFailed(name, errors);
3853
+ }
3854
+ if (typeof ngDevMode === "undefined" || ngDevMode) {
3855
+ if (warnings.length) {
3856
+ warnTriggerBuild(name, warnings);
3857
+ }
3858
+ }
3859
+ trigger = buildTrigger(name, ast, this._normalizer);
3860
+ this._triggerCache[cacheKey] = trigger;
3861
+ }
3862
+ this._transitionEngine.registerTrigger(namespaceId, name, trigger);
3863
+ }
3864
+ register(namespaceId, hostElement) {
3865
+ this._transitionEngine.register(namespaceId, hostElement);
3866
+ }
3867
+ destroy(namespaceId, context) {
3868
+ this._transitionEngine.destroy(namespaceId, context);
3869
+ }
3870
+ onInsert(namespaceId, element, parent, insertBefore) {
3871
+ this._transitionEngine.insertNode(namespaceId, element, parent, insertBefore);
3872
+ }
3873
+ onRemove(namespaceId, element, context) {
3874
+ this._transitionEngine.removeNode(namespaceId, element, context);
3875
+ }
3876
+ disableAnimations(element, disable) {
3877
+ this._transitionEngine.markElementAsDisabled(element, disable);
3878
+ }
3879
+ process(namespaceId, element, property, value) {
3880
+ if (property.charAt(0) == "@") {
3881
+ const [id, action] = parseTimelineCommand(property);
3882
+ const args = value;
3883
+ this._timelineEngine.command(id, element, action, args);
3884
+ } else {
3885
+ this._transitionEngine.trigger(namespaceId, element, property, value);
3886
+ }
3887
+ }
3888
+ listen(namespaceId, element, eventName, eventPhase, callback) {
3889
+ if (eventName.charAt(0) == "@") {
3890
+ const [id, action] = parseTimelineCommand(eventName);
3891
+ return this._timelineEngine.listen(id, element, action, callback);
3892
+ }
3893
+ return this._transitionEngine.listen(namespaceId, element, eventName, eventPhase, callback);
3894
+ }
3895
+ flush(microtaskId = -1) {
3896
+ this._transitionEngine.flush(microtaskId);
3897
+ }
3898
+ get players() {
3899
+ return [...this._transitionEngine.players, ...this._timelineEngine.players];
3900
+ }
3901
+ whenRenderingDone() {
3902
+ return this._transitionEngine.whenRenderingDone();
3903
+ }
3904
+ afterFlushAnimationsDone(cb) {
3905
+ this._transitionEngine.afterFlushAnimationsDone(cb);
3906
+ }
3907
+ };
3908
+ function packageNonAnimatableStyles(element, styles) {
3909
+ let startStyles = null;
3910
+ let endStyles = null;
3911
+ if (Array.isArray(styles) && styles.length) {
3912
+ startStyles = filterNonAnimatableStyles(styles[0]);
3913
+ if (styles.length > 1) {
3914
+ endStyles = filterNonAnimatableStyles(styles[styles.length - 1]);
3915
+ }
3916
+ } else if (styles instanceof Map) {
3917
+ startStyles = filterNonAnimatableStyles(styles);
3918
+ }
3919
+ return startStyles || endStyles ? new SpecialCasedStyles(element, startStyles, endStyles) : null;
3920
+ }
3921
+ var SpecialCasedStyles = class _SpecialCasedStyles {
3922
+ _element;
3923
+ _startStyles;
3924
+ _endStyles;
3925
+ static initialStylesByElement = /* @__PURE__ */ new WeakMap();
3926
+ _state = 0;
3927
+ _initialStyles;
3928
+ constructor(_element, _startStyles, _endStyles) {
3929
+ this._element = _element;
3930
+ this._startStyles = _startStyles;
3931
+ this._endStyles = _endStyles;
3932
+ let initialStyles = _SpecialCasedStyles.initialStylesByElement.get(_element);
3933
+ if (!initialStyles) {
3934
+ _SpecialCasedStyles.initialStylesByElement.set(_element, initialStyles = /* @__PURE__ */ new Map());
3935
+ }
3936
+ this._initialStyles = initialStyles;
3937
+ }
3938
+ start() {
3939
+ if (this._state < 1) {
3940
+ if (this._startStyles) {
3941
+ setStyles(this._element, this._startStyles, this._initialStyles);
3942
+ }
3943
+ this._state = 1;
3944
+ }
3945
+ }
3946
+ finish() {
3947
+ this.start();
3948
+ if (this._state < 2) {
3949
+ setStyles(this._element, this._initialStyles);
3950
+ if (this._endStyles) {
3951
+ setStyles(this._element, this._endStyles);
3952
+ this._endStyles = null;
3953
+ }
3954
+ this._state = 1;
3955
+ }
3956
+ }
3957
+ destroy() {
3958
+ this.finish();
3959
+ if (this._state < 3) {
3960
+ _SpecialCasedStyles.initialStylesByElement.delete(this._element);
3961
+ if (this._startStyles) {
3962
+ eraseStyles(this._element, this._startStyles);
3963
+ this._endStyles = null;
3964
+ }
3965
+ if (this._endStyles) {
3966
+ eraseStyles(this._element, this._endStyles);
3967
+ this._endStyles = null;
3968
+ }
3969
+ setStyles(this._element, this._initialStyles);
3970
+ this._state = 3;
3971
+ }
3972
+ }
3973
+ };
3974
+ function filterNonAnimatableStyles(styles) {
3975
+ let result = null;
3976
+ styles.forEach((val, prop) => {
3977
+ if (isNonAnimatableStyle(prop)) {
3978
+ result = result || /* @__PURE__ */ new Map();
3979
+ result.set(prop, val);
3980
+ }
3981
+ });
3982
+ return result;
3983
+ }
3984
+ function isNonAnimatableStyle(prop) {
3985
+ return prop === "display" || prop === "position";
3986
+ }
3987
+ var WebAnimationsPlayer = class {
3988
+ element;
3989
+ keyframes;
3990
+ options;
3991
+ _specialStyles;
3992
+ _onDoneFns = [];
3993
+ _onStartFns = [];
3994
+ _onDestroyFns = [];
3995
+ _duration;
3996
+ _delay;
3997
+ _initialized = false;
3998
+ _finished = false;
3999
+ _started = false;
4000
+ _destroyed = false;
4001
+ _finalKeyframe;
4002
+ // the following original fns are persistent copies of the _onStartFns and _onDoneFns
4003
+ // and are used to reset the fns to their original values upon reset()
4004
+ // (since the _onStartFns and _onDoneFns get deleted after they are called)
4005
+ _originalOnDoneFns = [];
4006
+ _originalOnStartFns = [];
4007
+ // using non-null assertion because it's re(set) by init();
4008
+ domPlayer;
4009
+ time = 0;
4010
+ parentPlayer = null;
4011
+ currentSnapshot = /* @__PURE__ */ new Map();
4012
+ constructor(element, keyframes, options, _specialStyles) {
4013
+ this.element = element;
4014
+ this.keyframes = keyframes;
4015
+ this.options = options;
4016
+ this._specialStyles = _specialStyles;
4017
+ this._duration = options["duration"];
4018
+ this._delay = options["delay"] || 0;
4019
+ this.time = this._duration + this._delay;
4020
+ }
4021
+ _onFinish() {
4022
+ if (!this._finished) {
4023
+ this._finished = true;
4024
+ this._onDoneFns.forEach((fn) => fn());
4025
+ this._onDoneFns = [];
4026
+ }
4027
+ }
4028
+ init() {
4029
+ this._buildPlayer();
4030
+ this._preparePlayerBeforeStart();
4031
+ }
4032
+ _buildPlayer() {
4033
+ if (this._initialized) return;
4034
+ this._initialized = true;
4035
+ const keyframes = this.keyframes;
4036
+ this.domPlayer = this._triggerWebAnimation(this.element, keyframes, this.options);
4037
+ this._finalKeyframe = keyframes.length ? keyframes[keyframes.length - 1] : /* @__PURE__ */ new Map();
4038
+ const onFinish = () => this._onFinish();
4039
+ this.domPlayer.addEventListener("finish", onFinish);
4040
+ this.onDestroy(() => {
4041
+ this.domPlayer.removeEventListener("finish", onFinish);
4042
+ });
4043
+ }
4044
+ _preparePlayerBeforeStart() {
4045
+ if (this._delay) {
4046
+ this._resetDomPlayerState();
4047
+ } else {
4048
+ this.domPlayer.pause();
4049
+ }
4050
+ }
4051
+ _convertKeyframesToObject(keyframes) {
4052
+ const kfs = [];
4053
+ keyframes.forEach((frame) => {
4054
+ kfs.push(Object.fromEntries(frame));
4055
+ });
4056
+ return kfs;
4057
+ }
4058
+ /** @internal */
4059
+ _triggerWebAnimation(element, keyframes, options) {
4060
+ return element.animate(this._convertKeyframesToObject(keyframes), options);
4061
+ }
4062
+ onStart(fn) {
4063
+ this._originalOnStartFns.push(fn);
4064
+ this._onStartFns.push(fn);
4065
+ }
4066
+ onDone(fn) {
4067
+ this._originalOnDoneFns.push(fn);
4068
+ this._onDoneFns.push(fn);
4069
+ }
4070
+ onDestroy(fn) {
4071
+ this._onDestroyFns.push(fn);
4072
+ }
4073
+ play() {
4074
+ this._buildPlayer();
4075
+ if (!this.hasStarted()) {
4076
+ this._onStartFns.forEach((fn) => fn());
4077
+ this._onStartFns = [];
4078
+ this._started = true;
4079
+ if (this._specialStyles) {
4080
+ this._specialStyles.start();
4081
+ }
4082
+ }
4083
+ this.domPlayer.play();
4084
+ }
4085
+ pause() {
4086
+ this.init();
4087
+ this.domPlayer.pause();
4088
+ }
4089
+ finish() {
4090
+ this.init();
4091
+ if (this._specialStyles) {
4092
+ this._specialStyles.finish();
4093
+ }
4094
+ this._onFinish();
4095
+ this.domPlayer.finish();
4096
+ }
4097
+ reset() {
4098
+ this._resetDomPlayerState();
4099
+ this._destroyed = false;
4100
+ this._finished = false;
4101
+ this._started = false;
4102
+ this._onStartFns = this._originalOnStartFns;
4103
+ this._onDoneFns = this._originalOnDoneFns;
4104
+ }
4105
+ _resetDomPlayerState() {
4106
+ if (this.domPlayer) {
4107
+ this.domPlayer.cancel();
4108
+ }
4109
+ }
4110
+ restart() {
4111
+ this.reset();
4112
+ this.play();
4113
+ }
4114
+ hasStarted() {
4115
+ return this._started;
4116
+ }
4117
+ destroy() {
4118
+ if (!this._destroyed) {
4119
+ this._destroyed = true;
4120
+ this._resetDomPlayerState();
4121
+ this._onFinish();
4122
+ if (this._specialStyles) {
4123
+ this._specialStyles.destroy();
4124
+ }
4125
+ this._onDestroyFns.forEach((fn) => fn());
4126
+ this._onDestroyFns = [];
4127
+ }
4128
+ }
4129
+ setPosition(p) {
4130
+ if (this.domPlayer === void 0) {
4131
+ this.init();
4132
+ }
4133
+ this.domPlayer.currentTime = p * this.time;
4134
+ }
4135
+ getPosition() {
4136
+ return +(this.domPlayer.currentTime ?? 0) / this.time;
4137
+ }
4138
+ get totalTime() {
4139
+ return this._delay + this._duration;
4140
+ }
4141
+ beforeDestroy() {
4142
+ const styles = /* @__PURE__ */ new Map();
4143
+ if (this.hasStarted()) {
4144
+ const finalKeyframe = this._finalKeyframe;
4145
+ finalKeyframe.forEach((val, prop) => {
4146
+ if (prop !== "offset") {
4147
+ styles.set(prop, this._finished ? val : computeStyle(this.element, prop));
4148
+ }
4149
+ });
4150
+ }
4151
+ this.currentSnapshot = styles;
4152
+ }
4153
+ /** @internal */
4154
+ triggerCallback(phaseName) {
4155
+ const methods = phaseName === "start" ? this._onStartFns : this._onDoneFns;
4156
+ methods.forEach((fn) => fn());
4157
+ methods.length = 0;
4158
+ }
4159
+ };
4160
+ var WebAnimationsDriver = class {
4161
+ validateStyleProperty(prop) {
4162
+ if (typeof ngDevMode === "undefined" || ngDevMode) {
4163
+ return validateStyleProperty(prop);
4164
+ }
4165
+ return true;
4166
+ }
4167
+ validateAnimatableStyleProperty(prop) {
4168
+ if (typeof ngDevMode === "undefined" || ngDevMode) {
4169
+ const cssProp = camelCaseToDashCase(prop);
4170
+ return validateWebAnimatableStyleProperty(cssProp);
4171
+ }
4172
+ return true;
4173
+ }
4174
+ containsElement(elm1, elm2) {
4175
+ return containsElement(elm1, elm2);
4176
+ }
4177
+ getParentElement(element) {
4178
+ return getParentElement(element);
4179
+ }
4180
+ query(element, selector, multi) {
4181
+ return invokeQuery(element, selector, multi);
4182
+ }
4183
+ computeStyle(element, prop, defaultValue) {
4184
+ return computeStyle(element, prop);
4185
+ }
4186
+ animate(element, keyframes, duration, delay, easing, previousPlayers = []) {
4187
+ const fill = delay == 0 ? "both" : "forwards";
4188
+ const playerOptions = {
4189
+ duration,
4190
+ delay,
4191
+ fill
4192
+ };
4193
+ if (easing) {
4194
+ playerOptions["easing"] = easing;
4195
+ }
4196
+ const previousStyles = /* @__PURE__ */ new Map();
4197
+ const previousWebAnimationPlayers = previousPlayers.filter((player) => player instanceof WebAnimationsPlayer);
4198
+ if (allowPreviousPlayerStylesMerge(duration, delay)) {
4199
+ previousWebAnimationPlayers.forEach((player) => {
4200
+ player.currentSnapshot.forEach((val, prop) => previousStyles.set(prop, val));
4201
+ });
4202
+ }
4203
+ let _keyframes = normalizeKeyframes(keyframes).map((styles) => new Map(styles));
4204
+ _keyframes = balancePreviousStylesIntoKeyframes(element, _keyframes, previousStyles);
4205
+ const specialStyles = packageNonAnimatableStyles(element, _keyframes);
4206
+ return new WebAnimationsPlayer(element, _keyframes, playerOptions, specialStyles);
4207
+ }
4208
+ };
4209
+ function createEngine(type, doc) {
4210
+ if (type === "noop") {
4211
+ return new AnimationEngine(doc, new NoopAnimationDriver(), new NoopAnimationStyleNormalizer());
4212
+ }
4213
+ return new AnimationEngine(doc, new WebAnimationsDriver(), new WebAnimationsStyleNormalizer());
4214
+ }
4215
+ var Animation = class {
4216
+ _driver;
4217
+ _animationAst;
4218
+ constructor(_driver, input) {
4219
+ this._driver = _driver;
4220
+ const errors = [];
4221
+ const warnings = [];
4222
+ const ast = buildAnimationAst(_driver, input, errors, warnings);
4223
+ if (errors.length) {
4224
+ throw validationFailed(errors);
4225
+ }
4226
+ if (typeof ngDevMode === "undefined" || ngDevMode) {
4227
+ if (warnings.length) {
4228
+ warnValidation(warnings);
4229
+ }
4230
+ }
4231
+ this._animationAst = ast;
4232
+ }
4233
+ buildTimelines(element, startingStyles, destinationStyles, options, subInstructions) {
4234
+ const start = Array.isArray(startingStyles) ? normalizeStyles(startingStyles) : startingStyles;
4235
+ const dest = Array.isArray(destinationStyles) ? normalizeStyles(destinationStyles) : destinationStyles;
4236
+ const errors = [];
4237
+ subInstructions = subInstructions || new ElementInstructionMap();
4238
+ const result = buildAnimationTimelines(this._driver, element, this._animationAst, ENTER_CLASSNAME, LEAVE_CLASSNAME, start, dest, options, subInstructions, errors);
4239
+ if (errors.length) {
4240
+ throw buildingFailed(errors);
4241
+ }
4242
+ return result;
4243
+ }
4244
+ };
4245
+ var ANIMATION_PREFIX = "@";
4246
+ var DISABLE_ANIMATIONS_FLAG = "@.disabled";
4247
+ var BaseAnimationRenderer = class {
4248
+ namespaceId;
4249
+ delegate;
4250
+ engine;
4251
+ _onDestroy;
4252
+ // We need to explicitly type this property because of an api-extractor bug
4253
+ // See https://github.com/microsoft/rushstack/issues/4390
4254
+ \u0275type = 0;
4255
+ constructor(namespaceId, delegate, engine, _onDestroy) {
4256
+ this.namespaceId = namespaceId;
4257
+ this.delegate = delegate;
4258
+ this.engine = engine;
4259
+ this._onDestroy = _onDestroy;
4260
+ }
4261
+ get data() {
4262
+ return this.delegate.data;
4263
+ }
4264
+ destroyNode(node) {
4265
+ this.delegate.destroyNode?.(node);
4266
+ }
4267
+ destroy() {
4268
+ this.engine.destroy(this.namespaceId, this.delegate);
4269
+ this.engine.afterFlushAnimationsDone(() => {
4270
+ queueMicrotask(() => {
4271
+ this.delegate.destroy();
4272
+ });
4273
+ });
4274
+ this._onDestroy?.();
4275
+ }
4276
+ createElement(name, namespace) {
4277
+ return this.delegate.createElement(name, namespace);
4278
+ }
4279
+ createComment(value) {
4280
+ return this.delegate.createComment(value);
4281
+ }
4282
+ createText(value) {
4283
+ return this.delegate.createText(value);
4284
+ }
4285
+ appendChild(parent, newChild) {
4286
+ this.delegate.appendChild(parent, newChild);
4287
+ this.engine.onInsert(this.namespaceId, newChild, parent, false);
4288
+ }
4289
+ insertBefore(parent, newChild, refChild, isMove = true) {
4290
+ this.delegate.insertBefore(parent, newChild, refChild);
4291
+ this.engine.onInsert(this.namespaceId, newChild, parent, isMove);
4292
+ }
4293
+ removeChild(parent, oldChild, isHostElement) {
4294
+ if (this.parentNode(oldChild)) {
4295
+ this.engine.onRemove(this.namespaceId, oldChild, this.delegate);
4296
+ }
4297
+ }
4298
+ selectRootElement(selectorOrNode, preserveContent) {
4299
+ return this.delegate.selectRootElement(selectorOrNode, preserveContent);
4300
+ }
4301
+ parentNode(node) {
4302
+ return this.delegate.parentNode(node);
4303
+ }
4304
+ nextSibling(node) {
4305
+ return this.delegate.nextSibling(node);
4306
+ }
4307
+ setAttribute(el, name, value, namespace) {
4308
+ this.delegate.setAttribute(el, name, value, namespace);
4309
+ }
4310
+ removeAttribute(el, name, namespace) {
4311
+ this.delegate.removeAttribute(el, name, namespace);
4312
+ }
4313
+ addClass(el, name) {
4314
+ this.delegate.addClass(el, name);
4315
+ }
4316
+ removeClass(el, name) {
4317
+ this.delegate.removeClass(el, name);
4318
+ }
4319
+ setStyle(el, style2, value, flags) {
4320
+ this.delegate.setStyle(el, style2, value, flags);
4321
+ }
4322
+ removeStyle(el, style2, flags) {
4323
+ this.delegate.removeStyle(el, style2, flags);
4324
+ }
4325
+ setProperty(el, name, value) {
4326
+ if (name.charAt(0) == ANIMATION_PREFIX && name == DISABLE_ANIMATIONS_FLAG) {
4327
+ this.disableAnimations(el, !!value);
4328
+ } else {
4329
+ this.delegate.setProperty(el, name, value);
4330
+ }
4331
+ }
4332
+ setValue(node, value) {
4333
+ this.delegate.setValue(node, value);
4334
+ }
4335
+ listen(target, eventName, callback) {
4336
+ return this.delegate.listen(target, eventName, callback);
4337
+ }
4338
+ disableAnimations(element, value) {
4339
+ this.engine.disableAnimations(element, value);
4340
+ }
4341
+ };
4342
+ var AnimationRenderer = class extends BaseAnimationRenderer {
4343
+ factory;
4344
+ constructor(factory, namespaceId, delegate, engine, onDestroy) {
4345
+ super(namespaceId, delegate, engine, onDestroy);
4346
+ this.factory = factory;
4347
+ this.namespaceId = namespaceId;
4348
+ }
4349
+ setProperty(el, name, value) {
4350
+ if (name.charAt(0) == ANIMATION_PREFIX) {
4351
+ if (name.charAt(1) == "." && name == DISABLE_ANIMATIONS_FLAG) {
4352
+ value = value === void 0 ? true : !!value;
4353
+ this.disableAnimations(el, value);
4354
+ } else {
4355
+ this.engine.process(this.namespaceId, el, name.slice(1), value);
4356
+ }
4357
+ } else {
4358
+ this.delegate.setProperty(el, name, value);
4359
+ }
4360
+ }
4361
+ listen(target, eventName, callback) {
4362
+ if (eventName.charAt(0) == ANIMATION_PREFIX) {
4363
+ const element = resolveElementFromTarget(target);
4364
+ let name = eventName.slice(1);
4365
+ let phase = "";
4366
+ if (name.charAt(0) != ANIMATION_PREFIX) {
4367
+ [name, phase] = parseTriggerCallbackName(name);
4368
+ }
4369
+ return this.engine.listen(this.namespaceId, element, name, phase, (event) => {
4370
+ const countId = event["_data"] || -1;
4371
+ this.factory.scheduleListenerCallback(countId, callback, event);
4372
+ });
4373
+ }
4374
+ return this.delegate.listen(target, eventName, callback);
4375
+ }
4376
+ };
4377
+ function resolveElementFromTarget(target) {
4378
+ switch (target) {
4379
+ case "body":
4380
+ return document.body;
4381
+ case "document":
4382
+ return document;
4383
+ case "window":
4384
+ return window;
4385
+ default:
4386
+ return target;
4387
+ }
4388
+ }
4389
+ function parseTriggerCallbackName(triggerName) {
4390
+ const dotIndex = triggerName.indexOf(".");
4391
+ const trigger = triggerName.substring(0, dotIndex);
4392
+ const phase = triggerName.slice(dotIndex + 1);
4393
+ return [trigger, phase];
4394
+ }
4395
+ var AnimationRendererFactory = class {
4396
+ delegate;
4397
+ engine;
4398
+ _zone;
4399
+ _currentId = 0;
4400
+ _microtaskId = 1;
4401
+ _animationCallbacksBuffer = [];
4402
+ _rendererCache = /* @__PURE__ */ new Map();
4403
+ _cdRecurDepth = 0;
4404
+ constructor(delegate, engine, _zone) {
4405
+ this.delegate = delegate;
4406
+ this.engine = engine;
4407
+ this._zone = _zone;
4408
+ engine.onRemovalComplete = (element, delegate2) => {
4409
+ delegate2?.removeChild(null, element);
4410
+ };
4411
+ }
4412
+ createRenderer(hostElement, type) {
4413
+ const EMPTY_NAMESPACE_ID = "";
4414
+ const delegate = this.delegate.createRenderer(hostElement, type);
4415
+ if (!hostElement || !type?.data?.["animation"]) {
4416
+ const cache = this._rendererCache;
4417
+ let renderer = cache.get(delegate);
4418
+ if (!renderer) {
4419
+ const onRendererDestroy = () => cache.delete(delegate);
4420
+ renderer = new BaseAnimationRenderer(EMPTY_NAMESPACE_ID, delegate, this.engine, onRendererDestroy);
4421
+ cache.set(delegate, renderer);
4422
+ }
4423
+ return renderer;
4424
+ }
4425
+ const componentId = type.id;
4426
+ const namespaceId = type.id + "-" + this._currentId;
4427
+ this._currentId++;
4428
+ this.engine.register(namespaceId, hostElement);
4429
+ const registerTrigger = (trigger) => {
4430
+ if (Array.isArray(trigger)) {
4431
+ trigger.forEach(registerTrigger);
4432
+ } else {
4433
+ this.engine.registerTrigger(componentId, namespaceId, hostElement, trigger.name, trigger);
4434
+ }
4435
+ };
4436
+ const animationTriggers = type.data["animation"];
4437
+ animationTriggers.forEach(registerTrigger);
4438
+ return new AnimationRenderer(this, namespaceId, delegate, this.engine);
4439
+ }
4440
+ begin() {
4441
+ this._cdRecurDepth++;
4442
+ if (this.delegate.begin) {
4443
+ this.delegate.begin();
4444
+ }
4445
+ }
4446
+ _scheduleCountTask() {
4447
+ queueMicrotask(() => {
4448
+ this._microtaskId++;
4449
+ });
4450
+ }
4451
+ /** @internal */
4452
+ scheduleListenerCallback(count, fn, data) {
4453
+ if (count >= 0 && count < this._microtaskId) {
4454
+ this._zone.run(() => fn(data));
4455
+ return;
4456
+ }
4457
+ const animationCallbacksBuffer = this._animationCallbacksBuffer;
4458
+ if (animationCallbacksBuffer.length == 0) {
4459
+ queueMicrotask(() => {
4460
+ this._zone.run(() => {
4461
+ animationCallbacksBuffer.forEach((tuple) => {
4462
+ const [fn2, data2] = tuple;
4463
+ fn2(data2);
4464
+ });
4465
+ this._animationCallbacksBuffer = [];
4466
+ });
4467
+ });
4468
+ }
4469
+ animationCallbacksBuffer.push([fn, data]);
4470
+ }
4471
+ end() {
4472
+ this._cdRecurDepth--;
4473
+ if (this._cdRecurDepth == 0) {
4474
+ this._zone.runOutsideAngular(() => {
4475
+ this._scheduleCountTask();
4476
+ this.engine.flush(this._microtaskId);
4477
+ });
4478
+ }
4479
+ if (this.delegate.end) {
4480
+ this.delegate.end();
4481
+ }
4482
+ }
4483
+ whenRenderingDone() {
4484
+ return this.engine.whenRenderingDone();
4485
+ }
4486
+ /**
4487
+ * Used during HMR to clear any cached data about a component.
4488
+ * @param componentId ID of the component that is being replaced.
4489
+ */
4490
+ componentReplaced(componentId) {
4491
+ this.delegate.componentReplaced?.(componentId);
4492
+ }
4493
+ };
4494
+ export {
4495
+ AnimationDriver,
4496
+ NoopAnimationDriver,
4497
+ Animation as \u0275Animation,
4498
+ AnimationEngine as \u0275AnimationEngine,
4499
+ AnimationRenderer as \u0275AnimationRenderer,
4500
+ AnimationRendererFactory as \u0275AnimationRendererFactory,
4501
+ AnimationStyleNormalizer as \u0275AnimationStyleNormalizer,
4502
+ BaseAnimationRenderer as \u0275BaseAnimationRenderer,
4503
+ NoopAnimationStyleNormalizer as \u0275NoopAnimationStyleNormalizer,
4504
+ WebAnimationsDriver as \u0275WebAnimationsDriver,
4505
+ WebAnimationsPlayer as \u0275WebAnimationsPlayer,
4506
+ WebAnimationsStyleNormalizer as \u0275WebAnimationsStyleNormalizer,
4507
+ allowPreviousPlayerStylesMerge as \u0275allowPreviousPlayerStylesMerge,
4508
+ camelCaseToDashCase as \u0275camelCaseToDashCase,
4509
+ containsElement as \u0275containsElement,
4510
+ createEngine as \u0275createEngine,
4511
+ getParentElement as \u0275getParentElement,
4512
+ invokeQuery as \u0275invokeQuery,
4513
+ normalizeKeyframes as \u0275normalizeKeyframes,
4514
+ validateStyleProperty as \u0275validateStyleProperty,
4515
+ validateWebAnimatableStyleProperty as \u0275validateWebAnimatableStyleProperty
4516
+ };
4517
+ /*! Bundled license information:
4518
+
4519
+ @angular/animations/fesm2022/animations.mjs:
4520
+ (**
4521
+ * @license Angular v19.0.7
4522
+ * (c) 2010-2024 Google LLC. https://angular.io/
4523
+ * License: MIT
4524
+ *)
4525
+
4526
+ @angular/animations/fesm2022/browser.mjs:
4527
+ (**
4528
+ * @license Angular v19.0.7
4529
+ * (c) 2010-2024 Google LLC. https://angular.io/
4530
+ * License: MIT
4531
+ *)
4532
+ */
4533
+ //# sourceMappingURL=chunk-EPVQ75R6.js.map