react-modal-navigation 1.1.9 → 1.1.11

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,140 +1,155 @@
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) {
1
+ import { jsx as i, jsxs as Ce } from "react/jsx-runtime";
2
+ import fe, { createContext as se, useState as xe, useEffect as H, useRef as k, useMemo as F, useSyncExternalStore as Ee, useContext as V, memo as Ue, useCallback as K, useReducer as Qn, useLayoutEffect as Ie, Suspense as Ln, useInsertionEffect as Zn } from "react";
3
+ import { createPortal as Xn } from "react-dom";
4
+ function Oe(e) {
6
5
  let n = e;
7
- const r = /* @__PURE__ */ new Set();
6
+ const t = /* @__PURE__ */ new Set();
7
+ let r = !1;
8
8
  return {
9
9
  getSnapshot: () => n,
10
- subscribe: (t) => (r.add(t), () => r.delete(t)),
11
- publish(t) {
12
- if (n !== t) {
13
- n = t;
14
- for (const c of [...r]) c();
10
+ subscribe: (o) => (r || t.add(o), () => t.delete(o)),
11
+ publish(o) {
12
+ if (!(r || Object.is(n, o))) {
13
+ n = o;
14
+ for (const g of [...t]) g();
15
15
  }
16
16
  },
17
- listenerCount: () => r.size
18
- };
19
- }
20
- function Te(e) {
21
- let n = e;
22
- const r = /* @__PURE__ */ new Set();
23
- return {
24
- getSnapshot: () => n,
25
- subscribe: (t) => (r.add(t), () => r.delete(t)),
26
- publish(t) {
27
- if (!Object.is(n, t)) {
28
- n = t;
29
- for (const c of [...r]) c();
30
- }
17
+ destroy() {
18
+ r = !0, t.clear();
31
19
  },
32
- listenerCount: () => r.size
20
+ listenerCount: () => t.size
33
21
  };
34
22
  }
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) {
23
+ const tn = se(null), An = se(null), Nn = se(null), Ve = se(null), De = se(null), bn = se(null), vn = se(null), rn = se(null), on = se(null), an = se(null), zn = se(null), Bn = se(null), sn = se(null), wn = se(null), xn = se(null), kn = se(null);
24
+ let Jn = 0;
25
+ const yn = (e, n) => ({ key: `modal-route-${++Jn}`, name: e, params: n ?? {} }), Fn = (e, n) => [yn(e, n)];
26
+ function Xe(e, n) {
38
27
  switch (n.type) {
28
+ case "COMMIT":
29
+ return n.stack;
39
30
  case "RESET":
40
- return Sn(n.name, n.params);
31
+ return Fn(n.name, n.params);
41
32
  case "NAVIGATE": {
42
- const r = e.findIndex((t) => t.name === n.name);
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);
33
+ const t = e.findIndex((r) => r.name === n.name);
34
+ return t < 0 ? [...e, yn(n.name, n.params)] : e.slice(0, t + 1).map((r, o) => o === t ? { ...r, params: n.params ?? {} } : r);
44
35
  }
45
36
  case "SET_OPTIONS":
46
- return e.map((r, t) => t === e.length - 1 ? { ...r, options: { ...r.options ?? {}, ...n.options ?? {} } } : r);
37
+ return e.map((t, r) => r === e.length - 1 ? { ...t, options: { ...t.options ?? {}, ...n.options ?? {} } } : t);
47
38
  case "SET_PARAMS":
48
- return e.map((r, t) => t === e.length - 1 ? { ...r, params: { ...r.params ?? {}, ...n.params ?? {} } } : r);
39
+ return e.map((t, r) => r === e.length - 1 ? { ...t, params: { ...t.params ?? {}, ...n.params ?? {} } } : t);
49
40
  case "BACK":
50
41
  return e.length > 1 ? e.slice(0, -1) : e;
51
42
  case "REPLACE":
52
- return e.length ? [...e.slice(0, -1), nn(n.name, n.params)] : e;
43
+ return e.length ? [...e.slice(0, -1), yn(n.name, n.params)] : e;
53
44
  default:
54
45
  return e;
55
46
  }
56
47
  }
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));
48
+ function et(e, n, t = 1 / 0) {
49
+ const r = t === 1 / 0 ? 1 / 0 : Math.max(0, Math.floor(Number(t) || 0)), o = e.slice(0, -1).filter((p) => n[p.name]?.keepAlive !== !1), g = new Set((r === 0 ? [] : o.slice(-r)).map((p) => p.key));
50
+ return e.filter((p, h) => h === e.length - 1 || g.has(p.key));
51
+ }
52
+ function nt(e, n) {
53
+ const t = e.responsive;
54
+ if (!t) return e;
55
+ const { sm: r, md: o, lg: g, xl: p } = t;
56
+ return { ...e, ...n < 768 ? r : n < 1024 ? o : n < 1280 ? g : p, ...e.runtimeLayout };
60
57
  }
61
- const $n = Object.freeze({ sm: 400, md: 560, lg: 720, xl: 960, full: "100%" }), Fe = (e) => typeof e == "number" ? `${e}px` : e, pn = () => {
58
+ function tt(e, n, t, r) {
59
+ const o = Math.max(0, Math.min(t ?? 1 / 0, r));
60
+ return Math.min(o, Math.max(Math.min(n ?? 240, o), e));
61
+ }
62
+ const rt = Object.freeze({ sm: 400, md: 560, lg: 720, xl: 960, full: "100%" }), Te = (e) => typeof e == "number" ? `${e}px` : e, Rn = () => {
62
63
  if (typeof document > "u") return "light";
63
64
  const e = document.documentElement, n = document.body;
64
65
  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
66
  };
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
- 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");
67
+ let Ge = 0;
68
+ const Ne = [];
69
+ let gn = null;
70
+ function ot() {
71
+ if (Ge++, Ge === 1) {
72
+ const n = document.documentElement, t = document.body, r = { html: n.style.overflow, body: t.style.overflow, padding: t.style.paddingRight, width: t.style.getPropertyValue("--modal-scrollbar-width") }, o = Math.max(0, window.innerWidth - n.clientWidth), g = parseFloat(getComputedStyle(t).paddingRight) || 0;
73
+ o && (t.style.paddingRight = `${g + o}px`), t.style.setProperty("--modal-scrollbar-width", `${o}px`), n.style.overflow = "hidden", t.style.overflow = "hidden", gn = () => {
74
+ n.style.overflow = r.html, t.style.overflow = r.body, t.style.paddingRight = r.padding, r.width ? t.style.setProperty("--modal-scrollbar-width", r.width) : t.style.removeProperty("--modal-scrollbar-width");
74
75
  };
75
76
  }
76
77
  let e = !1;
77
78
  return () => {
78
- e || (e = !0, je = Math.max(0, je - 1), je || (Xe?.(), Xe = null));
79
+ e || (e = !0, Ge = Math.max(0, Ge - 1), Ge || (gn?.(), gn = null));
79
80
  };
80
81
  }
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(() => {
82
+ const at = 'a[href],button:not([disabled]),input:not([disabled]),textarea:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])', st = (e) => !e.closest('[inert], [hidden], [aria-hidden="true"]') && e.getClientRects().length > 0 && getComputedStyle(e).visibility !== "hidden" && getComputedStyle(e).display !== "none";
83
+ function it({ dialogRef: e, options: n, requestClose: t, children: r, exiting: o = !1 }) {
84
+ const [g, p] = xe(() => typeof window > "u" ? 1024 : window.innerWidth), h = !!n.responsive;
85
+ H(() => {
86
+ if (!h) return;
87
+ const C = () => p(window.innerWidth < 768 ? 0 : window.innerWidth < 1024 ? 768 : window.innerWidth < 1280 ? 1024 : 1280);
88
+ return window.addEventListener("resize", C), C(), () => window.removeEventListener("resize", C);
89
+ }, [h]), n = nt(n, g);
90
+ const [l, d] = xe(null);
91
+ H(() => d(null), [n.width, n.placement]);
92
+ const u = k(null), x = k(0);
93
+ H(() => () => {
94
+ x.current && cancelAnimationFrame(x.current);
95
+ }, []);
96
+ const w = k(null), b = k(null), s = k(t);
97
+ s.current = t;
98
+ const m = k(n.closeOnEsc);
99
+ m.current = n.closeOnEsc;
100
+ const [M, I] = xe(Rn), j = n.theme === "light" || n.theme === "dark" ? n.theme : M;
101
+ H(() => {
89
102
  if (n.theme === "light" || n.theme === "dark") return;
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);
103
+ const C = () => I(Rn()), R = new MutationObserver(C);
104
+ for (const ge of [document.documentElement, document.body]) R.observe(ge, { attributes: !0, attributeFilter: ["class", "data-theme"] });
105
+ const de = window.matchMedia?.("(prefers-color-scheme: dark)");
106
+ return de?.addEventListener?.("change", C), C(), () => {
107
+ R.disconnect(), de?.removeEventListener?.("change", C);
95
108
  };
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");
109
+ }, [n.theme]), H(() => {
110
+ b.current = document.activeElement;
111
+ const C = ot(), R = w.current;
112
+ Ne.push(R), e.current?.focus({ preventScroll: !0 });
113
+ const de = (te) => {
114
+ const A = e.current;
115
+ if (!A || Ne.at(-1) !== R) return;
116
+ if (te.key === "Escape" && m.current !== !1) {
117
+ te.preventDefault(), s.current("escape");
105
118
  return;
106
119
  }
107
- if (B.key !== "Tab") return;
108
- const N = [...K.querySelectorAll(Dn)].filter(Kn);
109
- if (!N.length) {
110
- B.preventDefault(), K.focus();
120
+ if (te.key !== "Tab") return;
121
+ const y = [...A.querySelectorAll(at)].filter(st);
122
+ if (!y.length) {
123
+ te.preventDefault(), A.focus();
111
124
  return;
112
125
  }
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 });
126
+ const U = y[0], ve = y.at(-1);
127
+ A.contains(document.activeElement) ? te.shiftKey && (document.activeElement === U || document.activeElement === A) ? (te.preventDefault(), ve.focus()) : !te.shiftKey && (document.activeElement === ve || document.activeElement === A) && (te.preventDefault(), U.focus()) : (te.preventDefault(), (te.shiftKey ? ve : U).focus());
128
+ }, ge = (te) => {
129
+ Ne.at(-1) === R && e.current && !e.current.contains(te.target) && e.current.focus({ preventScroll: !0 });
117
130
  };
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 });
131
+ return document.addEventListener("keydown", de), document.addEventListener("focusin", ge), () => {
132
+ document.removeEventListener("keydown", de), document.removeEventListener("focusin", ge);
133
+ const te = Ne.at(-1) === R, A = Ne.indexOf(R);
134
+ if (A !== -1 && Ne.splice(A, 1), C(), te) {
135
+ const y = b.current;
136
+ y?.isConnected && !y.closest("[inert], [hidden]") ? y.focus?.({ preventScroll: !0 }) : Ne.at(-1)?.querySelector("[role=dialog]")?.focus?.({ preventScroll: !0 });
124
137
  }
125
138
  };
126
139
  }, [e]);
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(
140
+ const q = n.backgroundColor ?? n.backgroudColor, O = typeof q == "string" ? q : q?.[j], P = typeof O == "string" && /^(#|(?:rgb|rgba|hsl|hsla|hwb|oklch|oklab|lab|lch|color|color-mix|light-dark|var)\(|transparent$|currentColor$|[a-z]+$)/i.test(O.trim()) ? O.trim() : null, L = typeof O == "string" && !P ? O.trim() : "", Y = !!(P || L), T = ["center", "left", "right", "top", "bottom"].includes(n.placement) ? n.placement : "right", $ = Te(l ?? n.width ?? rt[n.size] ?? 460), Q = Te(n.height), X = Te(n.maxHeight), ne = Te(n.maxWidth), oe = Number(n.viewportGap ?? 5), be = Number.isFinite(oe) ? Math.max(0, oe) : 5, z = n.top == null ? null : Te(n.top), _ = T !== "bottom" && z !== null ? z : null, le = typeof n.borderRadius == "number" ? `${n.borderRadius}px` : n.borderRadius ?? "12px", W = n.resizable && !n.fullscreen && ["left", "right"].includes(T), ue = (C) => tt(C, n.minWidth, typeof n.maxWidth == "number" ? n.maxWidth : void 0, w.current?.clientWidth - be * 2 || window.innerWidth), ie = (C) => {
141
+ !u.current || u.current.id !== C.pointerId || (cancelAnimationFrame(x.current), d(u.current.width), e.current?.style.removeProperty("--pmn-drag-width"), u.current = null);
142
+ };
143
+ return Xn(/* @__PURE__ */ i(
129
144
  "div",
130
145
  {
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
- onMouseDown: (b) => {
135
- b.target === b.currentTarget && n.closeOnOverlay === !0 && f.current("overlay");
146
+ ref: w,
147
+ className: `pmn-overlay ${o ? "pmn-exiting" : "pmn-entering"} ${n.animation === !1 ? "pmn-no-animation" : ""} pmn-place-${T} ${n.fullscreen ? "pmn-fullscreen" : ""} ${n.mobileFullscreen ? "pmn-mobile-fullscreen" : ""}`,
148
+ style: { padding: be, ...n.bottom != null ? { paddingBottom: Te(n.bottom) } : {}, ...n.left != null ? { paddingLeft: Te(n.left) } : {}, ...n.right != null ? { paddingRight: Te(n.right) } : {}, ..._ !== null ? { paddingTop: _, "--pmn-top-offset": _ } : {}, "--pmn-animation-duration": `${Math.min(1e3, Math.max(0, Number(n.animationDuration ?? 220) || 0))}ms` },
149
+ onMouseDown: (C) => {
150
+ C.target === C.currentTarget && n.closeOnOverlay === !0 && s.current("overlay");
136
151
  },
137
- children: /* @__PURE__ */ s(
152
+ children: /* @__PURE__ */ Ce(
138
153
  "section",
139
154
  {
140
155
  ref: e,
@@ -142,896 +157,1170 @@ function En({ dialogRef: e, options: n, requestClose: r, children: t, exiting: c
142
157
  role: "dialog",
143
158
  "aria-modal": "true",
144
159
  "aria-label": n.ariaLabel ?? "Dialog",
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
- children: t
160
+ "data-modal-theme": j,
161
+ className: `pmn-dialog ${j === "dark" ? "dark" : ""} ${Y ? "pmn-has-custom-background" : ""} ${n.className ?? ""}`,
162
+ style: { "--pmn-width": $, "--pmn-gap": `${be}px`, ..._ !== null ? { "--pmn-top-offset": _ } : {}, ...Q !== void 0 ? { "--pmn-height": Q } : {}, ...X !== void 0 ? { "--pmn-max-height": X } : {}, ...ne !== void 0 ? { "--pmn-max-width": ne } : {}, borderRadius: le },
163
+ children: [
164
+ Y && /* @__PURE__ */ i("div", { "aria-hidden": "true", className: `pmn-custom-background-layer ${L}`, style: P ? { backgroundColor: P } : void 0 }),
165
+ r,
166
+ W && /* @__PURE__ */ i(
167
+ "div",
168
+ {
169
+ role: "separator",
170
+ "aria-label": "调整弹窗宽度",
171
+ "aria-orientation": "vertical",
172
+ tabIndex: 0,
173
+ className: `pmn-resize-handle pmn-resize-${T}`,
174
+ onKeyDown: (C) => {
175
+ ["ArrowLeft", "ArrowRight"].includes(C.key) && (C.preventDefault(), d(ue(e.current.getBoundingClientRect().width + (C.key === "ArrowRight" ? 16 : -16) * (T === "left" ? 1 : -1))));
176
+ },
177
+ onPointerDown: (C) => {
178
+ if (C.button !== 0) return;
179
+ C.preventDefault(), C.currentTarget.setPointerCapture(C.pointerId);
180
+ const R = e.current.getBoundingClientRect().width;
181
+ u.current = { id: C.pointerId, x: C.clientX, start: R, width: R };
182
+ },
183
+ onPointerMove: (C) => {
184
+ const R = u.current;
185
+ !R || R.id !== C.pointerId || (R.width = ue(R.start + (C.clientX - R.x) * (T === "left" ? 1 : -1)), cancelAnimationFrame(x.current), x.current = requestAnimationFrame(() => e.current?.style.setProperty("--pmn-drag-width", `${R.width}px`)));
186
+ },
187
+ onPointerUp: ie,
188
+ onPointerCancel: ie,
189
+ onLostPointerCapture: ie
190
+ }
191
+ )
192
+ ]
149
193
  }
150
194
  )
151
195
  }
152
196
  ), document.body);
153
197
  }
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" }) });
198
+ const ct = (e) => e;
199
+ function ke(e, n = ct, t = Object.is) {
200
+ const r = k({ store: null, initialized: !1, selection: void 0 }), o = F(() => {
201
+ let p = !1, h, l;
202
+ return () => {
203
+ const d = e.getSnapshot();
204
+ if (p && Object.is(h, d)) return l;
205
+ const u = n(d);
206
+ if (p)
207
+ t(l, u) || (l = u);
208
+ else {
209
+ const x = r.current;
210
+ l = x.initialized && x.store === e && t(x.selection, u) ? x.selection : u;
211
+ }
212
+ return h = d, p = !0, l;
213
+ };
214
+ }, [e, n, t]), g = Ee(e.subscribe, o, o);
215
+ return H(() => {
216
+ r.current = { store: e, initialized: !0, selection: g };
217
+ }, [e, g]), g;
218
+ }
219
+ function ze(e, n) {
220
+ if (Object.is(e, n)) return !0;
221
+ if (!e || !n || typeof e != "object" || typeof n != "object") return !1;
222
+ const t = Object.keys(e);
223
+ return t.length === Object.keys(n).length && t.every((r) => Object.hasOwn(n, r) && Object.is(e[r], n[r]));
224
+ }
225
+ const Ke = (e) => (n) => Object.fromEntries(e.map((t) => [t, n[t]])), lt = Ke(["pageAnimationDuration", "pageAnimationDistance", "pageAnimation", "animation", "lockCloseWhileLoading", "maxCachedScreens", "bodyClassName", "lazyFallback", "onBlur", "onNavigate", "onRouteChange", "onFocus"]), ut = Ke(["bodyClassName", "lazyFallback"]), dt = Ke(["showHeader", "showTitle", "renderHeader", "renderHeaderRight", "showHeaderBorder", "headerClassName", "showBackButton", "showCloseButton"]), jn = Ke(["showFooter", "renderFooter", "done", "cancel", "cancle", "showFooterBorder", "footerClassName", "actions", "loadingText", "cancelText", "doneText", "doneDisabled"]), mt = Ke(["fullscreenable", "fullscreen"]), Sn = ["responsive", "width", "height", "maxWidth", "maxHeight", "minWidth", "size", "placement", "viewportGap", "top", "bottom", "left", "right", "borderRadius", "resizable", "fullscreen", "mobileFullscreen", "animation", "animationDuration", "closeOnEsc", "closeOnOverlay", "theme", "backgroundColor", "backgroudColor", "ariaLabel", "className"], pt = Ke(Sn);
226
+ function ft(e, n) {
227
+ const t = { ...e, ...n, ...e.runtimeLayout };
228
+ return { ...pt(t), runtimeLayout: Object.fromEntries(Sn.filter((r) => Object.hasOwn(e.runtimeLayout ?? {}, r)).map((r) => [r, e.runtimeLayout[r]])) };
156
229
  }
157
- function Rn({ options: e, screen: n, route: r, navigation: t, requestClose: c, translate: g, canGoBack: p }) {
230
+ function gt(e, n) {
231
+ return ze(e.runtimeLayout, n.runtimeLayout) && Sn.every((t) => Object.is(e[t], n[t]));
232
+ }
233
+ const qn = {}, ht = () => qn, yt = () => () => {
234
+ }, bt = fe.memo(function({ action: n, context: t }) {
235
+ const r = k(!1), [o, g] = xe(!1), p = k(!1);
236
+ return H(() => (p.current = !0, () => {
237
+ p.current = !1;
238
+ }), []), /* @__PURE__ */ i("button", { type: "button", className: "pmn-icon-button", "aria-label": n.tooltip ?? n.key, title: n.tooltip, disabled: o || n.disabled || n.loading, onClick: async () => {
239
+ if (!(r.current || !p.current || n.disabled || n.loading)) {
240
+ r.current = !0, g(!0);
241
+ try {
242
+ await n.onClick?.(t);
243
+ } catch (h) {
244
+ console.error("[react-modal-navigation] header action", h);
245
+ } finally {
246
+ r.current = !1, p.current && g(!1);
247
+ }
248
+ }
249
+ }, children: o ? "…" : n.icon ?? n.label });
250
+ });
251
+ function Pn({ back: e }) {
252
+ return /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", children: e ? /* @__PURE__ */ i("path", { d: "m15 18-6-6 6-6" }) : /* @__PURE__ */ i("path", { d: "M18 6 6 18M6 6l12 12" }) });
253
+ }
254
+ function vt({ options: e, screen: n, route: t, navigation: r, requestClose: o, translate: g, canGoBack: p }) {
255
+ const h = V(tn), l = () => h?.getSnapshot()[t.key] ?? qn, d = Ee(h?.subscribe ?? yt, l, ht);
256
+ n = { ...n, ...d };
257
+ const u = g ?? ((M) => M), x = n.showTitle ?? e.showTitle ?? !0, w = typeof n.title == "function" ? n.title({ t: u, route: t, navigation: r }) : n.title ?? t.name, b = F(() => ({ route: t, navigation: r, close: o, canGoBack: p, title: w, t: u }), [t, r, o, p, w, u]);
158
258
  if (e.showHeader === !1) return null;
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, {}) })
259
+ const s = n.renderHeader ?? e.renderHeader;
260
+ if (s) return s(b);
261
+ const m = n.renderHeaderRight ?? e.renderHeaderRight;
262
+ return /* @__PURE__ */ Ce("header", { className: `pmn-header ${n.showHeaderBorder ?? e.showHeaderBorder ? "pmn-border-bottom" : ""} ${e.headerClassName ?? ""}`, children: [
263
+ (n.showBackButton ?? e.showBackButton) !== !1 && p && /* @__PURE__ */ i("button", { type: "button", className: "pmn-icon-button", "aria-label": u("modal.back"), onClick: () => r.goBack(), children: /* @__PURE__ */ i(Pn, { back: !0 }) }),
264
+ x ? /* @__PURE__ */ i("h2", { children: w }) : /* @__PURE__ */ i("div", { className: "pmn-header-spacer" }),
265
+ m?.(b),
266
+ d.actions?.filter((M) => !M.hidden).map((M) => /* @__PURE__ */ i(bt, { action: M, context: b }, `${t.key}:${M.key}`)),
267
+ /* @__PURE__ */ i(wt, { hidden: n.showFullscreenButton === !1 }),
268
+ (n.showCloseButton ?? e.showCloseButton) !== !1 && /* @__PURE__ */ i("button", { type: "button", className: "pmn-icon-button", "aria-label": u("modal.close"), onClick: () => o("header"), children: /* @__PURE__ */ i(Pn, {}) })
167
269
  ] });
168
270
  }
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, () => {
271
+ const wt = fe.memo(function({ hidden: n }) {
272
+ const t = V(wn), r = V(kn), o = ke(r.stores.layout, mt, ze);
273
+ return n || !o.fullscreenable ? null : /* @__PURE__ */ i("button", { type: "button", className: "pmn-icon-button", "aria-label": o.fullscreen ? "还原" : "全屏", onClick: t?.toggleFullscreen, children: /* @__PURE__ */ i("svg", { "aria-hidden": "true", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ i("path", { d: o.fullscreen ? "M3 9h6V3 M21 9h-6V3 M3 15h6v6 M21 15h-6v6" : "M3 9V3h6 M15 3h6v6 M3 15v6h6 M15 21h6v-6" }) }) });
274
+ }), $n = Ue(function({ store: n, screenOptions: t, ...r }) {
275
+ const o = K((p) => ft(p, t), [t]), g = ke(n, o, gt);
276
+ return /* @__PURE__ */ i(it, { ...r, options: g });
277
+ }), In = Ue(function({ store: n, ...t }) {
278
+ const r = ke(n, dt, ze);
279
+ return /* @__PURE__ */ i(vt, { ...t, options: r });
280
+ }), xt = fe.memo(function({ action: n, context: t, loadingApi: r, onError: o, loadingText: g }) {
281
+ const p = k(!1), [h, l] = xe(!1), d = k(!1);
282
+ H(() => (d.current = !0, () => {
172
283
  d.current = !1;
173
284
  }), []);
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"));
285
+ const u = h || n.loading === !0, x = n.loadingText ?? g ?? t.t("modal.processing"), w = async () => {
286
+ if (!d.current || p.current || n.disabled || n.loading || typeof n.onClick != "function") return;
287
+ p.current = !0, l(!0);
288
+ const b = r?.begin(t.route.key, x);
184
289
  try {
185
- await P(O);
186
- } catch (B) {
187
- f?.(B, { phase: "footer", action: b, route: t });
290
+ await n.onClick(t);
291
+ } catch (s) {
292
+ o?.(s, { phase: "footer", action: n.key, route: t.route });
188
293
  } finally {
189
- u?.end(t.key, U), k.current.delete(b), d.current && C((B) => B === b ? null : B);
294
+ b != null && r?.end(t.route.key, b), p.current = !1, d.current && l(!1);
190
295
  }
191
296
  };
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
- "button",
196
- {
197
- type: "button",
198
- disabled: b.disabled === !0 || P,
199
- className: `pmn-button ${b.variant === "primary" || b.variant === "danger" ? "pmn-button-primary" : "pmn-button-secondary"} ${b.variant === "danger" ? "pmn-button-danger" : ""}`,
200
- onClick: () => M(b.key, b.onClick, b.loadingText),
201
- children: P ? b.loadingText ?? a.loadingText ?? m("modal.processing") : b.label
202
- },
203
- b.key
204
- );
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") })
297
+ return /* @__PURE__ */ i(
298
+ "button",
299
+ {
300
+ type: "button",
301
+ disabled: n.disabled === !0 || u,
302
+ className: `pmn-button ${n.variant === "primary" || n.variant === "danger" ? "pmn-button-primary" : "pmn-button-secondary"} ${n.variant === "danger" ? "pmn-button-danger" : ""}`,
303
+ onClick: w,
304
+ children: u ? x : n.label
305
+ }
306
+ );
307
+ });
308
+ function Dn({ screen: e, options: n, override: t, route: r, navigation: o, requestClose: g, translate: p, onError: h, loadingApi: l }) {
309
+ const [d, u] = xe(null), x = k(/* @__PURE__ */ new Set()), w = k(!0);
310
+ H(() => (w.current = !0, () => {
311
+ w.current = !1;
312
+ }), []);
313
+ const b = p ?? (($) => $), s = { ...n, ...e, ...t }, { showFooter: m, renderFooter: M, done: I, cancel: j, cancle: q } = s, O = j ?? q, P = F(() => ({ route: r, navigation: o, close: g, t: b }), [r, o, g, b]);
314
+ if (m === !1) return null;
315
+ const L = `pmn-footer ${s.showFooterBorder ? "pmn-border-top" : ""} ${s.footerClassName ?? ""}`;
316
+ if (typeof M == "function") return /* @__PURE__ */ i("footer", { className: L, children: M({ ...P, pending: x.current.size > 0 }) });
317
+ const Y = Array.isArray(s.actions) ? s.actions : null;
318
+ if (!Y && typeof I != "function" && typeof O != "function") return null;
319
+ const T = async ($, Q, X) => {
320
+ if (!w.current || x.current.size > 0 || x.current.has($) || typeof Q != "function") return;
321
+ x.current.add($), u($);
322
+ const ne = l?.begin(r.key, s.loadingText ?? b("modal.processing"));
323
+ try {
324
+ await Q(P);
325
+ } catch (oe) {
326
+ h?.(oe, { phase: "footer", action: $, route: r });
327
+ } finally {
328
+ ne != null && l?.end(r.key, ne), x.current.delete($), w.current && u((oe) => oe === $ ? null : oe);
329
+ }
330
+ };
331
+ return Y ? /* @__PURE__ */ i("footer", { className: L, children: Y.filter(($) => !$.hidden).map(
332
+ ($) => /* @__PURE__ */ i(xt, { action: $, context: P, loadingApi: l, onError: h, loadingText: s.loadingText }, `${r.key}:${$.key}`)
333
+ ) }) : /* @__PURE__ */ Ce("footer", { className: L, children: [
334
+ typeof O == "function" && /* @__PURE__ */ i("button", { type: "button", disabled: d !== null, onClick: () => T("cancel", O), className: "pmn-button pmn-button-secondary", children: s.cancelText ?? b("modal.cancel") }),
335
+ typeof I == "function" && /* @__PURE__ */ i("button", { type: "button", disabled: d !== null || s.doneDisabled === !0, onClick: () => T("done", I), className: "pmn-button pmn-button-primary", children: d === "done" ? s.loadingText ?? b("modal.processing") : s.doneText ?? b("modal.done") })
208
336
  ] });
209
337
  }
210
- function Tn({ loading: e, translate: n }) {
338
+ function Kn({ loading: e, translate: n }) {
211
339
  if (!e.visible) return null;
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 })
340
+ const r = (n ?? ((g) => g))("modal.loading"), o = e.text ?? (r === "modal.loading" ? "加载中..." : r);
341
+ return /* @__PURE__ */ i("div", { className: "pmn-loading-overlay", role: "status", "aria-live": "polite", "aria-busy": "true", children: /* @__PURE__ */ Ce("div", { className: "pmn-loading-content", children: [
342
+ /* @__PURE__ */ i("span", { className: "pmn-spinner", "aria-hidden": "true" }),
343
+ o && /* @__PURE__ */ i("span", { className: "pmn-loading-text", children: o })
216
344
  ] }) });
217
345
  }
218
- class Mn extends be.Component {
346
+ class Cn extends fe.Component {
219
347
  state = { error: null };
220
348
  static getDerivedStateFromError(n) {
221
349
  return { error: n };
222
350
  }
223
- componentDidCatch(n, r) {
224
- this.props.onError?.(n, { phase: "render", route: this.props.route, componentStack: r.componentStack });
351
+ componentDidCatch(n, t) {
352
+ this.props.onError?.(n, { phase: "render", route: this.props.route, componentStack: t.componentStack });
225
353
  }
226
354
  componentDidUpdate(n) {
227
355
  n.route?.key !== this.props.route?.key && this.state.error && this.setState({ error: null });
228
356
  }
229
357
  render() {
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: "重试" })
358
+ return this.state.error ? /* @__PURE__ */ Ce("div", { role: "alert", className: "pmn-error-screen", children: [
359
+ /* @__PURE__ */ i("strong", { children: "页面加载失败" }),
360
+ /* @__PURE__ */ i("p", { children: this.state.error.message }),
361
+ /* @__PURE__ */ i("button", { type: "button", className: "pmn-button pmn-button-secondary", onClick: () => {
362
+ this.props.onRetry?.(), this.setState({ error: null });
363
+ }, children: "重试" })
234
364
  ] }) : this.props.children;
235
365
  }
236
366
  }
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
- ] }, r.id)) }) : null;
367
+ const kt = { success: "✓", error: "×", warning: "!", info: "i" };
368
+ function Hn({ items: e, dismiss: n }) {
369
+ return e.length ? /* @__PURE__ */ i("div", { className: "pmn-toast-region", "aria-label": "Notifications", children: e.map((t) => /* @__PURE__ */ Ce("div", { className: `pmn-toast pmn-toast-${t.type}`, role: t.type === "error" || t.type === "warning" ? "alert" : "status", children: [
370
+ /* @__PURE__ */ i("span", { className: "pmn-toast-symbol", "aria-hidden": "true", children: kt[t.type] }),
371
+ /* @__PURE__ */ i("span", { className: "pmn-toast-message", children: t.message }),
372
+ t.dismissible && /* @__PURE__ */ i("button", { type: "button", className: "pmn-toast-close", "aria-label": "Dismiss notification", onClick: () => n(t.id), children: "×" })
373
+ ] }, t.id)) }) : null;
244
374
  }
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;
375
+ function Wn(e, n, t) {
376
+ const r = k(0), o = k(/* @__PURE__ */ new Map()), g = K((l) => {
377
+ clearTimeout(o.current.get(l)), o.current.delete(l), n.current && e.current.publish(e.current.getSnapshot().filter((d) => d.id !== l));
378
+ }, []), p = K((l, d = {}) => {
379
+ if (typeof l != "string" || !l.trim()) throw new TypeError("[react-modal-navigation] toast message must be a non-empty string");
380
+ const u = typeof d == "string" ? { type: d } : d ?? {}, x = ["success", "error", "warning", "info"].includes(u.type) ? u.type : "info", w = ++r.current, b = Number.isFinite(u.duration) ? Math.max(0, u.duration) : 3e3;
251
381
  if (!n.current) return null;
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 });
382
+ const s = e.current.getSnapshot(), m = s.slice(0, Math.max(0, s.length - 4));
383
+ for (const M of m)
384
+ clearTimeout(o.current.get(M.id)), o.current.delete(M.id);
385
+ return e.current.publish([...s.slice(-4), { id: w, message: l, type: x, dismissible: u.dismissible !== !1 }]), b > 0 && o.current.set(w, setTimeout(() => g(w), b)), w;
386
+ }, [g]), h = F(() => {
387
+ const l = (d, u) => p(d, u);
388
+ for (const d of ["success", "error", "warning", "info"]) l[d] = (u, x = {}) => p(u, { ...x, type: d });
389
+ return l.promise = async (d, u, x = {}) => {
390
+ const w = p(u.loading, { ...x, type: "info", duration: 0 });
261
391
  try {
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;
392
+ const b = await (typeof d == "function" ? d() : d);
393
+ w != null && g(w);
394
+ const s = typeof u.success == "function" ? u.success(b) : u.success;
395
+ return s && p(s, { ...x, type: "success" }), b;
396
+ } catch (b) {
397
+ w != null && g(w);
398
+ const s = typeof u.error == "function" ? u.error(b) : u.error;
399
+ throw s && p(s, { ...x, type: "error" }), b;
270
400
  }
271
- }, f.dismiss = c, f.clear = () => {
272
- for (const u of t.current.values()) clearTimeout(u);
273
- t.current.clear(), e.current.publish([]);
274
- }, f;
275
- }, [g, c]);
276
- return Q(() => () => {
277
- for (const f of t.current.values()) clearTimeout(f);
278
- t.current.clear();
279
- }, []), { toast: p, dismissToast: c };
401
+ }, l.dismiss = g, l.clear = () => {
402
+ for (const d of o.current.values()) clearTimeout(d);
403
+ o.current.clear(), e.current.publish([]);
404
+ }, l;
405
+ }, [p, g]);
406
+ return H(() => {
407
+ const l = () => {
408
+ for (const u of o.current.values()) clearTimeout(u);
409
+ o.current.clear();
410
+ }, d = t?.addCleanup(l);
411
+ return () => {
412
+ d?.(), l();
413
+ };
414
+ }, [t]), { toast: h, dismissToast: g };
280
415
  }
281
- function An(e, n, r) {
282
- const t = l(/* @__PURE__ */ new Map()), c = l(0), g = w(() => {
416
+ function Gn(e, n, t, r) {
417
+ const o = r.loadingTasks, g = r.loadingSequence, p = K(() => {
283
418
  if (!n.current) return;
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);
419
+ const b = [...o.current.values()], s = { visible: b.length > 0, text: b.at(-1)?.text ?? null, count: b.length }, m = e.current.getSnapshot();
420
+ (m.visible !== s.visible || m.text !== s.text || m.count !== s.count) && e.current.publish(s);
421
+ }, []), h = K((b, s) => {
422
+ if (!n.current || b !== "global" && t.current !== b) return null;
423
+ const m = ++g.current;
424
+ return o.current.set(m, { owner: b, text: s }), p(), m;
425
+ }, [p]), l = K((b, s) => {
426
+ if (s != null)
427
+ o.current.get(s)?.owner === b && o.current.delete(s);
293
428
  else
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 };
429
+ for (const [m, M] of o.current) M.owner === b && o.current.delete(m);
430
+ p();
431
+ }, [p]), d = K((b, s) => {
432
+ b ? (l("global"), h("global", s)) : l("global");
433
+ }, [h, l]), u = K((b, s, m) => {
434
+ s ? (l(b), h(b, m)) : l(b);
435
+ }, [h, l]);
436
+ return { loadingApi: F(() => ({ setLoading: d, setScreenLoading: u, begin: h, end: l }), [d, u, h, l]), refreshLoading: p, loadingTasks: o, setLoading: d };
302
437
  }
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)` },
438
+ const St = fe.memo(function({ store: n, translate: t }) {
439
+ const r = Ee(n.subscribe, n.getSnapshot, n.getSnapshot);
440
+ return /* @__PURE__ */ i(Kn, { loading: r, translate: t });
441
+ }), Ct = fe.memo(function({ store: n, dismiss: t }) {
442
+ const r = Ee(n.subscribe, n.getSnapshot, n.getSnapshot);
443
+ return /* @__PURE__ */ i(Hn, { items: r, dismiss: t });
444
+ }), Et = fe.memo(function({ store: n, layoutStore: t, routeKey: r, ...o }) {
445
+ const g = () => n.getSnapshot()[r], p = Ee(n.subscribe, g, g), h = ke(t, jn, ze);
446
+ return /* @__PURE__ */ i(Dn, { ...o, options: h, override: p });
447
+ }), Mt = fe.memo(function({ route: n, screen: t, navigation: r, focused: o, resultEvent: g, setFooter: p, loadingApi: h, loadingStore: l, bodyClassName: d, notifyError: u, registerDirtyGuard: x, pageMotion: w, lazyFallback: b }) {
448
+ const s = t.component, m = k(null), M = k(!1);
449
+ Ie(() => {
450
+ const O = o && !M.current;
451
+ if (M.current = o, !O || !w?.enabled || !m.current?.animate) return;
452
+ const P = w.direction === "back" ? -100 : 100;
453
+ m.current.style.zIndex = "2";
454
+ const L = m.current.animate([
455
+ { opacity: 1, transform: `translate3d(${P}%,0,0)` },
321
456
  { opacity: 1, transform: "translate3d(0,0,0)" }
322
- ], { duration: d.duration, easing: "cubic-bezier(.22,1,.36,1)" });
457
+ ], { duration: w.duration, easing: "cubic-bezier(.22,1,.36,1)" });
323
458
  return () => {
324
- j.cancel(), T.current && (T.current.style.zIndex = "");
459
+ L.cancel(), m.current && (m.current.style.zIndex = "");
325
460
  };
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 }) }) }) }) }) }) }) }) });
461
+ }, [o, w?.enabled, w?.direction, w?.duration, w?.distance]);
462
+ const I = F(() => ({ isFocused: o, resultEvent: g, routeKey: n.key, setFooter: p }), [o, g, n.key, p]), j = F(() => ({
463
+ setLoading: (O, P) => h.setScreenLoading(n.key, O, P),
464
+ showLoading: (O) => h.begin(n.key, O),
465
+ hideLoading: (O) => h.end(n.key, O)
466
+ }), [h, n.key]), q = F(() => ({ routeKey: n.key, registerDirtyGuard: x }), [n.key, x]);
467
+ return /* @__PURE__ */ i(sn.Provider, { value: n, children: /* @__PURE__ */ i(bn.Provider, { value: q, children: /* @__PURE__ */ i(Ve.Provider, { value: I, children: /* @__PURE__ */ i(De.Provider, { value: j, children: /* @__PURE__ */ i(an.Provider, { value: l, children: /* @__PURE__ */ i("div", { ref: m, hidden: !o, inert: !o, "data-modal-route-key": n.key, tabIndex: -1, className: `pmn-body ${o && w?.enabled && typeof Element < "u" && !Element.prototype.animate ? `pmn-page-enter pmn-page-${w.direction}` : ""} ${d ?? ""}`, style: o && w?.enabled ? { "--pmn-page-duration": `${w.duration}ms`, "--pmn-page-distance": `${w.distance}px` } : void 0, children: /* @__PURE__ */ i(Cn, { route: n, onError: u, children: /* @__PURE__ */ i(Ln, { fallback: b ?? /* @__PURE__ */ i("div", { className: "pmn-lazy-loading", role: "status", "aria-live": "polite", children: "加载中..." }), children: /* @__PURE__ */ i(s, { route: n, navigation: r }) }) }) }) }) }) }) }) });
333
468
  });
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++;
342
- }), []);
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 };
362
- delete I[o], q.current.publish(I);
469
+ function Rt({ runtime: e, config: n, initialScreen: t, params: r, translate: o, onRequestClose: g, onOpened: p, registerLoading: h, notifyError: l, error: d, clearError: u, registerDirtyGuard: x, canNavigate: w, exiting: b = !1 }) {
470
+ const s = ke(e.stores.layout, lt, ze), [m, M] = Qn(Xe, e.stores.navigation.getSnapshot().stack), { navigation: I, loading: j, footer: q, toast: O } = e.refs, P = e.alive, L = k(0), { toast: Y, dismissToast: T } = Wn(O, P, e);
471
+ H(() => () => {
472
+ L.current++;
473
+ }, []);
474
+ const [$, Q] = xe({}), X = k(/* @__PURE__ */ new Map()), ne = k(null), oe = k(null), be = k(null), z = k(null), _ = k(null), le = k(!1), W = k(!1), ue = e.pageRequests, ie = k(0), C = K((c, E, D) => {
475
+ for (const [G, me] of ue.current)
476
+ c.includes(me.key) && (ue.current.delete(G), me.resolve({ status: E, ...E === "returned" ? { value: D } : {} }));
477
+ }, []), R = k(m);
478
+ R.current = m;
479
+ const de = k(w);
480
+ de.current = w;
481
+ const ge = k(!1), te = k(0), A = m.at(-1), y = A.key, U = k({ key: y, depth: m.length }), ve = U.current, we = ve.key !== y, Be = m.length < ve.depth ? "back" : "forward";
482
+ we && (U.current = { key: y, depth: m.length });
483
+ const Ye = Math.min(1e3, Math.max(0, Number(s.pageAnimationDuration ?? 360) || 0)), cn = Math.min(300, Math.max(0, Number(s.pageAnimationDistance ?? 96) || 0)), Re = F(() => ({ distance: cn, enabled: s.pageAnimation !== !1 && s.animation !== !1 && Ye > 0 && we, direction: Be, duration: Ye }), [cn, s.pageAnimation, s.animation, Ye, we, Be]), ln = k(y);
484
+ ln.current = y;
485
+ const { loadingApi: Qe, refreshLoading: un, loadingTasks: Ze, setLoading: Fe } = Gn(j, P, ln, e), Se = n.screens, Me = j, je = k(h);
486
+ je.current = h, H(() => (je.current?.({ setLoading: Fe }), () => je.current?.(null)), [Fe]);
487
+ const En = K((c, E) => {
488
+ if (!P.current) return;
489
+ const D = q.current.getSnapshot();
490
+ if (E === null) {
491
+ if (!(c in D)) return;
492
+ const G = { ...D };
493
+ delete G[c], q.current.publish(G);
363
494
  return;
364
495
  }
365
- z[o] !== S && q.current.publish({ ...z, [o]: S });
366
- }, []), X = w(() => {
496
+ D[c] !== E && q.current.publish({ ...D, [c]: E });
497
+ }, []), dn = K(() => {
367
498
  if (typeof document > "u") return;
368
- const o = document.activeElement;
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) => {
499
+ const c = document.activeElement;
500
+ if (!(c instanceof HTMLElement) || !ne.current?.contains(c)) return;
501
+ const E = c.closest("[data-modal-route-key]");
502
+ E && X.current.set(E.dataset.modalRouteKey, c), ne.current.focus({ preventScroll: !0 });
503
+ }, []), mn = K((c) => {
504
+ if (!Object.prototype.hasOwnProperty.call(Se, c)) throw new Error(`[react-modal-navigation] Unknown modal screen: ${c}`);
505
+ }, [Se]), a = K((c, E) => {
375
506
  try {
376
- Promise.resolve(t[o]?.(S)).catch((z) => u(z, { phase: o }));
377
- } catch (z) {
378
- u(z, { phase: o });
507
+ Promise.resolve(s[c]?.(E)).catch((D) => l(D, { phase: c }));
508
+ } catch (D) {
509
+ l(D, { phase: c });
379
510
  }
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;
511
+ }, [s, l]), f = K(async (c, E, D, G) => {
512
+ if (!P.current || W.current) return !1;
513
+ const me = L.current, Z = R.current, pe = Z.at(-1);
514
+ if (c !== "BACK" && mn(E), c === "BACK" && Z.length <= 1) return !1;
515
+ const Mn = c === "NAVIGATE" ? Z.findIndex((We) => We.name === E) : -1, pn = c === "RESET" ? Z : c === "BACK" || c === "REPLACE" ? [pe] : Mn >= 0 ? Z.slice(Mn + 1) : [];
516
+ W.current = !0;
386
517
  try {
387
- if (Qe.length && ie.current && !await ie.current(Qe.map((Je) => Je.key), {
518
+ if (pn.length && de.current && !await de.current(pn.map((fn) => fn.key), {
388
519
  reason: "navigation",
389
- action: o,
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;
393
- if (o === "BACK" && I !== void 0) {
394
- const Ce = Y.at(-2);
395
- b((Je) => ({ ...Je, [Ce.key]: { id: ++y.current, data: I } }));
520
+ action: c,
521
+ from: pe,
522
+ to: c === "BACK" ? Z.at(-2)?.name : E
523
+ }) || !P.current || me !== L.current || R.current.at(-1)?.key !== pe.key) return !1;
524
+ if (c === "BACK" && G !== void 0) {
525
+ const $e = Z.at(-2);
526
+ Q((fn) => ({ ...fn, [$e.key]: { id: ++te.current, data: G } }));
396
527
  }
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;
528
+ c === "RESET" && Q({}), C(pn.map(($e) => $e.key), c === "BACK" ? "returned" : "removed", G);
529
+ const We = [...oe.current?.querySelectorAll("[data-modal-route-key]") ?? []].find(($e) => $e.dataset.modalRouteKey === pe.key);
530
+ be.current = We?.cloneNode(!0) ?? null, dn();
531
+ const Yn = { type: c, name: E, params: D };
532
+ return R.current = Xe(R.current, Yn), M({ type: "COMMIT", stack: R.current }), !0;
533
+ } catch (We) {
534
+ return P.current && l(We, { phase: "navigationGuard", action: c }), !1;
404
535
  } finally {
405
- $.current = !1;
536
+ W.current = !1;
406
537
  }
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 });
538
+ }, [mn, dn, l, C]), S = K((c, E) => f("NAVIGATE", c, E), [f]), v = K(async (c, E) => {
539
+ if (!P.current) return { status: "cancelled" };
540
+ if (R.current, !await f("NAVIGATE", c, E) || !P.current) return { status: "cancelled" };
541
+ const G = R.current.at(-1);
542
+ return !G || G.name !== c ? { status: "cancelled" } : new Promise((me) => {
543
+ const Z = ++ie.current;
544
+ ue.current.set(Z, { key: G.key, resolve: me });
414
545
  });
415
- }, [ne]), ve = w((o, S) => ne("REPLACE", o, S), [ne]), qe = w((o, S) => ne("RESET", o, S), [ne]), Ee = w((o) => {
416
- if (!o || typeof o != "object" || Array.isArray(o)) throw new TypeError("[react-modal-navigation] setParams expects an object");
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) => {
421
- if (!o || typeof o != "object" || Array.isArray(o)) throw new TypeError("[react-modal-navigation] setOptions expects an object");
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 }
546
+ }, [f]), B = K((c, E) => f("REPLACE", c, E), [f]), N = K((c, E) => f("RESET", c, E), [f]), J = K((c) => {
547
+ if (!c || typeof c != "object" || Array.isArray(c)) throw new TypeError("[react-modal-navigation] setParams expects an object");
548
+ if (!P.current) return;
549
+ const E = { type: "SET_PARAMS", params: c };
550
+ R.current = Xe(R.current, E), M({ type: "COMMIT", stack: R.current });
551
+ }, []), ce = K((c) => {
552
+ if (!c || typeof c != "object" || Array.isArray(c)) throw new TypeError("[react-modal-navigation] setOptions expects an object");
553
+ if (!P.current) return;
554
+ const E = { type: "SET_OPTIONS", options: c };
555
+ R.current = Xe(R.current, E), M({ type: "COMMIT", stack: R.current });
556
+ }, []), ee = K((c) => f("BACK", null, void 0, c), [f]), he = K((c, E) => !P.current || Me.current.getSnapshot().visible && s.lockCloseWhileLoading !== !1 ? Promise.resolve(!1) : g(c, E, { route: A, stack: m }), [s.lockCloseWhileLoading, g, A, m]), qe = k(he);
557
+ qe.current = he;
558
+ const ae = K((c) => qe.current("api", c), []), Le = F(() => ({ navigate: S, navigateAsync: v, replace: B, reset: N, setParams: J, setOptions: ce, goBack: ee, close: ae, setLoading: Fe }), [S, v, B, N, J, ce, ee, ae, Fe]), He = F(() => ({ canGoBack: m.length > 1, stack: m, currentRoute: A }), [m]);
559
+ Ie(() => I.current.publish(He), [He]);
560
+ const ye = k(null);
561
+ ye.current || (ye.current = Object.defineProperties({}, {
562
+ canGoBack: { enumerable: !0, get: () => I.current.getSnapshot().canGoBack },
563
+ stack: { enumerable: !0, get: () => I.current.getSnapshot().stack },
564
+ currentRoute: { enumerable: !0, get: () => I.current.getSnapshot().currentRoute }
434
565
  }));
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);
566
+ const re = F(() => Object.assign(ye.current, Le), [Le]);
567
+ Ie(() => {
568
+ const c = be.current;
569
+ if (be.current = null, z.current?.cancel?.(), z.current = null, oe.current?.querySelectorAll("[data-pmn-outgoing]").forEach((pe) => pe.remove()), !we || !Re.enabled || !c || !oe.current || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) return;
570
+ const E = oe.current;
571
+ c.removeAttribute("hidden"), c.removeAttribute("tabindex"), c.setAttribute("aria-hidden", "true"), c.setAttribute("inert", ""), c.dataset.pmnOutgoing = "true", c.querySelectorAll("[id]").forEach((pe) => pe.removeAttribute("id")), c.querySelectorAll("[autofocus]").forEach((pe) => pe.removeAttribute("autofocus")), c.style.cssText += ";position:absolute;inset:0;width:100%;height:100%;z-index:1;pointer-events:none;overflow:hidden;background:var(--pmn-body);", E.appendChild(c);
572
+ const D = Re.direction === "back" ? 1 : -1, G = [...E.querySelectorAll("[data-modal-route-key]")].find((pe) => pe.dataset.modalRouteKey === y);
573
+ G && (G.style.zIndex = "2");
574
+ const me = () => {
575
+ c.remove(), G && (G.style.zIndex = ""), z.current === Z && (z.current = null);
445
576
  };
446
- let Y;
447
- if (o.animate)
448
- Y = o.animate([
577
+ let Z;
578
+ if (c.animate)
579
+ Z = c.animate([
449
580
  { 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;
581
+ { opacity: 1, transform: `translate3d(${D * 100}%,0,0)` }
582
+ ], { duration: Re.duration, easing: "cubic-bezier(.22,1,.36,1)", fill: "forwards" }), Z.addEventListener("finish", me, { once: !0 }), Z.addEventListener("cancel", me, { once: !0 }), z.current = Z;
452
583
  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;
584
+ c.classList.add("pmn-page-exit", `pmn-page-exit-${Re.direction}`), c.style.setProperty("--pmn-page-duration", `${Re.duration}ms`), c.style.setProperty("--pmn-page-distance", "100%");
585
+ const pe = setTimeout(me, Re.duration + 40);
586
+ Z = { cancel: () => {
587
+ clearTimeout(pe), me();
588
+ } }, z.current = Z;
458
589
  }
459
590
  return () => {
460
- Y?.cancel?.(), o.remove();
591
+ Z?.cancel?.(), c.remove();
461
592
  };
462
- }, [_]), He(() => {
463
- J.current = !1;
464
- const o = [...W.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((I) => I.dataset.modalRouteKey === _);
465
- if (!o) return;
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(() => {
469
- let o = !1;
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;
593
+ }, [y]), Ie(() => {
594
+ le.current = !1;
595
+ const c = [...ne.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((G) => G.dataset.modalRouteKey === y);
596
+ if (!c) return;
597
+ const E = X.current.get(y);
598
+ (E?.isConnected && c.contains(E) && !E.matches(":disabled") && !E.closest("[inert], [hidden]") ? E : c).focus({ preventScroll: !0 });
599
+ }, [y]), H(() => {
600
+ let c = !1;
601
+ for (const [D, G] of Ze.current)
602
+ G.owner !== "global" && G.owner !== y && (Ze.current.delete(D), c = !0);
603
+ c && un();
604
+ const E = new Set(m.map((D) => D.key));
605
+ Q((D) => {
606
+ const G = Object.keys(D).filter((Z) => !E.has(Z));
607
+ if (!G.length) return D;
608
+ const me = { ...D };
609
+ return G.forEach((Z) => delete me[Z]), me;
479
610
  });
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);
611
+ for (const D of X.current.keys()) E.has(D) || X.current.delete(D);
612
+ }, [y, m, un]), H(() => {
613
+ if (_.current?.key !== y) {
614
+ if (_.current) {
615
+ const c = { from: _.current, to: A, stack: m };
616
+ a("onBlur", { route: _.current, ...c }), a("onNavigate", c), a("onRouteChange", c);
486
617
  }
487
- ee("onFocus", { route: R, stack: a }), N.current = R;
618
+ a("onFocus", { route: A, stack: m }), _.current = A;
488
619
  }
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 }));
620
+ }, [A, y, m, a]), H(() => () => {
621
+ Ze.current.clear(), X.current.clear();
622
+ for (const c of ue.current.values()) c.resolve({ status: "dismissed" });
623
+ ue.current.clear();
624
+ }, []), H(() => {
625
+ ge.current || (ge.current = !0, p?.({ route: A, stack: m }));
495
626
  }, []);
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,
627
+ const Pe = F(() => et(m, Se, s.maxCachedScreens), [m, Se, s.maxCachedScreens]), Ae = F(() => ({ ...Se[A.name], ...A.options ?? {} }), [Se, A.name, A.options]), Vn = e.refs.header;
628
+ return /* @__PURE__ */ i(tn.Provider, { value: Vn.current, children: /* @__PURE__ */ i(vn.Provider, { value: Y, children: /* @__PURE__ */ i(Bn.Provider, { value: O.current, children: /* @__PURE__ */ i(zn.Provider, { value: q.current, children: /* @__PURE__ */ i(Nn.Provider, { value: re, children: /* @__PURE__ */ i(rn.Provider, { value: Le, children: /* @__PURE__ */ i(on.Provider, { value: I.current, children: /* @__PURE__ */ i(De.Provider, { value: Qe, children: /* @__PURE__ */ Ce($n, { store: e.stores.layout, screenOptions: Ae.modalOptions, dialogRef: ne, requestClose: he, exiting: b, children: [
629
+ /* @__PURE__ */ i(In, { store: e.stores.layout, screen: Ae, route: A, navigation: re, requestClose: he, translate: o, canGoBack: m.length > 1 }),
630
+ /* @__PURE__ */ i("main", { ref: oe, className: "pmn-main", children: Pe.map((c) => /* @__PURE__ */ i(
631
+ Mt,
501
632
  {
502
- route: o,
503
- screen: i[o.name],
504
- navigation: De,
505
- focused: o.key === _,
506
- resultEvent: M[o.key] ?? null,
507
- bodyClassName: t.bodyClassName,
508
- setFooter: E,
509
- loadingApi: ke,
510
- loadingStore: D.current,
511
- notifyError: u,
512
- registerDirtyGuard: k,
513
- pageMotion: ue,
514
- lazyFallback: t.lazyFallback
633
+ route: c,
634
+ screen: Se[c.name],
635
+ navigation: re,
636
+ focused: c.key === y,
637
+ resultEvent: $[c.key] ?? null,
638
+ bodyClassName: s.bodyClassName,
639
+ setFooter: En,
640
+ loadingApi: Qe,
641
+ loadingStore: j.current,
642
+ notifyError: l,
643
+ registerDirtyGuard: x,
644
+ pageMotion: c.key === y ? Re : null,
645
+ lazyFallback: s.lazyFallback
515
646
  },
516
- o.key
647
+ c.key
517
648
  )) }),
518
- /* @__PURE__ */ s(
519
- Wn,
649
+ /* @__PURE__ */ i(
650
+ Et,
520
651
  {
521
652
  store: q.current,
522
- routeKey: _,
523
- screen: un,
524
- options: t,
525
- route: R,
526
- navigation: De,
527
- requestClose: Oe,
528
- translate: c,
529
- onError: u,
530
- loadingApi: ke
653
+ routeKey: y,
654
+ screen: Ae,
655
+ layoutStore: e.stores.layout,
656
+ route: A,
657
+ navigation: re,
658
+ requestClose: he,
659
+ translate: o,
660
+ onError: l,
661
+ loadingApi: Qe
531
662
  },
532
- _
663
+ y
533
664
  ),
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: "×" })
665
+ /* @__PURE__ */ i(St, { store: j.current, translate: o }),
666
+ /* @__PURE__ */ i(Ct, { store: O.current, dismiss: T }),
667
+ d && /* @__PURE__ */ Ce("div", { className: "pmn-error", role: "alert", children: [
668
+ /* @__PURE__ */ i("span", { children: d.message || String(d) }),
669
+ /* @__PURE__ */ i("button", { type: "button", onClick: u, "aria-label": "Dismiss error", children: "×" })
539
670
  ] })
540
- ] }) }) }) }) }) }) }) });
671
+ ] }) }) }) }) }) }) }) }) });
541
672
  }
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: "×" })
614
- ] })
615
- ] }) }) }) }) }) }) }) });
673
+ const ar = (e) => e, sr = (e) => ({ definitionLoader: e }), Je = /* @__PURE__ */ new WeakMap();
674
+ function nn(e) {
675
+ if (!Je.has(e)) {
676
+ const n = Promise.resolve().then(e).catch((t) => {
677
+ throw Je.delete(e), t;
678
+ });
679
+ Je.set(e, n);
680
+ }
681
+ return Je.get(e);
616
682
  }
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(() => {
620
- if (typeof document > "u") return;
621
- const e = document;
622
- let n = en.get(e);
623
- if (!n) {
624
- let r = e.getElementById(gn);
625
- const t = !r;
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);
683
+ async function _n(e, n) {
684
+ let t = typeof e == "string" ? n?.[e] : e;
685
+ if (t?.definitionLoader) {
686
+ const r = await nn(t.definitionLoader);
687
+ t = r.default ?? r;
688
+ }
689
+ if (!t || !(t.component || t.loader || t.screens)) throw new Error(`[react-modal-navigation] Unknown or invalid modal: ${typeof e == "string" ? e : "inline"}`);
690
+ return t;
691
+ }
692
+ async function Pt(e, n, t) {
693
+ const r = await _n(e, n), o = r.screens ? r.screens[t ?? r.initialRoute ?? Object.keys(r.screens)[0]] : r;
694
+ if (!o) throw new Error("[react-modal-navigation] Unknown preload screen");
695
+ return o.loader && await nn(o.loader), r;
696
+ }
697
+ function Tt(e) {
698
+ return function(t) {
699
+ const [r, o] = xe(() => fe.lazy(() => nn(e)));
700
+ return /* @__PURE__ */ i(Cn, { route: t.route, onRetry: () => o(() => fe.lazy(() => nn(e))), children: /* @__PURE__ */ i(r, { ...t }) });
701
+ };
702
+ }
703
+ function Ot(e, n) {
704
+ const t = e.config.singlePage || Object.keys(e.config.screens).length === 1, r = t ? [{ key: "single", name: e.screen, params: e.params ?? {}, options: {} }] : Fn(e.screen, e.params), o = Oe({});
705
+ o.set = (s, m) => {
706
+ const M = o.getSnapshot();
707
+ if (m == null && !(s in M) || Object.is(M[s], m)) return;
708
+ const I = { ...M };
709
+ m == null ? delete I[s] : I[s] = m, o.publish(I);
710
+ };
711
+ const g = {
712
+ layout: Oe(n),
713
+ navigation: Oe({ canGoBack: !1, stack: r, currentRoute: r[0] }),
714
+ header: o,
715
+ footer: Oe({}),
716
+ loading: Oe({ visible: !1, text: null, count: 0 }),
717
+ toast: Oe([])
718
+ }, p = Object.fromEntries(Object.entries(g).map(([s, m]) => [s, { current: m }])), h = { current: !0 }, l = /* @__PURE__ */ new Set(), d = { current: /* @__PURE__ */ new Map() }, u = { current: /* @__PURE__ */ new Map() }, x = { current: 0 }, w = (s) => h.current ? (l.add(s), () => l.delete(s)) : (s(), () => {
719
+ }), b = () => {
720
+ if (h.current) {
721
+ h.current = !1;
722
+ for (const s of l)
723
+ try {
724
+ s();
725
+ } catch (m) {
726
+ console.error(m);
727
+ }
728
+ l.clear(), d.current.clear();
729
+ for (const s of u.current.values()) s.resolve({ status: "dismissed" });
730
+ u.current.clear(), Object.values(g).forEach((s) => s.destroy());
627
731
  }
628
- return n.count += 1, () => {
629
- n.count -= 1, n.count === 0 && (n.owned && n.element.remove(), en.delete(e));
630
- };
631
- }, []);
732
+ };
733
+ return { id: e.id, single: t, stores: g, refs: p, alive: h, loadingTasks: d, loadingSequence: x, pageRequests: u, addCleanup: w, destroy: b };
632
734
  }
633
- function Ge(e, n, r) {
735
+ function _e(e, n, t) {
634
736
  if (typeof e == "string") {
635
737
  if (!e.trim()) throw new TypeError("[react-modal-navigation] modal name must not be empty");
636
- return { name: e, params: n ?? {}, options: r ?? {} };
738
+ return { name: e, params: n ?? {}, options: t ?? {} };
637
739
  }
638
740
  if (e === null || typeof e != "object" || Array.isArray(e))
639
741
  throw new TypeError("[react-modal-navigation] open expects a modal name or a configuration object");
640
- const { name: t, screen: c, params: g = {}, options: p = {}, ...f } = e;
641
- if (typeof t != "string" || !t.trim())
742
+ if (e.component || e.loader || e.screens || e.definitionLoader) {
743
+ const { params: l, options: d, screen: u, ...x } = e;
744
+ return { name: x, params: n ?? l ?? {}, options: { ...d, ...t }, screen: u };
745
+ }
746
+ const { name: r, screen: o, params: g = {}, options: p = {}, ...h } = e;
747
+ if (typeof r != "string" || !r.trim())
642
748
  throw new TypeError("[react-modal-navigation] open config requires a non-empty string name");
643
749
  if (p === null || typeof p != "object" || Array.isArray(p))
644
750
  throw new TypeError("[react-modal-navigation] open config options must be an object");
645
- if (c !== void 0 && (typeof c != "string" || !c.trim()))
751
+ if (o !== void 0 && (typeof o != "string" || !o.trim()))
646
752
  throw new TypeError("[react-modal-navigation] screen must be a non-empty string");
647
- return { name: t, ...c === void 0 ? {} : { screen: c }, params: g, options: { ...f, ...p } };
753
+ return { name: r, ...o === void 0 ? {} : { screen: o }, params: g, options: { ...h, ...p } };
648
754
  }
649
- function nt() {
755
+ function Lt() {
650
756
  const e = /* @__PURE__ */ new Map();
651
757
  return {
652
758
  wait(n) {
653
- return new Promise((r) => {
654
- const t = setTimeout(() => {
655
- e.delete(t), r();
759
+ return n <= 0 ? Promise.resolve() : new Promise((t) => {
760
+ const r = setTimeout(() => {
761
+ e.delete(r), t();
656
762
  }, Math.max(0, n));
657
- e.set(t, r);
763
+ e.set(r, t);
658
764
  });
659
765
  },
660
766
  cancelAll() {
661
- for (const [n, r] of e)
662
- clearTimeout(n), r();
767
+ for (const [n, t] of e)
768
+ clearTimeout(n), t();
663
769
  e.clear();
664
770
  },
665
771
  pendingCount: () => e.size
666
772
  };
667
773
  }
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;
774
+ const At = { placement: "right", showHeader: !0, showBackButton: !0, showCloseButton: !0, viewportGap: 5, borderRadius: 12, closeOnOverlay: !1, closeOnEsc: !0 };
775
+ function Nt(e, n) {
776
+ let t = e;
777
+ const r = /* @__PURE__ */ new Set(), { confirmDiscard: o, onError: g } = t, p = Oe({ isOpen: !1, activeName: null, isFullscreen: !1, queueSize: 0, error: null }), h = Oe({ active: null, options: null, exiting: !1, error: null, translate: t.translate });
778
+ let l = null;
779
+ const d = (a) => {
780
+ l = a, Me();
781
+ };
782
+ let u = null;
783
+ const x = (a) => {
784
+ u = a, Me();
785
+ };
786
+ let w = 0;
787
+ const b = (a) => {
788
+ w = a, Me();
789
+ }, s = { current: null }, m = { current: /* @__PURE__ */ new Map() }, M = { current: [] }, I = { current: null }, j = { current: null }, q = { current: 0 }, O = { current: null }, P = { current: !1 }, L = { current: 0 }, Y = { current: null }, T = { current: /* @__PURE__ */ new Map() };
790
+ let $ = !1;
791
+ const Q = (a) => {
792
+ $ = a, Me();
793
+ }, X = { current: o }, ne = ((a, f) => (T.current.set(a, f), () => {
794
+ T.current.get(a) === f && T.current.delete(a);
795
+ })), oe = (async (a) => {
796
+ for (const f of T.current.values()) {
797
+ if (!f.dirty) continue;
798
+ if ((f.onBeforeDiscard ? await f.onBeforeDiscard(a) : X.current ? await X.current(a) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(f.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
679
799
  }
680
800
  return !0;
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;
801
+ }), be = (async (a, f) => {
802
+ for (const S of a) {
803
+ const v = T.current.get(S);
804
+ if (!v?.dirty) continue;
805
+ if ((v.onBeforeDiscard ? await v.onBeforeDiscard(f) : X.current ? await X.current(f) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(v.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
686
806
  }
687
807
  return !0;
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);
808
+ }), z = { current: !0 }, _ = { current: null };
809
+ _.current || (_.current = Lt());
810
+ const le = { current: g }, W = ((a, f) => {
811
+ z.current && x(a);
694
812
  try {
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);
813
+ le.current ? le.current(a, f) : console.error("[react-modal-navigation]", a);
814
+ } catch (S) {
815
+ console.error("[react-modal-navigation] onError failed", S);
698
816
  }
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 };
817
+ }), ue = ((a, f) => {
818
+ const S = m.current.get(a);
819
+ m.current.delete(a);
820
+ for (const v of S ?? []) v(f);
821
+ }), ie = ((a) => ({ ...At, ...t.defaultOptions, ...t.theme !== void 0 ? { theme: t.theme } : {}, ...t.backgroundColor !== void 0 ? { backgroundColor: t.backgroundColor } : {}, ...a.config.modalOptions, ...a.overrides, runtimeLayout: a.runtimeLayout })), C = (async (a = "api", f, S = {}) => {
822
+ const v = s.current;
823
+ if (!v || O.current || P.current) return !1;
824
+ const B = L.current;
825
+ O.current = v.id, P.current = !0;
826
+ const N = ie(v), J = { ...S, reason: a, result: f, name: v.name };
709
827
  try {
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 });
828
+ if (!await oe(J) || B !== L.current || s.current?.id !== v.id || await N.onBeforeClose?.(J) === !1 || s.current?.id !== v.id || !z.current) return !1;
829
+ Q(!0);
830
+ const ce = N.animation === !1 || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? 0 : Math.max(0, Number(N.animationDuration ?? 220) || 0);
831
+ if (await _.current.wait(Math.min(ce, 1e3)), !z.current || s.current?.id !== v.id) return !1;
832
+ v.runtime.destroy(), s.current = null, Y.current = null, $ = !1, d(null), T.current.clear(), ue(v.id, S.confirmed || f !== void 0 ? { status: "confirmed", value: f, reason: a } : { status: "dismissed", reason: a });
715
833
  try {
716
- await X.onClose?.(Z);
717
- } catch (ne) {
718
- ae(ne, { phase: "onClose", name: E.name });
834
+ (S.confirmed || f !== void 0) && await N.onConfirmed?.(f), await N.onClose?.(J), await N.onClosed?.(J);
835
+ } catch (ee) {
836
+ B === L.current && W(ee, { phase: "onClose", name: v.name });
719
837
  }
720
838
  return !0;
721
- } catch (ee) {
722
- return ae(ee, { phase: "onBeforeClose", name: E.name }), !1;
839
+ } catch (ce) {
840
+ return B === L.current && s.current?.id === v.id && W(ce, { phase: "onBeforeClose", name: v.name }), !1;
723
841
  } finally {
724
- x.current === E.id && (x.current = null), O.current = !1, !a.current && N.current && queueMicrotask(() => q.current?.());
842
+ O.current === v.id && (O.current = null), B === L.current && (P.current = !1), !s.current && z.current && queueMicrotask(() => j.current?.());
725
843
  }
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;
844
+ }), R = (async (a, f = {}, S = {}, v, B) => {
845
+ if (!z.current || P.current || O.current) return null;
846
+ P.current = !0;
847
+ const N = L.current;
734
848
  try {
735
- const de = a.current;
736
- if (de) {
737
- const qe = $.current ?? V(de), Ee = { reason: "replace", name: de.name, nextName: i };
849
+ const J = await _n(a, t.registry);
850
+ if (!z.current || N !== L.current) return null;
851
+ const ce = (re) => re.loader && !re.component ? { ...re, component: n(re.loader) } : re, ee = J.screens ? { ...J, screens: Object.fromEntries(Object.entries(J.screens).map(([re, Pe]) => [re, ce(Pe)])) } : ce(J);
852
+ a = typeof a == "string" ? a : J.name ?? "inline";
853
+ const he = ee?.component && !ee.screens ? { ...ee, singlePage: !0, initialRoute: "__single__", screens: { __single__: { component: ee.component, title: ee.title, ...J.screenOptions ?? {} } } } : ee;
854
+ if (!he) throw new Error(`[react-modal-navigation] Unknown modal: ${a}`);
855
+ const qe = B ?? he.initialRoute ?? Object.keys(he.screens ?? {})[0];
856
+ if (!he.screens?.[qe]) throw new Error(`[react-modal-navigation] Unknown initial screen '${qe}' in modal '${a}'`);
857
+ const ae = s.current, Le = S.instanceKey ?? he.modalOptions?.instanceKey, He = S.duplicateStrategy ?? he.modalOptions?.duplicateStrategy;
858
+ if (ae && Le != null && ae.instanceKey === Le) {
859
+ if (He === "ignore") return null;
860
+ if (He === "reuse") {
861
+ if (v) {
862
+ const re = m.current.get(ae.id) ?? [];
863
+ re.push(v), m.current.set(ae.id, re);
864
+ }
865
+ return ae.id;
866
+ }
867
+ }
868
+ if (ae) {
869
+ const re = ie(ae), Pe = { reason: "replace", name: ae.name, nextName: a };
738
870
  try {
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;
871
+ if (!await oe(Pe) || N !== L.current || s.current?.id !== ae.id || await re.onBeforeClose?.(Pe) === !1) return null;
872
+ } catch (Ae) {
873
+ return N === L.current && s.current?.id === ae.id && W(Ae, { phase: "onBeforeClose", name: ae.name }), null;
742
874
  }
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" });
875
+ if (!z.current || N !== L.current || s.current?.id !== ae.id) return null;
876
+ ae.runtime.destroy(), s.current = null, Y.current = null, d(null), T.current.clear(), ue(ae.id, { status: "replaced", reason: "replace" });
745
877
  try {
746
- await qe.onClose?.(Ee);
747
- } catch (Re) {
748
- ae(Re, { phase: "onClose", name: de.name });
878
+ await re.onClose?.(Pe), await re.onClosed?.(Pe);
879
+ } catch (Ae) {
880
+ N === L.current && W(Ae, { phase: "onClose", name: ae.name });
749
881
  }
750
- if (!N.current || Be !== j.current) return null;
882
+ if (!z.current || N !== L.current) return null;
751
883
  }
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;
884
+ const ye = { id: ++q.current, name: a, screen: qe, params: f, config: he, overrides: S, instanceKey: Le };
885
+ return ye.runtime = Ot(ye, ie(ye)), ye.runtime.bindings = je(ye.id), s.current = ye, Y.current = null, v && m.current.set(ye.id, [v]), u = null, d(ye), ye.id;
754
886
  } finally {
755
- O.current = !1;
887
+ N === L.current && (P.current = !1), !s.current && z.current && queueMicrotask(() => j.current?.());
756
888
  }
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);
889
+ });
890
+ I.current = R;
891
+ const de = (async () => {
892
+ if (!z.current || s.current || P.current || O.current) return;
893
+ const a = M.current.shift();
894
+ if (a) {
895
+ r.add(a), b(M.current.length);
764
896
  try {
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?.());
897
+ const f = await I.current(a.args.name, a.args.params, a.args.options, a.resolveResult, a.args.screen);
898
+ f === null ? (a.resolveResult?.({ status: "dismissed", reason: "blocked" }), a.resolveId?.(null), queueMicrotask(() => j.current?.())) : a.resolveId?.(f);
899
+ } catch (f) {
900
+ a.reject?.(f), queueMicrotask(() => j.current?.());
901
+ } finally {
902
+ r.delete(a);
769
903
  }
770
904
  }
771
- }, []);
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);
905
+ });
906
+ j.current = de;
907
+ const ge = ((a, f, S) => {
908
+ if (!z.current) return Promise.resolve(null);
909
+ const v = _e(a, f, S);
910
+ return typeof v.name == "string" && !t.registry?.[v.name] ? Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${v.name}`)) : new Promise((B, N) => {
911
+ M.current.push({ args: v, resolveId: B, reject: N }), b(M.current.length), queueMicrotask(() => j.current?.());
804
912
  });
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: [
816
- n,
817
- u && /* @__PURE__ */ s(
818
- Se,
819
- {
820
- config: u.config,
821
- initialScreen: u.screen,
822
- params: u.params,
823
- options: ie,
824
- translate: g,
825
- notifyError: ae,
826
- error: C,
827
- clearError: () => k(null),
828
- registerLoading: (i) => {
829
- F.current = i;
830
- },
831
- registerDirtyGuard: U,
832
- canNavigate: K,
833
- exiting: b,
834
- onRequestClose: y,
835
- onOpened: (i) => {
836
- try {
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" });
841
- }
913
+ }), te = ((a, f, S) => {
914
+ if (!z.current) return Promise.resolve({ status: "dismissed", reason: "unmount" });
915
+ const v = _e(a, f, S);
916
+ return typeof v.name == "string" && !t.registry?.[v.name] ? Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${v.name}`)) : new Promise((B, N) => {
917
+ M.current.push({ args: v, resolveResult: B, reject: N }), b(M.current.length), queueMicrotask(() => j.current?.());
918
+ });
919
+ }), A = ((a) => {
920
+ if (!a || typeof a != "object" || Array.isArray(a)) throw new TypeError("[react-modal-navigation] update expects an options object");
921
+ const f = s.current;
922
+ return !f || P.current ? !1 : (Object.keys(a).every((S) => Object.is(ie(f)[S], a[S])) || (f.overrides = { ...f.overrides, ...a }, f.runtimeLayout = { ...f.runtimeLayout, ...a }, Me()), !0);
923
+ }), y = ((a, f) => Pt(a, t.registry, f)), U = ((a) => A({ fullscreen: !!a })), ve = (() => U(!(s.current && ie(s.current).fullscreen))), we = ((a = "queue-cleared") => {
924
+ const f = M.current.splice(0);
925
+ b(0);
926
+ for (const S of f)
927
+ S.resolveId?.(null), S.resolveResult?.({ status: "dismissed", reason: a });
928
+ return f.length;
929
+ }), Fe = { open: ((a, f, S) => {
930
+ const v = _e(a, f, S);
931
+ return R(v.name, v.params, v.options, void 0, v.screen);
932
+ }), openInstance: (async (a, f, S) => {
933
+ const v = _e(a, f, S);
934
+ let B;
935
+ const N = new Promise((ee) => {
936
+ B = ee;
937
+ }), J = await R(v.name, v.params, v.options, B, v.screen);
938
+ J === null && B({ status: "dismissed", reason: "blocked" });
939
+ const ce = () => J !== null && s.current?.id === J;
940
+ return { id: J, result: N, isActive: ce, setOptions: (ee) => ce() && A(ee), setFullscreen: (ee) => ce() && A({ fullscreen: !!ee }), close: (ee) => ce() ? C("api", ee) : Promise.resolve(!1), confirm: (ee) => ce() ? C("confirm", ee, { confirmed: !0 }) : Promise.resolve(!1) };
941
+ }), openAsync: ((a, f, S) => {
942
+ const v = _e(a, f, S);
943
+ return new Promise((B, N) => {
944
+ R(v.name, v.params, v.options, B, v.screen).then((J) => {
945
+ J === null && B({ status: "dismissed", reason: "blocked" });
946
+ }, N);
947
+ });
948
+ }), enqueue: ge, enqueueAsync: te, update: A, setOptions: A, preload: y, setFullscreen: U, toggleFullscreen: ve, clearQueue: we, close: ((a) => C("api", a)), dismiss: ((a = "api") => C(a)), confirm: ((a) => C("confirm", a, { confirmed: !0 })), setLoading: ((a, f) => Y.current?.setLoading(a, f)), clearError: () => x(null) }, Se = (a, f) => Object.keys(a).length === Object.keys(f).length && Object.keys(a).every((S) => Object.is(a[S], f[S]));
949
+ function Me() {
950
+ const a = l ? ie(l) : null, f = h.getSnapshot();
951
+ l && !Se(a, l.runtime.stores.layout.getSnapshot()) && l.runtime.stores.layout.publish(a);
952
+ const S = l ? f.active === l ? f.options : a : null, v = { isOpen: !!l, activeName: l?.name ?? null, isFullscreen: !!a?.fullscreen, queueSize: w, error: u }, B = { active: l, options: S, exiting: $, error: u, translate: t.translate };
953
+ Se(v, p.getSnapshot()) || p.publish(v), Se(B, f) || h.publish(B);
954
+ }
955
+ const je = (a) => ({
956
+ registerLoading: (f) => {
957
+ s.current?.id === a && (Y.current = f);
958
+ },
959
+ registerDirtyGuard: (f, S) => s.current?.id === a ? ne(f, S) : () => {
960
+ },
961
+ canNavigate: (f, S) => s.current?.id === a ? be(f, S) : Promise.resolve(!1),
962
+ onRequestClose: (...f) => s.current?.id === a ? C(...f) : Promise.resolve(!1),
963
+ onOpened: (f) => {
964
+ if (s.current?.id !== a) return;
965
+ const S = ie(s.current), v = (B, N) => {
966
+ s.current?.id === a && W(B, { phase: N });
967
+ };
968
+ for (const B of ["onOpen", "onOpened"])
969
+ try {
970
+ Promise.resolve(S[B]?.(f)).catch((N) => v(N, B));
971
+ } catch (N) {
972
+ v(N, B);
842
973
  }
843
- },
844
- u.id
845
- )
846
- ] });
974
+ }
975
+ });
976
+ return { commands: Fe, statusStore: p, hostStore: h, bindInstance: je, configure: (a) => {
977
+ t = a, X.current = a.confirmDiscard, le.current = a.onError, Me();
978
+ }, mount: () => {
979
+ z.current = !0;
980
+ }, destroy: () => {
981
+ z.current = !1, L.current += 1, _.current.cancelAll(), s.current?.runtime.destroy(), s.current = null, Y.current = null, O.current = null, P.current = !1;
982
+ for (const a of m.current.keys()) ue(a, { status: "dismissed", reason: "unmount" });
983
+ m.current.clear(), T.current.clear(), l = null, $ = !1, u = null;
984
+ for (const a of r)
985
+ a.resolveId?.(null), a.resolveResult?.({ status: "dismissed", reason: "unmount" });
986
+ r.clear(), we("unmount"), Me();
987
+ }, reportError: W };
988
+ }
989
+ const zt = fe.memo(function({ Screen: n, route: t, navigation: r }) {
990
+ return /* @__PURE__ */ i(n, { route: t, navigation: r });
991
+ }), Bt = fe.memo(function({ store: n, layoutStore: t, route: r, ...o }) {
992
+ const g = () => n.getSnapshot()[r.key], p = Ee(n.subscribe, g, g), h = ke(t, jn, ze);
993
+ return /* @__PURE__ */ i(Dn, { ...o, options: h, route: r, override: p });
994
+ }), Ft = fe.memo(function({ store: n, translate: t }) {
995
+ const r = Ee(n.subscribe, n.getSnapshot, n.getSnapshot);
996
+ return /* @__PURE__ */ i(Kn, { loading: r, translate: t });
997
+ }), jt = fe.memo(function({ store: n, dismiss: t }) {
998
+ const r = Ee(n.subscribe, n.getSnapshot, n.getSnapshot);
999
+ return /* @__PURE__ */ i(Hn, { items: r, dismiss: t });
1000
+ });
1001
+ function qt({ runtime: e, config: n, initialScreen: t, params: r, translate: o, onRequestClose: g, onOpened: p, registerLoading: h, notifyError: l, error: d, clearError: u, registerDirtyGuard: x, exiting: w = !1 }) {
1002
+ const b = ke(e.stores.layout, ut, ze), s = t ?? n.initialRoute ?? Object.keys(n.screens)[0], [m, M] = xe(() => e.stores.navigation.getSnapshot().currentRoute), I = k(m);
1003
+ I.current = m;
1004
+ const j = n.screens[s], q = e.alive, O = k(null), { navigation: P, footer: L, loading: Y, toast: T } = e.refs, $ = k("single"), { loadingApi: Q, setLoading: X } = Gn(Y, q, $, e), { toast: ne, dismissToast: oe } = Wn(T, q, e), be = K((y, U) => {
1005
+ const ve = L.current, we = ve.getSnapshot();
1006
+ if (U === null) {
1007
+ if (we[y] !== void 0) {
1008
+ const Be = { ...we };
1009
+ delete Be[y], ve.publish(Be);
1010
+ }
1011
+ } else we[y] !== U && ve.publish({ ...we, [y]: U });
1012
+ }, []), z = K((y = "api", U) => !q.current || Y.current.getSnapshot().visible && e.stores.layout.getSnapshot().lockCloseWhileLoading !== !1 ? Promise.resolve(!1) : g(y, U), [g, e]), _ = K(() => Promise.resolve(!1), []), le = F(() => ({
1013
+ navigate: _,
1014
+ navigateAsync: async () => ({ status: "cancelled" }),
1015
+ replace: _,
1016
+ reset: _,
1017
+ goBack: _,
1018
+ popToTop: _,
1019
+ popTo: _,
1020
+ setParams: (y) => q.current ? (M((U) => ({ ...U, params: { ...U.params, ...typeof y == "function" ? y(U.params) : y } })), !0) : !1,
1021
+ setOptions: (y) => q.current ? (M((U) => ({ ...U, options: { ...U.options, ...y } })), !0) : !1,
1022
+ close: z,
1023
+ setLoading: X,
1024
+ canGoBack: !1,
1025
+ stack: [m],
1026
+ currentRoute: m
1027
+ }), [z, m, X, _]), W = k(le);
1028
+ W.current = le;
1029
+ const ue = F(() => ({
1030
+ navigate: (...y) => W.current.navigate(...y),
1031
+ navigateAsync: (...y) => W.current.navigateAsync(...y),
1032
+ replace: (...y) => W.current.replace(...y),
1033
+ reset: (...y) => W.current.reset(...y),
1034
+ goBack: (...y) => W.current.goBack(...y),
1035
+ popToTop: (...y) => W.current.popToTop(...y),
1036
+ popTo: (...y) => W.current.popTo(...y),
1037
+ setParams: (...y) => W.current.setParams(...y),
1038
+ setOptions: (...y) => W.current.setOptions(...y),
1039
+ close: (...y) => W.current.close(...y),
1040
+ setLoading: (...y) => W.current.setLoading(...y)
1041
+ }), []), ie = F(() => ({
1042
+ setLoading: (y, U) => Q.setScreenLoading("single", y, U),
1043
+ showLoading: (y) => Q.begin("single", y),
1044
+ hideLoading: (y) => Q.end("single", y)
1045
+ }), [Q]), C = F(() => ({ isFocused: !0, resultEvent: null, routeKey: "single", setFooter: be }), [be]), R = F(() => ({ routeKey: "single", registerDirtyGuard: x }), [x]);
1046
+ H(() => {
1047
+ P.current.publish({ canGoBack: !1, stack: [m], currentRoute: m });
1048
+ }, [m]);
1049
+ const de = k(!1);
1050
+ H(() => (h?.({ setLoading: X }), de.current || (de.current = !0, p?.({ route: I.current, stack: [I.current] })), () => {
1051
+ h?.(null);
1052
+ }), []);
1053
+ const ge = F(() => ({ ...j, ...m.options }), [j, m.options]), te = j.component, A = e.refs.header;
1054
+ return /* @__PURE__ */ i(tn.Provider, { value: A.current, children: /* @__PURE__ */ i(vn.Provider, { value: ne, children: /* @__PURE__ */ i(Bn.Provider, { value: T.current, children: /* @__PURE__ */ i(zn.Provider, { value: L.current, children: /* @__PURE__ */ i(Nn.Provider, { value: le, children: /* @__PURE__ */ i(rn.Provider, { value: ue, children: /* @__PURE__ */ i(on.Provider, { value: P.current, children: /* @__PURE__ */ i(De.Provider, { value: Q, children: /* @__PURE__ */ Ce($n, { store: e.stores.layout, screenOptions: ge.modalOptions, dialogRef: O, requestClose: z, exiting: w, children: [
1055
+ /* @__PURE__ */ i(In, { store: e.stores.layout, screen: ge, route: m, navigation: le, requestClose: z, translate: o, canGoBack: !1 }),
1056
+ /* @__PURE__ */ i("main", { className: "pmn-main", children: /* @__PURE__ */ i(sn.Provider, { value: m, children: /* @__PURE__ */ i(bn.Provider, { value: R, children: /* @__PURE__ */ i(Ve.Provider, { value: C, children: /* @__PURE__ */ i(De.Provider, { value: ie, children: /* @__PURE__ */ i(an.Provider, { value: Y.current, children: /* @__PURE__ */ i("div", { className: `pmn-body ${b.bodyClassName ?? ""}`, "data-modal-route-key": "single", tabIndex: -1, children: /* @__PURE__ */ i(Cn, { route: m, onError: l, children: /* @__PURE__ */ i(Ln, { fallback: b.lazyFallback ?? /* @__PURE__ */ i("div", { className: "pmn-lazy-loading", role: "status", "aria-live": "polite", children: "加载中..." }), children: /* @__PURE__ */ i(zt, { Screen: te, route: m, navigation: le }) }) }) }) }) }) }) }) }) }),
1057
+ /* @__PURE__ */ i(Bt, { store: L.current, route: m, screen: ge, layoutStore: e.stores.layout, navigation: le, requestClose: z, translate: o, onError: l, loadingApi: Q }),
1058
+ /* @__PURE__ */ i(Ft, { store: Y.current, translate: o }),
1059
+ /* @__PURE__ */ i(jt, { store: T.current, dismiss: oe }),
1060
+ d && /* @__PURE__ */ Ce("div", { className: "pmn-error", role: "alert", children: [
1061
+ /* @__PURE__ */ i("span", { children: d.message || String(d) }),
1062
+ /* @__PURE__ */ i("button", { type: "button", onClick: u, children: "×" })
1063
+ ] })
1064
+ ] }) }) }) }) }) }) }) }) });
1065
+ }
1066
+ const $t = Ue(Rt), It = Ue(qt), Dt = Ue(function({ manager: n }) {
1067
+ const { active: t, options: r, exiting: o, error: g, translate: p } = Ee(n.hostStore.subscribe, n.hostStore.getSnapshot, n.hostStore.getSnapshot), h = t?.id, l = t?.runtime.bindings, d = F(() => (x, w) => {
1068
+ t?.runtime.alive.current && n.hostStore.getSnapshot().active?.id === h && n.reportError(x, w);
1069
+ }, [n, t, h]);
1070
+ if (!t) return null;
1071
+ const u = t.config.singlePage || Object.keys(t.config.screens ?? {}).length === 1 ? It : $t;
1072
+ return /* @__PURE__ */ i(kn.Provider, { value: t.runtime, children: /* @__PURE__ */ i(u, { runtime: t.runtime, config: t.config, initialScreen: t.screen, params: t.params, options: r, translate: p, notifyError: d, error: g, clearError: n.commands.clearError, exiting: o, ...l }, h) });
1073
+ }), Kt = ".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))}.pmn-dialog.pmn-has-custom-background{isolation:isolate;--pmn-body:transparent}.pmn-custom-background-layer{position:absolute;inset:0;z-index:0;pointer-events:none}.pmn-dialog.pmn-has-custom-background>:not(.pmn-custom-background-layer){position:relative;z-index:1}.pmn-dialog.pmn-has-custom-background .pmn-main>.pmn-body{background:transparent}.pmn-overlay.pmn-fullscreen{padding:0!important;align-items:stretch;justify-content:stretch}.pmn-overlay.pmn-fullscreen .pmn-dialog{width:100%;max-width:100%;height:100%;max-height:100%;border-radius:0!important}.pmn-place-left .pmn-dialog,.pmn-place-right .pmn-dialog{height:100%;max-height:100%}.pmn-place-center .pmn-dialog{max-height:100%}.pmn-dialog{max-width:min(100%,var(--pmn-drag-width,var(--pmn-max-width,var(--pmn-width))));max-height:min(100%,var(--pmn-max-height,100dvh))}.pmn-dialog .pmn-resize-handle{position:absolute;z-index:5;top:0;bottom:0;width:10px;cursor:ew-resize;touch-action:none;-webkit-user-select:none;user-select:none}.pmn-resize-left{right:0}.pmn-resize-right{left:0}.pmn-resize-handle:hover,.pmn-resize-handle:focus-visible{background:var(--pmn-border)}@media(max-width:640px){.pmn-mobile-fullscreen .pmn-resize-handle{display:none}}.pmn-dialog{max-width:min(100%,var(--pmn-max-width,100%),var(--pmn-drag-width,var(--pmn-width)))}.pmn-overlay.pmn-fullscreen .pmn-dialog{max-width:100%}", Tn = "react-modal-navigation-styles", hn = /* @__PURE__ */ new WeakMap();
1074
+ function Ht() {
1075
+ Zn(() => {
1076
+ if (typeof document > "u") return;
1077
+ const e = document;
1078
+ let n = hn.get(e);
1079
+ if (!n) {
1080
+ let t = e.getElementById(Tn);
1081
+ const r = !t;
1082
+ t || (t = e.createElement("style"), t.id = Tn, t.setAttribute("data-react-modal-navigation", ""), t.textContent = Kt, e.head.appendChild(t)), n = { element: t, owned: r, count: 0 }, hn.set(e, n);
1083
+ }
1084
+ return n.count += 1, () => {
1085
+ n.count -= 1, n.count === 0 && (n.owned && n.element.remove(), hn.delete(e));
1086
+ };
1087
+ }, []);
1088
+ }
1089
+ const Wt = Object.freeze({}), Gt = (e) => ({ "modal.loading": "加载中...", "modal.processing": "处理中...", "modal.back": "返回", "modal.close": "关闭", "modal.cancel": "取消", "modal.done": "完成" })[e] ?? e;
1090
+ function ir({ children: e, registry: n, defaultOptions: t = Wt, backgroundColor: r, theme: o, translate: g = Gt, onError: p, confirmDiscard: h }) {
1091
+ Ht();
1092
+ const l = { registry: n, defaultOptions: t, backgroundColor: r, theme: o, translate: g, onError: p, confirmDiscard: h }, [d] = xe(() => Nt(l, Tt));
1093
+ return Ie(() => (d.mount(), d.destroy), [d]), Ie(() => {
1094
+ d.configure(l);
1095
+ }, [d, n, t, r, o, g, p, h]), /* @__PURE__ */ i(wn.Provider, { value: d.commands, children: /* @__PURE__ */ i(xn.Provider, { value: d.statusStore, children: /* @__PURE__ */ Ce(An.Provider, { value: d.commands, children: [
1096
+ e,
1097
+ /* @__PURE__ */ i(Dt, { manager: d })
1098
+ ] }) }) });
847
1099
  }
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);
852
- if (!e) throw new Error("[react-modal-navigation] useModal requires <ModalProvider>");
853
- const c = G(() => {
854
- const g = () => {
855
- if (!n) throw new Error("[react-modal-navigation] navigation requires an active modal screen; use modal.open() outside a modal");
856
- return n;
1100
+ const _t = Object.freeze({ canGoBack: !1, stack: [], currentRoute: null }), On = () => () => {
1101
+ }, en = () => _t;
1102
+ function cr({ subscribe: e = !0 } = {}) {
1103
+ const n = V(An), t = V(xn), r = Ee(e && t?.subscribe || On, e && t?.getSnapshot || en, e && t?.getSnapshot || en), o = F(() => n ? e ? { ...n, ...r } : n : null, [n, r, e]), g = V(rn), p = V(on), h = Ee(e && p?.subscribe || On, e && p?.getSnapshot || en, e && p?.getSnapshot || en);
1104
+ if (!o) throw new Error("[react-modal-navigation] useModal requires <ModalProvider>");
1105
+ const l = F(() => {
1106
+ const d = () => {
1107
+ if (!g) throw new Error("[react-modal-navigation] navigation requires an active modal screen; use modal.open() outside a modal");
1108
+ return g;
857
1109
  };
858
1110
  return {
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),
867
- canGoBack: t.canGoBack,
868
- stack: t.stack,
869
- currentRoute: t.currentRoute
1111
+ navigateAsync: (...u) => d().navigateAsync(...u),
1112
+ navigate: (...u) => d().navigate(...u),
1113
+ replace: (...u) => d().replace(...u),
1114
+ reset: (...u) => d().reset(...u),
1115
+ setParams: (...u) => d().setParams(...u),
1116
+ setOptions: (...u) => d().setOptions(...u),
1117
+ goBack: (...u) => d().goBack(...u),
1118
+ close: (...u) => d().close(...u),
1119
+ setLoading: (...u) => d().setLoading(...u),
1120
+ ...e ? { canGoBack: h.canGoBack, stack: h.stack, currentRoute: h.currentRoute } : {}
870
1121
  };
871
- }, [n, t]);
872
- return G(() => ({ ...e, modal: e, navigation: c }), [e, c]);
1122
+ }, [g, h, e]);
1123
+ return F(() => ({ ...o, modal: o, navigation: l }), [o, l]);
873
1124
  }
874
- function st() {
875
- const e = te(_e);
1125
+ function Ut() {
1126
+ const e = V(rn);
876
1127
  if (!e) throw new Error("useModalNavigationCommands requires an active modal screen");
877
1128
  return e;
878
1129
  }
879
- function ct() {
880
- const e = te(We);
881
- if (!e) throw new Error("useModalNavigationState requires an active modal screen");
882
- return fe(e.subscribe, e.getSnapshot, e.getSnapshot);
1130
+ function Vt(e, n) {
1131
+ const t = V(on);
1132
+ if (!t) throw new Error("useModalNavigationState requires an active modal screen");
1133
+ return ke(t, e, n);
883
1134
  }
884
- function gt() {
885
- const e = st(), n = ct();
886
- return G(() => ({ ...e, ...n }), [e, n]);
1135
+ function lr() {
1136
+ const e = Ut(), n = Vt();
1137
+ return F(() => ({ ...e, ...n }), [e, n]);
887
1138
  }
888
- function Ln() {
889
- const e = te($e);
1139
+ function Un() {
1140
+ const e = V(Ve);
890
1141
  if (!e) throw new Error("useIsFocused must be called inside a modal screen");
891
1142
  return e.isFocused;
892
1143
  }
893
- function ht(e) {
894
- const n = Ln();
895
- Q(() => {
1144
+ function ur(e) {
1145
+ const n = Un();
1146
+ H(() => {
896
1147
  if (n)
897
1148
  return e();
898
1149
  }, [n, e]);
899
1150
  }
900
- function bt(e) {
901
- const n = te($e);
1151
+ function dr(e) {
1152
+ const n = V(Ve);
902
1153
  if (!n) throw new Error("useNavigationResult requires an active modal screen");
903
- const r = l(e), t = l(null);
904
- Q(() => {
905
- r.current = e;
906
- }, [e]), Q(() => {
907
- !n.isFocused || !n.resultEvent || t.current !== n.resultEvent.id && (t.current = n.resultEvent.id, r.current(n.resultEvent.data));
1154
+ const t = k(e), r = k(null);
1155
+ H(() => {
1156
+ t.current = e;
1157
+ }, [e]), H(() => {
1158
+ !n.isFocused || !n.resultEvent || r.current !== n.resultEvent.id && (r.current = n.resultEvent.id, t.current(n.resultEvent.data));
908
1159
  }, [n.isFocused, n.resultEvent]);
909
1160
  }
910
- function yt(e = {}) {
911
- const n = te($e);
1161
+ function mr(e = {}) {
1162
+ const n = V(Ve);
912
1163
  if (!n) throw new Error("[react-modal-navigation] useModalFooter requires an active modal screen");
913
- const { setFooter: r, routeKey: t } = n, c = l(e);
914
- c.current = e;
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]));
919
- }) || (q.current = {
920
- source: H?.map((M) => ({ ...M })) ?? null,
921
- normalized: H?.map((M, b) => ({
922
- ...M,
923
- onClick: (...P) => (c.current.actions?.find((U) => U.key === M.key) ?? c.current.actions?.[b])?.onClick?.(...P)
1164
+ const { setFooter: t, routeKey: r } = n, o = k(e);
1165
+ o.current = e;
1166
+ const g = F(() => (...T) => o.current.done?.(...T), []), p = F(() => (...T) => (o.current.cancel ?? o.current.cancle)?.(...T), []), h = F(() => (...T) => o.current.renderFooter?.(...T), []), l = typeof e.done == "function", d = typeof (e.cancel ?? e.cancle) == "function", u = typeof e.renderFooter == "function", { showFooter: x, showFooterBorder: w, doneDisabled: b, doneText: s, cancelText: m, loadingText: M, footerClassName: I } = e, j = k({ source: null, normalized: void 0 }), q = Array.isArray(e.actions) ? e.actions : null, O = j.current.source;
1167
+ q === O || q && O && q.length === O.length && q.every((T, $) => {
1168
+ const Q = O[$];
1169
+ return [.../* @__PURE__ */ new Set([...Object.keys(T), ...Object.keys(Q)])].every((ne) => ne === "onClick" || Object.is(T[ne], Q[ne]));
1170
+ }) || (j.current = {
1171
+ source: q?.map((T) => ({ ...T })) ?? null,
1172
+ normalized: q?.map((T, $) => ({
1173
+ ...T,
1174
+ onClick: (...Q) => (o.current.actions?.find((ne) => ne.key === T.key) ?? o.current.actions?.[$])?.onClick?.(...Q)
924
1175
  }))
925
1176
  });
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]);
1177
+ const L = j.current.normalized, Y = F(() => ({
1178
+ showFooter: x,
1179
+ showFooterBorder: w,
1180
+ doneDisabled: b,
1181
+ doneText: s,
1182
+ cancelText: m,
1183
+ loadingText: M,
1184
+ footerClassName: I,
1185
+ ...L !== void 0 ? { actions: L } : {},
1186
+ ...l ? { done: g } : {},
1187
+ ...d ? { cancel: p } : {},
1188
+ ...u ? { renderFooter: h } : {}
1189
+ }), [x, w, b, s, m, M, I, L, l, d, u, g, p, h]);
1190
+ H(() => {
1191
+ t(r, Y);
1192
+ }, [r, t, Y]), H(() => () => t(r, null), [r, t]);
942
1193
  }
943
- function it() {
944
- const e = te(Me), n = te(Ue);
1194
+ const Yt = (e) => e.visible;
1195
+ function Qt() {
1196
+ const e = V(De), n = V(an);
945
1197
  if (!e || !n) throw new Error("[react-modal-navigation] useModalLoading requires an active modal screen");
946
- const r = fe(n.subscribe, n.getSnapshot, n.getSnapshot);
947
- return G(() => ({ ...e, isLoading: r.visible }), [e, r.visible]);
1198
+ const t = ke(n, Yt);
1199
+ return F(() => ({ ...e, isLoading: t }), [e, t]);
948
1200
  }
949
- function vt() {
950
- const e = te(Me);
1201
+ function pr() {
1202
+ const e = V(De);
951
1203
  if (!e) throw new Error("[react-modal-navigation] useModalLoadingCommands requires an active modal screen");
952
1204
  return e;
953
1205
  }
954
- function xt() {
955
- const e = te(Ue);
956
- if (!e) throw new Error("[react-modal-navigation] useModalLoadingState requires an active modal screen");
957
- return fe(e.subscribe, e.getSnapshot, e.getSnapshot);
1206
+ function fr(e, n) {
1207
+ const t = V(an);
1208
+ if (!t) throw new Error("[react-modal-navigation] useModalLoadingState requires an active modal screen");
1209
+ return ke(t, e, n);
958
1210
  }
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, () => {
962
- r.current = !1;
963
- }), []), { run: w(async (C, k = {}) => {
964
- if (t.current) return { status: "busy" };
965
- if (typeof C != "function") throw new TypeError("[react-modal-navigation] run requires a function");
966
- t.current = !0, r.current && (g(!0), f(null));
967
- const d = u.current.showLoading(k.loadingText);
1211
+ function gr() {
1212
+ const e = Qt(), n = Un(), t = k(!0), r = k(!1), [o, g] = xe(!1), [p, h] = xe(null), l = k(e);
1213
+ return l.current = e, H(() => (t.current = !0, () => {
1214
+ t.current = !1;
1215
+ }), []), { run: K(async (u, x = {}) => {
1216
+ if (r.current) return { status: "busy" };
1217
+ if (typeof u != "function") throw new TypeError("[react-modal-navigation] run requires a function");
1218
+ r.current = !0, t.current && (g(!0), h(null));
1219
+ const w = l.current.showLoading(x.loadingText);
968
1220
  try {
969
- const m = await C();
970
- return r.current && await k.onSuccess?.(m), { status: "success", value: m };
971
- } catch (m) {
972
- if (r.current) {
973
- f(m);
1221
+ const b = await u();
1222
+ return t.current && await x.onSuccess?.(b), { status: "success", value: b };
1223
+ } catch (b) {
1224
+ if (t.current) {
1225
+ h(b);
974
1226
  try {
975
- await k.onError?.(m);
976
- } catch (a) {
977
- console.error("[react-modal-navigation] onError failed", a);
1227
+ await x.onError?.(b);
1228
+ } catch (s) {
1229
+ console.error("[react-modal-navigation] onError failed", s);
978
1230
  }
979
1231
  }
980
- if (k.throwOnError) throw m;
981
- return { status: "error", error: m };
1232
+ if (x.throwOnError) throw b;
1233
+ return { status: "error", error: b };
982
1234
  } finally {
983
- d != null && u.current.hideLoading(d), t.current = !1, r.current && g(!1);
1235
+ w != null && l.current.hideLoading(w), r.current = !1, t.current && g(!1);
984
1236
  }
985
- }, []), pending: c, error: p, clearError: () => f(null), isFocused: n };
1237
+ }, []), pending: o, error: p, clearError: () => h(null), isFocused: n };
986
1238
  }
987
- function kt(e, n = {}) {
988
- const r = te(tn);
989
- if (!r) throw new Error("[react-modal-navigation] useModalUnsavedChanges must be used inside a modal screen");
990
- const t = l({ dirty: e, ...n });
991
- t.current = { dirty: e, ...n };
992
- const { routeKey: c, registerDirtyGuard: g } = r;
993
- Q(() => g(c, {
1239
+ function hr(e, n = {}) {
1240
+ const t = V(bn);
1241
+ if (!t) throw new Error("[react-modal-navigation] useModalUnsavedChanges must be used inside a modal screen");
1242
+ const r = k({ dirty: e, ...n });
1243
+ r.current = { dirty: e, ...n };
1244
+ const { routeKey: o, registerDirtyGuard: g } = t;
1245
+ H(() => g(o, {
994
1246
  get dirty() {
995
- return !!t.current.dirty;
1247
+ return !!r.current.dirty;
996
1248
  },
997
1249
  get message() {
998
- return t.current.message;
1250
+ return r.current.message;
999
1251
  },
1000
1252
  get onBeforeDiscard() {
1001
- return t.current.onBeforeDiscard;
1253
+ return r.current.onBeforeDiscard;
1002
1254
  }
1003
- }), [c, g]);
1255
+ }), [o, g]);
1004
1256
  }
1005
- const St = () => {
1006
- const e = te(rn);
1257
+ const yr = () => {
1258
+ const e = V(vn);
1007
1259
  if (!e) throw new Error("[react-modal-navigation] useToast requires an active modal");
1008
1260
  return e;
1009
1261
  };
1010
- function lt() {
1011
- const e = te(on);
1262
+ function Zt() {
1263
+ const e = V(sn);
1012
1264
  if (!e) throw new Error("[react-modal-navigation] useModalRoute requires a modal screen");
1013
1265
  return e;
1014
1266
  }
1015
- function Et() {
1016
- return lt().params;
1267
+ function br() {
1268
+ return Zt().params;
1269
+ }
1270
+ function Xt() {
1271
+ const e = V(wn);
1272
+ if (!e) throw new Error("[react-modal-navigation] ModalProvider required");
1273
+ return e;
1274
+ }
1275
+ const Jt = (e) => e;
1276
+ function er(e = Jt, n = Object.is) {
1277
+ const t = V(xn);
1278
+ if (!t) throw new Error("[react-modal-navigation] ModalProvider required");
1279
+ return ke(t, e, n);
1280
+ }
1281
+ const nr = (e) => e.isFullscreen;
1282
+ function vr() {
1283
+ const { setFullscreen: e, toggleFullscreen: n } = Xt();
1284
+ return { isFullscreen: er(nr), setFullscreen: e, toggleFullscreen: n };
1285
+ }
1286
+ function wr(e = {}) {
1287
+ const n = V(tn), t = V(sn);
1288
+ if (!n || !t) throw new Error("[react-modal-navigation] useModalHeader requires a modal screen");
1289
+ const r = k(e);
1290
+ r.current = e, H(() => {
1291
+ n.set(t.key, r.current);
1292
+ }), H(() => () => n.set(t.key, null), [n, t.key]);
1293
+ }
1294
+ function xr(e, n) {
1295
+ const t = V(kn);
1296
+ if (!t) throw new Error("[react-modal-navigation] useModalLayout requires an active modal");
1297
+ return ke(t.stores.layout, e, n);
1017
1298
  }
1018
1299
  export {
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
1300
+ Rt as ModalNavigator,
1301
+ ir as ModalProvider,
1302
+ ar as defineModal,
1303
+ sr as lazyModal,
1304
+ ze as shallowEqual,
1305
+ ur as useFocusEffect,
1306
+ Un as useIsFocused,
1307
+ cr as useModal,
1308
+ Xt as useModalCommands,
1309
+ mr as useModalFooter,
1310
+ vr as useModalFullscreen,
1311
+ wr as useModalHeader,
1312
+ xr as useModalLayout,
1313
+ Qt as useModalLoading,
1314
+ pr as useModalLoadingCommands,
1315
+ fr as useModalLoadingState,
1316
+ lr as useModalNavigation,
1317
+ Ut as useModalNavigationCommands,
1318
+ Vt as useModalNavigationState,
1319
+ br as useModalParams,
1320
+ Zt as useModalRoute,
1321
+ er as useModalStatus,
1322
+ gr as useModalTask,
1323
+ hr as useModalUnsavedChanges,
1324
+ dr as useNavigationResult,
1325
+ yr as useToast
1037
1326
  };