react-modal-navigation 1.1.6 → 1.1.8

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.js CHANGED
@@ -1,8 +1,8 @@
1
- import { jsx as h, jsxs as me } from "react/jsx-runtime";
2
- import Ne, { createContext as ee, useRef as d, useState as ie, useEffect as H, useCallback as v, useMemo as K, useSyncExternalStore as be, useReducer as ln, useLayoutEffect as Qe, useInsertionEffect as un, useContext as Q } from "react";
3
- import { createPortal as dn } from "react-dom";
4
- const nn = ee(null), mn = ee(null), je = ee(null), Fe = ee(null), tn = ee(null), rn = ee(null), Ue = ee(null), We = ee(null), Ye = ee(null), pn = ee(null), fn = ee(null), on = ee(null);
5
- function hn(e) {
1
+ import { jsx as h, jsxs as ue } from "react/jsx-runtime";
2
+ import Ne, { createContext as oe, useRef as l, useState as le, useEffect as W, useCallback as w, useMemo as K, useSyncExternalStore as fe, useLayoutEffect as Fe, useReducer as wn, useInsertionEffect as xn, useContext as ee } from "react";
3
+ import { createPortal as kn } from "react-dom";
4
+ const pn = oe(null), En = oe(null), je = oe(null), De = oe(null), fn = oe(null), gn = oe(null), Ve = oe(null), Qe = oe(null), Ze = oe(null), Sn = oe(null), Rn = oe(null), hn = oe(null);
5
+ function Cn(e) {
6
6
  let n = e;
7
7
  const r = /* @__PURE__ */ new Set();
8
8
  return {
@@ -11,13 +11,13 @@ function hn(e) {
11
11
  publish(t) {
12
12
  if (n !== t) {
13
13
  n = t;
14
- for (const c of [...r]) c();
14
+ for (const s of [...r]) s();
15
15
  }
16
16
  },
17
17
  listenerCount: () => r.size
18
18
  };
19
19
  }
20
- function ze(e) {
20
+ function Ue(e) {
21
21
  let n = e;
22
22
  const r = /* @__PURE__ */ new Set();
23
23
  return {
@@ -26,21 +26,21 @@ function ze(e) {
26
26
  publish(t) {
27
27
  if (!Object.is(n, t)) {
28
28
  n = t;
29
- for (const c of [...r]) c();
29
+ for (const s of [...r]) s();
30
30
  }
31
31
  },
32
32
  listenerCount: () => r.size
33
33
  };
34
34
  }
35
- let gn = 0;
36
- const He = (e, n) => ({ key: `modal-route-${++gn}`, name: e, params: n ?? {} }), an = (e, n) => [He(e, n)];
37
- function qe(e, n) {
35
+ let Tn = 0;
36
+ const _e = (e, n) => ({ key: `modal-route-${++Tn}`, name: e, params: n ?? {} }), bn = (e, n) => [_e(e, n)];
37
+ function $e(e, n) {
38
38
  switch (n.type) {
39
39
  case "RESET":
40
- return an(n.name, n.params);
40
+ return bn(n.name, n.params);
41
41
  case "NAVIGATE": {
42
42
  const r = e.findIndex((t) => t.name === n.name);
43
- return r < 0 ? [...e, He(n.name, n.params)] : e.slice(0, r + 1).map((t, c) => c === r ? { ...t, params: n.params ?? {} } : t);
43
+ return r < 0 ? [...e, _e(n.name, n.params)] : e.slice(0, r + 1).map((t, s) => s === r ? { ...t, params: n.params ?? {} } : t);
44
44
  }
45
45
  case "SET_OPTIONS":
46
46
  return e.map((r, t) => t === e.length - 1 ? { ...r, options: { ...r.options ?? {}, ...n.options ?? {} } } : r);
@@ -49,88 +49,88 @@ function qe(e, n) {
49
49
  case "BACK":
50
50
  return e.length > 1 ? e.slice(0, -1) : e;
51
51
  case "REPLACE":
52
- return e.length ? [...e.slice(0, -1), He(n.name, n.params)] : e;
52
+ return e.length ? [...e.slice(0, -1), _e(n.name, n.params)] : e;
53
53
  default:
54
54
  return e;
55
55
  }
56
56
  }
57
- function bn(e, n, r = 1 / 0) {
58
- const t = r === 1 / 0 ? 1 / 0 : Math.max(0, Math.floor(Number(r) || 0)), c = e.slice(0, -1).filter((i) => n[i.name]?.keepAlive !== !1), f = new Set((t === 0 ? [] : c.slice(-t)).map((i) => i.key));
59
- return e.filter((i, m) => m === e.length - 1 || f.has(i.key));
57
+ function Mn(e, n, r = 1 / 0) {
58
+ const t = r === 1 / 0 ? 1 / 0 : Math.max(0, Math.floor(Number(r) || 0)), s = e.slice(0, -1).filter((d) => n[d.name]?.keepAlive !== !1), g = new Set((t === 0 ? [] : s.slice(-t)).map((d) => d.key));
59
+ return e.filter((d, m) => m === e.length - 1 || g.has(d.key));
60
60
  }
61
- const Je = () => {
61
+ const ln = () => {
62
62
  if (typeof document > "u") return "light";
63
63
  const e = document.documentElement, n = document.body;
64
64
  return e.classList.contains("dark") || n.classList.contains("dark") || e.dataset.theme === "dark" || n.dataset.theme === "dark" ? "dark" : e.classList.contains("light") || n.classList.contains("light") || e.dataset.theme === "light" || n.dataset.theme === "light" ? "light" : window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
65
65
  };
66
- let Te = 0;
67
- const ge = [];
68
- let Ke = null;
69
- function yn() {
70
- if (Te++, Te === 1) {
71
- const n = document.documentElement, r = document.body, t = { html: n.style.overflow, body: r.style.overflow, padding: r.style.paddingRight, width: r.style.getPropertyValue("--modal-scrollbar-width") }, c = Math.max(0, window.innerWidth - n.clientWidth), f = parseFloat(getComputedStyle(r).paddingRight) || 0;
72
- c && (r.style.paddingRight = `${f + c}px`), r.style.setProperty("--modal-scrollbar-width", `${c}px`), n.style.overflow = "hidden", r.style.overflow = "hidden", Ke = () => {
66
+ let Ae = 0;
67
+ const pe = [];
68
+ let We = null;
69
+ function An() {
70
+ if (Ae++, Ae === 1) {
71
+ const n = document.documentElement, r = document.body, t = { html: n.style.overflow, body: r.style.overflow, padding: r.style.paddingRight, width: r.style.getPropertyValue("--modal-scrollbar-width") }, s = Math.max(0, window.innerWidth - n.clientWidth), g = parseFloat(getComputedStyle(r).paddingRight) || 0;
72
+ s && (r.style.paddingRight = `${g + s}px`), r.style.setProperty("--modal-scrollbar-width", `${s}px`), n.style.overflow = "hidden", r.style.overflow = "hidden", We = () => {
73
73
  n.style.overflow = t.html, r.style.overflow = t.body, r.style.paddingRight = t.padding, t.width ? r.style.setProperty("--modal-scrollbar-width", t.width) : r.style.removeProperty("--modal-scrollbar-width");
74
74
  };
75
75
  }
76
76
  let e = !1;
77
77
  return () => {
78
- e || (e = !0, Te = Math.max(0, Te - 1), Te || (Ke?.(), Ke = null));
78
+ e || (e = !0, Ae = Math.max(0, Ae - 1), Ae || (We?.(), We = null));
79
79
  };
80
80
  }
81
- const vn = 'a[href],button:not([disabled]),input:not([disabled]),textarea:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])', wn = (e) => !e.closest('[inert], [hidden], [aria-hidden="true"]') && e.getClientRects().length > 0 && getComputedStyle(e).visibility !== "hidden" && getComputedStyle(e).display !== "none";
82
- function xn({ dialogRef: e, options: n, requestClose: r, children: t, exiting: c = !1 }) {
83
- const f = d(null), i = d(null), m = d(r);
81
+ const Nn = 'a[href],button:not([disabled]),input:not([disabled]),textarea:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])', Pn = (e) => !e.closest('[inert], [hidden], [aria-hidden="true"]') && e.getClientRects().length > 0 && getComputedStyle(e).visibility !== "hidden" && getComputedStyle(e).display !== "none";
82
+ function Ln({ dialogRef: e, options: n, requestClose: r, children: t, exiting: s = !1 }) {
83
+ const g = l(null), d = l(null), m = l(r);
84
84
  m.current = r;
85
- const l = d(n.closeOnEsc);
86
- l.current = n.closeOnEsc;
87
- const [y, C] = ie(Je), x = n.theme === "light" || n.theme === "dark" ? n.theme : y;
88
- H(() => {
85
+ const p = l(n.closeOnEsc);
86
+ p.current = n.closeOnEsc;
87
+ const [y, R] = le(ln), x = n.theme === "light" || n.theme === "dark" ? n.theme : y;
88
+ W(() => {
89
89
  if (n.theme === "light" || n.theme === "dark") return;
90
- const b = () => C(Je()), T = new MutationObserver(b);
91
- for (const F of [document.documentElement, document.body]) T.observe(F, { attributes: !0, attributeFilter: ["class", "data-theme"] });
92
- const j = window.matchMedia?.("(prefers-color-scheme: dark)");
93
- return j?.addEventListener?.("change", b), b(), () => {
94
- T.disconnect(), j?.removeEventListener?.("change", b);
90
+ const b = () => R(ln()), T = new MutationObserver(b);
91
+ for (const z of [document.documentElement, document.body]) T.observe(z, { attributes: !0, attributeFilter: ["class", "data-theme"] });
92
+ const D = window.matchMedia?.("(prefers-color-scheme: dark)");
93
+ return D?.addEventListener?.("change", b), b(), () => {
94
+ T.disconnect(), D?.removeEventListener?.("change", b);
95
95
  };
96
- }, [n.theme]), H(() => {
97
- i.current = document.activeElement;
98
- const b = yn(), T = f.current;
99
- ge.push(T), e.current?.focus({ preventScroll: !0 });
100
- const j = (N) => {
101
- const V = e.current;
102
- if (!V || ge.at(-1) !== T) return;
103
- if (N.key === "Escape" && l.current !== !1) {
104
- N.preventDefault(), m.current("escape");
96
+ }, [n.theme]), W(() => {
97
+ d.current = document.activeElement;
98
+ const b = An(), T = g.current;
99
+ pe.push(T), e.current?.focus({ preventScroll: !0 });
100
+ const D = (M) => {
101
+ const G = e.current;
102
+ if (!G || pe.at(-1) !== T) return;
103
+ if (M.key === "Escape" && p.current !== !1) {
104
+ M.preventDefault(), m.current("escape");
105
105
  return;
106
106
  }
107
- if (N.key !== "Tab") return;
108
- const L = [...V.querySelectorAll(vn)].filter(wn);
109
- if (!L.length) {
110
- N.preventDefault(), V.focus();
107
+ if (M.key !== "Tab") return;
108
+ const $ = [...G.querySelectorAll(Nn)].filter(Pn);
109
+ if (!$.length) {
110
+ M.preventDefault(), G.focus();
111
111
  return;
112
112
  }
113
- const ne = L[0], te = L.at(-1);
114
- V.contains(document.activeElement) ? N.shiftKey && (document.activeElement === ne || document.activeElement === V) ? (N.preventDefault(), te.focus()) : !N.shiftKey && (document.activeElement === te || document.activeElement === V) && (N.preventDefault(), ne.focus()) : (N.preventDefault(), (N.shiftKey ? te : ne).focus());
115
- }, F = (N) => {
116
- ge.at(-1) === T && e.current && !e.current.contains(N.target) && e.current.focus({ preventScroll: !0 });
113
+ const se = $[0], ae = $.at(-1);
114
+ G.contains(document.activeElement) ? M.shiftKey && (document.activeElement === se || document.activeElement === G) ? (M.preventDefault(), ae.focus()) : !M.shiftKey && (document.activeElement === ae || document.activeElement === G) && (M.preventDefault(), se.focus()) : (M.preventDefault(), (M.shiftKey ? ae : se).focus());
115
+ }, z = (M) => {
116
+ pe.at(-1) === T && e.current && !e.current.contains(M.target) && e.current.focus({ preventScroll: !0 });
117
117
  };
118
- return document.addEventListener("keydown", j), document.addEventListener("focusin", F), () => {
119
- document.removeEventListener("keydown", j), document.removeEventListener("focusin", F);
120
- const N = ge.at(-1) === T, V = ge.indexOf(T);
121
- if (V !== -1 && ge.splice(V, 1), b(), N) {
122
- const L = i.current;
123
- L?.isConnected && !L.closest("[inert], [hidden]") ? L.focus?.({ preventScroll: !0 }) : ge.at(-1)?.querySelector("[role=dialog]")?.focus?.({ preventScroll: !0 });
118
+ return document.addEventListener("keydown", D), document.addEventListener("focusin", z), () => {
119
+ document.removeEventListener("keydown", D), document.removeEventListener("focusin", z);
120
+ const M = pe.at(-1) === T, G = pe.indexOf(T);
121
+ if (G !== -1 && pe.splice(G, 1), b(), M) {
122
+ const $ = d.current;
123
+ $?.isConnected && !$.closest("[inert], [hidden]") ? $.focus?.({ preventScroll: !0 }) : pe.at(-1)?.querySelector("[role=dialog]")?.focus?.({ preventScroll: !0 });
124
124
  }
125
125
  };
126
126
  }, [e]);
127
- const g = n.backgroundColor ?? n.backgroudColor, u = typeof g == "string" ? g : g?.[x], s = typeof u == "string" && /^(#|rgb\(|rgba\(|hsl\(|hsla\(|oklch\(|color\(|var\()/.test(u.trim()) ? u : null, B = { sm: 400, md: 560, lg: 720, xl: 960, full: "100%" }, R = ["center", "left", "right", "top", "bottom"].includes(n.placement) ? n.placement : "right", A = (b) => typeof b == "number" ? `${b}px` : b, q = A(n.width ?? B[n.size] ?? 460), $ = A(n.height), E = A(n.maxHeight), z = A(n.maxWidth), U = Number(n.viewportGap ?? 5), W = Number.isFinite(U) ? Math.max(0, U) : 5, M = typeof n.borderRadius == "number" ? `${n.borderRadius}px` : n.borderRadius ?? "12px";
128
- return dn(/* @__PURE__ */ h(
127
+ const c = n.backgroundColor ?? n.backgroudColor, u = typeof c == "string" ? c : c?.[x], a = typeof u == "string" && /^(#|rgb\(|rgba\(|hsl\(|hsla\(|oklch\(|color\(|var\()/.test(u.trim()) ? u : null, B = { sm: 400, md: 560, lg: 720, xl: 960, full: "100%" }, P = ["center", "left", "right", "top", "bottom"].includes(n.placement) ? n.placement : "right", O = (b) => typeof b == "number" ? `${b}px` : b, q = O(n.width ?? B[n.size] ?? 460), A = O(n.height), E = O(n.maxHeight), F = O(n.maxWidth), Y = Number(n.viewportGap ?? 5), _ = Number.isFinite(Y) ? Math.max(0, Y) : 5, C = typeof n.borderRadius == "number" ? `${n.borderRadius}px` : n.borderRadius ?? "12px";
128
+ return kn(/* @__PURE__ */ h(
129
129
  "div",
130
130
  {
131
- ref: f,
132
- className: `pmn-overlay ${c ? "pmn-exiting" : "pmn-entering"} ${n.animation === !1 ? "pmn-no-animation" : ""} pmn-place-${R} ${n.mobileFullscreen ? "pmn-mobile-fullscreen" : ""}`,
133
- style: { padding: W, "--pmn-animation-duration": `${Math.min(1e3, Math.max(0, Number(n.animationDuration ?? 220) || 0))}ms` },
131
+ ref: g,
132
+ className: `pmn-overlay ${s ? "pmn-exiting" : "pmn-entering"} ${n.animation === !1 ? "pmn-no-animation" : ""} pmn-place-${P} ${n.mobileFullscreen ? "pmn-mobile-fullscreen" : ""}`,
133
+ style: { padding: _, "--pmn-animation-duration": `${Math.min(1e3, Math.max(0, Number(n.animationDuration ?? 220) || 0))}ms` },
134
134
  onMouseDown: (b) => {
135
135
  b.target === b.currentTarget && n.closeOnOverlay === !0 && m.current("overlay");
136
136
  },
@@ -143,53 +143,53 @@ function xn({ dialogRef: e, options: n, requestClose: r, children: t, exiting: c
143
143
  "aria-modal": "true",
144
144
  "aria-label": n.ariaLabel ?? "Dialog",
145
145
  "data-modal-theme": x,
146
- className: `pmn-dialog ${x === "dark" ? "dark" : ""} ${!s && u ? u : ""} ${n.className ?? ""}`,
147
- style: { "--pmn-width": q, "--pmn-gap": `${W}px`, ...$ !== void 0 ? { "--pmn-height": $ } : {}, ...E !== void 0 ? { "--pmn-max-height": E } : {}, ...z !== void 0 ? { "--pmn-max-width": z } : {}, borderRadius: M, ...s ? { backgroundColor: s } : {} },
146
+ className: `pmn-dialog ${x === "dark" ? "dark" : ""} ${!a && u ? u : ""} ${n.className ?? ""}`,
147
+ style: { "--pmn-width": q, "--pmn-gap": `${_}px`, ...A !== void 0 ? { "--pmn-height": A } : {}, ...E !== void 0 ? { "--pmn-max-height": E } : {}, ...F !== void 0 ? { "--pmn-max-width": F } : {}, borderRadius: C, ...a ? { backgroundColor: a } : {} },
148
148
  children: t
149
149
  }
150
150
  )
151
151
  }
152
152
  ), document.body);
153
153
  }
154
- function Xe({ back: e }) {
154
+ function un({ back: e }) {
155
155
  return /* @__PURE__ */ h("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", children: e ? /* @__PURE__ */ h("path", { d: "m15 18-6-6 6-6" }) : /* @__PURE__ */ h("path", { d: "M18 6 6 18M6 6l12 12" }) });
156
156
  }
157
- function kn({ options: e, screen: n, route: r, navigation: t, requestClose: c, translate: f }) {
157
+ function Bn({ options: e, screen: n, route: r, navigation: t, requestClose: s, translate: g, canGoBack: d }) {
158
158
  if (e.showHeader === !1) return null;
159
- const i = f ?? ((g) => g), m = n.showTitle ?? e.showTitle ?? !0, l = typeof n.title == "function" ? n.title({ t: i, route: r, navigation: t }) : n.title ?? r.name, y = { route: r, navigation: t, close: c, canGoBack: t.canGoBack, title: l, t: i }, C = n.renderHeader ?? e.renderHeader;
160
- if (C) return C(y);
161
- const x = n.renderHeaderRight ?? e.renderHeaderRight;
162
- return /* @__PURE__ */ me("header", { className: `pmn-header ${n.showHeaderBorder ?? e.showHeaderBorder ? "pmn-border-bottom" : ""} ${e.headerClassName ?? ""}`, children: [
163
- e.showBackButton !== !1 && t.canGoBack && /* @__PURE__ */ h("button", { type: "button", className: "pmn-icon-button", "aria-label": i("modal.back"), onClick: () => t.goBack(), children: /* @__PURE__ */ h(Xe, { back: !0 }) }),
164
- m ? /* @__PURE__ */ h("h2", { children: l }) : /* @__PURE__ */ h("div", { className: "pmn-header-spacer" }),
165
- x?.(y),
166
- e.showCloseButton !== !1 && /* @__PURE__ */ h("button", { type: "button", className: "pmn-icon-button", "aria-label": i("modal.close"), onClick: () => c("header"), children: /* @__PURE__ */ h(Xe, {}) })
159
+ const m = g ?? ((u) => u), p = n.showTitle ?? e.showTitle ?? !0, y = typeof n.title == "function" ? n.title({ t: m, route: r, navigation: t }) : n.title ?? r.name, R = { route: r, navigation: t, close: s, canGoBack: d, title: y, t: m }, x = n.renderHeader ?? e.renderHeader;
160
+ if (x) return x(R);
161
+ const c = n.renderHeaderRight ?? e.renderHeaderRight;
162
+ return /* @__PURE__ */ ue("header", { className: `pmn-header ${n.showHeaderBorder ?? e.showHeaderBorder ? "pmn-border-bottom" : ""} ${e.headerClassName ?? ""}`, children: [
163
+ (n.showBackButton ?? e.showBackButton) !== !1 && d && /* @__PURE__ */ h("button", { type: "button", className: "pmn-icon-button", "aria-label": m("modal.back"), onClick: () => t.goBack(), children: /* @__PURE__ */ h(un, { back: !0 }) }),
164
+ p ? /* @__PURE__ */ h("h2", { children: y }) : /* @__PURE__ */ h("div", { className: "pmn-header-spacer" }),
165
+ c?.(R),
166
+ e.showCloseButton !== !1 && /* @__PURE__ */ h("button", { type: "button", className: "pmn-icon-button", "aria-label": m("modal.close"), onClick: () => s("header"), children: /* @__PURE__ */ h(un, {}) })
167
167
  ] });
168
168
  }
169
- function En({ screen: e, options: n, override: r, route: t, navigation: c, requestClose: f, translate: i, onError: m, loadingApi: l }) {
170
- const [y, C] = ie(null), x = d(/* @__PURE__ */ new Set()), g = d(!0);
171
- H(() => (g.current = !0, () => {
172
- g.current = !1;
169
+ function qn({ screen: e, options: n, override: r, route: t, navigation: s, requestClose: g, translate: d, onError: m, loadingApi: p }) {
170
+ const [y, R] = le(null), x = l(/* @__PURE__ */ new Set()), c = l(!0);
171
+ W(() => (c.current = !0, () => {
172
+ c.current = !1;
173
173
  }), []);
174
- const u = i ?? ((b) => b), s = { ...n, ...e, ...r }, { showFooter: B, renderFooter: R, done: A, cancel: q, cancle: $ } = s, E = q ?? $, z = { route: t, navigation: c, close: f, t: u };
174
+ const u = d ?? ((b) => b), a = { ...n, ...e, ...r }, { showFooter: B, renderFooter: P, done: O, cancel: q, cancle: A } = a, E = q ?? A, F = { route: t, navigation: s, close: g, t: u };
175
175
  if (B === !1) return null;
176
- const U = `pmn-footer ${s.showFooterBorder ? "pmn-border-top" : ""} ${s.footerClassName ?? ""}`;
177
- if (typeof R == "function") return /* @__PURE__ */ h("footer", { className: U, children: R({ ...z, pending: x.current.size > 0 }) });
178
- const W = Array.isArray(s.actions) ? s.actions : null;
179
- if (!W && typeof A != "function" && typeof E != "function") return null;
180
- const M = async (b, T, j) => {
176
+ const Y = `pmn-footer ${a.showFooterBorder ? "pmn-border-top" : ""} ${a.footerClassName ?? ""}`;
177
+ if (typeof P == "function") return /* @__PURE__ */ h("footer", { className: Y, children: P({ ...F, pending: x.current.size > 0 }) });
178
+ const _ = Array.isArray(a.actions) ? a.actions : null;
179
+ if (!_ && typeof O != "function" && typeof E != "function") return null;
180
+ const C = async (b, T, D) => {
181
181
  if (x.current.has(b) || typeof T != "function") return;
182
- x.current.add(b), C(b);
183
- const F = l?.begin(t.key, j ?? s.loadingText ?? u("modal.processing"));
182
+ x.current.add(b), R(b);
183
+ const z = p?.begin(t.key, D ?? a.loadingText ?? u("modal.processing"));
184
184
  try {
185
- await T(z);
186
- } catch (N) {
187
- m?.(N, { phase: "footer", action: b, route: t });
185
+ await T(F);
186
+ } catch (M) {
187
+ m?.(M, { phase: "footer", action: b, route: t });
188
188
  } finally {
189
- l?.end(t.key, F), x.current.delete(b), g.current && C((N) => N === b ? null : N);
189
+ p?.end(t.key, z), x.current.delete(b), c.current && R((M) => M === b ? null : M);
190
190
  }
191
191
  };
192
- return W ? /* @__PURE__ */ h("footer", { className: U, children: W.filter((b) => !b.hidden).map((b) => {
192
+ return _ ? /* @__PURE__ */ h("footer", { className: Y, children: _.filter((b) => !b.hidden).map((b) => {
193
193
  const T = x.current.has(b.key) || b.loading === !0;
194
194
  return /* @__PURE__ */ h(
195
195
  "button",
@@ -197,25 +197,25 @@ function En({ screen: e, options: n, override: r, route: t, navigation: c, reque
197
197
  type: "button",
198
198
  disabled: b.disabled === !0 || T,
199
199
  className: `pmn-button ${b.variant === "primary" || b.variant === "danger" ? "pmn-button-primary" : "pmn-button-secondary"} ${b.variant === "danger" ? "pmn-button-danger" : ""}`,
200
- onClick: () => M(b.key, b.onClick, b.loadingText),
201
- children: T ? b.loadingText ?? s.loadingText ?? u("modal.processing") : b.label
200
+ onClick: () => C(b.key, b.onClick, b.loadingText),
201
+ children: T ? b.loadingText ?? a.loadingText ?? u("modal.processing") : b.label
202
202
  },
203
203
  b.key
204
204
  );
205
- }) }) : /* @__PURE__ */ me("footer", { className: U, children: [
206
- typeof E == "function" && /* @__PURE__ */ h("button", { type: "button", disabled: y !== null, onClick: () => M("cancel", E), className: "pmn-button pmn-button-secondary", children: s.cancelText ?? u("modal.cancel") }),
207
- typeof A == "function" && /* @__PURE__ */ h("button", { type: "button", disabled: y !== null || s.doneDisabled === !0, onClick: () => M("done", A), className: "pmn-button pmn-button-primary", children: y === "done" ? s.loadingText ?? u("modal.processing") : s.doneText ?? u("modal.done") })
205
+ }) }) : /* @__PURE__ */ ue("footer", { className: Y, children: [
206
+ typeof E == "function" && /* @__PURE__ */ h("button", { type: "button", disabled: y !== null, onClick: () => C("cancel", E), className: "pmn-button pmn-button-secondary", children: a.cancelText ?? u("modal.cancel") }),
207
+ typeof O == "function" && /* @__PURE__ */ h("button", { type: "button", disabled: y !== null || a.doneDisabled === !0, onClick: () => C("done", O), className: "pmn-button pmn-button-primary", children: y === "done" ? a.loadingText ?? u("modal.processing") : a.doneText ?? u("modal.done") })
208
208
  ] });
209
209
  }
210
- function Sn({ loading: e, translate: n }) {
210
+ function $n({ loading: e, translate: n }) {
211
211
  if (!e.visible) return null;
212
- const t = (n ?? ((f) => f))("modal.loading"), c = e.text ?? (t === "modal.loading" ? "加载中..." : t);
213
- return /* @__PURE__ */ h("div", { className: "pmn-loading-overlay", role: "status", "aria-live": "polite", "aria-busy": "true", children: /* @__PURE__ */ me("div", { className: "pmn-loading-content", children: [
212
+ const t = (n ?? ((g) => g))("modal.loading"), s = e.text ?? (t === "modal.loading" ? "加载中..." : t);
213
+ return /* @__PURE__ */ h("div", { className: "pmn-loading-overlay", role: "status", "aria-live": "polite", "aria-busy": "true", children: /* @__PURE__ */ ue("div", { className: "pmn-loading-content", children: [
214
214
  /* @__PURE__ */ h("span", { className: "pmn-spinner", "aria-hidden": "true" }),
215
- c && /* @__PURE__ */ h("span", { className: "pmn-loading-text", children: c })
215
+ s && /* @__PURE__ */ h("span", { className: "pmn-loading-text", children: s })
216
216
  ] }) });
217
217
  }
218
- class Cn extends Ne.Component {
218
+ class On extends Ne.Component {
219
219
  state = { error: null };
220
220
  static getDerivedStateFromError(n) {
221
221
  return { error: n };
@@ -227,285 +227,324 @@ class Cn extends Ne.Component {
227
227
  n.route?.key !== this.props.route?.key && this.state.error && this.setState({ error: null });
228
228
  }
229
229
  render() {
230
- return this.state.error ? /* @__PURE__ */ me("div", { role: "alert", className: "pmn-error-screen", children: [
230
+ return this.state.error ? /* @__PURE__ */ ue("div", { role: "alert", className: "pmn-error-screen", children: [
231
231
  /* @__PURE__ */ h("strong", { children: "页面加载失败" }),
232
232
  /* @__PURE__ */ h("p", { children: this.state.error.message }),
233
233
  /* @__PURE__ */ h("button", { type: "button", className: "pmn-button pmn-button-secondary", onClick: () => this.setState({ error: null }), children: "重试" })
234
234
  ] }) : this.props.children;
235
235
  }
236
236
  }
237
- const Rn = { success: "✓", error: "×", warning: "!", info: "i" };
238
- function Mn({ items: e, dismiss: n }) {
239
- return e.length ? /* @__PURE__ */ h("div", { className: "pmn-toast-region", "aria-label": "Notifications", children: e.map((r) => /* @__PURE__ */ me("div", { className: `pmn-toast pmn-toast-${r.type}`, role: r.type === "error" || r.type === "warning" ? "alert" : "status", children: [
240
- /* @__PURE__ */ h("span", { className: "pmn-toast-symbol", "aria-hidden": "true", children: Rn[r.type] }),
237
+ const Fn = { success: "✓", error: "×", warning: "!", info: "i" };
238
+ function jn({ items: e, dismiss: n }) {
239
+ return e.length ? /* @__PURE__ */ h("div", { className: "pmn-toast-region", "aria-label": "Notifications", children: e.map((r) => /* @__PURE__ */ ue("div", { className: `pmn-toast pmn-toast-${r.type}`, role: r.type === "error" || r.type === "warning" ? "alert" : "status", children: [
240
+ /* @__PURE__ */ h("span", { className: "pmn-toast-symbol", "aria-hidden": "true", children: Fn[r.type] }),
241
241
  /* @__PURE__ */ h("span", { className: "pmn-toast-message", children: r.message }),
242
242
  r.dismissible && /* @__PURE__ */ h("button", { type: "button", className: "pmn-toast-close", "aria-label": "Dismiss notification", onClick: () => n(r.id), children: "×" })
243
243
  ] }, r.id)) }) : null;
244
244
  }
245
- function Tn(e, n) {
246
- const r = d(0), t = d(/* @__PURE__ */ new Map()), c = v((m) => {
247
- clearTimeout(t.current.get(m)), t.current.delete(m), n.current && e.current.publish(e.current.getSnapshot().filter((l) => l.id !== m));
248
- }, []), f = v((m, l = {}) => {
245
+ function Dn(e, n) {
246
+ const r = l(0), t = l(/* @__PURE__ */ new Map()), s = w((m) => {
247
+ clearTimeout(t.current.get(m)), t.current.delete(m), n.current && e.current.publish(e.current.getSnapshot().filter((p) => p.id !== m));
248
+ }, []), g = w((m, p = {}) => {
249
249
  if (typeof m != "string" || !m.trim()) throw new TypeError("[react-modal-navigation] toast message must be a non-empty string");
250
- const y = typeof l == "string" ? { type: l } : l ?? {}, C = ["success", "error", "warning", "info"].includes(y.type) ? y.type : "info", x = ++r.current, g = Number.isFinite(y.duration) ? Math.max(0, y.duration) : 3e3;
250
+ const y = typeof p == "string" ? { type: p } : p ?? {}, R = ["success", "error", "warning", "info"].includes(y.type) ? y.type : "info", x = ++r.current, c = Number.isFinite(y.duration) ? Math.max(0, y.duration) : 3e3;
251
251
  if (!n.current) return null;
252
- const u = e.current.getSnapshot(), s = u.slice(0, Math.max(0, u.length - 4));
253
- for (const B of s)
252
+ const u = e.current.getSnapshot(), a = u.slice(0, Math.max(0, u.length - 4));
253
+ for (const B of a)
254
254
  clearTimeout(t.current.get(B.id)), t.current.delete(B.id);
255
- return e.current.publish([...u.slice(-4), { id: x, message: m, type: C, dismissible: y.dismissible !== !1 }]), g > 0 && t.current.set(x, setTimeout(() => c(x), g)), x;
256
- }, [c]), i = K(() => {
257
- const m = (l, y) => f(l, y);
258
- for (const l of ["success", "error", "warning", "info"]) m[l] = (y, C = {}) => f(y, { ...C, type: l });
259
- return m.promise = async (l, y, C = {}) => {
260
- const x = f(y.loading, { ...C, type: "info", duration: 0 });
255
+ return e.current.publish([...u.slice(-4), { id: x, message: m, type: R, dismissible: y.dismissible !== !1 }]), c > 0 && t.current.set(x, setTimeout(() => s(x), c)), x;
256
+ }, [s]), d = K(() => {
257
+ const m = (p, y) => g(p, y);
258
+ for (const p of ["success", "error", "warning", "info"]) m[p] = (y, R = {}) => g(y, { ...R, type: p });
259
+ return m.promise = async (p, y, R = {}) => {
260
+ const x = g(y.loading, { ...R, type: "info", duration: 0 });
261
261
  try {
262
- const g = await (typeof l == "function" ? l() : l);
263
- x != null && c(x);
264
- const u = typeof y.success == "function" ? y.success(g) : y.success;
265
- return u && f(u, { ...C, type: "success" }), g;
266
- } catch (g) {
267
- x != null && c(x);
268
- const u = typeof y.error == "function" ? y.error(g) : y.error;
269
- throw u && f(u, { ...C, type: "error" }), g;
262
+ const c = await (typeof p == "function" ? p() : p);
263
+ x != null && s(x);
264
+ const u = typeof y.success == "function" ? y.success(c) : y.success;
265
+ return u && g(u, { ...R, type: "success" }), c;
266
+ } catch (c) {
267
+ x != null && s(x);
268
+ const u = typeof y.error == "function" ? y.error(c) : y.error;
269
+ throw u && g(u, { ...R, type: "error" }), c;
270
270
  }
271
- }, m.dismiss = c, m.clear = () => {
272
- for (const l of t.current.values()) clearTimeout(l);
271
+ }, m.dismiss = s, m.clear = () => {
272
+ for (const p of t.current.values()) clearTimeout(p);
273
273
  t.current.clear(), e.current.publish([]);
274
274
  }, m;
275
- }, [f, c]);
276
- return H(() => () => {
275
+ }, [g, s]);
276
+ return W(() => () => {
277
277
  for (const m of t.current.values()) clearTimeout(m);
278
278
  t.current.clear();
279
- }, []), { toast: i, dismissToast: c };
279
+ }, []), { toast: d, dismissToast: s };
280
280
  }
281
- function Nn(e, n, r) {
282
- const t = d(/* @__PURE__ */ new Map()), c = d(0), f = v(() => {
281
+ function zn(e, n, r) {
282
+ const t = l(/* @__PURE__ */ new Map()), s = l(0), g = w(() => {
283
283
  if (!n.current) return;
284
- const g = [...t.current.values()], u = { visible: g.length > 0, text: g.at(-1)?.text ?? null, count: g.length }, s = e.current.getSnapshot();
285
- (s.visible !== u.visible || s.text !== u.text || s.count !== u.count) && e.current.publish(u);
286
- }, []), i = v((g, u) => {
287
- if (!n.current || g !== "global" && r.current !== g) return null;
288
- const s = ++c.current;
289
- return t.current.set(s, { owner: g, text: u }), f(), s;
290
- }, [f]), m = v((g, u) => {
284
+ const c = [...t.current.values()], u = { visible: c.length > 0, text: c.at(-1)?.text ?? null, count: c.length }, a = e.current.getSnapshot();
285
+ (a.visible !== u.visible || a.text !== u.text || a.count !== u.count) && e.current.publish(u);
286
+ }, []), d = w((c, u) => {
287
+ if (!n.current || c !== "global" && r.current !== c) return null;
288
+ const a = ++s.current;
289
+ return t.current.set(a, { owner: c, text: u }), g(), a;
290
+ }, [g]), m = w((c, u) => {
291
291
  if (u != null)
292
- t.current.get(u)?.owner === g && t.current.delete(u);
292
+ t.current.get(u)?.owner === c && t.current.delete(u);
293
293
  else
294
- for (const [s, B] of t.current) B.owner === g && t.current.delete(s);
295
- f();
296
- }, [f]), l = v((g, u) => {
297
- g ? (m("global"), i("global", u)) : m("global");
298
- }, [i, m]), y = v((g, u, s) => {
299
- u ? (m(g), i(g, s)) : m(g);
300
- }, [i, m]);
301
- return { loadingApi: K(() => ({ setLoading: l, setScreenLoading: y, begin: i, end: m }), [l, y, i, m]), refreshLoading: f, loadingTasks: t, setLoading: l };
302
- }
303
- const Pn = Ne.memo(function({ store: n, translate: r }) {
304
- const t = be(n.subscribe, n.getSnapshot, n.getSnapshot);
305
- return /* @__PURE__ */ h(Sn, { loading: t, translate: r });
306
- }), Ln = Ne.memo(function({ store: n, dismiss: r }) {
307
- const t = be(n.subscribe, n.getSnapshot, n.getSnapshot);
308
- return /* @__PURE__ */ h(Mn, { items: t, dismiss: r });
309
- }), Bn = Ne.memo(function({ store: n, routeKey: r, ...t }) {
310
- const c = be(n.subscribe, n.getSnapshot, n.getSnapshot);
311
- return /* @__PURE__ */ h(En, { ...t, override: c[r] });
312
- }), An = Ne.memo(function({ route: n, screen: r, navigation: t, focused: c, resultEvent: f, setFooter: i, loadingApi: m, loadingStore: l, bodyClassName: y, notifyError: C, registerDirtyGuard: x }) {
313
- const g = r.component, u = K(() => ({ isFocused: c, resultEvent: f, routeKey: n.key, setFooter: i }), [c, f, n.key, i]), s = K(() => ({
314
- setLoading: (R, A) => m.setScreenLoading(n.key, R, A),
315
- showLoading: (R) => m.begin(n.key, R),
316
- hideLoading: (R) => m.end(n.key, R)
317
- }), [m, n.key]), B = K(() => ({ routeKey: n.key, registerDirtyGuard: x }), [n.key, x]);
318
- return /* @__PURE__ */ h(on.Provider, { value: n, children: /* @__PURE__ */ h(tn.Provider, { value: B, children: /* @__PURE__ */ h(je.Provider, { value: u, children: /* @__PURE__ */ h(Fe.Provider, { value: s, children: /* @__PURE__ */ h(Ye.Provider, { value: l, children: /* @__PURE__ */ h("div", { hidden: !c, inert: !c, "data-modal-route-key": n.key, tabIndex: -1, className: `pmn-body ${y ?? ""}`, children: /* @__PURE__ */ h(Cn, { route: n, onError: C, children: /* @__PURE__ */ h(g, { route: n, navigation: t }) }) }) }) }) }) }) });
294
+ for (const [a, B] of t.current) B.owner === c && t.current.delete(a);
295
+ g();
296
+ }, [g]), p = w((c, u) => {
297
+ c ? (m("global"), d("global", u)) : m("global");
298
+ }, [d, m]), y = w((c, u, a) => {
299
+ u ? (m(c), d(c, a)) : m(c);
300
+ }, [d, m]);
301
+ return { loadingApi: K(() => ({ setLoading: p, setScreenLoading: y, begin: d, end: m }), [p, y, d, m]), refreshLoading: g, loadingTasks: t, setLoading: p };
302
+ }
303
+ const In = Ne.memo(function({ store: n, translate: r }) {
304
+ const t = fe(n.subscribe, n.getSnapshot, n.getSnapshot);
305
+ return /* @__PURE__ */ h($n, { loading: t, translate: r });
306
+ }), Kn = Ne.memo(function({ store: n, dismiss: r }) {
307
+ const t = fe(n.subscribe, n.getSnapshot, n.getSnapshot);
308
+ return /* @__PURE__ */ h(jn, { items: t, dismiss: r });
309
+ }), Gn = Ne.memo(function({ store: n, routeKey: r, ...t }) {
310
+ const s = fe(n.subscribe, n.getSnapshot, n.getSnapshot);
311
+ return /* @__PURE__ */ h(qn, { ...t, override: s[r] });
312
+ }), Hn = Ne.memo(function({ route: n, screen: r, navigation: t, focused: s, resultEvent: g, setFooter: d, loadingApi: m, loadingStore: p, bodyClassName: y, notifyError: R, registerDirtyGuard: x, pageMotion: c }) {
313
+ const u = r.component, a = l(null), B = l(!1);
314
+ Fe(() => {
315
+ const A = s && !B.current;
316
+ if (B.current = s, !A || !c?.enabled || !a.current?.animate) return;
317
+ const E = c.direction === "back" ? -c.distance : c.distance, F = a.current.animate([
318
+ { opacity: 0.18, transform: `translate3d(${E}px,0,0) scale(.985)` },
319
+ { opacity: 1, transform: "translate3d(0,0,0)" }
320
+ ], { duration: c.duration, easing: "cubic-bezier(.22,1,.36,1)" });
321
+ return () => F.cancel();
322
+ }, [s, c?.enabled, c?.direction, c?.duration, c?.distance]);
323
+ const P = K(() => ({ isFocused: s, resultEvent: g, routeKey: n.key, setFooter: d }), [s, g, n.key, d]), O = K(() => ({
324
+ setLoading: (A, E) => m.setScreenLoading(n.key, A, E),
325
+ showLoading: (A) => m.begin(n.key, A),
326
+ hideLoading: (A) => m.end(n.key, A)
327
+ }), [m, n.key]), q = K(() => ({ routeKey: n.key, registerDirtyGuard: x }), [n.key, x]);
328
+ return /* @__PURE__ */ h(hn.Provider, { value: n, children: /* @__PURE__ */ h(fn.Provider, { value: q, children: /* @__PURE__ */ h(je.Provider, { value: P, children: /* @__PURE__ */ h(De.Provider, { value: O, children: /* @__PURE__ */ h(Ze.Provider, { value: p, children: /* @__PURE__ */ h("div", { ref: a, hidden: !s, inert: !s, "data-modal-route-key": n.key, tabIndex: -1, className: `pmn-body ${s && c?.enabled && typeof Element < "u" && !Element.prototype.animate ? `pmn-page-enter pmn-page-${c.direction}` : ""} ${y ?? ""}`, style: s && c?.enabled ? { "--pmn-page-duration": `${c.duration}ms`, "--pmn-page-distance": `${c.distance}px` } : void 0, children: /* @__PURE__ */ h(On, { route: n, onError: R, children: /* @__PURE__ */ h(u, { route: n, navigation: t }) }) }) }) }) }) }) });
319
329
  });
320
- function qn({ config: e, initialScreen: n, params: r, options: t, translate: c, onRequestClose: f, onOpened: i, registerLoading: m, notifyError: l, error: y, clearError: C, registerDirtyGuard: x, canNavigate: g, exiting: u = !1 }) {
321
- const [s, B] = ln(qe, null, () => an(n ?? e.initialRoute, r)), R = d(null);
322
- R.current || (R.current = hn({ canGoBack: s.length > 1, stack: s, currentRoute: s.at(-1) }));
323
- const A = d(null), q = d(null), $ = d(null);
324
- A.current || (A.current = ze({ visible: !1, text: null, count: 0 })), q.current || (q.current = ze({})), $.current || ($.current = ze([]));
325
- const E = d(!0), z = d(0), { toast: U, dismissToast: W } = Tn($, E);
326
- H(() => (E.current = !0, () => {
327
- E.current = !1, z.current++;
330
+ function Un({ config: e, initialScreen: n, params: r, options: t, translate: s, onRequestClose: g, onOpened: d, registerLoading: m, notifyError: p, error: y, clearError: R, registerDirtyGuard: x, canNavigate: c, exiting: u = !1 }) {
331
+ const [a, B] = wn($e, null, () => bn(n ?? e.initialRoute, r)), P = l(null);
332
+ P.current || (P.current = Cn({ canGoBack: a.length > 1, stack: a, currentRoute: a.at(-1) }));
333
+ const O = l(null), q = l(null), A = l(null);
334
+ O.current || (O.current = Ue({ visible: !1, text: null, count: 0 })), q.current || (q.current = Ue({})), A.current || (A.current = Ue([]));
335
+ const E = l(!0), F = l(0), { toast: Y, dismissToast: _ } = Dn(A, E);
336
+ W(() => (E.current = !0, () => {
337
+ E.current = !1, F.current++;
328
338
  }), []);
329
- const [M, b] = ie({}), T = d(/* @__PURE__ */ new Map()), j = d(null), F = d(null), N = d(!1), V = d(!1), L = d(/* @__PURE__ */ new Map()), ne = d(0), te = v((o, w, P) => {
330
- for (const [I, ce] of L.current)
331
- o.includes(ce.key) && (L.current.delete(I), ce.resolve({ status: w, ...w === "returned" ? { value: P } : {} }));
332
- }, []), O = d(s);
333
- O.current = s;
334
- const le = d(g);
335
- le.current = g;
336
- const re = d(!1), Ee = d(0), G = s.at(-1), D = G.key, ue = d(D);
337
- ue.current = D;
338
- const { loadingApi: Se, refreshLoading: Ce, loadingTasks: ye, setLoading: pe } = Nn(A, E, ue), oe = e.screens, Pe = A, ve = d(m);
339
- ve.current = m, H(() => (ve.current?.({ setLoading: pe }), () => ve.current?.(null)), [pe]);
340
- const Le = v((o, w) => {
339
+ const [C, b] = le({}), T = l(/* @__PURE__ */ new Map()), D = l(null), z = l(null), M = l(null), G = l(null), $ = l(null), se = l(!1), ae = l(!1), Z = l(/* @__PURE__ */ new Map()), ge = l(0), ie = w((o, v, N) => {
340
+ for (const [L, U] of Z.current)
341
+ o.includes(U.key) && (Z.current.delete(L), U.resolve({ status: v, ...v === "returned" ? { value: N } : {} }));
342
+ }, []), J = l(a);
343
+ J.current = a;
344
+ const he = l(c);
345
+ he.current = c;
346
+ const ce = l(!1), de = l(0), V = a.at(-1), I = V.key, ke = l({ key: I, depth: a.length }), Ee = ke.current, be = Ee.key !== I, Pe = a.length < Ee.depth ? "back" : "forward";
347
+ be && (ke.current = { key: I, depth: a.length });
348
+ const Se = Math.min(1e3, Math.max(0, Number(t.pageAnimationDuration ?? 360) || 0)), re = { distance: Math.min(300, Math.max(0, Number(t.pageAnimationDistance ?? 96) || 0)), enabled: t.pageAnimation !== !1 && t.animation !== !1 && Se > 0 && be, direction: Pe, duration: Se }, Re = l(I);
349
+ Re.current = I;
350
+ const { loadingApi: ye, refreshLoading: Le, loadingTasks: i, setLoading: f } = zn(O, E, Re), S = e.screens, k = O, H = l(m);
351
+ H.current = m, W(() => (H.current?.({ setLoading: f }), () => H.current?.(null)), [f]);
352
+ const Q = w((o, v) => {
341
353
  if (!E.current) return;
342
- const P = q.current.getSnapshot();
343
- if (w === null) {
344
- if (!(o in P)) return;
345
- const I = { ...P };
346
- delete I[o], q.current.publish(I);
354
+ const N = q.current.getSnapshot();
355
+ if (v === null) {
356
+ if (!(o in N)) return;
357
+ const L = { ...N };
358
+ delete L[o], q.current.publish(L);
347
359
  return;
348
360
  }
349
- P[o] !== w && q.current.publish({ ...P, [o]: w });
350
- }, []), Re = v(() => {
361
+ N[o] !== v && q.current.publish({ ...N, [o]: v });
362
+ }, []), ne = w(() => {
351
363
  if (typeof document > "u") return;
352
364
  const o = document.activeElement;
353
- if (!(o instanceof HTMLElement) || !j.current?.contains(o)) return;
354
- const w = o.closest("[data-modal-route-key]");
355
- w && T.current.set(w.dataset.modalRouteKey, o), j.current.focus({ preventScroll: !0 });
356
- }, []), Me = v((o) => {
357
- if (!Object.prototype.hasOwnProperty.call(oe, o)) throw new Error(`[react-modal-navigation] Unknown modal screen: ${o}`);
358
- }, [oe]), de = v((o, w) => {
365
+ if (!(o instanceof HTMLElement) || !D.current?.contains(o)) return;
366
+ const v = o.closest("[data-modal-route-key]");
367
+ v && T.current.set(v.dataset.modalRouteKey, o), D.current.focus({ preventScroll: !0 });
368
+ }, []), me = w((o) => {
369
+ if (!Object.prototype.hasOwnProperty.call(S, o)) throw new Error(`[react-modal-navigation] Unknown modal screen: ${o}`);
370
+ }, [S]), te = w((o, v) => {
359
371
  try {
360
- Promise.resolve(t[o]?.(w)).catch((P) => l(P, { phase: o }));
361
- } catch (P) {
362
- l(P, { phase: o });
372
+ Promise.resolve(t[o]?.(v)).catch((N) => p(N, { phase: o }));
373
+ } catch (N) {
374
+ p(N, { phase: o });
363
375
  }
364
- }, [t, l]), Z = v(async (o, w, P, I) => {
365
- if (!E.current || V.current) return !1;
366
- const ce = z.current, X = O.current, De = X.at(-1);
367
- if (o !== "BACK" && Me(w), o === "BACK" && X.length <= 1) return !1;
368
- const Ve = o === "NAVIGATE" ? X.findIndex((ke) => ke.name === w) : -1, Ie = o === "RESET" ? X : o === "BACK" || o === "REPLACE" ? [De] : Ve >= 0 ? X.slice(Ve + 1) : [];
369
- V.current = !0;
376
+ }, [t, p]), X = w(async (o, v, N, L) => {
377
+ if (!E.current || ae.current) return !1;
378
+ const U = F.current, j = J.current, qe = j.at(-1);
379
+ if (o !== "BACK" && me(v), o === "BACK" && j.length <= 1) return !1;
380
+ const sn = o === "NAVIGATE" ? j.findIndex((Me) => Me.name === v) : -1, Ge = o === "RESET" ? j : o === "BACK" || o === "REPLACE" ? [qe] : sn >= 0 ? j.slice(sn + 1) : [];
381
+ ae.current = !0;
370
382
  try {
371
- if (Ie.length && le.current && !await le.current(Ie.map(($e) => $e.key), {
383
+ if (Ge.length && he.current && !await he.current(Ge.map((He) => He.key), {
372
384
  reason: "navigation",
373
385
  action: o,
374
- from: De,
375
- to: o === "BACK" ? X.at(-2)?.name : w
376
- }) || !E.current || ce !== z.current || O.current.at(-1)?.key !== De.key) return !1;
377
- if (o === "BACK" && I !== void 0) {
378
- const Ae = X.at(-2);
379
- b(($e) => ({ ...$e, [Ae.key]: { id: ++Ee.current, data: I } }));
386
+ from: qe,
387
+ to: o === "BACK" ? j.at(-2)?.name : v
388
+ }) || !E.current || U !== F.current || J.current.at(-1)?.key !== qe.key) return !1;
389
+ if (o === "BACK" && L !== void 0) {
390
+ const xe = j.at(-2);
391
+ b((He) => ({ ...He, [xe.key]: { id: ++de.current, data: L } }));
380
392
  }
381
- o === "RESET" && b({}), te(Ie.map((Ae) => Ae.key), o === "BACK" ? "returned" : "removed", I), Re();
382
- const ke = { type: o, name: w, params: P };
383
- return O.current = qe(O.current, ke), B(ke), !0;
384
- } catch (ke) {
385
- return E.current && l(ke, { phase: "navigationGuard", action: o }), !1;
393
+ o === "RESET" && b({}), ie(Ge.map((xe) => xe.key), o === "BACK" ? "returned" : "removed", L);
394
+ const Me = [...z.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((xe) => xe.dataset.modalRouteKey === qe.key);
395
+ M.current = Me?.cloneNode(!0) ?? null, ne();
396
+ const cn = { type: o, name: v, params: N };
397
+ return J.current = $e(J.current, cn), B(cn), !0;
398
+ } catch (Me) {
399
+ return E.current && p(Me, { phase: "navigationGuard", action: o }), !1;
386
400
  } finally {
387
- V.current = !1;
401
+ ae.current = !1;
388
402
  }
389
- }, [Me, Re, l, te]), a = v((o, w) => Z("NAVIGATE", o, w), [Z]), p = v(async (o, w) => {
403
+ }, [me, ne, p, ie]), Ce = w((o, v) => X("NAVIGATE", o, v), [X]), ve = w(async (o, v) => {
390
404
  if (!E.current) return { status: "cancelled" };
391
- if (O.current, !await Z("NAVIGATE", o, w) || !E.current) return { status: "cancelled" };
392
- const I = O.current.at(-1);
393
- return !I || I.name !== o ? { status: "cancelled" } : new Promise((ce) => {
394
- const X = ++ne.current;
395
- L.current.set(X, { key: I.key, resolve: ce });
405
+ if (J.current, !await X("NAVIGATE", o, v) || !E.current) return { status: "cancelled" };
406
+ const L = J.current.at(-1);
407
+ return !L || L.name !== o ? { status: "cancelled" } : new Promise((U) => {
408
+ const j = ++ge.current;
409
+ Z.current.set(j, { key: L.key, resolve: U });
396
410
  });
397
- }, [Z]), S = v((o, w) => Z("REPLACE", o, w), [Z]), k = v((o, w) => Z("RESET", o, w), [Z]), Y = v((o) => {
411
+ }, [X]), we = w((o, v) => X("REPLACE", o, v), [X]), Je = w((o, v) => X("RESET", o, v), [X]), Xe = w((o) => {
398
412
  if (!o || typeof o != "object" || Array.isArray(o)) throw new TypeError("[react-modal-navigation] setParams expects an object");
399
413
  if (!E.current) return;
400
- const w = { type: "SET_PARAMS", params: o };
401
- O.current = qe(O.current, w), B(w);
402
- }, []), _ = v((o) => {
414
+ const v = { type: "SET_PARAMS", params: o };
415
+ J.current = $e(J.current, v), B(v);
416
+ }, []), en = w((o) => {
403
417
  if (!o || typeof o != "object" || Array.isArray(o)) throw new TypeError("[react-modal-navigation] setOptions expects an object");
404
418
  if (!E.current) return;
405
- const w = { type: "SET_OPTIONS", options: o };
406
- O.current = qe(O.current, w), B(w);
407
- }, []), J = v((o) => Z("BACK", null, void 0, o), [Z]), ae = v((o, w) => !E.current || Pe.current.getSnapshot().visible && t.lockCloseWhileLoading !== !1 ? Promise.resolve(!1) : f(o, w, { route: G, stack: s }), [t.lockCloseWhileLoading, f, G, s]), se = d(ae);
408
- se.current = ae;
409
- const fe = v((o) => se.current("api", o), []), we = K(() => ({ navigate: a, navigateAsync: p, replace: S, reset: k, setParams: Y, setOptions: _, goBack: J, close: fe, setLoading: pe }), [a, p, S, k, Y, _, J, fe, pe]), xe = K(() => ({ canGoBack: s.length > 1, stack: s, currentRoute: G }), [s]);
410
- Qe(() => R.current.publish(xe), [xe]);
411
- const he = d(null);
412
- he.current || (he.current = Object.defineProperties({}, {
413
- canGoBack: { enumerable: !0, get: () => R.current.getSnapshot().canGoBack },
414
- stack: { enumerable: !0, get: () => R.current.getSnapshot().stack },
415
- currentRoute: { enumerable: !0, get: () => R.current.getSnapshot().currentRoute }
419
+ const v = { type: "SET_OPTIONS", options: o };
420
+ J.current = $e(J.current, v), B(v);
421
+ }, []), nn = w((o) => X("BACK", null, void 0, o), [X]), Te = w((o, v) => !E.current || k.current.getSnapshot().visible && t.lockCloseWhileLoading !== !1 ? Promise.resolve(!1) : g(o, v, { route: V, stack: a }), [t.lockCloseWhileLoading, g, V, a]), tn = l(Te);
422
+ tn.current = Te;
423
+ const rn = w((o) => tn.current("api", o), []), Ie = K(() => ({ navigate: Ce, navigateAsync: ve, replace: we, reset: Je, setParams: Xe, setOptions: en, goBack: nn, close: rn, setLoading: f }), [Ce, ve, we, Je, Xe, en, nn, rn, f]), on = K(() => ({ canGoBack: a.length > 1, stack: a, currentRoute: V }), [a]);
424
+ Fe(() => P.current.publish(on), [on]);
425
+ const Ke = l(null);
426
+ Ke.current || (Ke.current = Object.defineProperties({}, {
427
+ canGoBack: { enumerable: !0, get: () => P.current.getSnapshot().canGoBack },
428
+ stack: { enumerable: !0, get: () => P.current.getSnapshot().stack },
429
+ currentRoute: { enumerable: !0, get: () => P.current.getSnapshot().currentRoute }
416
430
  }));
417
- const Be = K(() => Object.assign(he.current, we), [we]);
418
- Qe(() => {
419
- N.current = !1;
420
- const o = [...j.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((I) => I.dataset.modalRouteKey === D);
431
+ const Be = K(() => Object.assign(Ke.current, Ie), [Ie]);
432
+ Fe(() => {
433
+ const o = M.current;
434
+ if (M.current = null, G.current?.cancel?.(), G.current = null, z.current?.querySelectorAll("[data-pmn-outgoing]").forEach((j) => j.remove()), !be || !re.enabled || !o || !z.current || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) return;
435
+ const v = z.current;
436
+ o.removeAttribute("hidden"), o.removeAttribute("tabindex"), o.setAttribute("aria-hidden", "true"), o.setAttribute("inert", ""), o.dataset.pmnOutgoing = "true", o.querySelectorAll("[id]").forEach((j) => j.removeAttribute("id")), o.querySelectorAll("[autofocus]").forEach((j) => j.removeAttribute("autofocus")), o.style.cssText += ";position:absolute;inset:0;width:100%;height:100%;z-index:1;pointer-events:none;overflow:hidden;", v.appendChild(o);
437
+ const N = re.direction === "back" ? 1 : -1, L = () => {
438
+ o.remove(), G.current === U && (G.current = null);
439
+ };
440
+ let U;
441
+ if (o.animate)
442
+ U = o.animate([
443
+ { opacity: 1, transform: "translate3d(0,0,0)" },
444
+ { opacity: 0.45, transform: `translate3d(${N * re.distance}px,0,0) scale(.985)` }
445
+ ], { duration: re.duration, easing: "cubic-bezier(.22,1,.36,1)", fill: "forwards" }), U.addEventListener("finish", L, { once: !0 }), U.addEventListener("cancel", L, { once: !0 }), G.current = U;
446
+ else {
447
+ o.classList.add("pmn-page-exit", `pmn-page-exit-${re.direction}`), o.style.setProperty("--pmn-page-duration", `${re.duration}ms`), o.style.setProperty("--pmn-page-distance", `${re.distance}px`);
448
+ const j = setTimeout(L, re.duration + 40);
449
+ U = { cancel: () => {
450
+ clearTimeout(j), L();
451
+ } }, G.current = U;
452
+ }
453
+ return () => {
454
+ U?.cancel?.(), o.remove();
455
+ };
456
+ }, [I]), Fe(() => {
457
+ se.current = !1;
458
+ const o = [...D.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((L) => L.dataset.modalRouteKey === I);
421
459
  if (!o) return;
422
- const w = T.current.get(D);
423
- (w?.isConnected && o.contains(w) && !w.matches(":disabled") && !w.closest("[inert], [hidden]") ? w : o).focus({ preventScroll: !0 });
424
- }, [D]), H(() => {
460
+ const v = T.current.get(I);
461
+ (v?.isConnected && o.contains(v) && !v.matches(":disabled") && !v.closest("[inert], [hidden]") ? v : o).focus({ preventScroll: !0 });
462
+ }, [I]), W(() => {
425
463
  let o = !1;
426
- for (const [P, I] of ye.current)
427
- I.owner !== "global" && I.owner !== D && (ye.current.delete(P), o = !0);
428
- o && Ce();
429
- const w = new Set(s.map((P) => P.key));
430
- b((P) => {
431
- const I = Object.keys(P).filter((X) => !w.has(X));
432
- if (!I.length) return P;
433
- const ce = { ...P };
434
- return I.forEach((X) => delete ce[X]), ce;
464
+ for (const [N, L] of i.current)
465
+ L.owner !== "global" && L.owner !== I && (i.current.delete(N), o = !0);
466
+ o && Le();
467
+ const v = new Set(a.map((N) => N.key));
468
+ b((N) => {
469
+ const L = Object.keys(N).filter((j) => !v.has(j));
470
+ if (!L.length) return N;
471
+ const U = { ...N };
472
+ return L.forEach((j) => delete U[j]), U;
435
473
  });
436
- for (const P of T.current.keys()) w.has(P) || T.current.delete(P);
437
- }, [D, s, Ce]), H(() => {
438
- if (F.current?.key !== D) {
439
- if (F.current) {
440
- const o = { from: F.current, to: G, stack: s };
441
- de("onBlur", { route: F.current, ...o }), de("onNavigate", o), de("onRouteChange", o);
474
+ for (const N of T.current.keys()) v.has(N) || T.current.delete(N);
475
+ }, [I, a, Le]), W(() => {
476
+ if ($.current?.key !== I) {
477
+ if ($.current) {
478
+ const o = { from: $.current, to: V, stack: a };
479
+ te("onBlur", { route: $.current, ...o }), te("onNavigate", o), te("onRouteChange", o);
442
480
  }
443
- de("onFocus", { route: G, stack: s }), F.current = G;
481
+ te("onFocus", { route: V, stack: a }), $.current = V;
444
482
  }
445
- }, [G, D, s, de]), H(() => () => {
446
- ye.current.clear(), T.current.clear();
447
- for (const o of L.current.values()) o.resolve({ status: "dismissed" });
448
- L.current.clear();
449
- }, []), H(() => {
450
- re.current || (re.current = !0, i?.({ route: G, stack: s }));
483
+ }, [V, I, a, te]), W(() => () => {
484
+ i.current.clear(), T.current.clear();
485
+ for (const o of Z.current.values()) o.resolve({ status: "dismissed" });
486
+ Z.current.clear();
487
+ }, []), W(() => {
488
+ ce.current || (ce.current = !0, d?.({ route: V, stack: a }));
451
489
  }, []);
452
- const cn = K(() => bn(s, oe, t.maxCachedScreens), [s, oe, t.maxCachedScreens]), _e = K(() => ({ ...oe[G.name], ...G.options ?? {} }), [oe, G.name, G.options]);
453
- return /* @__PURE__ */ h(rn.Provider, { value: U, children: /* @__PURE__ */ h(fn.Provider, { value: $.current, children: /* @__PURE__ */ h(pn.Provider, { value: q.current, children: /* @__PURE__ */ h(mn.Provider, { value: Be, children: /* @__PURE__ */ h(Ue.Provider, { value: we, children: /* @__PURE__ */ h(We.Provider, { value: R.current, children: /* @__PURE__ */ h(Fe.Provider, { value: Se, children: /* @__PURE__ */ me(xn, { dialogRef: j, options: t, requestClose: ae, exiting: u, children: [
454
- /* @__PURE__ */ h(kn, { options: t, screen: _e, route: G, navigation: Be, requestClose: ae, translate: c }),
455
- /* @__PURE__ */ h("main", { className: "pmn-main", children: cn.map((o) => /* @__PURE__ */ h(
456
- An,
490
+ const vn = K(() => Mn(a, S, t.maxCachedScreens), [a, S, t.maxCachedScreens]), an = K(() => ({ ...S[V.name], ...V.options ?? {} }), [S, V.name, V.options]);
491
+ return /* @__PURE__ */ h(gn.Provider, { value: Y, children: /* @__PURE__ */ h(Rn.Provider, { value: A.current, children: /* @__PURE__ */ h(Sn.Provider, { value: q.current, children: /* @__PURE__ */ h(En.Provider, { value: Be, children: /* @__PURE__ */ h(Ve.Provider, { value: Ie, children: /* @__PURE__ */ h(Qe.Provider, { value: P.current, children: /* @__PURE__ */ h(De.Provider, { value: ye, children: /* @__PURE__ */ ue(Ln, { dialogRef: D, options: t, requestClose: Te, exiting: u, children: [
492
+ /* @__PURE__ */ h(Bn, { options: t, screen: an, route: V, navigation: Be, requestClose: Te, translate: s, canGoBack: a.length > 1 }),
493
+ /* @__PURE__ */ h("main", { ref: z, className: "pmn-main", children: vn.map((o) => /* @__PURE__ */ h(
494
+ Hn,
457
495
  {
458
496
  route: o,
459
- screen: oe[o.name],
497
+ screen: S[o.name],
460
498
  navigation: Be,
461
- focused: o.key === D,
462
- resultEvent: M[o.key] ?? null,
499
+ focused: o.key === I,
500
+ resultEvent: C[o.key] ?? null,
463
501
  bodyClassName: t.bodyClassName,
464
- setFooter: Le,
465
- loadingApi: Se,
466
- loadingStore: A.current,
467
- notifyError: l,
468
- registerDirtyGuard: x
502
+ setFooter: Q,
503
+ loadingApi: ye,
504
+ loadingStore: O.current,
505
+ notifyError: p,
506
+ registerDirtyGuard: x,
507
+ pageMotion: re
469
508
  },
470
509
  o.key
471
510
  )) }),
472
511
  /* @__PURE__ */ h(
473
- Bn,
512
+ Gn,
474
513
  {
475
514
  store: q.current,
476
- routeKey: D,
477
- screen: _e,
515
+ routeKey: I,
516
+ screen: an,
478
517
  options: t,
479
- route: G,
518
+ route: V,
480
519
  navigation: Be,
481
- requestClose: ae,
482
- translate: c,
483
- onError: l,
484
- loadingApi: Se
520
+ requestClose: Te,
521
+ translate: s,
522
+ onError: p,
523
+ loadingApi: ye
485
524
  },
486
- D
525
+ I
487
526
  ),
488
- /* @__PURE__ */ h(Pn, { store: A.current, translate: c }),
489
- /* @__PURE__ */ h(Ln, { store: $.current, dismiss: W }),
490
- y && /* @__PURE__ */ me("div", { className: "pmn-error", role: "alert", children: [
527
+ /* @__PURE__ */ h(In, { store: O.current, translate: s }),
528
+ /* @__PURE__ */ h(Kn, { store: A.current, dismiss: _ }),
529
+ y && /* @__PURE__ */ ue("div", { className: "pmn-error", role: "alert", children: [
491
530
  /* @__PURE__ */ h("span", { children: y.message || String(y) }),
492
- /* @__PURE__ */ h("button", { type: "button", onClick: C, "aria-label": "Dismiss error", children: "×" })
531
+ /* @__PURE__ */ h("button", { type: "button", onClick: R, "aria-label": "Dismiss error", children: "×" })
493
532
  ] })
494
533
  ] }) }) }) }) }) }) }) });
495
534
  }
496
- const On = ".pmn-overlay,.pmn-dialog,.pmn-dialog *{box-sizing:border-box}.pmn-overlay{position:fixed;inset:0;z-index:1000;display:flex;overscroll-behavior:none;background:#00000073}.pmn-place-right{justify-content:flex-end;align-items:stretch}.pmn-place-left{justify-content:flex-start;align-items:stretch}.pmn-place-center{justify-content:center;align-items:center}.pmn-place-top{justify-content:center;align-items:flex-start}.pmn-place-bottom{justify-content:center;align-items:flex-end}.pmn-dialog{--pmn-surface:#fff;--pmn-body:#fff;--pmn-text:#0f172a;--pmn-muted:#475569;--pmn-border:#e2e8f0;--pmn-hover:#f1f5f9;--pmn-overlay-card:rgba(255,255,255,.92);color-scheme:light;position:relative;display:flex;flex-direction:column;min-height:0;width:100%;max-width:min(calc(100vw - var(--pmn-gap)*2),var(--pmn-max-width, var(--pmn-width)));max-height:min(calc(100dvh - var(--pmn-gap)*2),var(--pmn-max-height, 100dvh));height:var(--pmn-height, 100%);overflow:hidden;outline:none;box-shadow:0 25px 50px -12px #00000040;background:var(--pmn-surface);color:var(--pmn-text)}.pmn-place-left .pmn-dialog,.pmn-place-right .pmn-dialog{height:calc(100dvh - var(--pmn-gap)*2);max-height:calc(100dvh - var(--pmn-gap)*2)}.pmn-place-center .pmn-dialog{height:var(--pmn-height, auto);min-height:150px}.pmn-place-top .pmn-dialog,.pmn-place-bottom .pmn-dialog{height:var(--pmn-height, auto);min-height:0}.pmn-dialog[data-modal-theme=dark]{--pmn-surface:#334155;--pmn-body:#334155;--pmn-text:#f1f5f9;--pmn-muted:#cbd5e1;--pmn-border:#475569;--pmn-hover:#1e293b;--pmn-overlay-card:rgba(51,65,85,.94);color-scheme:dark}.pmn-main{min-height:0;flex:1;overflow:hidden;display:flex;flex-direction:column;background:transparent}.pmn-body{height:100%;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:16px;flex:1}.pmn-body[hidden]{display:none!important}.pmn-header{display:flex;flex-shrink:0;height:64px;align-items:center;gap:12px;padding:0 20px;background:transparent}.pmn-header h2{font-size:18px;font-weight:600;min-width:0;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0}.pmn-header-spacer{flex:1}.pmn-border-bottom{border-bottom:1px solid var(--pmn-border)}.pmn-icon-button{display:inline-flex;align-items:center;justify-content:center;padding:8px;border:0;background:transparent;color:inherit;border-radius:8px;cursor:pointer}.pmn-icon-button:hover{background:var(--pmn-hover)}.pmn-footer{display:flex;flex-shrink:0;align-items:center;justify-content:flex-end;gap:12px;padding:16px 20px;background:transparent}.pmn-border-top{border-top:1px solid var(--pmn-border)}.pmn-button{padding:8px 16px;border-radius:8px;font-size:14px;font-weight:500;cursor:pointer}.pmn-button:disabled{opacity:.5;cursor:not-allowed}.pmn-button-secondary{border:1px solid var(--pmn-border);background:transparent;color:var(--pmn-text)}.pmn-button-secondary:hover:not(:disabled){background:var(--pmn-hover)}.pmn-button-primary{border:1px solid #2563eb;background:#2563eb;color:#fff}.pmn-button-primary:hover:not(:disabled){background:#1d4ed8}.pmn-loading-overlay{position:absolute;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;background:#ffffffb8;backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px);cursor:progress}.pmn-dialog[data-modal-theme=dark] .pmn-loading-overlay{background:#0f172ab8}.pmn-loading-content{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;max-width:85%;text-align:center;color:var(--pmn-text);pointer-events:none}.pmn-loading-text{font-size:14px;font-weight:500;line-height:1.5;overflow-wrap:anywhere}.pmn-spinner{width:38px;height:38px;border:3px solid rgba(37,99,235,.2);border-top-color:#2563eb;border-radius:50%;animation:pmn-spin .8s linear infinite}@keyframes pmn-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.pmn-spinner{animation-duration:1.8s}}.pmn-error{position:absolute;z-index:60;bottom:8px;left:12px;right:12px;display:flex;justify-content:space-between;gap:12px;padding:12px;border:1px solid #fca5a5;border-radius:8px;background:#fef2f2;color:#991b1b;font-size:13px}.pmn-error button{border:0;background:transparent;font-size:20px;cursor:pointer;color:inherit}.pmn-dialog input:not([type=checkbox]):not([type=radio]),.pmn-dialog textarea,.pmn-dialog select{color:var(--pmn-text);border-color:var(--pmn-border)}.pmn-error-screen{padding:24px;color:var(--pmn-text)}.pmn-error-screen p{color:#dc2626;overflow-wrap:anywhere}@media(max-width:640px){.pmn-overlay.pmn-mobile-fullscreen{padding:0!important}.pmn-mobile-fullscreen .pmn-dialog{max-width:100%;width:100%;height:100dvh;max-height:100dvh;border-radius:0!important}}@media(prefers-reduced-motion:reduce){.pmn-spinner{animation-duration:2s}}@keyframes pmn-fade-in{0%{opacity:0}to{opacity:1}}@keyframes pmn-fade-out{0%{opacity:1}to{opacity:0}}@keyframes pmn-scale-in{0%{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:none}}@keyframes pmn-scale-out{0%{opacity:1;transform:none}to{opacity:0;transform:translateY(10px) scale(.97)}}@keyframes pmn-right-in{0%{transform:translate(105%)}to{transform:none}}@keyframes pmn-right-out{0%{transform:none}to{transform:translate(105%)}}@keyframes pmn-left-in{0%{transform:translate(-105%)}to{transform:none}}@keyframes pmn-left-out{0%{transform:none}to{transform:translate(-105%)}}@keyframes pmn-top-in{0%{transform:translateY(-105%)}to{transform:none}}@keyframes pmn-top-out{0%{transform:none}to{transform:translateY(-105%)}}@keyframes pmn-bottom-in{0%{transform:translateY(105%)}to{transform:none}}@keyframes pmn-bottom-out{0%{transform:none}to{transform:translateY(105%)}}.pmn-entering{animation:pmn-fade-in var(--pmn-animation-duration) ease-out both}.pmn-exiting{animation:pmn-fade-out var(--pmn-animation-duration) ease-in both;pointer-events:none}.pmn-entering .pmn-dialog{animation:pmn-scale-in var(--pmn-animation-duration) cubic-bezier(.2,.8,.2,1) both}.pmn-exiting .pmn-dialog{animation:pmn-scale-out var(--pmn-animation-duration) ease-in both}.pmn-entering.pmn-place-right .pmn-dialog{animation-name:pmn-right-in}.pmn-exiting.pmn-place-right .pmn-dialog{animation-name:pmn-right-out}.pmn-entering.pmn-place-left .pmn-dialog{animation-name:pmn-left-in}.pmn-exiting.pmn-place-left .pmn-dialog{animation-name:pmn-left-out}.pmn-entering.pmn-place-top .pmn-dialog{animation-name:pmn-top-in}.pmn-exiting.pmn-place-top .pmn-dialog{animation-name:pmn-top-out}.pmn-entering.pmn-place-bottom .pmn-dialog{animation-name:pmn-bottom-in}.pmn-exiting.pmn-place-bottom .pmn-dialog{animation-name:pmn-bottom-out}.pmn-no-animation,.pmn-no-animation .pmn-dialog{animation:none!important}@media(prefers-reduced-motion:reduce){.pmn-entering,.pmn-exiting,.pmn-entering .pmn-dialog,.pmn-exiting .pmn-dialog{animation:none!important}}.pmn-toast-region{position:absolute;top:56px;left:12px;right:12px;z-index:80;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none;max-height:calc(100% - 72px);overflow:hidden}.pmn-toast{pointer-events:auto;display:flex;align-items:flex-start;gap:10px;width:max-content;max-width:100%;min-width:min(260px,100%);padding:11px 13px;border:1px solid var(--pmn-border);border-radius:9px;background:var(--pmn-surface);color:var(--pmn-text);box-shadow:0 5px 18px #0000001a;font-size:13px;line-height:1.5;overflow-wrap:anywhere}.pmn-toast-symbol{flex:0 0 20px;display:grid;place-items:center;width:20px;height:20px;border-radius:50%;font-size:13px;font-weight:700;background:var(--pmn-hover);color:var(--pmn-muted)}.pmn-toast-success .pmn-toast-symbol{background:#dcfce7;color:#15803d}.pmn-toast-error .pmn-toast-symbol{background:#fee2e2;color:#b91c1c}.pmn-toast-warning .pmn-toast-symbol{background:#fef3c7;color:#b45309}.pmn-toast-info .pmn-toast-symbol{background:#dbeafe;color:#1d4ed8}.pmn-toast-message{flex:1;min-width:0;white-space:pre-wrap}.pmn-toast-close{border:0;background:transparent;color:var(--pmn-muted);cursor:pointer;font-size:19px;line-height:18px;padding:0 1px}.pmn-toast-close:hover{color:var(--pmn-text)}.pmn-button-danger{background:#dc2626!important;color:#fff!important;border-color:#dc2626!important}", Ze = "react-modal-navigation-styles", Ge = /* @__PURE__ */ new WeakMap();
497
- function jn() {
498
- un(() => {
535
+ const Wn = ".pmn-overlay,.pmn-dialog,.pmn-dialog *{box-sizing:border-box}.pmn-overlay{position:fixed;inset:0;z-index:1000;display:flex;overscroll-behavior:none;background:#00000073}.pmn-place-right{justify-content:flex-end;align-items:stretch}.pmn-place-left{justify-content:flex-start;align-items:stretch}.pmn-place-center{justify-content:center;align-items:center}.pmn-place-top{justify-content:center;align-items:flex-start}.pmn-place-bottom{justify-content:center;align-items:flex-end}.pmn-dialog{--pmn-surface:#fff;--pmn-body:#fff;--pmn-text:#0f172a;--pmn-muted:#475569;--pmn-border:#e2e8f0;--pmn-hover:#f1f5f9;--pmn-overlay-card:rgba(255,255,255,.92);color-scheme:light;position:relative;display:flex;flex-direction:column;min-height:0;width:100%;max-width:min(calc(100vw - var(--pmn-gap)*2),var(--pmn-max-width, var(--pmn-width)));max-height:min(calc(100dvh - var(--pmn-gap)*2),var(--pmn-max-height, 100dvh));height:var(--pmn-height, 100%);overflow:hidden;outline:none;box-shadow:0 25px 50px -12px #00000040;background:var(--pmn-surface);color:var(--pmn-text)}.pmn-place-left .pmn-dialog,.pmn-place-right .pmn-dialog{height:calc(100dvh - var(--pmn-gap)*2);max-height:calc(100dvh - var(--pmn-gap)*2)}.pmn-place-center .pmn-dialog{height:var(--pmn-height, auto);min-height:150px}.pmn-place-top .pmn-dialog,.pmn-place-bottom .pmn-dialog{height:var(--pmn-height, auto);min-height:0}.pmn-dialog[data-modal-theme=dark]{--pmn-surface:#334155;--pmn-body:#334155;--pmn-text:#f1f5f9;--pmn-muted:#cbd5e1;--pmn-border:#475569;--pmn-hover:#1e293b;--pmn-overlay-card:rgba(51,65,85,.94);color-scheme:dark}.pmn-main{min-height:0;flex:1;overflow:hidden;display:flex;flex-direction:column;background:transparent}.pmn-body{height:100%;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:16px;flex:1}.pmn-body[hidden]{display:none!important}.pmn-header{display:flex;flex-shrink:0;height:64px;align-items:center;gap:12px;padding:0 20px;background:transparent}.pmn-header h2{font-size:18px;font-weight:600;min-width:0;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0}.pmn-header-spacer{flex:1}.pmn-border-bottom{border-bottom:1px solid var(--pmn-border)}.pmn-icon-button{display:inline-flex;align-items:center;justify-content:center;padding:8px;border:0;background:transparent;color:inherit;border-radius:8px;cursor:pointer}.pmn-icon-button:hover{background:var(--pmn-hover)}.pmn-footer{display:flex;flex-shrink:0;align-items:center;justify-content:flex-end;gap:12px;padding:16px 20px;background:transparent}.pmn-border-top{border-top:1px solid var(--pmn-border)}.pmn-button{padding:8px 16px;border-radius:8px;font-size:14px;font-weight:500;cursor:pointer}.pmn-button:disabled{opacity:.5;cursor:not-allowed}.pmn-button-secondary{border:1px solid var(--pmn-border);background:transparent;color:var(--pmn-text)}.pmn-button-secondary:hover:not(:disabled){background:var(--pmn-hover)}.pmn-button-primary{border:1px solid #2563eb;background:#2563eb;color:#fff}.pmn-button-primary:hover:not(:disabled){background:#1d4ed8}.pmn-loading-overlay{position:absolute;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;background:#ffffffb8;backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px);cursor:progress}.pmn-dialog[data-modal-theme=dark] .pmn-loading-overlay{background:#0f172ab8}.pmn-loading-content{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;max-width:85%;text-align:center;color:var(--pmn-text);pointer-events:none}.pmn-loading-text{font-size:14px;font-weight:500;line-height:1.5;overflow-wrap:anywhere}.pmn-spinner{width:38px;height:38px;border:3px solid rgba(37,99,235,.2);border-top-color:#2563eb;border-radius:50%;animation:pmn-spin .8s linear infinite}@keyframes pmn-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.pmn-spinner{animation-duration:1.8s}}.pmn-error{position:absolute;z-index:60;bottom:8px;left:12px;right:12px;display:flex;justify-content:space-between;gap:12px;padding:12px;border:1px solid #fca5a5;border-radius:8px;background:#fef2f2;color:#991b1b;font-size:13px}.pmn-error button{border:0;background:transparent;font-size:20px;cursor:pointer;color:inherit}.pmn-dialog input:not([type=checkbox]):not([type=radio]),.pmn-dialog textarea,.pmn-dialog select{color:var(--pmn-text);border-color:var(--pmn-border)}.pmn-error-screen{padding:24px;color:var(--pmn-text)}.pmn-error-screen p{color:#dc2626;overflow-wrap:anywhere}@media(max-width:640px){.pmn-overlay.pmn-mobile-fullscreen{padding:0!important}.pmn-mobile-fullscreen .pmn-dialog{max-width:100%;width:100%;height:100dvh;max-height:100dvh;border-radius:0!important}}@media(prefers-reduced-motion:reduce){.pmn-spinner{animation-duration:2s}}@keyframes pmn-fade-in{0%{opacity:0}to{opacity:1}}@keyframes pmn-fade-out{0%{opacity:1}to{opacity:0}}@keyframes pmn-scale-in{0%{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:none}}@keyframes pmn-scale-out{0%{opacity:1;transform:none}to{opacity:0;transform:translateY(10px) scale(.97)}}@keyframes pmn-right-in{0%{transform:translate(105%)}to{transform:none}}@keyframes pmn-right-out{0%{transform:none}to{transform:translate(105%)}}@keyframes pmn-left-in{0%{transform:translate(-105%)}to{transform:none}}@keyframes pmn-left-out{0%{transform:none}to{transform:translate(-105%)}}@keyframes pmn-top-in{0%{transform:translateY(-105%)}to{transform:none}}@keyframes pmn-top-out{0%{transform:none}to{transform:translateY(-105%)}}@keyframes pmn-bottom-in{0%{transform:translateY(105%)}to{transform:none}}@keyframes pmn-bottom-out{0%{transform:none}to{transform:translateY(105%)}}.pmn-entering{animation:pmn-fade-in var(--pmn-animation-duration) ease-out both}.pmn-exiting{animation:pmn-fade-out var(--pmn-animation-duration) ease-in both;pointer-events:none}.pmn-entering .pmn-dialog{animation:pmn-scale-in var(--pmn-animation-duration) cubic-bezier(.2,.8,.2,1) both}.pmn-exiting .pmn-dialog{animation:pmn-scale-out var(--pmn-animation-duration) ease-in both}.pmn-entering.pmn-place-right .pmn-dialog{animation-name:pmn-right-in}.pmn-exiting.pmn-place-right .pmn-dialog{animation-name:pmn-right-out}.pmn-entering.pmn-place-left .pmn-dialog{animation-name:pmn-left-in}.pmn-exiting.pmn-place-left .pmn-dialog{animation-name:pmn-left-out}.pmn-entering.pmn-place-top .pmn-dialog{animation-name:pmn-top-in}.pmn-exiting.pmn-place-top .pmn-dialog{animation-name:pmn-top-out}.pmn-entering.pmn-place-bottom .pmn-dialog{animation-name:pmn-bottom-in}.pmn-exiting.pmn-place-bottom .pmn-dialog{animation-name:pmn-bottom-out}.pmn-no-animation,.pmn-no-animation .pmn-dialog{animation:none!important}@media(prefers-reduced-motion:reduce){.pmn-entering,.pmn-exiting,.pmn-entering .pmn-dialog,.pmn-exiting .pmn-dialog{animation:none!important}}.pmn-toast-region{position:absolute;top:56px;left:12px;right:12px;z-index:80;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none;max-height:calc(100% - 72px);overflow:hidden}.pmn-toast{pointer-events:auto;display:flex;align-items:flex-start;gap:10px;width:max-content;max-width:100%;min-width:min(260px,100%);padding:11px 13px;border:1px solid var(--pmn-border);border-radius:9px;background:var(--pmn-surface);color:var(--pmn-text);box-shadow:0 5px 18px #0000001a;font-size:13px;line-height:1.5;overflow-wrap:anywhere}.pmn-toast-symbol{flex:0 0 20px;display:grid;place-items:center;width:20px;height:20px;border-radius:50%;font-size:13px;font-weight:700;background:var(--pmn-hover);color:var(--pmn-muted)}.pmn-toast-success .pmn-toast-symbol{background:#dcfce7;color:#15803d}.pmn-toast-error .pmn-toast-symbol{background:#fee2e2;color:#b91c1c}.pmn-toast-warning .pmn-toast-symbol{background:#fef3c7;color:#b45309}.pmn-toast-info .pmn-toast-symbol{background:#dbeafe;color:#1d4ed8}.pmn-toast-message{flex:1;min-width:0;white-space:pre-wrap}.pmn-toast-close{border:0;background:transparent;color:var(--pmn-muted);cursor:pointer;font-size:19px;line-height:18px;padding:0 1px}.pmn-toast-close:hover{color:var(--pmn-text)}.pmn-button-danger{background:#dc2626!important;color:#fff!important;border-color:#dc2626!important}@keyframes pmn-page-forward-in{0%{opacity:.18;transform:translate3d(var(--pmn-page-distance,96px),0,0) scale(.985)}to{opacity:1;transform:translateZ(0)}}@keyframes pmn-page-back-in{0%{opacity:.18;transform:translate3d(calc(-1 * var(--pmn-page-distance,96px)),0,0) scale(.985)}to{opacity:1;transform:translateZ(0)}}.pmn-page-enter{animation-duration:var(--pmn-page-duration,.36s);animation-timing-function:cubic-bezier(.2,.8,.2,1);animation-fill-mode:both;will-change:transform,opacity}.pmn-page-forward{animation-name:pmn-page-forward-in}.pmn-page-back{animation-name:pmn-page-back-in}@media(prefers-reduced-motion:reduce){.pmn-page-enter{animation:none!important;will-change:auto}}.pmn-main{position:relative;isolation:isolate}.pmn-page-exit{animation-duration:var(--pmn-page-duration,.36s);animation-timing-function:cubic-bezier(.22,1,.36,1);animation-fill-mode:forwards}@keyframes pmn-page-forward-out{to{opacity:.45;transform:translate3d(calc(-1 * var(--pmn-page-distance,96px)),0,0) scale(.985)}}@keyframes pmn-page-back-out{to{opacity:.45;transform:translate3d(var(--pmn-page-distance,96px),0,0) scale(.985)}}.pmn-page-exit-forward{animation-name:pmn-page-forward-out}.pmn-page-exit-back{animation-name:pmn-page-back-out}@media(prefers-reduced-motion:reduce){.pmn-page-exit{animation:none!important}}", dn = "react-modal-navigation-styles", Ye = /* @__PURE__ */ new WeakMap();
536
+ function Yn() {
537
+ xn(() => {
499
538
  if (typeof document > "u") return;
500
539
  const e = document;
501
- let n = Ge.get(e);
540
+ let n = Ye.get(e);
502
541
  if (!n) {
503
- let r = e.getElementById(Ze);
542
+ let r = e.getElementById(dn);
504
543
  const t = !r;
505
- r || (r = e.createElement("style"), r.id = Ze, r.setAttribute("data-react-modal-navigation", ""), r.textContent = On, e.head.appendChild(r)), n = { element: r, owned: t, count: 0 }, Ge.set(e, n);
544
+ r || (r = e.createElement("style"), r.id = dn, r.setAttribute("data-react-modal-navigation", ""), r.textContent = Wn, e.head.appendChild(r)), n = { element: r, owned: t, count: 0 }, Ye.set(e, n);
506
545
  }
507
546
  return n.count += 1, () => {
508
- n.count -= 1, n.count === 0 && (n.owned && n.element.remove(), Ge.delete(e));
547
+ n.count -= 1, n.count === 0 && (n.owned && n.element.remove(), Ye.delete(e));
509
548
  };
510
549
  }, []);
511
550
  }
@@ -516,337 +555,337 @@ function Oe(e, n, r) {
516
555
  }
517
556
  if (e === null || typeof e != "object" || Array.isArray(e))
518
557
  throw new TypeError("[react-modal-navigation] open expects a modal name or a configuration object");
519
- const { name: t, screen: c, params: f = {}, options: i = {}, ...m } = e;
558
+ const { name: t, screen: s, params: g = {}, options: d = {}, ...m } = e;
520
559
  if (typeof t != "string" || !t.trim())
521
560
  throw new TypeError("[react-modal-navigation] open config requires a non-empty string name");
522
- if (i === null || typeof i != "object" || Array.isArray(i))
561
+ if (d === null || typeof d != "object" || Array.isArray(d))
523
562
  throw new TypeError("[react-modal-navigation] open config options must be an object");
524
- if (c !== void 0 && (typeof c != "string" || !c.trim()))
563
+ if (s !== void 0 && (typeof s != "string" || !s.trim()))
525
564
  throw new TypeError("[react-modal-navigation] screen must be a non-empty string");
526
- return { name: t, ...c === void 0 ? {} : { screen: c }, params: f, options: { ...m, ...i } };
527
- }
528
- const Fn = { placement: "right", showHeader: !0, showBackButton: !0, showCloseButton: !0, viewportGap: 5, borderRadius: 12, closeOnOverlay: !1, closeOnEsc: !0 }, Dn = (e) => ({ "modal.loading": "加载中...", "modal.processing": "处理中...", "modal.back": "返回", "modal.close": "关闭", "modal.cancel": "取消", "modal.done": "完成" })[e] ?? e;
529
- function _n({ registry: e, children: n, defaultOptions: r = {}, backgroundColor: t, theme: c, translate: f = Dn, onError: i, confirmDiscard: m }) {
530
- jn();
531
- const [l, y] = ie(null), [C, x] = ie(null), [g, u] = ie(0), s = d(null), B = d(/* @__PURE__ */ new Map()), R = d([]), A = d(null), q = d(null), $ = d(0), E = d(null), z = d(!1), U = d(0), W = d(null), M = d(/* @__PURE__ */ new Map()), [b, T] = ie(!1), j = d(m);
532
- j.current = m;
533
- const F = v((a, p) => (M.current.set(a, p), () => {
534
- M.current.get(a) === p && M.current.delete(a);
535
- }), []), N = v(async (a) => {
536
- for (const p of M.current.values()) {
537
- if (!p.dirty) continue;
538
- if ((p.onBeforeDiscard ? await p.onBeforeDiscard(a) : j.current ? await j.current(a) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(p.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
565
+ return { name: t, ...s === void 0 ? {} : { screen: s }, params: g, options: { ...m, ...d } };
566
+ }
567
+ const _n = { placement: "right", showHeader: !0, showBackButton: !0, showCloseButton: !0, viewportGap: 5, borderRadius: 12, closeOnOverlay: !1, closeOnEsc: !0 }, Vn = (e) => ({ "modal.loading": "加载中...", "modal.processing": "处理中...", "modal.back": "返回", "modal.close": "关闭", "modal.cancel": "取消", "modal.done": "完成" })[e] ?? e;
568
+ function at({ registry: e, children: n, defaultOptions: r = {}, backgroundColor: t, theme: s, translate: g = Vn, onError: d, confirmDiscard: m }) {
569
+ Yn();
570
+ const [p, y] = le(null), [R, x] = le(null), [c, u] = le(0), a = l(null), B = l(/* @__PURE__ */ new Map()), P = l([]), O = l(null), q = l(null), A = l(0), E = l(null), F = l(!1), Y = l(0), _ = l(null), C = l(/* @__PURE__ */ new Map()), [b, T] = le(!1), D = l(m);
571
+ D.current = m;
572
+ const z = w((i, f) => (C.current.set(i, f), () => {
573
+ C.current.get(i) === f && C.current.delete(i);
574
+ }), []), M = w(async (i) => {
575
+ for (const f of C.current.values()) {
576
+ if (!f.dirty) continue;
577
+ if ((f.onBeforeDiscard ? await f.onBeforeDiscard(i) : D.current ? await D.current(i) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(f.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
539
578
  }
540
579
  return !0;
541
- }, []), V = v(async (a, p) => {
542
- for (const S of a) {
543
- const k = M.current.get(S);
580
+ }, []), G = w(async (i, f) => {
581
+ for (const S of i) {
582
+ const k = C.current.get(S);
544
583
  if (!k?.dirty) continue;
545
- if ((k.onBeforeDiscard ? await k.onBeforeDiscard(p) : j.current ? await j.current(p) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(k.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
584
+ if ((k.onBeforeDiscard ? await k.onBeforeDiscard(f) : D.current ? await D.current(f) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(k.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
546
585
  }
547
586
  return !0;
548
- }, []), L = d(!0), ne = d(null), te = d(i);
549
- te.current = i;
550
- const O = v((a, p) => {
551
- L.current && x(a);
587
+ }, []), $ = l(!0), se = l(null), ae = l(d);
588
+ ae.current = d;
589
+ const Z = w((i, f) => {
590
+ $.current && x(i);
552
591
  try {
553
- te.current ? te.current(a, p) : console.error("[react-modal-navigation]", a);
592
+ ae.current ? ae.current(i, f) : console.error("[react-modal-navigation]", i);
554
593
  } catch (S) {
555
594
  console.error("[react-modal-navigation] onError failed", S);
556
595
  }
557
- }, []), le = v((a, p) => {
558
- const S = B.current.get(a);
559
- B.current.delete(a), S?.(p);
560
- }, []), re = v((a) => ({ ...Fn, ...r, ...c !== void 0 ? { theme: c } : {}, ...t !== void 0 ? { backgroundColor: t } : {}, ...a.config.modalOptions, ...a.overrides }), [r, c, t]), Ee = l ? re(l) : null, G = d(null);
561
- G.current = Ee, ne.current = Ee;
562
- const D = v(async (a = "api", p, S = {}) => {
563
- const k = s.current;
564
- if (!k || E.current || z.current) return !1;
565
- E.current = k.id, z.current = !0;
566
- const Y = ne.current ?? re(k), _ = { ...S, reason: a, result: p, name: k.name };
596
+ }, []), ge = w((i, f) => {
597
+ const S = B.current.get(i);
598
+ B.current.delete(i), S?.(f);
599
+ }, []), ie = w((i) => ({ ..._n, ...r, ...s !== void 0 ? { theme: s } : {}, ...t !== void 0 ? { backgroundColor: t } : {}, ...i.config.modalOptions, ...i.overrides }), [r, s, t]), J = p ? ie(p) : null, he = l(null);
600
+ he.current = J, se.current = J;
601
+ const ce = w(async (i = "api", f, S = {}) => {
602
+ const k = a.current;
603
+ if (!k || E.current || F.current) return !1;
604
+ E.current = k.id, F.current = !0;
605
+ const H = se.current ?? ie(k), Q = { ...S, reason: i, result: f, name: k.name };
567
606
  try {
568
- if (!await N(_) || await Y.onBeforeClose?.(_) === !1 || s.current?.id !== k.id || !L.current || (T(!0), await new Promise((J) => {
569
- const ae = Y.animation === !1 || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? 0 : Math.max(0, Number(Y.animationDuration ?? 220) || 0);
570
- setTimeout(J, Math.min(ae, 1e3));
571
- }), !L.current || s.current?.id !== k.id)) return !1;
572
- s.current = null, W.current = null, y(null), T(!1), M.current.clear(), le(k.id, S.confirmed || p !== void 0 ? { status: "confirmed", value: p, reason: a } : { status: "dismissed", reason: a });
607
+ if (!await M(Q) || await H.onBeforeClose?.(Q) === !1 || a.current?.id !== k.id || !$.current || (T(!0), await new Promise((ne) => {
608
+ const me = H.animation === !1 || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? 0 : Math.max(0, Number(H.animationDuration ?? 220) || 0);
609
+ setTimeout(ne, Math.min(me, 1e3));
610
+ }), !$.current || a.current?.id !== k.id)) return !1;
611
+ a.current = null, _.current = null, y(null), T(!1), C.current.clear(), ge(k.id, S.confirmed || f !== void 0 ? { status: "confirmed", value: f, reason: i } : { status: "dismissed", reason: i });
573
612
  try {
574
- await Y.onClose?.(_);
575
- } catch (J) {
576
- O(J, { phase: "onClose", name: k.name });
613
+ await H.onClose?.(Q);
614
+ } catch (ne) {
615
+ Z(ne, { phase: "onClose", name: k.name });
577
616
  }
578
617
  return !0;
579
- } catch (J) {
580
- return O(J, { phase: "onBeforeClose", name: k.name }), !1;
618
+ } catch (ne) {
619
+ return Z(ne, { phase: "onBeforeClose", name: k.name }), !1;
581
620
  } finally {
582
- E.current === k.id && (E.current = null), z.current = !1, !s.current && L.current && queueMicrotask(() => q.current?.());
621
+ E.current === k.id && (E.current = null), F.current = !1, !a.current && $.current && queueMicrotask(() => q.current?.());
583
622
  }
584
- }, [re, O, le, N]), ue = v(async (a, p = {}, S = {}, k, Y) => {
585
- const _ = e?.[a];
586
- if (!_) throw new Error(`[react-modal-navigation] Unknown modal: ${a}`);
587
- const J = Y ?? _.initialRoute;
588
- if (!_.screens?.[J]) throw new Error(`[react-modal-navigation] Unknown initial screen '${J}' in modal '${a}'`);
589
- if (!L.current || z.current || E.current) return null;
590
- z.current = !0;
591
- const ae = U.current;
623
+ }, [ie, Z, ge, M]), de = w(async (i, f = {}, S = {}, k, H) => {
624
+ const Q = e?.[i];
625
+ if (!Q) throw new Error(`[react-modal-navigation] Unknown modal: ${i}`);
626
+ const ne = H ?? Q.initialRoute;
627
+ if (!Q.screens?.[ne]) throw new Error(`[react-modal-navigation] Unknown initial screen '${ne}' in modal '${i}'`);
628
+ if (!$.current || F.current || E.current) return null;
629
+ F.current = !0;
630
+ const me = Y.current;
592
631
  try {
593
- const se = s.current;
594
- if (se) {
595
- const we = ne.current ?? re(se), xe = { reason: "replace", name: se.name, nextName: a };
632
+ const te = a.current;
633
+ if (te) {
634
+ const Ce = se.current ?? ie(te), ve = { reason: "replace", name: te.name, nextName: i };
596
635
  try {
597
- if (!await N(xe) || await we.onBeforeClose?.(xe) === !1) return null;
598
- } catch (he) {
599
- return O(he, { phase: "onBeforeClose", name: se.name }), null;
636
+ if (!await M(ve) || await Ce.onBeforeClose?.(ve) === !1) return null;
637
+ } catch (we) {
638
+ return Z(we, { phase: "onBeforeClose", name: te.name }), null;
600
639
  }
601
- if (!L.current || ae !== U.current || s.current?.id !== se.id) return null;
602
- s.current = null, W.current = null, y(null), M.current.clear(), le(se.id, { status: "replaced", reason: "replace" });
640
+ if (!$.current || me !== Y.current || a.current?.id !== te.id) return null;
641
+ a.current = null, _.current = null, y(null), C.current.clear(), ge(te.id, { status: "replaced", reason: "replace" });
603
642
  try {
604
- await we.onClose?.(xe);
605
- } catch (he) {
606
- O(he, { phase: "onClose", name: se.name });
643
+ await Ce.onClose?.(ve);
644
+ } catch (we) {
645
+ Z(we, { phase: "onClose", name: te.name });
607
646
  }
608
- if (!L.current || ae !== U.current) return null;
647
+ if (!$.current || me !== Y.current) return null;
609
648
  }
610
- const fe = { id: ++$.current, name: a, screen: J, params: p, config: _, overrides: S };
611
- return s.current = fe, W.current = null, k && B.current.set(fe.id, k), x(null), y(fe), fe.id;
649
+ const X = { id: ++A.current, name: i, screen: ne, params: f, config: Q, overrides: S };
650
+ return a.current = X, _.current = null, k && B.current.set(X.id, k), x(null), y(X), X.id;
612
651
  } finally {
613
- z.current = !1;
652
+ F.current = !1;
614
653
  }
615
- }, [e, re, O, le, N]);
616
- A.current = ue;
617
- const Se = v(async () => {
618
- if (!L.current || s.current || z.current || E.current) return;
619
- const a = R.current.shift();
620
- if (a) {
621
- u(R.current.length);
654
+ }, [e, ie, Z, ge, M]);
655
+ O.current = de;
656
+ const V = w(async () => {
657
+ if (!$.current || a.current || F.current || E.current) return;
658
+ const i = P.current.shift();
659
+ if (i) {
660
+ u(P.current.length);
622
661
  try {
623
- const p = await A.current(a.args.name, a.args.params, a.args.options, a.resolveResult, a.args.screen);
624
- p === null ? (a.resolveResult?.({ status: "dismissed", reason: "blocked" }), a.resolveId?.(null), queueMicrotask(() => q.current?.())) : a.resolveId?.(p);
625
- } catch (p) {
626
- a.reject?.(p), queueMicrotask(() => q.current?.());
662
+ const f = await O.current(i.args.name, i.args.params, i.args.options, i.resolveResult, i.args.screen);
663
+ f === null ? (i.resolveResult?.({ status: "dismissed", reason: "blocked" }), i.resolveId?.(null), queueMicrotask(() => q.current?.())) : i.resolveId?.(f);
664
+ } catch (f) {
665
+ i.reject?.(f), queueMicrotask(() => q.current?.());
627
666
  }
628
667
  }
629
668
  }, []);
630
- q.current = Se;
631
- const Ce = v((a, p, S) => {
632
- const k = Oe(a, p, S);
633
- return e?.[k.name] ? new Promise((Y, _) => {
634
- R.current.push({ args: k, resolveId: Y, reject: _ }), u(R.current.length), queueMicrotask(() => q.current?.());
669
+ q.current = V;
670
+ const I = w((i, f, S) => {
671
+ const k = Oe(i, f, S);
672
+ return e?.[k.name] ? new Promise((H, Q) => {
673
+ P.current.push({ args: k, resolveId: H, reject: Q }), u(P.current.length), queueMicrotask(() => q.current?.());
635
674
  }) : Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${k.name}`));
636
- }, [e]), ye = v((a, p, S) => {
637
- const k = Oe(a, p, S);
638
- return e?.[k.name] ? new Promise((Y, _) => {
639
- R.current.push({ args: k, resolveResult: Y, reject: _ }), u(R.current.length), queueMicrotask(() => q.current?.());
675
+ }, [e]), ke = w((i, f, S) => {
676
+ const k = Oe(i, f, S);
677
+ return e?.[k.name] ? new Promise((H, Q) => {
678
+ P.current.push({ args: k, resolveResult: H, reject: Q }), u(P.current.length), queueMicrotask(() => q.current?.());
640
679
  }) : Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${k.name}`));
641
- }, [e]), pe = v((a) => {
642
- if (!a || typeof a != "object" || Array.isArray(a)) throw new TypeError("[react-modal-navigation] update expects an options object");
643
- const p = s.current;
644
- if (!p || z.current) return !1;
645
- const S = { ...p, overrides: { ...p.overrides, ...a } };
646
- return s.current = S, y(S), ne.current = re(S), !0;
647
- }, [re]), oe = v((a = "queue-cleared") => {
648
- const p = R.current.splice(0);
680
+ }, [e]), Ee = w((i) => {
681
+ if (!i || typeof i != "object" || Array.isArray(i)) throw new TypeError("[react-modal-navigation] update expects an options object");
682
+ const f = a.current;
683
+ if (!f || F.current) return !1;
684
+ const S = { ...f, overrides: { ...f.overrides, ...i } };
685
+ return a.current = S, y(S), se.current = ie(S), !0;
686
+ }, [ie]), be = w((i = "queue-cleared") => {
687
+ const f = P.current.splice(0);
649
688
  u(0);
650
- for (const S of p)
651
- S.resolveId?.(null), S.resolveResult?.({ status: "dismissed", reason: a });
652
- return p.length;
653
- }, []), Pe = v((a, p, S) => {
654
- const k = Oe(a, p, S);
655
- return ue(k.name, k.params, k.options, void 0, k.screen);
656
- }, [ue]), ve = v((a, p, S) => {
657
- const k = Oe(a, p, S);
658
- return new Promise((Y, _) => {
659
- ue(k.name, k.params, k.options, Y, k.screen).then((J) => {
660
- J === null && Y({ status: "dismissed", reason: "blocked" });
661
- }, _);
689
+ for (const S of f)
690
+ S.resolveId?.(null), S.resolveResult?.({ status: "dismissed", reason: i });
691
+ return f.length;
692
+ }, []), Pe = w((i, f, S) => {
693
+ const k = Oe(i, f, S);
694
+ return de(k.name, k.params, k.options, void 0, k.screen);
695
+ }, [de]), Se = w((i, f, S) => {
696
+ const k = Oe(i, f, S);
697
+ return new Promise((H, Q) => {
698
+ de(k.name, k.params, k.options, H, k.screen).then((ne) => {
699
+ ne === null && H({ status: "dismissed", reason: "blocked" });
700
+ }, Q);
662
701
  });
663
- }, [ue]), Le = v((a) => D("api", a), [D]), Re = v((a = "api") => D(a), [D]), Me = v((a) => D("confirm", a, { confirmed: !0 }), [D]), de = v((a, p) => W.current?.setLoading(a, p), []), Z = K(() => ({ open: Pe, openAsync: ve, enqueue: Ce, enqueueAsync: ye, update: pe, clearQueue: oe, close: Le, dismiss: Re, confirm: Me, setLoading: de, queueSize: g, isOpen: !!l, activeName: l?.name ?? null, error: C, clearError: () => x(null) }), [Pe, ve, Ce, ye, pe, oe, Le, Re, Me, de, l, C, g]);
664
- return H(() => (L.current = !0, () => {
665
- L.current = !1, U.current += 1, s.current = null;
666
- for (const p of B.current.values()) p({ status: "dismissed", reason: "unmount" });
667
- B.current.clear(), M.current.clear();
668
- const a = R.current.splice(0);
669
- for (const p of a)
670
- p.resolveId?.(null), p.resolveResult?.({ status: "dismissed", reason: "unmount" });
671
- }), []), /* @__PURE__ */ me(nn.Provider, { value: Z, children: [
702
+ }, [de]), ze = w((i) => ce("api", i), [ce]), re = w((i = "api") => ce(i), [ce]), Re = w((i) => ce("confirm", i, { confirmed: !0 }), [ce]), ye = w((i, f) => _.current?.setLoading(i, f), []), Le = K(() => ({ open: Pe, openAsync: Se, enqueue: I, enqueueAsync: ke, update: Ee, clearQueue: be, close: ze, dismiss: re, confirm: Re, setLoading: ye, queueSize: c, isOpen: !!p, activeName: p?.name ?? null, error: R, clearError: () => x(null) }), [Pe, Se, I, ke, Ee, be, ze, re, Re, ye, p, R, c]);
703
+ return W(() => ($.current = !0, () => {
704
+ $.current = !1, Y.current += 1, a.current = null;
705
+ for (const f of B.current.values()) f({ status: "dismissed", reason: "unmount" });
706
+ B.current.clear(), C.current.clear();
707
+ const i = P.current.splice(0);
708
+ for (const f of i)
709
+ f.resolveId?.(null), f.resolveResult?.({ status: "dismissed", reason: "unmount" });
710
+ }), []), /* @__PURE__ */ ue(pn.Provider, { value: Le, children: [
672
711
  n,
673
- l && /* @__PURE__ */ h(
674
- qn,
712
+ p && /* @__PURE__ */ h(
713
+ Un,
675
714
  {
676
- config: l.config,
677
- initialScreen: l.screen,
678
- params: l.params,
679
- options: Ee,
680
- translate: f,
681
- notifyError: O,
682
- error: C,
715
+ config: p.config,
716
+ initialScreen: p.screen,
717
+ params: p.params,
718
+ options: J,
719
+ translate: g,
720
+ notifyError: Z,
721
+ error: R,
683
722
  clearError: () => x(null),
684
- registerLoading: (a) => {
685
- W.current = a;
723
+ registerLoading: (i) => {
724
+ _.current = i;
686
725
  },
687
- registerDirtyGuard: F,
688
- canNavigate: V,
726
+ registerDirtyGuard: z,
727
+ canNavigate: G,
689
728
  exiting: b,
690
- onRequestClose: D,
691
- onOpened: (a) => {
729
+ onRequestClose: ce,
730
+ onOpened: (i) => {
692
731
  try {
693
- const p = G.current?.onOpen?.(a);
694
- Promise.resolve(p).catch((S) => O(S, { phase: "onOpen" }));
695
- } catch (p) {
696
- O(p, { phase: "onOpen" });
732
+ const f = he.current?.onOpen?.(i);
733
+ Promise.resolve(f).catch((S) => Z(S, { phase: "onOpen" }));
734
+ } catch (f) {
735
+ Z(f, { phase: "onOpen" });
697
736
  }
698
737
  }
699
738
  },
700
- l.id
739
+ p.id
701
740
  )
702
741
  ] });
703
742
  }
704
- const In = Object.freeze({ canGoBack: !1, stack: [], currentRoute: null }), $n = () => () => {
705
- }, en = () => In;
706
- function Vn() {
707
- const e = Q(nn), n = Q(Ue), r = Q(We), t = be(r?.subscribe ?? $n, r?.getSnapshot ?? en, r?.getSnapshot ?? en);
743
+ const Qn = Object.freeze({ canGoBack: !1, stack: [], currentRoute: null }), Zn = () => () => {
744
+ }, mn = () => Qn;
745
+ function st() {
746
+ const e = ee(pn), n = ee(Ve), r = ee(Qe), t = fe(r?.subscribe ?? Zn, r?.getSnapshot ?? mn, r?.getSnapshot ?? mn);
708
747
  if (!e) throw new Error("[react-modal-navigation] useModal requires <ModalProvider>");
709
- const c = K(() => {
710
- const f = () => {
748
+ const s = K(() => {
749
+ const g = () => {
711
750
  if (!n) throw new Error("[react-modal-navigation] navigation requires an active modal screen; use modal.open() outside a modal");
712
751
  return n;
713
752
  };
714
753
  return {
715
- navigate: (...i) => f().navigate(...i),
716
- replace: (...i) => f().replace(...i),
717
- reset: (...i) => f().reset(...i),
718
- setParams: (...i) => f().setParams(...i),
719
- setOptions: (...i) => f().setOptions(...i),
720
- goBack: (...i) => f().goBack(...i),
721
- close: (...i) => f().close(...i),
722
- setLoading: (...i) => f().setLoading(...i),
754
+ navigate: (...d) => g().navigate(...d),
755
+ replace: (...d) => g().replace(...d),
756
+ reset: (...d) => g().reset(...d),
757
+ setParams: (...d) => g().setParams(...d),
758
+ setOptions: (...d) => g().setOptions(...d),
759
+ goBack: (...d) => g().goBack(...d),
760
+ close: (...d) => g().close(...d),
761
+ setLoading: (...d) => g().setLoading(...d),
723
762
  canGoBack: t.canGoBack,
724
763
  stack: t.stack,
725
764
  currentRoute: t.currentRoute
726
765
  };
727
766
  }, [n, t]);
728
- return K(() => ({ ...e, modal: e, navigation: c }), [e, c]);
767
+ return K(() => ({ ...e, modal: e, navigation: s }), [e, s]);
729
768
  }
730
- function zn() {
731
- const e = Q(Ue);
769
+ function Jn() {
770
+ const e = ee(Ve);
732
771
  if (!e) throw new Error("useModalNavigationCommands requires an active modal screen");
733
772
  return e;
734
773
  }
735
- function Kn() {
736
- const e = Q(We);
774
+ function Xn() {
775
+ const e = ee(Qe);
737
776
  if (!e) throw new Error("useModalNavigationState requires an active modal screen");
738
- return be(e.subscribe, e.getSnapshot, e.getSnapshot);
777
+ return fe(e.subscribe, e.getSnapshot, e.getSnapshot);
739
778
  }
740
- function Qn() {
741
- const e = zn(), n = Kn();
779
+ function it() {
780
+ const e = Jn(), n = Xn();
742
781
  return K(() => ({ ...e, ...n }), [e, n]);
743
782
  }
744
- function sn() {
745
- const e = Q(je);
783
+ function yn() {
784
+ const e = ee(je);
746
785
  if (!e) throw new Error("useIsFocused must be called inside a modal screen");
747
786
  return e.isFocused;
748
787
  }
749
- function Jn(e) {
750
- const n = sn();
751
- H(() => {
788
+ function ct(e) {
789
+ const n = yn();
790
+ W(() => {
752
791
  if (n)
753
792
  return e();
754
793
  }, [n, e]);
755
794
  }
756
- function Xn(e) {
757
- const n = Q(je);
795
+ function lt(e) {
796
+ const n = ee(je);
758
797
  if (!n) throw new Error("useNavigationResult requires an active modal screen");
759
- const r = d(e), t = d(null);
760
- H(() => {
798
+ const r = l(e), t = l(null);
799
+ W(() => {
761
800
  r.current = e;
762
- }, [e]), H(() => {
801
+ }, [e]), W(() => {
763
802
  !n.isFocused || !n.resultEvent || t.current !== n.resultEvent.id && (t.current = n.resultEvent.id, r.current(n.resultEvent.data));
764
803
  }, [n.isFocused, n.resultEvent]);
765
804
  }
766
- function Zn(e = {}) {
767
- const n = Q(je);
805
+ function ut(e = {}) {
806
+ const n = ee(je);
768
807
  if (!n) throw new Error("[react-modal-navigation] useModalFooter requires an active modal screen");
769
- const { setFooter: r, routeKey: t } = n, c = d(e);
770
- c.current = e;
771
- const f = K(() => (...M) => c.current.done?.(...M), []), i = K(() => (...M) => (c.current.cancel ?? c.current.cancle)?.(...M), []), m = K(() => (...M) => c.current.renderFooter?.(...M), []), l = typeof e.done == "function", y = typeof (e.cancel ?? e.cancle) == "function", C = typeof e.renderFooter == "function", { showFooter: x, showFooterBorder: g, doneDisabled: u, doneText: s, cancelText: B, loadingText: R, footerClassName: A } = e, q = d({ source: null, normalized: void 0 }), $ = Array.isArray(e.actions) ? e.actions : null, E = q.current.source;
772
- $ === E || $ && E && $.length === E.length && $.every((M, b) => {
808
+ const { setFooter: r, routeKey: t } = n, s = l(e);
809
+ s.current = e;
810
+ const g = K(() => (...C) => s.current.done?.(...C), []), d = K(() => (...C) => (s.current.cancel ?? s.current.cancle)?.(...C), []), m = K(() => (...C) => s.current.renderFooter?.(...C), []), p = typeof e.done == "function", y = typeof (e.cancel ?? e.cancle) == "function", R = typeof e.renderFooter == "function", { showFooter: x, showFooterBorder: c, doneDisabled: u, doneText: a, cancelText: B, loadingText: P, footerClassName: O } = e, q = l({ source: null, normalized: void 0 }), A = Array.isArray(e.actions) ? e.actions : null, E = q.current.source;
811
+ A === E || A && E && A.length === E.length && A.every((C, b) => {
773
812
  const T = E[b];
774
- return [.../* @__PURE__ */ new Set([...Object.keys(M), ...Object.keys(T)])].every((F) => F === "onClick" || Object.is(M[F], T[F]));
813
+ return [.../* @__PURE__ */ new Set([...Object.keys(C), ...Object.keys(T)])].every((z) => z === "onClick" || Object.is(C[z], T[z]));
775
814
  }) || (q.current = {
776
- source: $?.map((M) => ({ ...M })) ?? null,
777
- normalized: $?.map((M, b) => ({
778
- ...M,
779
- onClick: (...T) => (c.current.actions?.find((F) => F.key === M.key) ?? c.current.actions?.[b])?.onClick?.(...T)
815
+ source: A?.map((C) => ({ ...C })) ?? null,
816
+ normalized: A?.map((C, b) => ({
817
+ ...C,
818
+ onClick: (...T) => (s.current.actions?.find((z) => z.key === C.key) ?? s.current.actions?.[b])?.onClick?.(...T)
780
819
  }))
781
820
  });
782
- const U = q.current.normalized, W = K(() => ({
821
+ const Y = q.current.normalized, _ = K(() => ({
783
822
  showFooter: x,
784
- showFooterBorder: g,
823
+ showFooterBorder: c,
785
824
  doneDisabled: u,
786
- doneText: s,
825
+ doneText: a,
787
826
  cancelText: B,
788
- loadingText: R,
789
- footerClassName: A,
790
- ...U !== void 0 ? { actions: U } : {},
791
- ...l ? { done: f } : {},
792
- ...y ? { cancel: i } : {},
793
- ...C ? { renderFooter: m } : {}
794
- }), [x, g, u, s, B, R, A, U, l, y, C, f, i, m]);
795
- H(() => {
796
- r(t, W);
797
- }, [t, r, W]), H(() => () => r(t, null), [t, r]);
798
- }
799
- function Gn() {
800
- const e = Q(Fe), n = Q(Ye);
827
+ loadingText: P,
828
+ footerClassName: O,
829
+ ...Y !== void 0 ? { actions: Y } : {},
830
+ ...p ? { done: g } : {},
831
+ ...y ? { cancel: d } : {},
832
+ ...R ? { renderFooter: m } : {}
833
+ }), [x, c, u, a, B, P, O, Y, p, y, R, g, d, m]);
834
+ W(() => {
835
+ r(t, _);
836
+ }, [t, r, _]), W(() => () => r(t, null), [t, r]);
837
+ }
838
+ function et() {
839
+ const e = ee(De), n = ee(Ze);
801
840
  if (!e || !n) throw new Error("[react-modal-navigation] useModalLoading requires an active modal screen");
802
- const r = be(n.subscribe, n.getSnapshot, n.getSnapshot);
841
+ const r = fe(n.subscribe, n.getSnapshot, n.getSnapshot);
803
842
  return K(() => ({ ...e, isLoading: r.visible }), [e, r.visible]);
804
843
  }
805
- function et() {
806
- const e = Q(Fe);
844
+ function dt() {
845
+ const e = ee(De);
807
846
  if (!e) throw new Error("[react-modal-navigation] useModalLoadingCommands requires an active modal screen");
808
847
  return e;
809
848
  }
810
- function nt() {
811
- const e = Q(Ye);
849
+ function mt() {
850
+ const e = ee(Ze);
812
851
  if (!e) throw new Error("[react-modal-navigation] useModalLoadingState requires an active modal screen");
813
- return be(e.subscribe, e.getSnapshot, e.getSnapshot);
852
+ return fe(e.subscribe, e.getSnapshot, e.getSnapshot);
814
853
  }
815
- function tt() {
816
- const e = Gn(), n = sn(), r = d(!0), t = d(!1), [c, f] = ie(!1), [i, m] = ie(null), l = d(e);
817
- return l.current = e, H(() => (r.current = !0, () => {
854
+ function pt() {
855
+ const e = et(), n = yn(), r = l(!0), t = l(!1), [s, g] = le(!1), [d, m] = le(null), p = l(e);
856
+ return p.current = e, W(() => (r.current = !0, () => {
818
857
  r.current = !1;
819
- }), []), { run: v(async (C, x = {}) => {
858
+ }), []), { run: w(async (R, x = {}) => {
820
859
  if (t.current) return { status: "busy" };
821
- if (typeof C != "function") throw new TypeError("[react-modal-navigation] run requires a function");
822
- t.current = !0, r.current && (f(!0), m(null));
823
- const g = l.current.showLoading(x.loadingText);
860
+ if (typeof R != "function") throw new TypeError("[react-modal-navigation] run requires a function");
861
+ t.current = !0, r.current && (g(!0), m(null));
862
+ const c = p.current.showLoading(x.loadingText);
824
863
  try {
825
- const u = await C();
864
+ const u = await R();
826
865
  return r.current && await x.onSuccess?.(u), { status: "success", value: u };
827
866
  } catch (u) {
828
867
  if (r.current) {
829
868
  m(u);
830
869
  try {
831
870
  await x.onError?.(u);
832
- } catch (s) {
833
- console.error("[react-modal-navigation] onError failed", s);
871
+ } catch (a) {
872
+ console.error("[react-modal-navigation] onError failed", a);
834
873
  }
835
874
  }
836
875
  if (x.throwOnError) throw u;
837
876
  return { status: "error", error: u };
838
877
  } finally {
839
- g != null && l.current.hideLoading(g), t.current = !1, r.current && f(!1);
878
+ c != null && p.current.hideLoading(c), t.current = !1, r.current && g(!1);
840
879
  }
841
- }, []), pending: c, error: i, clearError: () => m(null), isFocused: n };
880
+ }, []), pending: s, error: d, clearError: () => m(null), isFocused: n };
842
881
  }
843
- function rt(e, n = {}) {
844
- const r = Q(tn);
882
+ function ft(e, n = {}) {
883
+ const r = ee(fn);
845
884
  if (!r) throw new Error("[react-modal-navigation] useModalUnsavedChanges must be used inside a modal screen");
846
- const t = d({ dirty: e, ...n });
885
+ const t = l({ dirty: e, ...n });
847
886
  t.current = { dirty: e, ...n };
848
- const { routeKey: c, registerDirtyGuard: f } = r;
849
- H(() => f(c, {
887
+ const { routeKey: s, registerDirtyGuard: g } = r;
888
+ W(() => g(s, {
850
889
  get dirty() {
851
890
  return !!t.current.dirty;
852
891
  },
@@ -856,38 +895,38 @@ function rt(e, n = {}) {
856
895
  get onBeforeDiscard() {
857
896
  return t.current.onBeforeDiscard;
858
897
  }
859
- }), [c, f]);
898
+ }), [s, g]);
860
899
  }
861
- const ot = () => {
862
- const e = Q(rn);
900
+ const gt = () => {
901
+ const e = ee(gn);
863
902
  if (!e) throw new Error("[react-modal-navigation] useToast requires an active modal");
864
903
  return e;
865
904
  };
866
- function Hn() {
867
- const e = Q(on);
905
+ function nt() {
906
+ const e = ee(hn);
868
907
  if (!e) throw new Error("[react-modal-navigation] useModalRoute requires a modal screen");
869
908
  return e;
870
909
  }
871
- function at() {
872
- return Hn().params;
910
+ function ht() {
911
+ return nt().params;
873
912
  }
874
913
  export {
875
- qn as ModalNavigator,
876
- _n as ModalProvider,
877
- Jn as useFocusEffect,
878
- sn as useIsFocused,
879
- Vn as useModal,
880
- Zn as useModalFooter,
881
- Gn as useModalLoading,
882
- et as useModalLoadingCommands,
883
- nt as useModalLoadingState,
884
- Qn as useModalNavigation,
885
- zn as useModalNavigationCommands,
886
- Kn as useModalNavigationState,
887
- at as useModalParams,
888
- Hn as useModalRoute,
889
- tt as useModalTask,
890
- rt as useModalUnsavedChanges,
891
- Xn as useNavigationResult,
892
- ot as useToast
914
+ Un as ModalNavigator,
915
+ at as ModalProvider,
916
+ ct as useFocusEffect,
917
+ yn as useIsFocused,
918
+ st as useModal,
919
+ ut as useModalFooter,
920
+ et as useModalLoading,
921
+ dt as useModalLoadingCommands,
922
+ mt as useModalLoadingState,
923
+ it as useModalNavigation,
924
+ Jn as useModalNavigationCommands,
925
+ Xn as useModalNavigationState,
926
+ ht as useModalParams,
927
+ nt as useModalRoute,
928
+ pt as useModalTask,
929
+ ft as useModalUnsavedChanges,
930
+ lt as useNavigationResult,
931
+ gt as useToast
893
932
  };