@okam/directus-next 0.1.0 → 0.1.1

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 (3) hide show
  1. package/index.js +1 -1
  2. package/index.mjs +82 -1366
  3. package/package.json +2 -3
package/index.mjs CHANGED
@@ -1,1305 +1,21 @@
1
- import w from "react";
2
- import { template as me } from "radash";
3
- var q = { exports: {} }, ae = {}, Q = {}, Z = Object.defineProperty, be = Object.getOwnPropertyDescriptor, Se = Object.getOwnPropertyNames, Ce = Object.prototype.hasOwnProperty, Re = (t, e) => {
4
- for (var r in e)
5
- Z(t, r, { get: e[r], enumerable: !0 });
6
- }, Oe = (t, e, r, n) => {
7
- if (e && typeof e == "object" || typeof e == "function")
8
- for (let i of Se(e))
9
- !Ce.call(t, i) && i !== r && Z(t, i, { get: () => e[i], enumerable: !(n = be(e, i)) || n.enumerable });
10
- return t;
11
- }, Ee = (t) => Oe(Z({}, "__esModule", { value: !0 }), t), ue = {};
12
- Re(ue, {
13
- RequestCookies: () => xe,
14
- ResponseCookies: () => Le,
15
- parseCookie: () => ee,
16
- parseSetCookie: () => se,
17
- stringifyCookie: () => P
18
- });
19
- var Ae = Ee(ue);
20
- function P(t) {
21
- var e;
22
- const r = [
23
- "path" in t && t.path && `Path=${t.path}`,
24
- "expires" in t && (t.expires || t.expires === 0) && `Expires=${(typeof t.expires == "number" ? new Date(t.expires) : t.expires).toUTCString()}`,
25
- "maxAge" in t && typeof t.maxAge == "number" && `Max-Age=${t.maxAge}`,
26
- "domain" in t && t.domain && `Domain=${t.domain}`,
27
- "secure" in t && t.secure && "Secure",
28
- "httpOnly" in t && t.httpOnly && "HttpOnly",
29
- "sameSite" in t && t.sameSite && `SameSite=${t.sameSite}`,
30
- "priority" in t && t.priority && `Priority=${t.priority}`
31
- ].filter(Boolean);
32
- return `${t.name}=${encodeURIComponent((e = t.value) != null ? e : "")}; ${r.join("; ")}`;
33
- }
34
- function ee(t) {
35
- const e = /* @__PURE__ */ new Map();
36
- for (const r of t.split(/; */)) {
37
- if (!r)
38
- continue;
39
- const n = r.indexOf("=");
40
- if (n === -1) {
41
- e.set(r, "true");
42
- continue;
43
- }
44
- const [i, a] = [r.slice(0, n), r.slice(n + 1)];
45
- try {
46
- e.set(i, decodeURIComponent(a ?? "true"));
47
- } catch {
48
- }
49
- }
50
- return e;
51
- }
52
- function se(t) {
53
- if (!t)
54
- return;
55
- const [[e, r], ...n] = ee(t), {
56
- domain: i,
57
- expires: a,
58
- httponly: o,
59
- maxage: u,
60
- path: s,
61
- samesite: y,
62
- secure: c,
63
- priority: l
64
- } = Object.fromEntries(
65
- n.map(([d, _]) => [d.toLowerCase(), _])
66
- ), g = {
67
- name: e,
68
- value: decodeURIComponent(r),
69
- domain: i,
70
- ...a && { expires: new Date(a) },
71
- ...o && { httpOnly: !0 },
72
- ...typeof u == "string" && { maxAge: Number(u) },
73
- path: s,
74
- ...y && { sameSite: je(y) },
75
- ...c && { secure: !0 },
76
- ...l && { priority: ke(l) }
77
- };
78
- return Pe(g);
79
- }
80
- function Pe(t) {
81
- const e = {};
82
- for (const r in t)
83
- t[r] && (e[r] = t[r]);
84
- return e;
85
- }
86
- var we = ["strict", "lax", "none"];
87
- function je(t) {
88
- return t = t.toLowerCase(), we.includes(t) ? t : void 0;
89
- }
90
- var Me = ["low", "medium", "high"];
91
- function ke(t) {
92
- return t = t.toLowerCase(), Me.includes(t) ? t : void 0;
93
- }
94
- function Te(t) {
95
- if (!t)
96
- return [];
97
- var e = [], r = 0, n, i, a, o, u;
98
- function s() {
99
- for (; r < t.length && /\s/.test(t.charAt(r)); )
100
- r += 1;
101
- return r < t.length;
102
- }
103
- function y() {
104
- return i = t.charAt(r), i !== "=" && i !== ";" && i !== ",";
105
- }
106
- for (; r < t.length; ) {
107
- for (n = r, u = !1; s(); )
108
- if (i = t.charAt(r), i === ",") {
109
- for (a = r, r += 1, s(), o = r; r < t.length && y(); )
110
- r += 1;
111
- r < t.length && t.charAt(r) === "=" ? (u = !0, r = o, e.push(t.substring(n, a)), n = r) : r = a + 1;
112
- } else
113
- r += 1;
114
- (!u || r >= t.length) && e.push(t.substring(n, t.length));
115
- }
116
- return e;
117
- }
118
- var xe = class {
119
- constructor(t) {
120
- this._parsed = /* @__PURE__ */ new Map(), this._headers = t;
121
- const e = t.get("cookie");
122
- if (e) {
123
- const r = ee(e);
124
- for (const [n, i] of r)
125
- this._parsed.set(n, { name: n, value: i });
126
- }
127
- }
128
- [Symbol.iterator]() {
129
- return this._parsed[Symbol.iterator]();
130
- }
131
- /**
132
- * The amount of cookies received from the client
133
- */
134
- get size() {
135
- return this._parsed.size;
136
- }
137
- get(...t) {
138
- const e = typeof t[0] == "string" ? t[0] : t[0].name;
139
- return this._parsed.get(e);
140
- }
141
- getAll(...t) {
142
- var e;
143
- const r = Array.from(this._parsed);
144
- if (!t.length)
145
- return r.map(([i, a]) => a);
146
- const n = typeof t[0] == "string" ? t[0] : (e = t[0]) == null ? void 0 : e.name;
147
- return r.filter(([i]) => i === n).map(([i, a]) => a);
148
- }
149
- has(t) {
150
- return this._parsed.has(t);
151
- }
152
- set(...t) {
153
- const [e, r] = t.length === 1 ? [t[0].name, t[0].value] : t, n = this._parsed;
154
- return n.set(e, { name: e, value: r }), this._headers.set(
155
- "cookie",
156
- Array.from(n).map(([i, a]) => P(a)).join("; ")
157
- ), this;
158
- }
159
- /**
160
- * Delete the cookies matching the passed name or names in the request.
161
- */
162
- delete(t) {
163
- const e = this._parsed, r = Array.isArray(t) ? t.map((n) => e.delete(n)) : e.delete(t);
164
- return this._headers.set(
165
- "cookie",
166
- Array.from(e).map(([n, i]) => P(i)).join("; ")
167
- ), r;
168
- }
169
- /**
170
- * Delete all the cookies in the cookies in the request.
171
- */
172
- clear() {
173
- return this.delete(Array.from(this._parsed.keys())), this;
174
- }
175
- /**
176
- * Format the cookies in the request as a string for logging
177
- */
178
- [Symbol.for("edge-runtime.inspect.custom")]() {
179
- return `RequestCookies ${JSON.stringify(Object.fromEntries(this._parsed))}`;
180
- }
181
- toString() {
182
- return [...this._parsed.values()].map((t) => `${t.name}=${encodeURIComponent(t.value)}`).join("; ");
183
- }
184
- }, Le = class {
185
- constructor(t) {
186
- this._parsed = /* @__PURE__ */ new Map();
187
- var e, r, n;
188
- this._headers = t;
189
- const i = (n = (r = (e = t.getSetCookie) == null ? void 0 : e.call(t)) != null ? r : t.get("set-cookie")) != null ? n : [], a = Array.isArray(i) ? i : Te(i);
190
- for (const o of a) {
191
- const u = se(o);
192
- u && this._parsed.set(u.name, u);
193
- }
194
- }
195
- /**
196
- * {@link https://wicg.github.io/cookie-store/#CookieStore-get CookieStore#get} without the Promise.
197
- */
198
- get(...t) {
199
- const e = typeof t[0] == "string" ? t[0] : t[0].name;
200
- return this._parsed.get(e);
201
- }
202
- /**
203
- * {@link https://wicg.github.io/cookie-store/#CookieStore-getAll CookieStore#getAll} without the Promise.
204
- */
205
- getAll(...t) {
206
- var e;
207
- const r = Array.from(this._parsed.values());
208
- if (!t.length)
209
- return r;
210
- const n = typeof t[0] == "string" ? t[0] : (e = t[0]) == null ? void 0 : e.name;
211
- return r.filter((i) => i.name === n);
212
- }
213
- has(t) {
214
- return this._parsed.has(t);
215
- }
216
- /**
217
- * {@link https://wicg.github.io/cookie-store/#CookieStore-set CookieStore#set} without the Promise.
218
- */
219
- set(...t) {
220
- const [e, r, n] = t.length === 1 ? [t[0].name, t[0].value, t[0]] : t, i = this._parsed;
221
- return i.set(e, Ne({ name: e, value: r, ...n })), Ie(i, this._headers), this;
222
- }
223
- /**
224
- * {@link https://wicg.github.io/cookie-store/#CookieStore-delete CookieStore#delete} without the Promise.
225
- */
226
- delete(...t) {
227
- const [e, r, n] = typeof t[0] == "string" ? [t[0]] : [t[0].name, t[0].path, t[0].domain];
228
- return this.set({ name: e, path: r, domain: n, value: "", expires: /* @__PURE__ */ new Date(0) });
229
- }
230
- [Symbol.for("edge-runtime.inspect.custom")]() {
231
- return `ResponseCookies ${JSON.stringify(Object.fromEntries(this._parsed))}`;
232
- }
233
- toString() {
234
- return [...this._parsed.values()].map(P).join("; ");
235
- }
236
- };
237
- function Ie(t, e) {
238
- e.delete("set-cookie");
239
- for (const [, r] of t) {
240
- const n = P(r);
241
- e.append("set-cookie", n);
242
- }
243
- }
244
- function Ne(t = { name: "", value: "" }) {
245
- return typeof t.expires == "number" && (t.expires = new Date(t.expires)), t.maxAge && (t.expires = new Date(Date.now() + t.maxAge * 1e3)), (t.path === null || t.path === void 0) && (t.path = "/"), t;
246
- }
247
- (function(t) {
248
- Object.defineProperty(t, "__esModule", {
249
- value: !0
250
- });
251
- function e(n, i) {
252
- for (var a in i) Object.defineProperty(n, a, {
253
- enumerable: !0,
254
- get: i[a]
255
- });
256
- }
257
- e(t, {
258
- RequestCookies: function() {
259
- return r.RequestCookies;
260
- },
261
- ResponseCookies: function() {
262
- return r.ResponseCookies;
263
- }
264
- });
265
- const r = Ae;
266
- })(Q);
267
- var te = {};
268
- (function(t) {
269
- Object.defineProperty(t, "__esModule", {
270
- value: !0
271
- }), Object.defineProperty(t, "ReflectAdapter", {
272
- enumerable: !0,
273
- get: function() {
274
- return e;
275
- }
276
- });
277
- class e {
278
- static get(n, i, a) {
279
- const o = Reflect.get(n, i, a);
280
- return typeof o == "function" ? o.bind(n) : o;
281
- }
282
- static set(n, i, a, o) {
283
- return Reflect.set(n, i, a, o);
284
- }
285
- static has(n, i) {
286
- return Reflect.has(n, i);
287
- }
288
- static deleteProperty(n, i) {
289
- return Reflect.deleteProperty(n, i);
290
- }
291
- }
292
- })(te);
293
- (function(t) {
294
- Object.defineProperty(t, "__esModule", {
295
- value: !0
296
- });
297
- function e(c, l) {
298
- for (var g in l) Object.defineProperty(c, g, {
299
- enumerable: !0,
300
- get: l[g]
301
- });
302
- }
303
- e(t, {
304
- ReadonlyRequestCookiesError: function() {
305
- return i;
306
- },
307
- RequestCookiesAdapter: function() {
308
- return a;
309
- },
310
- getModifiedCookieValues: function() {
311
- return u;
312
- },
313
- appendMutableCookies: function() {
314
- return s;
315
- },
316
- MutableRequestCookiesAdapter: function() {
317
- return y;
318
- }
319
- });
320
- const r = Q, n = te;
321
- class i extends Error {
322
- constructor() {
323
- super("Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#cookiessetname-value-options");
324
- }
325
- static callable() {
326
- throw new i();
327
- }
328
- }
329
- class a {
330
- static seal(l) {
331
- return new Proxy(l, {
332
- get(g, d, _) {
333
- switch (d) {
334
- case "clear":
335
- case "delete":
336
- case "set":
337
- return i.callable;
338
- default:
339
- return n.ReflectAdapter.get(g, d, _);
340
- }
341
- }
342
- });
343
- }
344
- }
345
- const o = Symbol.for("next.mutated.cookies");
346
- function u(c) {
347
- const l = c[o];
348
- return !l || !Array.isArray(l) || l.length === 0 ? [] : l;
349
- }
350
- function s(c, l) {
351
- const g = u(l);
352
- if (g.length === 0)
353
- return !1;
354
- const d = new r.ResponseCookies(c), _ = d.getAll();
355
- for (const f of g)
356
- d.set(f);
357
- for (const f of _)
358
- d.set(f);
359
- return !0;
360
- }
361
- class y {
362
- static wrap(l, g) {
363
- const d = new r.ResponseCookies(new Headers());
364
- for (const v of l.getAll())
365
- d.set(v);
366
- let _ = [];
367
- const f = /* @__PURE__ */ new Set(), h = () => {
368
- var v;
369
- const C = fetch.__nextGetStaticStore == null || (v = fetch.__nextGetStaticStore.call(fetch)) == null ? void 0 : v.getStore();
370
- if (C && (C.pathWasRevalidated = !0), _ = d.getAll().filter((b) => f.has(b.name)), g) {
371
- const b = [];
372
- for (const j of _) {
373
- const M = new r.ResponseCookies(new Headers());
374
- M.set(j), b.push(M.toString());
375
- }
376
- g(b);
377
- }
378
- };
379
- return new Proxy(d, {
380
- get(v, C, O) {
381
- switch (C) {
382
- case o:
383
- return _;
384
- case "delete":
385
- return function(...b) {
386
- f.add(typeof b[0] == "string" ? b[0] : b[0].name);
387
- try {
388
- v.delete(...b);
389
- } finally {
390
- h();
391
- }
392
- };
393
- case "set":
394
- return function(...b) {
395
- f.add(typeof b[0] == "string" ? b[0] : b[0].name);
396
- try {
397
- return v.set(...b);
398
- } finally {
399
- h();
400
- }
401
- };
402
- default:
403
- return n.ReflectAdapter.get(v, C, O);
404
- }
405
- }
406
- });
407
- }
408
- }
409
- })(ae);
410
- var ce = {};
411
- (function(t) {
412
- Object.defineProperty(t, "__esModule", {
413
- value: !0
414
- });
415
- function e(a, o) {
416
- for (var u in o) Object.defineProperty(a, u, {
417
- enumerable: !0,
418
- get: o[u]
419
- });
420
- }
421
- e(t, {
422
- ReadonlyHeadersError: function() {
423
- return n;
424
- },
425
- HeadersAdapter: function() {
426
- return i;
427
- }
428
- });
429
- const r = te;
430
- class n extends Error {
431
- constructor() {
432
- super("Headers cannot be modified. Read more: https://nextjs.org/docs/app/api-reference/functions/headers");
433
- }
434
- static callable() {
435
- throw new n();
436
- }
437
- }
438
- class i extends Headers {
439
- constructor(o) {
440
- super(), this.headers = new Proxy(o, {
441
- get(u, s, y) {
442
- if (typeof s == "symbol")
443
- return r.ReflectAdapter.get(u, s, y);
444
- const c = s.toLowerCase(), l = Object.keys(o).find((g) => g.toLowerCase() === c);
445
- if (!(typeof l > "u"))
446
- return r.ReflectAdapter.get(u, l, y);
447
- },
448
- set(u, s, y, c) {
449
- if (typeof s == "symbol")
450
- return r.ReflectAdapter.set(u, s, y, c);
451
- const l = s.toLowerCase(), g = Object.keys(o).find((d) => d.toLowerCase() === l);
452
- return r.ReflectAdapter.set(u, g ?? s, y, c);
453
- },
454
- has(u, s) {
455
- if (typeof s == "symbol") return r.ReflectAdapter.has(u, s);
456
- const y = s.toLowerCase(), c = Object.keys(o).find((l) => l.toLowerCase() === y);
457
- return typeof c > "u" ? !1 : r.ReflectAdapter.has(u, c);
458
- },
459
- deleteProperty(u, s) {
460
- if (typeof s == "symbol") return r.ReflectAdapter.deleteProperty(u, s);
461
- const y = s.toLowerCase(), c = Object.keys(o).find((l) => l.toLowerCase() === y);
462
- return typeof c > "u" ? !0 : r.ReflectAdapter.deleteProperty(u, c);
463
- }
464
- });
465
- }
466
- /**
467
- * Seals a Headers instance to prevent modification by throwing an error when
468
- * any mutating method is called.
469
- */
470
- static seal(o) {
471
- return new Proxy(o, {
472
- get(u, s, y) {
473
- switch (s) {
474
- case "append":
475
- case "delete":
476
- case "set":
477
- return n.callable;
478
- default:
479
- return r.ReflectAdapter.get(u, s, y);
480
- }
481
- }
482
- });
483
- }
484
- /**
485
- * Merges a header value into a string. This stores multiple values as an
486
- * array, so we need to merge them into a string.
487
- *
488
- * @param value a header value
489
- * @returns a merged header value (a string)
490
- */
491
- merge(o) {
492
- return Array.isArray(o) ? o.join(", ") : o;
493
- }
494
- /**
495
- * Creates a Headers instance from a plain object or a Headers instance.
496
- *
497
- * @param headers a plain object or a Headers instance
498
- * @returns a headers instance
499
- */
500
- static from(o) {
501
- return o instanceof Headers ? o : new i(o);
502
- }
503
- append(o, u) {
504
- const s = this.headers[o];
505
- typeof s == "string" ? this.headers[o] = [
506
- s,
507
- u
508
- ] : Array.isArray(s) ? s.push(u) : this.headers[o] = u;
509
- }
510
- delete(o) {
511
- delete this.headers[o];
512
- }
513
- get(o) {
514
- const u = this.headers[o];
515
- return typeof u < "u" ? this.merge(u) : null;
516
- }
517
- has(o) {
518
- return typeof this.headers[o] < "u";
519
- }
520
- set(o, u) {
521
- this.headers[o] = u;
522
- }
523
- forEach(o, u) {
524
- for (const [s, y] of this.entries())
525
- o.call(u, y, s, this);
526
- }
527
- *entries() {
528
- for (const o of Object.keys(this.headers)) {
529
- const u = o.toLowerCase(), s = this.get(u);
530
- yield [
531
- u,
532
- s
533
- ];
534
- }
535
- }
536
- *keys() {
537
- for (const o of Object.keys(this.headers))
538
- yield o.toLowerCase();
539
- }
540
- *values() {
541
- for (const o of Object.keys(this.headers))
542
- yield this.get(o);
543
- }
544
- [Symbol.iterator]() {
545
- return this.entries();
546
- }
547
- }
548
- })(ce);
549
- var G = { exports: {} }, D = { exports: {} };
550
- (function(t, e) {
551
- Object.defineProperty(e, "__esModule", {
552
- value: !0
553
- }), Object.defineProperty(e, "createAsyncLocalStorage", {
554
- enumerable: !0,
555
- get: function() {
556
- return a;
557
- }
558
- });
559
- const r = new Error("Invariant: AsyncLocalStorage accessed in runtime where it is not available");
560
- class n {
561
- disable() {
562
- throw r;
563
- }
564
- getStore() {
565
- }
566
- run() {
567
- throw r;
568
- }
569
- exit() {
570
- throw r;
571
- }
572
- enterWith() {
573
- throw r;
574
- }
575
- }
576
- const i = globalThis.AsyncLocalStorage;
577
- function a() {
578
- return i ? new i() : new n();
579
- }
580
- (typeof e.default == "function" || typeof e.default == "object" && e.default !== null) && typeof e.default.__esModule > "u" && (Object.defineProperty(e.default, "__esModule", { value: !0 }), Object.assign(e.default, e), t.exports = e.default);
581
- })(D, D.exports);
582
- var re = D.exports;
583
- (function(t, e) {
584
- Object.defineProperty(e, "__esModule", {
585
- value: !0
586
- }), Object.defineProperty(e, "requestAsyncStorage", {
587
- enumerable: !0,
588
- get: function() {
589
- return n;
590
- }
591
- });
592
- const n = (0, re.createAsyncLocalStorage)();
593
- (typeof e.default == "function" || typeof e.default == "object" && e.default !== null) && typeof e.default.__esModule > "u" && (Object.defineProperty(e.default, "__esModule", { value: !0 }), Object.assign(e.default, e), t.exports = e.default);
594
- })(G, G.exports);
595
- var le = G.exports, H = { exports: {} };
596
- (function(t, e) {
597
- Object.defineProperty(e, "__esModule", {
598
- value: !0
599
- }), Object.defineProperty(e, "actionAsyncStorage", {
600
- enumerable: !0,
601
- get: function() {
602
- return n;
603
- }
604
- });
605
- const n = (0, re.createAsyncLocalStorage)();
606
- (typeof e.default == "function" || typeof e.default == "object" && e.default !== null) && typeof e.default.__esModule > "u" && (Object.defineProperty(e.default, "__esModule", { value: !0 }), Object.assign(e.default, e), t.exports = e.default);
607
- })(H, H.exports);
608
- var fe = H.exports, B = { exports: {} }, F = { exports: {} };
609
- (function(t, e) {
610
- Object.defineProperty(e, "__esModule", {
611
- value: !0
612
- });
613
- function r(o, u) {
614
- for (var s in u) Object.defineProperty(o, s, {
615
- enumerable: !0,
616
- get: u[s]
617
- });
618
- }
619
- r(e, {
620
- DynamicServerError: function() {
621
- return i;
622
- },
623
- isDynamicServerError: function() {
624
- return a;
625
- }
626
- });
627
- const n = "DYNAMIC_SERVER_USAGE";
628
- class i extends Error {
629
- constructor(u) {
630
- super("Dynamic server usage: " + u), this.description = u, this.digest = n;
631
- }
632
- }
633
- function a(o) {
634
- return typeof o != "object" || o === null || !("digest" in o) || typeof o.digest != "string" ? !1 : o.digest === n;
635
- }
636
- (typeof e.default == "function" || typeof e.default == "object" && e.default !== null) && typeof e.default.__esModule > "u" && (Object.defineProperty(e.default, "__esModule", { value: !0 }), Object.assign(e.default, e), t.exports = e.default);
637
- })(F, F.exports);
638
- var qe = F.exports, U = { exports: {} };
639
- (function(t, e) {
640
- Object.defineProperty(e, "__esModule", {
641
- value: !0
642
- }), Object.defineProperty(e, "staticGenerationAsyncStorage", {
643
- enumerable: !0,
644
- get: function() {
645
- return n;
646
- }
647
- });
648
- const n = (0, re.createAsyncLocalStorage)();
649
- (typeof e.default == "function" || typeof e.default == "object" && e.default !== null) && typeof e.default.__esModule > "u" && (Object.defineProperty(e.default, "__esModule", { value: !0 }), Object.assign(e.default, e), t.exports = e.default);
650
- })(U, U.exports);
651
- var de = U.exports;
652
- (function(t, e) {
653
- Object.defineProperty(e, "__esModule", {
654
- value: !0
655
- });
656
- function r(c, l) {
657
- for (var g in l) Object.defineProperty(c, g, {
658
- enumerable: !0,
659
- get: l[g]
660
- });
661
- }
662
- r(e, {
663
- isStaticGenBailoutError: function() {
664
- return u;
665
- },
666
- staticGenerationBailout: function() {
667
- return y;
668
- }
669
- });
670
- const n = qe, i = de, a = "NEXT_STATIC_GEN_BAILOUT";
671
- class o extends Error {
672
- constructor(...l) {
673
- super(...l), this.code = a;
674
- }
675
- }
676
- function u(c) {
677
- return typeof c != "object" || c === null || !("code" in c) ? !1 : c.code === a;
678
- }
679
- function s(c, l) {
680
- const { dynamic: g, link: d } = l || {}, _ = d ? " See more info here: " + d : "";
681
- return "Page" + (g ? ' with `dynamic = "' + g + '"`' : "") + " couldn't be rendered statically because it used `" + c + "`." + _;
682
- }
683
- const y = (c, l) => {
684
- let { dynamic: g, link: d } = l === void 0 ? {} : l;
685
- const _ = i.staticGenerationAsyncStorage.getStore();
686
- if (!_) return !1;
687
- if (_.forceStatic)
688
- return !0;
689
- if (_.dynamicShouldError)
690
- throw new o(s(c, {
691
- link: d,
692
- dynamic: g ?? "error"
693
- }));
694
- const f = s(c, {
695
- dynamic: g,
696
- // this error should be caught by Next to bail out of static generation
697
- // in case it's uncaught, this link provides some additional context as to why
698
- link: "https://nextjs.org/docs/messages/dynamic-server-error"
699
- });
700
- if (_.postpone == null || _.postpone.call(_, c), _.revalidate = 0, _.isStaticGeneration) {
701
- const h = new n.DynamicServerError(f);
702
- throw _.dynamicUsageDescription = c, _.dynamicUsageStack = h.stack, h;
703
- }
704
- return !1;
705
- };
706
- (typeof e.default == "function" || typeof e.default == "object" && e.default !== null) && typeof e.default.__esModule > "u" && (Object.defineProperty(e.default, "__esModule", { value: !0 }), Object.assign(e.default, e), t.exports = e.default);
707
- })(B, B.exports);
708
- var pe = B.exports, $ = { exports: {} };
709
- (function(t, e) {
710
- Object.defineProperty(e, "__esModule", {
711
- value: !0
712
- }), Object.defineProperty(e, "DraftMode", {
713
- enumerable: !0,
714
- get: function() {
715
- return n;
716
- }
717
- });
718
- const r = pe;
719
- class n {
720
- get isEnabled() {
721
- return this._provider.isEnabled;
722
- }
723
- enable() {
724
- if (!(0, r.staticGenerationBailout)("draftMode().enable()"))
725
- return this._provider.enable();
726
- }
727
- disable() {
728
- if (!(0, r.staticGenerationBailout)("draftMode().disable()"))
729
- return this._provider.disable();
730
- }
731
- constructor(a) {
732
- this._provider = a;
733
- }
734
- }
735
- (typeof e.default == "function" || typeof e.default == "object" && e.default !== null) && typeof e.default.__esModule > "u" && (Object.defineProperty(e.default, "__esModule", { value: !0 }), Object.assign(e.default, e), t.exports = e.default);
736
- })($, $.exports);
737
- var Ge = $.exports;
738
- (function(t, e) {
739
- Object.defineProperty(e, "__esModule", {
740
- value: !0
741
- });
742
- function r(d, _) {
743
- for (var f in _) Object.defineProperty(d, f, {
744
- enumerable: !0,
745
- get: _[f]
746
- });
747
- }
748
- r(e, {
749
- headers: function() {
750
- return c;
751
- },
752
- cookies: function() {
753
- return l;
754
- },
755
- draftMode: function() {
756
- return g;
757
- }
758
- });
759
- const n = ae, i = ce, a = Q, o = le, u = fe, s = pe, y = Ge;
760
- function c() {
761
- if ((0, s.staticGenerationBailout)("headers", {
762
- link: "https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering"
763
- }))
764
- return i.HeadersAdapter.seal(new Headers({}));
765
- const d = o.requestAsyncStorage.getStore();
766
- if (!d)
767
- throw new Error("Invariant: headers() expects to have requestAsyncStorage, none available.");
768
- return d.headers;
769
- }
770
- function l() {
771
- if ((0, s.staticGenerationBailout)("cookies", {
772
- link: "https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering"
773
- }))
774
- return n.RequestCookiesAdapter.seal(new a.RequestCookies(new Headers({})));
775
- const d = o.requestAsyncStorage.getStore();
776
- if (!d)
777
- throw new Error("Invariant: cookies() expects to have requestAsyncStorage, none available.");
778
- const _ = u.actionAsyncStorage.getStore();
779
- return _ && (_.isAction || _.isAppRoute) ? d.mutableCookies : d.cookies;
780
- }
781
- function g() {
782
- const d = o.requestAsyncStorage.getStore();
783
- if (!d)
784
- throw new Error("Invariant: draftMode() expects to have requestAsyncStorage, none available.");
785
- return new y.DraftMode(d.draftMode);
786
- }
787
- (typeof e.default == "function" || typeof e.default == "object" && e.default !== null) && typeof e.default.__esModule > "u" && (Object.defineProperty(e.default, "__esModule", { value: !0 }), Object.assign(e.default, e), t.exports = e.default);
788
- })(q, q.exports);
789
- var De = q.exports, He = De, V = { exports: {} }, ye = {}, I = {};
790
- I._ = I._interop_require_default = Be;
791
- function Be(t) {
792
- return t && t.__esModule ? t : { default: t };
793
- }
794
- (function(t) {
795
- "use client";
796
- Object.defineProperty(t, "__esModule", {
797
- value: !0
798
- });
799
- function e(y, c) {
800
- for (var l in c) Object.defineProperty(y, l, {
801
- enumerable: !0,
802
- get: c[l]
803
- });
804
- }
805
- e(t, {
806
- AppRouterContext: function() {
807
- return i;
808
- },
809
- LayoutRouterContext: function() {
810
- return a;
811
- },
812
- GlobalLayoutRouterContext: function() {
813
- return o;
814
- },
815
- TemplateContext: function() {
816
- return u;
817
- },
818
- MissingSlotContext: function() {
819
- return s;
820
- }
821
- });
822
- const n = /* @__PURE__ */ I._(w), i = n.default.createContext(null), a = n.default.createContext(null), o = n.default.createContext(null), u = n.default.createContext(null);
823
- process.env.NODE_ENV !== "production" && (i.displayName = "AppRouterContext", a.displayName = "LayoutRouterContext", o.displayName = "GlobalLayoutRouterContext", u.displayName = "TemplateContext");
824
- const s = n.default.createContext(/* @__PURE__ */ new Set());
825
- })(ye);
826
- var _e = {};
827
- (function(t) {
828
- "use client";
829
- Object.defineProperty(t, "__esModule", {
830
- value: !0
831
- });
832
- function e(o, u) {
833
- for (var s in u) Object.defineProperty(o, s, {
834
- enumerable: !0,
835
- get: u[s]
836
- });
837
- }
838
- e(t, {
839
- SearchParamsContext: function() {
840
- return n;
841
- },
842
- PathnameContext: function() {
843
- return i;
844
- },
845
- PathParamsContext: function() {
846
- return a;
847
- }
848
- });
849
- const r = w, n = (0, r.createContext)(null), i = (0, r.createContext)(null), a = (0, r.createContext)(null);
850
- process.env.NODE_ENV !== "production" && (n.displayName = "SearchParamsContext", i.displayName = "PathnameContext", a.displayName = "PathParamsContext");
851
- })(_e);
852
- var Y = { exports: {} };
853
- (function(t, e) {
854
- Object.defineProperty(e, "__esModule", {
855
- value: !0
856
- }), Object.defineProperty(e, "clientHookInServerComponentError", {
857
- enumerable: !0,
858
- get: function() {
859
- return i;
860
- }
861
- });
862
- const n = /* @__PURE__ */ I._(w);
863
- function i(a) {
864
- if (process.env.NODE_ENV !== "production" && !n.default.useState)
865
- throw new Error("" + a + ' only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/react-client-hook-in-server-component');
866
- }
867
- (typeof e.default == "function" || typeof e.default == "object" && e.default !== null) && typeof e.default.__esModule > "u" && (Object.defineProperty(e.default, "__esModule", { value: !0 }), Object.assign(e.default, e), t.exports = e.default);
868
- })(Y, Y.exports);
869
- var Fe = Y.exports, J = { exports: {} };
870
- (function(t, e) {
871
- Object.defineProperty(e, "__esModule", {
872
- value: !0
873
- }), Object.defineProperty(e, "getSegmentValue", {
874
- enumerable: !0,
875
- get: function() {
876
- return r;
877
- }
878
- });
879
- function r(n) {
880
- return Array.isArray(n) ? n[1] : n;
881
- }
882
- (typeof e.default == "function" || typeof e.default == "object" && e.default !== null) && typeof e.default.__esModule > "u" && (Object.defineProperty(e.default, "__esModule", { value: !0 }), Object.assign(e.default, e), t.exports = e.default);
883
- })(J, J.exports);
884
- var Ue = J.exports, ge = {};
885
- (function(t) {
886
- Object.defineProperty(t, "__esModule", {
887
- value: !0
888
- });
889
- function e(a, o) {
890
- for (var u in o) Object.defineProperty(a, u, {
891
- enumerable: !0,
892
- get: o[u]
893
- });
894
- }
895
- e(t, {
896
- isGroupSegment: function() {
897
- return r;
898
- },
899
- PAGE_SEGMENT_KEY: function() {
900
- return n;
901
- },
902
- DEFAULT_SEGMENT_KEY: function() {
903
- return i;
904
- }
905
- });
906
- function r(a) {
907
- return a[0] === "(" && a.endsWith(")");
908
- }
909
- const n = "__PAGE__", i = "__DEFAULT__";
910
- })(ge);
911
- var he = {}, W = {};
912
- function ve(t) {
913
- if (typeof WeakMap != "function") return null;
914
- var e = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap();
915
- return (ve = function(n) {
916
- return n ? r : e;
917
- })(t);
918
- }
919
- W._ = W._interop_require_wildcard = $e;
920
- function $e(t, e) {
921
- if (!e && t && t.__esModule) return t;
922
- if (t === null || typeof t != "object" && typeof t != "function") return { default: t };
923
- var r = ve(e);
924
- if (r && r.has(t)) return r.get(t);
925
- var n = {}, i = Object.defineProperty && Object.getOwnPropertyDescriptor;
926
- for (var a in t)
927
- if (a !== "default" && Object.prototype.hasOwnProperty.call(t, a)) {
928
- var o = i ? Object.getOwnPropertyDescriptor(t, a) : null;
929
- o && (o.get || o.set) ? Object.defineProperty(n, a, o) : n[a] = t[a];
930
- }
931
- return n.default = t, r && r.set(t, n), n;
932
- }
933
- (function(t) {
934
- "use client";
935
- Object.defineProperty(t, "__esModule", {
936
- value: !0
937
- });
938
- function e(o, u) {
939
- for (var s in u) Object.defineProperty(o, s, {
940
- enumerable: !0,
941
- get: u[s]
942
- });
943
- }
944
- e(t, {
945
- ServerInsertedHTMLContext: function() {
946
- return i;
947
- },
948
- useServerInsertedHTML: function() {
949
- return a;
950
- }
951
- });
952
- const n = /* @__PURE__ */ W._(w), i = /* @__PURE__ */ n.default.createContext(null);
953
- function a(o) {
954
- const u = (0, n.useContext)(i);
955
- u && u(o);
956
- }
957
- })(he);
958
- var z = { exports: {} }, X = { exports: {} };
959
- (function(t, e) {
960
- Object.defineProperty(e, "__esModule", {
961
- value: !0
962
- }), Object.defineProperty(e, "RedirectStatusCode", {
963
- enumerable: !0,
964
- get: function() {
965
- return r;
966
- }
967
- });
968
- var r;
969
- (function(n) {
970
- n[n.SeeOther = 303] = "SeeOther", n[n.TemporaryRedirect = 307] = "TemporaryRedirect", n[n.PermanentRedirect = 308] = "PermanentRedirect";
971
- })(r || (r = {})), (typeof e.default == "function" || typeof e.default == "object" && e.default !== null) && typeof e.default.__esModule > "u" && (Object.defineProperty(e.default, "__esModule", { value: !0 }), Object.assign(e.default, e), t.exports = e.default);
972
- })(X, X.exports);
973
- var Ve = X.exports;
974
- (function(t, e) {
975
- Object.defineProperty(e, "__esModule", {
976
- value: !0
977
- });
978
- function r(f, h) {
979
- for (var v in h) Object.defineProperty(f, v, {
980
- enumerable: !0,
981
- get: h[v]
982
- });
983
- }
984
- r(e, {
985
- RedirectType: function() {
986
- return u;
987
- },
988
- getRedirectError: function() {
989
- return s;
990
- },
991
- redirect: function() {
992
- return y;
993
- },
994
- permanentRedirect: function() {
995
- return c;
996
- },
997
- isRedirectError: function() {
998
- return l;
999
- },
1000
- getURLFromRedirectError: function() {
1001
- return g;
1002
- },
1003
- getRedirectTypeFromError: function() {
1004
- return d;
1005
- },
1006
- getRedirectStatusCodeFromError: function() {
1007
- return _;
1008
- }
1009
- });
1010
- const n = le, i = fe, a = Ve, o = "NEXT_REDIRECT";
1011
- var u;
1012
- (function(f) {
1013
- f.push = "push", f.replace = "replace";
1014
- })(u || (u = {}));
1015
- function s(f, h, v) {
1016
- v === void 0 && (v = a.RedirectStatusCode.TemporaryRedirect);
1017
- const C = new Error(o);
1018
- C.digest = o + ";" + h + ";" + f + ";" + v + ";";
1019
- const O = n.requestAsyncStorage.getStore();
1020
- return O && (C.mutableCookies = O.mutableCookies), C;
1021
- }
1022
- function y(f, h) {
1023
- h === void 0 && (h = "replace");
1024
- const v = i.actionAsyncStorage.getStore();
1025
- throw s(
1026
- f,
1027
- h,
1028
- // If we're in an action, we want to use a 303 redirect
1029
- // as we don't want the POST request to follow the redirect,
1030
- // as it could result in erroneous re-submissions.
1031
- v != null && v.isAction ? a.RedirectStatusCode.SeeOther : a.RedirectStatusCode.TemporaryRedirect
1032
- );
1033
- }
1034
- function c(f, h) {
1035
- h === void 0 && (h = "replace");
1036
- const v = i.actionAsyncStorage.getStore();
1037
- throw s(
1038
- f,
1039
- h,
1040
- // If we're in an action, we want to use a 303 redirect
1041
- // as we don't want the POST request to follow the redirect,
1042
- // as it could result in erroneous re-submissions.
1043
- v != null && v.isAction ? a.RedirectStatusCode.SeeOther : a.RedirectStatusCode.PermanentRedirect
1044
- );
1045
- }
1046
- function l(f) {
1047
- if (typeof f != "object" || f === null || !("digest" in f) || typeof f.digest != "string")
1048
- return !1;
1049
- const [h, v, C, O] = f.digest.split(";", 4), b = Number(O);
1050
- return h === o && (v === "replace" || v === "push") && typeof C == "string" && !isNaN(b) && b in a.RedirectStatusCode;
1051
- }
1052
- function g(f) {
1053
- return l(f) ? f.digest.split(";", 3)[2] : null;
1054
- }
1055
- function d(f) {
1056
- if (!l(f))
1057
- throw new Error("Not a redirect error");
1058
- return f.digest.split(";", 2)[1];
1059
- }
1060
- function _(f) {
1061
- if (!l(f))
1062
- throw new Error("Not a redirect error");
1063
- return Number(f.digest.split(";", 4)[3]);
1064
- }
1065
- (typeof e.default == "function" || typeof e.default == "object" && e.default !== null) && typeof e.default.__esModule > "u" && (Object.defineProperty(e.default, "__esModule", { value: !0 }), Object.assign(e.default, e), t.exports = e.default);
1066
- })(z, z.exports);
1067
- var Ye = z.exports, K = { exports: {} };
1068
- (function(t, e) {
1069
- Object.defineProperty(e, "__esModule", {
1070
- value: !0
1071
- });
1072
- function r(o, u) {
1073
- for (var s in u) Object.defineProperty(o, s, {
1074
- enumerable: !0,
1075
- get: u[s]
1076
- });
1077
- }
1078
- r(e, {
1079
- notFound: function() {
1080
- return i;
1081
- },
1082
- isNotFoundError: function() {
1083
- return a;
1084
- }
1085
- });
1086
- const n = "NEXT_NOT_FOUND";
1087
- function i() {
1088
- const o = new Error(n);
1089
- throw o.digest = n, o;
1090
- }
1091
- function a(o) {
1092
- return typeof o != "object" || o === null || !("digest" in o) ? !1 : o.digest === n;
1093
- }
1094
- (typeof e.default == "function" || typeof e.default == "object" && e.default !== null) && typeof e.default.__esModule > "u" && (Object.defineProperty(e.default, "__esModule", { value: !0 }), Object.assign(e.default, e), t.exports = e.default);
1095
- })(K, K.exports);
1096
- var Je = K.exports, x = { exports: {} }, N = {}, oe;
1097
- function We() {
1098
- return oe || (oe = 1, function(t) {
1099
- Object.defineProperty(t, "__esModule", {
1100
- value: !0
1101
- });
1102
- function e(a, o) {
1103
- for (var u in o) Object.defineProperty(a, u, {
1104
- enumerable: !0,
1105
- get: o[u]
1106
- });
1107
- }
1108
- e(t, {
1109
- BailoutToCSRError: function() {
1110
- return n;
1111
- },
1112
- isBailoutToCSRError: function() {
1113
- return i;
1114
- }
1115
- });
1116
- const r = "BAILOUT_TO_CLIENT_SIDE_RENDERING";
1117
- class n extends Error {
1118
- constructor(o) {
1119
- super("Bail out to client-side rendering: " + o), this.reason = o, this.digest = r;
1120
- }
1121
- }
1122
- function i(a) {
1123
- return typeof a != "object" || a === null || !("digest" in a) ? !1 : a.digest === r;
1124
- }
1125
- }(N)), N;
1126
- }
1127
- var ie;
1128
- function ze() {
1129
- return ie || (ie = 1, function(t, e) {
1130
- Object.defineProperty(e, "__esModule", {
1131
- value: !0
1132
- }), Object.defineProperty(e, "bailoutToClientRendering", {
1133
- enumerable: !0,
1134
- get: function() {
1135
- return i;
1136
- }
1137
- });
1138
- const r = We(), n = de;
1139
- function i(a) {
1140
- const o = n.staticGenerationAsyncStorage.getStore();
1141
- if (!(o != null && o.forceStatic) && o != null && o.isStaticGeneration)
1142
- throw new r.BailoutToCSRError(a);
1143
- }
1144
- (typeof e.default == "function" || typeof e.default == "object" && e.default !== null) && typeof e.default.__esModule > "u" && (Object.defineProperty(e.default, "__esModule", { value: !0 }), Object.assign(e.default, e), t.exports = e.default);
1145
- }(x, x.exports)), x.exports;
1146
- }
1147
- (function(t, e) {
1148
- Object.defineProperty(e, "__esModule", {
1149
- value: !0
1150
- });
1151
- function r(m, p) {
1152
- for (var R in p) Object.defineProperty(m, R, {
1153
- enumerable: !0,
1154
- get: p[R]
1155
- });
1156
- }
1157
- r(e, {
1158
- ReadonlyURLSearchParams: function() {
1159
- return _;
1160
- },
1161
- useSearchParams: function() {
1162
- return f;
1163
- },
1164
- usePathname: function() {
1165
- return h;
1166
- },
1167
- ServerInsertedHTMLContext: function() {
1168
- return y.ServerInsertedHTMLContext;
1169
- },
1170
- useServerInsertedHTML: function() {
1171
- return y.useServerInsertedHTML;
1172
- },
1173
- useRouter: function() {
1174
- return v;
1175
- },
1176
- useParams: function() {
1177
- return O;
1178
- },
1179
- useSelectedLayoutSegments: function() {
1180
- return j;
1181
- },
1182
- useSelectedLayoutSegment: function() {
1183
- return M;
1184
- },
1185
- redirect: function() {
1186
- return c.redirect;
1187
- },
1188
- permanentRedirect: function() {
1189
- return c.permanentRedirect;
1190
- },
1191
- RedirectType: function() {
1192
- return c.RedirectType;
1193
- },
1194
- notFound: function() {
1195
- return l.notFound;
1196
- }
1197
- });
1198
- const n = w, i = ye, a = _e, o = Fe, u = Ue, s = ge, y = he, c = Ye, l = Je, g = Symbol("internal for urlsearchparams readonly");
1199
- function d() {
1200
- return new Error("ReadonlyURLSearchParams cannot be modified");
1201
- }
1202
- class _ {
1203
- [Symbol.iterator]() {
1204
- return this[g][Symbol.iterator]();
1205
- }
1206
- append() {
1207
- throw d();
1208
- }
1209
- delete() {
1210
- throw d();
1211
- }
1212
- set() {
1213
- throw d();
1214
- }
1215
- sort() {
1216
- throw d();
1217
- }
1218
- constructor(p) {
1219
- this[g] = p, this.entries = p.entries.bind(p), this.forEach = p.forEach.bind(p), this.get = p.get.bind(p), this.getAll = p.getAll.bind(p), this.has = p.has.bind(p), this.keys = p.keys.bind(p), this.values = p.values.bind(p), this.toString = p.toString.bind(p), this.size = p.size;
1220
- }
1221
- }
1222
- function f() {
1223
- (0, o.clientHookInServerComponentError)("useSearchParams");
1224
- const m = (0, n.useContext)(a.SearchParamsContext), p = (0, n.useMemo)(() => m ? new _(m) : null, [
1225
- m
1226
- ]);
1227
- if (typeof window > "u") {
1228
- const { bailoutToClientRendering: R } = ze();
1229
- R("useSearchParams()");
1230
- }
1231
- return p;
1232
- }
1233
- function h() {
1234
- return (0, o.clientHookInServerComponentError)("usePathname"), (0, n.useContext)(a.PathnameContext);
1235
- }
1236
- function v() {
1237
- (0, o.clientHookInServerComponentError)("useRouter");
1238
- const m = (0, n.useContext)(i.AppRouterContext);
1239
- if (m === null)
1240
- throw new Error("invariant expected app router to be mounted");
1241
- return m;
1242
- }
1243
- function C(m, p) {
1244
- p === void 0 && (p = {});
1245
- const R = m[1];
1246
- for (const E of Object.values(R)) {
1247
- const S = E[0], A = Array.isArray(S), k = A ? S[1] : S;
1248
- if (!k || k.startsWith(s.PAGE_SEGMENT_KEY)) continue;
1249
- A && (S[2] === "c" || S[2] === "oc") ? p[S[0]] = S[1].split("/") : A && (p[S[0]] = S[1]), p = C(E, p);
1250
- }
1251
- return p;
1252
- }
1253
- function O() {
1254
- (0, o.clientHookInServerComponentError)("useParams");
1255
- const m = (0, n.useContext)(i.GlobalLayoutRouterContext), p = (0, n.useContext)(a.PathParamsContext);
1256
- return (0, n.useMemo)(() => m != null && m.tree ? C(m.tree) : p, [
1257
- m == null ? void 0 : m.tree,
1258
- p
1259
- ]);
1260
- }
1261
- function b(m, p, R, E) {
1262
- R === void 0 && (R = !0), E === void 0 && (E = []);
1263
- let S;
1264
- if (R)
1265
- S = m[1][p];
1266
- else {
1267
- const ne = m[1];
1268
- var A;
1269
- S = (A = ne.children) != null ? A : Object.values(ne)[0];
1270
- }
1271
- if (!S) return E;
1272
- const k = S[0], T = (0, u.getSegmentValue)(k);
1273
- return !T || T.startsWith(s.PAGE_SEGMENT_KEY) ? E : (E.push(T), b(S, p, !1, E));
1274
- }
1275
- function j(m) {
1276
- m === void 0 && (m = "children"), (0, o.clientHookInServerComponentError)("useSelectedLayoutSegments");
1277
- const { tree: p } = (0, n.useContext)(i.LayoutRouterContext);
1278
- return b(p, m);
1279
- }
1280
- function M(m) {
1281
- m === void 0 && (m = "children"), (0, o.clientHookInServerComponentError)("useSelectedLayoutSegment");
1282
- const p = j(m);
1283
- return p.length === 0 ? null : p[0];
1284
- }
1285
- (typeof e.default == "function" || typeof e.default == "object" && e.default !== null) && typeof e.default.__esModule > "u" && (Object.defineProperty(e.default, "__esModule", { value: !0 }), Object.assign(e.default, e), t.exports = e.default);
1286
- })(V, V.exports);
1287
- var Xe = V.exports, Ke = Xe;
1288
- function L(t, e) {
1289
- const r = {
1
+ import { draftMode as P } from "next/headers";
2
+ import { redirect as R } from "next/navigation";
3
+ import { template as I } from "radash";
4
+ function h(s, n) {
5
+ const o = {
1290
6
  // eslint-disable-next-line @typescript-eslint/naming-convention
1291
7
  "Content-Type": "text/json; charset=UTF-8"
1292
- }, n = JSON.stringify(t);
1293
- return new Response(n, {
1294
- status: e,
1295
- headers: r
8
+ }, a = JSON.stringify(s);
9
+ return new Response(a, {
10
+ status: n,
11
+ headers: o
1296
12
  });
1297
13
  }
1298
- function Qe() {
14
+ function A() {
1299
15
  return process.env.NEXT_API_DRAFT_SECRET || "";
1300
16
  }
1301
- function Ze(t) {
1302
- const { searchParams: e } = new URL(t), r = e.get("secret") || "", n = e.get("languages"), i = e.get("urls"), a = e.get("routes"), o = e.get("pk"), u = e.get("version"), s = {
17
+ function S(s) {
18
+ const { searchParams: n } = new URL(s), o = n.get("secret") || "", a = n.get("languages"), u = n.get("urls"), t = n.get("routes"), f = n.get("pk"), r = n.get("version"), c = {
1303
19
  secret: "",
1304
20
  languages: [],
1305
21
  paths: [],
@@ -1308,102 +24,102 @@ function Ze(t) {
1308
24
  pk: "",
1309
25
  version: ""
1310
26
  };
1311
- if (!r || !n || !(i || a))
1312
- return s;
1313
- const y = typeof o == "string" ? o : "", c = typeof u == "string" ? u : "";
27
+ if (!o || !a || !(u || t))
28
+ return c;
29
+ const i = typeof f == "string" ? f : "", e = typeof r == "string" ? r : "";
1314
30
  try {
1315
- const l = JSON.parse(n);
1316
- if (a) {
1317
- const d = JSON.parse(a);
31
+ const l = JSON.parse(a);
32
+ if (t) {
33
+ const m = JSON.parse(t);
1318
34
  return {
1319
- secret: r,
35
+ secret: o,
1320
36
  languages: l,
1321
37
  paths: [],
1322
- routes: d,
38
+ routes: m,
1323
39
  type: "route",
1324
- pk: y,
1325
- version: c
40
+ pk: i,
41
+ version: e
1326
42
  };
1327
43
  }
1328
- if (!i)
1329
- return s;
1330
- const g = JSON.parse(i);
44
+ if (!u)
45
+ return c;
46
+ const d = JSON.parse(u);
1331
47
  return {
1332
- secret: r,
48
+ secret: o,
1333
49
  languages: l,
1334
- paths: g,
50
+ paths: d,
1335
51
  routes: [],
1336
52
  type: "path",
1337
- pk: y,
1338
- version: c
53
+ pk: i,
54
+ version: e
1339
55
  };
1340
56
  } catch {
1341
- return s;
57
+ return c;
1342
58
  }
1343
59
  }
1344
- function et(t, e, r = 0) {
1345
- const { searchParams: n } = new URL(e), i = [...t.matchAll(/\{\{([a-z]+)\}\}/gi)], a = {};
1346
- return i.forEach((o) => {
1347
- const u = o[1] || "";
1348
- if (!u)
60
+ function J(s, n, o = 0) {
61
+ const { searchParams: a } = new URL(n), u = [...s.matchAll(/\{\{([a-z]+)\}\}/gi)], t = {};
62
+ return u.forEach((f) => {
63
+ const r = f[1] || "";
64
+ if (!r)
1349
65
  return;
1350
- const s = `${u}s`, y = n.get(s);
1351
- if (y)
66
+ const c = `${r}s`, i = a.get(c);
67
+ if (i)
1352
68
  try {
1353
- const c = JSON.parse(y);
1354
- a[u] = c[r] || "";
69
+ const e = JSON.parse(i);
70
+ t[r] = e[o] || "";
1355
71
  } catch {
1356
- a[u] = "";
72
+ t[r] = "";
1357
73
  }
1358
74
  else {
1359
- const c = n.get(u);
1360
- a[u] = c || "";
75
+ const e = a.get(r);
76
+ t[r] = e || "";
1361
77
  }
1362
- }), me(t, a);
78
+ }), I(s, t);
1363
79
  }
1364
- function nt({
1365
- url: t,
1366
- getDirectusLanguage: e,
1367
- getDraftSecret: r,
1368
- getJsonError: n
80
+ function E({
81
+ url: s,
82
+ getDirectusLanguage: n,
83
+ getDraftSecret: o,
84
+ getJsonError: a
1369
85
  }) {
1370
- const i = r || Qe, a = n || L, { secret: o, languages: u, paths: s, routes: y, type: c, version: l } = Ze(t);
1371
- if (o !== i())
1372
- return a({ error: "Invalid argument" }, 401);
1373
- if (c === "")
1374
- return a({ error: "Invalid argument" }, 400);
1375
- if (!Array.isArray(u) || u.length <= 0)
1376
- return a({ error: "Invalid languages argument" }, 400);
1377
- if (c === "path" && (!Array.isArray(s) || s.length <= 0))
1378
- return a({ error: "Invalid paths argument" }, 400);
1379
- if (c === "route" && (!Array.isArray(y) || y.length <= 0))
1380
- return a({ error: "Invalid routes argument" }, 400);
1381
- const g = e(), d = u.indexOf(g), _ = d !== -1 ? d : 0;
1382
- let f = "";
1383
- if (c === "path") {
1384
- const h = s[_] || "";
1385
- if (!h)
1386
- return L({ error: "Invalid path" }, 400);
1387
- f = h;
1388
- } else if (c === "route") {
1389
- const h = y[_] || "";
1390
- if (!h)
1391
- return L({ error: "Invalid route" }, 400);
1392
- const v = et(h, t, _);
86
+ const u = o || A, t = a || h, { secret: f, languages: r, paths: c, routes: i, type: e, version: l } = S(s);
87
+ if (f !== u())
88
+ return t({ error: "Invalid argument" }, 401);
89
+ if (e === "")
90
+ return t({ error: "Invalid argument" }, 400);
91
+ if (!Array.isArray(r) || r.length <= 0)
92
+ return t({ error: "Invalid languages argument" }, 400);
93
+ if (e === "path" && (!Array.isArray(c) || c.length <= 0))
94
+ return t({ error: "Invalid paths argument" }, 400);
95
+ if (e === "route" && (!Array.isArray(i) || i.length <= 0))
96
+ return t({ error: "Invalid routes argument" }, 400);
97
+ const d = n(), m = r.indexOf(d), y = m !== -1 ? m : 0;
98
+ let p = "";
99
+ if (e === "path") {
100
+ const g = c[y] || "";
101
+ if (!g)
102
+ return h({ error: "Invalid path" }, 400);
103
+ p = g;
104
+ } else if (e === "route") {
105
+ const g = i[y] || "";
106
+ if (!g)
107
+ return h({ error: "Invalid route" }, 400);
108
+ const v = J(g, s, y);
1393
109
  if (!v)
1394
- return L({ error: "Invalid route" }, 400);
1395
- f = v;
110
+ return h({ error: "Invalid route" }, 400);
111
+ p = v;
1396
112
  }
1397
- if (f && l) {
1398
- const h = f.indexOf("?") !== -1;
1399
- f = `${f}${h ? "&" : "?"}version=${encodeURIComponent(l)}`;
113
+ if (p && l) {
114
+ const g = p.indexOf("?") !== -1;
115
+ p = `${p}${g ? "&" : "?"}version=${encodeURIComponent(l)}`;
1400
116
  }
1401
- He.draftMode().enable(), Ke.redirect(f);
117
+ P().enable(), R(p);
1402
118
  }
1403
119
  export {
1404
- Qe as getDraftSecretDefault,
1405
- L as getJsonErrorResponse,
1406
- et as getPathFromRoute,
1407
- nt as handleDraftRoute,
1408
- Ze as parseParams
120
+ A as getDraftSecretDefault,
121
+ h as getJsonErrorResponse,
122
+ J as getPathFromRoute,
123
+ E as handleDraftRoute,
124
+ S as parseParams
1409
125
  };