@sigx/lynx-navigation 0.2.0 → 0.4.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 (193) hide show
  1. package/README.md +128 -8
  2. package/dist/components/EntryScope.d.ts +1 -1
  3. package/dist/components/EntryScope.d.ts.map +1 -1
  4. package/dist/components/Layer.d.ts +34 -0
  5. package/dist/components/Layer.d.ts.map +1 -0
  6. package/dist/components/Link.d.ts +2 -2
  7. package/dist/components/Link.d.ts.map +1 -1
  8. package/dist/components/NavigationRoot.d.ts +2 -2
  9. package/dist/components/NavigationRoot.d.ts.map +1 -1
  10. package/dist/components/Screen.d.ts +6 -6
  11. package/dist/components/Screen.d.ts.map +1 -1
  12. package/dist/components/Stack.d.ts +41 -16
  13. package/dist/components/Stack.d.ts.map +1 -1
  14. package/dist/components/TabBar.d.ts +19 -20
  15. package/dist/components/TabBar.d.ts.map +1 -1
  16. package/dist/components/Tabs.d.ts.map +1 -1
  17. package/dist/define-routes.d.ts +1 -1
  18. package/dist/define-routes.d.ts.map +1 -1
  19. package/dist/hooks/use-linking-nav.d.ts +3 -3
  20. package/dist/hooks/use-linking-nav.d.ts.map +1 -1
  21. package/dist/hooks/use-nav-internal.d.ts +21 -3
  22. package/dist/hooks/use-nav-internal.d.ts.map +1 -1
  23. package/dist/hooks/use-nav-serializer.d.ts +1 -1
  24. package/dist/hooks/use-nav-serializer.d.ts.map +1 -1
  25. package/dist/hooks/use-nav.d.ts +2 -2
  26. package/dist/hooks/use-nav.d.ts.map +1 -1
  27. package/dist/hooks/use-params.d.ts +1 -1
  28. package/dist/hooks/use-params.d.ts.map +1 -1
  29. package/dist/hooks/use-screen-chrome.d.ts +19 -0
  30. package/dist/hooks/use-screen-chrome.d.ts.map +1 -0
  31. package/dist/hooks/use-screen-options.d.ts +1 -1
  32. package/dist/hooks/use-screen-options.d.ts.map +1 -1
  33. package/dist/hooks/use-search.d.ts +1 -1
  34. package/dist/hooks/use-search.d.ts.map +1 -1
  35. package/dist/href.d.ts +2 -2
  36. package/dist/href.d.ts.map +1 -1
  37. package/dist/index.d.ts +33 -31
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +1160 -29
  40. package/dist/index.js.map +1 -1
  41. package/dist/internal/layer-plan.d.ts +69 -0
  42. package/dist/internal/layer-plan.d.ts.map +1 -0
  43. package/dist/internal/screen-registry.d.ts +1 -1
  44. package/dist/internal/screen-registry.d.ts.map +1 -1
  45. package/dist/internal/screen-width.d.ts +9 -7
  46. package/dist/internal/screen-width.d.ts.map +1 -1
  47. package/dist/navigator/core.d.ts +5 -4
  48. package/dist/navigator/core.d.ts.map +1 -1
  49. package/dist/register.d.ts +1 -1
  50. package/dist/register.d.ts.map +1 -1
  51. package/dist/url/index.d.ts +6 -6
  52. package/dist/url/index.d.ts.map +1 -1
  53. package/dist/url/parse.d.ts +1 -1
  54. package/dist/url/parse.d.ts.map +1 -1
  55. package/dist/url/registry.d.ts +2 -2
  56. package/dist/url/registry.d.ts.map +1 -1
  57. package/dist/url/validate.d.ts +1 -1
  58. package/dist/url/validate.d.ts.map +1 -1
  59. package/package.json +11 -10
  60. package/src/components/Drawer.d.ts +55 -0
  61. package/src/components/EdgeBackHandle.d.ts +1 -0
  62. package/src/components/EdgeBackHandle.tsx +2 -2
  63. package/{dist/components/EntryScope.js → src/components/EntryScope.d.ts} +7 -15
  64. package/src/components/EntryScope.tsx +15 -4
  65. package/src/components/Header.d.ts +6 -0
  66. package/src/components/Header.tsx +3 -3
  67. package/src/components/Layer.d.ts +33 -0
  68. package/src/components/Layer.tsx +96 -0
  69. package/src/components/Link.d.ts +60 -0
  70. package/src/components/Link.tsx +4 -4
  71. package/src/components/NavigationRoot.d.ts +36 -0
  72. package/src/components/NavigationRoot.tsx +6 -6
  73. package/src/components/Screen.d.ts +97 -0
  74. package/src/components/Screen.tsx +13 -11
  75. package/src/components/Stack.d.ts +90 -0
  76. package/src/components/Stack.tsx +142 -98
  77. package/src/components/TabBar.d.ts +38 -0
  78. package/src/components/TabBar.tsx +22 -22
  79. package/src/components/Tabs.d.ts +109 -0
  80. package/src/components/Tabs.tsx +15 -1
  81. package/{dist/define-routes.js → src/define-routes.d.ts} +2 -4
  82. package/src/define-routes.ts +1 -1
  83. package/src/hooks/use-focus.d.ts +45 -0
  84. package/src/hooks/use-focus.ts +2 -2
  85. package/src/hooks/use-hardware-back.d.ts +37 -0
  86. package/src/hooks/use-hardware-back.ts +1 -1
  87. package/src/hooks/use-linking-nav.d.ts +91 -0
  88. package/src/hooks/use-linking-nav.ts +4 -4
  89. package/src/hooks/use-nav-internal.d.ts +91 -0
  90. package/src/hooks/use-nav-internal.ts +24 -3
  91. package/src/hooks/use-nav-serializer.d.ts +82 -0
  92. package/src/hooks/use-nav-serializer.ts +3 -3
  93. package/src/hooks/use-nav.d.ts +111 -0
  94. package/src/hooks/use-nav.ts +2 -2
  95. package/{dist/hooks/use-params.js → src/hooks/use-params.d.ts} +2 -6
  96. package/src/hooks/use-params.ts +2 -2
  97. package/src/hooks/use-screen-chrome.d.ts +18 -0
  98. package/src/hooks/use-screen-chrome.ts +122 -0
  99. package/src/hooks/use-screen-options.d.ts +2 -0
  100. package/src/hooks/use-screen-options.ts +3 -3
  101. package/{dist/hooks/use-search.js → src/hooks/use-search.d.ts} +2 -6
  102. package/src/hooks/use-search.ts +2 -2
  103. package/src/href.d.ts +54 -0
  104. package/src/href.ts +6 -6
  105. package/src/index.d.ts +39 -0
  106. package/src/index.ts +33 -31
  107. package/src/internal/layer-plan.d.ts +68 -0
  108. package/src/internal/layer-plan.ts +187 -0
  109. package/{dist/internal/screen-registry.js → src/internal/screen-registry.d.ts} +21 -32
  110. package/src/internal/screen-registry.ts +1 -1
  111. package/src/internal/screen-width.d.ts +17 -0
  112. package/src/internal/screen-width.ts +22 -14
  113. package/src/navigator/core.d.ts +96 -0
  114. package/src/navigator/core.ts +17 -6
  115. package/src/register.d.ts +37 -0
  116. package/src/register.ts +1 -1
  117. package/src/types.d.ts +217 -0
  118. package/src/url/build.d.ts +15 -0
  119. package/src/url/build.ts +2 -2
  120. package/src/url/compile.d.ts +34 -0
  121. package/src/url/format.d.ts +28 -0
  122. package/src/url/index.ts +6 -6
  123. package/src/url/parse.d.ts +20 -0
  124. package/src/url/parse.ts +6 -6
  125. package/{dist/url/registry.js → src/url/registry.d.ts} +12 -28
  126. package/src/url/registry.ts +3 -3
  127. package/src/url/validate.d.ts +23 -0
  128. package/src/url/validate.ts +1 -1
  129. package/dist/components/Drawer.js +0 -74
  130. package/dist/components/Drawer.js.map +0 -1
  131. package/dist/components/EdgeBackHandle.js +0 -144
  132. package/dist/components/EdgeBackHandle.js.map +0 -1
  133. package/dist/components/EntryScope.js.map +0 -1
  134. package/dist/components/Header.js +0 -103
  135. package/dist/components/Header.js.map +0 -1
  136. package/dist/components/Link.js +0 -51
  137. package/dist/components/Link.js.map +0 -1
  138. package/dist/components/NavigationRoot.js +0 -67
  139. package/dist/components/NavigationRoot.js.map +0 -1
  140. package/dist/components/Screen.js +0 -94
  141. package/dist/components/Screen.js.map +0 -1
  142. package/dist/components/ScreenContainer.d.ts +0 -18
  143. package/dist/components/ScreenContainer.d.ts.map +0 -1
  144. package/dist/components/ScreenContainer.js +0 -77
  145. package/dist/components/ScreenContainer.js.map +0 -1
  146. package/dist/components/Stack.js +0 -221
  147. package/dist/components/Stack.js.map +0 -1
  148. package/dist/components/TabBar.js +0 -63
  149. package/dist/components/TabBar.js.map +0 -1
  150. package/dist/components/Tabs.js +0 -154
  151. package/dist/components/Tabs.js.map +0 -1
  152. package/dist/define-routes.js.map +0 -1
  153. package/dist/hooks/use-focus.js +0 -87
  154. package/dist/hooks/use-focus.js.map +0 -1
  155. package/dist/hooks/use-hardware-back.js +0 -84
  156. package/dist/hooks/use-hardware-back.js.map +0 -1
  157. package/dist/hooks/use-linking-nav.js +0 -109
  158. package/dist/hooks/use-linking-nav.js.map +0 -1
  159. package/dist/hooks/use-nav-internal.js +0 -44
  160. package/dist/hooks/use-nav-internal.js.map +0 -1
  161. package/dist/hooks/use-nav-serializer.js +0 -181
  162. package/dist/hooks/use-nav-serializer.js.map +0 -1
  163. package/dist/hooks/use-nav.js +0 -11
  164. package/dist/hooks/use-nav.js.map +0 -1
  165. package/dist/hooks/use-params.js.map +0 -1
  166. package/dist/hooks/use-screen-options.js +0 -43
  167. package/dist/hooks/use-screen-options.js.map +0 -1
  168. package/dist/hooks/use-search.js.map +0 -1
  169. package/dist/href.js +0 -57
  170. package/dist/href.js.map +0 -1
  171. package/dist/internal/screen-registry.js.map +0 -1
  172. package/dist/internal/screen-width.js +0 -30
  173. package/dist/internal/screen-width.js.map +0 -1
  174. package/dist/navigator/core.js +0 -383
  175. package/dist/navigator/core.js.map +0 -1
  176. package/dist/register.js +0 -2
  177. package/dist/register.js.map +0 -1
  178. package/dist/types.js +0 -9
  179. package/dist/types.js.map +0 -1
  180. package/dist/url/build.js +0 -30
  181. package/dist/url/build.js.map +0 -1
  182. package/dist/url/compile.js +0 -83
  183. package/dist/url/compile.js.map +0 -1
  184. package/dist/url/format.js +0 -102
  185. package/dist/url/format.js.map +0 -1
  186. package/dist/url/index.js +0 -13
  187. package/dist/url/index.js.map +0 -1
  188. package/dist/url/parse.js +0 -94
  189. package/dist/url/parse.js.map +0 -1
  190. package/dist/url/registry.js.map +0 -1
  191. package/dist/url/validate.js +0 -37
  192. package/dist/url/validate.js.map +0 -1
  193. package/src/components/ScreenContainer.tsx +0 -114
package/dist/index.js CHANGED
@@ -1,30 +1,1161 @@
1
- /**
2
- * @sigx/lynx-navigation — type-first native stack router.
3
- *
4
- * Phase 0.1 (current): typed registry, stack runtime, NavigationRoot + Stack.
5
- * Coming next: Screen with slot-based header API, MTS transitions, Tabs.
6
- */
7
- export { defineRoutes } from './define-routes.js';
8
- export { useNav } from './hooks/use-nav.js';
9
- export { useParams } from './hooks/use-params.js';
10
- export { useSearch } from './hooks/use-search.js';
11
- export { useHardwareBack } from './hooks/use-hardware-back.js';
12
- export { useLinkingNav } from './hooks/use-linking-nav.js';
13
- export { useIsFocused, useFocusEffect } from './hooks/use-focus.js';
14
- export { useScreenOptions } from './hooks/use-screen-options.js';
15
- export { useNavSerializer, NAV_SNAPSHOT_VERSION, } from './hooks/use-nav-serializer.js';
16
- export { hrefFor, parseHref } from './href.js';
17
- // URL bridge internals: `_setRouteRegistry` is a leading-underscore export —
18
- // intended for tests, deep-link bootstrap before a NavigationRoot mounts, and
19
- // any other integration that needs to seed the registry imperatively.
20
- export { _setRouteRegistry, _clearRouteRegistry } from './url/registry.js';
21
- export { compilePath } from './url/compile.js';
22
- export { NavigationRoot } from './components/NavigationRoot.js';
23
- export { Stack } from './components/Stack.js';
24
- export { Screen } from './components/Screen.js';
25
- export { Header } from './components/Header.js';
26
- export { Tabs, useTabs } from './components/Tabs.js';
27
- export { TabBar } from './components/TabBar.js';
28
- export { Drawer, useDrawer } from './components/Drawer.js';
29
- export { Link } from './components/Link.js';
1
+ import { Gesture as e, Suspense as t, component as n, compound as r, computed as i, defineInjectable as a, defineProvide as o, effect as s, isLazyComponent as c, onMounted as l, onUnmounted as u, runOnBackground as d, runOnMainThread as f, signal as p, untrack as m, useAnimatedStyle as h, useGestureDetector as g, useMainThreadRef as _, useSharedValue as v } from "@sigx/lynx";
2
+ import { BackHandler as y, Linking as b, parse as ee } from "@sigx/lynx-linking";
3
+ import { withTiming as x } from "@sigx/lynx-motion";
4
+ import { jsx as S, jsxs as C } from "@sigx/lynx/jsx-runtime";
5
+ //#region src/define-routes.ts
6
+ function w(e) {
7
+ return e;
8
+ }
9
+ //#endregion
10
+ //#region src/hooks/use-nav.ts
11
+ var T = a(() => {
12
+ throw Error("[lynx-navigation] useNav() called but no <NavigationRoot> is mounted in the component tree.");
13
+ });
14
+ //#endregion
15
+ //#region src/hooks/use-params.ts
16
+ function E(e) {
17
+ return T().current.params;
18
+ }
19
+ //#endregion
20
+ //#region src/hooks/use-search.ts
21
+ function te(e) {
22
+ return T().current.search;
23
+ }
24
+ //#endregion
25
+ //#region src/hooks/use-hardware-back.ts
26
+ function ne() {
27
+ let e = T();
28
+ l(() => {
29
+ let t = y.addEventListener(() => {
30
+ let t = e;
31
+ outer: for (; t._children.size > 0;) {
32
+ for (let e of t._children) if (e.isLocallyFocused) {
33
+ t = e;
34
+ continue outer;
35
+ }
36
+ break;
37
+ }
38
+ let n = t;
39
+ for (; n;) {
40
+ if (n.canGoBack) return n.pop(), !0;
41
+ n = n.parent;
42
+ }
43
+ return y.exitApp(), !0;
44
+ });
45
+ return () => t.remove();
46
+ });
47
+ }
48
+ //#endregion
49
+ //#region src/url/format.ts
50
+ function re(e) {
51
+ if (!e) return "";
52
+ let t = Object.keys(e).sort(), n = [];
53
+ for (let r of t) {
54
+ let t = e[r];
55
+ if (t == null) continue;
56
+ let i = encodeURIComponent(r);
57
+ if (Array.isArray(t)) for (let e of t) e != null && n.push(`${i}=${encodeURIComponent(ae(e))}`);
58
+ else n.push(`${i}=${encodeURIComponent(ae(t))}`);
59
+ }
60
+ return n.join("&");
61
+ }
62
+ function ie(e) {
63
+ let t = {};
64
+ if (!e) return t;
65
+ let n = e.startsWith("?") ? e.slice(1) : e;
66
+ if (!n) return t;
67
+ for (let e of n.split("&")) {
68
+ if (!e) continue;
69
+ let n = e.indexOf("="), r = n === -1 ? e : e.slice(0, n), i = n === -1 ? "" : e.slice(n + 1), a = oe(r), o = oe(i), s = t[a];
70
+ s === void 0 ? t[a] = o : Array.isArray(s) ? s.push(o) : t[a] = [s, o];
71
+ }
72
+ return t;
73
+ }
74
+ function ae(e) {
75
+ switch (typeof e) {
76
+ case "string": return e;
77
+ case "number":
78
+ case "boolean":
79
+ case "bigint": return String(e);
80
+ default: return JSON.stringify(e);
81
+ }
82
+ }
83
+ function oe(e) {
84
+ try {
85
+ return decodeURIComponent(e.replace(/\+/g, " "));
86
+ } catch {
87
+ return e;
88
+ }
89
+ }
90
+ //#endregion
91
+ //#region src/url/compile.ts
92
+ var D = /:([A-Za-z_][A-Za-z0-9_]*)/g;
93
+ function O(e) {
94
+ if (typeof e != "string") throw TypeError(`compilePath: expected string, got ${typeof e}`);
95
+ if (e.length === 0) throw Error("compilePath: path template must not be empty");
96
+ let t = e.startsWith("/") ? e : `/${e}`, n = [], r = 0, i = "";
97
+ D.lastIndex = 0;
98
+ for (let a = D.exec(t); a !== null; a = D.exec(t)) {
99
+ let o = a[1];
100
+ if (n.includes(o)) throw Error(`compilePath: duplicate param name ':${o}' in '${e}'`);
101
+ n.push(o), i += k(t.slice(r, a.index)), i += "([^/]+)", r = a.index + a[0].length;
102
+ }
103
+ i += k(t.slice(r));
104
+ let a = i.endsWith("/") ? i.slice(0, -1) : i;
105
+ return {
106
+ source: e,
107
+ paramNames: n,
108
+ regex: RegExp(`^${a}/?$`),
109
+ format(n) {
110
+ let r = "", i = 0;
111
+ D.lastIndex = 0;
112
+ for (let a = D.exec(t); a !== null; a = D.exec(t)) {
113
+ let o = a[1], s = n[o];
114
+ if (s == null) throw Error(`compilePath.format: missing required param ':${o}' for '${e}'`);
115
+ r += t.slice(i, a.index), r += encodeURIComponent(String(s)), i = a.index + a[0].length;
116
+ }
117
+ return r += t.slice(i), r;
118
+ }
119
+ };
120
+ }
121
+ var se = /[.*+?^${}()|[\]\\]/g;
122
+ function k(e) {
123
+ return e.replace(se, "\\$&");
124
+ }
125
+ //#endregion
126
+ //#region src/url/registry.ts
127
+ var A = null;
128
+ function j(e) {
129
+ A = {
130
+ routes: e,
131
+ compiled: /* @__PURE__ */ new Map()
132
+ };
133
+ }
134
+ function ce() {
135
+ A = null;
136
+ }
137
+ function M() {
138
+ if (!A) throw Error("[lynx-navigation] No route registry set — render a <NavigationRoot> first, or call _setRouteRegistry() for tests.");
139
+ return A;
140
+ }
141
+ function le(e, t) {
142
+ let n = e.routes[t];
143
+ if (!n || !n.path) return null;
144
+ let r = e.compiled.get(t);
145
+ return r || (r = O(n.path), e.compiled.set(t, r)), r;
146
+ }
147
+ //#endregion
148
+ //#region src/url/build.ts
149
+ function ue(e, t, n) {
150
+ let r = le(M(), e);
151
+ if (!r) return null;
152
+ let i = r.format(t ?? {}), a = re(n);
153
+ return a.length > 0 ? `${i}?${a}` : i;
154
+ }
155
+ //#endregion
156
+ //#region src/url/validate.ts
157
+ function N(e, t) {
158
+ if (!e) return {
159
+ ok: !0,
160
+ value: t
161
+ };
162
+ let n = e["~standard"]?.validate;
163
+ if (!n) return {
164
+ ok: !0,
165
+ value: t
166
+ };
167
+ let r = n(t);
168
+ if (de(r)) throw Error("[lynx-navigation] Async schema validation is not supported on the URL bridge — use a sync validator (Zod/Valibot/ArkType are all sync).");
169
+ return r.issues !== void 0 && r.issues.length > 0 ? {
170
+ ok: !1,
171
+ issues: r.issues.map((e) => e.message)
172
+ } : {
173
+ ok: !0,
174
+ value: r.value
175
+ };
176
+ }
177
+ function de(e) {
178
+ return typeof e == "object" && !!e && typeof e.then == "function";
179
+ }
180
+ //#endregion
181
+ //#region src/url/parse.ts
182
+ function fe(e) {
183
+ if (typeof e != "string" || e.length === 0) return null;
184
+ let { pathname: t, query: n } = me(e);
185
+ if (!t) return null;
186
+ let r = M(), i = ie(n);
187
+ for (let n of Object.keys(r.routes)) {
188
+ let a = le(r, n);
189
+ if (!a) continue;
190
+ let o = a.regex.exec(t);
191
+ if (!o) continue;
192
+ let s = pe(a, o), c = r.routes[n], l = N(c.params, s);
193
+ if (!l.ok) continue;
194
+ let u = N(c.search, i);
195
+ if (u.ok) return {
196
+ route: n,
197
+ params: l.value,
198
+ search: u.value,
199
+ url: e
200
+ };
201
+ }
202
+ return null;
203
+ }
204
+ function pe(e, t) {
205
+ let n = {};
206
+ for (let r = 0; r < e.paramNames.length; r++) {
207
+ let i = t[r + 1];
208
+ try {
209
+ n[e.paramNames[r]] = decodeURIComponent(i);
210
+ } catch {
211
+ n[e.paramNames[r]] = i;
212
+ }
213
+ }
214
+ return n;
215
+ }
216
+ function me(e) {
217
+ let t = e.indexOf("#"), n = t >= 0 ? e.slice(0, t) : e;
218
+ if (/^[a-zA-Z][a-zA-Z0-9+.\-]*:/.test(n)) {
219
+ let e = ee(n), t = n.indexOf("?"), r = t >= 0 ? n.slice(t + 1) : "";
220
+ return {
221
+ pathname: e.path,
222
+ query: r
223
+ };
224
+ }
225
+ let r = n.indexOf("?");
226
+ return r === -1 ? {
227
+ pathname: n,
228
+ query: ""
229
+ } : {
230
+ pathname: n.slice(0, r),
231
+ query: n.slice(r + 1)
232
+ };
233
+ }
234
+ //#endregion
235
+ //#region src/href.ts
236
+ function he(e, ...t) {
237
+ let n = M().routes[e];
238
+ if (!n) throw Error(`[lynx-navigation] hrefFor('${e}'): route is not in the active registry.`);
239
+ let r = !!n.params, i, a;
240
+ r ? (i = t[0], a = t[1]) : (i = void 0, a = t[0]);
241
+ let o = N(n.params, i ?? {});
242
+ if (!o.ok) throw Error(`[lynx-navigation] hrefFor('${e}'): params validation failed — ${o.issues.join("; ")}`);
243
+ let s = N(n.search, a ?? {});
244
+ if (!s.ok) throw Error(`[lynx-navigation] hrefFor('${e}'): search validation failed — ${s.issues.join("; ")}`);
245
+ let c = o.value, l = s.value;
246
+ return {
247
+ route: e,
248
+ params: c,
249
+ search: l,
250
+ url: ue(e, c, l)
251
+ };
252
+ }
253
+ function ge(e) {
254
+ return fe(e);
255
+ }
256
+ //#endregion
257
+ //#region src/hooks/use-nav-internal.ts
258
+ var P = a(() => {
259
+ throw Error("[lynx-navigation] No screen entry in scope. `useIsFocused` / `useFocusEffect` must be called from a component rendered as a route by <Stack>.");
260
+ }), _e = a(() => null), F = a(() => {
261
+ throw Error("[lynx-navigation] No <NavigationRoot> found in the component tree.");
262
+ }), I = a(() => {
263
+ throw Error("[lynx-navigation] No <NavigationRoot> found in the component tree.");
264
+ }), L = a(() => {
265
+ throw Error("[lynx-navigation] No screen registry in scope. `<Screen>` (and `<Screen.Header>`, etc.) must be used inside a route component rendered by `<Stack>`.");
266
+ });
267
+ //#endregion
268
+ //#region src/hooks/use-linking-nav.ts
269
+ function ve(e = {}) {
270
+ let t = T(), n = F(), r = (r, i) => {
271
+ if (e.onURL) {
272
+ e.onURL(r, t);
273
+ return;
274
+ }
275
+ let a = ge(ye(r, e.prefixes));
276
+ if (!a) {
277
+ e.onUnmatched?.(r);
278
+ return;
279
+ }
280
+ be(t, n, a, i);
281
+ };
282
+ l(() => {
283
+ let t = b.getInitialURL();
284
+ t && r(t, e.replaceInitial === !1 ? "push" : "replace");
285
+ let n = b.addEventListener("url", (e) => r(e.url, "push"));
286
+ return () => n.remove();
287
+ });
288
+ }
289
+ function ye(e, t) {
290
+ if (!t || t.length === 0) return e;
291
+ for (let n of t) if (e.startsWith(n)) {
292
+ let t = e.slice(n.length);
293
+ return t.startsWith("/") ? t : `/${t}`;
294
+ }
295
+ return e;
296
+ }
297
+ function be(e, t, n, r) {
298
+ let i = t[n.route];
299
+ if (!i) return;
300
+ let a = !!i.params, o = r === "replace" ? e.replace : e.push;
301
+ a ? o(n.route, n.params, n.search) : o(n.route, n.search);
302
+ }
303
+ //#endregion
304
+ //#region src/hooks/use-focus.ts
305
+ function R() {
306
+ let e = T(), t = P().key;
307
+ return i(() => e.current.key === t && e.isLocallyFocused);
308
+ }
309
+ function xe(e) {
310
+ let t = R(), n, r = s(() => {
311
+ let r = t.value;
312
+ if (typeof n == "function") {
313
+ let e = n;
314
+ n = void 0, e();
315
+ }
316
+ r && (n = m(() => e()));
317
+ });
318
+ u(() => {
319
+ if (typeof n == "function") {
320
+ let e = n;
321
+ n = void 0, e();
322
+ }
323
+ r.stop();
324
+ });
325
+ }
326
+ //#endregion
327
+ //#region src/internal/screen-registry.ts
328
+ function Se(e) {
329
+ return {
330
+ entry: e,
331
+ options: p({}),
332
+ slots: p({})
333
+ };
334
+ }
335
+ function z(e, t, n) {
336
+ if (n === void 0) {
337
+ delete e.slots[t];
338
+ return;
339
+ }
340
+ e.slots[t] = n;
341
+ }
342
+ function B(e, t) {
343
+ for (let n of Object.keys(t)) {
344
+ let r = t[n];
345
+ r === void 0 ? delete e.options[n] : e.options[n] = r;
346
+ }
347
+ }
348
+ //#endregion
349
+ //#region src/hooks/use-screen-options.ts
350
+ function Ce(e) {
351
+ let t = L();
352
+ if (typeof e != "function") {
353
+ B(t, e);
354
+ return;
355
+ }
356
+ let n = s(() => {
357
+ B(t, e());
358
+ });
359
+ u(() => n.stop());
360
+ }
361
+ //#endregion
362
+ //#region src/hooks/use-screen-chrome.ts
363
+ function we() {
364
+ let e = T(), t = I(), n = _e(), r = () => {
365
+ let t = e.transition;
366
+ return t ? t.kind === "pop" ? t.underneathEntry : t.topEntry : e.current;
367
+ }, i = () => n && e.stack.some((e) => e.key === n.key) ? n : r();
368
+ return {
369
+ get title() {
370
+ let e = i(), n = t.screens.get(e.key)?.options.title;
371
+ return typeof n == "function" ? n() : typeof n == "string" ? n : e.route;
372
+ },
373
+ get headerShown() {
374
+ return t.screens.get(i().key)?.options.headerShown !== !1;
375
+ },
376
+ get canGoBack() {
377
+ let t = i();
378
+ return e.stack.findIndex((e) => e.key === t.key) > 0;
379
+ },
380
+ pop() {
381
+ e.pop();
382
+ },
383
+ get header() {
384
+ return t.screens.get(i().key)?.slots.header;
385
+ },
386
+ get headerLeft() {
387
+ return t.screens.get(i().key)?.slots.headerLeft;
388
+ },
389
+ get headerRight() {
390
+ return t.screens.get(i().key)?.slots.headerRight;
391
+ }
392
+ };
393
+ }
394
+ //#endregion
395
+ //#region src/hooks/use-nav-serializer.ts
396
+ var Te = 1;
397
+ function Ee(e) {
398
+ let t = T(), n = F(), r = e.debounceMs ?? 250, i = e.onRestored, a = e.onRestoreError, o = !0, c = null, d = null;
399
+ l(() => {
400
+ Promise.resolve().then(() => e.storage.load()).then((e) => {
401
+ if (o) {
402
+ if (e == null) {
403
+ f();
404
+ return;
405
+ }
406
+ if (!De(e)) {
407
+ a?.("shape"), f();
408
+ return;
409
+ }
410
+ if (e.version !== 1) {
411
+ a?.("version"), f();
412
+ return;
413
+ }
414
+ for (let t of e.stack) if (!n[t.route]) {
415
+ a?.("unknown-route"), f();
416
+ return;
417
+ }
418
+ if (e.stack.length === 0) {
419
+ a?.("shape"), f();
420
+ return;
421
+ }
422
+ t.reset({ stack: e.stack }), i?.(e), f();
423
+ }
424
+ }).catch((e) => {
425
+ o && (a?.("load-threw", e), f());
426
+ });
427
+ });
428
+ function f() {
429
+ if (!o || d) return;
430
+ let e = !0, n = s(() => {
431
+ let n = {
432
+ version: 1,
433
+ stack: t.stack.map((e) => ({
434
+ key: e.key,
435
+ route: e.route,
436
+ params: e.params,
437
+ search: e.search,
438
+ state: e.state,
439
+ presentation: e.presentation
440
+ }))
441
+ };
442
+ if (e) {
443
+ e = !1;
444
+ return;
445
+ }
446
+ p(n);
447
+ });
448
+ d = () => n.stop();
449
+ }
450
+ function p(t) {
451
+ c != null && clearTimeout(c), c = setTimeout(() => {
452
+ c = null;
453
+ try {
454
+ let n = e.storage.save(t);
455
+ n && typeof n.catch == "function" && n.catch(() => {});
456
+ } catch {}
457
+ }, r);
458
+ }
459
+ u(() => {
460
+ o = !1, c != null && (clearTimeout(c), c = null), d &&= (d(), null);
461
+ });
462
+ }
463
+ function De(e) {
464
+ if (!e || typeof e != "object") return !1;
465
+ let t = e;
466
+ if (typeof t.version != "number" || !Array.isArray(t.stack)) return !1;
467
+ for (let e of t.stack) {
468
+ if (!e || typeof e != "object") return !1;
469
+ let t = e;
470
+ if (typeof t.key != "string" || typeof t.route != "string" || typeof t.presentation != "string") return !1;
471
+ }
472
+ return !0;
473
+ }
474
+ //#endregion
475
+ //#region src/navigator/core.ts
476
+ var V = .28;
477
+ function H(e) {
478
+ c(e) && e.preload().catch(() => {});
479
+ }
480
+ var U = 0;
481
+ function Oe() {
482
+ return U += 1, `entry-${U}-${Math.random().toString(36).slice(2, 8)}`;
483
+ }
484
+ function W(e, t, n, r, i) {
485
+ let a = i[e], o = r?.presentation ?? a?.presentation ?? "card";
486
+ return {
487
+ key: Oe(),
488
+ route: e,
489
+ params: t ?? {},
490
+ search: n ?? {},
491
+ state: r?.state,
492
+ presentation: o
493
+ };
494
+ }
495
+ function G(e, t, n) {
496
+ if (n[e]?.params) {
497
+ let [e, n, r] = t;
498
+ return {
499
+ params: e,
500
+ search: n,
501
+ options: r
502
+ };
503
+ }
504
+ let [r, i] = t;
505
+ return {
506
+ params: void 0,
507
+ search: r,
508
+ options: i
509
+ };
510
+ }
511
+ function K(e) {
512
+ let { routes: t, initial: n, progress: r, parent: i = null } = e, a = p([n]), o = p({ value: e.initialLocallyFocused ?? !0 }), s = /* @__PURE__ */ new Set(), c = p({ value: null });
513
+ function l() {
514
+ return a;
515
+ }
516
+ function u(e) {
517
+ a.$set(e);
518
+ }
519
+ function d(e) {
520
+ c.value = e;
521
+ }
522
+ function m() {
523
+ return c.value !== null;
524
+ }
525
+ async function h(e, t) {
526
+ if (!r) return;
527
+ let n = r;
528
+ f((e, t) => {
529
+ "main thread";
530
+ n.current.value = 0, x(n, e, { duration: t });
531
+ })(e, t), await new Promise((e) => {
532
+ setTimeout(e, Math.round(t * 1e3));
533
+ });
534
+ }
535
+ let g = ((e, ...n) => {
536
+ if (!t[e]) throw Error(`[lynx-navigation] push('${e}'): route is not registered. Known routes: ${Object.keys(t).join(", ") || "(none)"}`);
537
+ let { params: a, search: o, options: s } = G(e, n, t);
538
+ if ((s?.presentation ?? t[e].presentation ?? "card") !== "card" && i) {
539
+ i.push(e, ...n);
540
+ return;
541
+ }
542
+ if (m()) return;
543
+ H(t[e].component);
544
+ let c = W(e, a, o, s, t), f = l(), p = f[f.length - 1];
545
+ u([...f, c]), s?.animated !== !1 && r && (d({
546
+ kind: "push",
547
+ topEntry: c,
548
+ underneathEntry: p,
549
+ progress: r
550
+ }), h(1, V).then(() => d(null), () => d(null)));
551
+ }), _ = ((e, ...n) => {
552
+ if (m()) return;
553
+ let { params: r, search: i, options: a } = G(e, n, t);
554
+ if (!t[e]) throw Error(`[lynx-navigation] replace('${e}'): route is not registered.`);
555
+ H(t[e].component);
556
+ let o = W(e, r, i, a, t), s = l();
557
+ u([...s.slice(0, s.length - 1), o]);
558
+ });
559
+ function v(e = 1, t) {
560
+ if (m()) return;
561
+ let n = l(), i = Math.max(1, n.length - Math.max(1, e));
562
+ if (i === n.length) return;
563
+ if (!(t?.animated !== !1 && r && e === 1 && n.length >= 2)) {
564
+ u(n.slice(0, i));
565
+ return;
566
+ }
567
+ let a = n[n.length - 1], o = n[n.length - 2];
568
+ d({
569
+ kind: "pop",
570
+ topEntry: a,
571
+ underneathEntry: o,
572
+ progress: r
573
+ }), h(1, V).then(() => {
574
+ u(n.slice(0, n.length - 1)), d(null);
575
+ }, () => {
576
+ u(n.slice(0, n.length - 1)), d(null);
577
+ });
578
+ }
579
+ function y(e) {
580
+ if (m()) return;
581
+ let t = l();
582
+ for (let n = t.length - 1; n >= 0; n--) if (t[n].route === e) {
583
+ if (n === t.length - 1) return;
584
+ u(t.slice(0, n + 1));
585
+ return;
586
+ }
587
+ }
588
+ function b() {
589
+ if (m()) return;
590
+ let e = l();
591
+ e.length <= 1 || u([e[0]]);
592
+ }
593
+ function ee(e) {
594
+ if (e.stack.length === 0) throw Error("[lynx-navigation] reset() called with empty stack.");
595
+ u([...e.stack]), d(null);
596
+ }
597
+ function S() {
598
+ if (m()) return;
599
+ let e = l(), t = e.length - 1;
600
+ for (; t > 0 && e[t].presentation !== "card";) t--;
601
+ t < e.length - 1 && u(e.slice(0, t + 1));
602
+ }
603
+ function C() {
604
+ if (m()) return;
605
+ let e = l();
606
+ if (e.length < 2) return;
607
+ let t = e[e.length - 1], n = e[e.length - 2];
608
+ d({
609
+ kind: "pop",
610
+ topEntry: t,
611
+ underneathEntry: n,
612
+ progress: r
613
+ });
614
+ }
615
+ function w() {
616
+ let e = l();
617
+ e.length >= 2 && u(e.slice(0, e.length - 1)), d(null);
618
+ }
619
+ function T() {
620
+ d(null);
621
+ }
622
+ let E = {
623
+ push: g,
624
+ replace: _,
625
+ pop: v,
626
+ popTo: y,
627
+ popToRoot: b,
628
+ reset: ee,
629
+ dismiss: S,
630
+ get current() {
631
+ return a[a.length - 1];
632
+ },
633
+ get stack() {
634
+ return a;
635
+ },
636
+ get canGoBack() {
637
+ return a.length > 1;
638
+ },
639
+ get parent() {
640
+ return i;
641
+ },
642
+ get isLocallyFocused() {
643
+ return o.value;
644
+ },
645
+ get _children() {
646
+ return s;
647
+ },
648
+ get transition() {
649
+ return c.value;
650
+ }
651
+ };
652
+ i && i._children.add(E);
653
+ function te(e) {
654
+ o.value !== e && (o.value = e);
655
+ }
656
+ return {
657
+ nav: E,
658
+ routes: t,
659
+ _gesture: {
660
+ beginBackGesture: C,
661
+ commitBackGesture: w,
662
+ cancelBackGesture: T
663
+ },
664
+ _screens: ke(),
665
+ _setLocallyFocused: te
666
+ };
667
+ }
668
+ function ke() {
669
+ let e = /* @__PURE__ */ new Map(), t = p({ v: 0 });
670
+ return {
671
+ register(n) {
672
+ e.set(n.entry.key, n), m(() => {
673
+ t.v += 1;
674
+ });
675
+ },
676
+ unregister(n) {
677
+ e.get(n.entry.key) === n && (e.delete(n.entry.key), m(() => {
678
+ t.v += 1;
679
+ }));
680
+ },
681
+ get(n) {
682
+ return t.v, e.get(n);
683
+ }
684
+ };
685
+ }
686
+ //#endregion
687
+ //#region src/components/NavigationRoot.tsx
688
+ var Ae = n(({ props: e, slots: t }) => {
689
+ let n = e.routes, r = e.initialRoute ?? Object.keys(n)[0];
690
+ if (!n[r]) throw Error(`[lynx-navigation] <NavigationRoot> initialRoute='${r}' is not in the routes registry.`);
691
+ j(n);
692
+ let i = n[r].presentation ?? "card", a = {
693
+ key: "root",
694
+ route: r,
695
+ params: e.initialParams ?? {},
696
+ search: e.initialSearch ?? {},
697
+ state: void 0,
698
+ presentation: i
699
+ }, s = v(0), c = e.animated !== !1, l = K({
700
+ routes: n,
701
+ initial: a,
702
+ progress: c ? s : void 0
703
+ });
704
+ o(T, () => l.nav), o(F, () => l.routes);
705
+ let u = e.edgeSwipeEnabled !== !1;
706
+ return o(I, () => ({
707
+ progress: c ? s : null,
708
+ beginBackGesture: l._gesture.beginBackGesture,
709
+ commitBackGesture: l._gesture.commitBackGesture,
710
+ cancelBackGesture: l._gesture.cancelBackGesture,
711
+ edgeSwipeEnabled: u,
712
+ screens: l._screens
713
+ })), () => t.default?.();
714
+ });
715
+ //#endregion
716
+ //#region src/internal/screen-width.ts
717
+ function q(e, t) {
718
+ try {
719
+ let t = typeof lynx < "u" ? lynx?.SystemInfo : void 0, n = t?.[e], r = t?.pixelRatio || 1;
720
+ if (typeof n == "number" && n > 0) return Math.round(n / r);
721
+ } catch {}
722
+ return t;
723
+ }
724
+ var J = q("pixelWidth", 400), je = q("pixelHeight", 800), Me = .3;
725
+ function Y(e) {
726
+ return e === "modal" || e === "fullScreen" || e === "transparent-modal";
727
+ }
728
+ function Ne(e) {
729
+ return e ? `${e.axis}:${e.outputRange[0]}->${e.outputRange[1]}` : "static";
730
+ }
731
+ function Pe(e, t, n) {
732
+ return t === "push" ? e === "top" ? {
733
+ axis: "translateX",
734
+ inputRange: [0, 1],
735
+ outputRange: [J, 0],
736
+ progress: n
737
+ } : {
738
+ axis: "translateX",
739
+ inputRange: [0, 1],
740
+ outputRange: [0, -Me * J],
741
+ progress: n
742
+ } : e === "top" ? {
743
+ axis: "translateX",
744
+ inputRange: [0, 1],
745
+ outputRange: [0, J],
746
+ progress: n
747
+ } : {
748
+ axis: "translateX",
749
+ inputRange: [0, 1],
750
+ outputRange: [-Me * J, 0],
751
+ progress: n
752
+ };
753
+ }
754
+ function Fe(e, t) {
755
+ return e === "push" ? {
756
+ axis: "translateY",
757
+ inputRange: [0, 1],
758
+ outputRange: [je, 0],
759
+ progress: t
760
+ } : {
761
+ axis: "translateY",
762
+ inputRange: [0, 1],
763
+ outputRange: [0, je],
764
+ progress: t
765
+ };
766
+ }
767
+ function Ie(e, t, n) {
768
+ if (!t) {
769
+ let t = e.length - 1;
770
+ for (; t > 0 && Y(e[t].presentation);) --t;
771
+ return e.slice(t).map((e) => ({
772
+ entry: e,
773
+ animation: null
774
+ }));
775
+ }
776
+ if (!Y(t.topEntry.presentation)) return [{
777
+ entry: t.underneathEntry,
778
+ animation: n ? Pe("underneath", t.kind, n) : null
779
+ }, {
780
+ entry: t.topEntry,
781
+ animation: n ? Pe("top", t.kind, n) : null
782
+ }];
783
+ let r = e.findIndex((e) => e.key === t.underneathEntry.key), i = r >= 0 ? r : e.length - 1, a = i;
784
+ for (; a > 0 && Y(e[a].presentation);) --a;
785
+ return [...e.slice(a, i + 1).map((e) => ({
786
+ entry: e,
787
+ animation: null
788
+ })), {
789
+ entry: t.topEntry,
790
+ animation: n ? Fe(t.kind, n) : null
791
+ }];
792
+ }
793
+ //#endregion
794
+ //#region src/components/EdgeBackHandle.tsx
795
+ var Le = .33, Re = 300, ze = 20, Be = 8, X = .18, Z = Math.round(X * 1e3), Ve = n(() => {
796
+ let t = _(null), n = {
797
+ startPageX: 0,
798
+ prevPageX: 0,
799
+ prevTime: 0,
800
+ velocity: 0
801
+ }, r = I(), i = r.progress, a = r.beginBackGesture, o = r.commitBackGesture, s = r.cancelBackGesture;
802
+ return g(t, e.Pan().minDistance(Be).onBegin(() => {
803
+ "main thread";
804
+ }).onStart((e) => {
805
+ "main thread";
806
+ let t = e && e.params, r = t && t.pageX || 0;
807
+ n.startPageX = r, n.prevPageX = r, n.prevTime = Date.now(), n.velocity = 0, d(() => {
808
+ a();
809
+ })();
810
+ }).onUpdate((e) => {
811
+ "main thread";
812
+ if (!i) return;
813
+ let t = e && e.params, r = t && t.pageX || 0, a = r - n.startPageX, o = Math.max(0, Math.min(1, a / J));
814
+ i.current.value = o;
815
+ let s = Date.now(), c = s - n.prevTime;
816
+ c > 0 && (n.velocity = (r - n.prevPageX) / c * 1e3), n.prevPageX = r, n.prevTime = s;
817
+ }).onEnd((e) => {
818
+ "main thread";
819
+ if (!i) return;
820
+ let t = e && e.params;
821
+ ((t && t.pageX || 0) - n.startPageX) / J > Le || n.velocity > Re ? (x(i, 1, { duration: X }), d(() => {
822
+ setTimeout(() => o(), Z);
823
+ })()) : (x(i, 0, { duration: X }), d(() => {
824
+ setTimeout(() => s(), Z);
825
+ })());
826
+ })), () => /* @__PURE__ */ S("view", {
827
+ "main-thread:ref": t,
828
+ style: {
829
+ position: "absolute",
830
+ top: "0",
831
+ left: "0",
832
+ width: `${ze}px`,
833
+ bottom: "0"
834
+ }
835
+ });
836
+ }), He = n(({ props: e, slots: t }) => {
837
+ let n = I(), r = Se(e.entry);
838
+ return n.screens.register(r), u(() => {
839
+ n.screens.unregister(r);
840
+ }), o(P, () => e.entry), o(_e, () => e.entry), o(L, () => r), () => t.default?.();
841
+ }), Ue = n(({ props: e }) => {
842
+ let n = _(null);
843
+ if (e.animation) {
844
+ let t = e.animation;
845
+ h(n, t.progress, t.axis, {
846
+ inputRange: [t.inputRange[0], t.inputRange[1]],
847
+ outputRange: [t.outputRange[0], t.outputRange[1]]
848
+ });
849
+ }
850
+ return () => {
851
+ let r = e.routes[e.entry.route];
852
+ if (!r) return null;
853
+ let i = r.component;
854
+ if (typeof i != "function") return null;
855
+ let a = e.entry.params, o = c(i) && r.fallback ? /* @__PURE__ */ S(t, {
856
+ fallback: r.fallback,
857
+ children: /* @__PURE__ */ S(i, { ...a })
858
+ }) : /* @__PURE__ */ S(i, { ...a });
859
+ return /* @__PURE__ */ S("view", {
860
+ "main-thread:ref": n,
861
+ style: {
862
+ position: "absolute",
863
+ top: "0",
864
+ left: "0",
865
+ right: "0",
866
+ bottom: "0",
867
+ display: "flex",
868
+ flexDirection: "column"
869
+ },
870
+ children: /* @__PURE__ */ S(He, {
871
+ entry: e.entry,
872
+ children: o
873
+ }, e.entry.key)
874
+ });
875
+ };
876
+ }), Q = a(() => {
877
+ throw Error("[lynx-navigation] useTabs() called outside of a <Tabs> component.");
878
+ }), We = a(() => {
879
+ throw Error("[lynx-navigation] <Tabs.Screen> rendered outside a <Tabs> component.");
880
+ }), Ge = a(() => {
881
+ throw Error("[lynx-navigation] useTabScreenName() called outside a <Tabs.Screen> body.");
882
+ }), Ke = r(n(({ props: e, slots: t }) => {
883
+ let n = p([]), r = p({ value: e.initialTab ?? null }), i = {
884
+ register(e) {
885
+ m(() => {
886
+ let t = n.findIndex((t) => t.name === e.name);
887
+ t === -1 ? n.push(e) : n[t] = e, r.value === null && (r.value = e.name);
888
+ });
889
+ },
890
+ unregister(e) {
891
+ m(() => {
892
+ let t = n.findIndex((t) => t.name === e);
893
+ t !== -1 && n.splice(t, 1), r.value === e && (r.value = n[0]?.name ?? null);
894
+ });
895
+ },
896
+ tabs: n,
897
+ activeSignal: r
898
+ }, a = {
899
+ get active() {
900
+ return r.value ?? "";
901
+ },
902
+ setActive(e) {
903
+ n.some((t) => t.name === e) && (r.value = e);
904
+ },
905
+ get tabs() {
906
+ return n;
907
+ }
908
+ };
909
+ return o(Q, () => a), o(We, () => i), () => t.default?.();
910
+ }), { Screen: n(({ props: e, slots: t }) => {
911
+ let n = We(), r = e.name;
912
+ return n.register({
913
+ name: r,
914
+ icon: e.icon,
915
+ label: e.label,
916
+ accessibilityLabel: e.accessibilityLabel
917
+ }), u(() => n.unregister(r)), o(Ge, () => r), () => /* @__PURE__ */ S("view", {
918
+ style: {
919
+ display: n.activeSignal.value === r ? "flex" : "none",
920
+ flexDirection: "column",
921
+ width: "100%",
922
+ flexGrow: 1,
923
+ flexShrink: 1,
924
+ flexBasis: 0,
925
+ minHeight: 0
926
+ },
927
+ children: t.default?.()
928
+ });
929
+ }) }), qe = 0, Je = n(({ props: e, slots: t }) => {
930
+ let n = T(), r = F(), i = I(), a = e.initialRoute, c = typeof a == "string" && a.length > 0, l, d;
931
+ if (c) {
932
+ if (!r[a]) throw Error(`[lynx-navigation] <Stack initialRoute='${a}'>: route is not registered. Known routes: ${Object.keys(r).join(", ") || "(none)"}`);
933
+ let t = null;
934
+ try {
935
+ t = P().key;
936
+ } catch {
937
+ t = null;
938
+ }
939
+ let c = null, f = null;
940
+ try {
941
+ c = Ge(), f = Q();
942
+ } catch {
943
+ c = null, f = null;
944
+ }
945
+ let p = i.progress !== null, h = v(0), g = r[a].presentation ?? "card";
946
+ qe += 1;
947
+ let _ = K({
948
+ routes: r,
949
+ initial: {
950
+ key: `nested-${a}-${qe}`,
951
+ route: a,
952
+ params: e.initialParams ?? {},
953
+ search: e.initialSearch ?? {},
954
+ state: void 0,
955
+ presentation: g
956
+ },
957
+ progress: p ? h : void 0,
958
+ parent: n,
959
+ initialLocallyFocused: !1
960
+ });
961
+ l = _.nav, d = {
962
+ progress: p ? h : null,
963
+ beginBackGesture: _._gesture.beginBackGesture,
964
+ commitBackGesture: _._gesture.commitBackGesture,
965
+ cancelBackGesture: _._gesture.cancelBackGesture,
966
+ edgeSwipeEnabled: p && i.edgeSwipeEnabled,
967
+ screens: _._screens
968
+ };
969
+ let y = s(() => {
970
+ let e = t === null || n.current.key === t, r = n.isLocallyFocused, i = c === null || f === null ? !0 : f.active === c, a = e && r && i;
971
+ m(() => _._setLocallyFocused(a));
972
+ });
973
+ u(() => {
974
+ y.stop(), n._children.delete(l);
975
+ }), o(T, () => l), o(F, () => r), o(I, () => d);
976
+ } else l = n, d = i;
977
+ let f = {
978
+ flexGrow: 1,
979
+ flexShrink: 1,
980
+ flexBasis: 0,
981
+ minHeight: 0,
982
+ display: "flex",
983
+ flexDirection: "column"
984
+ };
985
+ return () => {
986
+ let e = t.default?.(), n = Ie(l.stack, l.transition, d.progress), i = (e) => e ? /* @__PURE__ */ S(Ue, {
987
+ entry: e.entry,
988
+ routes: r,
989
+ animation: e.animation
990
+ }, `layer-${e.entry.key}-${Ne(e.animation)}`) : null, a = l.current, o = d.edgeSwipeEnabled && l.canGoBack && !l.transition && !Y(a.presentation) ? /* @__PURE__ */ S(Ve, {}, "edge-back") : null, s = /* @__PURE__ */ C("view", {
991
+ style: {
992
+ position: "relative",
993
+ width: "100%",
994
+ ...f,
995
+ overflow: "hidden"
996
+ },
997
+ children: [
998
+ i(n[0]),
999
+ i(n[1]),
1000
+ i(n[2]),
1001
+ i(n[3]),
1002
+ i(n[4]),
1003
+ i(n[5]),
1004
+ i(n[6]),
1005
+ i(n[7]),
1006
+ i(n[8]),
1007
+ i(n[9]),
1008
+ i(n[10]),
1009
+ i(n[11]),
1010
+ i(n[12]),
1011
+ i(n[13]),
1012
+ i(n[14]),
1013
+ i(n[15]),
1014
+ o
1015
+ ]
1016
+ });
1017
+ return e == null ? s : /* @__PURE__ */ C("view", {
1018
+ style: f,
1019
+ children: [e, /* @__PURE__ */ S("view", {
1020
+ style: f,
1021
+ children: s
1022
+ })]
1023
+ });
1024
+ };
1025
+ }), Ye = n(({ props: e, slots: t }) => {
1026
+ let n = L(), r = {};
1027
+ return e.title !== void 0 && (r.title = e.title), e.headerShown !== void 0 && (r.headerShown = e.headerShown), e.gestureEnabled !== void 0 && (r.gestureEnabled = e.gestureEnabled), B(n, r), () => t.default?.();
1028
+ });
1029
+ function $(e) {
1030
+ return n(({ slots: t }) => {
1031
+ let n = L();
1032
+ return z(n, e, () => t.default?.()), u(() => z(n, e, void 0)), () => null;
1033
+ });
1034
+ }
1035
+ var Xe = $("header"), Ze = $("headerLeft"), Qe = $("headerRight"), $e = n(({ slots: e }) => {
1036
+ let t = L();
1037
+ return z(t, "tabBarItem", (t) => {
1038
+ let n = e.default?.();
1039
+ if (typeof n == "function") return n(t);
1040
+ if (Array.isArray(n)) {
1041
+ let e = n[0];
1042
+ if (typeof e == "function") return e(t);
1043
+ }
1044
+ return n;
1045
+ }), u(() => z(t, "tabBarItem", void 0)), () => null;
1046
+ }), et = Object.assign(Ye, {
1047
+ Header: Xe,
1048
+ HeaderLeft: Ze,
1049
+ HeaderRight: Qe,
1050
+ TabBarItem: $e
1051
+ });
1052
+ //#endregion
1053
+ //#region src/components/Header.tsx
1054
+ function tt(e, t) {
1055
+ return typeof e == "function" ? e() : typeof e == "string" ? e : t;
1056
+ }
1057
+ var nt = n(({ props: e }) => () => /* @__PURE__ */ S("view", {
1058
+ bindtap: () => e.onPress(),
1059
+ "accessibility-element": !0,
1060
+ "accessibility-label": "Back",
1061
+ "accessibility-trait": "button",
1062
+ children: /* @__PURE__ */ S("text", { children: "‹ Back" })
1063
+ })), rt = n(({ props: e }) => () => /* @__PURE__ */ S("view", { children: /* @__PURE__ */ S("text", { children: e.text }) })), it = n(() => {
1064
+ let e = T(), t = I(), n = i(() => e.current), r = i(() => t.screens.get(n.value.key)?.slots.header), a = i(() => t.screens.get(n.value.key)?.slots.headerLeft), o = i(() => t.screens.get(n.value.key)?.slots.headerRight), s = i(() => t.screens.get(n.value.key)?.options.headerShown !== !1), c = i(() => tt(t.screens.get(n.value.key)?.options.title, n.value.route));
1065
+ return () => {
1066
+ if (!s.value) return null;
1067
+ let t = r.value;
1068
+ return t ? t() : /* @__PURE__ */ C("view", { children: [
1069
+ /* @__PURE__ */ S("view", { children: a.value ? a.value() : e.canGoBack ? /* @__PURE__ */ S(nt, { onPress: () => e.pop() }) : null }),
1070
+ /* @__PURE__ */ S(rt, { text: c.value }),
1071
+ /* @__PURE__ */ S("view", { children: o.value ? o.value() : null })
1072
+ ] });
1073
+ };
1074
+ }), at = n(({ props: e }) => () => {
1075
+ let t = e.info.label ?? e.info.name;
1076
+ return /* @__PURE__ */ C("view", {
1077
+ bindtap: () => e.onPress(),
1078
+ "accessibility-element": !0,
1079
+ "accessibility-label": e.info.accessibilityLabel ?? t,
1080
+ "accessibility-trait": "button",
1081
+ "accessibility-status": e.active ? "selected" : void 0,
1082
+ style: { opacity: e.active ? 1 : .6 },
1083
+ children: [e.info.icon ?? null, /* @__PURE__ */ S("text", { children: t })]
1084
+ });
1085
+ }), ot = n(({ props: e }) => {
1086
+ let t = Q();
1087
+ return () => {
1088
+ let n = t.tabs, r = t.active, i = e.renderTab;
1089
+ return /* @__PURE__ */ S("view", {
1090
+ "accessibility-element": !1,
1091
+ children: n.map((e) => {
1092
+ let n = e.name === r, a = () => t.setActive(e.name);
1093
+ return i ? i(e, {
1094
+ active: n,
1095
+ onPress: a
1096
+ }) : /* @__PURE__ */ S(at, {
1097
+ info: e,
1098
+ active: n,
1099
+ onPress: a
1100
+ });
1101
+ })
1102
+ });
1103
+ };
1104
+ }), st = a(() => {
1105
+ throw Error("[lynx-navigation] useDrawer() called outside of a <Drawer> component.");
1106
+ }), ct = n(({ props: e, slots: t }) => {
1107
+ let n = p({ value: e.initialOpen === !0 }), r = {
1108
+ get isOpen() {
1109
+ return n.value;
1110
+ },
1111
+ open() {
1112
+ n.value = !0;
1113
+ },
1114
+ close() {
1115
+ n.value = !1;
1116
+ },
1117
+ toggle() {
1118
+ n.value = !n.value;
1119
+ }
1120
+ };
1121
+ return o(st, () => r), () => {
1122
+ let e = n.value;
1123
+ return /* @__PURE__ */ C("view", {
1124
+ style: {
1125
+ width: "100%",
1126
+ height: "100%"
1127
+ },
1128
+ children: [/* @__PURE__ */ S("view", {
1129
+ style: {
1130
+ width: "100%",
1131
+ height: "100%"
1132
+ },
1133
+ children: t.default?.()
1134
+ }), /* @__PURE__ */ S("view", {
1135
+ style: {
1136
+ position: "absolute",
1137
+ left: 0,
1138
+ top: 0,
1139
+ bottom: 0,
1140
+ display: e ? "flex" : "none"
1141
+ },
1142
+ children: t.sidebar?.()
1143
+ })]
1144
+ });
1145
+ };
1146
+ }), lt = n(({ props: e, slots: t }) => {
1147
+ let n = T(), r = F(), i = () => {
1148
+ let t = e.to, i = r[t];
1149
+ if (!i) throw Error(`[lynx-navigation] <Link to='${t}'>: route is not registered.`);
1150
+ let a = !!i.params, o = e.replace ? n.replace : n.push;
1151
+ a ? o(t, e.params, e.search) : o(t, e.search);
1152
+ };
1153
+ return () => /* @__PURE__ */ S("view", {
1154
+ bindtap: i,
1155
+ children: t.default?.()
1156
+ });
1157
+ }, { name: "Link" });
1158
+ //#endregion
1159
+ export { ct as Drawer, it as Header, lt as Link, Te as NAV_SNAPSHOT_VERSION, Ae as NavigationRoot, et as Screen, Je as Stack, ot as TabBar, Ke as Tabs, ce as _clearRouteRegistry, j as _setRouteRegistry, O as compilePath, w as defineRoutes, he as hrefFor, ge as parseHref, st as useDrawer, xe as useFocusEffect, ne as useHardwareBack, R as useIsFocused, ve as useLinkingNav, T as useNav, Ee as useNavSerializer, E as useParams, we as useScreenChrome, Ce as useScreenOptions, te as useSearch, Q as useTabs };
1160
+
30
1161
  //# sourceMappingURL=index.js.map