@flemo/react 1.0.6 → 1.1.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.
package/dist/index.mjs CHANGED
@@ -1,34 +1,34 @@
1
- import { jsx as N, jsxs as Ht, Fragment as fe } from "react/jsx-runtime";
2
- import xt, { useEffect as ht, createContext as Gt, useContext as Yt, useReducer as me, Children as te, useInsertionEffect as ye, useRef as L, useImperativeHandle as he, useState as bt, useLayoutEffect as ft } from "react";
3
- import { consumeSelfInducedPop as ge, TaskManger as G, useNavigateStore as W, useHistoryStore as O, getMatchedPathPattern as we, transitionMap as ct, decoratorMap as yt, isServer as Mt, compileTransitionStyles as Se, useTransitionStore as Ot, getParams as ve, markSelfInducedPop as ee, targetToDecls as Te, easingToCss as Ee, variantHasAnimation as Pe, animationName as xe, findScrollable as qt, collectAnimatedProperties as be } from "@flemo/core";
4
- import { createDecorator as tn, createRawDecorator as en, createRawTransition as nn, createTransition as rn } from "@flemo/core";
5
- function Ie() {
6
- return ht(() => {
1
+ import { jsx as k, jsxs as Bt, Fragment as ye } from "react/jsx-runtime";
2
+ import xt, { useEffect as wt, createContext as _t, useContext as jt, useReducer as we, Children as oe, useInsertionEffect as ge, useRef as N, useImperativeHandle as Se, useState as bt, useLayoutEffect as mt } from "react";
3
+ import { consumeSelfInducedPop as ve, TaskManger as V, useNavigateStore as J, useHistoryStore as G, getMatchedPathPattern as Ee, transitionMap as ut, decoratorMap as yt, isServer as Ut, compileTransitionStyles as Pe, useTransitionStore as Yt, getParams as Te, markSelfInducedPop as Ft, targetToDecls as xe, easingToCss as be, variantHasAnimation as Ie, animationName as Re, findScrollable as Jt, collectAnimatedProperties as De } from "@flemo/core";
4
+ import { createDecorator as rn, createRawDecorator as on, createRawTransition as sn, createTransition as an } from "@flemo/core";
5
+ function Le() {
6
+ return wt(() => {
7
7
  const n = async (e) => {
8
- if (ge())
8
+ if (ve())
9
9
  return;
10
- const r = e.state?.id, a = G.generateTaskId();
11
- (await G.addTask(
12
- async (u) => {
13
- const i = e.state?.index, s = e.state?.status, T = e.state?.params, E = e.state?.transitionName, m = e.state?.layoutId, { setStatus: x, setTransitionTaskId: h } = W.getState(), { index: R, addHistory: $, popHistory: C } = O.getState(), D = i < R, q = s === "PUSHING" && i > R, M = s === "REPLACING" && i > R, Y = window.location.pathname;
14
- if (!D && !q && !M) {
15
- u.abort();
10
+ const r = e.state?.id, a = V.generateTaskId();
11
+ (await V.addTask(
12
+ async (c) => {
13
+ const i = e.state?.index, s = e.state?.status, w = e.state?.params, P = e.state?.transitionName, f = e.state?.layoutId, { setStatus: T, setTransitionTaskId: p } = J.getState(), { index: I, addHistory: L, popHistory: H } = G.getState(), R = i < I, U = s === "PUSHING" && i > I, C = s === "REPLACING" && i > I, A = window.location.pathname;
14
+ if (!R && !U && !C) {
15
+ c.abort();
16
16
  return;
17
17
  }
18
- return h(a), D ? x("POPPING") : q ? (x("PUSHING"), $({
18
+ return p(a), R ? T("POPPING") : U ? (T("PUSHING"), L({
19
19
  id: r,
20
- pathname: Y,
21
- params: T,
22
- transitionName: E,
23
- layoutId: m
24
- })) : M && (x("REPLACING"), $({
20
+ pathname: A,
21
+ params: w,
22
+ transitionName: P,
23
+ layoutId: f
24
+ })) : C && (T("REPLACING"), L({
25
25
  id: r,
26
- pathname: Y,
27
- params: T,
28
- transitionName: E,
29
- layoutId: m
26
+ pathname: A,
27
+ params: w,
28
+ transitionName: P,
29
+ layoutId: f
30
30
  })), async () => {
31
- D && C(i + 1), x("COMPLETED");
31
+ R && H(i + 1), T("COMPLETED");
32
32
  };
33
33
  },
34
34
  {
@@ -44,267 +44,267 @@ function Ie() {
44
44
  };
45
45
  }, []), null;
46
46
  }
47
- var j = {}, zt;
48
- function Re() {
49
- if (zt) return j;
50
- zt = 1, Object.defineProperty(j, "__esModule", { value: !0 }), j.PathError = j.TokenData = void 0, j.parse = m, j.compile = x, j.match = $, j.pathToRegexp = C, j.stringify = wt;
51
- const n = "/", e = (o) => o, r = /^[$_\p{ID_Start}]$/u, a = /^[$\u200c\u200d\p{ID_Continue}]$/u, u = /^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u;
47
+ var F = {}, Qt;
48
+ function Ne() {
49
+ if (Qt) return F;
50
+ Qt = 1, Object.defineProperty(F, "__esModule", { value: !0 }), F.PathError = F.TokenData = void 0, F.parse = f, F.compile = T, F.match = L, F.pathToRegexp = H, F.stringify = X;
51
+ const n = "/", e = (o) => o, r = /^[$_\p{ID_Start}]$/u, a = /^[$\u200c\u200d\p{ID_Continue}]$/u, c = /^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u;
52
52
  function i(o) {
53
53
  return o.replace(/[{}()\[\]+?!:*\\]/g, "\\$&");
54
54
  }
55
55
  function s(o) {
56
56
  return o.replace(/[.+*?^${}()[\]|/\\]/g, "\\$&");
57
57
  }
58
- class T {
59
- constructor(c, y) {
60
- this.tokens = c, this.originalPath = y;
58
+ class w {
59
+ constructor(u, y) {
60
+ this.tokens = u, this.originalPath = y;
61
61
  }
62
62
  }
63
- j.TokenData = T;
64
- class E extends TypeError {
65
- constructor(c, y) {
66
- let p = c;
67
- y && (p += `: ${y}`), p += "; visit https://git.new/pathToRegexpError for info", super(p), this.originalPath = y;
63
+ F.TokenData = w;
64
+ class P extends TypeError {
65
+ constructor(u, y) {
66
+ let l = u;
67
+ y && (l += `: ${y}`), l += "; visit https://git.new/pathToRegexpError for info", super(l), this.originalPath = y;
68
68
  }
69
69
  }
70
- j.PathError = E;
71
- function m(o, c = {}) {
72
- const { encodePath: y = e } = c, p = [...o];
73
- let l = 0;
74
- function g(d) {
75
- const P = [];
76
- let w = "";
77
- function I() {
78
- w && (P.push({
70
+ F.PathError = P;
71
+ function f(o, u = {}) {
72
+ const { encodePath: y = e } = u, l = [...o];
73
+ let d = 0;
74
+ function g(m) {
75
+ const x = [];
76
+ let S = "";
77
+ function D() {
78
+ S && (x.push({
79
79
  type: "text",
80
- value: y(w)
81
- }), w = "");
80
+ value: y(S)
81
+ }), S = "");
82
82
  }
83
- for (; l < p.length; ) {
84
- const b = p[l++];
85
- if (b === d)
86
- return I(), P;
83
+ for (; d < l.length; ) {
84
+ const b = l[d++];
85
+ if (b === m)
86
+ return D(), x;
87
87
  if (b === "\\") {
88
- if (l === p.length)
89
- throw new E(`Unexpected end after \\ at index ${l}`, o);
90
- w += p[l++];
88
+ if (d === l.length)
89
+ throw new P(`Unexpected end after \\ at index ${d}`, o);
90
+ S += l[d++];
91
91
  continue;
92
92
  }
93
93
  if (b === ":" || b === "*") {
94
- const U = b === ":" ? "param" : "wildcard";
95
- let S = "";
96
- if (r.test(p[l]))
94
+ const Y = b === ":" ? "param" : "wildcard";
95
+ let v = "";
96
+ if (r.test(l[d]))
97
97
  do
98
- S += p[l++];
99
- while (a.test(p[l]));
100
- else if (p[l] === '"') {
101
- let H = l;
102
- for (; l < p.length; ) {
103
- if (p[++l] === '"') {
104
- l++, H = 0;
98
+ v += l[d++];
99
+ while (a.test(l[d]));
100
+ else if (l[d] === '"') {
101
+ let B = d;
102
+ for (; d < l.length; ) {
103
+ if (l[++d] === '"') {
104
+ d++, B = 0;
105
105
  break;
106
106
  }
107
- p[l] === "\\" && l++, S += p[l];
107
+ l[d] === "\\" && d++, v += l[d];
108
108
  }
109
- if (H)
110
- throw new E(`Unterminated quote at index ${H}`, o);
109
+ if (B)
110
+ throw new P(`Unterminated quote at index ${B}`, o);
111
111
  }
112
- if (!S)
113
- throw new E(`Missing parameter name at index ${l}`, o);
114
- I(), P.push({ type: U, name: S });
112
+ if (!v)
113
+ throw new P(`Missing parameter name at index ${d}`, o);
114
+ D(), x.push({ type: Y, name: v });
115
115
  continue;
116
116
  }
117
117
  if (b === "{") {
118
- I(), P.push({
118
+ D(), x.push({
119
119
  type: "group",
120
120
  tokens: g("}")
121
121
  });
122
122
  continue;
123
123
  }
124
124
  if (b === "}" || b === "(" || b === ")" || b === "[" || b === "]" || b === "+" || b === "?" || b === "!")
125
- throw new E(`Unexpected ${b} at index ${l - 1}`, o);
126
- w += b;
125
+ throw new P(`Unexpected ${b} at index ${d - 1}`, o);
126
+ S += b;
127
127
  }
128
- if (d)
129
- throw new E(`Unexpected end at index ${l}, expected ${d}`, o);
130
- return I(), P;
128
+ if (m)
129
+ throw new P(`Unexpected end at index ${d}, expected ${m}`, o);
130
+ return D(), x;
131
131
  }
132
- return new T(g(""), o);
132
+ return new w(g(""), o);
133
133
  }
134
- function x(o, c = {}) {
135
- const { encode: y = encodeURIComponent, delimiter: p = n } = c, l = typeof o == "object" ? o : m(o, c), g = h(l.tokens, p, y);
136
- return function(P = {}) {
137
- const w = [], I = g(P, w);
138
- if (w.length)
139
- throw new TypeError(`Missing parameters: ${w.join(", ")}`);
140
- return I;
134
+ function T(o, u = {}) {
135
+ const { encode: y = encodeURIComponent, delimiter: l = n } = u, d = typeof o == "object" ? o : f(o, u), g = p(d.tokens, l, y);
136
+ return function(x = {}) {
137
+ const S = [], D = g(x, S);
138
+ if (S.length)
139
+ throw new TypeError(`Missing parameters: ${S.join(", ")}`);
140
+ return D;
141
141
  };
142
142
  }
143
- function h(o, c, y) {
144
- const p = o.map((l) => R(l, c, y));
145
- return (l, g) => {
146
- let d = "";
147
- for (const P of p)
148
- d += P(l, g);
149
- return d;
143
+ function p(o, u, y) {
144
+ const l = o.map((d) => I(d, u, y));
145
+ return (d, g) => {
146
+ let m = "";
147
+ for (const x of l)
148
+ m += x(d, g);
149
+ return m;
150
150
  };
151
151
  }
152
- function R(o, c, y) {
152
+ function I(o, u, y) {
153
153
  if (o.type === "text")
154
154
  return () => o.value;
155
155
  if (o.type === "group") {
156
- const l = h(o.tokens, c, y);
157
- return (g, d) => {
158
- const P = d.length, w = l(g, d);
159
- return d.length === P ? w : (d.length = P, "");
156
+ const d = p(o.tokens, u, y);
157
+ return (g, m) => {
158
+ const x = m.length, S = d(g, m);
159
+ return m.length === x ? S : (m.length = x, "");
160
160
  };
161
161
  }
162
- const p = y || e;
163
- return o.type === "wildcard" && y !== !1 ? (l, g) => {
164
- const d = l[o.name];
165
- if (d == null)
162
+ const l = y || e;
163
+ return o.type === "wildcard" && y !== !1 ? (d, g) => {
164
+ const m = d[o.name];
165
+ if (m == null)
166
166
  return g.push(o.name), "";
167
- if (!Array.isArray(d) || d.length === 0)
167
+ if (!Array.isArray(m) || m.length === 0)
168
168
  throw new TypeError(`Expected "${o.name}" to be a non-empty array`);
169
- let P = "";
170
- for (let w = 0; w < d.length; w++) {
171
- if (typeof d[w] != "string")
172
- throw new TypeError(`Expected "${o.name}/${w}" to be a string`);
173
- w > 0 && (P += c), P += p(d[w]);
169
+ let x = "";
170
+ for (let S = 0; S < m.length; S++) {
171
+ if (typeof m[S] != "string")
172
+ throw new TypeError(`Expected "${o.name}/${S}" to be a string`);
173
+ S > 0 && (x += u), x += l(m[S]);
174
174
  }
175
- return P;
176
- } : (l, g) => {
177
- const d = l[o.name];
178
- if (d == null)
175
+ return x;
176
+ } : (d, g) => {
177
+ const m = d[o.name];
178
+ if (m == null)
179
179
  return g.push(o.name), "";
180
- if (typeof d != "string")
180
+ if (typeof m != "string")
181
181
  throw new TypeError(`Expected "${o.name}" to be a string`);
182
- return p(d);
182
+ return l(m);
183
183
  };
184
184
  }
185
- function $(o, c = {}) {
186
- const { decode: y = decodeURIComponent, delimiter: p = n } = c, { regexp: l, keys: g } = C(o, c), d = g.map((P) => y === !1 ? e : P.type === "param" ? y : (w) => w.split(p).map(y));
187
- return function(w) {
188
- const I = l.exec(w);
189
- if (!I)
185
+ function L(o, u = {}) {
186
+ const { decode: y = decodeURIComponent, delimiter: l = n } = u, { regexp: d, keys: g } = H(o, u), m = g.map((x) => y === !1 ? e : x.type === "param" ? y : (S) => S.split(l).map(y));
187
+ return function(S) {
188
+ const D = d.exec(S);
189
+ if (!D)
190
190
  return !1;
191
- const b = I[0], U = /* @__PURE__ */ Object.create(null);
192
- for (let S = 1; S < I.length; S++) {
193
- if (I[S] === void 0)
191
+ const b = D[0], Y = /* @__PURE__ */ Object.create(null);
192
+ for (let v = 1; v < D.length; v++) {
193
+ if (D[v] === void 0)
194
194
  continue;
195
- const H = g[S - 1], _ = d[S - 1];
196
- U[H.name] = _(I[S]);
195
+ const B = g[v - 1], j = m[v - 1];
196
+ Y[B.name] = j(D[v]);
197
197
  }
198
- return { path: b, params: U };
198
+ return { path: b, params: Y };
199
199
  };
200
200
  }
201
- function C(o, c = {}) {
202
- const { delimiter: y = n, end: p = !0, sensitive: l = !1, trailing: g = !0 } = c, d = [];
203
- let P = "", w = 0;
204
- function I(U) {
205
- if (Array.isArray(U)) {
206
- for (const H of U)
207
- I(H);
201
+ function H(o, u = {}) {
202
+ const { delimiter: y = n, end: l = !0, sensitive: d = !1, trailing: g = !0 } = u, m = [];
203
+ let x = "", S = 0;
204
+ function D(Y) {
205
+ if (Array.isArray(Y)) {
206
+ for (const B of Y)
207
+ D(B);
208
208
  return;
209
209
  }
210
- const S = typeof U == "object" ? U : m(U, c);
211
- D(S.tokens, 0, [], (H) => {
212
- if (w >= 256)
213
- throw new E("Too many path combinations", S.originalPath);
214
- w > 0 && (P += "|"), P += q(H, y, d, S.originalPath), w++;
210
+ const v = typeof Y == "object" ? Y : f(Y, u);
211
+ R(v.tokens, 0, [], (B) => {
212
+ if (S >= 256)
213
+ throw new P("Too many path combinations", v.originalPath);
214
+ S > 0 && (x += "|"), x += U(B, y, m, v.originalPath), S++;
215
215
  });
216
216
  }
217
- I(o);
218
- let b = `^(?:${P})`;
219
- return g && (b += "(?:" + s(y) + "$)?"), b += p ? "$" : "(?=" + s(y) + "|$)", { regexp: new RegExp(b, l ? "" : "i"), keys: d };
217
+ D(o);
218
+ let b = `^(?:${x})`;
219
+ return g && (b += "(?:" + s(y) + "$)?"), b += l ? "$" : "(?=" + s(y) + "|$)", { regexp: new RegExp(b, d ? "" : "i"), keys: m };
220
220
  }
221
- function D(o, c, y, p) {
222
- for (; c < o.length; ) {
223
- const l = o[c++];
224
- if (l.type === "group") {
221
+ function R(o, u, y, l) {
222
+ for (; u < o.length; ) {
223
+ const d = o[u++];
224
+ if (d.type === "group") {
225
225
  const g = y.length;
226
- D(l.tokens, 0, y, (d) => D(o, c, d, p)), y.length = g;
226
+ R(d.tokens, 0, y, (m) => R(o, u, m, l)), y.length = g;
227
227
  continue;
228
228
  }
229
- y.push(l);
229
+ y.push(d);
230
230
  }
231
- p(y);
231
+ l(y);
232
232
  }
233
- function q(o, c, y, p) {
234
- let l = "", g = "", d = "", P = 0, w = 0, I = 0;
235
- function b(S, H) {
236
- for (; S < o.length; ) {
237
- const _ = o[S++];
238
- if (_.type === H)
233
+ function U(o, u, y, l) {
234
+ let d = "", g = "", m = "", x = 0, S = 0, D = 0;
235
+ function b(v, B) {
236
+ for (; v < o.length; ) {
237
+ const j = o[v++];
238
+ if (j.type === B)
239
239
  return !0;
240
- if (_.type === "text" && _.value.includes(c))
240
+ if (j.type === "text" && j.value.includes(u))
241
241
  break;
242
242
  }
243
243
  return !1;
244
244
  }
245
- function U(S) {
246
- let H = "";
247
- for (; S < o.length; ) {
248
- const _ = o[S++];
249
- if (_.type !== "text")
245
+ function Y(v) {
246
+ let B = "";
247
+ for (; v < o.length; ) {
248
+ const j = o[v++];
249
+ if (j.type !== "text")
250
250
  break;
251
- H += _.value;
251
+ B += j.value;
252
252
  }
253
- return H;
253
+ return B;
254
254
  }
255
- for (; I < o.length; ) {
256
- const S = o[I++];
257
- if (S.type === "text") {
258
- l += s(S.value), g += S.value, P === 2 && (d += S.value), S.value.includes(c) && (w = 0);
255
+ for (; D < o.length; ) {
256
+ const v = o[D++];
257
+ if (v.type === "text") {
258
+ d += s(v.value), g += v.value, x === 2 && (m += v.value), v.value.includes(u) && (S = 0);
259
259
  continue;
260
260
  }
261
- if (S.type === "param" || S.type === "wildcard") {
262
- if (P && !g)
263
- throw new E(`Missing text before "${S.name}" ${S.type}`, p);
264
- S.type === "param" ? (l += w & 2 ? `(${M(c, g)}+)` : b(I, "wildcard") ? `(${M(c, U(I))}+)` : w & 1 ? `(${M(c, g)}+|${s(g)})` : `(${M(c, "")}+)`, w |= P = 1) : (l += w & 2 ? `(${M(g, "")}+)` : d ? `(${M(d, "")}+|${M(c, "")}+)` : "([^]+)", d = "", w |= P = 2), y.push(S), g = "";
261
+ if (v.type === "param" || v.type === "wildcard") {
262
+ if (x && !g)
263
+ throw new P(`Missing text before "${v.name}" ${v.type}`, l);
264
+ v.type === "param" ? (d += S & 2 ? `(${C(u, g)}+)` : b(D, "wildcard") ? `(${C(u, Y(D))}+)` : S & 1 ? `(${C(u, g)}+|${s(g)})` : `(${C(u, "")}+)`, S |= x = 1) : (d += S & 2 ? `(${C(g, "")}+)` : m ? `(${C(m, "")}+|${C(u, "")}+)` : "([^]+)", m = "", S |= x = 2), y.push(v), g = "";
265
265
  continue;
266
266
  }
267
- throw new TypeError(`Unknown token type: ${S.type}`);
267
+ throw new TypeError(`Unknown token type: ${v.type}`);
268
268
  }
269
- return l;
269
+ return d;
270
270
  }
271
- function M(o, c) {
272
- return c.length > o.length ? M(c, o) : (o === c && (c = ""), c.length > 1 ? `(?:(?!${s(o)}|${s(c)})[^])` : o.length > 1 ? `(?:(?!${s(o)})[^${s(c)}])` : `[^${s(o + c)}]`);
271
+ function C(o, u) {
272
+ return u.length > o.length ? C(u, o) : (o === u && (u = ""), u.length > 1 ? `(?:(?!${s(o)}|${s(u)})[^])` : o.length > 1 ? `(?:(?!${s(o)})[^${s(u)}])` : `[^${s(o + u)}]`);
273
273
  }
274
- function Y(o, c) {
274
+ function A(o, u) {
275
275
  let y = "";
276
- for (; c < o.length; ) {
277
- const p = o[c++];
278
- if (p.type === "text") {
279
- y += i(p.value);
276
+ for (; u < o.length; ) {
277
+ const l = o[u++];
278
+ if (l.type === "text") {
279
+ y += i(l.value);
280
280
  continue;
281
281
  }
282
- if (p.type === "group") {
283
- y += "{" + Y(p.tokens, 0) + "}";
282
+ if (l.type === "group") {
283
+ y += "{" + A(l.tokens, 0) + "}";
284
284
  continue;
285
285
  }
286
- if (p.type === "param") {
287
- y += ":" + B(p.name, o[c]);
286
+ if (l.type === "param") {
287
+ y += ":" + O(l.name, o[u]);
288
288
  continue;
289
289
  }
290
- if (p.type === "wildcard") {
291
- y += "*" + B(p.name, o[c]);
290
+ if (l.type === "wildcard") {
291
+ y += "*" + O(l.name, o[u]);
292
292
  continue;
293
293
  }
294
- throw new TypeError(`Unknown token type: ${p.type}`);
294
+ throw new TypeError(`Unknown token type: ${l.type}`);
295
295
  }
296
296
  return y;
297
297
  }
298
- function wt(o) {
299
- return Y(o.tokens, 0);
298
+ function X(o) {
299
+ return A(o.tokens, 0);
300
300
  }
301
- function B(o, c) {
302
- return !u.test(o) || c?.type === "text" && a.test(c.value[0]) ? JSON.stringify(o) : o;
301
+ function O(o, u) {
302
+ return !c.test(o) || u?.type === "text" && a.test(u.value[0]) ? JSON.stringify(o) : o;
303
303
  }
304
- return j;
304
+ return F;
305
305
  }
306
- var Bt = Re();
307
- const ne = Gt({
306
+ var It = Ne();
307
+ const ie = _t({
308
308
  id: "",
309
309
  isActive: !1,
310
310
  isRoot: !0,
@@ -318,94 +318,94 @@ const ne = Gt({
318
318
  routePath: ""
319
319
  });
320
320
  function gt() {
321
- return Yt(ne);
321
+ return jt(ie);
322
322
  }
323
- const re = Gt({}), oe = Gt(() => {
323
+ const se = _t({}), ae = _t(() => {
324
324
  });
325
- function De(n, e) {
325
+ function ke(n, e) {
326
326
  return e.type === "SET" ? e.params : n;
327
327
  }
328
- function Le({ children: n }) {
329
- const { isActive: e, params: r } = gt(), [a, u] = me(De, r);
330
- return ht(() => {
328
+ function Ae({ children: n }) {
329
+ const { isActive: e, params: r } = gt(), [a, c] = we(ke, r);
330
+ return wt(() => {
331
331
  const i = async (s) => {
332
- s.state?.step && await G.addTask(async () => {
333
- u({ type: "SET", params: s.state?.params || {} });
332
+ s.state?.step && await V.addTask(async () => {
333
+ c({ type: "SET", params: s.state?.params || {} });
334
334
  });
335
335
  };
336
336
  return e && window.addEventListener("popstate", i), () => {
337
337
  window.removeEventListener("popstate", i);
338
338
  };
339
- }, [e, u]), /* @__PURE__ */ N(oe.Provider, { value: u, children: /* @__PURE__ */ N(re.Provider, { value: a, children: n }) });
339
+ }, [e, c]), /* @__PURE__ */ k(ae.Provider, { value: c, children: /* @__PURE__ */ k(se.Provider, { value: a, children: n }) });
340
340
  }
341
- function Ne({ children: n }) {
342
- const e = O((a) => a.index), r = O((a) => a.histories);
341
+ function $e({ children: n }) {
342
+ const e = G((a) => a.index), r = G((a) => a.histories);
343
343
  return r.map(
344
- (a) => te.toArray(n).filter(
345
- (u) => Bt.pathToRegexp(u.props.path).regexp.test(
344
+ (a) => oe.toArray(n).filter(
345
+ (c) => It.pathToRegexp(c.props.path).regexp.test(
346
346
  a.pathname
347
347
  )
348
348
  )
349
- ).map(([a], u) => /* @__PURE__ */ N(
350
- ne.Provider,
349
+ ).map(([a], c) => /* @__PURE__ */ k(
350
+ ie.Provider,
351
351
  {
352
352
  value: {
353
- id: r[u].id,
354
- isActive: u === e,
355
- isRoot: u === 0,
356
- isPrev: u < e - 1,
357
- zIndex: u,
358
- pathname: r[u].pathname,
359
- params: r[u].params,
353
+ id: r[c].id,
354
+ isActive: c === e,
355
+ isRoot: c === 0,
356
+ isPrev: c < e - 1,
357
+ zIndex: c,
358
+ pathname: r[c].pathname,
359
+ params: r[c].params,
360
360
  transitionName: r[e].transitionName,
361
361
  prevTransitionName: r[e - 1]?.transitionName,
362
- layoutId: r[u].layoutId,
363
- routePath: we(
362
+ layoutId: r[c].layoutId,
363
+ routePath: Ee(
364
364
  a.props.path,
365
- r[u].pathname
365
+ r[c].pathname
366
366
  )
367
367
  },
368
- children: /* @__PURE__ */ N(Le, { children: a })
368
+ children: /* @__PURE__ */ k(Ae, { children: a })
369
369
  },
370
- r[u].id
370
+ r[c].id
371
371
  ));
372
372
  }
373
- const Kt = "data-flemo", Wt = () => {
374
- if (Mt()) return;
375
- const n = Se(ct.values(), yt.values());
376
- let e = document.head.querySelector(`style[${Kt}]`);
377
- e || (e = document.createElement("style"), e.setAttribute(Kt, ""), document.head.appendChild(e)), e.textContent !== n && (e.textContent = n);
373
+ const Zt = "data-flemo", te = () => {
374
+ if (Ut()) return;
375
+ const n = Pe(ut.values(), yt.values());
376
+ let e = document.head.querySelector(`style[${Zt}]`);
377
+ e || (e = document.createElement("style"), e.setAttribute(Zt, ""), document.head.appendChild(e)), e.textContent !== n && (e.textContent = n);
378
378
  };
379
- function $e(n, e) {
380
- ye(() => {
381
- for (const r of n) ct.set(r.name, r);
379
+ function Ce(n, e) {
380
+ ge(() => {
381
+ for (const r of n) ut.set(r.name, r);
382
382
  for (const r of e) yt.set(r.name, r);
383
- return Wt(), () => {
384
- for (const r of n) ct.delete(r.name);
383
+ return te(), () => {
384
+ for (const r of n) ut.delete(r.name);
385
385
  for (const r of e) yt.delete(r.name);
386
- Wt();
386
+ te();
387
387
  };
388
388
  }, [n, e]);
389
389
  }
390
- const Ae = [], ke = [];
391
- function Fe({
390
+ const Me = [], He = [];
391
+ function Ke({
392
392
  children: n,
393
393
  initPath: e = "/",
394
394
  defaultTransitionName: r = "cupertino",
395
- transitions: a = Ae,
396
- decorators: u = ke
395
+ transitions: a = Me,
396
+ decorators: c = He
397
397
  }) {
398
- const i = Mt() ? e || "/" : window.location.pathname, s = Mt() ? i.split("?")[1] || "" : window.location.search;
399
- return Ot.setState({
398
+ const i = Ut() ? e || "/" : window.location.pathname, s = Ut() ? i.split("?")[1] || "" : window.location.search;
399
+ return Yt.setState({
400
400
  defaultTransitionName: r
401
- }), O.setState({
401
+ }), G.setState({
402
402
  index: 0,
403
403
  histories: [
404
404
  {
405
405
  id: "root",
406
406
  pathname: i,
407
- params: ve(
408
- te.toArray(n).map((T) => T.props.path).flat(),
407
+ params: Te(
408
+ oe.toArray(n).map((w) => w.props.path).flat(),
409
409
  i,
410
410
  s
411
411
  ),
@@ -413,7 +413,7 @@ function Fe({
413
413
  layoutId: null
414
414
  }
415
415
  ]
416
- }), $e(a, u), ht(() => {
416
+ }), Ce(a, c), wt(() => {
417
417
  window.history.state?.index || window.history.replaceState(
418
418
  {
419
419
  id: "root",
@@ -426,132 +426,203 @@ function Fe({
426
426
  "",
427
427
  window.location.href
428
428
  );
429
- }, [r]), /* @__PURE__ */ Ht(fe, { children: [
430
- /* @__PURE__ */ N(Ie, {}),
431
- /* @__PURE__ */ N(Ne, { children: n })
429
+ }, [r]), /* @__PURE__ */ Bt(ye, { children: [
430
+ /* @__PURE__ */ k(Le, {}),
431
+ /* @__PURE__ */ k($e, { children: n })
432
432
  ] });
433
433
  }
434
- function qe({ element: n }) {
434
+ function We({ element: n }) {
435
435
  return n;
436
436
  }
437
- function It(n, e) {
438
- const r = e ?? {}, a = Bt.compile(n), u = Object.fromEntries(
439
- Object.entries(r).map(([h, R]) => [h, String(R)])
440
- ), i = a(u), T = (typeof n == "string" ? Bt.parse(n) : n).tokens.filter((h) => h.type === "param").map((h) => h.name), E = Object.fromEntries(
441
- Object.entries(r).filter(([h]) => !T.includes(h))
442
- ), m = new URLSearchParams(E).toString();
443
- return { pathname: `${i}${m ? `?${m}` : ""}`, toPathname: i };
437
+ function Rt(n, e) {
438
+ const r = e ?? {}, a = It.compile(n), c = Object.fromEntries(
439
+ Object.entries(r).map(([p, I]) => [p, String(I)])
440
+ ), i = a(c), w = (typeof n == "string" ? It.parse(n) : n).tokens.filter((p) => p.type === "param").map((p) => p.name), P = Object.fromEntries(
441
+ Object.entries(r).filter(([p]) => !w.includes(p))
442
+ ), f = new URLSearchParams(P).toString();
443
+ return { pathname: `${i}${f ? `?${f}` : ""}`, toPathname: i };
444
444
  }
445
- function ze() {
446
- return {
447
- push: async (a, u, i) => {
448
- const { status: s } = W.getState();
449
- if (s !== "COMPLETED" && s !== "IDLE")
450
- return;
451
- const { index: T, addHistory: E } = O.getState(), m = Ot.getState().defaultTransitionName, { transitionName: x = m, layoutId: h = null } = i ?? {}, R = G.generateTaskId();
452
- (await G.addTask(
453
- async () => {
454
- const { setStatus: $, setTransitionTaskId: C } = W.getState();
455
- $("PUSHING"), C(R);
456
- const { pathname: D, toPathname: q } = It(a, u ?? {});
457
- return window.history.pushState(
445
+ const Mt = (n, e, r) => {
446
+ const { regexp: a } = It.pathToRegexp(n);
447
+ for (let c = e - 1; c >= 0; c--)
448
+ if (a.test(r[c].pathname))
449
+ return e - c;
450
+ return -1;
451
+ }, Ht = (n, e) => typeof n == "number" && Number.isFinite(n) ? Math.max(0, Math.trunc(n)) : e, Ot = async (n, e) => {
452
+ let r;
453
+ const a = new Promise((s) => {
454
+ r = () => s(!0), window.addEventListener("popstate", r, { once: !0 });
455
+ }), c = new Promise((s) => setTimeout(() => s(!1), 200));
456
+ if (Ft(), window.history.go(-n), !await Promise.race([a, c])) {
457
+ window.removeEventListener("popstate", r);
458
+ return;
459
+ }
460
+ e();
461
+ };
462
+ function Je() {
463
+ const n = async (c, i, s) => {
464
+ const { status: w } = J.getState();
465
+ if (w !== "COMPLETED" && w !== "IDLE")
466
+ return;
467
+ const P = Yt.getState().defaultTransitionName, { transitionName: f = P, layoutId: T = null } = s ?? {}, p = V.generateTaskId();
468
+ (await V.addTask(
469
+ async () => {
470
+ const { index: I, histories: L, addHistory: H, popHistories: R } = G.getState(), U = (() => {
471
+ if (s?.until != null) {
472
+ const u = Mt(s.until, I, L);
473
+ return u < 0 ? 0 : u;
474
+ }
475
+ return Math.min(Ht(s?.skip, 0), Math.max(0, I));
476
+ })(), { setStatus: C, setTransitionTaskId: A } = J.getState();
477
+ C("PUSHING"), A(p);
478
+ const { pathname: X, toPathname: O } = Rt(c, i ?? {}), o = {
479
+ id: p,
480
+ pathname: O,
481
+ params: i ?? {},
482
+ transitionName: f,
483
+ layoutId: T
484
+ };
485
+ return U === 0 ? (window.history.pushState(
486
+ { id: p, index: I + 1, status: "PUSHING", params: i, transitionName: f, layoutId: T },
487
+ "",
488
+ X
489
+ ), H(o), () => {
490
+ C("COMPLETED");
491
+ }) : (H(o), await Ot(U, () => {
492
+ window.history.pushState(
458
493
  {
459
- id: R,
460
- index: T + 1,
494
+ id: p,
495
+ index: G.getState().index - U,
461
496
  status: "PUSHING",
462
- params: u,
463
- transitionName: x,
464
- layoutId: h
497
+ params: i,
498
+ transitionName: f,
499
+ layoutId: T
465
500
  },
466
501
  "",
467
- D
468
- ), E({
469
- id: R,
470
- pathname: q,
471
- params: u ?? {},
472
- transitionName: x,
473
- layoutId: h
474
- }), () => {
475
- $("COMPLETED");
476
- };
477
- },
478
- {
479
- id: R,
480
- control: {
481
- manual: !0
502
+ X
503
+ );
504
+ }), async () => {
505
+ R(U), C("COMPLETED");
506
+ });
507
+ },
508
+ {
509
+ id: p,
510
+ control: {
511
+ manual: !0
512
+ }
513
+ }
514
+ )).result?.();
515
+ }, e = async (c, i, s) => {
516
+ const { status: w } = J.getState();
517
+ if (w !== "COMPLETED" && w !== "IDLE")
518
+ return;
519
+ const P = Yt.getState().defaultTransitionName, { transitionName: f = P, layoutId: T = null } = s ?? {}, p = V.generateTaskId();
520
+ (await V.addTask(
521
+ async (I) => {
522
+ const { index: L, histories: H, addHistory: R, replaceHistory: U, popHistories: C } = G.getState(), A = (() => {
523
+ if (s?.until != null) {
524
+ const l = Mt(s.until, L, H);
525
+ return l < 0 ? 0 : l + 1;
482
526
  }
527
+ return Math.min(Ht(s?.skip, 0) + 1, L + 1);
528
+ })();
529
+ if (A <= 0) {
530
+ I.abort();
531
+ return;
483
532
  }
484
- )).result?.();
485
- },
486
- replace: async (a, u, i) => {
487
- const { status: s } = W.getState();
488
- if (s !== "COMPLETED" && s !== "IDLE")
489
- return;
490
- const { index: T, addHistory: E } = O.getState(), m = O.getState().replaceHistory, x = Ot.getState().defaultTransitionName, { transitionName: h = x, layoutId: R = null } = i ?? {}, $ = G.generateTaskId();
491
- (await G.addTask(
492
- async () => {
493
- const { setStatus: C, setTransitionTaskId: D } = W.getState();
494
- C("REPLACING"), D($);
495
- const { pathname: q, toPathname: M } = It(a, u ?? {});
496
- return window.history.replaceState(
533
+ const { setStatus: X, setTransitionTaskId: O } = J.getState();
534
+ X("REPLACING"), O(p);
535
+ const { pathname: o, toPathname: u } = Rt(c, i ?? {}), y = {
536
+ id: p,
537
+ pathname: u,
538
+ params: i ?? {},
539
+ transitionName: f,
540
+ layoutId: T
541
+ };
542
+ return A === 1 ? (window.history.replaceState(
543
+ { id: p, index: L, status: "REPLACING", params: i, transitionName: f, layoutId: T },
544
+ "",
545
+ o
546
+ ), R(y), async () => {
547
+ U(L), X("COMPLETED");
548
+ }) : (C(A - 1), R(y), A <= L ? await Ot(A, () => {
549
+ window.history.pushState(
497
550
  {
498
- id: $,
499
- index: T,
551
+ id: p,
552
+ index: G.getState().index - 1,
500
553
  status: "REPLACING",
501
- params: u,
502
- transitionName: h,
503
- layoutId: R
554
+ params: i,
555
+ transitionName: f,
556
+ layoutId: T
504
557
  },
505
558
  "",
506
- q
507
- ), E({
508
- id: $,
509
- pathname: M,
510
- params: u ?? {},
511
- transitionName: h,
512
- layoutId: R
513
- }), async () => {
514
- m(T), C("COMPLETED");
515
- };
516
- },
517
- {
518
- id: $,
519
- control: {
520
- manual: !0
521
- }
559
+ o
560
+ );
561
+ }) : await Ot(L, () => {
562
+ window.history.replaceState(
563
+ { id: p, index: 0, status: "REPLACING", params: i, transitionName: f, layoutId: T },
564
+ "",
565
+ o
566
+ );
567
+ }), async () => {
568
+ U(G.getState().index - 1), X("COMPLETED");
569
+ });
570
+ },
571
+ {
572
+ id: p,
573
+ control: {
574
+ manual: !0
522
575
  }
523
- )).result?.();
524
- },
525
- pop: async () => {
526
- const a = G.generateTaskId();
527
- (await G.addTask(
528
- async (u) => {
529
- const { index: i, popHistory: s } = O.getState();
530
- if (i <= 0) {
531
- u.abort();
532
- return;
533
- }
534
- const { setStatus: T, setTransitionTaskId: E } = W.getState();
535
- return T("POPPING"), E(a), ee(), window.history.back(), async () => {
536
- s(i), T("COMPLETED");
537
- };
538
- },
539
- {
540
- id: a,
541
- control: {
542
- manual: !0
543
- }
576
+ }
577
+ )).result?.();
578
+ }, r = async (c) => {
579
+ const i = V.generateTaskId();
580
+ (await V.addTask(
581
+ async (s) => {
582
+ const { index: w, histories: P, popHistory: f, popHistories: T } = G.getState();
583
+ if (w <= 0) {
584
+ s.abort();
585
+ return;
544
586
  }
545
- )).result?.();
587
+ const p = Math.min(c(w, P), w);
588
+ if (p <= 0) {
589
+ s.abort();
590
+ return;
591
+ }
592
+ const { setStatus: I, setTransitionTaskId: L } = J.getState();
593
+ return I("POPPING"), L(i), T(p - 1), Ft(), p === 1 ? window.history.back() : window.history.go(-p), async () => {
594
+ f(G.getState().index), I("COMPLETED");
595
+ };
596
+ },
597
+ {
598
+ id: i,
599
+ control: {
600
+ manual: !0
601
+ }
602
+ }
603
+ )).result?.();
604
+ };
605
+ return {
606
+ push: n,
607
+ replace: e,
608
+ pop: async (c) => {
609
+ await r((i, s) => {
610
+ if (c?.until != null) {
611
+ const P = Mt(c.until, i, s);
612
+ return P < 0 ? 0 : P;
613
+ }
614
+ const w = Ht(c?.skip, 1);
615
+ return w <= 0 ? 0 : Math.min(w, i);
616
+ });
546
617
  }
547
618
  };
548
619
  }
549
- function Ke() {
550
- const { routePath: n } = gt(), e = Yt(oe);
620
+ function Qe() {
621
+ const { routePath: n } = gt(), e = jt(ae);
551
622
  return {
552
623
  pushStep: async (i) => {
553
- (await G.addTask(async () => {
554
- const { pathname: s } = It(n, i);
624
+ (await V.addTask(async () => {
625
+ const { pathname: s } = Rt(n, i);
555
626
  return window.history.state?.step || window.history.replaceState(
556
627
  {
557
628
  ...window.history.state,
@@ -571,8 +642,8 @@ function Ke() {
571
642
  })).result?.();
572
643
  },
573
644
  replaceStep: async (i) => {
574
- (await G.addTask(async () => {
575
- const { pathname: s } = It(n, i);
645
+ (await V.addTask(async () => {
646
+ const { pathname: s } = Rt(n, i);
576
647
  return window.history.replaceState(
577
648
  {
578
649
  ...window.history.state,
@@ -585,34 +656,34 @@ function Ke() {
585
656
  })).result?.();
586
657
  },
587
658
  popStep: async () => {
588
- const i = G.generateTaskId();
589
- (await G.addTask(
659
+ const i = V.generateTaskId();
660
+ (await V.addTask(
590
661
  async (s) => {
591
- const T = new Promise((C) => {
662
+ const w = new Promise((H) => {
592
663
  window.addEventListener(
593
664
  "popstate",
594
- (D) => C(D.state),
665
+ (R) => H(R.state),
595
666
  { once: !0 }
596
667
  );
597
- }), E = new Promise(
598
- (C) => setTimeout(() => C(void 0), 200)
668
+ }), P = new Promise(
669
+ (H) => setTimeout(() => H(void 0), 200)
599
670
  );
600
- ee(), window.history.back();
601
- const m = await Promise.race([
602
- T,
603
- E
671
+ Ft(), window.history.back();
672
+ const f = await Promise.race([
673
+ w,
674
+ P
604
675
  ]);
605
- if (!m) {
676
+ if (!f) {
606
677
  s.abort();
607
678
  return;
608
679
  }
609
- if (m.step) {
610
- e({ type: "SET", params: m.params ?? {} }), s.abort();
680
+ if (f.step) {
681
+ e({ type: "SET", params: f.params ?? {} }), s.abort();
611
682
  return;
612
683
  }
613
- const { setStatus: x, setTransitionTaskId: h } = W.getState(), { index: R, popHistory: $ } = O.getState();
614
- return x("POPPING"), h(i), async () => {
615
- $(R), x("COMPLETED");
684
+ const { setStatus: T, setTransitionTaskId: p } = J.getState(), { index: I, popHistory: L } = G.getState();
685
+ return T("POPPING"), p(i), async () => {
686
+ L(I), T("COMPLETED");
616
687
  };
617
688
  },
618
689
  {
@@ -625,12 +696,12 @@ function Ke() {
625
696
  }
626
697
  };
627
698
  }
628
- function We() {
629
- return Yt(re);
699
+ function Ze() {
700
+ return jt(se);
630
701
  }
631
- function Ce({ freeze: n, children: e }) {
632
- const r = L(e);
633
- return n || (r.current = e), /* @__PURE__ */ N(
702
+ function Oe({ freeze: n, children: e }) {
703
+ const r = N(e);
704
+ return n || (r.current = e), /* @__PURE__ */ k(
634
705
  "div",
635
706
  {
636
707
  style: {
@@ -640,16 +711,16 @@ function Ce({ freeze: n, children: e }) {
640
711
  }
641
712
  );
642
713
  }
643
- function He({ ref: n, style: e, ...r }) {
644
- const { isActive: a, transitionName: u } = gt(), i = L(null);
645
- he(n, () => i.current);
646
- const s = W((x) => x.status), T = ct.get(u) ?? ct.get("none"), { decoratorName: E } = T, m = yt.get(E);
647
- return m ? /* @__PURE__ */ N(
714
+ function Ge({ ref: n, style: e, ...r }) {
715
+ const { isActive: a, transitionName: c } = gt(), i = N(null);
716
+ Se(n, () => i.current);
717
+ const s = J((T) => T.status), w = ut.get(c) ?? ut.get("none"), { decoratorName: P } = w, f = yt.get(P);
718
+ return f ? /* @__PURE__ */ k(
648
719
  "div",
649
720
  {
650
721
  ref: i,
651
722
  "data-flemo-decorator": !0,
652
- "data-flemo-decorator-name": m.name,
723
+ "data-flemo-decorator-name": f.name,
653
724
  "data-flemo-status": s,
654
725
  "data-flemo-active": a ? "true" : "false",
655
726
  style: {
@@ -666,18 +737,18 @@ function He({ ref: n, style: e, ...r }) {
666
737
  }
667
738
  ) : null;
668
739
  }
669
- const Jt = (n) => {
740
+ const ee = (n) => {
670
741
  let e;
671
- const r = /* @__PURE__ */ new Set(), a = (m, x) => {
672
- const h = typeof m == "function" ? m(e) : m;
673
- if (!Object.is(h, e)) {
674
- const R = e;
675
- e = x ?? (typeof h != "object" || h === null) ? h : Object.assign({}, e, h), r.forEach(($) => $(e, R));
742
+ const r = /* @__PURE__ */ new Set(), a = (f, T) => {
743
+ const p = typeof f == "function" ? f(e) : f;
744
+ if (!Object.is(p, e)) {
745
+ const I = e;
746
+ e = T ?? (typeof p != "object" || p === null) ? p : Object.assign({}, e, p), r.forEach((L) => L(e, I));
676
747
  }
677
- }, u = () => e, T = { setState: a, getState: u, getInitialState: () => E, subscribe: (m) => (r.add(m), () => r.delete(m)) }, E = e = n(a, u, T);
678
- return T;
679
- }, Me = ((n) => n ? Jt(n) : Jt), Oe = (n) => n;
680
- function Be(n, e = Oe) {
748
+ }, c = () => e, w = { setState: a, getState: c, getInitialState: () => P, subscribe: (f) => (r.add(f), () => r.delete(f)) }, P = e = n(a, c, w);
749
+ return w;
750
+ }, Be = ((n) => n ? ee(n) : ee), Ue = (n) => n;
751
+ function Ye(n, e = Ue) {
681
752
  const r = xt.useSyncExternalStore(
682
753
  n.subscribe,
683
754
  xt.useCallback(() => e(n.getState()), [n, e]),
@@ -685,10 +756,10 @@ function Be(n, e = Oe) {
685
756
  );
686
757
  return xt.useDebugValue(r), r;
687
758
  }
688
- const Qt = (n) => {
689
- const e = Me(n), r = (a) => Be(e, a);
759
+ const ne = (n) => {
760
+ const e = Be(n), r = (a) => Ye(e, a);
690
761
  return Object.assign(r, e), r;
691
- }, Ue = ((n) => n ? Qt(n) : Qt), Q = Ue((n) => ({
762
+ }, Ve = ((n) => n ? ne(n) : ne), Z = Ve((n) => ({
692
763
  dragStatus: "IDLE",
693
764
  replaceTransitionStatus: "IDLE",
694
765
  sharedBars: {},
@@ -700,30 +771,30 @@ const Qt = (n) => {
700
771
  return delete a[e], { sharedBars: a };
701
772
  })
702
773
  }));
703
- let Ct = 0;
704
- function Ge() {
774
+ let Gt = 0;
775
+ function _e() {
705
776
  const [n, e] = bt(0), [r, a] = bt(0);
706
- return ht(() => {
707
- let u = 0;
777
+ return wt(() => {
778
+ let c = 0;
708
779
  const i = () => {
709
- cancelAnimationFrame(u), u = requestAnimationFrame(() => {
780
+ cancelAnimationFrame(c), c = requestAnimationFrame(() => {
710
781
  let s = document.documentElement.scrollHeight - (window.visualViewport?.height || 0);
711
782
  s = s < 0 ? 0 : s;
712
- let T = s - Ct;
713
- T = T < 0 ? 0 : T, Ct || (Ct = s), a(T), e(s);
783
+ let w = s - Gt;
784
+ w = w < 0 ? 0 : w, Gt || (Gt = s), a(w), e(s);
714
785
  });
715
786
  };
716
787
  return window.visualViewport?.addEventListener("resize", i), window.visualViewport?.addEventListener("scroll", i), () => {
717
- cancelAnimationFrame(u), window.visualViewport?.removeEventListener("resize", i), window.visualViewport?.removeEventListener("scroll", i);
788
+ cancelAnimationFrame(c), window.visualViewport?.removeEventListener("resize", i), window.visualViewport?.removeEventListener("scroll", i);
718
789
  };
719
790
  }, []), { viewportScrollHeight: n, changedViewportScrollHeight: r };
720
791
  }
721
- const Ye = (n) => typeof HTMLElement < "u" && n instanceof HTMLElement, Ut = /* @__PURE__ */ new WeakMap(), Zt = (n, e) => {
722
- let r = Ut.get(n);
723
- r || (r = /* @__PURE__ */ new Set(), Ut.set(n, r)), r.add(e);
724
- }, F = (n, e) => {
792
+ const je = (n) => typeof HTMLElement < "u" && n instanceof HTMLElement, Vt = /* @__PURE__ */ new WeakMap(), re = (n, e) => {
793
+ let r = Vt.get(n);
794
+ r || (r = /* @__PURE__ */ new Set(), Vt.set(n, r)), r.add(e);
795
+ }, z = (n, e) => {
725
796
  n.style.transition = "";
726
- const r = Ut.get(n);
797
+ const r = Vt.get(n);
727
798
  if (r && r.size > 0) {
728
799
  for (const a of r)
729
800
  n.style.removeProperty(a);
@@ -731,284 +802,284 @@ const Ye = (n) => typeof HTMLElement < "u" && n instanceof HTMLElement, Ut = /*
731
802
  return;
732
803
  }
733
804
  n.style.removeProperty("transform"), n.style.removeProperty("opacity");
734
- }, lt = (n, e, r = {}) => {
735
- if (!Ye(n)) return Promise.resolve();
736
- const a = n, u = Te(e);
737
- if (u.length === 0) return Promise.resolve();
738
- const i = typeof r.duration == "number" ? r.duration : 0, s = typeof r.delay == "number" && r.delay > 0 ? r.delay : 0, T = Ee(r.ease);
805
+ }, dt = (n, e, r = {}) => {
806
+ if (!je(n)) return Promise.resolve();
807
+ const a = n, c = xe(e);
808
+ if (c.length === 0) return Promise.resolve();
809
+ const i = typeof r.duration == "number" ? r.duration : 0, s = typeof r.delay == "number" && r.delay > 0 ? r.delay : 0, w = be(r.ease);
739
810
  if (i <= 0 && s <= 0) {
740
811
  a.style.transition = "none";
741
- for (const m of u)
742
- a.style.setProperty(m.property, m.value), Zt(a, m.property);
812
+ for (const f of c)
813
+ a.style.setProperty(f.property, f.value), re(a, f.property);
743
814
  return Promise.resolve();
744
815
  }
745
- const E = u.map((m) => `${m.property} ${i}s ${T} ${s}s`).join(", ");
746
- a.style.transition = E, a.offsetWidth;
747
- for (const m of u)
748
- a.style.setProperty(m.property, m.value), Zt(a, m.property);
749
- return new Promise((m) => {
750
- let x = !1;
751
- const h = () => {
752
- x || (x = !0, a.removeEventListener("transitionend", R), m());
753
- }, R = ($) => {
754
- $.target === a && h();
816
+ const P = c.map((f) => `${f.property} ${i}s ${w} ${s}s`).join(", ");
817
+ a.style.transition = P, a.offsetWidth;
818
+ for (const f of c)
819
+ a.style.setProperty(f.property, f.value), re(a, f.property);
820
+ return new Promise((f) => {
821
+ let T = !1;
822
+ const p = () => {
823
+ T || (T = !0, a.removeEventListener("transitionend", I), f());
824
+ }, I = (L) => {
825
+ L.target === a && p();
755
826
  };
756
- a.addEventListener("transitionend", R), setTimeout(h, (i + s) * 1e3 + 60);
827
+ a.addEventListener("transitionend", I), setTimeout(p, (i + s) * 1e3 + 60);
757
828
  });
758
- }, pt = W, mt = "data-flemo-skip-animation";
759
- function Ve({
829
+ }, pt = J, ht = "data-flemo-skip-animation";
830
+ function Fe({
760
831
  children: n,
761
832
  statusBarHeight: e,
762
833
  statusBarColor: r,
763
834
  systemNavigationBarHeight: a,
764
- systemNavigationBarColor: u,
835
+ systemNavigationBarColor: c,
765
836
  sharedAppBar: i,
766
837
  sharedNavigationBar: s,
767
- appBar: T,
768
- navigationBar: E,
769
- hideStatusBar: m,
770
- hideSystemNavigationBar: x,
771
- backgroundColor: h = "white",
772
- contentScrollable: R = !0,
773
- ...$
838
+ appBar: w,
839
+ navigationBar: P,
840
+ hideStatusBar: f,
841
+ hideSystemNavigationBar: T,
842
+ backgroundColor: p = "white",
843
+ contentScrollable: I = !0,
844
+ ...L
774
845
  }) {
775
- const { id: C, isActive: D, isRoot: q, zIndex: M, transitionName: Y, prevTransitionName: wt } = gt(), B = pt((t) => t.status), o = Q((t) => t.dragStatus), c = Q.getState().setDragStatus, y = Q.getState().setReplaceTransitionStatus, p = O((t) => t.index), l = ct.get(Y) ?? ct.get("none"), { initial: g, swipeDirection: d, decoratorName: P } = l, w = yt.get(P), { viewportScrollHeight: I } = Ge(), b = I > 0, [U, S] = bt(0), [H, _] = bt(0), Vt = L(null), V = L(null), Z = L(null), z = L(null), ut = L(null), J = L({
846
+ const { id: H, isActive: R, isRoot: U, zIndex: C, transitionName: A, prevTransitionName: X } = gt(), O = pt((t) => t.status), o = Z((t) => t.dragStatus), u = Z.getState().setDragStatus, y = Z.getState().setReplaceTransitionStatus, l = G((t) => t.index), d = ut.get(A) ?? ut.get("none"), { initial: g, swipeDirection: m, decoratorName: x } = d, S = yt.get(x), { viewportScrollHeight: D } = _e(), b = D > 0, [Y, v] = bt(0), [B, j] = bt(0), Xt = N(null), _ = N(null), tt = N(null), K = N(null), lt = N(null), Q = N({
776
847
  current: [],
777
848
  prev: []
778
- }), tt = L(!1), dt = L(!1), rt = L(!1), ae = L(0), Rt = L({ x: 0, y: 0 }), St = L({ x: 0, y: 0 }), Dt = L(0), Lt = L({ x: 0, y: 0 }), et = L({
849
+ }), et = N(!1), ft = N(!1), ot = N(!1), ce = N(0), Dt = N({ x: 0, y: 0 }), St = N({ x: 0, y: 0 }), Lt = N(0), Nt = N({ x: 0, y: 0 }), nt = N({
779
850
  element: null,
780
851
  hasMarker: !1
781
- }), ot = L({ element: null, hasMarker: !1 }), Nt = L(0), $t = L(0), at = L(null), it = L(null), At = (t) => {
782
- const f = St.current;
852
+ }), it = N({ element: null, hasMarker: !1 }), kt = N(0), At = N(0), st = N(null), at = N(null), $t = (t) => {
853
+ const h = St.current;
783
854
  return {
784
855
  point: { x: t.clientX, y: t.clientY },
785
856
  offset: {
786
- x: t.clientX - Rt.current.x,
787
- y: t.clientY - Rt.current.y
857
+ x: t.clientX - Dt.current.x,
858
+ y: t.clientY - Dt.current.y
788
859
  },
789
- delta: { x: t.clientX - f.x, y: t.clientY - f.y },
790
- velocity: Lt.current
860
+ delta: { x: t.clientX - h.x, y: t.clientY - h.y },
861
+ velocity: Nt.current
791
862
  };
792
- }, ie = (t) => {
793
- const f = t.timeStamp, v = Math.max(1, f - Dt.current), k = St.current;
794
- Lt.current = {
795
- x: (t.clientX - k.x) / v * 1e3,
796
- y: (t.clientY - k.y) / v * 1e3
797
- }, St.current = { x: t.clientX, y: t.clientY }, Dt.current = f;
798
- }, kt = (t, f, v) => {
799
- const k = lt(t, f, v);
800
- if (t === V.current)
801
- for (const A of J.current.current)
802
- lt(A, f, v);
803
- else if (t === Z.current)
804
- for (const A of J.current.prev)
805
- lt(A, f, v);
806
- return k;
807
- }, se = (t) => {
808
- const f = D ? O.getState().histories[p - 1]?.id : O.getState().histories[p]?.id, v = f ? Q.getState().sharedBars[f] : void 0, k = [], A = at.current, st = it.current;
809
- A && Tt && !v?.appBar && k.push(A), st && Et && !v?.navigationBar && k.push(st);
810
- const X = [];
863
+ }, ue = (t) => {
864
+ const h = t.timeStamp, E = Math.max(1, h - Lt.current), M = St.current;
865
+ Nt.current = {
866
+ x: (t.clientX - M.x) / E * 1e3,
867
+ y: (t.clientY - M.y) / E * 1e3
868
+ }, St.current = { x: t.clientX, y: t.clientY }, Lt.current = h;
869
+ }, Ct = (t, h, E) => {
870
+ const M = dt(t, h, E);
871
+ if (t === _.current)
872
+ for (const $ of Q.current.current)
873
+ dt($, h, E);
874
+ else if (t === tt.current)
875
+ for (const $ of Q.current.prev)
876
+ dt($, h, E);
877
+ return M;
878
+ }, le = (t) => {
879
+ const h = R ? G.getState().histories[l - 1]?.id : G.getState().histories[l]?.id, E = h ? Z.getState().sharedBars[h] : void 0, M = [], $ = st.current, ct = at.current;
880
+ $ && Et && !E?.appBar && M.push($), ct && Pt && !E?.navigationBar && M.push(ct);
881
+ const q = [];
811
882
  if (t) {
812
- const nt = t.querySelector('[data-flemo-bar="app"]'), Ft = t.querySelector('[data-flemo-bar="nav"]');
813
- nt && !Tt && X.push(nt), Ft && !Et && X.push(Ft);
883
+ const rt = t.querySelector('[data-flemo-bar="app"]'), Wt = t.querySelector('[data-flemo-bar="nav"]');
884
+ rt && !Et && q.push(rt), Wt && !Pt && q.push(Wt);
814
885
  }
815
- J.current = { current: k, prev: X };
816
- const Pt = be(l).join(", ");
817
- for (const nt of k) nt.style.willChange = Pt;
818
- for (const nt of X) nt.style.willChange = Pt;
819
- }, _t = () => {
820
- for (const t of J.current.current)
821
- F(t), t.style.removeProperty("will-change");
822
- for (const t of J.current.prev)
823
- F(t), t.style.removeProperty("will-change");
824
- J.current = { current: [], prev: [] };
886
+ Q.current = { current: M, prev: q };
887
+ const Tt = De(d).join(", ");
888
+ for (const rt of M) rt.style.willChange = Tt;
889
+ for (const rt of q) rt.style.willChange = Tt;
890
+ }, qt = () => {
891
+ for (const t of Q.current.current)
892
+ z(t), t.style.removeProperty("will-change");
893
+ for (const t of Q.current.prev)
894
+ z(t), t.style.removeProperty("will-change");
895
+ Q.current = { current: [], prev: [] };
825
896
  }, vt = async (t) => {
826
- if (!d || I > 10) return;
827
- const f = V.current;
828
- if (!f) return;
829
- const v = Vt.current?.parentElement?.previousElementSibling;
830
- if (Z.current = v?.querySelector("[data-flemo-screen]") ?? null, ut.current = v?.querySelector("[data-flemo-decorator]") ?? null, !Z.current) return;
831
- rt.current = !0, ae.current = t.timeStamp, Rt.current = { x: t.clientX, y: t.clientY }, St.current = { x: t.clientX, y: t.clientY }, Dt.current = t.timeStamp, Lt.current = { x: 0, y: 0 }, f.setPointerCapture(t.pointerId), se(v), await l?.onSwipeStart(t, At(t), {
832
- animate: kt,
833
- currentScreen: f,
834
- prevScreen: Z.current,
835
- onStart: (A) => w?.onSwipeStart?.(A, {
836
- animate: lt,
837
- currentDecorator: z.current,
838
- prevDecorator: ut.current
897
+ if (!m || D > 10) return;
898
+ const h = _.current;
899
+ if (!h) return;
900
+ const E = Xt.current?.parentElement?.previousElementSibling;
901
+ if (tt.current = E?.querySelector("[data-flemo-screen]") ?? null, lt.current = E?.querySelector("[data-flemo-decorator]") ?? null, !tt.current) return;
902
+ ot.current = !0, ce.current = t.timeStamp, Dt.current = { x: t.clientX, y: t.clientY }, St.current = { x: t.clientX, y: t.clientY }, Lt.current = t.timeStamp, Nt.current = { x: 0, y: 0 }, h.setPointerCapture(t.pointerId), le(E), await d?.onSwipeStart(t, $t(t), {
903
+ animate: Ct,
904
+ currentScreen: h,
905
+ prevScreen: tt.current,
906
+ onStart: ($) => S?.onSwipeStart?.($, {
907
+ animate: dt,
908
+ currentDecorator: K.current,
909
+ prevDecorator: lt.current
839
910
  })
840
- }) ? c("PENDING") : (c("IDLE"), rt.current = !1, _t());
841
- }, ce = (t) => {
842
- !d || !rt.current || I > 10 || (ie(t), l.onSwipe(t, At(t), {
843
- animate: kt,
844
- currentScreen: V.current,
845
- prevScreen: Z.current,
846
- onProgress: (f, v) => w?.onSwipe?.(f, v, {
847
- animate: lt,
848
- currentDecorator: z.current,
849
- prevDecorator: ut.current
911
+ }) ? u("PENDING") : (u("IDLE"), ot.current = !1, qt());
912
+ }, de = (t) => {
913
+ !m || !ot.current || D > 10 || (ue(t), d.onSwipe(t, $t(t), {
914
+ animate: Ct,
915
+ currentScreen: _.current,
916
+ prevScreen: tt.current,
917
+ onProgress: (h, E) => S?.onSwipe?.(h, E, {
918
+ animate: dt,
919
+ currentDecorator: K.current,
920
+ prevDecorator: lt.current
850
921
  })
851
922
  }));
852
- }, ue = async (t) => {
853
- if (!d || !rt.current) return;
854
- rt.current = !1;
855
- const f = V.current;
856
- f && f.hasPointerCapture(t.pointerId) && f.releasePointerCapture(t.pointerId);
857
- const v = At(t);
858
- if (await l?.onSwipeEnd(t, v, {
859
- animate: kt,
860
- currentScreen: V.current,
861
- prevScreen: Z.current,
862
- onStart: (A) => w?.onSwipeEnd?.(A, {
863
- animate: lt,
864
- currentDecorator: z.current,
865
- prevDecorator: ut.current
923
+ }, pe = async (t) => {
924
+ if (!m || !ot.current) return;
925
+ ot.current = !1;
926
+ const h = _.current;
927
+ h && h.hasPointerCapture(t.pointerId) && h.releasePointerCapture(t.pointerId);
928
+ const E = $t(t);
929
+ if (await d?.onSwipeEnd(t, E, {
930
+ animate: Ct,
931
+ currentScreen: _.current,
932
+ prevScreen: tt.current,
933
+ onStart: ($) => S?.onSwipeEnd?.($, {
934
+ animate: dt,
935
+ currentDecorator: K.current,
936
+ prevDecorator: lt.current
866
937
  })
867
938
  })) {
868
- V.current?.setAttribute(mt, "true"), z.current?.setAttribute(mt, "true");
869
- for (const A of J.current.current)
870
- A.style.removeProperty("will-change");
871
- for (const A of J.current.prev)
872
- F(A), A.style.removeProperty("will-change");
873
- J.current = { current: [], prev: [] }, window.history.back();
939
+ _.current?.setAttribute(ht, "true"), K.current?.setAttribute(ht, "true");
940
+ for (const $ of Q.current.current)
941
+ $.style.removeProperty("will-change");
942
+ for (const $ of Q.current.prev)
943
+ z($), $.style.removeProperty("will-change");
944
+ Q.current = { current: [], prev: [] }, window.history.back();
874
945
  } else
875
- F(V.current), Z.current && F(Z.current), z.current && F(z.current), ut.current && F(ut.current), _t(), c("IDLE");
876
- }, le = (t) => {
877
- if (!(!q && D && B === "COMPLETED" && o === "IDLE" && !!d && I < 10))
946
+ z(_.current), tt.current && z(tt.current), K.current && z(K.current), lt.current && z(lt.current), qt(), u("IDLE");
947
+ }, fe = (t) => {
948
+ if (!(!U && R && O === "COMPLETED" && o === "IDLE" && !!m && D < 10))
878
949
  return;
879
- et.current = qt(t.target, {
950
+ nt.current = Jt(t.target, {
880
951
  direction: "x",
881
952
  verifyByScroll: !0
882
- }), ot.current = qt(t.target, {
953
+ }), it.current = Jt(t.target, {
883
954
  direction: "y",
884
955
  verifyByScroll: !0
885
- }), Nt.current = t.clientX, $t.current = t.clientY, (!et.current.element && !ot.current.element || et.current.element || ot.current.element) && (tt.current = !0);
886
- }, pe = (t) => {
887
- if (I > 10)
956
+ }), kt.current = t.clientX, At.current = t.clientY, (!nt.current.element && !it.current.element || nt.current.element || it.current.element) && (et.current = !0);
957
+ }, me = (t) => {
958
+ if (D > 10)
888
959
  return;
889
- if (rt.current) {
890
- ce(t.nativeEvent);
960
+ if (ot.current) {
961
+ de(t.nativeEvent);
891
962
  return;
892
963
  }
893
- const f = !et.current.element && !ot.current.element;
894
- if (tt.current && f) {
895
- tt.current = !1, dt.current = !0;
896
- const v = t.clientY - $t.current, k = t.clientX - Nt.current;
897
- (d === "y" && v > 0 || d === "x" && k > 0) && vt(t.nativeEvent);
898
- } else if (tt.current && !f) {
899
- const v = t.clientX - Nt.current, k = t.clientY - $t.current, A = ot.current.element && ot.current.element.scrollTop <= 0, st = et.current.element && et.current.element.scrollLeft <= 0 && et.current.hasMarker;
900
- (d === "y" && (A || et.current.element) && k > 0 && Math.abs(v) < 2 || d === "x" && (st || ot.current.element) && v > 0 && Math.abs(k) < 2) && (tt.current = !1, dt.current = !0, vt(t.nativeEvent));
964
+ const h = !nt.current.element && !it.current.element;
965
+ if (et.current && h) {
966
+ et.current = !1, ft.current = !0;
967
+ const E = t.clientY - At.current, M = t.clientX - kt.current;
968
+ (m === "y" && E > 0 || m === "x" && M > 0) && vt(t.nativeEvent);
969
+ } else if (et.current && !h) {
970
+ const E = t.clientX - kt.current, M = t.clientY - At.current, $ = it.current.element && it.current.element.scrollTop <= 0, ct = nt.current.element && nt.current.element.scrollLeft <= 0 && nt.current.hasMarker;
971
+ (m === "y" && ($ || nt.current.element) && M > 0 && Math.abs(E) < 2 || m === "x" && (ct || it.current.element) && E > 0 && Math.abs(M) < 2) && (et.current = !1, ft.current = !0, vt(t.nativeEvent));
901
972
  }
902
- }, jt = (t) => {
903
- tt.current = !1, dt.current = !1, rt.current && ue(t.nativeEvent);
973
+ }, zt = (t) => {
974
+ et.current = !1, ft.current = !1, ot.current && pe(t.nativeEvent);
904
975
  };
905
- ht(() => {
906
- const t = V.current;
976
+ wt(() => {
977
+ const t = _.current;
907
978
  if (!t) return;
908
- const f = (v) => {
909
- dt.current && v.preventDefault(), v.target?.dataset.swipeAtEdgeBar === "true" && v.preventDefault();
979
+ const h = (E) => {
980
+ ft.current && E.preventDefault(), E.target?.dataset.swipeAtEdgeBar === "true" && E.preventDefault();
910
981
  };
911
- return t.addEventListener("touchmove", f, {
982
+ return t.addEventListener("touchmove", h, {
912
983
  passive: !1
913
984
  }), () => {
914
- t.removeEventListener("touchmove", f);
985
+ t.removeEventListener("touchmove", h);
915
986
  };
916
- }, []), ft(() => {
917
- if (!D) {
918
- B === "REPLACING" && wt !== Y && y("PENDING");
987
+ }, []), mt(() => {
988
+ if (!R) {
989
+ O === "REPLACING" && X !== A && y("PENDING");
919
990
  return;
920
991
  }
921
- if (B === "COMPLETED") {
922
- c("IDLE"), y("IDLE"), V.current && (F(V.current), V.current.removeAttribute(mt)), z.current && (F(z.current), z.current.removeAttribute(mt)), at.current && (F(at.current), at.current.style.removeProperty("will-change")), it.current && (F(it.current), it.current.style.removeProperty("will-change"));
992
+ if (O === "COMPLETED") {
993
+ u("IDLE"), y("IDLE"), _.current && (z(_.current), _.current.removeAttribute(ht)), K.current && (z(K.current), K.current.removeAttribute(ht)), st.current && (z(st.current), st.current.style.removeProperty("will-change")), at.current && (z(at.current), at.current.style.removeProperty("will-change"));
923
994
  return;
924
995
  }
925
- if (B === "IDLE") return;
926
- const t = V.current;
996
+ if (O === "IDLE") return;
997
+ const t = _.current;
927
998
  if (!t) return;
928
- const f = () => {
929
- const K = pt.getState().transitionTaskId;
930
- K && G.resolveTask(K);
931
- }, v = `${B}-true`;
932
- if (!(!(t.getAttribute(mt) === "true") && Pe(l, v))) {
933
- queueMicrotask(f);
999
+ const h = () => {
1000
+ const W = pt.getState().transitionTaskId;
1001
+ W && V.resolveTask(W);
1002
+ }, E = `${O}-true`;
1003
+ if (!(!(t.getAttribute(ht) === "true") && Ie(d, E))) {
1004
+ queueMicrotask(h);
934
1005
  return;
935
1006
  }
936
- const st = xe("screen", Y, v), X = (K) => {
937
- K.target === t && K.animationName === st && (t.removeEventListener("animationend", X), f());
1007
+ const ct = Re("screen", A, E), q = (W) => {
1008
+ W.target === t && W.animationName === ct && (t.removeEventListener("animationend", q), h());
938
1009
  };
939
- return t.addEventListener("animationend", X), () => {
940
- t.removeEventListener("animationend", X);
1010
+ return t.addEventListener("animationend", q), () => {
1011
+ t.removeEventListener("animationend", q);
941
1012
  };
942
1013
  }, [
943
- B,
944
- D,
945
- C,
946
- wt,
947
- Y,
948
- l,
949
- c,
1014
+ O,
1015
+ R,
1016
+ H,
1017
+ X,
1018
+ A,
1019
+ d,
1020
+ u,
950
1021
  y
951
- ]), ft(() => {
952
- const t = at.current;
1022
+ ]), mt(() => {
1023
+ const t = st.current;
953
1024
  if (!t) {
954
- S(0);
1025
+ v(0);
955
1026
  return;
956
1027
  }
957
- S(t.offsetHeight);
958
- const f = new ResizeObserver(([v]) => {
959
- S(v.contentRect.height);
1028
+ v(t.offsetHeight);
1029
+ const h = new ResizeObserver(([E]) => {
1030
+ v(E.contentRect.height);
960
1031
  });
961
- return f.observe(t), () => {
962
- f.disconnect();
1032
+ return h.observe(t), () => {
1033
+ h.disconnect();
963
1034
  };
964
- }, [i]), ft(() => {
965
- const t = it.current;
1035
+ }, [i]), mt(() => {
1036
+ const t = at.current;
966
1037
  if (!t) {
967
- _(0);
1038
+ j(0);
968
1039
  return;
969
1040
  }
970
- _(t.offsetHeight);
971
- const f = new ResizeObserver(([v]) => {
972
- _(v.contentRect.height);
1041
+ j(t.offsetHeight);
1042
+ const h = new ResizeObserver(([E]) => {
1043
+ j(E.contentRect.height);
973
1044
  });
974
- return f.observe(t), () => {
975
- f.disconnect();
1045
+ return h.observe(t), () => {
1046
+ h.disconnect();
976
1047
  };
977
- }, [s]), ft(() => {
978
- const { registerSharedBars: t, unregisterSharedBars: f } = Q.getState();
979
- return t(C, {
1048
+ }, [s]), mt(() => {
1049
+ const { registerSharedBars: t, unregisterSharedBars: h } = Z.getState();
1050
+ return t(H, {
980
1051
  appBar: !!i,
981
1052
  navigationBar: !!s
982
- }), () => f(C);
983
- }, [C, i, s]);
984
- const Xt = D || M === p - 1, Tt = !!i, Et = !!s;
985
- ft(() => {
986
- const t = at.current, f = it.current;
987
- if (!t && !f) return;
988
- const v = () => {
989
- if (!(pt.getState().status === "PUSHING" || pt.getState().status === "POPPING" || pt.getState().status === "REPLACING") || !Xt) {
990
- t?.removeAttribute("data-flemo-bar-riding"), f?.removeAttribute("data-flemo-bar-riding");
1053
+ }), () => h(H);
1054
+ }, [H, i, s]);
1055
+ const Kt = R || C === l - 1, Et = !!i, Pt = !!s;
1056
+ mt(() => {
1057
+ const t = st.current, h = at.current;
1058
+ if (!t && !h) return;
1059
+ const E = () => {
1060
+ if (!(pt.getState().status === "PUSHING" || pt.getState().status === "POPPING" || pt.getState().status === "REPLACING") || !Kt) {
1061
+ t?.removeAttribute("data-flemo-bar-riding"), h?.removeAttribute("data-flemo-bar-riding");
991
1062
  return;
992
1063
  }
993
- const X = D ? O.getState().histories[p - 1]?.id : O.getState().histories[p]?.id, K = X ? Q.getState().sharedBars[X] : void 0, Pt = Tt && !K?.appBar, nt = Et && !K?.navigationBar;
994
- t && t.setAttribute("data-flemo-bar-riding", Pt ? "true" : "false"), f && f.setAttribute("data-flemo-bar-riding", nt ? "true" : "false");
1064
+ const q = R ? G.getState().histories[l - 1]?.id : G.getState().histories[l]?.id, W = q ? Z.getState().sharedBars[q] : void 0, Tt = Et && !W?.appBar, rt = Pt && !W?.navigationBar;
1065
+ t && t.setAttribute("data-flemo-bar-riding", Tt ? "true" : "false"), h && h.setAttribute("data-flemo-bar-riding", rt ? "true" : "false");
995
1066
  };
996
- v();
997
- const k = Q.subscribe(v), A = pt.subscribe(v);
1067
+ E();
1068
+ const M = Z.subscribe(E), $ = pt.subscribe(E);
998
1069
  return () => {
999
- k(), A(), t?.removeAttribute("data-flemo-bar-riding"), f?.removeAttribute("data-flemo-bar-riding");
1070
+ M(), $(), t?.removeAttribute("data-flemo-bar-riding"), h?.removeAttribute("data-flemo-bar-riding");
1000
1071
  };
1001
- }, [Xt, D, p, Tt, Et]);
1002
- const de = (() => {
1003
- if (!D) return {};
1004
- if (B !== "PUSHING" && B !== "REPLACING") return {};
1072
+ }, [Kt, R, l, Et, Pt]);
1073
+ const he = (() => {
1074
+ if (!R) return {};
1075
+ if (O !== "PUSHING" && O !== "REPLACING") return {};
1005
1076
  const t = {};
1006
1077
  return typeof g.x == "number" && (t.transform = `translateX(${g.x}px)`), typeof g.x == "string" && (t.transform = `translateX(${g.x})`), typeof g.y == "number" && (t.transform = `translateY(${g.y}px)`), typeof g.y == "string" && (t.transform = `translateY(${g.y})`), typeof g.opacity == "number" && (t.opacity = `${g.opacity}`), t;
1007
1078
  })();
1008
- return /* @__PURE__ */ Ht(
1079
+ return /* @__PURE__ */ Bt(
1009
1080
  "div",
1010
1081
  {
1011
- ref: Vt,
1082
+ ref: Xt,
1012
1083
  style: {
1013
1084
  position: "fixed",
1014
1085
  top: 0,
@@ -1026,7 +1097,7 @@ function Ve({
1026
1097
  overscrollBehavior: "contain"
1027
1098
  },
1028
1099
  children: [
1029
- /* @__PURE__ */ N(
1100
+ /* @__PURE__ */ k(
1030
1101
  "div",
1031
1102
  {
1032
1103
  "data-swipe-at-edge-bar": !0,
@@ -1040,31 +1111,31 @@ function Ve({
1040
1111
  }
1041
1112
  }
1042
1113
  ),
1043
- /* @__PURE__ */ Ht(
1114
+ /* @__PURE__ */ Bt(
1044
1115
  "div",
1045
1116
  {
1046
- ref: V,
1047
- ...$,
1048
- onPointerDown: le,
1049
- onPointerMove: pe,
1050
- onPointerUp: jt,
1051
- onPointerCancel: jt,
1117
+ ref: _,
1118
+ ...L,
1119
+ onPointerDown: fe,
1120
+ onPointerMove: me,
1121
+ onPointerUp: zt,
1122
+ onPointerCancel: zt,
1052
1123
  "data-flemo-screen": !0,
1053
- "data-flemo-transition": Y,
1054
- "data-flemo-status": B,
1055
- "data-flemo-active": D ? "true" : "false",
1124
+ "data-flemo-transition": A,
1125
+ "data-flemo-status": O,
1126
+ "data-flemo-active": R ? "true" : "false",
1056
1127
  style: {
1057
1128
  display: "flex",
1058
1129
  flexDirection: "column",
1059
1130
  height: "100%",
1060
- backgroundColor: h,
1061
- overflowY: R ? void 0 : "auto",
1062
- touchAction: d === "x" ? "pan-y" : d === "y" ? "pan-x" : "auto",
1063
- ...de,
1064
- ...$.style
1131
+ backgroundColor: p,
1132
+ overflowY: I ? void 0 : "auto",
1133
+ touchAction: m === "x" ? "pan-y" : m === "y" ? "pan-x" : "auto",
1134
+ ...he,
1135
+ ...L.style
1065
1136
  },
1066
1137
  children: [
1067
- !m && e && /* @__PURE__ */ N("div", { style: { minHeight: e }, children: /* @__PURE__ */ N(
1138
+ !f && e && /* @__PURE__ */ k("div", { style: { minHeight: e }, children: /* @__PURE__ */ k(
1068
1139
  "div",
1069
1140
  {
1070
1141
  style: {
@@ -1076,47 +1147,47 @@ function Ve({
1076
1147
  }
1077
1148
  }
1078
1149
  ) }),
1079
- i && /* @__PURE__ */ N(
1150
+ i && /* @__PURE__ */ k(
1080
1151
  "div",
1081
1152
  {
1082
1153
  style: {
1083
1154
  width: "100%",
1084
- minHeight: U
1155
+ minHeight: Y
1085
1156
  }
1086
1157
  }
1087
1158
  ),
1088
- T,
1089
- /* @__PURE__ */ N(
1159
+ w,
1160
+ /* @__PURE__ */ k(
1090
1161
  "div",
1091
1162
  {
1092
1163
  style: {
1093
1164
  display: "flex",
1094
1165
  flexDirection: "column",
1095
1166
  flexGrow: 1,
1096
- overflowY: R ? "auto" : void 0
1167
+ overflowY: I ? "auto" : void 0
1097
1168
  },
1098
1169
  children: n
1099
1170
  }
1100
1171
  ),
1101
- E,
1102
- s && /* @__PURE__ */ N(
1172
+ P,
1173
+ s && /* @__PURE__ */ k(
1103
1174
  "div",
1104
1175
  {
1105
1176
  style: {
1106
1177
  display: b ? "none" : void 0,
1107
1178
  width: "100%",
1108
- minHeight: H
1179
+ minHeight: B
1109
1180
  }
1110
1181
  }
1111
1182
  ),
1112
- !x && a && /* @__PURE__ */ N(
1183
+ !T && a && /* @__PURE__ */ k(
1113
1184
  "div",
1114
1185
  {
1115
1186
  style: {
1116
1187
  display: b ? "none" : void 0,
1117
1188
  minHeight: a
1118
1189
  },
1119
- children: /* @__PURE__ */ N(
1190
+ children: /* @__PURE__ */ k(
1120
1191
  "div",
1121
1192
  {
1122
1193
  style: {
@@ -1124,7 +1195,7 @@ function Ve({
1124
1195
  bottom: 0,
1125
1196
  width: "100%",
1126
1197
  minHeight: a,
1127
- backgroundColor: u
1198
+ backgroundColor: c
1128
1199
  }
1129
1200
  }
1130
1201
  )
@@ -1133,17 +1204,17 @@ function Ve({
1133
1204
  ]
1134
1205
  }
1135
1206
  ),
1136
- i && /* @__PURE__ */ N(
1207
+ i && /* @__PURE__ */ k(
1137
1208
  "div",
1138
1209
  {
1139
- ref: at,
1210
+ ref: st,
1140
1211
  "data-flemo-bar": "app",
1141
- "data-flemo-bar-transition": Y,
1142
- "data-flemo-bar-status": B,
1143
- "data-flemo-bar-active": D ? "true" : "false",
1212
+ "data-flemo-bar-transition": A,
1213
+ "data-flemo-bar-status": O,
1214
+ "data-flemo-bar-active": R ? "true" : "false",
1144
1215
  style: {
1145
1216
  position: "fixed",
1146
- top: m ? 0 : e,
1217
+ top: f ? 0 : e,
1147
1218
  left: 0,
1148
1219
  width: "100%",
1149
1220
  zIndex: 1
@@ -1151,18 +1222,18 @@ function Ve({
1151
1222
  children: i
1152
1223
  }
1153
1224
  ),
1154
- s && /* @__PURE__ */ N(
1225
+ s && /* @__PURE__ */ k(
1155
1226
  "div",
1156
1227
  {
1157
- ref: it,
1228
+ ref: at,
1158
1229
  "data-flemo-bar": "nav",
1159
- "data-flemo-bar-transition": Y,
1160
- "data-flemo-bar-status": B,
1161
- "data-flemo-bar-active": D ? "true" : "false",
1230
+ "data-flemo-bar-transition": A,
1231
+ "data-flemo-bar-status": O,
1232
+ "data-flemo-bar-active": R ? "true" : "false",
1162
1233
  style: {
1163
1234
  display: b ? "none" : void 0,
1164
1235
  position: "fixed",
1165
- bottom: x ? 0 : a,
1236
+ bottom: T ? 0 : a,
1166
1237
  left: 0,
1167
1238
  width: "100%",
1168
1239
  zIndex: 1
@@ -1170,8 +1241,8 @@ function Ve({
1170
1241
  children: s
1171
1242
  }
1172
1243
  ),
1173
- w && /* @__PURE__ */ N(He, { ref: z }),
1174
- /* @__PURE__ */ N(
1244
+ S && /* @__PURE__ */ k(Ge, { ref: K }),
1245
+ /* @__PURE__ */ k(
1175
1246
  "div",
1176
1247
  {
1177
1248
  "data-swipe-at-edge-bar": !0,
@@ -1189,26 +1260,26 @@ function Ve({
1189
1260
  }
1190
1261
  );
1191
1262
  }
1192
- function Je({ children: n, ...e }) {
1193
- const { isActive: r, isPrev: a, zIndex: u } = gt(), i = O((h) => h.index), s = W((h) => h.status), T = Q((h) => h.dragStatus), E = Q((h) => h.replaceTransitionStatus), x = !r && (s === "COMPLETED" && T === "IDLE") || a && i - 2 <= u && E === "IDLE" || a && i - 2 > u;
1194
- return /* @__PURE__ */ N(Ce, { freeze: x, children: /* @__PURE__ */ N(Ve, { ...e, children: n }) });
1263
+ function tn({ children: n, ...e }) {
1264
+ const { isActive: r, isPrev: a, zIndex: c } = gt(), i = G((p) => p.index), s = J((p) => p.status), w = Z((p) => p.dragStatus), P = Z((p) => p.replaceTransitionStatus), T = !r && (s === "COMPLETED" && w === "IDLE") || a && i - 2 <= c && P === "IDLE" || a && i - 2 > c;
1265
+ return /* @__PURE__ */ k(Oe, { freeze: T, children: /* @__PURE__ */ k(Fe, { ...e, children: n }) });
1195
1266
  }
1196
1267
  export {
1197
- qe as Route,
1198
- Fe as Router,
1199
- Je as Screen,
1200
- ne as ScreenContext,
1201
- He as ScreenDecorator,
1202
- Ce as ScreenFreeze,
1203
- Ve as ScreenMotion,
1204
- tn as createDecorator,
1205
- en as createRawDecorator,
1206
- nn as createRawTransition,
1207
- rn as createTransition,
1208
- ze as useNavigate,
1209
- We as useParams,
1268
+ We as Route,
1269
+ Ke as Router,
1270
+ tn as Screen,
1271
+ ie as ScreenContext,
1272
+ Ge as ScreenDecorator,
1273
+ Oe as ScreenFreeze,
1274
+ Fe as ScreenMotion,
1275
+ rn as createDecorator,
1276
+ on as createRawDecorator,
1277
+ sn as createRawTransition,
1278
+ an as createTransition,
1279
+ Je as useNavigate,
1280
+ Ze as useParams,
1210
1281
  gt as useScreen,
1211
- Q as useScreenStore,
1212
- Ke as useStep,
1213
- Ge as useViewportScrollHeight
1282
+ Z as useScreenStore,
1283
+ Qe as useStep,
1284
+ _e as useViewportScrollHeight
1214
1285
  };