react-modal-navigation 1.1.11 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,192 +1,207 @@
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) {
5
- let n = e;
6
- const t = /* @__PURE__ */ new Set();
1
+ import { jsx as p, jsxs as be } from "react/jsx-runtime";
2
+ import Se, { createContext as we, useState as xe, useEffect as U, useRef as P, useMemo as Q, useSyncExternalStore as Oe, useContext as ee, memo as rt, useCallback as _, useReducer as dn, useLayoutEffect as Ae, Suspense as Wt, useInsertionEffect as mn } from "react";
3
+ import { createPortal as pn } from "react-dom";
4
+ function je(e) {
5
+ let t = e;
6
+ const n = /* @__PURE__ */ new Set();
7
7
  let r = !1;
8
8
  return {
9
- getSnapshot: () => n,
10
- subscribe: (o) => (r || t.add(o), () => t.delete(o)),
9
+ getSnapshot: () => t,
10
+ subscribe: (o) => (r || n.add(o), () => n.delete(o)),
11
11
  publish(o) {
12
- if (!(r || Object.is(n, o))) {
13
- n = o;
14
- for (const g of [...t]) g();
12
+ if (!(r || Object.is(t, o))) {
13
+ t = o;
14
+ for (const a of [...n])
15
+ if (!(r || !n.has(a)))
16
+ try {
17
+ const l = a();
18
+ l && typeof l.then == "function" && Promise.resolve(l).catch((f) => console.error(f));
19
+ } catch (l) {
20
+ console.error(l);
21
+ }
15
22
  }
16
23
  },
17
- destroy() {
18
- r = !0, t.clear();
24
+ destroy(...o) {
25
+ r = !0, n.clear(), o.length && (t = o[0]);
19
26
  },
20
- listenerCount: () => t.size
27
+ listenerCount: () => n.size
21
28
  };
22
29
  }
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) {
27
- switch (n.type) {
30
+ const yt = we(null), Gt = we(null), _t = we(null), ot = we(null), Ue = we(null), Pt = we(null), Tt = we(null), vt = we(null), bt = we(null), wt = we(null), Ut = we(null), Vt = we(null), Ve = we(null), Lt = we(null), zt = we(null), at = we(null);
31
+ let fn = 0;
32
+ const ht = (e, t) => ({ key: `modal-route-${++fn}`, name: e, params: t ?? {} }), Yt = (e, t) => [ht(e, t)];
33
+ function mt(e, t) {
34
+ switch (t.type) {
28
35
  case "COMMIT":
29
- return n.stack;
36
+ return t.stack;
37
+ case "PUSH":
38
+ return [...e, ht(t.name, t.params)];
39
+ case "POP":
40
+ return e.slice(0, Math.max(1, e.length - t.count));
30
41
  case "RESET":
31
- return Fn(n.name, n.params);
42
+ return Yt(t.name, t.params);
32
43
  case "NAVIGATE": {
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
+ const n = e.findIndex((r) => r.name === t.name);
45
+ return n < 0 ? [...e, ht(t.name, t.params)] : e.slice(0, n + 1).map((r, o) => o === n ? { ...r, params: t.params ?? {} } : r);
35
46
  }
36
47
  case "SET_OPTIONS":
37
- return e.map((t, r) => r === e.length - 1 ? { ...t, options: { ...t.options ?? {}, ...n.options ?? {} } } : t);
48
+ return e.map((n, r) => r === e.length - 1 ? { ...n, options: { ...n.options ?? {}, ...t.options ?? {} } } : n);
38
49
  case "SET_PARAMS":
39
- return e.map((t, r) => r === e.length - 1 ? { ...t, params: { ...t.params ?? {}, ...n.params ?? {} } } : t);
50
+ return e.map((n, r) => r === e.length - 1 ? { ...n, params: { ...n.params ?? {}, ...t.params ?? {} } } : n);
40
51
  case "BACK":
41
52
  return e.length > 1 ? e.slice(0, -1) : e;
42
53
  case "REPLACE":
43
- return e.length ? [...e.slice(0, -1), yn(n.name, n.params)] : e;
54
+ return e.length ? [...e.slice(0, -1), ht(t.name, t.params)] : e;
44
55
  default:
45
56
  return e;
46
57
  }
47
58
  }
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));
59
+ function $t(e, t, n = 1 / 0, r = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set()) {
60
+ const a = n === 1 / 0 ? 1 / 0 : Math.max(0, Math.floor(Number(n) || 0)), l = e.slice(0, -1).filter((u) => t[u.name]?.keepAlive !== !1), f = new Set((a === 0 ? [] : l.slice(-a)).map((u) => u.key));
61
+ return e.filter((u, i) => i === e.length - 1 || (f.has(u.key) || o.has(u.key)) && !r.has(u.key));
51
62
  }
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 };
63
+ function hn(e, t, n) {
64
+ const r = new Set(t.map((a) => a.key)), o = new Set(e.slice(0, -1).filter((a) => n.has(a.key) || !r.has(a.key)).map((a) => a.key));
65
+ return o.size === n.size && [...o].every((a) => n.has(a)) ? n : o;
57
66
  }
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));
67
+ function gn(e, t) {
68
+ const n = e.responsive;
69
+ if (!n) return e;
70
+ const { sm: r, md: o, lg: a, xl: l } = n;
71
+ return { ...e, ...t < 768 ? r : t < 1024 ? o : t < 1280 ? a : l, ...e.runtimeLayout };
61
72
  }
62
- const rt = Object.freeze({ sm: 400, md: 560, lg: 720, xl: 960, full: "100%" }), Te = (e) => typeof e == "number" ? `${e}px` : e, Rn = () => {
73
+ function yn(e, t, n, r) {
74
+ const o = Math.max(0, Math.min(n ?? 1 / 0, r));
75
+ return Math.min(o, Math.max(Math.min(t ?? 240, o), e));
76
+ }
77
+ const vn = Object.freeze({ sm: 400, md: 560, lg: 720, xl: 960, full: "100%" }), Ie = (e) => typeof e == "number" ? `${e}px` : e, It = () => {
63
78
  if (typeof document > "u") return "light";
64
- const e = document.documentElement, n = document.body;
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";
79
+ const e = document.documentElement, t = document.body;
80
+ return e.classList.contains("dark") || t.classList.contains("dark") || e.dataset.theme === "dark" || t.dataset.theme === "dark" ? "dark" : e.classList.contains("light") || t.classList.contains("light") || e.dataset.theme === "light" || t.dataset.theme === "light" ? "light" : window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
66
81
  };
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");
82
+ let tt = 0;
83
+ const Ke = [];
84
+ let Mt = null;
85
+ function bn() {
86
+ if (tt++, tt === 1) {
87
+ const t = document.documentElement, n = document.body, r = { html: t.style.overflow, body: n.style.overflow, padding: n.style.paddingRight, width: n.style.getPropertyValue("--modal-scrollbar-width") }, o = Math.max(0, window.innerWidth - t.clientWidth), a = parseFloat(getComputedStyle(n).paddingRight) || 0;
88
+ o && (n.style.paddingRight = `${a + o}px`), n.style.setProperty("--modal-scrollbar-width", `${o}px`), t.style.overflow = "hidden", n.style.overflow = "hidden", Mt = () => {
89
+ t.style.overflow = r.html, n.style.overflow = r.body, n.style.paddingRight = r.padding, r.width ? n.style.setProperty("--modal-scrollbar-width", r.width) : n.style.removeProperty("--modal-scrollbar-width");
75
90
  };
76
91
  }
77
92
  let e = !1;
78
93
  return () => {
79
- e || (e = !0, Ge = Math.max(0, Ge - 1), Ge || (gn?.(), gn = null));
94
+ e || (e = !0, tt = Math.max(0, tt - 1), tt || (Mt?.(), Mt = null));
80
95
  };
81
96
  }
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);
97
+ const wn = '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";
98
+ function xn({ dialogRef: e, options: t, requestClose: n, children: r, exiting: o = !1 }) {
99
+ const [a, l] = xe(() => typeof window > "u" ? 1024 : window.innerWidth), f = !!t.responsive;
100
+ U(() => {
101
+ if (!f) return;
102
+ const O = () => l(window.innerWidth < 768 ? 0 : window.innerWidth < 1024 ? 768 : window.innerWidth < 1280 ? 1024 : 1280);
103
+ return window.addEventListener("resize", O), O(), () => window.removeEventListener("resize", O);
104
+ }, [f]), t = gn(t, a);
105
+ const [u, i] = xe(null);
106
+ U(() => i(null), [t.width, t.placement]);
107
+ const d = P(null), g = P(0);
108
+ U(() => () => {
109
+ g.current && cancelAnimationFrame(g.current);
95
110
  }, []);
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(() => {
102
- if (n.theme === "light" || n.theme === "dark") return;
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);
111
+ const b = P(null), x = P(null), h = P(n);
112
+ h.current = n;
113
+ const s = P(t.closeOnEsc);
114
+ s.current = t.closeOnEsc;
115
+ const [v, I] = xe(It), z = t.theme === "light" || t.theme === "dark" ? t.theme : v;
116
+ U(() => {
117
+ if (t.theme === "light" || t.theme === "dark") return;
118
+ const O = () => I(It()), G = new MutationObserver(O);
119
+ for (const Ce of [document.documentElement, document.body]) G.observe(Ce, { attributes: !0, attributeFilter: ["class", "data-theme"] });
120
+ const ke = window.matchMedia?.("(prefers-color-scheme: dark)");
121
+ return ke?.addEventListener?.("change", O), O(), () => {
122
+ G.disconnect(), ke?.removeEventListener?.("change", O);
108
123
  };
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");
124
+ }, [t.theme]), U(() => {
125
+ x.current = document.activeElement;
126
+ const O = bn(), G = b.current;
127
+ Ke.push(G), e.current?.focus({ preventScroll: !0 });
128
+ const ke = (K) => {
129
+ const de = e.current;
130
+ if (!de || Ke.at(-1) !== G) return;
131
+ if (K.key === "Escape" && s.current !== !1) {
132
+ K.preventDefault(), h.current("escape");
118
133
  return;
119
134
  }
120
- if (te.key !== "Tab") return;
121
- const y = [...A.querySelectorAll(at)].filter(st);
122
- if (!y.length) {
123
- te.preventDefault(), A.focus();
135
+ if (K.key !== "Tab") return;
136
+ const k = [...de.querySelectorAll(wn)].filter(kn);
137
+ if (!k.length) {
138
+ K.preventDefault(), de.focus();
124
139
  return;
125
140
  }
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 });
141
+ const ce = k[0], ne = k.at(-1);
142
+ de.contains(document.activeElement) ? K.shiftKey && (document.activeElement === ce || document.activeElement === de) ? (K.preventDefault(), ne.focus()) : !K.shiftKey && (document.activeElement === ne || document.activeElement === de) && (K.preventDefault(), ce.focus()) : (K.preventDefault(), (K.shiftKey ? ne : ce).focus());
143
+ }, Ce = (K) => {
144
+ Ke.at(-1) === G && e.current && !e.current.contains(K.target) && e.current.focus({ preventScroll: !0 });
130
145
  };
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 });
146
+ return document.addEventListener("keydown", ke), document.addEventListener("focusin", Ce), () => {
147
+ document.removeEventListener("keydown", ke), document.removeEventListener("focusin", Ce);
148
+ const K = Ke.at(-1) === G, de = Ke.indexOf(G);
149
+ if (de !== -1 && Ke.splice(de, 1), O(), K) {
150
+ const k = x.current;
151
+ k?.isConnected && !k.closest("[inert], [hidden]") ? k.focus?.({ preventScroll: !0 }) : Ke.at(-1)?.querySelector("[role=dialog]")?.focus?.({ preventScroll: !0 });
137
152
  }
138
153
  };
139
154
  }, [e]);
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);
155
+ const T = t.backgroundColor ?? t.backgroudColor, E = typeof T == "string" ? T : T?.[z], D = typeof E == "string" && /^(#|(?:rgb|rgba|hsl|hsla|hwb|oklch|oklab|lab|lch|color|color-mix|light-dark|var)\(|transparent$|currentColor$|[a-z]+$)/i.test(E.trim()) ? E.trim() : null, L = typeof E == "string" && !D ? E.trim() : "", A = !!(D || L), q = ["center", "left", "right", "top", "bottom"].includes(t.placement) ? t.placement : "right", N = Ie(u ?? t.width ?? vn[t.size] ?? 460), Z = Ie(t.height), ue = Ie(t.maxHeight), C = Ie(t.maxWidth), F = Number(t.viewportGap ?? 5), $ = Number.isFinite(F) ? Math.max(0, F) : 5, X = t.top == null ? null : Ie(t.top), B = q !== "bottom" && X !== null ? X : null, te = typeof t.borderRadius == "number" ? `${t.borderRadius}px` : t.borderRadius ?? "12px", V = t.resizable && !t.fullscreen && ["left", "right"].includes(q), oe = (O) => yn(O, t.minWidth, typeof t.maxWidth == "number" ? t.maxWidth : void 0, b.current?.clientWidth - $ * 2 || window.innerWidth), J = (O) => {
156
+ !d.current || d.current.id !== O.pointerId || (cancelAnimationFrame(g.current), i(d.current.width), e.current?.style.removeProperty("--pmn-drag-width"), d.current = null);
142
157
  };
143
- return Xn(/* @__PURE__ */ i(
158
+ return pn(/* @__PURE__ */ p(
144
159
  "div",
145
160
  {
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");
161
+ ref: b,
162
+ className: `pmn-overlay ${o ? "pmn-exiting" : "pmn-entering"} ${t.animation === !1 ? "pmn-no-animation" : ""} pmn-place-${q} ${t.fullscreen ? "pmn-fullscreen" : ""} ${t.mobileFullscreen ? "pmn-mobile-fullscreen" : ""}`,
163
+ style: { padding: $, ...t.bottom != null ? { paddingBottom: Ie(t.bottom) } : {}, ...t.left != null ? { paddingLeft: Ie(t.left) } : {}, ...t.right != null ? { paddingRight: Ie(t.right) } : {}, ...B !== null ? { paddingTop: B, "--pmn-top-offset": B } : {}, "--pmn-animation-duration": `${Math.min(1e3, Math.max(0, Number(t.animationDuration ?? 220) || 0))}ms` },
164
+ onMouseDown: (O) => {
165
+ O.target === O.currentTarget && t.closeOnOverlay === !0 && h.current("overlay");
151
166
  },
152
- children: /* @__PURE__ */ Ce(
167
+ children: /* @__PURE__ */ be(
153
168
  "section",
154
169
  {
155
170
  ref: e,
156
171
  tabIndex: -1,
157
172
  role: "dialog",
158
173
  "aria-modal": "true",
159
- "aria-label": n.ariaLabel ?? "Dialog",
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 },
174
+ "aria-label": t.ariaLabel ?? "Dialog",
175
+ "data-modal-theme": z,
176
+ className: `pmn-dialog ${z === "dark" ? "dark" : ""} ${A ? "pmn-has-custom-background" : ""} ${t.className ?? ""}`,
177
+ style: { "--pmn-width": N, "--pmn-gap": `${$}px`, ...B !== null ? { "--pmn-top-offset": B } : {}, ...Z !== void 0 ? { "--pmn-height": Z } : {}, ...ue !== void 0 ? { "--pmn-max-height": ue } : {}, ...C !== void 0 ? { "--pmn-max-width": C } : {}, borderRadius: te },
163
178
  children: [
164
- Y && /* @__PURE__ */ i("div", { "aria-hidden": "true", className: `pmn-custom-background-layer ${L}`, style: P ? { backgroundColor: P } : void 0 }),
179
+ A && /* @__PURE__ */ p("div", { "aria-hidden": "true", className: `pmn-custom-background-layer ${L}`, style: D ? { backgroundColor: D } : void 0 }),
165
180
  r,
166
- W && /* @__PURE__ */ i(
181
+ V && /* @__PURE__ */ p(
167
182
  "div",
168
183
  {
169
184
  role: "separator",
170
185
  "aria-label": "调整弹窗宽度",
171
186
  "aria-orientation": "vertical",
172
187
  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))));
188
+ className: `pmn-resize-handle pmn-resize-${q}`,
189
+ onKeyDown: (O) => {
190
+ ["ArrowLeft", "ArrowRight"].includes(O.key) && (O.preventDefault(), i(oe(e.current.getBoundingClientRect().width + (O.key === "ArrowRight" ? 16 : -16) * (q === "left" ? 1 : -1))));
176
191
  },
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 };
192
+ onPointerDown: (O) => {
193
+ if (O.button !== 0) return;
194
+ O.preventDefault(), O.currentTarget.setPointerCapture(O.pointerId);
195
+ const G = e.current.getBoundingClientRect().width;
196
+ d.current = { id: O.pointerId, x: O.clientX, start: G, width: G };
182
197
  },
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`)));
198
+ onPointerMove: (O) => {
199
+ const G = d.current;
200
+ !G || G.id !== O.pointerId || (G.width = oe(G.start + (O.clientX - G.x) * (q === "left" ? 1 : -1)), cancelAnimationFrame(g.current), g.current = requestAnimationFrame(() => e.current?.style.setProperty("--pmn-drag-width", `${G.width}px`)));
186
201
  },
187
- onPointerUp: ie,
188
- onPointerCancel: ie,
189
- onLostPointerCapture: ie
202
+ onPointerUp: J,
203
+ onPointerCancel: J,
204
+ onLostPointerCapture: J
190
205
  }
191
206
  )
192
207
  ]
@@ -195,1054 +210,1339 @@ function it({ dialogRef: e, options: n, requestClose: t, children: r, exiting: o
195
210
  }
196
211
  ), document.body);
197
212
  }
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;
213
+ const Sn = (e) => e;
214
+ function Pe(e, t = Sn, n = Object.is) {
215
+ const r = P({ store: null, initialized: !1, selection: void 0 }), o = Q(() => {
216
+ let l = !1, f, u;
202
217
  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);
218
+ const i = e.getSnapshot();
219
+ if (l && Object.is(f, i)) return u;
220
+ const d = t(i);
221
+ if (l)
222
+ n(u, d) || (u = d);
208
223
  else {
209
- const x = r.current;
210
- l = x.initialized && x.store === e && t(x.selection, u) ? x.selection : u;
224
+ const g = r.current;
225
+ u = g.initialized && g.store === e && n(g.selection, d) ? g.selection : d;
211
226
  }
212
- return h = d, p = !0, l;
227
+ return f = i, l = !0, u;
213
228
  };
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]])) };
229
- }
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);
229
+ }, [e, t, n]), a = Oe(e.subscribe, o, o);
230
+ return U(() => {
231
+ r.current = { store: e, initialized: !0, selection: a };
232
+ }, [e, a]), a;
233
+ }
234
+ function He(e, t) {
235
+ if (Object.is(e, t)) return !0;
236
+ if (!e || !t || typeof e != "object" || typeof t != "object") return !1;
237
+ const n = Object.keys(e);
238
+ return n.length === Object.keys(t).length && n.every((r) => Object.hasOwn(t, r) && Object.is(e[r], t[r]));
239
+ }
240
+ const Ye = (e) => (t) => Object.fromEntries(e.map((n) => [n, t[n]])), Cn = Ye(["pageAnimationDuration", "pageAnimationDistance", "pageAnimation", "animation", "lockCloseWhileLoading", "maxCachedScreens", "bodyClassName", "lazyFallback", "onBlur", "onNavigate", "onRouteChange", "onFocus"]), En = Ye(["bodyClassName", "lazyFallback"]), Rn = Ye(["showHeader", "showTitle", "renderHeader", "renderHeaderRight", "showHeaderBorder", "headerClassName", "showBackButton", "showCloseButton"]), Qt = Ye(["showFooter", "renderFooter", "done", "cancel", "cancle", "showFooterBorder", "footerClassName", "actions", "loadingText", "cancelText", "doneText", "doneDisabled"]), Mn = Ye(["fullscreenable", "fullscreen"]), At = ["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"], On = Ye(At);
241
+ function Pn(e, t) {
242
+ const n = { ...e, ...t, ...e.runtimeLayout };
243
+ return { ...On(n), runtimeLayout: Object.fromEntries(At.filter((r) => Object.hasOwn(e.runtimeLayout ?? {}, r)).map((r) => [r, e.runtimeLayout[r]])) };
244
+ }
245
+ function Tn(e, t) {
246
+ return He(e.runtimeLayout, t.runtimeLayout) && At.every((n) => Object.is(e[n], t[n]));
247
+ }
248
+ const Zt = {}, Ln = () => Zt, zn = () => () => {
249
+ }, An = Se.memo(function({ action: t, context: n }) {
250
+ const r = P(!1), [o, a] = xe(!1), l = P(!1);
251
+ return U(() => (l.current = !0, () => {
252
+ l.current = !1;
253
+ }), []), /* @__PURE__ */ p("button", { type: "button", className: "pmn-icon-button", "aria-label": t.tooltip ?? t.key, title: t.tooltip, disabled: o || t.disabled || t.loading, onClick: async () => {
254
+ if (!(r.current || !l.current || t.disabled || t.loading)) {
255
+ r.current = !0, a(!0);
241
256
  try {
242
- await n.onClick?.(t);
243
- } catch (h) {
244
- console.error("[react-modal-navigation] header action", h);
257
+ await t.onClick?.(n);
258
+ } catch (f) {
259
+ console.error("[react-modal-navigation] header action", f);
245
260
  } finally {
246
- r.current = !1, p.current && g(!1);
261
+ r.current = !1, l.current && a(!1);
247
262
  }
248
263
  }
249
- }, children: o ? "…" : n.icon ?? n.label });
264
+ }, children: o ? "…" : t.icon ?? t.label });
250
265
  });
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" }) });
266
+ function Dt({ back: e }) {
267
+ return /* @__PURE__ */ p("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", children: e ? /* @__PURE__ */ p("path", { d: "m15 18-6-6 6-6" }) : /* @__PURE__ */ p("path", { d: "M18 6 6 18M6 6l12 12" }) });
253
268
  }
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]);
269
+ function Nn({ options: e, screen: t, route: n, navigation: r, requestClose: o, translate: a, canGoBack: l }) {
270
+ const f = ee(yt), u = () => f?.getSnapshot()[n.key] ?? Zt, i = Oe(f?.subscribe ?? zn, u, Ln);
271
+ t = { ...t, ...i };
272
+ const d = a ?? ((v) => v), g = t.showTitle ?? e.showTitle ?? !0, b = typeof t.title == "function" ? t.title({ t: d, route: n, navigation: r }) : t.title ?? n.name, x = Q(() => ({ route: n, navigation: r, close: o, canGoBack: l, title: b, t: d }), [n, r, o, l, b, d]);
258
273
  if (e.showHeader === !1) return null;
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, {}) })
274
+ const h = t.renderHeader ?? e.renderHeader;
275
+ if (h) return h(x);
276
+ const s = t.renderHeaderRight ?? e.renderHeaderRight;
277
+ return /* @__PURE__ */ be("header", { className: `pmn-header ${t.showHeaderBorder ?? e.showHeaderBorder ? "pmn-border-bottom" : ""} ${e.headerClassName ?? ""}`, children: [
278
+ (t.showBackButton ?? e.showBackButton) !== !1 && l && /* @__PURE__ */ p("button", { type: "button", className: "pmn-icon-button", "aria-label": d("modal.back"), onClick: () => r.goBack(), children: /* @__PURE__ */ p(Dt, { back: !0 }) }),
279
+ g ? /* @__PURE__ */ p("h2", { children: b }) : /* @__PURE__ */ p("div", { className: "pmn-header-spacer" }),
280
+ s?.(x),
281
+ i.actions?.filter((v) => !v.hidden).map((v) => /* @__PURE__ */ p(An, { action: v, context: x }, `${n.key}:${v.key}`)),
282
+ /* @__PURE__ */ p(jn, { hidden: t.showFullscreenButton === !1 }),
283
+ (t.showCloseButton ?? e.showCloseButton) !== !1 && /* @__PURE__ */ p("button", { type: "button", className: "pmn-icon-button", "aria-label": d("modal.close"), onClick: () => o("header"), children: /* @__PURE__ */ p(Dt, {}) })
269
284
  ] });
270
285
  }
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, () => {
283
- d.current = !1;
286
+ const jn = Se.memo(function({ hidden: t }) {
287
+ const n = ee(Lt), r = ee(at), o = Pe(r.stores.layout, Mn, He);
288
+ return t || !o.fullscreenable ? null : /* @__PURE__ */ p("button", { type: "button", className: "pmn-icon-button", "aria-label": o.fullscreen ? "还原" : "全屏", onClick: n?.toggleFullscreen, children: /* @__PURE__ */ p("svg", { "aria-hidden": "true", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ p("path", { d: o.fullscreen ? "M3 9h6V3 M21 9h-6V3 M3 15h6v6 M21 15h-6v6" : "M3 9V3h6 M15 3h6v6 M3 15v6h6 M15 21h6v-6" }) }) });
289
+ }), Xt = rt(function({ store: t, screenOptions: n, ...r }) {
290
+ const o = _((l) => Pn(l, n), [n]), a = Pe(t, o, Tn);
291
+ return /* @__PURE__ */ p(xn, { ...r, options: a });
292
+ }), Jt = rt(function({ store: t, ...n }) {
293
+ const r = Pe(t, Rn, He);
294
+ return /* @__PURE__ */ p(Nn, { ...n, options: r });
295
+ }), Bn = Se.memo(function({ action: t, context: n, loadingApi: r, onError: o, loadingText: a }) {
296
+ const l = P(!1), [f, u] = xe(!1), i = P(!1);
297
+ U(() => (i.current = !0, () => {
298
+ i.current = !1;
284
299
  }), []);
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);
300
+ const d = f || t.loading === !0, g = t.loadingText ?? a ?? n.t("modal.processing"), b = async () => {
301
+ if (!i.current || l.current || t.disabled || t.loading || typeof t.onClick != "function") return;
302
+ l.current = !0, u(!0);
303
+ const x = r?.begin(n.route.key, g);
289
304
  try {
290
- await n.onClick(t);
291
- } catch (s) {
292
- o?.(s, { phase: "footer", action: n.key, route: t.route });
305
+ await t.onClick(n);
306
+ } catch (h) {
307
+ o?.(h, { phase: "footer", action: t.key, route: n.route });
293
308
  } finally {
294
- b != null && r?.end(t.route.key, b), p.current = !1, d.current && l(!1);
309
+ x != null && r?.end(n.route.key, x), l.current = !1, i.current && u(!1);
295
310
  }
296
311
  };
297
- return /* @__PURE__ */ i(
312
+ return /* @__PURE__ */ p(
298
313
  "button",
299
314
  {
300
315
  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
316
+ disabled: t.disabled === !0 || d,
317
+ className: `pmn-button ${t.variant === "primary" || t.variant === "danger" ? "pmn-button-primary" : "pmn-button-secondary"} ${t.variant === "danger" ? "pmn-button-danger" : ""}`,
318
+ onClick: b,
319
+ children: d ? g : t.label
305
320
  }
306
321
  );
307
322
  });
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;
323
+ function en({ screen: e, options: t, override: n, route: r, navigation: o, requestClose: a, translate: l, onError: f, loadingApi: u }) {
324
+ const [i, d] = xe(null), g = P(/* @__PURE__ */ new Set()), b = P(!0);
325
+ U(() => (b.current = !0, () => {
326
+ b.current = !1;
312
327
  }), []);
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"));
328
+ const x = l ?? ((N) => N), h = { ...t, ...e, ...n }, { showFooter: s, renderFooter: v, done: I, cancel: z, cancle: T } = h, E = z ?? T, D = Q(() => ({ route: r, navigation: o, close: a, t: x }), [r, o, a, x]);
329
+ if (s === !1) return null;
330
+ const L = `pmn-footer ${h.showFooterBorder ? "pmn-border-top" : ""} ${h.footerClassName ?? ""}`;
331
+ if (typeof v == "function") return /* @__PURE__ */ p("footer", { className: L, children: v({ ...D, pending: g.current.size > 0 }) });
332
+ const A = Array.isArray(h.actions) ? h.actions : null;
333
+ if (!A && typeof I != "function" && typeof E != "function") return null;
334
+ const q = async (N, Z, ue) => {
335
+ if (!b.current || g.current.size > 0 || g.current.has(N) || typeof Z != "function") return;
336
+ g.current.add(N), d(N);
337
+ const C = u?.begin(r.key, h.loadingText ?? x("modal.processing"));
323
338
  try {
324
- await Q(P);
325
- } catch (oe) {
326
- h?.(oe, { phase: "footer", action: $, route: r });
339
+ await Z(D);
340
+ } catch (F) {
341
+ f?.(F, { phase: "footer", action: N, route: r });
327
342
  } finally {
328
- ne != null && l?.end(r.key, ne), x.current.delete($), w.current && u((oe) => oe === $ ? null : oe);
343
+ C != null && u?.end(r.key, C), g.current.delete(N), b.current && d((F) => F === N ? null : F);
329
344
  }
330
345
  };
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") })
346
+ return A ? /* @__PURE__ */ p("footer", { className: L, children: A.filter((N) => !N.hidden).map(
347
+ (N) => /* @__PURE__ */ p(Bn, { action: N, context: D, loadingApi: u, onError: f, loadingText: h.loadingText }, `${r.key}:${N.key}`)
348
+ ) }) : /* @__PURE__ */ be("footer", { className: L, children: [
349
+ typeof E == "function" && /* @__PURE__ */ p("button", { type: "button", disabled: i !== null, onClick: () => q("cancel", E), className: "pmn-button pmn-button-secondary", children: h.cancelText ?? x("modal.cancel") }),
350
+ typeof I == "function" && /* @__PURE__ */ p("button", { type: "button", disabled: i !== null || h.doneDisabled === !0, onClick: () => q("done", I), className: "pmn-button pmn-button-primary", children: i === "done" ? h.loadingText ?? x("modal.processing") : h.doneText ?? x("modal.done") })
336
351
  ] });
337
352
  }
338
- function Kn({ loading: e, translate: n }) {
353
+ function tn({ loading: e, translate: t }) {
339
354
  if (!e.visible) return null;
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 })
355
+ const r = (t ?? ((a) => a))("modal.loading"), o = e.text ?? (r === "modal.loading" ? "加载中..." : r);
356
+ return /* @__PURE__ */ p("div", { className: "pmn-loading-overlay", role: "status", "aria-live": "polite", "aria-busy": "true", children: /* @__PURE__ */ be("div", { className: "pmn-loading-content", children: [
357
+ /* @__PURE__ */ p("span", { className: "pmn-spinner", "aria-hidden": "true" }),
358
+ o && /* @__PURE__ */ p("span", { className: "pmn-loading-text", children: o })
344
359
  ] }) });
345
360
  }
346
- class Cn extends fe.Component {
361
+ class Nt extends Se.Component {
347
362
  state = { error: null };
348
- static getDerivedStateFromError(n) {
349
- return { error: n };
363
+ static getDerivedStateFromError(t) {
364
+ return { error: t };
350
365
  }
351
- componentDidCatch(n, t) {
352
- this.props.onError?.(n, { phase: "render", route: this.props.route, componentStack: t.componentStack });
366
+ componentDidCatch(t, n) {
367
+ this.props.onError?.(t, { phase: "render", route: this.props.route, componentStack: n.componentStack });
353
368
  }
354
- componentDidUpdate(n) {
355
- n.route?.key !== this.props.route?.key && this.state.error && this.setState({ error: null });
369
+ componentDidUpdate(t) {
370
+ t.route?.key !== this.props.route?.key && this.state.error && this.setState({ error: null });
356
371
  }
357
372
  render() {
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: () => {
373
+ return this.state.error ? /* @__PURE__ */ be("div", { role: "alert", className: "pmn-error-screen", children: [
374
+ /* @__PURE__ */ p("strong", { children: "页面加载失败" }),
375
+ /* @__PURE__ */ p("p", { children: this.state.error.message }),
376
+ /* @__PURE__ */ p("button", { type: "button", className: "pmn-button pmn-button-secondary", onClick: () => {
362
377
  this.props.onRetry?.(), this.setState({ error: null });
363
378
  }, children: "重试" })
364
379
  ] }) : this.props.children;
365
380
  }
366
381
  }
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;
374
- }
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;
381
- if (!n.current) return null;
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 });
382
+ const qn = { success: "✓", error: "×", warning: "!", info: "i" };
383
+ function nn({ items: e, dismiss: t }) {
384
+ return e.length ? /* @__PURE__ */ p("div", { className: "pmn-toast-region", "aria-label": "Notifications", children: e.map((n) => /* @__PURE__ */ be("div", { className: `pmn-toast pmn-toast-${n.type}`, role: n.type === "error" || n.type === "warning" ? "alert" : "status", children: [
385
+ /* @__PURE__ */ p("span", { className: "pmn-toast-symbol", "aria-hidden": "true", children: qn[n.type] }),
386
+ /* @__PURE__ */ p("span", { className: "pmn-toast-message", children: n.message }),
387
+ n.dismissible && /* @__PURE__ */ p("button", { type: "button", className: "pmn-toast-close", "aria-label": "Dismiss notification", onClick: () => t(n.id), children: "×" })
388
+ ] }, n.id)) }) : null;
389
+ }
390
+ function rn(e, t, n) {
391
+ const r = P(0), o = P(/* @__PURE__ */ new Map()), a = _((u) => {
392
+ clearTimeout(o.current.get(u)), o.current.delete(u), t.current && e.current.publish(e.current.getSnapshot().filter((i) => i.id !== u));
393
+ }, []), l = _((u, i = {}) => {
394
+ if (typeof u != "string" || !u.trim()) throw new TypeError("[react-modal-navigation] toast message must be a non-empty string");
395
+ const d = typeof i == "string" ? { type: i } : i ?? {}, g = ["success", "error", "warning", "info"].includes(d.type) ? d.type : "info", b = ++r.current, x = Number.isFinite(d.duration) ? Math.max(0, d.duration) : 3e3;
396
+ if (!t.current) return null;
397
+ const h = e.current.getSnapshot(), s = h.slice(0, Math.max(0, h.length - 4));
398
+ for (const v of s)
399
+ clearTimeout(o.current.get(v.id)), o.current.delete(v.id);
400
+ return e.current.publish([...h.slice(-4), { id: b, message: u, type: g, dismissible: d.dismissible !== !1 }]), x > 0 && o.current.set(b, setTimeout(() => a(b), x)), b;
401
+ }, [a]), f = Q(() => {
402
+ const u = (i, d) => l(i, d);
403
+ for (const i of ["success", "error", "warning", "info"]) u[i] = (d, g = {}) => l(d, { ...g, type: i });
404
+ return u.promise = async (i, d, g = {}) => {
405
+ const b = l(d.loading, { ...g, type: "info", duration: 0 });
391
406
  try {
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;
407
+ const x = await (typeof i == "function" ? i() : i);
408
+ b != null && a(b);
409
+ const h = typeof d.success == "function" ? d.success(x) : d.success;
410
+ return h && l(h, { ...g, type: "success" }), x;
411
+ } catch (x) {
412
+ b != null && a(b);
413
+ const h = typeof d.error == "function" ? d.error(x) : d.error;
414
+ throw h && l(h, { ...g, type: "error" }), x;
400
415
  }
401
- }, l.dismiss = g, l.clear = () => {
402
- for (const d of o.current.values()) clearTimeout(d);
416
+ }, u.dismiss = a, u.clear = () => {
417
+ for (const i of o.current.values()) clearTimeout(i);
403
418
  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);
419
+ }, u;
420
+ }, [l, a]);
421
+ return U(() => {
422
+ const u = () => {
423
+ for (const d of o.current.values()) clearTimeout(d);
409
424
  o.current.clear();
410
- }, d = t?.addCleanup(l);
425
+ }, i = n?.addCleanup(u);
411
426
  return () => {
412
- d?.(), l();
427
+ i?.(), u();
413
428
  };
414
- }, [t]), { toast: h, dismissToast: g };
415
- }
416
- function Gn(e, n, t, r) {
417
- const o = r.loadingTasks, g = r.loadingSequence, p = K(() => {
418
- if (!n.current) return;
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) => {
429
+ }, [n]), { toast: f, dismissToast: a };
430
+ }
431
+ function Fn(e) {
432
+ let t;
433
+ return {
434
+ added(n) {
435
+ t = n;
436
+ },
437
+ read() {
438
+ if (!e.has(t)) {
439
+ t = void 0;
440
+ for (const n of e.keys()) t = n;
441
+ }
442
+ return { visible: e.size > 0, text: e.get(t)?.text ?? null, count: e.size };
443
+ }
444
+ };
445
+ }
446
+ function on(e, t, n, r) {
447
+ const o = r.loadingTasks, a = r.loadingSequence, l = Q(() => Fn(o.current), [o]), f = _(() => {
448
+ if (!t.current) return;
449
+ const h = l.read(), s = e.current.getSnapshot();
450
+ (s.visible !== h.visible || s.text !== h.text || s.count !== h.count) && e.current.publish(h);
451
+ }, [l]), u = _((h, s) => {
452
+ if (!t.current || h !== "global" && n.current !== h) return null;
453
+ const v = ++a.current;
454
+ return o.current.set(v, { owner: h, text: s }), l.added(v), f(), v;
455
+ }, [f, l]), i = _((h, s) => {
426
456
  if (s != null)
427
- o.current.get(s)?.owner === b && o.current.delete(s);
457
+ o.current.get(s)?.owner === h && o.current.delete(s);
428
458
  else
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 };
437
- }
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)` },
459
+ for (const [v, I] of o.current) I.owner === h && o.current.delete(v);
460
+ f();
461
+ }, [f]), d = _((h, s) => {
462
+ h ? (i("global"), u("global", s)) : i("global");
463
+ }, [u, i]), g = _((h, s, v) => {
464
+ s ? (i(h), u(h, v)) : i(h);
465
+ }, [u, i]);
466
+ return { loadingApi: Q(() => ({ setLoading: d, setScreenLoading: g, begin: u, end: i }), [d, g, u, i]), refreshLoading: f, loadingTasks: o, setLoading: d };
467
+ }
468
+ const $n = Se.memo(function({ store: t, translate: n }) {
469
+ const r = Oe(t.subscribe, t.getSnapshot, t.getSnapshot);
470
+ return /* @__PURE__ */ p(tn, { loading: r, translate: n });
471
+ }), In = Se.memo(function({ store: t, dismiss: n }) {
472
+ const r = Oe(t.subscribe, t.getSnapshot, t.getSnapshot);
473
+ return /* @__PURE__ */ p(nn, { items: r, dismiss: n });
474
+ }), Dn = Se.memo(function({ store: t, layoutStore: n, routeKey: r, ...o }) {
475
+ const a = () => t.getSnapshot()[r], l = Oe(t.subscribe, a, a), f = Pe(n, Qt, He);
476
+ return /* @__PURE__ */ p(en, { ...o, options: f, override: l });
477
+ }), Kn = Se.memo(function({ route: t, screen: n, navigation: r, focused: o, resultEvent: a, setFooter: l, loadingApi: f, loadingStore: u, bodyClassName: i, notifyError: d, registerDirtyGuard: g, pageMotion: b, lazyFallback: x }) {
478
+ const h = n.component, s = P(null), v = P(!1);
479
+ Ae(() => {
480
+ const E = o && !v.current;
481
+ if (v.current = o, !E || !b?.enabled || !s.current?.animate) return;
482
+ const D = b.direction === "back" ? -100 : 100;
483
+ s.current.style.zIndex = "2";
484
+ const L = s.current.animate([
485
+ { opacity: 1, transform: `translate3d(${D}%,0,0)` },
456
486
  { opacity: 1, transform: "translate3d(0,0,0)" }
457
- ], { duration: w.duration, easing: "cubic-bezier(.22,1,.36,1)" });
487
+ ], { duration: b.duration, easing: "cubic-bezier(.22,1,.36,1)" });
458
488
  return () => {
459
- L.cancel(), m.current && (m.current.style.zIndex = "");
489
+ L.cancel(), s.current && (s.current.style.zIndex = "");
460
490
  };
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 }) }) }) }) }) }) }) }) });
491
+ }, [o, b?.enabled, b?.direction, b?.duration, b?.distance]);
492
+ const I = Q(() => ({ isFocused: o, resultEvent: a, routeKey: t.key, setFooter: l }), [o, a, t.key, l]), z = Q(() => ({
493
+ setLoading: (E, D) => f.setScreenLoading(t.key, E, D),
494
+ showLoading: (E) => f.begin(t.key, E),
495
+ hideLoading: (E) => f.end(t.key, E)
496
+ }), [f, t.key]), T = Q(() => ({ routeKey: t.key, registerDirtyGuard: g }), [t.key, g]);
497
+ return /* @__PURE__ */ p(Ve.Provider, { value: t, children: /* @__PURE__ */ p(Pt.Provider, { value: T, children: /* @__PURE__ */ p(ot.Provider, { value: I, children: /* @__PURE__ */ p(Ue.Provider, { value: z, children: /* @__PURE__ */ p(wt.Provider, { value: u, children: /* @__PURE__ */ p("div", { ref: s, hidden: !o, inert: !o, "data-modal-route-key": t.key, tabIndex: -1, className: `pmn-body ${o && b?.enabled && typeof Element < "u" && !Element.prototype.animate ? `pmn-page-enter pmn-page-${b.direction}` : ""} ${i ?? ""}`, style: o && b?.enabled ? { "--pmn-page-duration": `${b.duration}ms`, "--pmn-page-distance": `${b.distance}px` } : void 0, children: /* @__PURE__ */ p(Nt, { route: t, onError: d, children: /* @__PURE__ */ p(Wt, { fallback: x ?? /* @__PURE__ */ p("div", { className: "pmn-lazy-loading", role: "status", "aria-live": "polite", children: "加载中..." }), children: /* @__PURE__ */ p(h, { route: t, navigation: r }) }) }) }) }) }) }) }) });
468
498
  });
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++;
499
+ function Hn({ runtime: e, config: t, initialScreen: n, params: r, translate: o, onRequestClose: a, onOpened: l, registerLoading: f, notifyError: u, error: i, clearError: d, registerDirtyGuard: g, getProtectedCacheKeys: b, canNavigate: x, exiting: h = !1 }) {
500
+ const s = Pe(e.stores.layout, Cn, He), [v, I] = dn(mt, e.stores.navigation.getSnapshot().stack), { navigation: z, loading: T, footer: E, toast: D } = e.refs, L = e.alive, A = P(0), { toast: q, dismissToast: N } = rn(D, L, e);
501
+ U(() => () => {
502
+ A.current++;
473
503
  }, []);
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);
504
+ const [Z, ue] = xe({}), [C, F] = xe(() => /* @__PURE__ */ new Set()), $ = P(/* @__PURE__ */ new Map()), X = P(null), B = P(null), te = P(null), V = P(null), oe = P(null), J = P(!1), O = P(!1), G = e.pageRequests, ke = P(0), Ce = _((m, M, j) => {
505
+ for (const [Y, fe] of G.current)
506
+ m.includes(fe.key) && (G.current.delete(Y), fe.resolve({ status: M, ...M === "returned" ? { value: j } : {} }));
507
+ }, []), K = P(v);
508
+ K.current = v;
509
+ const de = P(x);
510
+ de.current = x;
511
+ const k = P(!1), ce = P(0), ne = v.at(-1), re = ne.key, Be = P({ key: re, depth: v.length }), st = Be.current, We = st.key !== re, it = v.length < st.depth ? "back" : "forward";
512
+ We && (Be.current = { key: re, depth: v.length });
513
+ const Qe = Math.min(1e3, Math.max(0, Number(s.pageAnimationDuration ?? 360) || 0)), ct = Math.min(300, Math.max(0, Number(s.pageAnimationDistance ?? 96) || 0)), Ne = Q(() => ({ distance: ct, enabled: s.pageAnimation !== !1 && s.animation !== !1 && Qe > 0 && We, direction: it, duration: Qe }), [ct, s.pageAnimation, s.animation, Qe, We, it]), lt = P(re);
514
+ lt.current = re;
515
+ const { loadingApi: Ze, refreshLoading: Ge, loadingTasks: ut, setLoading: De } = on(T, L, lt, e), Ee = t.screens, Te = T, _e = P(f);
516
+ _e.current = f, U(() => (_e.current?.({ setLoading: De }), () => _e.current?.(null)), [De]);
517
+ const qt = _((m, M) => {
518
+ if (!L.current) return;
519
+ const j = E.current.getSnapshot();
520
+ if (M === null) {
521
+ if (!(m in j)) return;
522
+ const Y = { ...j };
523
+ delete Y[m], E.current.publish(Y);
494
524
  return;
495
525
  }
496
- D[c] !== E && q.current.publish({ ...D, [c]: E });
497
- }, []), dn = K(() => {
526
+ j[m] !== M && E.current.publish({ ...j, [m]: M });
527
+ }, []), kt = _(() => {
498
528
  if (typeof document > "u") return;
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) => {
529
+ const m = document.activeElement;
530
+ if (!(m instanceof HTMLElement) || !X.current?.contains(m)) return;
531
+ const M = m.closest("[data-modal-route-key]");
532
+ M && $.current.set(M.dataset.modalRouteKey, m), X.current.focus({ preventScroll: !0 });
533
+ }, []), xt = _((m) => {
534
+ if (!Object.prototype.hasOwnProperty.call(Ee, m)) throw new Error(`[react-modal-navigation] Unknown modal screen: ${m}`);
535
+ }, [Ee]), c = _((m, M) => {
506
536
  try {
507
- Promise.resolve(s[c]?.(E)).catch((D) => l(D, { phase: c }));
508
- } catch (D) {
509
- l(D, { phase: c });
537
+ Promise.resolve(s[m]?.(M)).catch((j) => u(j, { phase: m }));
538
+ } catch (j) {
539
+ u(j, { phase: m });
510
540
  }
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;
541
+ }, [s, u]), y = _(async (m, M, j, Y, fe) => {
542
+ if (!L.current || O.current) return !1;
543
+ const ve = A.current, se = K.current, Xe = se.at(-1);
544
+ if (m !== "BACK" && m !== "POP" && xt(M), m === "POP" && (!Number.isInteger(j) || j < 1 || se.length <= 1) || m === "BACK" && se.length <= 1) return !1;
545
+ const Ft = m === "NAVIGATE" ? se.findIndex((Je) => Je.name === M) : -1, $e = m === "POP" ? se.slice(Math.max(1, se.length - j)) : m === "RESET" ? se : m === "BACK" || m === "REPLACE" ? [Xe] : Ft >= 0 ? se.slice(Ft + 1) : [];
546
+ O.current = !0;
517
547
  try {
518
- if (pn.length && de.current && !await de.current(pn.map((fn) => fn.key), {
548
+ if ($e.length && de.current && !await de.current($e.map((Me) => Me.key), {
519
549
  reason: "navigation",
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 } }));
550
+ action: m,
551
+ from: Xe,
552
+ to: m === "POP" ? se[Math.max(0, se.length - j - 1)]?.name : m === "BACK" ? se.at(-2)?.name : M
553
+ }) || $e.length && !await e.canRemove($e.map((ge) => ge.key), { reason: "navigation", action: m, from: Xe, to: M }) || !L.current || ve !== A.current || K.current.at(-1)?.key !== Xe.key) return !1;
554
+ if (m === "BACK" && Y !== void 0) {
555
+ const ge = se.at(-2);
556
+ ue((Me) => ({ ...Me, [ge.key]: { id: ++ce.current, data: Y } }));
527
557
  }
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;
558
+ if ($e.length) {
559
+ const ge = new Set($e.map((Me) => Me.key));
560
+ ge.forEach((Me) => $.current.delete(Me)), ue((Me) => Object.fromEntries(Object.entries(Me).filter(([et]) => !ge.has(et))));
561
+ }
562
+ e.tasks.cancelRoutes($e.map((ge) => ge.key)), Ce($e.map((ge) => ge.key), m === "BACK" ? "returned" : "removed", Y);
563
+ const Je = [...B.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((ge) => ge.dataset.modalRouteKey === Xe.key);
564
+ te.current = Je?.cloneNode(!0) ?? null, kt();
565
+ const un = { type: m, name: M, params: j, count: j };
566
+ K.current = mt(K.current, un);
567
+ const Rt = K.current;
568
+ return F((ge) => {
569
+ const Me = new Set(Rt.slice(0, -1).filter((et) => ge.has(et.key)).map((et) => et.key));
570
+ return Me.size === ge.size ? ge : Me;
571
+ }), fe?.(Rt.at(-1)), I({ type: "COMMIT", stack: Rt }), !0;
572
+ } catch (Je) {
573
+ return L.current && u(Je, { phase: "navigationGuard", action: m }), !1;
535
574
  } finally {
536
- W.current = !1;
575
+ O.current = !1;
537
576
  }
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 });
545
- });
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 }
577
+ }, [xt, kt, u, Ce]), R = _((m, M) => y("NAVIGATE", m, M), [y]), w = _((m, M) => y("PUSH", m, M), [y]), H = _((m = 1) => y("POP", null, m), [y]), W = _(() => H(K.current.length - 1), [H]), ae = _((m) => {
578
+ const M = K.current.findLastIndex((j) => j.name === m);
579
+ return M < 0 ? Promise.resolve(!1) : H(K.current.length - M - 1);
580
+ }, [H]), me = _(async (m, M) => {
581
+ if (!L.current) return { status: "cancelled" };
582
+ let j;
583
+ return await y("NAVIGATE", m, M, void 0, (fe) => {
584
+ j = new Promise((ve) => {
585
+ const se = ++ke.current;
586
+ G.current.set(se, { key: fe.key, resolve: ve });
587
+ });
588
+ }) && j ? j : { status: "cancelled" };
589
+ }, [y]), ie = _((m, M) => y("REPLACE", m, M), [y]), pe = _((m, M) => y("RESET", m, M), [y]), Re = _((m) => {
590
+ if (!m || typeof m != "object" || Array.isArray(m)) throw new TypeError("[react-modal-navigation] setParams expects an object");
591
+ if (!L.current) return;
592
+ const M = { type: "SET_PARAMS", params: m };
593
+ K.current = mt(K.current, M), I({ type: "COMMIT", stack: K.current });
594
+ }, []), S = _((m) => {
595
+ if (!m || typeof m != "object" || Array.isArray(m)) throw new TypeError("[react-modal-navigation] setOptions expects an object");
596
+ if (!L.current) return;
597
+ const M = { type: "SET_OPTIONS", options: m };
598
+ K.current = mt(K.current, M), I({ type: "COMMIT", stack: K.current });
599
+ }, []), le = _((m) => y("BACK", null, void 0, m), [y]), Le = _((m, M) => !L.current || Te.current.getSnapshot().visible && s.lockCloseWhileLoading !== !1 ? Promise.resolve(!1) : a(m, M, { route: ne, stack: v }), [s.lockCloseWhileLoading, a, ne, v]), ye = P(Le);
600
+ ye.current = Le;
601
+ const he = _((m) => ye.current("api", m), []), ze = _(async (m) => {
602
+ if (!L.current || O.current) return !1;
603
+ const M = K.current, j = $t(M, Ee, s.maxCachedScreens, C, b?.()).slice(0, -1).filter((Y) => m === void 0 || Y.name === m).map((Y) => Y.key);
604
+ if (!j.length) return !1;
605
+ O.current = !0;
606
+ try {
607
+ const Y = { reason: "cache", action: "CLEAR_CACHE", from: M.at(-1) };
608
+ return de.current && !await de.current(j, Y) || !await e.canRemove(j, Y) || !L.current || K.current !== M ? !1 : (e.tasks.cancelRoutes(j), j.forEach((fe) => $.current.delete(fe)), F((fe) => /* @__PURE__ */ new Set([...fe, ...j])), !0);
609
+ } catch (Y) {
610
+ return L.current && u(Y, { phase: "clearCache" }), !1;
611
+ } finally {
612
+ O.current = !1;
613
+ }
614
+ }, [e, u, Ee, s.maxCachedScreens, C, b]), qe = Q(() => ({ navigate: R, navigateAsync: me, push: w, pop: H, popTo: ae, popToTop: W, replace: ie, reset: pe, setParams: Re, setOptions: S, goBack: le, close: he, setLoading: De, clearCache: ze }), [R, me, w, H, ae, W, ie, pe, Re, S, le, he, De, ze]);
615
+ Ae(() => e.registerNavigation(qe), [e, qe]);
616
+ const Fe = Q(() => ({ canGoBack: v.length > 1, stack: v, currentRoute: ne }), [v]);
617
+ Ae(() => z.current.publish(Fe), [Fe]);
618
+ const St = P(null);
619
+ St.current || (St.current = Object.defineProperties({}, {
620
+ canGoBack: { enumerable: !0, get: () => z.current.getSnapshot().canGoBack },
621
+ stack: { enumerable: !0, get: () => z.current.getSnapshot().stack },
622
+ currentRoute: { enumerable: !0, get: () => z.current.getSnapshot().currentRoute }
565
623
  }));
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);
624
+ const dt = Q(() => Object.assign(St.current, qe), [qe]);
625
+ Ae(() => {
626
+ const m = te.current;
627
+ if (te.current = null, V.current?.cancel?.(), V.current = null, B.current?.querySelectorAll("[data-pmn-outgoing]").forEach((se) => se.remove()), !We || !Ne.enabled || !m || !B.current || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) return;
628
+ const M = B.current;
629
+ m.removeAttribute("hidden"), m.removeAttribute("tabindex"), m.setAttribute("aria-hidden", "true"), m.setAttribute("inert", ""), m.dataset.pmnOutgoing = "true", m.querySelectorAll("[id]").forEach((se) => se.removeAttribute("id")), m.querySelectorAll("[autofocus]").forEach((se) => se.removeAttribute("autofocus")), m.style.cssText += ";position:absolute;inset:0;width:100%;height:100%;z-index:1;pointer-events:none;overflow:hidden;background:var(--pmn-body);", M.appendChild(m);
630
+ const j = Ne.direction === "back" ? 1 : -1, Y = [...M.querySelectorAll("[data-modal-route-key]")].find((se) => se.dataset.modalRouteKey === re);
631
+ Y && (Y.style.zIndex = "2");
632
+ const fe = () => {
633
+ m.remove(), Y && (Y.style.zIndex = ""), V.current === ve && (V.current = null);
576
634
  };
577
- let Z;
578
- if (c.animate)
579
- Z = c.animate([
635
+ let ve;
636
+ if (m.animate)
637
+ ve = m.animate([
580
638
  { opacity: 1, transform: "translate3d(0,0,0)" },
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;
639
+ { opacity: 1, transform: `translate3d(${j * 100}%,0,0)` }
640
+ ], { duration: Ne.duration, easing: "cubic-bezier(.22,1,.36,1)", fill: "forwards" }), ve.addEventListener("finish", fe, { once: !0 }), ve.addEventListener("cancel", fe, { once: !0 }), V.current = ve;
583
641
  else {
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;
642
+ m.classList.add("pmn-page-exit", `pmn-page-exit-${Ne.direction}`), m.style.setProperty("--pmn-page-duration", `${Ne.duration}ms`), m.style.setProperty("--pmn-page-distance", "100%");
643
+ const se = setTimeout(fe, Ne.duration + 40);
644
+ ve = { cancel: () => {
645
+ clearTimeout(se), fe();
646
+ } }, V.current = ve;
589
647
  }
590
648
  return () => {
591
- Z?.cancel?.(), c.remove();
649
+ ve?.cancel?.(), m.remove();
592
650
  };
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;
651
+ }, [re]), Ae(() => {
652
+ J.current = !1;
653
+ const m = [...X.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((Y) => Y.dataset.modalRouteKey === re);
654
+ if (!m) return;
655
+ const M = $.current.get(re);
656
+ (M?.isConnected && m.contains(M) && !M.matches(":disabled") && !M.closest("[inert], [hidden]") ? M : m).focus({ preventScroll: !0 });
657
+ }, [re]), U(() => {
658
+ let m = !1;
659
+ for (const [j, Y] of ut.current)
660
+ Y.owner !== "global" && Y.owner !== re && (ut.current.delete(j), m = !0);
661
+ m && Ge();
662
+ const M = new Set(v.map((j) => j.key));
663
+ ue((j) => {
664
+ const Y = Object.keys(j).filter((ve) => !M.has(ve));
665
+ if (!Y.length) return j;
666
+ const fe = { ...j };
667
+ return Y.forEach((ve) => delete fe[ve]), fe;
610
668
  });
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);
669
+ for (const j of $.current.keys()) M.has(j) || $.current.delete(j);
670
+ }, [re, v, Ge]), U(() => {
671
+ if (oe.current?.key !== re) {
672
+ if (oe.current) {
673
+ const m = { from: oe.current, to: ne, stack: v };
674
+ c("onBlur", { route: oe.current, ...m }), c("onNavigate", m), c("onRouteChange", m);
617
675
  }
618
- a("onFocus", { route: A, stack: m }), _.current = A;
676
+ c("onFocus", { route: ne, stack: v }), oe.current = ne;
619
677
  }
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 }));
678
+ }, [ne, re, v, c]), U(() => () => {
679
+ ut.current.clear(), $.current.clear();
680
+ for (const m of G.current.values()) m.resolve({ status: "dismissed" });
681
+ G.current.clear();
682
+ }, []), U(() => {
683
+ k.current || (k.current = !0, l?.({ route: ne, stack: v }));
626
684
  }, []);
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,
685
+ const Ct = $t(v, Ee, s.maxCachedScreens, C, b?.());
686
+ Ae(() => {
687
+ F((m) => hn(v, Ct, m));
688
+ }, [v, Ct]);
689
+ const Et = Q(() => ({ ...Ee[ne.name], ...ne.options ?? {} }), [Ee, ne.name, ne.options]), ln = e.refs.header;
690
+ return /* @__PURE__ */ p(yt.Provider, { value: ln.current, children: /* @__PURE__ */ p(Tt.Provider, { value: q, children: /* @__PURE__ */ p(Vt.Provider, { value: D.current, children: /* @__PURE__ */ p(Ut.Provider, { value: E.current, children: /* @__PURE__ */ p(_t.Provider, { value: dt, children: /* @__PURE__ */ p(vt.Provider, { value: qe, children: /* @__PURE__ */ p(bt.Provider, { value: z.current, children: /* @__PURE__ */ p(Ue.Provider, { value: Ze, children: /* @__PURE__ */ be(Xt, { store: e.stores.layout, screenOptions: Et.modalOptions, dialogRef: X, requestClose: Le, exiting: h, children: [
691
+ /* @__PURE__ */ p(Jt, { store: e.stores.layout, screen: Et, route: ne, navigation: dt, requestClose: Le, translate: o, canGoBack: v.length > 1 }),
692
+ /* @__PURE__ */ p("main", { ref: B, className: "pmn-main", children: Ct.map((m) => /* @__PURE__ */ p(
693
+ Kn,
632
694
  {
633
- route: c,
634
- screen: Se[c.name],
635
- navigation: re,
636
- focused: c.key === y,
637
- resultEvent: $[c.key] ?? null,
695
+ route: m,
696
+ screen: Ee[m.name],
697
+ navigation: dt,
698
+ focused: m.key === re,
699
+ resultEvent: Z[m.key] ?? null,
638
700
  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,
701
+ setFooter: qt,
702
+ loadingApi: Ze,
703
+ loadingStore: T.current,
704
+ notifyError: u,
705
+ registerDirtyGuard: g,
706
+ pageMotion: m.key === re ? Ne : null,
645
707
  lazyFallback: s.lazyFallback
646
708
  },
647
- c.key
709
+ m.key
648
710
  )) }),
649
- /* @__PURE__ */ i(
650
- Et,
711
+ /* @__PURE__ */ p(
712
+ Dn,
651
713
  {
652
- store: q.current,
653
- routeKey: y,
654
- screen: Ae,
714
+ store: E.current,
715
+ routeKey: re,
716
+ screen: Et,
655
717
  layoutStore: e.stores.layout,
656
- route: A,
657
- navigation: re,
658
- requestClose: he,
718
+ route: ne,
719
+ navigation: dt,
720
+ requestClose: Le,
659
721
  translate: o,
660
- onError: l,
661
- loadingApi: Qe
722
+ onError: u,
723
+ loadingApi: Ze
662
724
  },
663
- y
725
+ re
664
726
  ),
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: "×" })
727
+ /* @__PURE__ */ p($n, { store: T.current, translate: o }),
728
+ /* @__PURE__ */ p(In, { store: D.current, dismiss: N }),
729
+ i && /* @__PURE__ */ be("div", { className: "pmn-error", role: "alert", children: [
730
+ /* @__PURE__ */ p("span", { children: i.message || String(i) }),
731
+ /* @__PURE__ */ p("button", { type: "button", onClick: d, "aria-label": "Dismiss error", children: "×" })
670
732
  ] })
671
733
  ] }) }) }) }) }) }) }) }) });
672
734
  }
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;
735
+ const Or = (e) => e, Pr = (e) => ({ definitionLoader: e }), pt = /* @__PURE__ */ new WeakMap();
736
+ function gt(e) {
737
+ if (!pt.has(e)) {
738
+ const t = Promise.resolve().then(e).catch((n) => {
739
+ throw pt.delete(e), n;
678
740
  });
679
- Je.set(e, n);
741
+ pt.set(e, t);
680
742
  }
681
- return Je.get(e);
743
+ return pt.get(e);
682
744
  }
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;
745
+ async function an(e, t) {
746
+ let n = typeof e == "string" ? t && Object.hasOwn(t, e) ? t[e] : void 0 : e;
747
+ if (n?.definitionLoader) {
748
+ const r = await gt(n.definitionLoader);
749
+ n = r.default ?? r;
688
750
  }
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 }) });
751
+ if (!n || !(n.component || n.loader || n.screens)) throw new Error(`[react-modal-navigation] Unknown or invalid modal: ${typeof e == "string" ? e : "inline"}`);
752
+ return n;
753
+ }
754
+ async function Wn(e, t, n) {
755
+ const r = await an(e, t), a = (Array.isArray(n) ? n : [n ?? r.initialRoute ?? Object.keys(r.screens ?? {})[0]]).map((l) => r.screens ? Object.hasOwn(r.screens, l) ? r.screens[l] : null : r);
756
+ if (a.some((l) => !l)) throw new Error("[react-modal-navigation] Unknown preload screen");
757
+ return await Promise.all(a.map((l) => l.loader ? gt(l.loader) : void 0)), r;
758
+ }
759
+ function Gn(e) {
760
+ return function(n) {
761
+ const [r, o] = xe(() => Se.lazy(() => gt(e)));
762
+ return /* @__PURE__ */ p(Nt, { route: n.route, onRetry: () => o(() => Se.lazy(() => gt(e))), children: /* @__PURE__ */ p(r, { ...n }) });
763
+ };
764
+ }
765
+ function _n(e, { limit: t = 100 } = {}) {
766
+ const n = Number.isFinite(t) ? Math.max(1, Math.min(1e3, Math.floor(t))) : 100, r = je({ active: null, queueSize: 0, events: [] });
767
+ let o, a = 0, l = !1, f = [];
768
+ const u = (g, b) => {
769
+ if (l) return;
770
+ const x = r.getSnapshot(), h = e.hostStore.getSnapshot().active, s = h?.runtime.alive.current ? h : null, v = s?.runtime.stores.navigation.getSnapshot(), I = s?.runtime.stores.loading.getSnapshot();
771
+ let z = s ? { id: s.id, name: s.name, routes: v.stack.map(({ key: L, name: A }) => ({ key: L, name: A })), focusedKey: v.currentRoute?.key, loadingCount: I.count, taskCount: s.runtime.tasks.count() } : null;
772
+ const T = g ? [...x.events, { sequence: ++a, time: Date.now(), type: g, id: b }].slice(-n) : x.events, E = x.active;
773
+ z && E && z.id === E.id && z.name === E.name && z.focusedKey === E.focusedKey && z.loadingCount === E.loadingCount && z.taskCount === E.taskCount && z.routes.length === E.routes.length && z.routes.every((L, A) => L.key === E.routes[A].key && L.name === E.routes[A].name) && (z = E);
774
+ const D = e.statusStore.getSnapshot().queueSize;
775
+ z === E && D === x.queueSize && T === x.events || r.publish({ active: z, queueSize: D, events: T });
776
+ }, i = () => {
777
+ const g = e.hostStore.getSnapshot().active?.runtime;
778
+ g !== o && (f.forEach((b) => b()), o = g, f = g ? ["ready", "destroy", "change", "routeChange", "routeRemove", "routeBlur", "routeFocus"].map((b) => g.events.on(b, (x) => u(b === "change" ? `store.${x.store}` : `instance.${b}`, x.id))) : []), u();
779
+ }, d = [e.hostStore.subscribe(i), e.statusStore.subscribe(() => u()), ...["open", "close", "queueChange"].map((g) => e.commands.on(g, (b) => u(`manager.${g}`, b.id)))];
780
+ return i(), {
781
+ getSnapshot: r.getSnapshot,
782
+ subscribe: r.subscribe,
783
+ refresh: () => u(),
784
+ clear() {
785
+ !l && r.getSnapshot().events.length && r.publish({ ...r.getSnapshot(), events: [] });
786
+ },
787
+ dispose() {
788
+ l || (l = !0, d.forEach((g) => g()), f.forEach((g) => g()), f = [], o = null, r.publish({ active: null, queueSize: 0, events: [] }), r.destroy());
789
+ }
701
790
  };
702
791
  }
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);
792
+ function sn() {
793
+ const e = /* @__PURE__ */ new Map();
794
+ let t = !1;
795
+ const n = (r, o) => {
796
+ const a = e.get(r);
797
+ a?.delete(o), a?.size || e.delete(r);
710
798
  };
711
- const g = {
712
- layout: Oe(n),
713
- navigation: Oe({ canGoBack: !1, stack: r, currentRoute: r[0] }),
799
+ return {
800
+ on(r, o) {
801
+ if (t) return () => {
802
+ };
803
+ const a = e.get(r) ?? /* @__PURE__ */ new Set();
804
+ return e.set(r, a), a.add(o), () => n(r, o);
805
+ },
806
+ off: n,
807
+ emit(r, o) {
808
+ if (!t) {
809
+ for (const a of [...e.get(r) ?? []])
810
+ if (!(t || !e.get(r)?.has(a)))
811
+ try {
812
+ Promise.resolve(a(o)).catch((l) => console.error(l));
813
+ } catch (l) {
814
+ console.error(l);
815
+ }
816
+ }
817
+ },
818
+ clear() {
819
+ e.clear();
820
+ },
821
+ destroy() {
822
+ t = !0, e.clear();
823
+ }
824
+ };
825
+ }
826
+ function Un(e, t, n, r) {
827
+ const o = n.currentRoute, a = r.currentRoute;
828
+ if (o?.key === a?.key && n.stack.length === r.stack.length && n.stack.every((g, b) => g.key === r.stack[b].key)) return;
829
+ const l = new Set(n.stack.map((g) => g.key)), f = new Set(r.stack.map((g) => g.key)), u = n.stack.filter((g) => !f.has(g.key)), i = r.stack.filter((g) => !l.has(g.key));
830
+ if (o?.key === a?.key && !u.length && !i.length) return;
831
+ const d = { id: t, from: o, to: a, added: i, removed: u, stack: r.stack };
832
+ e.emit("routeChange", d), u.length && e.emit("routeRemove", d), o?.key !== a?.key && (o && e.emit("routeBlur", { ...d, route: o }), a && e.emit("routeFocus", { ...d, route: a }));
833
+ }
834
+ function Vn() {
835
+ const e = /* @__PURE__ */ new Map();
836
+ let t = !1;
837
+ const n = /* @__PURE__ */ new Set(), r = (a) => {
838
+ try {
839
+ Promise.resolve(a.cancel()).catch((l) => console.error(l));
840
+ } catch (l) {
841
+ console.error(l);
842
+ }
843
+ }, o = (a) => {
844
+ for (const [l, f] of [...e])
845
+ !a(f) || !e.delete(l) || r(l);
846
+ };
847
+ return {
848
+ register(a, l) {
849
+ return t || n.has(a) ? (r(l), () => {
850
+ }) : (e.set(l, a), () => e.delete(l));
851
+ },
852
+ cancelRoutes(a) {
853
+ const l = new Set(a), f = [...l].filter((u) => !n.has(u));
854
+ f.forEach((u) => n.add(u));
855
+ try {
856
+ o((u) => l.has(u));
857
+ } finally {
858
+ f.forEach((u) => n.delete(u));
859
+ }
860
+ },
861
+ destroy() {
862
+ t || (t = !0, o(() => !0));
863
+ },
864
+ count: () => e.size
865
+ };
866
+ }
867
+ function Yn(e, t) {
868
+ const n = e.config.singlePage || Object.keys(e.config.screens).length === 1, r = n ? [{ key: "single", name: e.screen, params: e.params ?? {}, options: {} }] : Yt(e.screen, e.params), o = je({});
869
+ o.set = (C, F) => {
870
+ const $ = o.getSnapshot();
871
+ if (F == null && !(C in $) || Object.is($[C], F)) return;
872
+ const X = { ...$ };
873
+ F == null ? delete X[C] : X[C] = F, o.publish(X);
874
+ };
875
+ const a = {
876
+ layout: je(t),
877
+ navigation: je({ canGoBack: !1, stack: r, currentRoute: r[0] }),
714
878
  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)
879
+ footer: je({}),
880
+ loading: je({ visible: !1, text: null, count: 0 }),
881
+ toast: je([])
882
+ }, l = Object.fromEntries(Object.entries(a).map(([C, F]) => [C, { current: F }])), f = sn();
883
+ let u;
884
+ const i = () => {
885
+ const C = Object.entries(a);
886
+ return (!u || C.some(([F, $]) => !Object.is(u[F], $.getSnapshot()))) && (u = Object.freeze(Object.fromEntries(C.map(([F, $]) => [F, $.getSnapshot()])))), u;
887
+ }, d = (C, F, $ = Object.is, X) => {
888
+ if (!s.current) return () => {
889
+ };
890
+ const B = X === void 0 ? Object.values(a) : [...new Set(X)].map((J) => {
891
+ if (!Object.hasOwn(a, J)) throw new Error(`Unknown runtime store: ${J}`);
892
+ return a[J];
893
+ });
894
+ let te = C(i());
895
+ const V = () => {
896
+ try {
897
+ const J = C(i());
898
+ if ($(te, J)) return;
899
+ const O = te;
900
+ te = J, Promise.resolve(F(J, O)).catch((G) => console.error(G));
901
+ } catch (J) {
902
+ console.error(J);
903
+ }
904
+ }, oe = B.map((J) => J.subscribe(V));
905
+ return () => oe.forEach((J) => J());
906
+ }, g = Vn(), b = /* @__PURE__ */ new Map(), x = (C, F) => {
907
+ if (!s.current) return () => {
908
+ };
909
+ const $ = b.get(C) ?? /* @__PURE__ */ new Set();
910
+ return b.set(C, $), $.add(F), () => {
911
+ $.delete(F), !$.size && b.get(C) === $ && b.delete(C);
912
+ };
913
+ }, h = async (C, F) => {
914
+ for (const $ of C) for (const X of [...b.get($) ?? []]) {
915
+ if (!s.current) return !1;
916
+ if (b.get($)?.has(X) && await X(F) === !1)
917
+ return !1;
918
+ }
919
+ return s.current;
920
+ }, s = { current: !0 };
921
+ let v;
922
+ const I = new Promise((C) => {
923
+ v = C;
924
+ }), z = (C) => s.current ? (N.navigationCommands = C, v(!0), N.hasRegistered || (N.hasRegistered = !0, f.emit("ready", { id: e.id })), () => {
925
+ N.navigationCommands === C && (N.navigationCommands = null);
926
+ }) : () => {
927
+ }, T = /* @__PURE__ */ new Set(), E = { current: /* @__PURE__ */ new Map() }, D = { current: /* @__PURE__ */ new Map() }, L = { current: 0 }, A = (C) => s.current ? (T.add(C), () => T.delete(C)) : (C(), () => {
928
+ }), q = () => {
929
+ if (s.current) {
930
+ s.current = !1, v(!1), N.navigationCommands = null, g.destroy(), b.clear();
931
+ for (const C of T)
723
932
  try {
724
- s();
725
- } catch (m) {
726
- console.error(m);
933
+ C();
934
+ } catch (F) {
935
+ console.error(F);
727
936
  }
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());
937
+ T.clear(), E.current.clear();
938
+ for (const C of D.current.values()) C.resolve({ status: "dismissed" });
939
+ D.current.clear(), a.layout.destroy({}), a.navigation.destroy({ canGoBack: !1, stack: [], currentRoute: null }), a.header.destroy({}), a.footer.destroy({}), a.loading.destroy({ visible: !1, text: null, count: 0 }), a.toast.destroy([]), u = void 0, f.emit("destroy", { id: e.id }), f.destroy();
731
940
  }
732
- };
733
- return { id: e.id, single: t, stores: g, refs: p, alive: h, loadingTasks: d, loadingSequence: x, pageRequests: u, addCleanup: w, destroy: b };
941
+ }, N = { events: f, getSnapshot: i, subscribeState: d, ready: I, registerNavigation: z, id: e.id, single: n, stores: a, refs: l, alive: s, loadingTasks: E, loadingSequence: L, pageRequests: D, tasks: g, registerRemovalGuard: x, canRemove: h, addCleanup: A, destroy: q }, Z = [];
942
+ let ue = !1;
943
+ for (const [C, F] of Object.entries(a)) {
944
+ let $ = F.getSnapshot();
945
+ F.subscribe(() => {
946
+ const X = F.getSnapshot(), B = $;
947
+ if ($ = X, Z.push({ key: C, old: B, next: X }), !ue) {
948
+ ue = !0;
949
+ try {
950
+ for (let te = 0; te < Z.length && s.current; te++) {
951
+ const { key: V, old: oe, next: J } = Z[te];
952
+ f.emit("change", { id: e.id, store: V, previous: oe, current: J }), V === "navigation" && s.current && Un(f, e.id, oe, J);
953
+ }
954
+ } finally {
955
+ Z.length = 0, ue = !1;
956
+ }
957
+ }
958
+ });
959
+ }
960
+ return N;
734
961
  }
735
- function _e(e, n, t) {
962
+ function nt(e, t, n) {
736
963
  if (typeof e == "string") {
737
964
  if (!e.trim()) throw new TypeError("[react-modal-navigation] modal name must not be empty");
738
- return { name: e, params: n ?? {}, options: t ?? {} };
965
+ return { name: e, params: t ?? {}, options: n ?? {} };
739
966
  }
740
967
  if (e === null || typeof e != "object" || Array.isArray(e))
741
968
  throw new TypeError("[react-modal-navigation] open expects a modal name or a configuration object");
742
969
  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 };
970
+ const { params: u, options: i, screen: d, ...g } = e;
971
+ return { name: g, params: t ?? u ?? {}, options: { ...i, ...n }, screen: d };
745
972
  }
746
- const { name: r, screen: o, params: g = {}, options: p = {}, ...h } = e;
973
+ const { name: r, screen: o, params: a = {}, options: l = {}, ...f } = e;
747
974
  if (typeof r != "string" || !r.trim())
748
975
  throw new TypeError("[react-modal-navigation] open config requires a non-empty string name");
749
- if (p === null || typeof p != "object" || Array.isArray(p))
976
+ if (l === null || typeof l != "object" || Array.isArray(l))
750
977
  throw new TypeError("[react-modal-navigation] open config options must be an object");
751
978
  if (o !== void 0 && (typeof o != "string" || !o.trim()))
752
979
  throw new TypeError("[react-modal-navigation] screen must be a non-empty string");
753
- return { name: r, ...o === void 0 ? {} : { screen: o }, params: g, options: { ...h, ...p } };
980
+ return { name: r, ...o === void 0 ? {} : { screen: o }, params: a, options: { ...f, ...l } };
754
981
  }
755
- function Lt() {
982
+ function Qn() {
756
983
  const e = /* @__PURE__ */ new Map();
757
984
  return {
758
- wait(n) {
759
- return n <= 0 ? Promise.resolve() : new Promise((t) => {
985
+ wait(t) {
986
+ return t <= 0 ? Promise.resolve() : new Promise((n) => {
760
987
  const r = setTimeout(() => {
761
- e.delete(r), t();
762
- }, Math.max(0, n));
763
- e.set(r, t);
988
+ e.delete(r), n();
989
+ }, Math.max(0, t));
990
+ e.set(r, n);
764
991
  });
765
992
  },
766
993
  cancelAll() {
767
- for (const [n, t] of e)
768
- clearTimeout(n), t();
994
+ for (const [t, n] of e)
995
+ clearTimeout(t), n();
769
996
  e.clear();
770
997
  },
771
998
  pendingCount: () => e.size
772
999
  };
773
1000
  }
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();
1001
+ const Zn = { placement: "right", showHeader: !0, showBackButton: !0, showCloseButton: !0, viewportGap: 5, borderRadius: 12, closeOnOverlay: !1, closeOnEsc: !0 };
1002
+ function Xn(e, t) {
1003
+ let n = e;
1004
+ const r = sn(), o = /* @__PURE__ */ new Set(), { confirmDiscard: a, onError: l } = n, f = je({ isOpen: !1, activeName: null, isFullscreen: !1, queueSize: 0, error: null }), u = je({ active: null, options: null, exiting: !1, error: null, translate: n.translate });
1005
+ let i = null;
1006
+ const d = (c) => {
1007
+ i = c, Te();
781
1008
  };
782
- let u = null;
783
- const x = (a) => {
784
- u = a, Me();
1009
+ let g = null;
1010
+ const b = (c) => {
1011
+ g = c, Te();
785
1012
  };
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;
799
- }
800
- return !0;
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;
1013
+ let x = 0;
1014
+ const h = (c) => {
1015
+ x = c, Te();
1016
+ }, s = { current: null }, v = { current: /* @__PURE__ */ new Map() }, I = { current: [] }, z = { current: null }, T = { current: null }, E = { current: 0 }, D = { current: null }, L = { current: !1 }, A = { current: 0 }, q = { current: null }, N = { current: /* @__PURE__ */ new Map() };
1017
+ let Z = !1;
1018
+ const ue = (c) => {
1019
+ Z = c, Te();
1020
+ }, C = { current: a }, F = (c, y) => {
1021
+ const R = N.current.get(c) ?? /* @__PURE__ */ new Set();
1022
+ return N.current.set(c, R), R.add(y), () => {
1023
+ R.delete(y), !R.size && N.current.get(c) === R && N.current.delete(c);
1024
+ };
1025
+ }, $ = async (c, y) => {
1026
+ for (const R of c) for (const w of [...N.current.get(R) ?? []]) {
1027
+ if (!N.current.get(R)?.has(w) || !w.dirty) continue;
1028
+ if ((w.onBeforeDiscard ? await w.onBeforeDiscard(y) : C.current ? await C.current(y) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(w.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
806
1029
  }
807
1030
  return !0;
808
- }), z = { current: !0 }, _ = { current: null };
809
- _.current || (_.current = Lt());
810
- const le = { current: g }, W = ((a, f) => {
811
- z.current && x(a);
1031
+ }, X = (c) => $([...N.current.keys()], c), B = { current: !0 }, te = { current: null };
1032
+ te.current || (te.current = Qn());
1033
+ const V = { current: l }, oe = ((c, y) => {
1034
+ B.current && b(c);
812
1035
  try {
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);
1036
+ V.current ? V.current(c, y) : console.error("[react-modal-navigation]", c);
1037
+ } catch (R) {
1038
+ console.error("[react-modal-navigation] onError failed", R);
816
1039
  }
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 };
1040
+ }), J = ((c, y) => {
1041
+ const R = v.current.get(c);
1042
+ v.current.delete(c);
1043
+ for (const w of R ?? []) w(y);
1044
+ }), O = ((c) => ({ ...Zn, ...n.defaultOptions, ...n.theme !== void 0 ? { theme: n.theme } : {}, ...n.backgroundColor !== void 0 ? { backgroundColor: n.backgroundColor } : {}, ...c.config.modalOptions, ...c.overrides, runtimeLayout: c.runtimeLayout })), G = (async (c = "api", y, R = {}) => {
1045
+ const w = s.current;
1046
+ if (!w || D.current || L.current) return !1;
1047
+ const H = A.current;
1048
+ D.current = w.id, L.current = !0;
1049
+ const W = O(w), ae = { ...R, reason: c, result: y, name: w.name };
827
1050
  try {
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 });
1051
+ if (!await X(ae) || H !== A.current || s.current?.id !== w.id || !await w.runtime.canRemove(w.runtime.stores.navigation.getSnapshot().stack.map((pe) => pe.key), ae) || H !== A.current || s.current?.id !== w.id || await W.onBeforeClose?.(ae) === !1 || H !== A.current || s.current?.id !== w.id || !B.current) return !1;
1052
+ ue(!0);
1053
+ const me = W.animation === !1 || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? 0 : Math.max(0, Number(W.animationDuration ?? 220) || 0);
1054
+ if (await te.current.wait(Math.min(me, 1e3)), !B.current || s.current?.id !== w.id) return !1;
1055
+ w.runtime.destroy(), s.current = null, q.current = null, Z = !1, d(null), N.current.clear();
1056
+ const ie = R.confirmed || y !== void 0 ? { status: "confirmed", value: y, reason: c } : { status: "dismissed", reason: c };
1057
+ J(w.id, ie), r.emit("close", { id: w.id, name: w.name, result: ie });
833
1058
  try {
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 });
1059
+ (R.confirmed || y !== void 0) && await W.onConfirmed?.(y), await W.onClose?.(ae), await W.onClosed?.(ae);
1060
+ } catch (pe) {
1061
+ H === A.current && oe(pe, { phase: "onClose", name: w.name });
837
1062
  }
838
1063
  return !0;
839
- } catch (ce) {
840
- return B === L.current && s.current?.id === v.id && W(ce, { phase: "onBeforeClose", name: v.name }), !1;
1064
+ } catch (me) {
1065
+ return H === A.current && s.current?.id === w.id && oe(me, { phase: "onBeforeClose", name: w.name }), !1;
841
1066
  } finally {
842
- O.current === v.id && (O.current = null), B === L.current && (P.current = !1), !s.current && z.current && queueMicrotask(() => j.current?.());
1067
+ D.current === w.id && (D.current = null), H === A.current && (L.current = !1), !s.current && B.current && queueMicrotask(() => T.current?.());
843
1068
  }
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;
1069
+ }), ke = (async (c, y = {}, R = {}, w, H) => {
1070
+ if (!B.current || L.current || D.current) return null;
1071
+ L.current = !0;
1072
+ const W = A.current;
848
1073
  try {
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);
1074
+ const ae = await an(c, n.registry);
1075
+ if (!B.current || W !== A.current) return null;
1076
+ const me = (he) => he.loader && !he.component ? { ...he, component: t(he.loader) } : he, ie = ae.screens ? { ...ae, screens: Object.fromEntries(Object.entries(ae.screens).map(([he, ze]) => [he, me(ze)])) } : me(ae);
1077
+ c = typeof c == "string" ? c : ae.name ?? "inline";
1078
+ const pe = ie?.component && !ie.screens ? { ...ie, singlePage: !0, initialRoute: "__single__", screens: { __single__: { component: ie.component, title: ie.title, ...ae.screenOptions ?? {} } } } : ie;
1079
+ if (!pe) throw new Error(`[react-modal-navigation] Unknown modal: ${c}`);
1080
+ const Re = H ?? pe.initialRoute ?? Object.keys(pe.screens ?? {})[0];
1081
+ if (!pe.screens || !Object.hasOwn(pe.screens, Re) || !pe.screens[Re]) throw new Error(`[react-modal-navigation] Unknown initial screen '${Re}' in modal '${c}'`);
1082
+ const S = s.current, le = R.instanceKey ?? pe.modalOptions?.instanceKey, Le = R.duplicateStrategy ?? pe.modalOptions?.duplicateStrategy;
1083
+ if (S && le != null && S.instanceKey === le) {
1084
+ if (Le === "ignore") return null;
1085
+ if (Le === "reuse") {
1086
+ if (w) {
1087
+ const he = v.current.get(S.id) ?? [];
1088
+ he.push(w), v.current.set(S.id, he);
864
1089
  }
865
- return ae.id;
1090
+ return S.id;
866
1091
  }
867
1092
  }
868
- if (ae) {
869
- const re = ie(ae), Pe = { reason: "replace", name: ae.name, nextName: a };
1093
+ if (S) {
1094
+ const he = O(S), ze = { reason: "replace", name: S.name, nextName: c };
870
1095
  try {
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;
1096
+ if (!await X(ze) || W !== A.current || s.current?.id !== S.id || !await S.runtime.canRemove(S.runtime.stores.navigation.getSnapshot().stack.map((Fe) => Fe.key), ze) || W !== A.current || s.current?.id !== S.id || await he.onBeforeClose?.(ze) === !1) return null;
1097
+ } catch (Fe) {
1098
+ return W === A.current && s.current?.id === S.id && oe(Fe, { phase: "onBeforeClose", name: S.name }), null;
874
1099
  }
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" });
1100
+ if (!B.current || W !== A.current || s.current?.id !== S.id) return null;
1101
+ S.runtime.destroy(), s.current = null, q.current = null, d(null), N.current.clear();
1102
+ const qe = { status: "replaced", reason: "replace" };
1103
+ J(S.id, qe), r.emit("close", { id: S.id, name: S.name, result: qe });
877
1104
  try {
878
- await re.onClose?.(Pe), await re.onClosed?.(Pe);
879
- } catch (Ae) {
880
- N === L.current && W(Ae, { phase: "onClose", name: ae.name });
1105
+ await he.onClose?.(ze), await he.onClosed?.(ze);
1106
+ } catch (Fe) {
1107
+ W === A.current && oe(Fe, { phase: "onClose", name: S.name });
881
1108
  }
882
- if (!z.current || N !== L.current) return null;
1109
+ if (!B.current || W !== A.current) return null;
883
1110
  }
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;
1111
+ const ye = { id: ++E.current, name: c, screen: Re, params: y, config: pe, overrides: R, instanceKey: le };
1112
+ return ye.runtime = Yn(ye, O(ye)), ye.runtime.bindings = _e(ye.id), s.current = ye, q.current = null, w && v.current.set(ye.id, [w]), g = null, d(ye), r.emit("open", { id: ye.id, name: ye.name }), ye.id;
886
1113
  } finally {
887
- N === L.current && (P.current = !1), !s.current && z.current && queueMicrotask(() => j.current?.());
1114
+ W === A.current && (L.current = !1), !s.current && B.current && queueMicrotask(() => T.current?.());
888
1115
  }
889
1116
  });
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);
1117
+ z.current = ke;
1118
+ const Ce = (async () => {
1119
+ if (!B.current || s.current || L.current || D.current) return;
1120
+ const c = I.current.shift();
1121
+ if (c) {
1122
+ o.add(c), h(I.current.length);
896
1123
  try {
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?.());
1124
+ const y = await z.current(c.args.name, c.args.params, c.args.options, c.resolveResult, c.args.screen);
1125
+ y === null ? (c.resolveResult?.({ status: "dismissed", reason: "blocked" }), c.resolveId?.(null), queueMicrotask(() => T.current?.())) : c.resolveId?.(y);
1126
+ } catch (y) {
1127
+ c.reject?.(y), queueMicrotask(() => T.current?.());
901
1128
  } finally {
902
- r.delete(a);
1129
+ o.delete(c);
903
1130
  }
904
1131
  }
905
1132
  });
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?.());
1133
+ T.current = Ce;
1134
+ const K = ((c, y, R) => {
1135
+ if (!B.current) return Promise.resolve(null);
1136
+ const w = nt(c, y, R);
1137
+ return typeof w.name == "string" && !n.registry?.[w.name] ? Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${w.name}`)) : new Promise((H, W) => {
1138
+ I.current.push({ args: w, resolveId: H, reject: W }), h(I.current.length), queueMicrotask(() => T.current?.());
912
1139
  });
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?.());
1140
+ }), de = ((c, y, R) => {
1141
+ if (!B.current) return Promise.resolve({ status: "dismissed", reason: "unmount" });
1142
+ const w = nt(c, y, R);
1143
+ return typeof w.name == "string" && !n.registry?.[w.name] ? Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${w.name}`)) : new Promise((H, W) => {
1144
+ I.current.push({ args: w, resolveResult: H, reject: W }), h(I.current.length), queueMicrotask(() => T.current?.());
918
1145
  });
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);
1146
+ }), k = ((c) => {
1147
+ if (!c || typeof c != "object" || Array.isArray(c)) throw new TypeError("[react-modal-navigation] update expects an options object");
1148
+ const y = s.current;
1149
+ return !y || L.current ? !1 : (Object.keys(c).every((R) => Object.is(O(y)[R], c[R])) || (y.overrides = { ...y.overrides, ...c }, y.runtimeLayout = { ...y.runtimeLayout, ...c }, Te()), !0);
1150
+ }), ce = ((c, y) => Wn(c, n.registry, y)), ne = ((c) => k({ fullscreen: !!c })), re = (() => ne(!(s.current && O(s.current).fullscreen))), Be = ((c = "queue-cleared") => {
1151
+ const y = I.current.splice(0);
1152
+ h(0);
1153
+ for (const R of y)
1154
+ R.resolveId?.(null), R.resolveResult?.({ status: "dismissed", reason: c });
1155
+ return y.length;
1156
+ }), st = ((c, y, R) => {
1157
+ const w = nt(c, y, R);
1158
+ return ke(w.name, w.params, w.options, void 0, w.screen);
1159
+ }), We = ((c, y, R) => {
1160
+ const w = nt(c, y, R);
1161
+ return new Promise((H, W) => {
1162
+ ke(w.name, w.params, w.options, H, w.screen).then((ae) => {
1163
+ ae === null && H({ status: "dismissed", reason: "blocked" });
1164
+ }, W);
947
1165
  });
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);
1166
+ }), it = (async (c, y, R) => {
1167
+ const w = nt(c, y, R);
1168
+ let H;
1169
+ const W = new Promise((S) => {
1170
+ H = S;
1171
+ }), ae = await ke(w.name, w.params, w.options, H, w.screen);
1172
+ ae === null && H({ status: "dismissed", reason: "blocked" });
1173
+ const me = () => ae !== null && s.current?.id === ae && s.current.runtime.alive.current, ie = () => me() ? s.current.runtime : null, pe = ie()?.ready.then((S) => S && me()) ?? Promise.resolve(!1), Re = (S, ...le) => ie()?.navigationCommands?.[S]?.(...le) ?? !1;
1174
+ return {
1175
+ id: ae,
1176
+ result: W,
1177
+ isActive: me,
1178
+ replaceOptions: (S) => {
1179
+ if (!me() || L.current) return !1;
1180
+ const le = s.current;
1181
+ return le.overrides = { ...S }, le.runtimeLayout = void 0, Te(), !0;
1182
+ },
1183
+ dispose: () => {
1184
+ if (!me()) return !1;
1185
+ const S = s.current;
1186
+ A.current++, te.current.cancelAll(), s.current = null, q.current = null, D.current = null, L.current = !1, Z = !1, N.current.clear(), S.runtime.destroy(), d(null);
1187
+ const le = { status: "dismissed", reason: "unmount" };
1188
+ return J(ae, le), r.emit("close", { id: ae, name: S.name, result: le }), queueMicrotask(() => T.current?.()), !0;
1189
+ },
1190
+ ready: pe,
1191
+ on: (S, le) => ie()?.events.on(S, le) ?? (() => {
1192
+ }),
1193
+ off: (S, le) => ie()?.events.off(S, le),
1194
+ getSnapshot: () => ie()?.getSnapshot() ?? null,
1195
+ subscribeState: (S, le, Le, ye) => ie()?.subscribeState(S, le, Le, ye) ?? (() => {
1196
+ }),
1197
+ getState: () => ie()?.stores.navigation.getSnapshot() ?? null,
1198
+ subscribe: (S) => ie()?.stores.navigation.subscribe(S) ?? (() => {
1199
+ }),
1200
+ clearCache: async (S) => !!await Re("clearCache", S),
1201
+ navigate: async (...S) => !!await Re("navigate", ...S),
1202
+ setParams: (S) => ie()?.navigationCommands ? (Re("setParams", S), !0) : !1,
1203
+ setLoading: (S, le) => ie()?.navigationCommands?.setLoading ? (Re("setLoading", S, le), !0) : !1,
1204
+ setOptions: (S) => me() && k(S),
1205
+ setFullscreen: (S) => me() && k({ fullscreen: !!S }),
1206
+ close: (S) => me() ? G("api", S) : Promise.resolve(!1),
1207
+ confirm: (S) => me() ? G("confirm", S, { confirmed: !0 }) : Promise.resolve(!1)
1208
+ };
1209
+ }), Qe = ((c) => G("api", c)), ct = ((c = "api") => G(c)), Ne = ((c) => G("confirm", c, { confirmed: !0 })), lt = ((c, y) => q.current?.setLoading(c, y)), Ze = () => b(null), Ge = /* @__PURE__ */ new Set(), De = { inspect: (c) => {
1210
+ const y = _n({ hostStore: u, statusStore: f, commands: De }, c), R = y.dispose;
1211
+ return y.dispose = () => {
1212
+ Ge.delete(y), R();
1213
+ }, Ge.add(y), B.current || y.dispose(), y;
1214
+ }, on: r.on, off: r.off, open: st, openInstance: it, openAsync: We, enqueue: K, enqueueAsync: de, update: k, setOptions: k, preload: ce, setFullscreen: ne, toggleFullscreen: re, clearQueue: Be, close: Qe, dismiss: ct, confirm: Ne, setLoading: lt, clearError: Ze }, Ee = (c, y) => Object.keys(c).length === Object.keys(y).length && Object.keys(c).every((R) => Object.is(c[R], y[R]));
1215
+ function Te() {
1216
+ const c = i ? O(i) : null, y = u.getSnapshot();
1217
+ i && !Ee(c, i.runtime.stores.layout.getSnapshot()) && i.runtime.stores.layout.publish(c);
1218
+ const R = i ? y.active === i ? y.options : c : null, w = { isOpen: !!i, activeName: i?.name ?? null, isFullscreen: !!c?.fullscreen, queueSize: x, error: g }, H = { active: i, options: R, exiting: Z, error: g, translate: n.translate }, W = f.getSnapshot();
1219
+ Ee(w, W) || f.publish(w), Ee(H, y) || u.publish(H), W.queueSize !== w.queueSize && r.emit("queueChange", { previous: W.queueSize, current: w.queueSize });
954
1220
  }
955
- const je = (a) => ({
956
- registerLoading: (f) => {
957
- s.current?.id === a && (Y.current = f);
1221
+ const _e = (c) => ({
1222
+ registerLoading: (y) => {
1223
+ s.current?.id === c && (q.current = y);
958
1224
  },
959
- registerDirtyGuard: (f, S) => s.current?.id === a ? ne(f, S) : () => {
1225
+ registerDirtyGuard: (y, R) => s.current?.id === c ? F(y, R) : () => {
960
1226
  },
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 });
1227
+ getProtectedCacheKeys: () => s.current?.id === c ? new Set([...N.current].filter(([, y]) => [...y].some((R) => R.dirty)).map(([y]) => y)) : /* @__PURE__ */ new Set(),
1228
+ canNavigate: (y, R) => s.current?.id === c ? $(y, R) : Promise.resolve(!1),
1229
+ onRequestClose: (...y) => s.current?.id === c ? G(...y) : Promise.resolve(!1),
1230
+ onOpened: (y) => {
1231
+ if (s.current?.id !== c) return;
1232
+ const R = O(s.current), w = (H, W) => {
1233
+ s.current?.id === c && oe(H, { phase: W });
967
1234
  };
968
- for (const B of ["onOpen", "onOpened"])
1235
+ for (const H of ["onOpen", "onOpened"])
969
1236
  try {
970
- Promise.resolve(S[B]?.(f)).catch((N) => v(N, B));
971
- } catch (N) {
972
- v(N, B);
1237
+ Promise.resolve(R[H]?.(y)).catch((W) => w(W, H));
1238
+ } catch (W) {
1239
+ w(W, H);
973
1240
  }
974
1241
  }
975
1242
  });
976
- return { commands: Fe, statusStore: p, hostStore: h, bindInstance: je, configure: (a) => {
977
- t = a, X.current = a.confirmDiscard, le.current = a.onError, Me();
1243
+ return { commands: De, statusStore: f, hostStore: u, bindInstance: _e, configure: (c) => {
1244
+ n = c, C.current = c.confirmDiscard, V.current = c.onError, Te();
978
1245
  }, mount: () => {
979
- z.current = !0;
1246
+ B.current = !0;
980
1247
  }, 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 });
1248
+ B.current = !1;
1249
+ for (const c of Ge) c.dispose();
1250
+ r.clear(), A.current += 1, te.current.cancelAll(), s.current?.runtime.destroy(), s.current = null, q.current = null, D.current = null, L.current = !1;
1251
+ for (const c of v.current.keys()) J(c, { status: "dismissed", reason: "unmount" });
1252
+ v.current.clear(), N.current.clear(), i = null, Z = !1, g = null;
1253
+ for (const c of o)
1254
+ c.resolveId?.(null), c.resolveResult?.({ status: "dismissed", reason: "unmount" });
1255
+ o.clear(), Be("unmount"), Te();
1256
+ }, reportError: oe };
1257
+ }
1258
+ const Jn = Se.memo(function({ Screen: t, route: n, navigation: r }) {
1259
+ return /* @__PURE__ */ p(t, { route: n, navigation: r });
1260
+ }), er = Se.memo(function({ store: t, layoutStore: n, route: r, ...o }) {
1261
+ const a = () => t.getSnapshot()[r.key], l = Oe(t.subscribe, a, a), f = Pe(n, Qt, He);
1262
+ return /* @__PURE__ */ p(en, { ...o, options: f, route: r, override: l });
1263
+ }), tr = Se.memo(function({ store: t, translate: n }) {
1264
+ const r = Oe(t.subscribe, t.getSnapshot, t.getSnapshot);
1265
+ return /* @__PURE__ */ p(tn, { loading: r, translate: n });
1266
+ }), nr = Se.memo(function({ store: t, dismiss: n }) {
1267
+ const r = Oe(t.subscribe, t.getSnapshot, t.getSnapshot);
1268
+ return /* @__PURE__ */ p(nn, { items: r, dismiss: n });
1000
1269
  });
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);
1270
+ function rr({ runtime: e, config: t, initialScreen: n, params: r, translate: o, onRequestClose: a, onOpened: l, registerLoading: f, notifyError: u, error: i, clearError: d, registerDirtyGuard: g, exiting: b = !1 }) {
1271
+ const x = Pe(e.stores.layout, En, He), h = n ?? t.initialRoute ?? Object.keys(t.screens)[0], [s, v] = xe(() => e.stores.navigation.getSnapshot().currentRoute), I = P(s);
1272
+ I.current = s;
1273
+ const z = t.screens[h], T = e.alive, E = P(null), { navigation: D, footer: L, loading: A, toast: q } = e.refs, N = P("single"), { loadingApi: Z, setLoading: ue } = on(A, T, N, e), { toast: C, dismissToast: F } = rn(q, T, e), $ = _((k, ce) => {
1274
+ const ne = L.current, re = ne.getSnapshot();
1275
+ if (ce === null) {
1276
+ if (re[k] !== void 0) {
1277
+ const Be = { ...re };
1278
+ delete Be[k], ne.publish(Be);
1010
1279
  }
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: _,
1280
+ } else re[k] !== ce && ne.publish({ ...re, [k]: ce });
1281
+ }, []), X = _((k = "api", ce) => !T.current || A.current.getSnapshot().visible && e.stores.layout.getSnapshot().lockCloseWhileLoading !== !1 ? Promise.resolve(!1) : a(k, ce), [a, e]), B = _(() => Promise.resolve(!1), []), te = Q(() => ({
1282
+ navigate: B,
1014
1283
  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,
1284
+ replace: B,
1285
+ reset: B,
1286
+ clearCache: B,
1287
+ goBack: B,
1288
+ push: B,
1289
+ pop: B,
1290
+ popToTop: B,
1291
+ popTo: B,
1292
+ setParams: (k) => T.current ? (v((ce) => ({ ...ce, params: { ...ce.params, ...typeof k == "function" ? k(ce.params) : k } })), !0) : !1,
1293
+ setOptions: (k) => T.current ? (v((ce) => ({ ...ce, options: { ...ce.options, ...k } })), !0) : !1,
1294
+ close: X,
1295
+ setLoading: ue,
1024
1296
  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);
1297
+ stack: [s],
1298
+ currentRoute: s
1299
+ }), [X, s, ue, B]), V = P(te);
1300
+ V.current = te;
1301
+ const oe = Q(() => ({
1302
+ clearCache: (...k) => V.current.clearCache(...k),
1303
+ navigate: (...k) => V.current.navigate(...k),
1304
+ navigateAsync: (...k) => V.current.navigateAsync(...k),
1305
+ replace: (...k) => V.current.replace(...k),
1306
+ reset: (...k) => V.current.reset(...k),
1307
+ goBack: (...k) => V.current.goBack(...k),
1308
+ push: (...k) => V.current.push(...k),
1309
+ pop: (...k) => V.current.pop(...k),
1310
+ popToTop: (...k) => V.current.popToTop(...k),
1311
+ popTo: (...k) => V.current.popTo(...k),
1312
+ setParams: (...k) => V.current.setParams(...k),
1313
+ setOptions: (...k) => V.current.setOptions(...k),
1314
+ close: (...k) => V.current.close(...k),
1315
+ setLoading: (...k) => V.current.setLoading(...k)
1316
+ }), []);
1317
+ Ae(() => e.registerNavigation(oe), [e, oe]);
1318
+ const J = Q(() => ({
1319
+ setLoading: (k, ce) => Z.setScreenLoading("single", k, ce),
1320
+ showLoading: (k) => Z.begin("single", k),
1321
+ hideLoading: (k) => Z.end("single", k)
1322
+ }), [Z]), O = Q(() => ({ isFocused: !0, resultEvent: null, routeKey: "single", setFooter: $ }), [$]), G = Q(() => ({ routeKey: "single", registerDirtyGuard: g }), [g]);
1323
+ U(() => {
1324
+ D.current.publish({ canGoBack: !1, stack: [s], currentRoute: s });
1325
+ }, [s]);
1326
+ const ke = P(!1);
1327
+ U(() => (f?.({ setLoading: ue }), ke.current || (ke.current = !0, l?.({ route: I.current, stack: [I.current] })), () => {
1328
+ f?.(null);
1052
1329
  }), []);
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: "×" })
1330
+ const Ce = Q(() => ({ ...z, ...s.options }), [z, s.options]), K = z.component, de = e.refs.header;
1331
+ return /* @__PURE__ */ p(yt.Provider, { value: de.current, children: /* @__PURE__ */ p(Tt.Provider, { value: C, children: /* @__PURE__ */ p(Vt.Provider, { value: q.current, children: /* @__PURE__ */ p(Ut.Provider, { value: L.current, children: /* @__PURE__ */ p(_t.Provider, { value: te, children: /* @__PURE__ */ p(vt.Provider, { value: oe, children: /* @__PURE__ */ p(bt.Provider, { value: D.current, children: /* @__PURE__ */ p(Ue.Provider, { value: Z, children: /* @__PURE__ */ be(Xt, { store: e.stores.layout, screenOptions: Ce.modalOptions, dialogRef: E, requestClose: X, exiting: b, children: [
1332
+ /* @__PURE__ */ p(Jt, { store: e.stores.layout, screen: Ce, route: s, navigation: te, requestClose: X, translate: o, canGoBack: !1 }),
1333
+ /* @__PURE__ */ p("main", { className: "pmn-main", children: /* @__PURE__ */ p(Ve.Provider, { value: s, children: /* @__PURE__ */ p(Pt.Provider, { value: G, children: /* @__PURE__ */ p(ot.Provider, { value: O, children: /* @__PURE__ */ p(Ue.Provider, { value: J, children: /* @__PURE__ */ p(wt.Provider, { value: A.current, children: /* @__PURE__ */ p("div", { className: `pmn-body ${x.bodyClassName ?? ""}`, "data-modal-route-key": "single", tabIndex: -1, children: /* @__PURE__ */ p(Nt, { route: s, onError: u, children: /* @__PURE__ */ p(Wt, { fallback: x.lazyFallback ?? /* @__PURE__ */ p("div", { className: "pmn-lazy-loading", role: "status", "aria-live": "polite", children: "加载中..." }), children: /* @__PURE__ */ p(Jn, { Screen: K, route: s, navigation: te }) }) }) }) }) }) }) }) }) }),
1334
+ /* @__PURE__ */ p(er, { store: L.current, route: s, screen: Ce, layoutStore: e.stores.layout, navigation: te, requestClose: X, translate: o, onError: u, loadingApi: Z }),
1335
+ /* @__PURE__ */ p(tr, { store: A.current, translate: o }),
1336
+ /* @__PURE__ */ p(nr, { store: q.current, dismiss: F }),
1337
+ i && /* @__PURE__ */ be("div", { className: "pmn-error", role: "alert", children: [
1338
+ /* @__PURE__ */ p("span", { children: i.message || String(i) }),
1339
+ /* @__PURE__ */ p("button", { type: "button", onClick: d, children: "×" })
1063
1340
  ] })
1064
1341
  ] }) }) }) }) }) }) }) }) });
1065
1342
  }
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(() => {
1343
+ const or = rt(Hn), ar = rt(rr), sr = rt(function({ manager: t }) {
1344
+ const { active: n, options: r, exiting: o, error: a, translate: l } = Oe(t.hostStore.subscribe, t.hostStore.getSnapshot, t.hostStore.getSnapshot), f = n?.id, u = n?.runtime.bindings, i = Q(() => (g, b) => {
1345
+ n?.runtime.alive.current && t.hostStore.getSnapshot().active?.id === f && t.reportError(g, b);
1346
+ }, [t, n, f]);
1347
+ if (!n) return null;
1348
+ const d = n.config.singlePage || Object.keys(n.config.screens ?? {}).length === 1 ? ar : or;
1349
+ return /* @__PURE__ */ p(at.Provider, { value: n.runtime, children: /* @__PURE__ */ p(d, { runtime: n.runtime, config: n.config, initialScreen: n.screen, params: n.params, options: r, translate: l, notifyError: i, error: a, clearError: t.commands.clearError, exiting: o, ...u }, f) });
1350
+ }), ir = ".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%}", Kt = "react-modal-navigation-styles", Ot = /* @__PURE__ */ new WeakMap();
1351
+ function cr() {
1352
+ mn(() => {
1076
1353
  if (typeof document > "u") return;
1077
1354
  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);
1355
+ let t = Ot.get(e);
1356
+ if (!t) {
1357
+ let n = e.getElementById(Kt);
1358
+ const r = !n;
1359
+ n || (n = e.createElement("style"), n.id = Kt, n.setAttribute("data-react-modal-navigation", ""), n.textContent = ir, e.head.appendChild(n)), t = { element: n, owned: r, count: 0 }, Ot.set(e, t);
1083
1360
  }
1084
- return n.count += 1, () => {
1085
- n.count -= 1, n.count === 0 && (n.owned && n.element.remove(), hn.delete(e));
1361
+ return t.count += 1, () => {
1362
+ t.count -= 1, t.count === 0 && (t.owned && t.element.remove(), Ot.delete(e));
1086
1363
  };
1087
1364
  }, []);
1088
1365
  }
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: [
1366
+ const lr = Object.freeze({}), ur = (e) => ({ "modal.loading": "加载中...", "modal.processing": "处理中...", "modal.back": "返回", "modal.close": "关闭", "modal.cancel": "取消", "modal.done": "完成" })[e] ?? e;
1367
+ function Tr({ children: e, registry: t, defaultOptions: n = lr, backgroundColor: r, theme: o, translate: a = ur, onError: l, confirmDiscard: f }) {
1368
+ cr();
1369
+ const u = { registry: t, defaultOptions: n, backgroundColor: r, theme: o, translate: a, onError: l, confirmDiscard: f }, [i] = xe(() => Xn(u, Gn));
1370
+ return Ae(() => (i.mount(), i.destroy), [i]), Ae(() => {
1371
+ i.configure(u);
1372
+ }, [i, t, n, r, o, a, l, f]), /* @__PURE__ */ p(Lt.Provider, { value: i.commands, children: /* @__PURE__ */ p(zt.Provider, { value: i.statusStore, children: /* @__PURE__ */ be(Gt.Provider, { value: i.commands, children: [
1096
1373
  e,
1097
- /* @__PURE__ */ i(Dt, { manager: d })
1374
+ /* @__PURE__ */ p(sr, { manager: i })
1098
1375
  ] }) }) });
1099
1376
  }
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);
1377
+ const dr = Object.freeze({ canGoBack: !1, stack: [], currentRoute: null }), Ht = () => () => {
1378
+ }, ft = () => dr;
1379
+ function Lr({ subscribe: e = !0 } = {}) {
1380
+ const t = ee(Gt), n = ee(zt), r = Oe(e && n?.subscribe || Ht, e && n?.getSnapshot || ft, e && n?.getSnapshot || ft), o = Q(() => t ? e ? { ...t, ...r } : t : null, [t, r, e]), a = ee(vt), l = ee(bt), f = Oe(e && l?.subscribe || Ht, e && l?.getSnapshot || ft, e && l?.getSnapshot || ft);
1104
1381
  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;
1382
+ const u = Q(() => {
1383
+ const i = () => {
1384
+ if (!a) throw new Error("[react-modal-navigation] navigation requires an active modal screen; use modal.open() outside a modal");
1385
+ return a;
1109
1386
  };
1110
1387
  return {
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 } : {}
1388
+ clearCache: (...d) => i().clearCache(...d),
1389
+ navigateAsync: (...d) => i().navigateAsync(...d),
1390
+ navigate: (...d) => i().navigate(...d),
1391
+ push: (...d) => i().push(...d),
1392
+ pop: (...d) => i().pop(...d),
1393
+ popTo: (...d) => i().popTo(...d),
1394
+ popToTop: (...d) => i().popToTop(...d),
1395
+ replace: (...d) => i().replace(...d),
1396
+ reset: (...d) => i().reset(...d),
1397
+ setParams: (...d) => i().setParams(...d),
1398
+ setOptions: (...d) => i().setOptions(...d),
1399
+ goBack: (...d) => i().goBack(...d),
1400
+ close: (...d) => i().close(...d),
1401
+ setLoading: (...d) => i().setLoading(...d),
1402
+ ...e ? { canGoBack: f.canGoBack, stack: f.stack, currentRoute: f.currentRoute } : {}
1121
1403
  };
1122
- }, [g, h, e]);
1123
- return F(() => ({ ...o, modal: o, navigation: l }), [o, l]);
1404
+ }, [a, f, e]);
1405
+ return Q(() => ({ ...o, modal: o, navigation: u }), [o, u]);
1124
1406
  }
1125
- function Ut() {
1126
- const e = V(rn);
1407
+ function cn() {
1408
+ const e = ee(vt);
1127
1409
  if (!e) throw new Error("useModalNavigationCommands requires an active modal screen");
1128
1410
  return e;
1129
1411
  }
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);
1412
+ function mr(e, t) {
1413
+ const n = ee(bt);
1414
+ if (!n) throw new Error("useModalNavigationState requires an active modal screen");
1415
+ return Pe(n, e, t);
1134
1416
  }
1135
- function lr() {
1136
- const e = Ut(), n = Vt();
1137
- return F(() => ({ ...e, ...n }), [e, n]);
1417
+ function zr() {
1418
+ const e = cn(), t = mr();
1419
+ return Q(() => ({ ...e, ...t }), [e, t]);
1138
1420
  }
1139
- function Un() {
1140
- const e = V(Ve);
1421
+ function jt() {
1422
+ const e = ee(ot);
1141
1423
  if (!e) throw new Error("useIsFocused must be called inside a modal screen");
1142
1424
  return e.isFocused;
1143
1425
  }
1144
- function ur(e) {
1145
- const n = Un();
1146
- H(() => {
1147
- if (n)
1426
+ function Ar(e) {
1427
+ const t = jt();
1428
+ U(() => {
1429
+ if (t)
1148
1430
  return e();
1149
- }, [n, e]);
1150
- }
1151
- function dr(e) {
1152
- const n = V(Ve);
1153
- if (!n) throw new Error("useNavigationResult requires an active modal screen");
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));
1159
- }, [n.isFocused, n.resultEvent]);
1160
- }
1161
- function mr(e = {}) {
1162
- const n = V(Ve);
1163
- if (!n) throw new Error("[react-modal-navigation] useModalFooter requires an active modal screen");
1164
- const { setFooter: t, routeKey: r } = n, o = k(e);
1431
+ }, [t, e]);
1432
+ }
1433
+ function Nr(e) {
1434
+ const t = ee(ot);
1435
+ if (!t) throw new Error("useNavigationResult requires an active modal screen");
1436
+ const n = P(e), r = P(null);
1437
+ U(() => {
1438
+ n.current = e;
1439
+ }, [e]), U(() => {
1440
+ !t.isFocused || !t.resultEvent || r.current !== t.resultEvent.id && (r.current = t.resultEvent.id, n.current(t.resultEvent.data));
1441
+ }, [t.isFocused, t.resultEvent]);
1442
+ }
1443
+ function jr(e = {}) {
1444
+ const t = ee(ot);
1445
+ if (!t) throw new Error("[react-modal-navigation] useModalFooter requires an active modal screen");
1446
+ const { setFooter: n, routeKey: r } = t, o = P(e);
1165
1447
  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)
1448
+ const a = Q(() => (...q) => o.current.done?.(...q), []), l = Q(() => (...q) => (o.current.cancel ?? o.current.cancle)?.(...q), []), f = Q(() => (...q) => o.current.renderFooter?.(...q), []), u = typeof e.done == "function", i = typeof (e.cancel ?? e.cancle) == "function", d = typeof e.renderFooter == "function", { showFooter: g, showFooterBorder: b, doneDisabled: x, doneText: h, cancelText: s, loadingText: v, footerClassName: I } = e, z = P({ source: null, normalized: void 0 }), T = Array.isArray(e.actions) ? e.actions : null, E = z.current.source;
1449
+ T === E || T && E && T.length === E.length && T.every((q, N) => {
1450
+ const Z = E[N];
1451
+ return [.../* @__PURE__ */ new Set([...Object.keys(q), ...Object.keys(Z)])].every((C) => C === "onClick" || Object.is(q[C], Z[C]));
1452
+ }) || (z.current = {
1453
+ source: T?.map((q) => ({ ...q })) ?? null,
1454
+ normalized: T?.map((q, N) => ({
1455
+ ...q,
1456
+ onClick: (...Z) => (o.current.actions?.find((C) => C.key === q.key) ?? o.current.actions?.[N])?.onClick?.(...Z)
1175
1457
  }))
1176
1458
  });
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,
1459
+ const L = z.current.normalized, A = Q(() => ({
1460
+ showFooter: g,
1461
+ showFooterBorder: b,
1462
+ doneDisabled: x,
1463
+ doneText: h,
1464
+ cancelText: s,
1465
+ loadingText: v,
1184
1466
  footerClassName: I,
1185
1467
  ...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]);
1193
- }
1194
- const Yt = (e) => e.visible;
1195
- function Qt() {
1196
- const e = V(De), n = V(an);
1197
- if (!e || !n) throw new Error("[react-modal-navigation] useModalLoading requires an active modal screen");
1198
- const t = ke(n, Yt);
1199
- return F(() => ({ ...e, isLoading: t }), [e, t]);
1200
- }
1201
- function pr() {
1202
- const e = V(De);
1468
+ ...u ? { done: a } : {},
1469
+ ...i ? { cancel: l } : {},
1470
+ ...d ? { renderFooter: f } : {}
1471
+ }), [g, b, x, h, s, v, I, L, u, i, d, a, l, f]);
1472
+ U(() => {
1473
+ n(r, A);
1474
+ }, [r, n, A]), U(() => () => n(r, null), [r, n]);
1475
+ }
1476
+ const pr = (e) => e.visible;
1477
+ function Br() {
1478
+ const e = ee(Ue), t = ee(wt);
1479
+ if (!e || !t) throw new Error("[react-modal-navigation] useModalLoading requires an active modal screen");
1480
+ const n = Pe(t, pr);
1481
+ return Q(() => ({ ...e, isLoading: n }), [e, n]);
1482
+ }
1483
+ function fr() {
1484
+ const e = ee(Ue);
1203
1485
  if (!e) throw new Error("[react-modal-navigation] useModalLoadingCommands requires an active modal screen");
1204
1486
  return e;
1205
1487
  }
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);
1488
+ function qr(e, t) {
1489
+ const n = ee(wt);
1490
+ if (!n) throw new Error("[react-modal-navigation] useModalLoadingState requires an active modal screen");
1491
+ return Pe(n, e, t);
1210
1492
  }
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);
1493
+ function Fr() {
1494
+ const e = ee(at), t = ee(Ve), n = fr(), r = jt(), o = P(!0), a = P(null), [l, f] = xe(!1), [u, i] = xe(null), d = _((x) => {
1495
+ if (!x || a.current !== x) return !1;
1496
+ a.current = null, x.unregister?.(), o.current && f(!1);
1220
1497
  try {
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);
1226
- try {
1227
- await x.onError?.(b);
1228
- } catch (s) {
1229
- console.error("[react-modal-navigation] onError failed", s);
1230
- }
1498
+ x.controller.abort();
1499
+ } finally {
1500
+ x.release();
1501
+ }
1502
+ return !0;
1503
+ }, []), g = _(() => d(a.current), [d]);
1504
+ return U(() => (o.current = !0, () => {
1505
+ o.current = !1, g();
1506
+ }), [g]), { run: _(async (x, h = {}) => {
1507
+ if (!o.current || e && !e.alive.current) return { status: "cancelled" };
1508
+ if (a.current) return { status: "busy" };
1509
+ if (typeof x != "function") throw new TypeError("[react-modal-navigation] run requires a function");
1510
+ const s = new AbortController();
1511
+ let v, I = !1;
1512
+ const z = { controller: s, release: () => {
1513
+ I || (I = !0, v != null && n.hideLoading(v));
1514
+ } };
1515
+ a.current = z, z.cancel = () => d(z), z.unregister = e?.tasks.register(t?.key, z);
1516
+ const T = () => o.current && a.current === z && !s.signal.aborted;
1517
+ try {
1518
+ if (!T()) return { status: "cancelled" };
1519
+ if (f(!0), i(null), v = n.showLoading(h.loadingText), !T())
1520
+ return v != null && I && n.hideLoading(v), { status: "cancelled" };
1521
+ const E = await x({ signal: s.signal });
1522
+ return T() ? (await h.onSuccess?.(E), T() ? { status: "success", value: E } : { status: "cancelled" }) : { status: "cancelled" };
1523
+ } catch (E) {
1524
+ if (!T()) return { status: "cancelled" };
1525
+ i(E);
1526
+ try {
1527
+ await h.onError?.(E);
1528
+ } catch (D) {
1529
+ console.error("[react-modal-navigation] onError failed", D);
1231
1530
  }
1232
- if (x.throwOnError) throw b;
1233
- return { status: "error", error: b };
1531
+ if (!T()) return { status: "cancelled" };
1532
+ if (h.throwOnError) throw E;
1533
+ return { status: "error", error: E };
1234
1534
  } finally {
1235
- w != null && l.current.hideLoading(w), r.current = !1, t.current && g(!1);
1535
+ z.unregister?.(), z.release(), a.current === z && (a.current = null, o.current && f(!1));
1236
1536
  }
1237
- }, []), pending: o, error: p, clearError: () => h(null), isFocused: n };
1238
- }
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, {
1537
+ }, [n, e, t?.key, d]), cancel: g, pending: l, error: u, clearError: () => i(null), isFocused: r };
1538
+ }
1539
+ function hr(e, t = {}) {
1540
+ const n = ee(Pt);
1541
+ if (!n) throw new Error("[react-modal-navigation] useModalUnsavedChanges must be used inside a modal screen");
1542
+ const r = P({ dirty: e, ...t });
1543
+ r.current = { dirty: e, ...t };
1544
+ const { routeKey: o, registerDirtyGuard: a } = n;
1545
+ U(() => a(o, {
1246
1546
  get dirty() {
1247
1547
  return !!r.current.dirty;
1248
1548
  },
@@ -1252,75 +1552,238 @@ function hr(e, n = {}) {
1252
1552
  get onBeforeDiscard() {
1253
1553
  return r.current.onBeforeDiscard;
1254
1554
  }
1255
- }), [o, g]);
1555
+ }), [o, a]);
1256
1556
  }
1257
- const yr = () => {
1258
- const e = V(vn);
1557
+ const $r = () => {
1558
+ const e = ee(Tt);
1259
1559
  if (!e) throw new Error("[react-modal-navigation] useToast requires an active modal");
1260
1560
  return e;
1261
1561
  };
1262
- function Zt() {
1263
- const e = V(sn);
1562
+ function gr() {
1563
+ const e = ee(Ve);
1264
1564
  if (!e) throw new Error("[react-modal-navigation] useModalRoute requires a modal screen");
1265
1565
  return e;
1266
1566
  }
1267
- function br() {
1268
- return Zt().params;
1567
+ function yr() {
1568
+ return gr().params;
1269
1569
  }
1270
- function Xt() {
1271
- const e = V(wn);
1570
+ function Bt() {
1571
+ const e = ee(Lt);
1272
1572
  if (!e) throw new Error("[react-modal-navigation] ModalProvider required");
1273
1573
  return e;
1274
1574
  }
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);
1575
+ const vr = (e) => e;
1576
+ function br(e = vr, t = Object.is) {
1577
+ const n = ee(zt);
1578
+ if (!n) throw new Error("[react-modal-navigation] ModalProvider required");
1579
+ return Pe(n, e, t);
1580
+ }
1581
+ const wr = (e) => e.isFullscreen;
1582
+ function Ir() {
1583
+ const { setFullscreen: e, toggleFullscreen: t } = Bt();
1584
+ return { isFullscreen: br(wr), setFullscreen: e, toggleFullscreen: t };
1585
+ }
1586
+ function Dr(e = {}) {
1587
+ const t = ee(yt), n = ee(Ve);
1588
+ if (!t || !n) throw new Error("[react-modal-navigation] useModalHeader requires a modal screen");
1589
+ const r = P(e);
1590
+ r.current = e, U(() => {
1591
+ t.set(n.key, r.current);
1592
+ }), U(() => () => t.set(n.key, null), [t, n.key]);
1593
+ }
1594
+ function Kr(e, t) {
1595
+ const n = ee(at);
1596
+ if (!n) throw new Error("[react-modal-navigation] useModalLayout requires an active modal");
1597
+ return Pe(n.stores.layout, e, t);
1598
+ }
1599
+ function Hr(e = {}) {
1600
+ const t = ee(at), n = ee(Ve), r = jt(), o = P(e);
1601
+ U(() => {
1602
+ o.current = e;
1603
+ }), U(() => (o.current.onMount?.(), () => o.current.onDestroy?.()), []), U(() => {
1604
+ if (r)
1605
+ return o.current.onFocus?.(), () => o.current.onBlur?.();
1606
+ }, [r]), U(() => t?.registerRemovalGuard(n?.key, (a) => o.current.onBeforeRemove?.(a)), [t, n?.key]);
1607
+ }
1608
+ function Wr({ values: e, initialValues: t, equals: n = Object.is, message: r, onBeforeDiscard: o }) {
1609
+ const [a, l] = xe(() => t), f = !n(a, e);
1610
+ hr(f, { message: r, onBeforeDiscard: o });
1611
+ const u = _((i = e) => l(() => i), [e]);
1612
+ return { dirty: f, markSaved: u };
1613
+ }
1614
+ const kr = (e, t) => e && t && Object.keys(e).length === Object.keys(t).length && Object.keys(e).every((n) => Object.hasOwn(t, n) && Object.is(e[n], t[n]));
1615
+ function xr(e, t) {
1616
+ let n, r, o, a = !1, l = !1, f = !1, u = 0, i = -1;
1617
+ const d = (h) => {
1618
+ try {
1619
+ a && n?.onError ? Promise.resolve(n.onError(h)).catch((s) => console.error(s)) : console.error(h);
1620
+ } catch (s) {
1621
+ console.error(s);
1622
+ }
1623
+ }, g = (h, ...s) => {
1624
+ if (a)
1625
+ try {
1626
+ Promise.resolve(n[h]?.(...s)).catch(d);
1627
+ } catch (v) {
1628
+ d(v);
1629
+ }
1630
+ }, b = () => {
1631
+ f = !0, l || x();
1632
+ };
1633
+ async function x() {
1634
+ l = !0;
1635
+ try {
1636
+ for (; f; ) {
1637
+ if (f = !1, !a) {
1638
+ r?.dispose();
1639
+ continue;
1640
+ }
1641
+ const h = n;
1642
+ if (!h) continue;
1643
+ const s = u;
1644
+ if (!h.open) {
1645
+ r?.isActive() && i !== s && (i = s, !await r.close() && u === s && g("onBlocked", "close"));
1646
+ continue;
1647
+ }
1648
+ if (!r?.isActive()) {
1649
+ if (i === s) continue;
1650
+ i = s;
1651
+ const v = await e.openInstance(
1652
+ { component: t, title: h.title },
1653
+ { children: h.children, title: h.title },
1654
+ h.options
1655
+ );
1656
+ if (r = v, o = h, !v.isActive()) {
1657
+ u === s && g("onBlocked", "open");
1658
+ continue;
1659
+ }
1660
+ if (v.result.then((I) => {
1661
+ r === v && (r = null, o = null, n.open && u === i && g("onOpenChange", !1, I), b());
1662
+ }).catch(d), !a) {
1663
+ v.dispose();
1664
+ continue;
1665
+ }
1666
+ if (!n.open) {
1667
+ f = !0;
1668
+ continue;
1669
+ }
1670
+ if (!await v.ready || !v.isActive()) continue;
1671
+ f = !0;
1672
+ continue;
1673
+ }
1674
+ i = s, !(!kr(o?.options, h.options) && !r.replaceOptions(h.options)) && ((!o || !Object.is(o.children, h.children) || !Object.is(o.title, h.title)) && !r.setParams({ children: h.children, title: h.title }) || (o = h));
1675
+ }
1676
+ } catch (h) {
1677
+ d(h);
1678
+ } finally {
1679
+ l = !1, f && b();
1680
+ }
1681
+ }
1682
+ return {
1683
+ mount() {
1684
+ a = !0;
1685
+ },
1686
+ update(h) {
1687
+ (!n || n.open !== h.open) && u++, n = h, b();
1688
+ },
1689
+ unmount() {
1690
+ a = !1, queueMicrotask(() => {
1691
+ a || (r?.dispose(), b());
1692
+ });
1693
+ }
1694
+ };
1695
+ }
1696
+ function Sr() {
1697
+ const { children: e, title: t } = yr(), n = cn();
1698
+ return Ae(() => {
1699
+ n.setOptions({ title: t });
1700
+ }, [n, t]), e;
1701
+ }
1702
+ function Gr({ open: e, onOpenChange: t, onBlocked: n, onError: r, children: o, title: a, ...l }) {
1703
+ const f = Bt(), u = Q(() => xr(f, Sr), [f]);
1704
+ return U(() => (u.mount(), u.unmount), [u]), U(() => {
1705
+ u.update({
1706
+ open: e,
1707
+ onOpenChange: t,
1708
+ onBlocked: n,
1709
+ onError: r,
1710
+ children: o,
1711
+ title: a,
1712
+ options: { ...l, instanceKey: void 0, duplicateStrategy: "allow" }
1713
+ });
1714
+ }), null;
1715
+ }
1716
+ function Cr({ inspector: e }) {
1717
+ const { active: t, queueSize: n, events: r } = Oe(e.subscribe, e.getSnapshot, e.getSnapshot);
1718
+ return /* @__PURE__ */ be("details", { style: { font: "12px monospace", padding: 12, border: "1px solid #888", borderRadius: 8 }, children: [
1719
+ /* @__PURE__ */ be("summary", { children: [
1720
+ "Modal DevTools · ",
1721
+ t?.name ?? "Idle"
1722
+ ] }),
1723
+ /* @__PURE__ */ be("p", { children: [
1724
+ "Queue: ",
1725
+ n,
1726
+ " · Loading: ",
1727
+ t?.loadingCount ?? 0,
1728
+ " · Tasks: ",
1729
+ t?.taskCount ?? 0
1730
+ ] }),
1731
+ /* @__PURE__ */ p("button", { type: "button", onClick: e.refresh, children: "Refresh" }),
1732
+ " ",
1733
+ /* @__PURE__ */ p("button", { type: "button", onClick: e.clear, children: "Clear events" }),
1734
+ /* @__PURE__ */ p("ol", { children: t?.routes.map((o) => /* @__PURE__ */ be("li", { children: [
1735
+ o.name,
1736
+ o.key === t.focusedKey ? " (focused)" : ""
1737
+ ] }, o.key)) }),
1738
+ /* @__PURE__ */ p("ol", { style: { maxHeight: 240, overflow: "auto" }, children: r.map((o) => /* @__PURE__ */ be("li", { children: [
1739
+ o.sequence,
1740
+ " · ",
1741
+ o.type,
1742
+ " ",
1743
+ o.id ?? ""
1744
+ ] }, o.sequence)) })
1745
+ ] });
1746
+ }
1747
+ function _r({ enabled: e = !1, limit: t = 100 }) {
1748
+ const n = Bt(), [r, o] = xe(null);
1749
+ return U(() => {
1750
+ if (!e) {
1751
+ o(null);
1752
+ return;
1753
+ }
1754
+ const a = n.inspect({ limit: t });
1755
+ return o(a), a.dispose;
1756
+ }, [n, e, t]), e && r ? /* @__PURE__ */ p(Cr, { inspector: r }) : null;
1298
1757
  }
1299
1758
  export {
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,
1759
+ Gr as Modal,
1760
+ _r as ModalDevTools,
1761
+ Hn as ModalNavigator,
1762
+ Tr as ModalProvider,
1763
+ Or as defineModal,
1764
+ Pr as lazyModal,
1765
+ He as shallowEqual,
1766
+ Ar as useFocusEffect,
1767
+ jt as useIsFocused,
1768
+ Lr as useModal,
1769
+ Bt as useModalCommands,
1770
+ jr as useModalFooter,
1771
+ Wr as useModalFormGuard,
1772
+ Ir as useModalFullscreen,
1773
+ Dr as useModalHeader,
1774
+ Kr as useModalLayout,
1775
+ Hr as useModalLifecycle,
1776
+ Br as useModalLoading,
1777
+ fr as useModalLoadingCommands,
1778
+ qr as useModalLoadingState,
1779
+ zr as useModalNavigation,
1780
+ cn as useModalNavigationCommands,
1781
+ mr as useModalNavigationState,
1782
+ yr as useModalParams,
1783
+ gr as useModalRoute,
1784
+ br as useModalStatus,
1785
+ Fr as useModalTask,
1323
1786
  hr as useModalUnsavedChanges,
1324
- dr as useNavigationResult,
1325
- yr as useToast
1787
+ Nr as useNavigationResult,
1788
+ $r as useToast
1326
1789
  };