@flemo/core 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.
Files changed (36) hide show
  1. package/LICENSE +21 -0
  2. package/dist/core/TaskManger.d.ts +62 -0
  3. package/dist/core/__tests__/TaskManger.test.d.ts +1 -0
  4. package/dist/history/__tests__/store.test.d.ts +1 -0
  5. package/dist/history/store.d.ts +17 -0
  6. package/dist/index.d.ts +23 -0
  7. package/dist/index.mjs +965 -0
  8. package/dist/navigate/__tests__/selfPopGuard.test.d.ts +1 -0
  9. package/dist/navigate/selfPopGuard.d.ts +12 -0
  10. package/dist/navigate/store.d.ts +9 -0
  11. package/dist/transition/__tests__/compileTransitionStyles.test.d.ts +7 -0
  12. package/dist/transition/compileTransitionStyles.d.ts +13 -0
  13. package/dist/transition/createRawTransition.d.ts +18 -0
  14. package/dist/transition/createTransition.d.ts +14 -0
  15. package/dist/transition/cssTypes.d.ts +22 -0
  16. package/dist/transition/cupertino.d.ts +2 -0
  17. package/dist/transition/decorator/createDecorator.d.ts +12 -0
  18. package/dist/transition/decorator/createRawDecorator.d.ts +19 -0
  19. package/dist/transition/decorator/decorator.d.ts +2 -0
  20. package/dist/transition/decorator/overlay.d.ts +2 -0
  21. package/dist/transition/decorator/typing.d.ts +24 -0
  22. package/dist/transition/layout.d.ts +2 -0
  23. package/dist/transition/material.d.ts +2 -0
  24. package/dist/transition/none.d.ts +2 -0
  25. package/dist/transition/store.d.ts +7 -0
  26. package/dist/transition/transition.d.ts +2 -0
  27. package/dist/transition/typing.d.ts +61 -0
  28. package/dist/utils/__tests__/findScrollable.test.d.ts +1 -0
  29. package/dist/utils/__tests__/getMatchedPathPattern.test.d.ts +1 -0
  30. package/dist/utils/__tests__/getParams.test.d.ts +1 -0
  31. package/dist/utils/__tests__/isServer.test.d.ts +1 -0
  32. package/dist/utils/findScrollable.d.ts +21 -0
  33. package/dist/utils/getMatchedPathPattern.d.ts +2 -0
  34. package/dist/utils/getParams.d.ts +4 -0
  35. package/dist/utils/isServer.d.ts +1 -0
  36. package/package.json +62 -0
package/dist/index.mjs ADDED
@@ -0,0 +1,965 @@
1
+ import { create as D } from "zustand";
2
+ import { pathToRegexp as w, match as H } from "path-to-regexp";
3
+ class U {
4
+ tasks = /* @__PURE__ */ new Map();
5
+ instanceId = Date.now().toString();
6
+ isLocked = !1;
7
+ currentTaskId = null;
8
+ taskQueue = Promise.resolve();
9
+ signalListeners = /* @__PURE__ */ new Map();
10
+ pendingTaskQueue = [];
11
+ isProcessingPending = !1;
12
+ async acquireLock(t) {
13
+ for (let a = 0; a < 10; a++) {
14
+ if (!this.isLocked)
15
+ return this.isLocked = !0, this.currentTaskId = t, !0;
16
+ await new Promise((r) => setTimeout(r, 100));
17
+ }
18
+ return !1;
19
+ }
20
+ releaseLock(t) {
21
+ this.currentTaskId === t && (this.isLocked = !1, this.currentTaskId = null);
22
+ }
23
+ generateTaskId() {
24
+ return `${this.instanceId}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
25
+ }
26
+ emitSignal(t) {
27
+ const e = this.signalListeners.get(t);
28
+ e && (e.forEach((s) => {
29
+ this.resolveTask(s);
30
+ }), this.signalListeners.delete(t));
31
+ }
32
+ // 대기 중인 태스크들을 처리하는 메서드
33
+ async processPendingTasks() {
34
+ if (!(this.isProcessingPending || this.pendingTaskQueue.length === 0)) {
35
+ this.isProcessingPending = !0;
36
+ try {
37
+ for (; this.pendingTaskQueue.length > 0; ) {
38
+ const t = this.pendingTaskQueue[0];
39
+ if (t.status === "COMPLETED" || t.status === "FAILED" || t.status === "ROLLEDBACK") {
40
+ this.pendingTaskQueue.shift();
41
+ continue;
42
+ }
43
+ if (t.status === "MANUAL_PENDING" || t.status === "SIGNAL_PENDING" || t.status === "PROCESSING" || t.status === "PENDING")
44
+ break;
45
+ }
46
+ } finally {
47
+ this.isProcessingPending = !1;
48
+ }
49
+ }
50
+ }
51
+ // 모든 대기 중인 태스크가 완료될 때까지 대기
52
+ async waitForPendingTasks() {
53
+ return new Promise((t) => {
54
+ const e = () => {
55
+ this.pendingTaskQueue.filter(
56
+ (a) => a.status === "MANUAL_PENDING" || a.status === "SIGNAL_PENDING"
57
+ ).length === 0 ? t() : setTimeout(e, 100);
58
+ };
59
+ e();
60
+ });
61
+ }
62
+ // 태스크 상태 변경 시 대기 큐 처리
63
+ async onTaskStatusChange(t, e) {
64
+ (e === "COMPLETED" || e === "FAILED" || e === "ROLLEDBACK") && (this.pendingTaskQueue = this.pendingTaskQueue.filter((s) => s.id !== t), await this.processPendingTasks());
65
+ }
66
+ async addTask(t, e = {}) {
67
+ const s = e.id || this.generateTaskId();
68
+ return new Promise((a, r) => {
69
+ this.taskQueue = this.taskQueue.then(async () => {
70
+ try {
71
+ const { control: i, validate: c, rollback: l, dependencies: u = [], delay: d } = e, h = new AbortController(), o = {
72
+ id: s,
73
+ execute: t,
74
+ timestamp: Date.now(),
75
+ retryCount: 0,
76
+ status: "PENDING",
77
+ dependencies: u,
78
+ instanceId: this.instanceId,
79
+ validate: c,
80
+ rollback: l,
81
+ control: i,
82
+ abortController: h
83
+ };
84
+ this.tasks.set(o.id, o), this.pendingTaskQueue.length > 0 && (this.pendingTaskQueue.push(o), await this.waitForPendingTasks(), this.pendingTaskQueue = this.pendingTaskQueue.filter((P) => P.id !== o.id));
85
+ try {
86
+ if (!await this.acquireLock(o.id))
87
+ throw o.status = "FAILED", new Error("FAILED");
88
+ try {
89
+ o.status = "PROCESSING";
90
+ for (const f of o.dependencies) {
91
+ const y = this.tasks.get(f);
92
+ if (!y || y.status !== "COMPLETED")
93
+ throw o.status = "FAILED", new Error("FAILED");
94
+ }
95
+ if (o.validate && !await o.validate())
96
+ throw o.status = "FAILED", new Error("FAILED");
97
+ d && d > 0 && await new Promise((f) => setTimeout(f, d));
98
+ const m = await o.execute(o.abortController);
99
+ if (o.abortController.signal.aborted) {
100
+ o.status = "COMPLETED", await this.onTaskStatusChange(o.id, "COMPLETED"), a({
101
+ success: !0,
102
+ result: void 0,
103
+ taskId: o.id,
104
+ timestamp: Date.now(),
105
+ instanceId: this.instanceId
106
+ });
107
+ return;
108
+ }
109
+ if (e.control) {
110
+ const f = e.control;
111
+ if (f.delay && f.delay > 0 && await new Promise((y) => setTimeout(y, f.delay)), f.manual) {
112
+ o.status = "MANUAL_PENDING", o.manualResolver = { resolve: a, reject: r, result: m }, this.pendingTaskQueue.push(o), await this.onTaskStatusChange(o.id, "MANUAL_PENDING");
113
+ return;
114
+ }
115
+ if (f.signal) {
116
+ o.status = "SIGNAL_PENDING", o.manualResolver = { resolve: a, reject: r, result: m }, this.signalListeners.has(f.signal) || this.signalListeners.set(f.signal, /* @__PURE__ */ new Set()), this.signalListeners.get(f.signal).add(o.id), this.pendingTaskQueue.push(o), await this.onTaskStatusChange(o.id, "SIGNAL_PENDING");
117
+ return;
118
+ }
119
+ if (f.condition && !await f.condition()) {
120
+ o.status = "MANUAL_PENDING", o.manualResolver = { resolve: a, reject: r, result: m }, this.pendingTaskQueue.push(o), await this.onTaskStatusChange(o.id, "MANUAL_PENDING");
121
+ return;
122
+ }
123
+ }
124
+ o.status = "COMPLETED", await this.onTaskStatusChange(o.id, "COMPLETED"), a({
125
+ success: !0,
126
+ result: m,
127
+ taskId: o.id,
128
+ timestamp: Date.now(),
129
+ instanceId: this.instanceId
130
+ });
131
+ } catch (m) {
132
+ if (o.status = "FAILED", o.rollback)
133
+ try {
134
+ await o.rollback(), o.status = "ROLLEDBACK";
135
+ } catch {
136
+ }
137
+ throw await this.onTaskStatusChange(o.id, o.status), m;
138
+ } finally {
139
+ this.releaseLock(o.id);
140
+ }
141
+ } catch (P) {
142
+ r(P);
143
+ }
144
+ } catch (i) {
145
+ r(i);
146
+ }
147
+ }).catch(r);
148
+ });
149
+ }
150
+ async resolveTask(t) {
151
+ const e = this.tasks.get(t);
152
+ if (!e || e.status !== "MANUAL_PENDING" && e.status !== "SIGNAL_PENDING")
153
+ return !1;
154
+ if (e.manualResolver) {
155
+ if (e.control?.condition && !await e.control.condition())
156
+ return !1;
157
+ e.status = "COMPLETED";
158
+ const s = e.manualResolver;
159
+ return s.resolve({
160
+ success: !0,
161
+ result: s.result,
162
+ taskId: e.id,
163
+ timestamp: Date.now(),
164
+ instanceId: this.instanceId
165
+ }), delete e.manualResolver, await this.onTaskStatusChange(t, "COMPLETED"), !0;
166
+ }
167
+ return !1;
168
+ }
169
+ async resolveAllPending() {
170
+ const t = Array.from(this.tasks.values()).filter(
171
+ (e) => ["PENDING", "MANUAL_PENDING", "SIGNAL_PENDING"].includes(e.status)
172
+ );
173
+ await Promise.all(t.map((e) => this.resolveTask(e.id)));
174
+ }
175
+ }
176
+ const ut = new U(), lt = D((n) => ({
177
+ index: -1,
178
+ histories: [],
179
+ addHistory: (t) => n((e) => ({
180
+ index: e.index + 1,
181
+ histories: e.histories.concat(t)
182
+ })),
183
+ replaceHistory: (t) => n((e) => (e.histories.splice(t, 1), {
184
+ index: e.index - 1,
185
+ histories: e.histories
186
+ })),
187
+ popHistory: (t) => n((e) => ({
188
+ index: e.index - 1,
189
+ histories: e.histories.filter((s, a) => a !== t)
190
+ }))
191
+ })), ft = D((n) => ({
192
+ status: "IDLE",
193
+ transitionTaskId: null,
194
+ setStatus: (t) => n({ status: t }),
195
+ setTransitionTaskId: (t) => n({ transitionTaskId: t })
196
+ }));
197
+ let N = 0;
198
+ function dt() {
199
+ N += 1;
200
+ }
201
+ function ht() {
202
+ return N > 0 ? (N -= 1, !0) : !1;
203
+ }
204
+ function k({
205
+ name: n,
206
+ initial: t,
207
+ idle: e,
208
+ enter: s,
209
+ enterBack: a,
210
+ exit: r,
211
+ exitBack: i,
212
+ options: c
213
+ }) {
214
+ return {
215
+ name: n,
216
+ initial: t,
217
+ variants: {
218
+ "IDLE-true": e,
219
+ "IDLE-false": e,
220
+ "PUSHING-false": r,
221
+ "PUSHING-true": s,
222
+ "REPLACING-false": r,
223
+ "REPLACING-true": s,
224
+ "POPPING-false": i,
225
+ "POPPING-true": a,
226
+ "COMPLETED-false": r,
227
+ "COMPLETED-true": s
228
+ },
229
+ ...c
230
+ };
231
+ }
232
+ function mt({
233
+ name: n,
234
+ initial: t,
235
+ idle: e,
236
+ pushOnEnter: s,
237
+ pushOnExit: a,
238
+ replaceOnEnter: r,
239
+ replaceOnExit: i,
240
+ popOnEnter: c,
241
+ popOnExit: l,
242
+ completedOnExit: u,
243
+ completedOnEnter: d,
244
+ options: h
245
+ }) {
246
+ return {
247
+ name: n,
248
+ initial: t,
249
+ variants: {
250
+ "IDLE-true": e,
251
+ "IDLE-false": e,
252
+ "PUSHING-false": a,
253
+ "PUSHING-true": s,
254
+ "REPLACING-false": i,
255
+ "REPLACING-true": r,
256
+ "POPPING-false": l,
257
+ "POPPING-true": c,
258
+ "COMPLETED-false": u,
259
+ "COMPLETED-true": d
260
+ },
261
+ ...h
262
+ };
263
+ }
264
+ const Y = (n, t, e) => {
265
+ const [s, a] = t, [r, i] = e;
266
+ if (a === s) return r;
267
+ const c = (n - s) / (a - s);
268
+ return r + c * (i - r);
269
+ }, B = k({
270
+ name: "cupertino",
271
+ initial: {
272
+ x: "100%"
273
+ },
274
+ idle: {
275
+ value: {
276
+ x: 0
277
+ },
278
+ options: {
279
+ duration: 0
280
+ }
281
+ },
282
+ enter: {
283
+ value: {
284
+ x: 0
285
+ },
286
+ options: {
287
+ duration: 0.7,
288
+ ease: [0.32, 0.72, 0, 1]
289
+ }
290
+ },
291
+ enterBack: {
292
+ value: {
293
+ x: "100%"
294
+ },
295
+ options: {
296
+ duration: 0.6,
297
+ ease: [0.32, 0.72, 0, 1]
298
+ }
299
+ },
300
+ exit: {
301
+ value: {
302
+ x: -100
303
+ },
304
+ options: {
305
+ duration: 0.7,
306
+ ease: [0.32, 0.72, 0, 1]
307
+ }
308
+ },
309
+ exitBack: {
310
+ value: {
311
+ x: 0
312
+ },
313
+ options: {
314
+ duration: 0.6,
315
+ ease: [0.32, 0.72, 0, 1]
316
+ }
317
+ },
318
+ options: {
319
+ decoratorName: "overlay",
320
+ swipeDirection: "x",
321
+ onSwipeStart: async () => !0,
322
+ onSwipe: (n, t, { animate: e, currentScreen: s, prevScreen: a, onProgress: r }) => {
323
+ const { offset: i } = t, c = i.x, l = Y(c, [0, window.innerWidth], [0, 100]);
324
+ return r?.(!0, l), e(
325
+ s,
326
+ {
327
+ x: Math.max(0, c)
328
+ },
329
+ {
330
+ duration: 0
331
+ }
332
+ ), e(
333
+ a,
334
+ {
335
+ x: -100 + l
336
+ },
337
+ {
338
+ duration: 0
339
+ }
340
+ ), l;
341
+ },
342
+ onSwipeEnd: async (n, t, { animate: e, currentScreen: s, prevScreen: a, onStart: r }) => {
343
+ const { offset: i, velocity: c } = t, u = i.x > 50 || c.x > 20;
344
+ return r?.(u), await Promise.all([
345
+ e(
346
+ s,
347
+ {
348
+ x: u ? "100%" : 0
349
+ },
350
+ {
351
+ duration: 0.3,
352
+ ease: [0.32, 0.72, 0, 1]
353
+ }
354
+ ),
355
+ e(
356
+ a,
357
+ {
358
+ x: u ? 0 : -100
359
+ },
360
+ {
361
+ duration: 0.3,
362
+ ease: [0.32, 0.72, 0, 1]
363
+ }
364
+ )
365
+ ]), u;
366
+ }
367
+ }
368
+ }), Q = (n, t, e) => {
369
+ const [s, a] = t, [r, i] = e;
370
+ if (a === s) return r;
371
+ const c = (n - s) / (a - s);
372
+ return r + c * (i - r);
373
+ }, X = k({
374
+ name: "layout",
375
+ initial: {
376
+ opacity: 0.97
377
+ },
378
+ idle: {
379
+ value: {
380
+ opacity: 1
381
+ },
382
+ options: {
383
+ duration: 0.3
384
+ }
385
+ },
386
+ enter: {
387
+ value: {
388
+ opacity: 1
389
+ },
390
+ options: {
391
+ duration: 0.3
392
+ }
393
+ },
394
+ enterBack: {
395
+ value: {
396
+ opacity: 0.97
397
+ },
398
+ options: {
399
+ duration: 0.3
400
+ }
401
+ },
402
+ exit: {
403
+ value: {
404
+ opacity: 0.97
405
+ },
406
+ options: {
407
+ duration: 0.3
408
+ }
409
+ },
410
+ exitBack: {
411
+ value: {
412
+ opacity: 1
413
+ },
414
+ options: {
415
+ duration: 0.3
416
+ }
417
+ },
418
+ options: {
419
+ decoratorName: "overlay",
420
+ swipeDirection: "y",
421
+ onSwipeStart: async () => !0,
422
+ onSwipe: (n, t, { animate: e, currentScreen: s, onProgress: a }) => {
423
+ const { offset: r } = t, i = r.y, c = Math.max(0, Math.min(56, i)), l = Q(c, [0, 56], [1, 0.96]), u = Math.max(0, i - 56), d = Math.min(1, u / 160), h = Math.sqrt(d) * 12, o = Math.max(0, c + h), p = Math.min(56, o);
424
+ return a?.(!0, 100), e(
425
+ s,
426
+ {
427
+ y: o,
428
+ opacity: l
429
+ },
430
+ {
431
+ duration: 0
432
+ }
433
+ ), p;
434
+ },
435
+ onSwipeEnd: async (n, t, { animate: e, currentScreen: s, prevScreen: a, onStart: r }) => {
436
+ const { offset: i, velocity: c } = t, u = i.y > 56 || c.y > 20;
437
+ return r?.(u), await Promise.all([
438
+ e(
439
+ s,
440
+ {
441
+ y: u ? "100%" : 0,
442
+ opacity: u ? 0.96 : 1
443
+ },
444
+ {
445
+ duration: 0.3
446
+ }
447
+ ),
448
+ e(
449
+ a,
450
+ {
451
+ y: 0,
452
+ opacity: u ? 1 : 0.97
453
+ },
454
+ {
455
+ duration: 0.3
456
+ }
457
+ )
458
+ ]), u;
459
+ }
460
+ }
461
+ }), F = k({
462
+ name: "material",
463
+ initial: {
464
+ y: "100%"
465
+ },
466
+ idle: {
467
+ value: {
468
+ y: 0
469
+ },
470
+ options: {
471
+ duration: 0
472
+ }
473
+ },
474
+ enter: {
475
+ value: {
476
+ y: 0
477
+ },
478
+ options: {
479
+ duration: 0.35,
480
+ ease: [0, 0, 0.2, 1]
481
+ }
482
+ },
483
+ enterBack: {
484
+ value: {
485
+ y: "100%"
486
+ },
487
+ options: {
488
+ duration: 0.25,
489
+ ease: [0.4, 0, 1, 1]
490
+ }
491
+ },
492
+ exit: {
493
+ value: {
494
+ y: -56
495
+ },
496
+ options: {
497
+ duration: 0.35,
498
+ ease: [0.4, 0, 1, 1]
499
+ }
500
+ },
501
+ exitBack: {
502
+ value: {
503
+ y: 0
504
+ },
505
+ options: {
506
+ duration: 0.25,
507
+ ease: [0, 0, 0.2, 1]
508
+ }
509
+ },
510
+ options: {
511
+ swipeDirection: "y",
512
+ onSwipeStart: async () => !0,
513
+ onSwipe: (n, t, { animate: e, currentScreen: s, prevScreen: a, onProgress: r }) => {
514
+ const { offset: i } = t, c = i.y, l = Math.max(0, Math.min(56, c)), u = Math.max(0, c - 56), d = Math.min(1, u / 160), h = Math.sqrt(d) * 12, o = Math.max(0, l + h), p = Math.min(56, o);
515
+ return r?.(!0, p), e(
516
+ s,
517
+ {
518
+ y: o
519
+ },
520
+ {
521
+ duration: 0
522
+ }
523
+ ), e(
524
+ a,
525
+ {
526
+ y: -56 + p
527
+ },
528
+ { duration: 0 }
529
+ ), p;
530
+ },
531
+ onSwipeEnd: async (n, t, { animate: e, currentScreen: s, prevScreen: a, onStart: r }) => {
532
+ const { offset: i, velocity: c } = t, u = i.y > 56 || c.y > 20;
533
+ return r?.(u), await Promise.all([
534
+ e(
535
+ s,
536
+ {
537
+ y: u ? "100%" : 0
538
+ },
539
+ {
540
+ duration: u ? 0.22 : 0.24,
541
+ ease: u ? [0.4, 0, 1, 1] : [0, 0, 0.2, 1]
542
+ }
543
+ ),
544
+ e(
545
+ a,
546
+ {
547
+ y: u ? 0 : -56
548
+ },
549
+ {
550
+ duration: u ? 0.22 : 0.24,
551
+ ease: u ? [0, 0, 0.2, 1] : [0.4, 0, 1, 1]
552
+ }
553
+ )
554
+ ]), u;
555
+ }
556
+ }
557
+ }), V = k({
558
+ name: "none",
559
+ initial: {},
560
+ idle: {
561
+ value: {},
562
+ options: {
563
+ duration: 0
564
+ }
565
+ },
566
+ enter: {
567
+ value: {},
568
+ options: {
569
+ duration: 0
570
+ }
571
+ },
572
+ enterBack: {
573
+ value: {},
574
+ options: {
575
+ duration: 0
576
+ }
577
+ },
578
+ exit: {
579
+ value: {},
580
+ options: {
581
+ duration: 0
582
+ }
583
+ },
584
+ exitBack: {
585
+ value: {},
586
+ options: {
587
+ duration: 0
588
+ }
589
+ }
590
+ }), pt = /* @__PURE__ */ new Map([
591
+ ["none", V],
592
+ ["cupertino", B],
593
+ ["material", F],
594
+ ["layout", X]
595
+ ]), yt = D((n) => ({
596
+ defaultTransitionName: "cupertino",
597
+ setDefaultTransitionName: (t) => n({ defaultTransitionName: t })
598
+ }));
599
+ function j({
600
+ name: n,
601
+ initial: t,
602
+ enter: e,
603
+ exit: s,
604
+ options: a
605
+ }) {
606
+ return {
607
+ name: n,
608
+ initial: t,
609
+ variants: {
610
+ "IDLE-true": e,
611
+ "IDLE-false": e,
612
+ "PUSHING-false": s,
613
+ "PUSHING-true": e,
614
+ "REPLACING-false": s,
615
+ "REPLACING-true": e,
616
+ "POPPING-false": e,
617
+ "POPPING-true": e,
618
+ "COMPLETED-false": s,
619
+ "COMPLETED-true": e
620
+ },
621
+ ...a
622
+ };
623
+ }
624
+ function Pt({
625
+ name: n,
626
+ initial: t,
627
+ idle: e,
628
+ pushOnEnter: s,
629
+ pushOnExit: a,
630
+ replaceOnEnter: r,
631
+ replaceOnExit: i,
632
+ popOnEnter: c,
633
+ popOnExit: l,
634
+ completedOnEnter: u,
635
+ completedOnExit: d,
636
+ options: h
637
+ }) {
638
+ return {
639
+ name: n,
640
+ initial: t,
641
+ variants: {
642
+ "IDLE-true": e,
643
+ "IDLE-false": e,
644
+ "PUSHING-false": a,
645
+ "PUSHING-true": s,
646
+ "REPLACING-false": i,
647
+ "REPLACING-true": r,
648
+ "POPPING-false": l,
649
+ "POPPING-true": c,
650
+ "COMPLETED-false": d,
651
+ "COMPLETED-true": u
652
+ },
653
+ ...h
654
+ };
655
+ }
656
+ const z = j({
657
+ name: "overlay",
658
+ initial: {
659
+ opacity: 0,
660
+ backgroundColor: "rgba(0, 0, 0, 0)"
661
+ },
662
+ enter: {
663
+ value: {
664
+ opacity: 0,
665
+ backgroundColor: "rgba(0, 0, 0, 0.3)"
666
+ },
667
+ options: {
668
+ duration: 0.3
669
+ }
670
+ },
671
+ exit: {
672
+ value: {
673
+ opacity: 1,
674
+ backgroundColor: "rgba(0, 0, 0, 0.3)"
675
+ },
676
+ options: {
677
+ duration: 0.3
678
+ }
679
+ },
680
+ options: {
681
+ onSwipeStart: (n, { animate: t, prevDecorator: e }) => t(
682
+ e,
683
+ {
684
+ opacity: n ? 1 : 0
685
+ },
686
+ {
687
+ duration: 0.3
688
+ }
689
+ ),
690
+ onSwipe: (n, t, { animate: e, prevDecorator: s }) => e(
691
+ s,
692
+ {
693
+ opacity: Math.max(0, 1 - t / 100)
694
+ },
695
+ {
696
+ duration: 0
697
+ }
698
+ ),
699
+ onSwipeEnd: (n, { animate: t, prevDecorator: e }) => t(
700
+ e,
701
+ {
702
+ opacity: n ? 0 : 1
703
+ },
704
+ {
705
+ duration: 0.3
706
+ }
707
+ )
708
+ }
709
+ }), gt = /* @__PURE__ */ new Map([["overlay", z]]), I = {
710
+ "IDLE-true": "self",
711
+ "IDLE-false": "self",
712
+ "PUSHING-true": "initial",
713
+ "PUSHING-false": "IDLE-true",
714
+ "REPLACING-true": "initial",
715
+ "REPLACING-false": "IDLE-true",
716
+ "POPPING-true": "IDLE-true",
717
+ "POPPING-false": "PUSHING-false",
718
+ "COMPLETED-true": "self",
719
+ "COMPLETED-false": "self"
720
+ }, G = Object.keys(I), Z = G, K = (n) => n.replace(/[^a-zA-Z0-9_-]/g, "_"), C = (n) => typeof n == "object" && n !== null && !Array.isArray(n), q = (n, t) => t === "opacity" || t === "scale" || t === "scaleX" || t === "scaleY" ? `${n}` : t === "rotate" || t === "rotateX" || t === "rotateY" || t === "rotateZ" ? `${n}deg` : `${n}px`, O = (n, t) => typeof t == "number" ? q(t, n) : typeof t == "string" ? t : "", b = (n) => n.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`), $ = /* @__PURE__ */ new Set([
721
+ "x",
722
+ "y",
723
+ "z",
724
+ "scale",
725
+ "scaleX",
726
+ "scaleY",
727
+ "rotate",
728
+ "rotateX",
729
+ "rotateY",
730
+ "rotateZ"
731
+ ]), W = /^-?0(\.0+)?(px|%|em|rem|vh|vw|vmin|vmax)?$/, J = /^-?0(\.0+)?(deg|rad|grad|turn)?$/, tt = /^1(\.0+)?$/, et = (n, t) => n === "scale" || n === "scaleX" || n === "scaleY" ? t === 1 ? !0 : typeof t == "string" ? tt.test(t.trim()) : !1 : n === "rotate" || n === "rotateX" || n === "rotateY" || n === "rotateZ" ? t === 0 ? !0 : typeof t == "string" ? J.test(t.trim()) : !1 : t === 0 ? !0 : typeof t == "string" ? W.test(t.trim()) : !1, nt = (n, t) => {
732
+ switch (n) {
733
+ case "x":
734
+ return `translateX(${t})`;
735
+ case "y":
736
+ return `translateY(${t})`;
737
+ case "z":
738
+ return `translateZ(${t})`;
739
+ case "scale":
740
+ return `scale(${t})`;
741
+ case "scaleX":
742
+ return `scaleX(${t})`;
743
+ case "scaleY":
744
+ return `scaleY(${t})`;
745
+ case "rotate":
746
+ case "rotateZ":
747
+ return `rotate(${t})`;
748
+ case "rotateX":
749
+ return `rotateX(${t})`;
750
+ case "rotateY":
751
+ return `rotateY(${t})`;
752
+ default:
753
+ return "";
754
+ }
755
+ }, Et = (n) => {
756
+ const t = /* @__PURE__ */ new Set();
757
+ let e = !1;
758
+ const s = (a) => {
759
+ if (C(a))
760
+ for (const r of Object.keys(a)) {
761
+ const i = a[r];
762
+ O(r, i) !== "" && ($.has(r) ? e = !0 : t.add(b(r)));
763
+ }
764
+ };
765
+ s(n.initial);
766
+ for (const a of Object.values(n.variants))
767
+ s(a.value);
768
+ return e && t.add("transform"), Array.from(t);
769
+ }, g = (n) => {
770
+ if (!C(n)) return [];
771
+ const t = [];
772
+ let e = !0;
773
+ const s = [];
774
+ for (const a of Object.keys(n)) {
775
+ const r = n[a], i = O(a, r);
776
+ i !== "" && ($.has(a) ? (t.push(nt(a, i)), et(a, r) || (e = !1)) : s.push({ property: b(a), value: i }));
777
+ }
778
+ return t.length > 0 && s.push({
779
+ property: "transform",
780
+ value: e ? "none" : t.join(" ")
781
+ }), s;
782
+ }, E = (n) => n.map((t) => ` ${t.property}: ${t.value};`).join(`
783
+ `), st = (n) => Array.isArray(n) ? n.length === 4 && n.every((t) => typeof t == "number") ? `cubic-bezier(${n.join(", ")})` : "linear" : typeof n == "string" ? {
784
+ linear: "linear",
785
+ easeIn: "ease-in",
786
+ easeOut: "ease-out",
787
+ easeInOut: "ease-in-out",
788
+ circIn: "cubic-bezier(0, 0.55, 0.45, 1)",
789
+ circOut: "cubic-bezier(0.55, 0, 1, 0.45)",
790
+ backIn: "cubic-bezier(0.31, 0.01, 0.66, -0.59)",
791
+ backOut: "cubic-bezier(0.33, 1.53, 0.69, 0.99)",
792
+ anticipate: "cubic-bezier(0.36, 0, 0.66, -0.56)"
793
+ }[n] ?? "ease" : "ease", R = (n) => {
794
+ if (!n) return 0;
795
+ const t = n.duration;
796
+ return typeof t == "number" && t >= 0 ? t : 0;
797
+ }, _ = (n) => n && typeof n.delay == "number" && n.delay > 0 ? n.delay : 0, v = (n, t) => {
798
+ const [e, s] = t.split("-");
799
+ return `[data-flemo-screen][data-flemo-transition="${n}"][data-flemo-status="${e}"][data-flemo-active="${s}"]`;
800
+ }, A = (n, t) => {
801
+ const [e, s] = t.split("-");
802
+ return `[data-flemo-decorator][data-flemo-decorator-name="${n}"][data-flemo-status="${e}"][data-flemo-active="${s}"]`;
803
+ }, at = (n, t, e) => `flemo-${n}-${K(t)}-${e}`, M = (n, t, e, s, a, r) => {
804
+ const i = g(s), c = g(a.value), l = R(a.options), u = _(a.options), d = st(a.options?.ease), h = r(t, e);
805
+ if (c.length === 0 && i.length === 0)
806
+ return "";
807
+ if (l <= 0 && u <= 0)
808
+ return c.length === 0 ? "" : `${h} {
809
+ ${E(c)}
810
+ animation: none;
811
+ }`;
812
+ const o = at(n, t, e), p = [
813
+ `@keyframes ${o} {`,
814
+ " from {",
815
+ E(i).replace(/^/gm, " "),
816
+ " }",
817
+ " to {",
818
+ E(c).replace(/^/gm, " "),
819
+ " }",
820
+ "}"
821
+ ].join(`
822
+ `), P = [
823
+ `${o}`,
824
+ `${l}s`,
825
+ d,
826
+ u > 0 ? `${u}s` : null,
827
+ "both"
828
+ ].filter(Boolean).join(" "), m = Array.from(
829
+ /* @__PURE__ */ new Set([...i.map((T) => T.property), ...c.map((T) => T.property)])
830
+ ), f = m.length > 0 ? ` will-change: ${m.join(", ")};
831
+ ` : "", y = `${h} {
832
+ animation: ${P};
833
+ ${f}}`;
834
+ return `${p}
835
+ ${y}`;
836
+ }, S = (n, t, e, s) => {
837
+ const a = g(s.value);
838
+ return a.length === 0 ? "" : `${n(t, e)} {
839
+ ${E(a)}
840
+ }`;
841
+ }, It = (n, t) => {
842
+ const e = [];
843
+ for (const s of n) {
844
+ const a = s.name;
845
+ for (const r of G) {
846
+ const i = s.variants[r], c = I[r];
847
+ if (c === "self") {
848
+ e.push(S(v, a, r, i));
849
+ continue;
850
+ }
851
+ const l = c === "initial" ? s.initial : s.variants[c].value;
852
+ e.push(
853
+ M("screen", a, r, l, i, v)
854
+ );
855
+ }
856
+ }
857
+ for (const s of t) {
858
+ const a = s.name;
859
+ for (const r of Z) {
860
+ const i = s.variants[r], c = I[r];
861
+ if (c === "self") {
862
+ e.push(S(A, a, r, i));
863
+ continue;
864
+ }
865
+ const l = c === "initial" ? s.initial : s.variants[c].value;
866
+ e.push(
867
+ M(
868
+ "decorator",
869
+ a,
870
+ r,
871
+ l,
872
+ i,
873
+ A
874
+ )
875
+ );
876
+ }
877
+ }
878
+ return e.filter((s) => s.length > 0).join(`
879
+
880
+ `);
881
+ }, kt = (n, t) => {
882
+ const e = I[t];
883
+ if (e === "self") return !1;
884
+ const s = n.variants[t], a = R(s.options), r = _(s.options);
885
+ if (a <= 0 && r <= 0) return !1;
886
+ const i = e === "initial" ? n.initial : n.variants[e].value, c = g(i), l = g(s.value);
887
+ return c.length > 0 || l.length > 0;
888
+ };
889
+ function Tt() {
890
+ return typeof document > "u";
891
+ }
892
+ function rt(n, t) {
893
+ return Array.isArray(n) ? n.find((e) => w(e).regexp.test(t)) ?? "" : w(n).regexp.test(t) ? n : "";
894
+ }
895
+ function Nt(n, t, e) {
896
+ const s = rt(n, t), a = H(s)(t), r = new URLSearchParams(e), i = Object.fromEntries(r.entries());
897
+ return a ? { ...a.params, ...i } : {};
898
+ }
899
+ function Lt(n, t) {
900
+ const {
901
+ direction: e = "x",
902
+ markerSelector: s = "[data-swipe-at-edge]",
903
+ depthLimit: a = 24,
904
+ verifyByScroll: r = !1
905
+ } = t ?? {}, i = it(n);
906
+ if (!i) return { element: null, hasMarker: !1 };
907
+ const c = i.closest?.(s);
908
+ if (c instanceof HTMLElement && L(c, e) && (!r || x(c, e)))
909
+ return { element: c, hasMarker: !0 };
910
+ let l = i, u = 0;
911
+ for (; l && u < a; ) {
912
+ if (L(l, e) && (!r || x(l, e)))
913
+ return { element: l, hasMarker: !1 };
914
+ l = l.parentElement, u++;
915
+ }
916
+ return { element: null, hasMarker: !1 };
917
+ }
918
+ function it(n) {
919
+ if (!n) return null;
920
+ const t = n, e = typeof t.composedPath == "function" ? t.composedPath() : void 0;
921
+ if (e && e.length) {
922
+ for (const s of e)
923
+ if (s instanceof HTMLElement) return s;
924
+ }
925
+ return n instanceof HTMLElement ? n : null;
926
+ }
927
+ function L(n, t) {
928
+ return t === "y" ? n.scrollHeight - n.clientHeight > 1 : n.scrollWidth - n.clientWidth > 1;
929
+ }
930
+ function x(n, t) {
931
+ if (!L(n, t) || typeof window > "u") return !1;
932
+ const e = window.getComputedStyle(n), s = t === "y" ? e.overflowY : e.overflowX;
933
+ return s === "auto" || s === "scroll" || s === "overlay";
934
+ }
935
+ export {
936
+ ut as TaskManger,
937
+ at as animationName,
938
+ x as canProgrammaticallyScroll,
939
+ Et as collectAnimatedProperties,
940
+ It as compileTransitionStyles,
941
+ ht as consumeSelfInducedPop,
942
+ j as createDecorator,
943
+ Pt as createRawDecorator,
944
+ mt as createRawTransition,
945
+ k as createTransition,
946
+ B as cupertino,
947
+ gt as decoratorMap,
948
+ st as easingToCss,
949
+ Lt as findScrollable,
950
+ rt as getMatchedPathPattern,
951
+ Nt as getParams,
952
+ Tt as isServer,
953
+ X as layout,
954
+ dt as markSelfInducedPop,
955
+ F as material,
956
+ V as none,
957
+ L as overflowsAxis,
958
+ z as overlay,
959
+ g as targetToDecls,
960
+ pt as transitionMap,
961
+ lt as useHistoryStore,
962
+ ft as useNavigateStore,
963
+ yt as useTransitionStore,
964
+ kt as variantHasAnimation
965
+ };