react-modal-navigation 1.1.4 → 1.1.6

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