@flemo/core 1.3.0 → 1.5.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 (39) hide show
  1. package/dist/core/engine/__tests__/barRiding.test.d.ts +1 -0
  2. package/dist/core/engine/__tests__/createSwipeController.test.d.ts +1 -0
  3. package/dist/core/engine/__tests__/createTransitionEngine.test.d.ts +1 -0
  4. package/dist/core/engine/barRiding.d.ts +18 -0
  5. package/dist/core/engine/createSwipeController.d.ts +32 -0
  6. package/dist/core/engine/createTransitionEngine.d.ts +2 -0
  7. package/dist/core/engine/types.d.ts +22 -0
  8. package/dist/history/__tests__/createHistorySync.test.d.ts +1 -0
  9. package/dist/history/__tests__/seedInitialHistory.test.d.ts +1 -0
  10. package/dist/history/createHistorySync.d.ts +9 -0
  11. package/dist/history/ensureWindowHistoryState.d.ts +2 -0
  12. package/dist/history/seedInitialHistory.d.ts +4 -0
  13. package/dist/history/store.d.ts +4 -3
  14. package/dist/index.d.ts +21 -3
  15. package/dist/index.mjs +1442 -1046
  16. package/dist/navigate/__tests__/createNavigationController.test.d.ts +1 -0
  17. package/dist/navigate/createNavigationController.d.ts +31 -0
  18. package/dist/navigate/store.d.ts +4 -3
  19. package/dist/screen/__tests__/computeScreenFreeze.test.d.ts +1 -0
  20. package/dist/screen/__tests__/createScreenSelector.test.d.ts +1 -0
  21. package/dist/screen/__tests__/store.test.d.ts +1 -0
  22. package/dist/screen/computeScreenFreeze.d.ts +11 -0
  23. package/dist/screen/createScreenSelector.d.ts +10 -0
  24. package/dist/screen/store.d.ts +16 -0
  25. package/dist/transition/__tests__/animateInline.test.d.ts +1 -0
  26. package/dist/transition/__tests__/applyTransitionStyles.test.d.ts +1 -0
  27. package/dist/transition/__tests__/compileTransitionStyles.test.d.ts +5 -0
  28. package/dist/transition/animateInline.d.ts +4 -0
  29. package/dist/transition/applyTransitionStyles.d.ts +1 -0
  30. package/dist/transition/compileTransitionStyles.d.ts +3 -2
  31. package/dist/transition/partTransition/__tests__/createPartTransition.test.d.ts +1 -0
  32. package/dist/transition/partTransition/__tests__/createRawPartTransition.test.d.ts +1 -0
  33. package/dist/transition/partTransition/createPartTransition.d.ts +13 -0
  34. package/dist/transition/partTransition/createRawPartTransition.d.ts +19 -0
  35. package/dist/transition/partTransition/partTransition.d.ts +2 -0
  36. package/dist/transition/partTransition/typing.d.ts +24 -0
  37. package/dist/transition/store.d.ts +4 -3
  38. package/dist/utils/findScrollable.d.ts +1 -1
  39. package/package.json +11 -11
package/dist/index.mjs CHANGED
@@ -1,1061 +1,1457 @@
1
- import { create as w } from "zustand";
2
- import { pathToRegexp as v, match as B } from "path-to-regexp";
3
- class Q {
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: o, validate: c, rollback: l, dependencies: u = [], delay: d } = e, m = new AbortController(), i = {
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: o,
82
- abortController: m
83
- };
84
- this.tasks.set(i.id, i), this.pendingTaskQueue.length > 0 && (this.pendingTaskQueue.push(i), await this.waitForPendingTasks(), this.pendingTaskQueue = this.pendingTaskQueue.filter((P) => P.id !== i.id));
85
- try {
86
- if (!await this.acquireLock(i.id))
87
- throw i.status = "FAILED", new Error("FAILED");
88
- try {
89
- i.status = "PROCESSING";
90
- for (const f of i.dependencies) {
91
- const y = this.tasks.get(f);
92
- if (!y || y.status !== "COMPLETED")
93
- throw i.status = "FAILED", new Error("FAILED");
94
- }
95
- if (i.validate && !await i.validate())
96
- throw i.status = "FAILED", new Error("FAILED");
97
- d && d > 0 && await new Promise((f) => setTimeout(f, d));
98
- const h = await i.execute(i.abortController);
99
- if (i.abortController.signal.aborted) {
100
- i.status = "COMPLETED", await this.onTaskStatusChange(i.id, "COMPLETED"), a({
101
- success: !0,
102
- result: void 0,
103
- taskId: i.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
- i.status = "MANUAL_PENDING", i.manualResolver = { resolve: a, reject: r, result: h }, this.pendingTaskQueue.push(i), await this.onTaskStatusChange(i.id, "MANUAL_PENDING");
113
- return;
114
- }
115
- if (f.signal) {
116
- i.status = "SIGNAL_PENDING", i.manualResolver = { resolve: a, reject: r, result: h }, this.signalListeners.has(f.signal) || this.signalListeners.set(f.signal, /* @__PURE__ */ new Set()), this.signalListeners.get(f.signal).add(i.id), this.pendingTaskQueue.push(i), await this.onTaskStatusChange(i.id, "SIGNAL_PENDING");
117
- return;
118
- }
119
- if (f.condition && !await f.condition()) {
120
- i.status = "MANUAL_PENDING", i.manualResolver = { resolve: a, reject: r, result: h }, this.pendingTaskQueue.push(i), await this.onTaskStatusChange(i.id, "MANUAL_PENDING");
121
- return;
122
- }
123
- }
124
- i.status = "COMPLETED", await this.onTaskStatusChange(i.id, "COMPLETED"), a({
125
- success: !0,
126
- result: h,
127
- taskId: i.id,
128
- timestamp: Date.now(),
129
- instanceId: this.instanceId
130
- });
131
- } catch (h) {
132
- if (i.status = "FAILED", i.rollback)
133
- try {
134
- await i.rollback(), i.status = "ROLLEDBACK";
135
- } catch {
136
- }
137
- throw await this.onTaskStatusChange(i.id, i.status), h;
138
- } finally {
139
- this.releaseLock(i.id);
140
- }
141
- } catch (P) {
142
- r(P);
143
- }
144
- } catch (o) {
145
- r(o);
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
- }
1
+ import { createStore as e } from "zustand/vanilla";
2
+ import { match as t, pathToRegexp as n } from "path-to-regexp";
3
+ var r = new class {
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(e) {
13
+ for (let t = 0; t < 10; t++) {
14
+ if (!this.isLocked) return this.isLocked = !0, this.currentTaskId = e, !0;
15
+ await new Promise((e) => setTimeout(e, 100));
16
+ }
17
+ return !1;
18
+ }
19
+ releaseLock(e) {
20
+ this.currentTaskId === e && (this.isLocked = !1, this.currentTaskId = null);
21
+ }
22
+ generateTaskId() {
23
+ return `${this.instanceId}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
24
+ }
25
+ emitSignal(e) {
26
+ let t = this.signalListeners.get(e);
27
+ t && (t.forEach((e) => {
28
+ this.resolveTask(e);
29
+ }), this.signalListeners.delete(e));
30
+ }
31
+ async processPendingTasks() {
32
+ if (!(this.isProcessingPending || this.pendingTaskQueue.length === 0)) {
33
+ this.isProcessingPending = !0;
34
+ try {
35
+ for (; this.pendingTaskQueue.length > 0;) {
36
+ let e = this.pendingTaskQueue[0];
37
+ if (e.status === "COMPLETED" || e.status === "FAILED" || e.status === "ROLLEDBACK") {
38
+ this.pendingTaskQueue.shift();
39
+ continue;
40
+ }
41
+ if (e.status === "MANUAL_PENDING" || e.status === "SIGNAL_PENDING" || e.status === "PROCESSING" || e.status === "PENDING") break;
42
+ }
43
+ } finally {
44
+ this.isProcessingPending = !1;
45
+ }
46
+ }
47
+ }
48
+ async waitForPendingTasks() {
49
+ return new Promise((e) => {
50
+ let t = () => {
51
+ this.pendingTaskQueue.filter((e) => e.status === "MANUAL_PENDING" || e.status === "SIGNAL_PENDING").length === 0 ? e() : setTimeout(t, 100);
52
+ };
53
+ t();
54
+ });
55
+ }
56
+ async onTaskStatusChange(e, t) {
57
+ (t === "COMPLETED" || t === "FAILED" || t === "ROLLEDBACK") && (this.pendingTaskQueue = this.pendingTaskQueue.filter((t) => t.id !== e), await this.processPendingTasks());
58
+ }
59
+ async addTask(e, t = {}) {
60
+ let n = t.id || this.generateTaskId();
61
+ return new Promise((r, i) => {
62
+ this.taskQueue = this.taskQueue.then(async () => {
63
+ try {
64
+ let { control: a, validate: o, rollback: s, dependencies: c = [], delay: l } = t, u = new AbortController(), d = {
65
+ id: n,
66
+ execute: e,
67
+ timestamp: Date.now(),
68
+ retryCount: 0,
69
+ status: "PENDING",
70
+ dependencies: c,
71
+ instanceId: this.instanceId,
72
+ validate: o,
73
+ rollback: s,
74
+ control: a,
75
+ abortController: u
76
+ };
77
+ this.tasks.set(d.id, d), this.pendingTaskQueue.length > 0 && (this.pendingTaskQueue.push(d), await this.waitForPendingTasks(), this.pendingTaskQueue = this.pendingTaskQueue.filter((e) => e.id !== d.id));
78
+ try {
79
+ if (!await this.acquireLock(d.id)) throw d.status = "FAILED", Error("FAILED");
80
+ try {
81
+ d.status = "PROCESSING";
82
+ for (let e of d.dependencies) {
83
+ let t = this.tasks.get(e);
84
+ if (!t || t.status !== "COMPLETED") throw d.status = "FAILED", Error("FAILED");
85
+ }
86
+ if (d.validate && !await d.validate()) throw d.status = "FAILED", Error("FAILED");
87
+ l && l > 0 && await new Promise((e) => setTimeout(e, l));
88
+ let e = await d.execute(d.abortController);
89
+ if (d.abortController.signal.aborted) {
90
+ d.status = "COMPLETED", await this.onTaskStatusChange(d.id, "COMPLETED"), r({
91
+ success: !0,
92
+ result: void 0,
93
+ taskId: d.id,
94
+ timestamp: Date.now(),
95
+ instanceId: this.instanceId
96
+ });
97
+ return;
98
+ }
99
+ if (t.control) {
100
+ let n = t.control;
101
+ if (n.delay && n.delay > 0 && await new Promise((e) => setTimeout(e, n.delay)), n.manual) {
102
+ d.status = "MANUAL_PENDING", d.manualResolver = {
103
+ resolve: r,
104
+ reject: i,
105
+ result: e
106
+ }, this.pendingTaskQueue.push(d), await this.onTaskStatusChange(d.id, "MANUAL_PENDING");
107
+ return;
108
+ }
109
+ if (n.signal) {
110
+ d.status = "SIGNAL_PENDING", d.manualResolver = {
111
+ resolve: r,
112
+ reject: i,
113
+ result: e
114
+ }, this.signalListeners.has(n.signal) || this.signalListeners.set(n.signal, /* @__PURE__ */ new Set()), this.signalListeners.get(n.signal).add(d.id), this.pendingTaskQueue.push(d), await this.onTaskStatusChange(d.id, "SIGNAL_PENDING");
115
+ return;
116
+ }
117
+ if (n.condition && !await n.condition()) {
118
+ d.status = "MANUAL_PENDING", d.manualResolver = {
119
+ resolve: r,
120
+ reject: i,
121
+ result: e
122
+ }, this.pendingTaskQueue.push(d), await this.onTaskStatusChange(d.id, "MANUAL_PENDING");
123
+ return;
124
+ }
125
+ }
126
+ d.status = "COMPLETED", await this.onTaskStatusChange(d.id, "COMPLETED"), r({
127
+ success: !0,
128
+ result: e,
129
+ taskId: d.id,
130
+ timestamp: Date.now(),
131
+ instanceId: this.instanceId
132
+ });
133
+ } catch (e) {
134
+ if (d.status = "FAILED", d.rollback) try {
135
+ await d.rollback(), d.status = "ROLLEDBACK";
136
+ } catch {}
137
+ throw await this.onTaskStatusChange(d.id, d.status), e;
138
+ } finally {
139
+ this.releaseLock(d.id);
140
+ }
141
+ } catch (e) {
142
+ i(e);
143
+ }
144
+ } catch (e) {
145
+ i(e);
146
+ }
147
+ }).catch(i);
148
+ });
149
+ }
150
+ async resolveTask(e) {
151
+ let t = this.tasks.get(e);
152
+ if (!t || t.status !== "MANUAL_PENDING" && t.status !== "SIGNAL_PENDING") return !1;
153
+ if (t.manualResolver) {
154
+ if (t.control?.condition && !await t.control.condition()) return !1;
155
+ t.status = "COMPLETED";
156
+ let n = t.manualResolver;
157
+ return n.resolve({
158
+ success: !0,
159
+ result: n.result,
160
+ taskId: t.id,
161
+ timestamp: Date.now(),
162
+ instanceId: this.instanceId
163
+ }), delete t.manualResolver, await this.onTaskStatusChange(e, "COMPLETED"), !0;
164
+ }
165
+ return !1;
166
+ }
167
+ async resolveAllPending() {
168
+ let e = Array.from(this.tasks.values()).filter((e) => [
169
+ "PENDING",
170
+ "MANUAL_PENDING",
171
+ "SIGNAL_PENDING"
172
+ ].includes(e.status));
173
+ await Promise.all(e.map((e) => this.resolveTask(e.id)));
174
+ }
175
+ }();
176
+ //#endregion
177
+ //#region src/history/store.ts
178
+ function i(t = [], n = -1) {
179
+ return e((e) => ({
180
+ index: n,
181
+ histories: t,
182
+ addHistory: (t) => e((e) => ({
183
+ index: e.index + 1,
184
+ histories: e.histories.concat(t)
185
+ })),
186
+ replaceHistory: (t) => e((e) => (e.histories.splice(t, 1), {
187
+ index: e.index - 1,
188
+ histories: e.histories
189
+ })),
190
+ popHistory: (t) => e((e) => ({
191
+ index: e.index - 1,
192
+ histories: e.histories.filter((e, n) => n !== t)
193
+ })),
194
+ popHistories: (t) => {
195
+ t <= 0 || e((e) => {
196
+ let n = e.index;
197
+ return {
198
+ index: e.index - t,
199
+ histories: e.histories.filter((e, r) => r < n - t || r >= n)
200
+ };
201
+ });
202
+ },
203
+ setTransitionName: (t, n) => e((e) => {
204
+ let r = e.histories[t];
205
+ if (!r || r.transitionName === n) return {};
206
+ let i = e.histories.slice();
207
+ return i[t] = {
208
+ ...r,
209
+ transitionName: n
210
+ }, { histories: i };
211
+ })
212
+ }));
175
213
  }
176
- const yt = new Q(), Pt = w((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
- // Drop `count` entries sitting directly below the current top, keeping the
192
- // top itself. Used by pop(n) to remove the screens it skips over in the same
193
- // synchronous block that starts the transition — so they never paint — while
194
- // the leaving top stays mounted to drive and resolve the animation.
195
- popHistories: (t) => {
196
- t <= 0 || n((e) => {
197
- const s = e.index;
198
- return {
199
- index: e.index - t,
200
- histories: e.histories.filter((a, r) => r < s - t || r >= s)
201
- };
202
- });
203
- },
204
- // Override one entry's transition. Used by pop() to relabel the leaving top
205
- // before the POPPING flip so the back animation uses the caller's
206
- // `transitionName` from the first frame — its original transition never
207
- // paints. Returns a fresh array so the renderer re-reads it.
208
- setTransitionName: (t, e) => n((s) => {
209
- const a = s.histories[t];
210
- if (!a || a.transitionName === e) return {};
211
- const r = s.histories.slice();
212
- return r[t] = { ...a, transitionName: e }, { histories: r };
213
- })
214
- })), gt = w((n) => ({
215
- status: "IDLE",
216
- transitionTaskId: null,
217
- setStatus: (t) => n({ status: t }),
218
- setTransitionTaskId: (t) => n({ transitionTaskId: t })
219
- }));
220
- let L = 0;
221
- function It() {
222
- L += 1;
214
+ //#endregion
215
+ //#region src/utils/getMatchedPathPattern.ts
216
+ function a(e, t) {
217
+ return Array.isArray(e) ? e.find((e) => n(e).regexp.test(t)) ?? "" : n(e).regexp.test(t) ? e : "";
223
218
  }
224
- function Et() {
225
- return L > 0 ? (L -= 1, !0) : !1;
219
+ //#endregion
220
+ //#region src/utils/getParams.ts
221
+ function o(e, n, r) {
222
+ let i = t(a(e, n))(n), o = new URLSearchParams(r), s = Object.fromEntries(o.entries());
223
+ return i ? {
224
+ ...i.params,
225
+ ...s
226
+ } : {};
226
227
  }
227
- function T({
228
- name: n,
229
- initial: t,
230
- idle: e,
231
- enter: s,
232
- enterBack: a,
233
- exit: r,
234
- exitBack: o,
235
- options: c
236
- }) {
237
- return {
238
- name: n,
239
- initial: t,
240
- variants: {
241
- "IDLE-true": e,
242
- "IDLE-false": e,
243
- "PUSHING-false": r,
244
- "PUSHING-true": s,
245
- "REPLACING-false": r,
246
- "REPLACING-true": s,
247
- "POPPING-false": o,
248
- "POPPING-true": a,
249
- "COMPLETED-false": r,
250
- "COMPLETED-true": s
251
- },
252
- ...c
253
- };
228
+ //#endregion
229
+ //#region src/history/seedInitialHistory.ts
230
+ function s(e, t, n, r) {
231
+ return {
232
+ id: "root",
233
+ pathname: t,
234
+ params: o(e, t, n),
235
+ transitionName: r,
236
+ layoutId: null
237
+ };
254
238
  }
255
- function kt({
256
- name: n,
257
- initial: t,
258
- idle: e,
259
- pushOnEnter: s,
260
- pushOnExit: a,
261
- replaceOnEnter: r,
262
- replaceOnExit: o,
263
- popOnEnter: c,
264
- popOnExit: l,
265
- completedOnExit: u,
266
- completedOnEnter: d,
267
- options: m
268
- }) {
269
- return {
270
- name: n,
271
- initial: t,
272
- variants: {
273
- "IDLE-true": e,
274
- "IDLE-false": e,
275
- "PUSHING-false": a,
276
- "PUSHING-true": s,
277
- "REPLACING-false": o,
278
- "REPLACING-true": r,
279
- "POPPING-false": l,
280
- "POPPING-true": c,
281
- "COMPLETED-false": u,
282
- "COMPLETED-true": d
283
- },
284
- ...m
285
- };
239
+ //#endregion
240
+ //#region src/utils/isServer.ts
241
+ function c() {
242
+ return typeof document > "u";
286
243
  }
287
- const X = (n, t, e) => {
288
- const [s, a] = t, [r, o] = e;
289
- if (a === s) return r;
290
- const c = (n - s) / (a - s);
291
- return r + c * (o - r);
292
- }, F = T({
293
- name: "cupertino",
294
- initial: {
295
- x: "100%"
296
- },
297
- idle: {
298
- value: {
299
- x: 0
300
- },
301
- options: {
302
- duration: 0
303
- }
304
- },
305
- enter: {
306
- value: {
307
- x: 0
308
- },
309
- options: {
310
- duration: 0.7,
311
- ease: [0.32, 0.72, 0, 1]
312
- }
313
- },
314
- enterBack: {
315
- value: {
316
- x: "100%"
317
- },
318
- options: {
319
- duration: 0.6,
320
- ease: [0.32, 0.72, 0, 1]
321
- }
322
- },
323
- exit: {
324
- value: {
325
- x: "-30%"
326
- },
327
- options: {
328
- duration: 0.7,
329
- ease: [0.32, 0.72, 0, 1]
330
- }
331
- },
332
- exitBack: {
333
- value: {
334
- x: 0
335
- },
336
- options: {
337
- duration: 0.6,
338
- ease: [0.32, 0.72, 0, 1]
339
- }
340
- },
341
- options: {
342
- decoratorName: "overlay",
343
- swipeDirection: "x",
344
- onSwipeStart: async () => !0,
345
- onSwipe: (n, t, { animate: e, currentScreen: s, prevScreen: a, onProgress: r }) => {
346
- const { offset: o } = t, c = o.x, l = X(c, [0, window.innerWidth], [0, 100]);
347
- return r?.(!0, l), e(
348
- s,
349
- {
350
- x: Math.max(0, c)
351
- },
352
- {
353
- duration: 0
354
- }
355
- ), e(
356
- a,
357
- {
358
- x: `${-30 + l * 0.3}%`
359
- },
360
- {
361
- duration: 0
362
- }
363
- ), l;
364
- },
365
- onSwipeEnd: async (n, t, { animate: e, currentScreen: s, prevScreen: a, onStart: r }) => {
366
- const { offset: o, velocity: c } = t, u = o.x > 50 || c.x > 20;
367
- return r?.(u), await Promise.all([
368
- e(
369
- s,
370
- {
371
- x: u ? "100%" : 0
372
- },
373
- {
374
- duration: 0.3,
375
- ease: [0.32, 0.72, 0, 1]
376
- }
377
- ),
378
- e(
379
- a,
380
- {
381
- x: u ? 0 : "-30%"
382
- },
383
- {
384
- duration: 0.3,
385
- ease: [0.32, 0.72, 0, 1]
386
- }
387
- )
388
- ]), u;
389
- }
390
- }
391
- }), z = (n, t, e) => {
392
- const [s, a] = t, [r, o] = e;
393
- if (a === s) return r;
394
- const c = (n - s) / (a - s);
395
- return r + c * (o - r);
396
- }, V = T({
397
- name: "layout",
398
- initial: {
399
- opacity: 0.97
400
- },
401
- idle: {
402
- value: {
403
- opacity: 1
404
- },
405
- options: {
406
- duration: 0.3
407
- }
408
- },
409
- enter: {
410
- value: {
411
- opacity: 1
412
- },
413
- options: {
414
- duration: 0.3
415
- }
416
- },
417
- enterBack: {
418
- value: {
419
- opacity: 0.97
420
- },
421
- options: {
422
- duration: 0.3
423
- }
424
- },
425
- exit: {
426
- value: {
427
- opacity: 0.97
428
- },
429
- options: {
430
- duration: 0.3
431
- }
432
- },
433
- exitBack: {
434
- value: {
435
- opacity: 1
436
- },
437
- options: {
438
- duration: 0.3
439
- }
440
- },
441
- options: {
442
- decoratorName: "overlay",
443
- swipeDirection: "y",
444
- onSwipeStart: async () => !0,
445
- onSwipe: (n, t, { animate: e, currentScreen: s, onProgress: a }) => {
446
- const { offset: r } = t, o = r.y, c = Math.max(0, Math.min(56, o)), l = z(c, [0, 56], [1, 0.96]), u = Math.max(0, o - 56), d = Math.min(1, u / 160), m = Math.sqrt(d) * 12, i = Math.max(0, c + m), p = Math.min(56, i);
447
- return a?.(!0, 100), e(
448
- s,
449
- {
450
- y: i,
451
- opacity: l
452
- },
453
- {
454
- duration: 0
455
- }
456
- ), p;
457
- },
458
- onSwipeEnd: async (n, t, { animate: e, currentScreen: s, prevScreen: a, onStart: r }) => {
459
- const { offset: o, velocity: c } = t, u = o.y > 56 || c.y > 20;
460
- return r?.(u), await Promise.all([
461
- e(
462
- s,
463
- {
464
- y: u ? "100%" : 0,
465
- opacity: u ? 0.96 : 1
466
- },
467
- {
468
- duration: 0.3
469
- }
470
- ),
471
- e(
472
- a,
473
- {
474
- y: 0,
475
- opacity: u ? 1 : 0.97
476
- },
477
- {
478
- duration: 0.3
479
- }
480
- )
481
- ]), u;
482
- }
483
- }
484
- }), Z = T({
485
- name: "material",
486
- initial: {
487
- y: "100%"
488
- },
489
- idle: {
490
- value: {
491
- y: 0,
492
- opacity: 1
493
- },
494
- options: {
495
- duration: 0
496
- }
497
- },
498
- enter: {
499
- value: {
500
- y: 0
501
- },
502
- options: {
503
- duration: 0.35,
504
- ease: [0, 0, 0.2, 1]
505
- }
506
- },
507
- enterBack: {
508
- value: {
509
- y: "100%"
510
- },
511
- options: {
512
- duration: 0.25,
513
- ease: [0.4, 0, 1, 1]
514
- }
515
- },
516
- exit: {
517
- value: {
518
- y: -56,
519
- opacity: 0
520
- },
521
- options: {
522
- duration: 0.35,
523
- ease: [0.4, 0, 1, 1]
524
- }
525
- },
526
- exitBack: {
527
- value: {
528
- y: 0,
529
- opacity: 1
530
- },
531
- options: {
532
- duration: 0.25,
533
- ease: [0, 0, 0.2, 1]
534
- }
535
- },
536
- options: {
537
- swipeDirection: "y",
538
- onSwipeStart: async () => !0,
539
- onSwipe: (n, t, { animate: e, currentScreen: s, prevScreen: a, onProgress: r }) => {
540
- const { offset: o } = t, c = o.y, l = Math.max(0, Math.min(56, c)), u = Math.max(0, c - 56), d = Math.min(1, u / 160), m = Math.sqrt(d) * 12, i = Math.max(0, l + m), p = Math.min(56, i);
541
- return r?.(!0, p), e(
542
- s,
543
- {
544
- y: i
545
- },
546
- {
547
- duration: 0
548
- }
549
- ), e(
550
- a,
551
- {
552
- y: -56 + p,
553
- opacity: p / 56
554
- },
555
- { duration: 0 }
556
- ), p;
557
- },
558
- onSwipeEnd: async (n, t, { animate: e, currentScreen: s, prevScreen: a, onStart: r }) => {
559
- const { offset: o, velocity: c } = t, u = o.y > 56 || c.y > 20;
560
- return r?.(u), await Promise.all([
561
- e(
562
- s,
563
- {
564
- y: u ? "100%" : 0
565
- },
566
- {
567
- duration: u ? 0.22 : 0.24,
568
- ease: u ? [0.4, 0, 1, 1] : [0, 0, 0.2, 1]
569
- }
570
- ),
571
- e(
572
- a,
573
- {
574
- y: u ? 0 : -56,
575
- opacity: u ? 1 : 0
576
- },
577
- {
578
- duration: u ? 0.22 : 0.24,
579
- ease: u ? [0, 0, 0.2, 1] : [0.4, 0, 1, 1]
580
- }
581
- )
582
- ]), u;
583
- }
584
- }
585
- }), j = T({
586
- name: "none",
587
- initial: {},
588
- idle: {
589
- value: {},
590
- options: {
591
- duration: 0
592
- }
593
- },
594
- enter: {
595
- value: {},
596
- options: {
597
- duration: 0
598
- }
599
- },
600
- enterBack: {
601
- value: {},
602
- options: {
603
- duration: 0
604
- }
605
- },
606
- exit: {
607
- value: {},
608
- options: {
609
- duration: 0
610
- }
611
- },
612
- exitBack: {
613
- value: {},
614
- options: {
615
- duration: 0
616
- }
617
- }
618
- }), Tt = /* @__PURE__ */ new Map([
619
- ["none", j],
620
- ["cupertino", F],
621
- ["material", Z],
622
- ["layout", V]
623
- ]), Nt = w((n) => ({
624
- defaultTransitionName: "cupertino",
625
- setDefaultTransitionName: (t) => n({ defaultTransitionName: t })
626
- }));
627
- function K({
628
- name: n,
629
- initial: t,
630
- idle: e,
631
- enter: s,
632
- exit: a,
633
- options: r
634
- }) {
635
- return {
636
- name: n,
637
- initial: t,
638
- variants: {
639
- "IDLE-true": e,
640
- "IDLE-false": e,
641
- "PUSHING-true": e,
642
- "PUSHING-false": s,
643
- "REPLACING-true": e,
644
- "REPLACING-false": s,
645
- "POPPING-true": e,
646
- "POPPING-false": a,
647
- "COMPLETED-true": e,
648
- "COMPLETED-false": s
649
- },
650
- ...r
651
- };
244
+ //#endregion
245
+ //#region src/history/ensureWindowHistoryState.ts
246
+ function l(e) {
247
+ c() || window.history.state?.index || window.history.replaceState({
248
+ id: "root",
249
+ index: 0,
250
+ status: "IDLE",
251
+ params: {},
252
+ transitionName: e,
253
+ layoutId: null
254
+ }, "", window.location.href);
652
255
  }
653
- function Lt({
654
- name: n,
655
- initial: t,
656
- idle: e,
657
- pushOnEnter: s,
658
- pushOnExit: a,
659
- replaceOnEnter: r,
660
- replaceOnExit: o,
661
- popOnEnter: c,
662
- popOnExit: l,
663
- completedOnEnter: u,
664
- completedOnExit: d,
665
- options: m
666
- }) {
667
- return {
668
- name: n,
669
- initial: t,
670
- variants: {
671
- "IDLE-true": e,
672
- "IDLE-false": e,
673
- "PUSHING-false": a,
674
- "PUSHING-true": s,
675
- "REPLACING-false": o,
676
- "REPLACING-true": r,
677
- "POPPING-false": l,
678
- "POPPING-true": c,
679
- "COMPLETED-false": d,
680
- "COMPLETED-true": u
681
- },
682
- ...m
683
- };
256
+ //#endregion
257
+ //#region src/navigate/selfPopGuard.ts
258
+ var u = 0;
259
+ function d() {
260
+ u += 1;
684
261
  }
685
- const I = "rgba(0, 0, 0, 0.3)", q = K({
686
- name: "overlay",
687
- initial: {
688
- opacity: 0,
689
- backgroundColor: I
690
- },
691
- idle: {
692
- value: {
693
- opacity: 0,
694
- backgroundColor: I
695
- },
696
- options: {
697
- duration: 0
698
- }
699
- },
700
- // Visible dim applied when this screen is the one going behind / sitting
701
- // behind a new active screen (PUSHING-false / REPLACING-false / COMPLETED-false).
702
- // Duration matches cupertino's enter so the dim resolves in lockstep with the
703
- // underlying screen slide (and there's no animation-vs-hold-by-fill window for
704
- // the rest-rule handoff to race against — that's a function of duration + fill,
705
- // not the curve). Easing is intentionally left at the default: this animates
706
- // `opacity` (a luminance channel), not position, so cupertino's positional
707
- // decelerate curve would front-load the darkening into an abrupt step with a
708
- // long invisible tail. The default ease spreads the perceived dim evenly across
709
- // the duration, matching this decorator's linear-perceived-ramp design (see the
710
- // DIM_COLOR note above).
711
- enter: {
712
- value: {
713
- opacity: 1,
714
- backgroundColor: I
715
- },
716
- options: {
717
- duration: 0.7
718
- }
719
- },
720
- // POPPING-false target: the previously-behind screen is returning to active.
721
- // Fades from `enter` (visible dim) back to invisible so the overlay clears
722
- // before the screen lands at COMPLETED-true (= idle). Mirrors cupertino's
723
- // enterBack (the returning screen's slide-in) duration.
724
- exit: {
725
- value: {
726
- opacity: 0,
727
- backgroundColor: I
728
- },
729
- options: {
730
- duration: 0.6
731
- }
732
- },
733
- options: {
734
- onSwipeStart: (n, { animate: t, prevDecorator: e }) => t(
735
- e,
736
- {
737
- opacity: n ? 1 : 0
738
- },
739
- {
740
- duration: 0.3
741
- }
742
- ),
743
- onSwipe: (n, t, { animate: e, prevDecorator: s }) => e(
744
- s,
745
- {
746
- opacity: Math.max(0, 1 - t / 100)
747
- },
748
- {
749
- duration: 0
750
- }
751
- ),
752
- onSwipeEnd: (n, { animate: t, prevDecorator: e }) => t(
753
- e,
754
- {
755
- opacity: n ? 0 : 1
756
- },
757
- {
758
- duration: 0.3
759
- }
760
- )
761
- }
762
- }), Dt = /* @__PURE__ */ new Map([["overlay", q]]), k = {
763
- "IDLE-true": "self",
764
- "IDLE-false": "self",
765
- "PUSHING-true": "initial",
766
- "PUSHING-false": "IDLE-true",
767
- "REPLACING-true": "initial",
768
- "REPLACING-false": "IDLE-true",
769
- "POPPING-true": "IDLE-true",
770
- "POPPING-false": "PUSHING-false",
771
- "COMPLETED-true": "self",
772
- "COMPLETED-false": "self"
773
- }, O = Object.keys(k), W = O, J = (n) => n.replace(/[^a-zA-Z0-9_-]/g, "_"), b = (n) => typeof n == "object" && n !== null && !Array.isArray(n), tt = /* @__PURE__ */ new Set([
774
- "opacity",
775
- "scale",
776
- "scaleX",
777
- "scaleY",
778
- "scaleZ",
779
- "aspectRatio",
780
- "columnCount",
781
- "columns",
782
- "flex",
783
- "flexGrow",
784
- "flexShrink",
785
- "fontWeight",
786
- "gridArea",
787
- "gridColumn",
788
- "gridColumnEnd",
789
- "gridColumnStart",
790
- "gridRow",
791
- "gridRowEnd",
792
- "gridRowStart",
793
- "lineHeight",
794
- "lineClamp",
795
- "order",
796
- "orphans",
797
- "tabSize",
798
- "widows",
799
- "zIndex",
800
- "zoom",
801
- // SVG numerics
802
- "fillOpacity",
803
- "floodOpacity",
804
- "stopOpacity",
805
- "strokeOpacity",
806
- "strokeDasharray",
807
- "strokeDashoffset",
808
- "strokeMiterlimit",
809
- "strokeWidth"
810
- ]), et = (n, t) => t.startsWith("--") ? `${n}` : tt.has(t) ? `${n}` : t === "rotate" || t === "rotateX" || t === "rotateY" || t === "rotateZ" ? `${n}deg` : `${n}px`, $ = (n, t) => typeof t == "number" ? et(t, n) : typeof t == "string" ? t : "", R = (n) => n.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`), _ = /* @__PURE__ */ new Set([
811
- "x",
812
- "y",
813
- "z",
814
- "scale",
815
- "scaleX",
816
- "scaleY",
817
- "rotate",
818
- "rotateX",
819
- "rotateY",
820
- "rotateZ"
821
- ]), nt = /^-?0(\.0+)?(px|%|em|rem|vh|vw|vmin|vmax)?$/, st = /^-?0(\.0+)?(deg|rad|grad|turn)?$/, at = /^1(\.0+)?$/, rt = (n, t) => n === "scale" || n === "scaleX" || n === "scaleY" ? t === 1 ? !0 : typeof t == "string" ? at.test(t.trim()) : !1 : n === "rotate" || n === "rotateX" || n === "rotateY" || n === "rotateZ" ? t === 0 ? !0 : typeof t == "string" ? st.test(t.trim()) : !1 : t === 0 ? !0 : typeof t == "string" ? nt.test(t.trim()) : !1, ot = (n, t) => {
822
- switch (n) {
823
- case "x":
824
- return `translateX(${t})`;
825
- case "y":
826
- return `translateY(${t})`;
827
- case "z":
828
- return `translateZ(${t})`;
829
- case "scale":
830
- return `scale(${t})`;
831
- case "scaleX":
832
- return `scaleX(${t})`;
833
- case "scaleY":
834
- return `scaleY(${t})`;
835
- case "rotate":
836
- case "rotateZ":
837
- return `rotate(${t})`;
838
- case "rotateX":
839
- return `rotateX(${t})`;
840
- case "rotateY":
841
- return `rotateY(${t})`;
842
- default:
843
- return "";
844
- }
845
- }, wt = (n) => {
846
- const t = /* @__PURE__ */ new Set();
847
- let e = !1;
848
- const s = (a) => {
849
- if (b(a))
850
- for (const r of Object.keys(a)) {
851
- const o = a[r];
852
- $(r, o) !== "" && (_.has(r) ? e = !0 : t.add(R(r)));
853
- }
854
- };
855
- s(n.initial);
856
- for (const a of Object.values(n.variants))
857
- s(a.value);
858
- return e && t.add("transform"), Array.from(t);
859
- }, g = (n) => {
860
- if (!b(n)) return [];
861
- const t = [];
862
- let e = !0;
863
- const s = [];
864
- for (const a of Object.keys(n)) {
865
- const r = n[a], o = $(a, r);
866
- o !== "" && (_.has(a) ? (t.push(ot(a, o)), rt(a, r) || (e = !1)) : s.push({ property: R(a), value: o }));
867
- }
868
- return t.length > 0 && s.push({
869
- property: "transform",
870
- value: e ? "none" : t.join(" ")
871
- }), s;
872
- }, E = (n) => n.map((t) => ` ${t.property}: ${t.value};`).join(`
873
- `), it = (n) => Array.isArray(n) ? n.length === 4 && n.every((t) => typeof t == "number") ? `cubic-bezier(${n.join(", ")})` : "linear" : typeof n == "string" ? {
874
- linear: "linear",
875
- easeIn: "ease-in",
876
- easeOut: "ease-out",
877
- easeInOut: "ease-in-out",
878
- circIn: "cubic-bezier(0, 0.55, 0.45, 1)",
879
- circOut: "cubic-bezier(0.55, 0, 1, 0.45)",
880
- backIn: "cubic-bezier(0.31, 0.01, 0.66, -0.59)",
881
- backOut: "cubic-bezier(0.33, 1.53, 0.69, 0.99)",
882
- anticipate: "cubic-bezier(0.36, 0, 0.66, -0.56)"
883
- }[n] ?? "ease" : "ease", H = (n) => {
884
- if (!n) return 0;
885
- const t = n.duration;
886
- return typeof t == "number" && t >= 0 ? t : 0;
887
- }, U = (n) => n && typeof n.delay == "number" && n.delay > 0 ? n.delay : 0, A = (n, t) => {
888
- const [e, s] = t.split("-");
889
- return `[data-flemo-screen][data-flemo-transition="${n}"][data-flemo-status="${e}"][data-flemo-active="${s}"]`;
890
- }, M = (n, t) => {
891
- const [e, s] = t.split("-");
892
- return `[data-flemo-decorator][data-flemo-decorator-name="${n}"][data-flemo-status="${e}"][data-flemo-active="${s}"]`;
893
- }, ct = (n, t) => {
894
- const [e, s] = t.split("-");
895
- return `[data-flemo-bar][data-flemo-bar-transition="${n}"][data-flemo-bar-status="${e}"][data-flemo-bar-active="${s}"][data-flemo-bar-riding="true"]`;
896
- }, ut = (n, t, e) => `flemo-${n}-${J(t)}-${e}`, x = (n, t, e, s, a, r) => {
897
- const o = g(s), c = g(a.value), l = H(a.options), u = U(a.options), d = it(a.options?.ease), m = r(t, e), i = n === "screen" ? `${m},
898
- ${ct(t, e)}` : m;
899
- if (c.length === 0 && o.length === 0)
900
- return "";
901
- if (l <= 0 && u <= 0)
902
- return c.length === 0 ? "" : `${i} {
903
- ${E(c)}
904
- animation: none;
905
- }`;
906
- const p = ut(n, t, e), P = [
907
- `@keyframes ${p} {`,
908
- " from {",
909
- E(o).replace(/^/gm, " "),
910
- " }",
911
- " to {",
912
- E(c).replace(/^/gm, " "),
913
- " }",
914
- "}"
915
- ].join(`
916
- `), h = [
917
- `${p}`,
918
- `${l}s`,
919
- d,
920
- u > 0 ? `${u}s` : null,
921
- "both"
922
- ].filter(Boolean).join(" "), f = Array.from(
923
- /* @__PURE__ */ new Set([...o.map((N) => N.property), ...c.map((N) => N.property)])
924
- ), y = f.length > 0 ? ` will-change: ${f.join(", ")};
925
- ` : "", S = e.split("-")[0], Y = `${i} {
926
- animation: ${h};
927
- ${y}${S === "PUSHING" || S === "REPLACING" ? ` contain: layout;
928
- pointer-events: none;
929
- ` : ""}}`;
930
- return `${P}
931
- ${Y}`;
932
- }, C = (n, t, e, s) => {
933
- const a = g(s.value);
934
- return a.length === 0 ? "" : `${n(t, e)} {
935
- ${E(a)}
936
- }`;
937
- }, St = (n, t) => {
938
- const e = [];
939
- for (const s of n) {
940
- const a = s.name;
941
- for (const r of O) {
942
- const o = s.variants[r], c = k[r];
943
- if (c === "self") {
944
- e.push(C(A, a, r, o));
945
- continue;
946
- }
947
- const l = c === "initial" ? s.initial : s.variants[c].value;
948
- e.push(
949
- x("screen", a, r, l, o, A)
950
- );
951
- }
952
- }
953
- for (const s of t) {
954
- const a = s.name;
955
- for (const r of W) {
956
- const o = s.variants[r], c = k[r];
957
- if (c === "self") {
958
- e.push(C(M, a, r, o));
959
- continue;
960
- }
961
- const l = c === "initial" ? s.initial : s.variants[c].value;
962
- e.push(
963
- x(
964
- "decorator",
965
- a,
966
- r,
967
- l,
968
- o,
969
- M
970
- )
971
- );
972
- }
973
- }
974
- return e.filter((s) => s.length > 0).join(`
975
-
976
- `);
977
- }, vt = (n, t) => {
978
- const e = k[t];
979
- if (e === "self") return !1;
980
- const s = n.variants[t], a = H(s.options), r = U(s.options);
981
- if (a <= 0 && r <= 0) return !1;
982
- const o = e === "initial" ? n.initial : n.variants[e].value, c = g(o), l = g(s.value);
983
- return c.length > 0 || l.length > 0;
262
+ function f() {
263
+ return u > 0 ? (--u, !0) : !1;
264
+ }
265
+ //#endregion
266
+ //#region src/history/createHistorySync.ts
267
+ function p(e) {
268
+ let { stores: t } = e, n = async (e) => {
269
+ if (f()) return;
270
+ let n = e.state?.id, i = r.generateTaskId();
271
+ (await r.addTask(async (r) => {
272
+ let a = e.state?.index, o = e.state?.status, s = e.state?.params, c = e.state?.transitionName, l = e.state?.layoutId, { setStatus: u, setTransitionTaskId: d } = t.navigate.getState(), { index: f, addHistory: p, popHistory: m } = t.history.getState(), h = a < f, g = o === "PUSHING" && a > f, _ = o === "REPLACING" && a > f, v = window.location.pathname;
273
+ if (!h && !g && !_) {
274
+ r.abort();
275
+ return;
276
+ }
277
+ return d(i), h ? u("POPPING") : g ? (u("PUSHING"), p({
278
+ id: n,
279
+ pathname: v,
280
+ params: s,
281
+ transitionName: c,
282
+ layoutId: l
283
+ })) : (u("REPLACING"), p({
284
+ id: n,
285
+ pathname: v,
286
+ params: s,
287
+ transitionName: c,
288
+ layoutId: l
289
+ })), async () => {
290
+ h && m(a + 1), u("COMPLETED");
291
+ };
292
+ }, {
293
+ id: i,
294
+ control: { manual: !0 }
295
+ })).result?.();
296
+ };
297
+ return window.addEventListener("popstate", n), () => {
298
+ window.removeEventListener("popstate", n);
299
+ };
300
+ }
301
+ //#endregion
302
+ //#region src/navigate/store.ts
303
+ function m() {
304
+ return e((e) => ({
305
+ status: "IDLE",
306
+ transitionTaskId: null,
307
+ setStatus: (t) => e({ status: t }),
308
+ setTransitionTaskId: (t) => e({ transitionTaskId: t })
309
+ }));
310
+ }
311
+ //#endregion
312
+ //#region src/navigate/createNavigationController.ts
313
+ var h = (e, t, r) => {
314
+ let { regexp: i } = n(e);
315
+ for (let e = t - 1; e >= 0; e--) if (i.test(r[e].pathname)) return t - e;
316
+ return -1;
317
+ }, g = (e, t) => typeof e == "number" && Number.isFinite(e) ? Math.max(0, Math.trunc(e)) : t, _ = async (e, t) => {
318
+ let n, r = new Promise((e) => {
319
+ n = () => e(!0), window.addEventListener("popstate", n, { once: !0 });
320
+ }), i = new Promise((e) => setTimeout(() => e(!1), 200));
321
+ if (d(), window.history.go(-e), !await Promise.race([r, i])) {
322
+ window.removeEventListener("popstate", n);
323
+ return;
324
+ }
325
+ t();
984
326
  };
985
- function At() {
986
- return typeof document > "u";
327
+ function v(e) {
328
+ let { stores: t, buildPathname: n } = e, i = async (e, i, a) => {
329
+ let { status: o } = t.navigate.getState();
330
+ if (o !== "COMPLETED" && o !== "IDLE") return;
331
+ let s = t.transition.getState().defaultTransitionName, { transitionName: c = s, layoutId: l = null } = a ?? {}, u = r.generateTaskId();
332
+ (await r.addTask(async () => {
333
+ let { index: r, histories: o, addHistory: s, popHistories: d } = t.history.getState(), f = (() => {
334
+ if (a?.until != null) {
335
+ let e = h(a.until, r, o);
336
+ return e < 0 ? 0 : e;
337
+ }
338
+ return Math.min(g(a?.skip, 0), Math.max(0, r));
339
+ })(), { setStatus: p, setTransitionTaskId: m } = t.navigate.getState();
340
+ p("PUSHING"), m(u);
341
+ let { pathname: v, toPathname: y } = n(e, i ?? {}), b = {
342
+ id: u,
343
+ pathname: y,
344
+ params: i ?? {},
345
+ transitionName: c,
346
+ layoutId: l
347
+ };
348
+ return f === 0 ? (window.history.pushState({
349
+ id: u,
350
+ index: r + 1,
351
+ status: "PUSHING",
352
+ params: i,
353
+ transitionName: c,
354
+ layoutId: l
355
+ }, "", v), s(b), () => {
356
+ p("COMPLETED");
357
+ }) : (s(b), await _(f, () => {
358
+ window.history.pushState({
359
+ id: u,
360
+ index: t.history.getState().index - f,
361
+ status: "PUSHING",
362
+ params: i,
363
+ transitionName: c,
364
+ layoutId: l
365
+ }, "", v);
366
+ }), async () => {
367
+ d(f), p("COMPLETED");
368
+ });
369
+ }, {
370
+ id: u,
371
+ control: { manual: !0 }
372
+ })).result?.();
373
+ }, a = async (e, i, a) => {
374
+ let { status: o } = t.navigate.getState();
375
+ if (o !== "COMPLETED" && o !== "IDLE") return;
376
+ let s = t.transition.getState().defaultTransitionName, { transitionName: c = s, layoutId: l = null } = a ?? {}, u = r.generateTaskId();
377
+ (await r.addTask(async (r) => {
378
+ let { index: o, histories: s, addHistory: d, replaceHistory: f, popHistories: p } = t.history.getState(), m = (() => {
379
+ if (a?.until != null) {
380
+ let e = h(a.until, o, s);
381
+ return e < 0 ? 0 : e + 1;
382
+ }
383
+ return Math.min(g(a?.skip, 0) + 1, o + 1);
384
+ })();
385
+ if (m <= 0) {
386
+ r.abort();
387
+ return;
388
+ }
389
+ let { setStatus: v, setTransitionTaskId: y } = t.navigate.getState();
390
+ v("REPLACING"), y(u);
391
+ let { pathname: b, toPathname: x } = n(e, i ?? {}), S = {
392
+ id: u,
393
+ pathname: x,
394
+ params: i ?? {},
395
+ transitionName: c,
396
+ layoutId: l
397
+ };
398
+ return m === 1 ? (window.history.replaceState({
399
+ id: u,
400
+ index: o,
401
+ status: "REPLACING",
402
+ params: i,
403
+ transitionName: c,
404
+ layoutId: l
405
+ }, "", b), d(S), async () => {
406
+ f(o), v("COMPLETED");
407
+ }) : (p(m - 1), d(S), m <= o ? await _(m, () => {
408
+ window.history.pushState({
409
+ id: u,
410
+ index: t.history.getState().index - 1,
411
+ status: "REPLACING",
412
+ params: i,
413
+ transitionName: c,
414
+ layoutId: l
415
+ }, "", b);
416
+ }) : await _(o, () => {
417
+ window.history.replaceState({
418
+ id: u,
419
+ index: 0,
420
+ status: "REPLACING",
421
+ params: i,
422
+ transitionName: c,
423
+ layoutId: l
424
+ }, "", b);
425
+ }), async () => {
426
+ f(t.history.getState().index - 1), v("COMPLETED");
427
+ });
428
+ }, {
429
+ id: u,
430
+ control: { manual: !0 }
431
+ })).result?.();
432
+ }, o = async (e, n) => {
433
+ let i = r.generateTaskId();
434
+ (await r.addTask(async (r) => {
435
+ let { index: a, histories: o, popHistory: s, popHistories: c, setTransitionName: l } = t.history.getState();
436
+ if (a <= 0) {
437
+ r.abort();
438
+ return;
439
+ }
440
+ let u = Math.min(e(a, o), a);
441
+ if (u <= 0) {
442
+ r.abort();
443
+ return;
444
+ }
445
+ let { setStatus: f, setTransitionTaskId: p } = t.navigate.getState();
446
+ return n && l(a, n), f("POPPING"), p(i), c(u - 1), d(), u === 1 ? window.history.back() : window.history.go(-u), async () => {
447
+ s(t.history.getState().index), f("COMPLETED");
448
+ };
449
+ }, {
450
+ id: i,
451
+ control: { manual: !0 }
452
+ })).result?.();
453
+ };
454
+ return {
455
+ push: i,
456
+ replace: a,
457
+ pop: async (e) => {
458
+ await o((t, n) => {
459
+ if (e?.until != null) {
460
+ let r = h(e.until, t, n);
461
+ return r < 0 ? 0 : r;
462
+ }
463
+ let r = g(e?.skip, 1);
464
+ return r <= 0 ? 0 : Math.min(r, t);
465
+ }, e?.transitionName);
466
+ }
467
+ };
987
468
  }
988
- function lt(n, t) {
989
- return Array.isArray(n) ? n.find((e) => v(e).regexp.test(t)) ?? "" : v(n).regexp.test(t) ? n : "";
469
+ //#endregion
470
+ //#region src/screen/store.ts
471
+ function y() {
472
+ return e((e) => ({
473
+ dragStatus: "IDLE",
474
+ replaceTransitionStatus: "IDLE",
475
+ sharedBars: {},
476
+ setDragStatus: (t) => e({ dragStatus: t }),
477
+ setReplaceTransitionStatus: (t) => e({ replaceTransitionStatus: t }),
478
+ registerSharedBars: (t, n) => e((e) => ({ sharedBars: {
479
+ ...e.sharedBars,
480
+ [t]: n
481
+ } })),
482
+ unregisterSharedBars: (t) => e((e) => {
483
+ let n = { ...e.sharedBars };
484
+ return delete n[t], { sharedBars: n };
485
+ })
486
+ }));
990
487
  }
991
- function Mt(n, t, e) {
992
- const s = lt(n, t), a = B(s)(t), r = new URLSearchParams(e), o = Object.fromEntries(r.entries());
993
- return a ? { ...a.params, ...o } : {};
488
+ //#endregion
489
+ //#region src/screen/createScreenSelector.ts
490
+ function b(e, t) {
491
+ return e.map((n, r) => ({
492
+ ...n,
493
+ isActive: r === t,
494
+ isRoot: r === 0,
495
+ isPrev: r < t - 1,
496
+ zIndex: r,
497
+ transitionName: e[t].transitionName,
498
+ prevTransitionName: e[t - 1]?.transitionName
499
+ }));
994
500
  }
995
- function xt(n, t) {
996
- const {
997
- direction: e = "x",
998
- markerSelector: s = "[data-swipe-at-edge]",
999
- depthLimit: a = 24,
1000
- verifyByScroll: r = !1
1001
- } = t ?? {}, o = ft(n);
1002
- if (!o) return { element: null, hasMarker: !1 };
1003
- const c = o.closest?.(s);
1004
- if (c instanceof HTMLElement && D(c, e) && (!r || G(c, e)))
1005
- return { element: c, hasMarker: !0 };
1006
- let l = o, u = 0;
1007
- for (; l && u < a; ) {
1008
- if (D(l, e) && (!r || G(l, e)))
1009
- return { element: l, hasMarker: !1 };
1010
- l = l.parentElement, u++;
1011
- }
1012
- return { element: null, hasMarker: !1 };
501
+ //#endregion
502
+ //#region src/screen/computeScreenFreeze.ts
503
+ function x(e) {
504
+ let t = e.status === "COMPLETED" && e.dragStatus === "IDLE";
505
+ return !e.isActive && t || e.isPrev && e.index - 2 <= e.zIndex && e.replaceTransitionStatus === "IDLE" || e.isPrev && e.index - 2 > e.zIndex;
1013
506
  }
1014
- function ft(n) {
1015
- if (!n) return null;
1016
- const t = n, e = typeof t.composedPath == "function" ? t.composedPath() : void 0;
1017
- if (e && e.length) {
1018
- for (const s of e)
1019
- if (s instanceof HTMLElement) return s;
1020
- }
1021
- return n instanceof HTMLElement ? n : null;
507
+ //#endregion
508
+ //#region src/transition/createTransition.ts
509
+ function S({ name: e, initial: t, idle: n, enter: r, enterBack: i, exit: a, exitBack: o, options: s }) {
510
+ return {
511
+ name: e,
512
+ initial: t,
513
+ variants: {
514
+ "IDLE-true": n,
515
+ "IDLE-false": n,
516
+ "PUSHING-false": a,
517
+ "PUSHING-true": r,
518
+ "REPLACING-false": a,
519
+ "REPLACING-true": r,
520
+ "POPPING-false": o,
521
+ "POPPING-true": i,
522
+ "COMPLETED-false": a,
523
+ "COMPLETED-true": r
524
+ },
525
+ ...s
526
+ };
1022
527
  }
1023
- function D(n, t) {
1024
- return t === "y" ? n.scrollHeight - n.clientHeight > 1 : n.scrollWidth - n.clientWidth > 1;
528
+ //#endregion
529
+ //#region src/transition/createRawTransition.ts
530
+ function C({ name: e, initial: t, idle: n, pushOnEnter: r, pushOnExit: i, replaceOnEnter: a, replaceOnExit: o, popOnEnter: s, popOnExit: c, completedOnExit: l, completedOnEnter: u, options: d }) {
531
+ return {
532
+ name: e,
533
+ initial: t,
534
+ variants: {
535
+ "IDLE-true": n,
536
+ "IDLE-false": n,
537
+ "PUSHING-false": i,
538
+ "PUSHING-true": r,
539
+ "REPLACING-false": o,
540
+ "REPLACING-true": a,
541
+ "POPPING-false": c,
542
+ "POPPING-true": s,
543
+ "COMPLETED-false": l,
544
+ "COMPLETED-true": u
545
+ },
546
+ ...d
547
+ };
1025
548
  }
1026
- function G(n, t) {
1027
- if (!D(n, t) || typeof window > "u") return !1;
1028
- const e = window.getComputedStyle(n), s = t === "y" ? e.overflowY : e.overflowX;
1029
- return s === "auto" || s === "scroll" || s === "overlay";
549
+ //#endregion
550
+ //#region src/transition/cupertino.ts
551
+ var w = (e, t, n) => {
552
+ let [r, i] = t, [a, o] = n;
553
+ return i === r ? a : a + (e - r) / (i - r) * (o - a);
554
+ }, T = S({
555
+ name: "cupertino",
556
+ initial: { x: "100%" },
557
+ idle: {
558
+ value: { x: 0 },
559
+ options: { duration: 0 }
560
+ },
561
+ enter: {
562
+ value: { x: 0 },
563
+ options: {
564
+ duration: .7,
565
+ ease: [
566
+ .32,
567
+ .72,
568
+ 0,
569
+ 1
570
+ ]
571
+ }
572
+ },
573
+ enterBack: {
574
+ value: { x: "100%" },
575
+ options: {
576
+ duration: .6,
577
+ ease: [
578
+ .32,
579
+ .72,
580
+ 0,
581
+ 1
582
+ ]
583
+ }
584
+ },
585
+ exit: {
586
+ value: { x: "-30%" },
587
+ options: {
588
+ duration: .7,
589
+ ease: [
590
+ .32,
591
+ .72,
592
+ 0,
593
+ 1
594
+ ]
595
+ }
596
+ },
597
+ exitBack: {
598
+ value: { x: 0 },
599
+ options: {
600
+ duration: .6,
601
+ ease: [
602
+ .32,
603
+ .72,
604
+ 0,
605
+ 1
606
+ ]
607
+ }
608
+ },
609
+ options: {
610
+ decoratorName: "overlay",
611
+ swipeDirection: "x",
612
+ onSwipeStart: async () => !0,
613
+ onSwipe: (e, t, { animate: n, currentScreen: r, prevScreen: i, onProgress: a }) => {
614
+ let { offset: o } = t, s = o.x, c = w(s, [0, window.innerWidth], [0, 100]);
615
+ return a?.(!0, c), n(r, { x: Math.max(0, s) }, { duration: 0 }), n(i, { x: `${-30 + c * .3}%` }, { duration: 0 }), c;
616
+ },
617
+ onSwipeEnd: async (e, t, { animate: n, currentScreen: r, prevScreen: i, onStart: a }) => {
618
+ let { offset: o, velocity: s } = t, c = o.x > 50 || s.x > 20;
619
+ return a?.(c), await Promise.all([n(r, { x: c ? "100%" : 0 }, {
620
+ duration: .3,
621
+ ease: [
622
+ .32,
623
+ .72,
624
+ 0,
625
+ 1
626
+ ]
627
+ }), n(i, { x: c ? 0 : "-30%" }, {
628
+ duration: .3,
629
+ ease: [
630
+ .32,
631
+ .72,
632
+ 0,
633
+ 1
634
+ ]
635
+ })]), c;
636
+ }
637
+ }
638
+ }), ee = (e, t, n) => {
639
+ let [r, i] = t, [a, o] = n;
640
+ return i === r ? a : a + (e - r) / (i - r) * (o - a);
641
+ }, te = S({
642
+ name: "layout",
643
+ initial: { opacity: .97 },
644
+ idle: {
645
+ value: { opacity: 1 },
646
+ options: { duration: .3 }
647
+ },
648
+ enter: {
649
+ value: { opacity: 1 },
650
+ options: { duration: .3 }
651
+ },
652
+ enterBack: {
653
+ value: { opacity: .97 },
654
+ options: { duration: .3 }
655
+ },
656
+ exit: {
657
+ value: { opacity: .97 },
658
+ options: { duration: .3 }
659
+ },
660
+ exitBack: {
661
+ value: { opacity: 1 },
662
+ options: { duration: .3 }
663
+ },
664
+ options: {
665
+ decoratorName: "overlay",
666
+ swipeDirection: "y",
667
+ onSwipeStart: async () => !0,
668
+ onSwipe: (e, t, { animate: n, currentScreen: r, onProgress: i }) => {
669
+ let { offset: a } = t, o = a.y, s = Math.max(0, Math.min(56, o)), c = ee(s, [0, 56], [1, .96]), l = Math.max(0, o - 56), u = Math.min(1, l / 160), d = Math.sqrt(u) * 12, f = Math.max(0, s + d), p = Math.min(56, f);
670
+ return i?.(!0, 100), n(r, {
671
+ y: f,
672
+ opacity: c
673
+ }, { duration: 0 }), p;
674
+ },
675
+ onSwipeEnd: async (e, t, { animate: n, currentScreen: r, prevScreen: i, onStart: a }) => {
676
+ let { offset: o, velocity: s } = t, c = o.y > 56 || s.y > 20;
677
+ return a?.(c), await Promise.all([n(r, {
678
+ y: c ? "100%" : 0,
679
+ opacity: c ? .96 : 1
680
+ }, { duration: .3 }), n(i, {
681
+ y: 0,
682
+ opacity: c ? 1 : .97
683
+ }, { duration: .3 })]), c;
684
+ }
685
+ }
686
+ }), ne = S({
687
+ name: "material",
688
+ initial: { y: "100%" },
689
+ idle: {
690
+ value: {
691
+ y: 0,
692
+ opacity: 1
693
+ },
694
+ options: { duration: 0 }
695
+ },
696
+ enter: {
697
+ value: { y: 0 },
698
+ options: {
699
+ duration: .35,
700
+ ease: [
701
+ 0,
702
+ 0,
703
+ .2,
704
+ 1
705
+ ]
706
+ }
707
+ },
708
+ enterBack: {
709
+ value: { y: "100%" },
710
+ options: {
711
+ duration: .25,
712
+ ease: [
713
+ .4,
714
+ 0,
715
+ 1,
716
+ 1
717
+ ]
718
+ }
719
+ },
720
+ exit: {
721
+ value: {
722
+ y: -56,
723
+ opacity: 0
724
+ },
725
+ options: {
726
+ duration: .35,
727
+ ease: [
728
+ .4,
729
+ 0,
730
+ 1,
731
+ 1
732
+ ]
733
+ }
734
+ },
735
+ exitBack: {
736
+ value: {
737
+ y: 0,
738
+ opacity: 1
739
+ },
740
+ options: {
741
+ duration: .25,
742
+ ease: [
743
+ 0,
744
+ 0,
745
+ .2,
746
+ 1
747
+ ]
748
+ }
749
+ },
750
+ options: {
751
+ swipeDirection: "y",
752
+ onSwipeStart: async () => !0,
753
+ onSwipe: (e, t, { animate: n, currentScreen: r, prevScreen: i, onProgress: a }) => {
754
+ let { offset: o } = t, s = o.y, c = Math.max(0, Math.min(56, s)), l = Math.max(0, s - 56), u = Math.min(1, l / 160), d = Math.sqrt(u) * 12, f = Math.max(0, c + d), p = Math.min(56, f);
755
+ return a?.(!0, p), n(r, { y: f }, { duration: 0 }), n(i, {
756
+ y: -56 + p,
757
+ opacity: p / 56
758
+ }, { duration: 0 }), p;
759
+ },
760
+ onSwipeEnd: async (e, t, { animate: n, currentScreen: r, prevScreen: i, onStart: a }) => {
761
+ let { offset: o, velocity: s } = t, c = o.y > 56 || s.y > 20;
762
+ return a?.(c), await Promise.all([n(r, { y: c ? "100%" : 0 }, {
763
+ duration: c ? .22 : .24,
764
+ ease: c ? [
765
+ .4,
766
+ 0,
767
+ 1,
768
+ 1
769
+ ] : [
770
+ 0,
771
+ 0,
772
+ .2,
773
+ 1
774
+ ]
775
+ }), n(i, {
776
+ y: c ? 0 : -56,
777
+ opacity: +!!c
778
+ }, {
779
+ duration: c ? .22 : .24,
780
+ ease: c ? [
781
+ 0,
782
+ 0,
783
+ .2,
784
+ 1
785
+ ] : [
786
+ .4,
787
+ 0,
788
+ 1,
789
+ 1
790
+ ]
791
+ })]), c;
792
+ }
793
+ }
794
+ }), E = S({
795
+ name: "none",
796
+ initial: {},
797
+ idle: {
798
+ value: {},
799
+ options: { duration: 0 }
800
+ },
801
+ enter: {
802
+ value: {},
803
+ options: { duration: 0 }
804
+ },
805
+ enterBack: {
806
+ value: {},
807
+ options: { duration: 0 }
808
+ },
809
+ exit: {
810
+ value: {},
811
+ options: { duration: 0 }
812
+ },
813
+ exitBack: {
814
+ value: {},
815
+ options: { duration: 0 }
816
+ }
817
+ }), D = new Map([
818
+ ["none", E],
819
+ ["cupertino", T],
820
+ ["material", ne],
821
+ ["layout", te]
822
+ ]);
823
+ //#endregion
824
+ //#region src/transition/store.ts
825
+ function re(t = "cupertino") {
826
+ return e((e) => ({
827
+ defaultTransitionName: t,
828
+ setDefaultTransitionName: (t) => e({ defaultTransitionName: t })
829
+ }));
1030
830
  }
1031
- export {
1032
- yt as TaskManger,
1033
- ut as animationName,
1034
- G as canProgrammaticallyScroll,
1035
- wt as collectAnimatedProperties,
1036
- St as compileTransitionStyles,
1037
- Et as consumeSelfInducedPop,
1038
- K as createDecorator,
1039
- Lt as createRawDecorator,
1040
- kt as createRawTransition,
1041
- T as createTransition,
1042
- F as cupertino,
1043
- Dt as decoratorMap,
1044
- it as easingToCss,
1045
- xt as findScrollable,
1046
- lt as getMatchedPathPattern,
1047
- Mt as getParams,
1048
- At as isServer,
1049
- V as layout,
1050
- It as markSelfInducedPop,
1051
- Z as material,
1052
- j as none,
1053
- D as overflowsAxis,
1054
- q as overlay,
1055
- g as targetToDecls,
1056
- Tt as transitionMap,
1057
- Pt as useHistoryStore,
1058
- gt as useNavigateStore,
1059
- Nt as useTransitionStore,
1060
- vt as variantHasAnimation
1061
- };
831
+ //#endregion
832
+ //#region src/transition/decorator/createDecorator.ts
833
+ function ie({ name: e, initial: t, idle: n, enter: r, exit: i, options: a }) {
834
+ return {
835
+ name: e,
836
+ initial: t,
837
+ variants: {
838
+ "IDLE-true": n,
839
+ "IDLE-false": n,
840
+ "PUSHING-true": n,
841
+ "PUSHING-false": r,
842
+ "REPLACING-true": n,
843
+ "REPLACING-false": r,
844
+ "POPPING-true": n,
845
+ "POPPING-false": i,
846
+ "COMPLETED-true": n,
847
+ "COMPLETED-false": r
848
+ },
849
+ ...a
850
+ };
851
+ }
852
+ //#endregion
853
+ //#region src/transition/decorator/createRawDecorator.ts
854
+ function ae({ name: e, initial: t, idle: n, pushOnEnter: r, pushOnExit: i, replaceOnEnter: a, replaceOnExit: o, popOnEnter: s, popOnExit: c, completedOnEnter: l, completedOnExit: u, options: d }) {
855
+ return {
856
+ name: e,
857
+ initial: t,
858
+ variants: {
859
+ "IDLE-true": n,
860
+ "IDLE-false": n,
861
+ "PUSHING-false": i,
862
+ "PUSHING-true": r,
863
+ "REPLACING-false": o,
864
+ "REPLACING-true": a,
865
+ "POPPING-false": c,
866
+ "POPPING-true": s,
867
+ "COMPLETED-false": u,
868
+ "COMPLETED-true": l
869
+ },
870
+ ...d
871
+ };
872
+ }
873
+ //#endregion
874
+ //#region src/transition/decorator/overlay.ts
875
+ var O = "rgba(0, 0, 0, 0.3)", oe = ie({
876
+ name: "overlay",
877
+ initial: {
878
+ opacity: 0,
879
+ backgroundColor: O
880
+ },
881
+ idle: {
882
+ value: {
883
+ opacity: 0,
884
+ backgroundColor: O
885
+ },
886
+ options: { duration: 0 }
887
+ },
888
+ enter: {
889
+ value: {
890
+ opacity: 1,
891
+ backgroundColor: O
892
+ },
893
+ options: { duration: .7 }
894
+ },
895
+ exit: {
896
+ value: {
897
+ opacity: 0,
898
+ backgroundColor: O
899
+ },
900
+ options: { duration: .6 }
901
+ },
902
+ options: {
903
+ onSwipeStart: (e, { animate: t, prevDecorator: n }) => t(n, { opacity: +!!e }, { duration: .3 }),
904
+ onSwipe: (e, t, { animate: n, prevDecorator: r }) => n(r, { opacity: Math.max(0, 1 - t / 100) }, { duration: 0 }),
905
+ onSwipeEnd: (e, { animate: t, prevDecorator: n }) => t(n, { opacity: +!e }, { duration: .3 })
906
+ }
907
+ }), se = new Map([["overlay", oe]]);
908
+ //#endregion
909
+ //#region src/transition/partTransition/createPartTransition.ts
910
+ function ce({ name: e, initial: t, idle: n, enter: r, exit: i, options: a }) {
911
+ return {
912
+ name: e,
913
+ initial: t,
914
+ variants: {
915
+ "IDLE-true": n,
916
+ "IDLE-false": n,
917
+ "PUSHING-true": n,
918
+ "PUSHING-false": r,
919
+ "REPLACING-true": n,
920
+ "REPLACING-false": r,
921
+ "POPPING-true": n,
922
+ "POPPING-false": i,
923
+ "COMPLETED-true": n,
924
+ "COMPLETED-false": r
925
+ },
926
+ ...a
927
+ };
928
+ }
929
+ //#endregion
930
+ //#region src/transition/partTransition/createRawPartTransition.ts
931
+ function le({ name: e, initial: t, idle: n, pushOnEnter: r, pushOnExit: i, replaceOnEnter: a, replaceOnExit: o, popOnEnter: s, popOnExit: c, completedOnEnter: l, completedOnExit: u, options: d }) {
932
+ return {
933
+ name: e,
934
+ initial: t,
935
+ variants: {
936
+ "IDLE-true": n,
937
+ "IDLE-false": n,
938
+ "PUSHING-false": i,
939
+ "PUSHING-true": r,
940
+ "REPLACING-false": o,
941
+ "REPLACING-true": a,
942
+ "POPPING-false": c,
943
+ "POPPING-true": s,
944
+ "COMPLETED-false": u,
945
+ "COMPLETED-true": l
946
+ },
947
+ ...d
948
+ };
949
+ }
950
+ //#endregion
951
+ //#region src/transition/partTransition/partTransition.ts
952
+ var k = /* @__PURE__ */ new Map(), A = {
953
+ "IDLE-true": "self",
954
+ "IDLE-false": "self",
955
+ "PUSHING-true": "initial",
956
+ "PUSHING-false": "IDLE-true",
957
+ "REPLACING-true": "initial",
958
+ "REPLACING-false": "IDLE-true",
959
+ "POPPING-true": "IDLE-true",
960
+ "POPPING-false": "PUSHING-false",
961
+ "COMPLETED-true": "self",
962
+ "COMPLETED-false": "self"
963
+ }, ue = Object.keys(A), de = ue, fe = (e) => e.replace(/[^a-zA-Z0-9_-]/g, "_"), j = (e) => typeof e == "object" && !!e && !Array.isArray(e), pe = new Set(/* @__PURE__ */ "opacity.scale.scaleX.scaleY.scaleZ.aspectRatio.columnCount.columns.flex.flexGrow.flexShrink.fontWeight.gridArea.gridColumn.gridColumnEnd.gridColumnStart.gridRow.gridRowEnd.gridRowStart.lineHeight.lineClamp.order.orphans.tabSize.widows.zIndex.zoom.fillOpacity.floodOpacity.stopOpacity.strokeOpacity.strokeDasharray.strokeDashoffset.strokeMiterlimit.strokeWidth".split(".")), me = (e, t) => t.startsWith("--") || pe.has(t) ? `${e}` : t === "rotate" || t === "rotateX" || t === "rotateY" || t === "rotateZ" ? `${e}deg` : `${e}px`, M = (e, t) => typeof t == "number" ? me(t, e) : typeof t == "string" ? t : "", N = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), P = new Set([
964
+ "x",
965
+ "y",
966
+ "z",
967
+ "scale",
968
+ "scaleX",
969
+ "scaleY",
970
+ "rotate",
971
+ "rotateX",
972
+ "rotateY",
973
+ "rotateZ"
974
+ ]), he = /^-?0(\.0+)?(px|%|em|rem|vh|vw|vmin|vmax)?$/, ge = /^-?0(\.0+)?(deg|rad|grad|turn)?$/, _e = /^1(\.0+)?$/, ve = (e, t) => e === "scale" || e === "scaleX" || e === "scaleY" ? t === 1 ? !0 : typeof t == "string" ? _e.test(t.trim()) : !1 : e === "rotate" || e === "rotateX" || e === "rotateY" || e === "rotateZ" ? t === 0 ? !0 : typeof t == "string" ? ge.test(t.trim()) : !1 : t === 0 ? !0 : typeof t == "string" ? he.test(t.trim()) : !1, ye = (e, t) => {
975
+ switch (e) {
976
+ case "x": return `translateX(${t})`;
977
+ case "y": return `translateY(${t})`;
978
+ case "z": return `translateZ(${t})`;
979
+ case "scale": return `scale(${t})`;
980
+ case "scaleX": return `scaleX(${t})`;
981
+ case "scaleY": return `scaleY(${t})`;
982
+ case "rotate":
983
+ case "rotateZ": return `rotate(${t})`;
984
+ case "rotateX": return `rotateX(${t})`;
985
+ case "rotateY": return `rotateY(${t})`;
986
+ default: return "";
987
+ }
988
+ }, F = (e) => {
989
+ let t = /* @__PURE__ */ new Set(), n = !1, r = (e) => {
990
+ if (j(e)) for (let r of Object.keys(e)) {
991
+ let i = e[r];
992
+ M(r, i) !== "" && (P.has(r) ? n = !0 : t.add(N(r)));
993
+ }
994
+ };
995
+ r(e.initial);
996
+ for (let t of Object.values(e.variants)) r(t.value);
997
+ return n && t.add("transform"), Array.from(t);
998
+ }, I = (e) => {
999
+ if (!j(e)) return [];
1000
+ let t = [], n = !0, r = [];
1001
+ for (let i of Object.keys(e)) {
1002
+ let a = e[i], o = M(i, a);
1003
+ o !== "" && (P.has(i) ? (t.push(ye(i, o)), ve(i, a) || (n = !1)) : r.push({
1004
+ property: N(i),
1005
+ value: o
1006
+ }));
1007
+ }
1008
+ return t.length > 0 && r.push({
1009
+ property: "transform",
1010
+ value: n ? "none" : t.join(" ")
1011
+ }), r;
1012
+ }, L = (e) => e.map((e) => ` ${e.property}: ${e.value};`).join("\n"), R = (e) => Array.isArray(e) ? e.length === 4 && e.every((e) => typeof e == "number") ? `cubic-bezier(${e.join(", ")})` : "linear" : typeof e == "string" ? {
1013
+ linear: "linear",
1014
+ easeIn: "ease-in",
1015
+ easeOut: "ease-out",
1016
+ easeInOut: "ease-in-out",
1017
+ circIn: "cubic-bezier(0, 0.55, 0.45, 1)",
1018
+ circOut: "cubic-bezier(0.55, 0, 1, 0.45)",
1019
+ backIn: "cubic-bezier(0.31, 0.01, 0.66, -0.59)",
1020
+ backOut: "cubic-bezier(0.33, 1.53, 0.69, 0.99)",
1021
+ anticipate: "cubic-bezier(0.36, 0, 0.66, -0.56)"
1022
+ }[e] ?? "ease" : "ease", z = (e) => {
1023
+ if (!e) return 0;
1024
+ let t = e.duration;
1025
+ return typeof t == "number" && t >= 0 ? t : 0;
1026
+ }, B = (e) => e && typeof e.delay == "number" && e.delay > 0 ? e.delay : 0, be = (e, t) => {
1027
+ let [n, r] = t.split("-");
1028
+ return `[data-flemo-screen][data-flemo-transition="${e}"][data-flemo-status="${n}"][data-flemo-active="${r}"]`;
1029
+ }, xe = (e, t) => {
1030
+ let [n, r] = t.split("-");
1031
+ return `[data-flemo-decorator][data-flemo-decorator-name="${e}"][data-flemo-status="${n}"][data-flemo-active="${r}"]`;
1032
+ }, Se = (e, t) => {
1033
+ let [n, r] = t.split("-");
1034
+ return `[data-flemo-bar][data-flemo-bar-transition="${e}"][data-flemo-bar-status="${n}"][data-flemo-bar-active="${r}"][data-flemo-bar-riding="true"]`;
1035
+ }, Ce = (e, t) => {
1036
+ let [n, r] = t.split("-");
1037
+ return `[data-flemo-part-name="${e}"][data-flemo-status="${n}"][data-flemo-active="${r}"]`;
1038
+ }, V = (e, t, n) => `flemo-${e}-${fe(t)}-${n}`, H = (e, t, n, r, i, a) => {
1039
+ let o = I(r), s = I(i.value), c = z(i.options), l = B(i.options), u = R(i.options?.ease), d = a(t, n), f = e === "screen" ? `${d},\n${Se(t, n)}` : d;
1040
+ if (s.length === 0 && o.length === 0) return "";
1041
+ if (c <= 0 && l <= 0) return s.length === 0 ? "" : `${f} {\n${L(s)}\n animation: none;\n}`;
1042
+ let p = V(e, t, n), m = [
1043
+ `@keyframes ${p} {`,
1044
+ " from {",
1045
+ L(o).replace(/^/gm, " "),
1046
+ " }",
1047
+ " to {",
1048
+ L(s).replace(/^/gm, " "),
1049
+ " }",
1050
+ "}"
1051
+ ].join("\n"), h = [
1052
+ `${p}`,
1053
+ `${c}s`,
1054
+ u,
1055
+ l > 0 ? `${l}s` : null,
1056
+ "both"
1057
+ ].filter(Boolean).join(" "), g = Array.from(new Set([...o.map((e) => e.property), ...s.map((e) => e.property)])), _ = g.length > 0 ? ` will-change: ${g.join(", ")};\n` : "", v = n.split("-")[0];
1058
+ return `${m}\n${`${f} {\n animation: ${h};\n${_}${v === "PUSHING" || v === "REPLACING" ? " contain: layout;\n pointer-events: none;\n" : ""}}`}`;
1059
+ }, U = (e, t, n, r) => {
1060
+ let i = I(r.value);
1061
+ return i.length === 0 ? "" : `${e(t, n)} {\n${L(i)}\n}`;
1062
+ }, we = (e, t, n = []) => {
1063
+ let r = [];
1064
+ for (let t of e) {
1065
+ let e = t.name;
1066
+ for (let n of ue) {
1067
+ let i = t.variants[n], a = A[n];
1068
+ if (a === "self") {
1069
+ r.push(U(be, e, n, i));
1070
+ continue;
1071
+ }
1072
+ let o = a === "initial" ? t.initial : t.variants[a].value;
1073
+ r.push(H("screen", e, n, o, i, be));
1074
+ }
1075
+ }
1076
+ for (let e of t) {
1077
+ let t = e.name;
1078
+ for (let n of de) {
1079
+ let i = e.variants[n], a = A[n];
1080
+ if (a === "self") {
1081
+ r.push(U(xe, t, n, i));
1082
+ continue;
1083
+ }
1084
+ let o = a === "initial" ? e.initial : e.variants[a].value;
1085
+ r.push(H("decorator", t, n, o, i, xe));
1086
+ }
1087
+ }
1088
+ for (let e of n) {
1089
+ let t = e.name;
1090
+ for (let n of de) {
1091
+ let i = e.variants[n], a = A[n];
1092
+ if (a === "self") {
1093
+ r.push(U(Ce, t, n, i));
1094
+ continue;
1095
+ }
1096
+ let o = a === "initial" ? e.initial : e.variants[a].value;
1097
+ r.push(H("part", t, n, o, i, Ce));
1098
+ }
1099
+ }
1100
+ return r.filter((e) => e.length > 0).join("\n\n");
1101
+ }, Te = (e, t) => {
1102
+ let n = A[t];
1103
+ if (n === "self") return !1;
1104
+ let r = e.variants[t], i = z(r.options), a = B(r.options);
1105
+ if (i <= 0 && a <= 0) return !1;
1106
+ let o = I(n === "initial" ? e.initial : e.variants[n].value), s = I(r.value);
1107
+ return o.length > 0 || s.length > 0;
1108
+ }, Ee = "data-flemo";
1109
+ function De() {
1110
+ if (c()) return;
1111
+ let e = we(D.values(), se.values(), k.values()), t = document.head.querySelector(`style[${Ee}]`);
1112
+ t || (t = document.createElement("style"), t.setAttribute(Ee, ""), document.head.appendChild(t)), t.textContent !== e && (t.textContent = e);
1113
+ }
1114
+ //#endregion
1115
+ //#region src/transition/animateInline.ts
1116
+ var Oe = (e) => typeof HTMLElement < "u" && e instanceof HTMLElement, W = /* @__PURE__ */ new WeakMap(), ke = (e, t) => {
1117
+ let n = W.get(e);
1118
+ n || (n = /* @__PURE__ */ new Set(), W.set(e, n)), n.add(t);
1119
+ }, G = (e, t) => {
1120
+ if (e.style.transition = "", t) {
1121
+ let n = W.get(e);
1122
+ for (let r of t) e.style.removeProperty(r), n?.delete(r);
1123
+ return;
1124
+ }
1125
+ let n = W.get(e);
1126
+ if (n && n.size > 0) {
1127
+ for (let t of n) e.style.removeProperty(t);
1128
+ n.clear();
1129
+ return;
1130
+ }
1131
+ e.style.removeProperty("transform"), e.style.removeProperty("opacity");
1132
+ }, K = (e, t, n = {}) => {
1133
+ if (!Oe(e)) return Promise.resolve();
1134
+ let r = e, i = I(t);
1135
+ if (i.length === 0) return Promise.resolve();
1136
+ let a = typeof n.duration == "number" ? n.duration : 0, o = typeof n.delay == "number" && n.delay > 0 ? n.delay : 0, s = R(n.ease);
1137
+ if (a <= 0 && o <= 0) {
1138
+ r.style.transition = "none";
1139
+ for (let e of i) r.style.setProperty(e.property, e.value), ke(r, e.property);
1140
+ return Promise.resolve();
1141
+ }
1142
+ let c = i.map((e) => `${e.property} ${a}s ${s} ${o}s`).join(", ");
1143
+ r.style.transition = c, r.offsetWidth;
1144
+ for (let e of i) r.style.setProperty(e.property, e.value), ke(r, e.property);
1145
+ return new Promise((e) => {
1146
+ let t = !1, n = () => {
1147
+ t || (t = !0, r.removeEventListener("transitionend", i), e());
1148
+ }, i = (e) => {
1149
+ e.target === r && n();
1150
+ };
1151
+ r.addEventListener("transitionend", i), setTimeout(n, (a + o) * 1e3 + 60);
1152
+ });
1153
+ }, q = "data-flemo-skip-animation", J = () => {};
1154
+ function Ae(e) {
1155
+ return { driveScreenLifecycle: (t) => {
1156
+ let { getElements: n, transitionName: i, prevTransitionName: a, status: o, isActive: s } = t;
1157
+ if (!s) return o === "REPLACING" && a !== i && e.setReplaceTransitionStatus("PENDING"), J;
1158
+ if (o === "COMPLETED") {
1159
+ e.setDragStatus("IDLE"), e.setReplaceTransitionStatus("IDLE");
1160
+ let { scope: t, decorator: r, bars: i } = n();
1161
+ t && (G(t), t.removeAttribute(q)), r && (G(r), r.removeAttribute(q));
1162
+ for (let e of i ?? []) e && (G(e), e.style.removeProperty("will-change"));
1163
+ return J;
1164
+ }
1165
+ if (o === "IDLE") return J;
1166
+ let { scope: c } = n();
1167
+ if (!c) return J;
1168
+ let l = () => {
1169
+ let t = e.getTransitionTaskId();
1170
+ t && r.resolveTask(t);
1171
+ }, u = D.get(i) ?? D.get("none"), d = `${o}-true`;
1172
+ if (!(c.getAttribute("data-flemo-skip-animation") !== "true" && Te(u, d))) return queueMicrotask(l), J;
1173
+ let f = V("screen", i, d), p = (e) => {
1174
+ e.target === c && e.animationName === f && (c.removeEventListener("animationend", p), l());
1175
+ };
1176
+ return c.addEventListener("animationend", p), () => {
1177
+ c.removeEventListener("animationend", p);
1178
+ };
1179
+ } };
1180
+ }
1181
+ //#endregion
1182
+ //#region src/utils/findScrollable.ts
1183
+ function Y(e, t) {
1184
+ let { direction: n = "x", markerSelector: r = "[data-swipe-at-edge]", depthLimit: i = 24, verifyByScroll: a = !1 } = t ?? {}, o = je(e);
1185
+ if (!o) return {
1186
+ element: null,
1187
+ hasMarker: !1
1188
+ };
1189
+ let s = o.closest?.(r);
1190
+ if (s instanceof HTMLElement && X(s, n) && (!a || Z(s, n))) return {
1191
+ element: s,
1192
+ hasMarker: !0
1193
+ };
1194
+ let c = o, l = 0;
1195
+ for (; c && l < i;) {
1196
+ if (X(c, n) && (!a || Z(c, n))) return {
1197
+ element: c,
1198
+ hasMarker: !1
1199
+ };
1200
+ c = c.parentElement, l++;
1201
+ }
1202
+ return {
1203
+ element: null,
1204
+ hasMarker: !1
1205
+ };
1206
+ }
1207
+ function je(e) {
1208
+ if (!e) return null;
1209
+ let t = e, n = typeof t.composedPath == "function" ? t.composedPath() : void 0;
1210
+ if (n && n.length) {
1211
+ for (let e of n) if (e instanceof HTMLElement) return e;
1212
+ }
1213
+ return e instanceof HTMLElement ? e : null;
1214
+ }
1215
+ function X(e, t) {
1216
+ return t === "y" ? e.scrollHeight - e.clientHeight > 1 : e.scrollWidth - e.clientWidth > 1;
1217
+ }
1218
+ function Z(e, t) {
1219
+ if (!X(e, t) || typeof window > "u") return !1;
1220
+ let n = window.getComputedStyle(e), r = t === "y" ? n.overflowY : n.overflowX;
1221
+ return r === "auto" || r === "scroll" || r === "overlay";
1222
+ }
1223
+ //#endregion
1224
+ //#region src/core/engine/createSwipeController.ts
1225
+ var Q = "data-flemo-skip-animation";
1226
+ function Me(e) {
1227
+ let t = null, n = null, r = {
1228
+ current: [],
1229
+ prev: []
1230
+ }, i = {
1231
+ current: [],
1232
+ prev: []
1233
+ }, a = !1, o = !1, s = !1, c = {
1234
+ x: 0,
1235
+ y: 0
1236
+ }, l = {
1237
+ x: 0,
1238
+ y: 0
1239
+ }, u = 0, d = {
1240
+ x: 0,
1241
+ y: 0
1242
+ }, f = {
1243
+ element: null,
1244
+ hasMarker: !1
1245
+ }, p = {
1246
+ element: null,
1247
+ hasMarker: !1
1248
+ }, m = 0, h = 0, g = (e) => ({
1249
+ point: {
1250
+ x: e.clientX,
1251
+ y: e.clientY
1252
+ },
1253
+ offset: {
1254
+ x: e.clientX - c.x,
1255
+ y: e.clientY - c.y
1256
+ },
1257
+ delta: {
1258
+ x: e.clientX - l.x,
1259
+ y: e.clientY - l.y
1260
+ },
1261
+ velocity: d
1262
+ }), _ = (e) => {
1263
+ let t = e.timeStamp, n = Math.max(1, t - u);
1264
+ d = {
1265
+ x: (e.clientX - l.x) / n * 1e3,
1266
+ y: (e.clientY - l.y) / n * 1e3
1267
+ }, l = {
1268
+ x: e.clientX,
1269
+ y: e.clientY
1270
+ }, u = t;
1271
+ }, v = (n, i, a) => {
1272
+ let o = K(n, i, a);
1273
+ if (n === e.getElements().scope) for (let e of r.current) K(e, i, a);
1274
+ else if (n === t) for (let e of r.prev) K(e, i, a);
1275
+ return o;
1276
+ }, y = (t) => {
1277
+ let n = e.getPartnerBars(), i = [], { sharedAppBar: a, sharedNavigationBar: o } = e.getElements();
1278
+ a && e.hasSharedAppBar() && !n?.appBar && i.push(a), o && e.hasSharedNavigationBar() && !n?.navigationBar && i.push(o);
1279
+ let s = [];
1280
+ if (t) {
1281
+ let n = t.querySelector("[data-flemo-bar=\"app\"]"), r = t.querySelector("[data-flemo-bar=\"nav\"]");
1282
+ n && !e.hasSharedAppBar() && s.push(n), r && !e.hasSharedNavigationBar() && s.push(r);
1283
+ }
1284
+ r = {
1285
+ current: i,
1286
+ prev: s
1287
+ };
1288
+ let c = F(e.getTransition()).join(", ");
1289
+ for (let e of i) e.style.willChange = c;
1290
+ for (let e of s) e.style.willChange = c;
1291
+ }, b = () => {
1292
+ for (let e of r.current) G(e), e.style.removeProperty("will-change");
1293
+ for (let e of r.prev) G(e), e.style.removeProperty("will-change");
1294
+ r = {
1295
+ current: [],
1296
+ prev: []
1297
+ };
1298
+ }, x = (t) => {
1299
+ let { screenContainer: n } = e.getElements(), r = (e) => Array.from(e.querySelectorAll("[data-flemo-part-name]"));
1300
+ i = {
1301
+ current: r(n),
1302
+ prev: r(t)
1303
+ };
1304
+ }, S = (e, t, n) => {
1305
+ let r = (r, i) => {
1306
+ let a = k.get(r.getAttribute("data-flemo-part-name"));
1307
+ if (!a) return;
1308
+ let o = {
1309
+ animate: K,
1310
+ element: r,
1311
+ active: i
1312
+ };
1313
+ e === "swipe" ? a.onSwipe?.(t, n, o) : e === "start" ? a.onSwipeStart?.(t, o) : a.onSwipeEnd?.(t, o);
1314
+ };
1315
+ for (let e of i.current) r(e, !0);
1316
+ for (let e of i.prev) r(e, !1);
1317
+ }, C = () => {
1318
+ for (let e of [...i.current, ...i.prev]) G(e);
1319
+ i = {
1320
+ current: [],
1321
+ prev: []
1322
+ };
1323
+ }, w = async (r) => {
1324
+ let i = e.getTransition();
1325
+ if (!i.swipeDirection || e.getViewportScrollHeight() > 10) return;
1326
+ let { scope: a, screenContainer: o, decorator: f } = e.getElements();
1327
+ if (!a) return;
1328
+ let p = o?.parentElement?.previousElementSibling ?? null;
1329
+ if (t = p?.querySelector("[data-flemo-screen]") ?? null, n = p?.querySelector("[data-flemo-decorator]") ?? null, !t) return;
1330
+ s = !0, c = {
1331
+ x: r.clientX,
1332
+ y: r.clientY
1333
+ }, l = {
1334
+ x: r.clientX,
1335
+ y: r.clientY
1336
+ }, u = r.timeStamp, d = {
1337
+ x: 0,
1338
+ y: 0
1339
+ }, a.setPointerCapture(r.pointerId), y(p), x(p);
1340
+ let m = e.getDecorator();
1341
+ await i.onSwipeStart(r, g(r), {
1342
+ animate: v,
1343
+ currentScreen: a,
1344
+ prevScreen: t,
1345
+ onStart: (e) => {
1346
+ m?.onSwipeStart?.(e, {
1347
+ animate: K,
1348
+ currentDecorator: f,
1349
+ prevDecorator: n
1350
+ }), S("start", e, 0);
1351
+ }
1352
+ }) ? e.setDragStatus("PENDING") : (e.setDragStatus("IDLE"), s = !1, b());
1353
+ }, T = (r) => {
1354
+ let i = e.getTransition();
1355
+ if (!i.swipeDirection || !s || e.getViewportScrollHeight() > 10) return;
1356
+ _(r);
1357
+ let { scope: a, decorator: o } = e.getElements(), c = e.getDecorator();
1358
+ i.onSwipe(r, g(r), {
1359
+ animate: v,
1360
+ currentScreen: a,
1361
+ prevScreen: t,
1362
+ onProgress: (e, t) => {
1363
+ c?.onSwipe?.(e, t, {
1364
+ animate: K,
1365
+ currentDecorator: o,
1366
+ prevDecorator: n
1367
+ }), S("swipe", e, t);
1368
+ }
1369
+ });
1370
+ }, ee = async (a) => {
1371
+ let o = e.getTransition();
1372
+ if (!o.swipeDirection || !s) return;
1373
+ s = !1;
1374
+ let { scope: c, decorator: l } = e.getElements();
1375
+ c && c.hasPointerCapture(a.pointerId) && c.releasePointerCapture(a.pointerId);
1376
+ let u = e.getDecorator();
1377
+ if (await o.onSwipeEnd(a, g(a), {
1378
+ animate: v,
1379
+ currentScreen: c,
1380
+ prevScreen: t,
1381
+ onStart: (e) => {
1382
+ u?.onSwipeEnd?.(e, {
1383
+ animate: K,
1384
+ currentDecorator: l,
1385
+ prevDecorator: n
1386
+ }), S("end", e, 0);
1387
+ }
1388
+ })) {
1389
+ c?.setAttribute(Q, "true"), l?.setAttribute(Q, "true");
1390
+ for (let e of r.current) e.style.removeProperty("will-change");
1391
+ for (let e of r.prev) G(e), e.style.removeProperty("will-change");
1392
+ r = {
1393
+ current: [],
1394
+ prev: []
1395
+ };
1396
+ for (let e of i.prev) G(e);
1397
+ i = {
1398
+ current: [],
1399
+ prev: []
1400
+ }, e.back();
1401
+ } else c && G(c), t && G(t), l && G(l), n && G(n), b(), C(), e.setDragStatus("IDLE");
1402
+ };
1403
+ return {
1404
+ pointerDown: (t) => {
1405
+ e.isReadyForDrag() && (f = Y(t.target, {
1406
+ direction: "x",
1407
+ verifyByScroll: !0
1408
+ }), p = Y(t.target, {
1409
+ direction: "y",
1410
+ verifyByScroll: !0
1411
+ }), m = t.clientX, h = t.clientY, (!f.element && !p.element || f.element || p.element) && (a = !0));
1412
+ },
1413
+ pointerMove: (t) => {
1414
+ if (e.getViewportScrollHeight() > 10) return;
1415
+ if (s) {
1416
+ T(t);
1417
+ return;
1418
+ }
1419
+ let n = e.getTransition().swipeDirection, r = !f.element && !p.element;
1420
+ if (a && r) {
1421
+ a = !1, o = !0;
1422
+ let e = t.clientY - h, r = t.clientX - m;
1423
+ (n === "y" && e > 0 || n === "x" && r > 0) && w(t);
1424
+ } else if (a && !r) {
1425
+ let e = t.clientX - m, r = t.clientY - h, i = p.element && p.element.scrollTop <= 0, s = f.element && f.element.scrollLeft <= 0 && f.hasMarker;
1426
+ (n === "y" && (i || f.element) && r > 0 && Math.abs(e) < 2 || n === "x" && (s || p.element) && e > 0 && Math.abs(r) < 2) && (a = !1, o = !0, w(t));
1427
+ }
1428
+ },
1429
+ pointerUp: (e) => {
1430
+ a = !1, o = !1, s && ee(e);
1431
+ },
1432
+ shouldPreventTouch: () => o
1433
+ };
1434
+ }
1435
+ //#endregion
1436
+ //#region src/core/engine/barRiding.ts
1437
+ var $ = "data-flemo-bar-riding";
1438
+ function Ne(e) {
1439
+ let { appBar: t, navBar: n } = e;
1440
+ if (!t && !n) return () => {};
1441
+ let r = () => {
1442
+ let r = e.getStatus();
1443
+ if (!(r === "PUSHING" || r === "POPPING" || r === "REPLACING") || !e.isTopOrTopPrev) {
1444
+ t?.removeAttribute($), n?.removeAttribute($);
1445
+ return;
1446
+ }
1447
+ let i = e.getHistories(), a = e.isActive ? i[e.index - 1]?.id : i[e.index]?.id, o = a ? e.getSharedBars()[a] : void 0, s = e.hasAppBar && !o?.appBar, c = e.hasNavBar && !o?.navigationBar;
1448
+ t && t.setAttribute($, s ? "true" : "false"), n && n.setAttribute($, c ? "true" : "false");
1449
+ };
1450
+ r();
1451
+ let i = e.subscribeStatus(r), a = e.subscribeSharedBars(r);
1452
+ return () => {
1453
+ i(), a(), t?.removeAttribute($), n?.removeAttribute($);
1454
+ };
1455
+ }
1456
+ //#endregion
1457
+ export { q as SKIP_ANIMATION_ATTR, r as TaskManger, K as animateInline, V as animationName, De as applyTransitionStyles, Z as canProgrammaticallyScroll, G as clearInlineAnimation, F as collectAnimatedProperties, we as compileTransitionStyles, x as computeScreenFreeze, f as consumeSelfInducedPop, ie as createDecorator, i as createHistoryStore, p as createHistorySync, m as createNavigateStore, v as createNavigationController, ce as createPartTransition, ae as createRawDecorator, le as createRawPartTransition, C as createRawTransition, b as createScreenSelector, y as createScreenStore, Me as createSwipeController, S as createTransition, Ae as createTransitionEngine, re as createTransitionStore, T as cupertino, se as decoratorMap, Ne as driveBarRiding, R as easingToCss, l as ensureWindowHistoryState, Y as findScrollable, a as getMatchedPathPattern, o as getParams, c as isServer, te as layout, d as markSelfInducedPop, ne as material, E as none, X as overflowsAxis, oe as overlay, k as partTransitionMap, s as seedInitialHistory, I as targetToDecls, D as transitionMap, Te as variantHasAnimation };