react-modal-navigation 1.1.7 → 1.1.9

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