sanity 3.94.1 → 3.94.2-next.1.a8381d7633

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.
Files changed (113) hide show
  1. package/lib/_chunks-cjs/version.js +1 -1
  2. package/lib/_chunks-es/version.mjs +1 -1
  3. package/package.json +25 -25
  4. package/dist/BehaviorSubject-CU-WJrzA.mjs +0 -30
  5. package/dist/BehaviorSubject-CU-WJrzA.mjs.map +0 -1
  6. package/dist/BroadcastDisplayedDocument-BSV9T3BU.mjs +0 -20
  7. package/dist/BroadcastDisplayedDocument-BSV9T3BU.mjs.map +0 -1
  8. package/dist/DisplayedDocumentBroadcaster-DZ65n35Q.mjs +0 -62
  9. package/dist/DisplayedDocumentBroadcaster-DZ65n35Q.mjs.map +0 -1
  10. package/dist/LiveQueries-Crz53eU5.mjs +0 -407
  11. package/dist/LiveQueries-Crz53eU5.mjs.map +0 -1
  12. package/dist/Observable-CCQtH8Gg.mjs +0 -546
  13. package/dist/Observable-CCQtH8Gg.mjs.map +0 -1
  14. package/dist/PostMessageDocuments-BjgsJxz4.mjs +0 -72
  15. package/dist/PostMessageDocuments-BjgsJxz4.mjs.map +0 -1
  16. package/dist/PostMessagePerspective-pucY-E6a.mjs +0 -22
  17. package/dist/PostMessagePerspective-pucY-E6a.mjs.map +0 -1
  18. package/dist/PostMessagePreviewSnapshots-CRQgRg4_.mjs +0 -71
  19. package/dist/PostMessagePreviewSnapshots-CRQgRg4_.mjs.map +0 -1
  20. package/dist/PostMessageRefreshMutations-D944RbO3.mjs +0 -66
  21. package/dist/PostMessageRefreshMutations-D944RbO3.mjs.map +0 -1
  22. package/dist/PostMessageSchema-3eOtr1bs.mjs +0 -516
  23. package/dist/PostMessageSchema-3eOtr1bs.mjs.map +0 -1
  24. package/dist/PostMessageTelemetry-DMTQDJeN.mjs +0 -20
  25. package/dist/PostMessageTelemetry-DMTQDJeN.mjs.map +0 -1
  26. package/dist/PresentationToolGrantsCheck-B0q4AQ3b.mjs +0 -3999
  27. package/dist/PresentationToolGrantsCheck-B0q4AQ3b.mjs.map +0 -1
  28. package/dist/QRCodeSVG-hyTW2xeN.mjs +0 -648
  29. package/dist/QRCodeSVG-hyTW2xeN.mjs.map +0 -1
  30. package/dist/Refractor-Zss2QEe8.mjs +0 -2568
  31. package/dist/Refractor-Zss2QEe8.mjs.map +0 -1
  32. package/dist/SourceContext-QxJD1Wrm.mjs +0 -111
  33. package/dist/SourceContext-QxJD1Wrm.mjs.map +0 -1
  34. package/dist/StructureToolProvider-B-7cwz7l.mjs +0 -2287
  35. package/dist/StructureToolProvider-B-7cwz7l.mjs.map +0 -1
  36. package/dist/ViteDevServerStopped-CgIEqy9p.mjs +0 -57
  37. package/dist/ViteDevServerStopped-CgIEqy9p.mjs.map +0 -1
  38. package/dist/_createContext.mjs +0 -38
  39. package/dist/_createContext.mjs.map +0 -1
  40. package/dist/_singletons.mjs +0 -216
  41. package/dist/_singletons.mjs.map +0 -1
  42. package/dist/browser-B0Q9qZJS.mjs +0 -478
  43. package/dist/browser-B0Q9qZJS.mjs.map +0 -1
  44. package/dist/browser-DmX5VEcE.mjs +0 -324
  45. package/dist/browser-DmX5VEcE.mjs.map +0 -1
  46. package/dist/desk.mjs +0 -53
  47. package/dist/desk.mjs.map +0 -1
  48. package/dist/first-Cz545eV-.mjs +0 -42
  49. package/dist/first-Cz545eV-.mjs.map +0 -1
  50. package/dist/index-B2GCDfau.mjs +0 -96
  51. package/dist/index-B2GCDfau.mjs.map +0 -1
  52. package/dist/index-BRIelBPK.mjs +0 -6946
  53. package/dist/index-BRIelBPK.mjs.map +0 -1
  54. package/dist/index-BUB137yJ.mjs +0 -144
  55. package/dist/index-BUB137yJ.mjs.map +0 -1
  56. package/dist/index-C3PGPrdL.mjs +0 -1192
  57. package/dist/index-C3PGPrdL.mjs.map +0 -1
  58. package/dist/index-C9NvTy6s.mjs +0 -319
  59. package/dist/index-C9NvTy6s.mjs.map +0 -1
  60. package/dist/index-DCkQlgdi.mjs +0 -4001
  61. package/dist/index-DCkQlgdi.mjs.map +0 -1
  62. package/dist/index-DG-3plB0.mjs +0 -71
  63. package/dist/index-DG-3plB0.mjs.map +0 -1
  64. package/dist/index-RoxwhtVB.mjs +0 -5600
  65. package/dist/index-RoxwhtVB.mjs.map +0 -1
  66. package/dist/index-iMZR29eF.mjs +0 -756
  67. package/dist/index-iMZR29eF.mjs.map +0 -1
  68. package/dist/index-wVXq9rWS.mjs +0 -244
  69. package/dist/index-wVXq9rWS.mjs.map +0 -1
  70. package/dist/index.mjs +0 -137385
  71. package/dist/index.mjs.map +0 -1
  72. package/dist/lodash-Vz5dH_Dm.mjs +0 -3679
  73. package/dist/lodash-Vz5dH_Dm.mjs.map +0 -1
  74. package/dist/pane-Bm_57XKB.mjs +0 -5
  75. package/dist/pane-Bm_57XKB.mjs.map +0 -1
  76. package/dist/pane-Dopl4BjD.mjs +0 -5
  77. package/dist/pane-Dopl4BjD.mjs.map +0 -1
  78. package/dist/presentation-DsIky7Cj.mjs +0 -556
  79. package/dist/presentation-DsIky7Cj.mjs.map +0 -1
  80. package/dist/presentation.mjs +0 -10
  81. package/dist/presentation.mjs.map +0 -1
  82. package/dist/publishReplay-PuJoYJpp.mjs +0 -92
  83. package/dist/publishReplay-PuJoYJpp.mjs.map +0 -1
  84. package/dist/refractor-Bg1S3YDK.mjs +0 -26
  85. package/dist/refractor-Bg1S3YDK.mjs.map +0 -1
  86. package/dist/resources-BQsCEzu1.mjs +0 -60
  87. package/dist/resources-BQsCEzu1.mjs.map +0 -1
  88. package/dist/resources-BahMtJuO.mjs +0 -177
  89. package/dist/resources-BahMtJuO.mjs.map +0 -1
  90. package/dist/resources-CjkBN4z6.mjs +0 -126
  91. package/dist/resources-CjkBN4z6.mjs.map +0 -1
  92. package/dist/resources-Dc-6ZcPg.mjs +0 -157
  93. package/dist/resources-Dc-6ZcPg.mjs.map +0 -1
  94. package/dist/resources-DqxSuDsr.mjs +0 -37
  95. package/dist/resources-DqxSuDsr.mjs.map +0 -1
  96. package/dist/resources-_gTjFWLH.mjs +0 -517
  97. package/dist/resources-_gTjFWLH.mjs.map +0 -1
  98. package/dist/resources-kA1bao30.mjs +0 -358
  99. package/dist/resources-kA1bao30.mjs.map +0 -1
  100. package/dist/router.mjs +0 -721
  101. package/dist/router.mjs.map +0 -1
  102. package/dist/stegaEncodeSourceMap-DCG9Ba1H.mjs +0 -358
  103. package/dist/stegaEncodeSourceMap-DCG9Ba1H.mjs.map +0 -1
  104. package/dist/structure.mjs +0 -57
  105. package/dist/structure.mjs.map +0 -1
  106. package/dist/structureTool-Bth1vd8r.mjs +0 -13150
  107. package/dist/structureTool-Bth1vd8r.mjs.map +0 -1
  108. package/dist/switchMap-DHVUskpL.mjs +0 -54
  109. package/dist/switchMap-DHVUskpL.mjs.map +0 -1
  110. package/dist/v4-zH-CAum7.mjs +0 -24798
  111. package/dist/v4-zH-CAum7.mjs.map +0 -1
  112. package/dist/version-DoE_JnhG.mjs +0 -5
  113. package/dist/version-DoE_JnhG.mjs.map +0 -1
package/dist/router.mjs DELETED
@@ -1,721 +0,0 @@
1
- import { RouterContext as J } from "sanity/_singletons";
2
- import { RouterContext as le } from "sanity/_singletons";
3
- import { jsx as $ } from "react/jsx-runtime";
4
- import { d as C } from "./index-C9NvTy6s.mjs";
5
- import { useContext as at, forwardRef as D, useCallback as j, useMemo as M, useRef as ct, useEffect as it } from "react";
6
- import { l as k } from "./lodash-Vz5dH_Dm.mjs";
7
- import { D as lt } from "./browser-DmX5VEcE.mjs";
8
- function w() {
9
- const e = at(J);
10
- if (!e)
11
- throw new Error("Router: missing context value");
12
- return e;
13
- }
14
- function ut(e) {
15
- return e.button === 0;
16
- }
17
- function ft(e) {
18
- return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
19
- }
20
- function z(e) {
21
- const r = C.c(8), {
22
- onClick: n,
23
- href: t,
24
- target: o,
25
- replace: s
26
- } = e, a = s === void 0 ? !1 : s, {
27
- navigateUrl: i
28
- } = w();
29
- let c;
30
- r[0] !== t || r[1] !== i || r[2] !== n || r[3] !== a || r[4] !== o ? (c = (u) => {
31
- u.isDefaultPrevented() || t && (n && n(u), !(ft(u) || !ut(u)) && (o || (u.preventDefault(), i({
32
- path: t,
33
- replace: a
34
- }))));
35
- }, r[0] = t, r[1] = i, r[2] = n, r[3] = a, r[4] = o, r[5] = c) : c = r[5];
36
- const m = c;
37
- let d;
38
- return r[6] !== m ? (d = {
39
- onClick: m
40
- }, r[6] = m, r[7] = d) : d = r[7], d;
41
- }
42
- function mt(e) {
43
- const r = C.c(13), {
44
- intent: n,
45
- onClick: t,
46
- params: o,
47
- replace: s,
48
- target: a,
49
- searchParams: i
50
- } = e, {
51
- resolveIntentLink: c
52
- } = w();
53
- let m, d;
54
- r[0] !== n || r[1] !== o || r[2] !== c || r[3] !== i ? (d = c(n, o, i), r[0] = n, r[1] = o, r[2] = c, r[3] = i, r[4] = d) : d = r[4], m = d;
55
- const u = m;
56
- let h;
57
- r[5] !== u || r[6] !== t || r[7] !== s || r[8] !== a ? (h = {
58
- href: u,
59
- onClick: t,
60
- replace: s,
61
- target: a
62
- }, r[5] = u, r[6] = t, r[7] = s, r[8] = a, r[9] = h) : h = r[9];
63
- const {
64
- onClick: l
65
- } = z(h);
66
- let f;
67
- return r[10] !== u || r[11] !== l ? (f = {
68
- onClick: l,
69
- href: u
70
- }, r[10] = u, r[11] = l, r[12] = f) : f = r[12], f;
71
- }
72
- const ee = D(function(r, n) {
73
- const t = C.c(18);
74
- let o, s, a, i, c;
75
- t[0] !== r ? ({
76
- intent: o,
77
- params: s,
78
- target: c,
79
- searchParams: i,
80
- ...a
81
- } = r, t[0] = r, t[1] = o, t[2] = s, t[3] = a, t[4] = i, t[5] = c) : (o = t[1], s = t[2], a = t[3], i = t[4], c = t[5]);
82
- let m;
83
- t[6] !== o || t[7] !== s || t[8] !== r.onClick || t[9] !== i || t[10] !== c ? (m = {
84
- intent: o,
85
- params: s,
86
- target: c,
87
- onClick: r.onClick,
88
- searchParams: i
89
- }, t[6] = o, t[7] = s, t[8] = r.onClick, t[9] = i, t[10] = c, t[11] = m) : m = t[11];
90
- const {
91
- onClick: d,
92
- href: u
93
- } = mt(m);
94
- let h;
95
- return t[12] !== u || t[13] !== d || t[14] !== n || t[15] !== a || t[16] !== c ? (h = /* @__PURE__ */ $("a", { ...a, href: u, onClick: d, ref: n, target: c }), t[12] = u, t[13] = d, t[14] = n, t[15] = a, t[16] = c, t[17] = h) : h = t[17], h;
96
- }), re = D(function(r, n) {
97
- const t = C.c(17);
98
- let o, s, a, i, c;
99
- t[0] !== r ? ({
100
- onClick: s,
101
- href: o,
102
- target: c,
103
- replace: a,
104
- ...i
105
- } = r, t[0] = r, t[1] = o, t[2] = s, t[3] = a, t[4] = i, t[5] = c) : (o = t[1], s = t[2], a = t[3], i = t[4], c = t[5]);
106
- let m;
107
- t[6] !== o || t[7] !== s || t[8] !== a || t[9] !== c ? (m = {
108
- onClick: s,
109
- href: o,
110
- target: c,
111
- replace: a
112
- }, t[6] = o, t[7] = s, t[8] = a, t[9] = c, t[10] = m) : m = t[10];
113
- const {
114
- onClick: d
115
- } = z(m);
116
- let u;
117
- return t[11] !== o || t[12] !== d || t[13] !== n || t[14] !== i || t[15] !== c ? (u = /* @__PURE__ */ $("a", { ...i, onClick: d, href: o, target: c, ref: n }), t[11] = o, t[12] = d, t[13] = n, t[14] = i, t[15] = c, t[16] = u) : u = t[16], u;
118
- }), dt = /^[a-zA-Z0-9_-]+$/;
119
- function ht(e) {
120
- if (!e)
121
- return null;
122
- if (e.startsWith(":")) {
123
- const r = e.slice(1);
124
- if (!dt.test(r)) {
125
- const n = e.includes("*") ? " Splats are not supported. Consider using child routes instead" : "";
126
- console.error(new Error(`Warning: Param segments "${e}" includes invalid characters.${n}`));
127
- }
128
- return {
129
- type: "param",
130
- name: r
131
- };
132
- }
133
- return {
134
- type: "dir",
135
- name: e
136
- };
137
- }
138
- function pt(e) {
139
- const [r] = e.split("?"), n = r.split("/").map(ht).filter(Boolean);
140
- return {
141
- raw: e,
142
- segments: n
143
- };
144
- }
145
- function et(e) {
146
- return Array.isArray(e) ? e : e ? [e] : [];
147
- }
148
- function Y(e) {
149
- return k.isPlainObject(e);
150
- }
151
- function N(e, r, n) {
152
- return {
153
- type: "error",
154
- node: e,
155
- missingKeys: r,
156
- unmappableStateKeys: n
157
- };
158
- }
159
- function B(e, r, n, t) {
160
- return {
161
- type: "ok",
162
- node: e,
163
- matchedState: r,
164
- searchParams: n,
165
- child: t
166
- };
167
- }
168
- function rt(e, r) {
169
- if (!r)
170
- return B(e, {}, []);
171
- const n = e.scope ? r[e.scope] : r, {
172
- _searchParams: t = [],
173
- ...o
174
- } = n || {}, s = e.route.segments.filter((P) => P.type === "param").map((P) => P.name), a = Y(o) ? Object.keys(o) : [], i = k.intersection(a, s), c = k.difference(s, i), m = k.difference(a, i);
175
- if (c.length > 0)
176
- return N(e, c, []);
177
- const d = t.map(([P, y]) => [[P], y]), u = k.pick(o, i);
178
- if (m.length === 0)
179
- return B(e, u, d);
180
- const h = et((typeof e.children == "function" ? e.children(Y(o) ? o : {}) : e.children) || []);
181
- if (m.length > 0 && h.length === 0)
182
- return N(e, [], m);
183
- const l = k.pick(o, m), p = h.map((P) => rt(P, l)).find((P) => P.type === "ok");
184
- return p ? B(e, u, d, p) : N(e, [], m);
185
- }
186
- function nt(e, r) {
187
- const n = [...String(e)];
188
- let t = "";
189
- for (let o = 0; o < n.length; o++) {
190
- const s = n[o];
191
- r.includes(s) ? t += s : t += encodeURIComponent(s);
192
- }
193
- return t;
194
- }
195
- const K = lt("state-router");
196
- function Pt(e, r) {
197
- K("Resolving path from state %o", r);
198
- const n = rt(e, r);
199
- if (n.type === "error") {
200
- const a = n.unmappableStateKeys;
201
- if (a.length > 0)
202
- throw new Error(`Unable to find matching route for state. Could not map the following state key${a.length == 1 ? "" : "s"} to a valid url: ${a.map(q).join(", ")}`);
203
- const i = n.missingKeys;
204
- throw new Error(`Unable to find matching route for state. State object is missing the following key${i.length == 1 ? "" : "s"} defined in route: ${i.map(q).join(", ")}`);
205
- }
206
- const {
207
- path: t,
208
- searchParams: o
209
- } = ot(n), s = o.length > 0 ? kt(o) : "";
210
- return `/${t.join("/")}${s ? `?${s}` : ""}`;
211
- }
212
- function yt(e) {
213
- return `[${e}]`;
214
- }
215
- function kt(e) {
216
- return e.flatMap(([r, n]) => n === void 0 ? [] : [_t(gt(r)), St(n)].join("=")).join("&");
217
- }
218
- function gt(e) {
219
- const [r, ...n] = e;
220
- return n.length > 0 ? [r, ...n.map(yt)].join("") : r;
221
- }
222
- function St(e) {
223
- return nt(e, "/");
224
- }
225
- function _t(e) {
226
- return nt(e, "[]");
227
- }
228
- function ot(e) {
229
- const r = e.matchedState, n = e.node.route.segments.map((s) => {
230
- if (s.type === "dir")
231
- return s.name;
232
- const a = e.node.transform && e.node.transform[s.name];
233
- return a ? a.toPath(r[s.name]) : r[s.name];
234
- }), t = e.child ? ot(e.child) : void 0, o = t != null && t.searchParams ? [...e.searchParams, ...t.searchParams] : e.searchParams;
235
- return {
236
- searchParams: Ct(e.node, o),
237
- path: [...n || [], ...(t == null ? void 0 : t.path) || []]
238
- };
239
- }
240
- function Ct(e, r) {
241
- const n = e.scope;
242
- return n && !e.__unsafe_disableScopedSearchParams ? r.map(([t, o]) => [[n, ...t], o]) : r;
243
- }
244
- function q(e) {
245
- return `"${e}"`;
246
- }
247
- function Rt(e) {
248
- return e.map(([r, n]) => [vt(r), n]);
249
- }
250
- const F = 1, G = 0;
251
- function vt(e) {
252
- const r = [];
253
- let n = 0, t = G;
254
- for (; n < e.length; ) {
255
- const o = e.indexOf("[", n);
256
- if (o === -1) {
257
- r.push(e.slice(n, e.length));
258
- break;
259
- }
260
- if (t === F)
261
- throw new Error("Nested brackets not supported");
262
- t = F, o > n && (r.push(e.slice(n, o)), n = o);
263
- const s = e.indexOf("]", o);
264
- if (s === -1) {
265
- if (t === F)
266
- throw new Error("Unclosed bracket");
267
- break;
268
- }
269
- t = G, r.push(e.slice(n + 1, s)), n = s + 1;
270
- }
271
- return r;
272
- }
273
- function st(e, r, n) {
274
- const t = r.split("/").filter(Boolean), o = e.route.segments.length;
275
- if (t.length < o)
276
- return null;
277
- const s = {};
278
- if (!e.route.segments.every((l, f) => {
279
- if (l.type === "dir")
280
- return l.name === t[f];
281
- const p = e.transform && e.transform[l.name];
282
- return s[l.name] = p ? p.toState(t[f]) : t[f], !0;
283
- }))
284
- return null;
285
- const i = t.slice(o);
286
- let c = null;
287
- const m = typeof e.children == "function" ? et(e.children(s)) : e.children, d = $t(e.scope, n);
288
- if (m.some((l) => {
289
- if (l) {
290
- const f = l.scope ? d.filter(([p]) => l.scope === p[0]) : d;
291
- return c = st(l, i.join("/"), f), c;
292
- }
293
- }), i.length > 0 && !c)
294
- return null;
295
- const u = d.flatMap(([l, f]) => l.length === 1 ? [[l[0], f]] : []), h = {
296
- ...s,
297
- ...c === null ? {} : c,
298
- ...u.length > 0 ? {
299
- _searchParams: u
300
- } : {}
301
- };
302
- return e.scope ? {
303
- [e.scope]: h
304
- } : h;
305
- }
306
- function bt(e, r) {
307
- K("resolving state from path %s", r);
308
- const [n, t] = r.split("?"), o = Array.from(new URLSearchParams(t).entries()), s = st(e, n, Rt(o));
309
- return K("resolved: %o", s || null), s || null;
310
- }
311
- function $t(e, r) {
312
- return e ? r.map(([n, t]) => [n[0] === e ? n.slice(1) : n, t]) : r;
313
- }
314
- function wt(e) {
315
- return jt(e).replace(/\//g, "_").replace(/\+/g, "-").replace(/[=]+$/, "");
316
- }
317
- function Et(e) {
318
- return Lt(e.replace(/-/g, "+").replace(/_/g, "/"));
319
- }
320
- function It(e) {
321
- return String.fromCharCode(parseInt(e.slice(1), 16));
322
- }
323
- function jt(e) {
324
- return btoa(encodeURIComponent(e).replace(/%[0-9A-F]{2}/g, It));
325
- }
326
- function At(e) {
327
- return `%${`00${e.charCodeAt(0).toString(16)}`.slice(-2)}`;
328
- }
329
- function Lt(e) {
330
- return decodeURIComponent(Array.from(atob(e), At).join(""));
331
- }
332
- function Ut(e = "") {
333
- const r = decodeURIComponent(e);
334
- if (!r)
335
- return {};
336
- try {
337
- return JSON.parse(Et(r));
338
- } catch {
339
- }
340
- try {
341
- return JSON.parse(atob(r));
342
- } catch {
343
- }
344
- try {
345
- return JSON.parse(r);
346
- } catch {
347
- console.warn("Failed to parse JSON parameters");
348
- }
349
- return {};
350
- }
351
- function xt(e) {
352
- return e ? wt(JSON.stringify(e)) : "";
353
- }
354
- function Mt(e) {
355
- return e.split(";").reduce((r, n) => {
356
- const [t, o] = n.split("=");
357
- return r[decodeURIComponent(t)] = decodeURIComponent(o), r;
358
- }, {});
359
- }
360
- function Nt(e) {
361
- return Object.entries(e).filter(([, r]) => r != null).map(([r, n]) => `${encodeURIComponent(r)}=${encodeURIComponent(n)}`).join(";");
362
- }
363
- const T = {
364
- create: (e, r, n) => X(H(e, r, n)),
365
- intents: (e) => {
366
- const r = Ft(e).join("/");
367
- return T.create(`${r}/:intent`, [T.create(":params", {
368
- transform: {
369
- params: {
370
- toState: Mt,
371
- toPath: Nt
372
- }
373
- }
374
- }, [T.create(":payload", {
375
- transform: {
376
- payload: {
377
- toState: Ut,
378
- toPath: xt
379
- }
380
- }
381
- })])]);
382
- },
383
- scope(e, r, n, t) {
384
- const o = H(r, n, t);
385
- return X({
386
- ...o,
387
- scope: e
388
- });
389
- }
390
- };
391
- function Z(e) {
392
- return Array.isArray(e) || typeof e == "function" ? e : e ? [e] : [];
393
- }
394
- function Bt(e) {
395
- return e && "_isRoute" in e;
396
- }
397
- function H(e, r, n) {
398
- return typeof e == "object" ? e : Array.isArray(r) || typeof r == "function" || Bt(r) ? {
399
- path: e,
400
- children: Z(r)
401
- } : n ? {
402
- path: e,
403
- ...r,
404
- children: Z(n)
405
- } : {
406
- path: e,
407
- ...r
408
- };
409
- }
410
- function Ft(...e) {
411
- return e.reduce((r, n) => r.concat(n.split("/")), []).filter(Boolean);
412
- }
413
- const Tt = {};
414
- function Q(e) {
415
- return e.split("/").every((r) => !r);
416
- }
417
- function X(e) {
418
- const {
419
- path: r,
420
- scope: n,
421
- transform: t,
422
- children: o,
423
- __unsafe_disableScopedSearchParams: s
424
- } = e;
425
- if (!r)
426
- throw new TypeError("Missing path");
427
- const a = pt(r);
428
- return {
429
- _isRoute: !0,
430
- // todo: make a Router class instead
431
- scope: n,
432
- // eslint-disable-next-line camelcase
433
- __unsafe_disableScopedSearchParams: s,
434
- route: a,
435
- children: o || [],
436
- transform: t,
437
- encode(i) {
438
- return Pt(this, i);
439
- },
440
- decode(i) {
441
- return bt(this, i);
442
- },
443
- isRoot: Q,
444
- isNotFound(i) {
445
- return this.decode(i) === null;
446
- },
447
- getBasePath() {
448
- return this.encode(Tt);
449
- },
450
- getRedirectBase(i) {
451
- if (Q(i)) {
452
- const c = this.getBasePath();
453
- if (i !== c)
454
- return c;
455
- }
456
- return null;
457
- }
458
- };
459
- }
460
- const A = ["perspective", "excludedPerspectives"], L = (e) => {
461
- if (typeof e != "object" || e === null || Array.isArray(e) || !("replace" in e || "stickyParams" in e || "state" in e))
462
- return !1;
463
- if ("state" in e) {
464
- const {
465
- state: n
466
- } = e;
467
- return n == null || typeof n == "object";
468
- }
469
- return !0;
470
- };
471
- function ne(e) {
472
- const {
473
- onNavigate: r,
474
- router: n,
475
- state: t
476
- } = e, o = j((l, f, p) => {
477
- const [P, y] = Array.isArray(f) ? f : [f];
478
- return n.encode({
479
- intent: l,
480
- params: P,
481
- payload: y,
482
- _searchParams: k.toPairs({
483
- ...k.fromPairs((t._searchParams ?? []).filter(([g]) => A.includes(g))),
484
- ...k.fromPairs(p ?? [])
485
- })
486
- });
487
- }, [n, t._searchParams]), s = j((l) => {
488
- const f = t._searchParams || [], p = (l == null ? void 0 : l._searchParams) || [], P = A.reduce((y, g) => Kt(y, g, O(p, g) ?? O(f, g)), p || []);
489
- return n.encode({
490
- ...l,
491
- _searchParams: P
492
- });
493
- }, [n, t]), a = j((l, f) => {
494
- const P = L(l) && !f ? l : f || {}, y = L(l) ? Dt(l, t) ?? t : l, g = t._searchParams || [], R = P.stickyParams ?? Object.fromEntries(g.filter(([E]) => A.includes(E)));
495
- zt(R);
496
- const S = y._searchParams || [], b = Jt(S, R);
497
- r({
498
- path: s({
499
- ...y,
500
- _searchParams: b
501
- }),
502
- replace: P.replace
503
- });
504
- }, [r, s, t]), i = j((l, f = {}) => a({
505
- stickyParams: l,
506
- ...f,
507
- state: void 0
508
- }), [a]), c = j((l, f, p = {}) => {
509
- r({
510
- path: o(l, f),
511
- replace: p.replace
512
- });
513
- }, [r, o]), [m, d] = M(() => {
514
- if (!t._searchParams)
515
- return [t, null];
516
- const {
517
- _searchParams: l,
518
- ...f
519
- } = t, [p, P] = k.partition(l, ([y]) => A.includes(y));
520
- return p.length === 0 ? [t, null] : [{
521
- ...f,
522
- _searchParams: P
523
- }, p];
524
- }, [t]), u = M(() => Object.fromEntries(d || []), [d]), h = M(() => ({
525
- navigate: a,
526
- navigateIntent: c,
527
- navigateStickyParams: i,
528
- navigateUrl: r,
529
- resolveIntentLink: o,
530
- resolvePathFromState: s,
531
- state: m,
532
- stickyParams: u
533
- }), [i, a, c, r, o, s, m, u]);
534
- return /* @__PURE__ */ $(J.Provider, { value: h, children: e.children });
535
- }
536
- function Kt(e, r, n) {
537
- const t = e.filter(([o]) => o !== r);
538
- return n === void 0 || n == "" ? t : [...t, [r, n]];
539
- }
540
- function Jt(e, r) {
541
- if (!r) return e;
542
- const n = e.filter(([a]) => !Object.hasOwn(r, a)), t = (a) => a[1] !== void 0, o = (a) => [a[0], a[1] === null ? "" : a[1]], s = Object.entries(r).filter(t).map(o);
543
- return [...n, ...s];
544
- }
545
- function O(e, r) {
546
- const n = e.find(([t]) => t === r);
547
- return n ? n[1] : void 0;
548
- }
549
- function Dt(e, r) {
550
- return L(e) ? e.state === null ? {} : e.state ?? r : null;
551
- }
552
- function zt(e) {
553
- if (Object.keys(e).some((n) => !A.includes(n))) throw new Error("One or more parameters are not sticky");
554
- }
555
- function Wt(e, r, n) {
556
- return n && {
557
- ...e,
558
- [r]: n
559
- };
560
- }
561
- const Vt = function(r) {
562
- const n = C.c(24), {
563
- children: t,
564
- scope: o,
565
- __unsafe_disableScopedSearchParams: s
566
- } = r, a = w(), {
567
- resolvePathFromState: i,
568
- navigate: c
569
- } = a, m = ct(a.state);
570
- let d, u;
571
- n[0] !== a.state ? (d = () => {
572
- m.current = a.state;
573
- }, u = [a.state], n[0] = a.state, n[1] = d, n[2] = u) : (d = n[1], u = n[2]), it(d, u);
574
- let h;
575
- n[3] !== s || n[4] !== o ? (h = (_) => {
576
- if (_ === null)
577
- return null;
578
- const {
579
- _searchParams: I,
580
- ...x
581
- } = _ || {}, v = Wt(m.current, o, x);
582
- return s ? v._searchParams = I : v[o]._searchParams = I, v;
583
- }, n[3] = s, n[4] = o, n[5] = h) : h = n[5];
584
- const l = h;
585
- let f;
586
- n[6] !== i || n[7] !== l ? (f = (_) => i(l(_)), n[6] = i, n[7] = l, n[8] = f) : f = n[8];
587
- const p = f;
588
- let P;
589
- n[9] !== c || n[10] !== l ? (P = (_, I) => {
590
- if (L(_) && !I) {
591
- const v = _, {
592
- state: W
593
- } = v;
594
- if (W) {
595
- const V = l(W);
596
- return c(V === null ? {} : V, v);
597
- }
598
- return c(v);
599
- }
600
- const x = L(_) ? l(null) : l(_);
601
- return c(x === null ? {} : x, I || {});
602
- }, n[9] = c, n[10] = l, n[11] = P) : P = n[11];
603
- const y = P;
604
- let g;
605
- const R = a.state;
606
- let S;
607
- n[12] !== s || n[13] !== R || n[14] !== o ? (S = typeof R[o] == "object" ? {
608
- ...R[o]
609
- } : {}, s && (S._searchParams = R._searchParams), n[12] = s, n[13] = R, n[14] = o, n[15] = S) : S = n[15];
610
- let b;
611
- n[16] !== S || n[17] !== y || n[18] !== a || n[19] !== p ? (b = {
612
- ...a,
613
- navigate: y,
614
- resolvePathFromState: p,
615
- state: S
616
- }, n[16] = S, n[17] = y, n[18] = a, n[19] = p, n[20] = b) : b = n[20], g = b;
617
- const E = g;
618
- let U;
619
- return n[21] !== E || n[22] !== t ? (U = /* @__PURE__ */ $(J.Provider, { value: E, children: t }), n[21] = E, n[22] = t, n[23] = U) : U = n[23], U;
620
- };
621
- Vt.displayName = "RouteScope";
622
- const tt = {};
623
- function Yt(e) {
624
- const r = C.c(11), {
625
- onClick: n,
626
- replace: t,
627
- state: o,
628
- target: s,
629
- toIndex: a
630
- } = e, i = a === void 0 ? !1 : a;
631
- if (o && i)
632
- throw new Error("Passing both `state` and `toIndex={true}` as props to StateLink is invalid");
633
- !o && !i && console.error(new Error("No state passed to StateLink. If you want to link to an empty state, its better to use the the `toIndex` property"));
634
- const {
635
- resolvePathFromState: c
636
- } = w();
637
- let m;
638
- const d = i ? tt : o || tt;
639
- let u;
640
- r[0] !== c || r[1] !== d ? (u = c(d), r[0] = c, r[1] = d, r[2] = u) : u = r[2], m = u;
641
- const h = m;
642
- let l;
643
- r[3] !== h || r[4] !== n || r[5] !== t || r[6] !== s ? (l = {
644
- href: h,
645
- onClick: n,
646
- replace: t,
647
- target: s
648
- }, r[3] = h, r[4] = n, r[5] = t, r[6] = s, r[7] = l) : l = r[7];
649
- const {
650
- onClick: f
651
- } = z(l);
652
- let p;
653
- return r[8] !== h || r[9] !== f ? (p = {
654
- onClick: f,
655
- href: h
656
- }, r[8] = h, r[9] = f, r[10] = p) : p = r[10], p;
657
- }
658
- const oe = D(function(r, n) {
659
- const t = C.c(18);
660
- let o, s, a, i, c, m;
661
- t[0] !== r ? ({
662
- onClick: o,
663
- replace: s,
664
- state: i,
665
- target: m,
666
- toIndex: c,
667
- ...a
668
- } = r, t[0] = r, t[1] = o, t[2] = s, t[3] = a, t[4] = i, t[5] = c, t[6] = m) : (o = t[1], s = t[2], a = t[3], i = t[4], c = t[5], m = t[6]);
669
- const d = c === void 0 ? !1 : c;
670
- let u;
671
- t[7] !== o || t[8] !== s || t[9] !== i || t[10] !== m || t[11] !== d ? (u = {
672
- onClick: o,
673
- replace: s,
674
- state: i,
675
- target: m,
676
- toIndex: d
677
- }, t[7] = o, t[8] = s, t[9] = i, t[10] = m, t[11] = d, t[12] = u) : u = t[12];
678
- const {
679
- onClick: h,
680
- href: l
681
- } = Yt(u);
682
- let f;
683
- return t[13] !== l || t[14] !== h || t[15] !== n || t[16] !== a ? (f = /* @__PURE__ */ $("a", { ...a, href: l, onClick: h, ref: n }), t[13] = l, t[14] = h, t[15] = n, t[16] = a, t[17] = f) : f = t[17], f;
684
- });
685
- function se(e) {
686
- const r = C.c(3), n = e === void 0 ? k.identity : e, {
687
- state: t
688
- } = w();
689
- let o, s;
690
- return r[0] !== n || r[1] !== t ? (s = n(t), r[0] = n, r[1] = t, r[2] = s) : s = r[2], o = s, o;
691
- }
692
- function qt(e) {
693
- function r(n) {
694
- const t = C.c(3), o = w(), s = n;
695
- let a;
696
- return t[0] !== o || t[1] !== s ? (a = /* @__PURE__ */ $(e, { ...s, router: o }), t[0] = o, t[1] = s, t[2] = a) : a = t[2], a;
697
- }
698
- return r.displayName = `withRouter(${e.displayName || e.name})`, r;
699
- }
700
- const ae = qt((e) => e.children(e.router));
701
- export {
702
- ee as IntentLink,
703
- re as Link,
704
- Vt as RouteScope,
705
- le as RouterContext,
706
- ne as RouterProvider,
707
- A as STICKY_PARAMS,
708
- oe as StateLink,
709
- ae as WithRouter,
710
- X as _createNode,
711
- Ut as decodeJsonParams,
712
- xt as encodeJsonParams,
713
- T as route,
714
- mt as useIntentLink,
715
- z as useLink,
716
- w as useRouter,
717
- se as useRouterState,
718
- Yt as useStateLink,
719
- qt as withRouter
720
- };
721
- //# sourceMappingURL=router.mjs.map