@fluenti/next 0.3.0 → 0.3.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.
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { t as e } from "./chunk-DpeYiwci.js";
2
- import { existsSync as t, mkdirSync as n, watch as r, writeFileSync as i } from "node:fs";
3
- import { dirname as a, join as o, relative as s, resolve as c } from "node:path";
1
+ import { existsSync as e, mkdirSync as t, watch as n, writeFileSync as r } from "node:fs";
2
+ import { dirname as i, join as a, relative as o, resolve as s } from "node:path";
3
+ import { fileURLToPath as c } from "node:url";
4
4
  import { DEFAULT_FLUENTI_CONFIG as l, loadConfigSync as u } from "@fluenti/core/config";
5
5
  import { validateLocale as d } from "@fluenti/core";
6
6
  import { resolveLocaleCodes as f } from "@fluenti/core/internal";
7
- import { exec as p } from "node:child_process";
8
- import { createRequire as m } from "node:module";
7
+ import { createRequire as p } from "node:module";
8
+ import { exec as m } from "node:child_process";
9
9
  //#region src/read-config.ts
10
10
  function h(e, t) {
11
11
  let n;
@@ -23,26 +23,30 @@ function h(e, t) {
23
23
  }
24
24
  //#endregion
25
25
  //#region src/generate-server-module.ts
26
- function g(e, r) {
27
- if (r.serverModule) return c(e, r.serverModule);
28
- let a = c(e, r.serverModuleOutDir), o = c(a, "server.js"), l = c(a, "server.d.ts");
29
- t(a) || n(a, { recursive: !0 });
30
- let u = f(r.fluentiConfig.locales), p = r.fluentiConfig.defaultLocale ?? r.fluentiConfig.sourceLocale, m = r.fluentiConfig.compileOutDir, h = r.fluentiConfig.fallbackChain;
26
+ function g(n, i) {
27
+ if (i.serverModule) return s(n, i.serverModule);
28
+ let a = s(n, i.serverModuleOutDir), c = s(a, "server.js"), l = s(a, "server.d.ts");
29
+ e(a) || t(a, { recursive: !0 });
30
+ let u = f(i.fluentiConfig.locales), p = i.fluentiConfig.defaultLocale ?? i.fluentiConfig.sourceLocale, m = i.fluentiConfig.compileOutDir, h = i.fluentiConfig.fallbackChain, g = _(i.cookieName), y = _(p);
31
31
  for (let e of u) d(e, "next-plugin");
32
- let g = _(s(a, c(e, m))), v = u.map((e) => ` case '${e}': return import('${g}/${e}')`).join("\n"), y = h ? JSON.stringify(h) : "undefined";
33
- i(c(a, "client-provider.js"), `"use client";
32
+ let b = v(o(a, s(n, m))), x = u.map((e) => ` case '${_(e)}': return import('${b}/${e}')`).join("\n"), S = h ? JSON.stringify(h) : "undefined";
33
+ r(s(a, "client-provider.js"), `"use client";
34
34
  // Auto-generated by @fluenti/next — do not edit
35
+ // @ts-nocheck
35
36
  import { createElement } from 'react'
36
37
  import { I18nProvider } from '@fluenti/react'
37
- ${u.map((e) => `import ${e.replace(/[^a-zA-Z0-9]/g, "_")} from '${g}/${e}'`).join("\n")}
38
+ ${u.map((e) => `import ${e.replace(/[^a-zA-Z0-9]/g, "_")} from '${b}/${e}'`).join("\n")}
38
39
 
39
- const __allMessages = { ${u.map((e) => `'${e}': ${e.replace(/[^a-zA-Z0-9]/g, "_")}`).join(", ")} }
40
+ const __allMessages = { ${u.map((e) => {
41
+ let t = e.replace(/[^a-zA-Z0-9]/g, "_");
42
+ return `'${_(e)}': ${t}`;
43
+ }).join(", ")} }
40
44
 
41
45
  export function ClientI18nProvider({ locale, fallbackLocale, fallbackChain, children }) {
42
46
  return createElement(I18nProvider, { locale, fallbackLocale, messages: __allMessages, fallbackChain }, children)
43
47
  }
44
48
  `, "utf-8");
45
- let b = r.resolveLocale ? `import __resolveLocale from '${_(s(a, c(e, r.resolveLocale)))}'` : null, x = r.resolveLocale ? "resolveLocale: __resolveLocale," : `resolveLocale: async () => {
49
+ let C = i.resolveLocale ? `import __resolveLocale from '${v(o(a, s(n, i.resolveLocale)))}'` : null, w = i.resolveLocale ? "resolveLocale: __resolveLocale," : `resolveLocale: async () => {
46
50
  try {
47
51
  const { cookies, headers } = await import('next/headers')
48
52
  const [cookieStore, headerStore] = await Promise.all([cookies(), headers()])
@@ -57,7 +61,7 @@ export function ClientI18nProvider({ locale, fallbackLocale, fallbackChain, chil
57
61
  }
58
62
 
59
63
  // 2. Cookie (configurable name)
60
- const fromCookie = cookieStore.get('${r.cookieName}')?.value
64
+ const fromCookie = cookieStore.get('${g}')?.value
61
65
  if (fromCookie && __locales.includes(fromCookie)) return fromCookie
62
66
 
63
67
  // 3. Accept-Language header
@@ -72,27 +76,28 @@ export function ClientI18nProvider({ locale, fallbackLocale, fallbackChain, chil
72
76
  }
73
77
  }
74
78
 
75
- return '${p}'
79
+ return '${y}'
76
80
  } catch {
77
- return '${p}'
81
+ return '${y}'
78
82
  }
79
- },`, S = JSON.stringify(u);
80
- return i(o, `// Auto-generated by @fluenti/next — do not edit
83
+ },`, T = JSON.stringify(u);
84
+ return r(c, `// Auto-generated by @fluenti/next — do not edit
85
+ // @ts-nocheck
81
86
  import { createServerI18n } from '@fluenti/react/server'
82
87
  import { createElement } from 'react'
83
- ${b ? `${b}\n` : ""}
84
- const __locales = ${S}
88
+ ${C ? `${C}\n` : ""}
89
+ const __locales = ${T}
85
90
 
86
91
  const serverI18n = createServerI18n({
87
92
  loadMessages: async (locale) => {
88
93
  switch (locale) {
89
- ${v}
90
- default: return import('${g}/${p}')
94
+ ${x}
95
+ default: return import('${b}/${y}')
91
96
  }
92
97
  },
93
- fallbackLocale: '${p}',
94
- fallbackChain: ${y},
95
- ${x}
98
+ fallbackLocale: '${y}',
99
+ fallbackChain: ${S},
100
+ ${w}
96
101
  })
97
102
 
98
103
  export const setLocale = serverI18n.setLocale
@@ -118,7 +123,7 @@ export const NumberFormat = serverI18n.NumberFormat
118
123
  * Sets up both server-side (React.cache) and client-side (I18nProvider) i18n.
119
124
  */
120
125
  export async function I18nProvider({ locale, children }) {
121
- const activeLocale = (locale && locale.trim()) ? locale : '${p}'
126
+ const activeLocale = (locale && locale.trim()) ? locale : '${y}'
122
127
 
123
128
  // 1. Initialize server-side i18n (React.cache scoped)
124
129
  serverI18n.setLocale(activeLocale)
@@ -130,31 +135,34 @@ export async function I18nProvider({ locale, children }) {
130
135
 
131
136
  return createElement(ClientI18nProvider, {
132
137
  locale: activeLocale,
133
- fallbackLocale: '${p}',
134
- fallbackChain: ${y},
138
+ fallbackLocale: '${y}',
139
+ fallbackChain: ${S},
135
140
  }, children)
136
141
  }
137
- `, "utf-8"), i(l, "// Auto-generated by @fluenti/next — do not edit\nimport type { ReactNode, ReactElement } from 'react'\nimport type { CompileTimeT, FluentiCoreInstanceFull } from '@fluenti/core'\n\nexport declare function setLocale(locale: string): void\nexport declare function getI18n(): Promise<FluentiCoreInstanceFull & { locale: string }>\nexport declare const t: CompileTimeT\n\nexport declare function Trans(props: {\n children: ReactNode\n id?: string\n context?: string\n comment?: string\n render?: (translation: ReactNode) => ReactNode\n}): Promise<ReactElement>\n\nexport declare function Plural(props: {\n value: number\n id?: string\n context?: string\n comment?: string\n zero?: ReactNode\n one?: ReactNode\n two?: ReactNode\n few?: ReactNode\n many?: ReactNode\n other: ReactNode\n offset?: number\n}): Promise<ReactElement>\n\nexport declare function Select(props: {\n value: string\n id?: string\n context?: string\n comment?: string\n other: ReactNode\n options?: Record<string, ReactNode>\n [key: string]: ReactNode | Record<string, ReactNode> | string | undefined\n}): Promise<ReactElement>\n\nexport declare function DateTime(props: {\n value: Date | number\n style?: string\n}): Promise<ReactElement>\n\nexport declare function NumberFormat(props: {\n value: number\n style?: string\n}): Promise<ReactElement>\n\nexport declare function I18nProvider(props: {\n locale?: string\n children: ReactNode\n}): Promise<ReactElement>\n", "utf-8"), o;
142
+ `, "utf-8"), r(l, "// Auto-generated by @fluenti/next — do not edit\nimport type { ReactNode, ReactElement } from 'react'\nimport type { CompileTimeT, FluentiCoreInstanceFull } from '@fluenti/core'\n\nexport declare function setLocale(locale: string): void\nexport declare function getI18n(): Promise<FluentiCoreInstanceFull & { locale: string }>\nexport declare const t: CompileTimeT\n\nexport declare function Trans(props: {\n children: ReactNode\n id?: string\n context?: string\n comment?: string\n render?: (translation: ReactNode) => ReactNode\n}): Promise<ReactElement>\n\nexport declare function Plural(props: {\n value: number\n id?: string\n context?: string\n comment?: string\n zero?: ReactNode\n one?: ReactNode\n two?: ReactNode\n few?: ReactNode\n many?: ReactNode\n other: ReactNode\n offset?: number\n}): Promise<ReactElement>\n\nexport declare function Select(props: {\n value: string\n id?: string\n context?: string\n comment?: string\n other: ReactNode\n options?: Record<string, ReactNode>\n [key: string]: ReactNode | Record<string, ReactNode> | string | undefined\n}): Promise<ReactElement>\n\nexport declare function DateTime(props: {\n value: Date | number\n style?: string\n}): Promise<ReactElement>\n\nexport declare function NumberFormat(props: {\n value: number\n style?: string\n}): Promise<ReactElement>\n\nexport declare function I18nProvider(props: {\n locale?: string\n children: ReactNode\n}): Promise<ReactElement>\n", "utf-8"), c;
138
143
  }
139
144
  function _(e) {
145
+ return e.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
146
+ }
147
+ function v(e) {
140
148
  return e.split("\\").join("/");
141
149
  }
142
150
  //#endregion
143
151
  //#region src/dev-runner.ts
144
- function v(e) {
145
- let n = e;
152
+ function y(t) {
153
+ let n = t;
146
154
  for (;;) {
147
- let e = c(n, "node_modules/.bin/fluenti");
148
- if (t(e)) return e;
149
- let r = a(n);
155
+ let t = s(n, "node_modules/.bin/fluenti");
156
+ if (e(t)) return t;
157
+ let r = i(n);
150
158
  if (r === n) break;
151
159
  n = r;
152
160
  }
153
161
  return null;
154
162
  }
155
- async function y(e) {
163
+ async function b(e) {
156
164
  if (e.compileOnly) try {
157
- let { runCompile: t } = m(o(e.cwd, "package.json"))("@fluenti/cli");
165
+ let { runCompile: t } = p(a(e.cwd, "package.json"))("@fluenti/cli");
158
166
  await t(e.cwd), console.log("[fluenti] Compiling... done"), e.onSuccess?.();
159
167
  return;
160
168
  } catch (t) {
@@ -163,23 +171,31 @@ async function y(e) {
163
171
  console.warn("[fluenti] Compile failed:", n.message), e.onError?.(n);
164
172
  return;
165
173
  }
174
+ let t = null;
166
175
  try {
167
- let { runExtract: t, runCompile: n } = m(o(e.cwd, "package.json"))("@fluenti/cli");
168
- await t(e.cwd), await n(e.cwd, { parallel: e.parallelCompile }), console.log("[fluenti] Extracting and compiling... done"), e.onSuccess?.();
169
- return;
176
+ t = p(a(e.cwd, "package.json"))("@fluenti/cli");
170
177
  } catch {}
171
- let t = v(e.cwd);
172
- if (!t) {
178
+ if (t) try {
179
+ await t.runExtract(e.cwd), e.parallelCompile ? await t.runCompile(e.cwd, { parallel: !0 }) : await t.runCompile(e.cwd), console.log("[fluenti] Extracting and compiling... done"), e.onSuccess?.();
180
+ return;
181
+ } catch (t) {
182
+ let n = t instanceof Error ? t : Error(String(t));
183
+ if (e.throwOnError) throw n;
184
+ console.warn("[fluenti] Extract/compile failed:", n.message), e.onError?.(n);
185
+ return;
186
+ }
187
+ let n = y(e.cwd);
188
+ if (!n) {
173
189
  let t = "[fluenti] CLI not found — skipping auto-compile. Install @fluenti/cli as a devDependency.";
174
190
  return e.throwOnError ? Promise.reject(Error(t)) : (console.warn(t), Promise.resolve());
175
191
  }
176
- let n = `${t} extract && ${t} compile${e.parallelCompile ? " --parallel" : ""}`;
177
- return new Promise((t, r) => {
178
- p(n, { cwd: e.cwd }, (n, i, a) => {
179
- if (n) {
180
- let t = Error(a || n.message);
192
+ let r = `${n} extract && ${n} compile${e.parallelCompile ? " --parallel" : ""}`;
193
+ return new Promise((t, n) => {
194
+ m(r, { cwd: e.cwd }, (r, i, a) => {
195
+ if (r) {
196
+ let t = Error(a || r.message);
181
197
  if (e.throwOnError) {
182
- r(t);
198
+ n(t);
183
199
  return;
184
200
  }
185
201
  console.warn("[fluenti] Extract/compile failed:", t.message), e.onError?.(t);
@@ -188,12 +204,12 @@ async function y(e) {
188
204
  });
189
205
  });
190
206
  }
191
- function b(e, t = 300) {
207
+ function x(e, t = 300) {
192
208
  let n = null, r = !1, i = !1;
193
209
  async function a() {
194
210
  r = !0;
195
211
  try {
196
- await y(e);
212
+ await b(e);
197
213
  } finally {
198
214
  r = !1, i && (i = !1, o());
199
215
  }
@@ -206,959 +222,41 @@ function b(e, t = 300) {
206
222
  return o;
207
223
  }
208
224
  //#endregion
209
- //#region ../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js
210
- var x = /* @__PURE__ */ e(((e, t) => {
211
- var n = "\\\\/", r = `[^${n}]`, i = "\\.", a = "\\+", o = "\\?", s = "\\/", c = "(?=.)", l = "[^/]", u = `(?:${s}|$)`, d = `(?:^|${s})`, f = `${i}{1,2}${u}`, p = {
212
- DOT_LITERAL: i,
213
- PLUS_LITERAL: a,
214
- QMARK_LITERAL: o,
215
- SLASH_LITERAL: s,
216
- ONE_CHAR: c,
217
- QMARK: l,
218
- END_ANCHOR: u,
219
- DOTS_SLASH: f,
220
- NO_DOT: `(?!${i})`,
221
- NO_DOTS: `(?!${d}${f})`,
222
- NO_DOT_SLASH: `(?!${i}{0,1}${u})`,
223
- NO_DOTS_SLASH: `(?!${f})`,
224
- QMARK_NO_DOT: `[^.${s}]`,
225
- STAR: `${l}*?`,
226
- START_ANCHOR: d,
227
- SEP: "/"
228
- }, m = {
229
- ...p,
230
- SLASH_LITERAL: `[${n}]`,
231
- QMARK: r,
232
- STAR: `${r}*?`,
233
- DOTS_SLASH: `${i}{1,2}(?:[${n}]|$)`,
234
- NO_DOT: `(?!${i})`,
235
- NO_DOTS: `(?!(?:^|[${n}])${i}{1,2}(?:[${n}]|$))`,
236
- NO_DOT_SLASH: `(?!${i}{0,1}(?:[${n}]|$))`,
237
- NO_DOTS_SLASH: `(?!${i}{1,2}(?:[${n}]|$))`,
238
- QMARK_NO_DOT: `[^.${n}]`,
239
- START_ANCHOR: `(?:^|[${n}])`,
240
- END_ANCHOR: `(?:[${n}]|$)`,
241
- SEP: "\\"
242
- };
243
- t.exports = {
244
- MAX_LENGTH: 1024 * 64,
245
- POSIX_REGEX_SOURCE: {
246
- alnum: "a-zA-Z0-9",
247
- alpha: "a-zA-Z",
248
- ascii: "\\x00-\\x7F",
249
- blank: " \\t",
250
- cntrl: "\\x00-\\x1F\\x7F",
251
- digit: "0-9",
252
- graph: "\\x21-\\x7E",
253
- lower: "a-z",
254
- print: "\\x20-\\x7E ",
255
- punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
256
- space: " \\t\\r\\n\\v\\f",
257
- upper: "A-Z",
258
- word: "A-Za-z0-9_",
259
- xdigit: "A-Fa-f0-9"
260
- },
261
- REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
262
- REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
263
- REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
264
- REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
265
- REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
266
- REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
267
- REPLACEMENTS: {
268
- __proto__: null,
269
- "***": "*",
270
- "**/**": "**",
271
- "**/**/**": "**"
272
- },
273
- CHAR_0: 48,
274
- CHAR_9: 57,
275
- CHAR_UPPERCASE_A: 65,
276
- CHAR_LOWERCASE_A: 97,
277
- CHAR_UPPERCASE_Z: 90,
278
- CHAR_LOWERCASE_Z: 122,
279
- CHAR_LEFT_PARENTHESES: 40,
280
- CHAR_RIGHT_PARENTHESES: 41,
281
- CHAR_ASTERISK: 42,
282
- CHAR_AMPERSAND: 38,
283
- CHAR_AT: 64,
284
- CHAR_BACKWARD_SLASH: 92,
285
- CHAR_CARRIAGE_RETURN: 13,
286
- CHAR_CIRCUMFLEX_ACCENT: 94,
287
- CHAR_COLON: 58,
288
- CHAR_COMMA: 44,
289
- CHAR_DOT: 46,
290
- CHAR_DOUBLE_QUOTE: 34,
291
- CHAR_EQUAL: 61,
292
- CHAR_EXCLAMATION_MARK: 33,
293
- CHAR_FORM_FEED: 12,
294
- CHAR_FORWARD_SLASH: 47,
295
- CHAR_GRAVE_ACCENT: 96,
296
- CHAR_HASH: 35,
297
- CHAR_HYPHEN_MINUS: 45,
298
- CHAR_LEFT_ANGLE_BRACKET: 60,
299
- CHAR_LEFT_CURLY_BRACE: 123,
300
- CHAR_LEFT_SQUARE_BRACKET: 91,
301
- CHAR_LINE_FEED: 10,
302
- CHAR_NO_BREAK_SPACE: 160,
303
- CHAR_PERCENT: 37,
304
- CHAR_PLUS: 43,
305
- CHAR_QUESTION_MARK: 63,
306
- CHAR_RIGHT_ANGLE_BRACKET: 62,
307
- CHAR_RIGHT_CURLY_BRACE: 125,
308
- CHAR_RIGHT_SQUARE_BRACKET: 93,
309
- CHAR_SEMICOLON: 59,
310
- CHAR_SINGLE_QUOTE: 39,
311
- CHAR_SPACE: 32,
312
- CHAR_TAB: 9,
313
- CHAR_UNDERSCORE: 95,
314
- CHAR_VERTICAL_LINE: 124,
315
- CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
316
- extglobChars(e) {
317
- return {
318
- "!": {
319
- type: "negate",
320
- open: "(?:(?!(?:",
321
- close: `))${e.STAR})`
322
- },
323
- "?": {
324
- type: "qmark",
325
- open: "(?:",
326
- close: ")?"
327
- },
328
- "+": {
329
- type: "plus",
330
- open: "(?:",
331
- close: ")+"
332
- },
333
- "*": {
334
- type: "star",
335
- open: "(?:",
336
- close: ")*"
337
- },
338
- "@": {
339
- type: "at",
340
- open: "(?:",
341
- close: ")"
342
- }
343
- };
344
- },
345
- globChars(e) {
346
- return e === !0 ? m : p;
347
- }
348
- };
349
- })), S = /* @__PURE__ */ e(((e) => {
350
- var { REGEX_BACKSLASH: t, REGEX_REMOVE_BACKSLASH: n, REGEX_SPECIAL_CHARS: r, REGEX_SPECIAL_CHARS_GLOBAL: i } = x();
351
- e.isObject = (e) => typeof e == "object" && !!e && !Array.isArray(e), e.hasRegexChars = (e) => r.test(e), e.isRegexChar = (t) => t.length === 1 && e.hasRegexChars(t), e.escapeRegex = (e) => e.replace(i, "\\$1"), e.toPosixSlashes = (e) => e.replace(t, "/"), e.isWindows = () => {
352
- if (typeof navigator < "u" && navigator.platform) {
353
- let e = navigator.platform.toLowerCase();
354
- return e === "win32" || e === "windows";
355
- }
356
- return typeof process < "u" && process.platform ? process.platform === "win32" : !1;
357
- }, e.removeBackslashes = (e) => e.replace(n, (e) => e === "\\" ? "" : e), e.escapeLast = (t, n, r) => {
358
- let i = t.lastIndexOf(n, r);
359
- return i === -1 ? t : t[i - 1] === "\\" ? e.escapeLast(t, n, i - 1) : `${t.slice(0, i)}\\${t.slice(i)}`;
360
- }, e.removePrefix = (e, t = {}) => {
361
- let n = e;
362
- return n.startsWith("./") && (n = n.slice(2), t.prefix = "./"), n;
363
- }, e.wrapOutput = (e, t = {}, n = {}) => {
364
- let r = `${n.contains ? "" : "^"}(?:${e})${n.contains ? "" : "$"}`;
365
- return t.negated === !0 && (r = `(?:^(?!${r}).*$)`), r;
366
- }, e.basename = (e, { windows: t } = {}) => {
367
- let n = e.split(t ? /[\\/]/ : "/"), r = n[n.length - 1];
368
- return r === "" ? n[n.length - 2] : r;
369
- };
370
- })), C = /* @__PURE__ */ e(((e, t) => {
371
- var n = S(), { CHAR_ASTERISK: r, CHAR_AT: i, CHAR_BACKWARD_SLASH: a, CHAR_COMMA: o, CHAR_DOT: s, CHAR_EXCLAMATION_MARK: c, CHAR_FORWARD_SLASH: l, CHAR_LEFT_CURLY_BRACE: u, CHAR_LEFT_PARENTHESES: d, CHAR_LEFT_SQUARE_BRACKET: f, CHAR_PLUS: p, CHAR_QUESTION_MARK: m, CHAR_RIGHT_CURLY_BRACE: h, CHAR_RIGHT_PARENTHESES: g, CHAR_RIGHT_SQUARE_BRACKET: _ } = x(), v = (e) => e === l || e === a, y = (e) => {
372
- e.isPrefix !== !0 && (e.depth = e.isGlobstar ? Infinity : 1);
373
- };
374
- t.exports = (e, t) => {
375
- let b = t || {}, x = e.length - 1, S = b.parts === !0 || b.scanToEnd === !0, C = [], w = [], T = [], E = e, D = -1, O = 0, k = 0, A = !1, j = !1, M = !1, N = !1, P = !1, F = !1, I = !1, L = !1, R = !1, z = !1, B = 0, V, H, U = {
376
- value: "",
377
- depth: 0,
378
- isGlob: !1
379
- }, W = () => D >= x, G = () => E.charCodeAt(D + 1), K = () => (V = H, E.charCodeAt(++D));
380
- for (; D < x;) {
381
- H = K();
382
- let e;
383
- if (H === a) {
384
- I = U.backslashes = !0, H = K(), H === u && (F = !0);
385
- continue;
386
- }
387
- if (F === !0 || H === u) {
388
- for (B++; W() !== !0 && (H = K());) {
389
- if (H === a) {
390
- I = U.backslashes = !0, K();
391
- continue;
392
- }
393
- if (H === u) {
394
- B++;
395
- continue;
396
- }
397
- if (F !== !0 && H === s && (H = K()) === s) {
398
- if (A = U.isBrace = !0, M = U.isGlob = !0, z = !0, S === !0) continue;
399
- break;
400
- }
401
- if (F !== !0 && H === o) {
402
- if (A = U.isBrace = !0, M = U.isGlob = !0, z = !0, S === !0) continue;
403
- break;
404
- }
405
- if (H === h && (B--, B === 0)) {
406
- F = !1, A = U.isBrace = !0, z = !0;
407
- break;
408
- }
409
- }
410
- if (S === !0) continue;
411
- break;
412
- }
413
- if (H === l) {
414
- if (C.push(D), w.push(U), U = {
415
- value: "",
416
- depth: 0,
417
- isGlob: !1
418
- }, z === !0) continue;
419
- if (V === s && D === O + 1) {
420
- O += 2;
421
- continue;
422
- }
423
- k = D + 1;
424
- continue;
425
- }
426
- if (b.noext !== !0 && (H === p || H === i || H === r || H === m || H === c) && G() === d) {
427
- if (M = U.isGlob = !0, N = U.isExtglob = !0, z = !0, H === c && D === O && (R = !0), S === !0) {
428
- for (; W() !== !0 && (H = K());) {
429
- if (H === a) {
430
- I = U.backslashes = !0, H = K();
431
- continue;
432
- }
433
- if (H === g) {
434
- M = U.isGlob = !0, z = !0;
435
- break;
436
- }
437
- }
438
- continue;
439
- }
440
- break;
441
- }
442
- if (H === r) {
443
- if (V === r && (P = U.isGlobstar = !0), M = U.isGlob = !0, z = !0, S === !0) continue;
444
- break;
445
- }
446
- if (H === m) {
447
- if (M = U.isGlob = !0, z = !0, S === !0) continue;
448
- break;
449
- }
450
- if (H === f) {
451
- for (; W() !== !0 && (e = K());) {
452
- if (e === a) {
453
- I = U.backslashes = !0, K();
454
- continue;
455
- }
456
- if (e === _) {
457
- j = U.isBracket = !0, M = U.isGlob = !0, z = !0;
458
- break;
459
- }
460
- }
461
- if (S === !0) continue;
462
- break;
463
- }
464
- if (b.nonegate !== !0 && H === c && D === O) {
465
- L = U.negated = !0, O++;
466
- continue;
467
- }
468
- if (b.noparen !== !0 && H === d) {
469
- if (M = U.isGlob = !0, S === !0) {
470
- for (; W() !== !0 && (H = K());) {
471
- if (H === d) {
472
- I = U.backslashes = !0, H = K();
473
- continue;
474
- }
475
- if (H === g) {
476
- z = !0;
477
- break;
478
- }
479
- }
480
- continue;
481
- }
482
- break;
483
- }
484
- if (M === !0) {
485
- if (z = !0, S === !0) continue;
486
- break;
487
- }
488
- }
489
- b.noext === !0 && (N = !1, M = !1);
490
- let q = E, J = "", Y = "";
491
- O > 0 && (J = E.slice(0, O), E = E.slice(O), k -= O), q && M === !0 && k > 0 ? (q = E.slice(0, k), Y = E.slice(k)) : M === !0 ? (q = "", Y = E) : q = E, q && q !== "" && q !== "/" && q !== E && v(q.charCodeAt(q.length - 1)) && (q = q.slice(0, -1)), b.unescape === !0 && (Y &&= n.removeBackslashes(Y), q && I === !0 && (q = n.removeBackslashes(q)));
492
- let X = {
493
- prefix: J,
494
- input: e,
495
- start: O,
496
- base: q,
497
- glob: Y,
498
- isBrace: A,
499
- isBracket: j,
500
- isGlob: M,
501
- isExtglob: N,
502
- isGlobstar: P,
503
- negated: L,
504
- negatedExtglob: R
505
- };
506
- if (b.tokens === !0 && (X.maxDepth = 0, v(H) || w.push(U), X.tokens = w), b.parts === !0 || b.tokens === !0) {
507
- let t;
508
- for (let n = 0; n < C.length; n++) {
509
- let r = t ? t + 1 : O, i = C[n], a = e.slice(r, i);
510
- b.tokens && (n === 0 && O !== 0 ? (w[n].isPrefix = !0, w[n].value = J) : w[n].value = a, y(w[n]), X.maxDepth += w[n].depth), (n !== 0 || a !== "") && T.push(a), t = i;
511
- }
512
- if (t && t + 1 < e.length) {
513
- let n = e.slice(t + 1);
514
- T.push(n), b.tokens && (w[w.length - 1].value = n, y(w[w.length - 1]), X.maxDepth += w[w.length - 1].depth);
515
- }
516
- X.slashes = C, X.parts = T;
517
- }
518
- return X;
519
- };
520
- })), w = /* @__PURE__ */ e(((e, t) => {
521
- var n = x(), r = S(), { MAX_LENGTH: i, POSIX_REGEX_SOURCE: a, REGEX_NON_SPECIAL_CHARS: o, REGEX_SPECIAL_CHARS_BACKREF: s, REPLACEMENTS: c } = n, l = (e, t) => {
522
- if (typeof t.expandRange == "function") return t.expandRange(...e, t);
523
- e.sort();
524
- let n = `[${e.join("-")}]`;
525
- try {
526
- new RegExp(n);
527
- } catch {
528
- return e.map((e) => r.escapeRegex(e)).join("..");
529
- }
530
- return n;
531
- }, u = (e, t) => `Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`, d = (e, t) => {
532
- if (typeof e != "string") throw TypeError("Expected a string");
533
- e = c[e] || e;
534
- let f = { ...t }, p = typeof f.maxLength == "number" ? Math.min(i, f.maxLength) : i, m = e.length;
535
- if (m > p) throw SyntaxError(`Input length: ${m}, exceeds maximum allowed length: ${p}`);
536
- let h = {
537
- type: "bos",
538
- value: "",
539
- output: f.prepend || ""
540
- }, g = [h], _ = f.capture ? "" : "?:", v = n.globChars(f.windows), y = n.extglobChars(v), { DOT_LITERAL: b, PLUS_LITERAL: x, SLASH_LITERAL: S, ONE_CHAR: C, DOTS_SLASH: w, NO_DOT: T, NO_DOT_SLASH: E, NO_DOTS_SLASH: D, QMARK: O, QMARK_NO_DOT: k, STAR: A, START_ANCHOR: j } = v, M = (e) => `(${_}(?:(?!${j}${e.dot ? w : b}).)*?)`, N = f.dot ? "" : T, P = f.dot ? O : k, F = f.bash === !0 ? M(f) : A;
541
- f.capture && (F = `(${F})`), typeof f.noext == "boolean" && (f.noextglob = f.noext);
542
- let I = {
543
- input: e,
544
- index: -1,
545
- start: 0,
546
- dot: f.dot === !0,
547
- consumed: "",
548
- output: "",
549
- prefix: "",
550
- backtrack: !1,
551
- negated: !1,
552
- brackets: 0,
553
- braces: 0,
554
- parens: 0,
555
- quotes: 0,
556
- globstar: !1,
557
- tokens: g
558
- };
559
- e = r.removePrefix(e, I), m = e.length;
560
- let L = [], R = [], z = [], B = h, V, H = () => I.index === m - 1, U = I.peek = (t = 1) => e[I.index + t], W = I.advance = () => e[++I.index] || "", G = () => e.slice(I.index + 1), K = (e = "", t = 0) => {
561
- I.consumed += e, I.index += t;
562
- }, q = (e) => {
563
- I.output += e.output == null ? e.value : e.output, K(e.value);
564
- }, J = () => {
565
- let e = 1;
566
- for (; U() === "!" && (U(2) !== "(" || U(3) === "?");) W(), I.start++, e++;
567
- return e % 2 == 0 ? !1 : (I.negated = !0, I.start++, !0);
568
- }, Y = (e) => {
569
- I[e]++, z.push(e);
570
- }, X = (e) => {
571
- I[e]--, z.pop();
572
- }, Z = (e) => {
573
- if (B.type === "globstar") {
574
- let t = I.braces > 0 && (e.type === "comma" || e.type === "brace"), n = e.extglob === !0 || L.length && (e.type === "pipe" || e.type === "paren");
575
- e.type !== "slash" && e.type !== "paren" && !t && !n && (I.output = I.output.slice(0, -B.output.length), B.type = "star", B.value = "*", B.output = F, I.output += B.output);
576
- }
577
- if (L.length && e.type !== "paren" && (L[L.length - 1].inner += e.value), (e.value || e.output) && q(e), B && B.type === "text" && e.type === "text") {
578
- B.output = (B.output || B.value) + e.value, B.value += e.value;
579
- return;
580
- }
581
- e.prev = B, g.push(e), B = e;
582
- }, Q = (e, t) => {
583
- let n = {
584
- ...y[t],
585
- conditions: 1,
586
- inner: ""
587
- };
588
- n.prev = B, n.parens = I.parens, n.output = I.output;
589
- let r = (f.capture ? "(" : "") + n.open;
590
- Y("parens"), Z({
591
- type: e,
592
- value: t,
593
- output: I.output ? "" : C
594
- }), Z({
595
- type: "paren",
596
- extglob: !0,
597
- value: W(),
598
- output: r
599
- }), L.push(n);
600
- }, $ = (e) => {
601
- let n = e.close + (f.capture ? ")" : ""), r;
602
- if (e.type === "negate") {
603
- let i = F;
604
- e.inner && e.inner.length > 1 && e.inner.includes("/") && (i = M(f)), (i !== F || H() || /^\)+$/.test(G())) && (n = e.close = `)$))${i}`), e.inner.includes("*") && (r = G()) && /^\.[^\\/.]+$/.test(r) && (n = e.close = `)${d(r, {
605
- ...t,
606
- fastpaths: !1
607
- }).output})${i})`), e.prev.type === "bos" && (I.negatedExtglob = !0);
608
- }
609
- Z({
610
- type: "paren",
611
- extglob: !0,
612
- value: V,
613
- output: n
614
- }), X("parens");
615
- };
616
- if (f.fastpaths !== !1 && !/(^[*!]|[/()[\]{}"])/.test(e)) {
617
- let n = !1, i = e.replace(s, (e, t, r, i, a, o) => i === "\\" ? (n = !0, e) : i === "?" ? t ? t + i + (a ? O.repeat(a.length) : "") : o === 0 ? P + (a ? O.repeat(a.length) : "") : O.repeat(r.length) : i === "." ? b.repeat(r.length) : i === "*" ? t ? t + i + (a ? F : "") : F : t ? e : `\\${e}`);
618
- return n === !0 && (i = f.unescape === !0 ? i.replace(/\\/g, "") : i.replace(/\\+/g, (e) => e.length % 2 == 0 ? "\\\\" : e ? "\\" : "")), i === e && f.contains === !0 ? (I.output = e, I) : (I.output = r.wrapOutput(i, I, t), I);
619
- }
620
- for (; !H();) {
621
- if (V = W(), V === "\0") continue;
622
- if (V === "\\") {
623
- let e = U();
624
- if (e === "/" && f.bash !== !0 || e === "." || e === ";") continue;
625
- if (!e) {
626
- V += "\\", Z({
627
- type: "text",
628
- value: V
629
- });
630
- continue;
631
- }
632
- let t = /^\\+/.exec(G()), n = 0;
633
- if (t && t[0].length > 2 && (n = t[0].length, I.index += n, n % 2 != 0 && (V += "\\")), f.unescape === !0 ? V = W() : V += W(), I.brackets === 0) {
634
- Z({
635
- type: "text",
636
- value: V
637
- });
638
- continue;
639
- }
640
- }
641
- if (I.brackets > 0 && (V !== "]" || B.value === "[" || B.value === "[^")) {
642
- if (f.posix !== !1 && V === ":") {
643
- let e = B.value.slice(1);
644
- if (e.includes("[") && (B.posix = !0, e.includes(":"))) {
645
- let e = B.value.lastIndexOf("["), t = B.value.slice(0, e), n = a[B.value.slice(e + 2)];
646
- if (n) {
647
- B.value = t + n, I.backtrack = !0, W(), !h.output && g.indexOf(B) === 1 && (h.output = C);
648
- continue;
649
- }
650
- }
651
- }
652
- (V === "[" && U() !== ":" || V === "-" && U() === "]") && (V = `\\${V}`), V === "]" && (B.value === "[" || B.value === "[^") && (V = `\\${V}`), f.posix === !0 && V === "!" && B.value === "[" && (V = "^"), B.value += V, q({ value: V });
653
- continue;
654
- }
655
- if (I.quotes === 1 && V !== "\"") {
656
- V = r.escapeRegex(V), B.value += V, q({ value: V });
657
- continue;
658
- }
659
- if (V === "\"") {
660
- I.quotes = I.quotes === 1 ? 0 : 1, f.keepQuotes === !0 && Z({
661
- type: "text",
662
- value: V
663
- });
664
- continue;
665
- }
666
- if (V === "(") {
667
- Y("parens"), Z({
668
- type: "paren",
669
- value: V
670
- });
671
- continue;
672
- }
673
- if (V === ")") {
674
- if (I.parens === 0 && f.strictBrackets === !0) throw SyntaxError(u("opening", "("));
675
- let e = L[L.length - 1];
676
- if (e && I.parens === e.parens + 1) {
677
- $(L.pop());
678
- continue;
679
- }
680
- Z({
681
- type: "paren",
682
- value: V,
683
- output: I.parens ? ")" : "\\)"
684
- }), X("parens");
685
- continue;
686
- }
687
- if (V === "[") {
688
- if (f.nobracket === !0 || !G().includes("]")) {
689
- if (f.nobracket !== !0 && f.strictBrackets === !0) throw SyntaxError(u("closing", "]"));
690
- V = `\\${V}`;
691
- } else Y("brackets");
692
- Z({
693
- type: "bracket",
694
- value: V
695
- });
696
- continue;
697
- }
698
- if (V === "]") {
699
- if (f.nobracket === !0 || B && B.type === "bracket" && B.value.length === 1) {
700
- Z({
701
- type: "text",
702
- value: V,
703
- output: `\\${V}`
704
- });
705
- continue;
706
- }
707
- if (I.brackets === 0) {
708
- if (f.strictBrackets === !0) throw SyntaxError(u("opening", "["));
709
- Z({
710
- type: "text",
711
- value: V,
712
- output: `\\${V}`
713
- });
714
- continue;
715
- }
716
- X("brackets");
717
- let e = B.value.slice(1);
718
- if (B.posix !== !0 && e[0] === "^" && !e.includes("/") && (V = `/${V}`), B.value += V, q({ value: V }), f.literalBrackets === !1 || r.hasRegexChars(e)) continue;
719
- let t = r.escapeRegex(B.value);
720
- if (I.output = I.output.slice(0, -B.value.length), f.literalBrackets === !0) {
721
- I.output += t, B.value = t;
722
- continue;
723
- }
724
- B.value = `(${_}${t}|${B.value})`, I.output += B.value;
725
- continue;
726
- }
727
- if (V === "{" && f.nobrace !== !0) {
728
- Y("braces");
729
- let e = {
730
- type: "brace",
731
- value: V,
732
- output: "(",
733
- outputIndex: I.output.length,
734
- tokensIndex: I.tokens.length
735
- };
736
- R.push(e), Z(e);
737
- continue;
738
- }
739
- if (V === "}") {
740
- let e = R[R.length - 1];
741
- if (f.nobrace === !0 || !e) {
742
- Z({
743
- type: "text",
744
- value: V,
745
- output: V
746
- });
747
- continue;
748
- }
749
- let t = ")";
750
- if (e.dots === !0) {
751
- let e = g.slice(), n = [];
752
- for (let t = e.length - 1; t >= 0 && (g.pop(), e[t].type !== "brace"); t--) e[t].type !== "dots" && n.unshift(e[t].value);
753
- t = l(n, f), I.backtrack = !0;
754
- }
755
- if (e.comma !== !0 && e.dots !== !0) {
756
- let n = I.output.slice(0, e.outputIndex), r = I.tokens.slice(e.tokensIndex);
757
- e.value = e.output = "\\{", V = t = "\\}", I.output = n;
758
- for (let e of r) I.output += e.output || e.value;
759
- }
760
- Z({
761
- type: "brace",
762
- value: V,
763
- output: t
764
- }), X("braces"), R.pop();
765
- continue;
766
- }
767
- if (V === "|") {
768
- L.length > 0 && L[L.length - 1].conditions++, Z({
769
- type: "text",
770
- value: V
771
- });
772
- continue;
773
- }
774
- if (V === ",") {
775
- let e = V, t = R[R.length - 1];
776
- t && z[z.length - 1] === "braces" && (t.comma = !0, e = "|"), Z({
777
- type: "comma",
778
- value: V,
779
- output: e
780
- });
781
- continue;
782
- }
783
- if (V === "/") {
784
- if (B.type === "dot" && I.index === I.start + 1) {
785
- I.start = I.index + 1, I.consumed = "", I.output = "", g.pop(), B = h;
786
- continue;
787
- }
788
- Z({
789
- type: "slash",
790
- value: V,
791
- output: S
792
- });
793
- continue;
794
- }
795
- if (V === ".") {
796
- if (I.braces > 0 && B.type === "dot") {
797
- B.value === "." && (B.output = b);
798
- let e = R[R.length - 1];
799
- B.type = "dots", B.output += V, B.value += V, e.dots = !0;
800
- continue;
801
- }
802
- if (I.braces + I.parens === 0 && B.type !== "bos" && B.type !== "slash") {
803
- Z({
804
- type: "text",
805
- value: V,
806
- output: b
807
- });
808
- continue;
809
- }
810
- Z({
811
- type: "dot",
812
- value: V,
813
- output: b
814
- });
815
- continue;
816
- }
817
- if (V === "?") {
818
- if (!(B && B.value === "(") && f.noextglob !== !0 && U() === "(" && U(2) !== "?") {
819
- Q("qmark", V);
820
- continue;
821
- }
822
- if (B && B.type === "paren") {
823
- let e = U(), t = V;
824
- (B.value === "(" && !/[!=<:]/.test(e) || e === "<" && !/<([!=]|\w+>)/.test(G())) && (t = `\\${V}`), Z({
825
- type: "text",
826
- value: V,
827
- output: t
828
- });
829
- continue;
830
- }
831
- if (f.dot !== !0 && (B.type === "slash" || B.type === "bos")) {
832
- Z({
833
- type: "qmark",
834
- value: V,
835
- output: k
836
- });
837
- continue;
838
- }
839
- Z({
840
- type: "qmark",
841
- value: V,
842
- output: O
843
- });
844
- continue;
845
- }
846
- if (V === "!") {
847
- if (f.noextglob !== !0 && U() === "(" && (U(2) !== "?" || !/[!=<:]/.test(U(3)))) {
848
- Q("negate", V);
849
- continue;
850
- }
851
- if (f.nonegate !== !0 && I.index === 0) {
852
- J();
853
- continue;
854
- }
855
- }
856
- if (V === "+") {
857
- if (f.noextglob !== !0 && U() === "(" && U(2) !== "?") {
858
- Q("plus", V);
859
- continue;
860
- }
861
- if (B && B.value === "(" || f.regex === !1) {
862
- Z({
863
- type: "plus",
864
- value: V,
865
- output: x
866
- });
867
- continue;
868
- }
869
- if (B && (B.type === "bracket" || B.type === "paren" || B.type === "brace") || I.parens > 0) {
870
- Z({
871
- type: "plus",
872
- value: V
873
- });
874
- continue;
875
- }
876
- Z({
877
- type: "plus",
878
- value: x
879
- });
880
- continue;
881
- }
882
- if (V === "@") {
883
- if (f.noextglob !== !0 && U() === "(" && U(2) !== "?") {
884
- Z({
885
- type: "at",
886
- extglob: !0,
887
- value: V,
888
- output: ""
889
- });
890
- continue;
891
- }
892
- Z({
893
- type: "text",
894
- value: V
895
- });
896
- continue;
897
- }
898
- if (V !== "*") {
899
- (V === "$" || V === "^") && (V = `\\${V}`);
900
- let e = o.exec(G());
901
- e && (V += e[0], I.index += e[0].length), Z({
902
- type: "text",
903
- value: V
904
- });
905
- continue;
906
- }
907
- if (B && (B.type === "globstar" || B.star === !0)) {
908
- B.type = "star", B.star = !0, B.value += V, B.output = F, I.backtrack = !0, I.globstar = !0, K(V);
909
- continue;
910
- }
911
- let t = G();
912
- if (f.noextglob !== !0 && /^\([^?]/.test(t)) {
913
- Q("star", V);
914
- continue;
915
- }
916
- if (B.type === "star") {
917
- if (f.noglobstar === !0) {
918
- K(V);
919
- continue;
920
- }
921
- let n = B.prev, r = n.prev, i = n.type === "slash" || n.type === "bos", a = r && (r.type === "star" || r.type === "globstar");
922
- if (f.bash === !0 && (!i || t[0] && t[0] !== "/")) {
923
- Z({
924
- type: "star",
925
- value: V,
926
- output: ""
927
- });
928
- continue;
929
- }
930
- let o = I.braces > 0 && (n.type === "comma" || n.type === "brace"), s = L.length && (n.type === "pipe" || n.type === "paren");
931
- if (!i && n.type !== "paren" && !o && !s) {
932
- Z({
933
- type: "star",
934
- value: V,
935
- output: ""
936
- });
937
- continue;
938
- }
939
- for (; t.slice(0, 3) === "/**";) {
940
- let n = e[I.index + 4];
941
- if (n && n !== "/") break;
942
- t = t.slice(3), K("/**", 3);
943
- }
944
- if (n.type === "bos" && H()) {
945
- B.type = "globstar", B.value += V, B.output = M(f), I.output = B.output, I.globstar = !0, K(V);
946
- continue;
947
- }
948
- if (n.type === "slash" && n.prev.type !== "bos" && !a && H()) {
949
- I.output = I.output.slice(0, -(n.output + B.output).length), n.output = `(?:${n.output}`, B.type = "globstar", B.output = M(f) + (f.strictSlashes ? ")" : "|$)"), B.value += V, I.globstar = !0, I.output += n.output + B.output, K(V);
950
- continue;
951
- }
952
- if (n.type === "slash" && n.prev.type !== "bos" && t[0] === "/") {
953
- let e = t[1] === void 0 ? "" : "|$";
954
- I.output = I.output.slice(0, -(n.output + B.output).length), n.output = `(?:${n.output}`, B.type = "globstar", B.output = `${M(f)}${S}|${S}${e})`, B.value += V, I.output += n.output + B.output, I.globstar = !0, K(V + W()), Z({
955
- type: "slash",
956
- value: "/",
957
- output: ""
958
- });
959
- continue;
960
- }
961
- if (n.type === "bos" && t[0] === "/") {
962
- B.type = "globstar", B.value += V, B.output = `(?:^|${S}|${M(f)}${S})`, I.output = B.output, I.globstar = !0, K(V + W()), Z({
963
- type: "slash",
964
- value: "/",
965
- output: ""
966
- });
967
- continue;
968
- }
969
- I.output = I.output.slice(0, -B.output.length), B.type = "globstar", B.output = M(f), B.value += V, I.output += B.output, I.globstar = !0, K(V);
970
- continue;
971
- }
972
- let n = {
973
- type: "star",
974
- value: V,
975
- output: F
976
- };
977
- if (f.bash === !0) {
978
- n.output = ".*?", (B.type === "bos" || B.type === "slash") && (n.output = N + n.output), Z(n);
979
- continue;
980
- }
981
- if (B && (B.type === "bracket" || B.type === "paren") && f.regex === !0) {
982
- n.output = V, Z(n);
983
- continue;
984
- }
985
- (I.index === I.start || B.type === "slash" || B.type === "dot") && (B.type === "dot" ? (I.output += E, B.output += E) : f.dot === !0 ? (I.output += D, B.output += D) : (I.output += N, B.output += N), U() !== "*" && (I.output += C, B.output += C)), Z(n);
986
- }
987
- for (; I.brackets > 0;) {
988
- if (f.strictBrackets === !0) throw SyntaxError(u("closing", "]"));
989
- I.output = r.escapeLast(I.output, "["), X("brackets");
990
- }
991
- for (; I.parens > 0;) {
992
- if (f.strictBrackets === !0) throw SyntaxError(u("closing", ")"));
993
- I.output = r.escapeLast(I.output, "("), X("parens");
994
- }
995
- for (; I.braces > 0;) {
996
- if (f.strictBrackets === !0) throw SyntaxError(u("closing", "}"));
997
- I.output = r.escapeLast(I.output, "{"), X("braces");
998
- }
999
- if (f.strictSlashes !== !0 && (B.type === "star" || B.type === "bracket") && Z({
1000
- type: "maybe_slash",
1001
- value: "",
1002
- output: `${S}?`
1003
- }), I.backtrack === !0) {
1004
- I.output = "";
1005
- for (let e of I.tokens) I.output += e.output == null ? e.value : e.output, e.suffix && (I.output += e.suffix);
1006
- }
1007
- return I;
1008
- };
1009
- d.fastpaths = (e, t) => {
1010
- let a = { ...t }, o = typeof a.maxLength == "number" ? Math.min(i, a.maxLength) : i, s = e.length;
1011
- if (s > o) throw SyntaxError(`Input length: ${s}, exceeds maximum allowed length: ${o}`);
1012
- e = c[e] || e;
1013
- let { DOT_LITERAL: l, SLASH_LITERAL: u, ONE_CHAR: d, DOTS_SLASH: f, NO_DOT: p, NO_DOTS: m, NO_DOTS_SLASH: h, STAR: g, START_ANCHOR: _ } = n.globChars(a.windows), v = a.dot ? m : p, y = a.dot ? h : p, b = a.capture ? "" : "?:", x = {
1014
- negated: !1,
1015
- prefix: ""
1016
- }, S = a.bash === !0 ? ".*?" : g;
1017
- a.capture && (S = `(${S})`);
1018
- let C = (e) => e.noglobstar === !0 ? S : `(${b}(?:(?!${_}${e.dot ? f : l}).)*?)`, w = (e) => {
1019
- switch (e) {
1020
- case "*": return `${v}${d}${S}`;
1021
- case ".*": return `${l}${d}${S}`;
1022
- case "*.*": return `${v}${S}${l}${d}${S}`;
1023
- case "*/*": return `${v}${S}${u}${d}${y}${S}`;
1024
- case "**": return v + C(a);
1025
- case "**/*": return `(?:${v}${C(a)}${u})?${y}${d}${S}`;
1026
- case "**/*.*": return `(?:${v}${C(a)}${u})?${y}${S}${l}${d}${S}`;
1027
- case "**/.*": return `(?:${v}${C(a)}${u})?${l}${d}${S}`;
1028
- default: {
1029
- let t = /^(.*?)\.(\w+)$/.exec(e);
1030
- if (!t) return;
1031
- let n = w(t[1]);
1032
- return n ? n + l + t[2] : void 0;
1033
- }
1034
- }
1035
- }, T = w(r.removePrefix(e, x));
1036
- return T && a.strictSlashes !== !0 && (T += `${u}?`), T;
1037
- }, t.exports = d;
1038
- })), T = /* @__PURE__ */ e(((e, t) => {
1039
- var n = C(), r = w(), i = S(), a = x(), o = (e) => e && typeof e == "object" && !Array.isArray(e), s = (e, t, n = !1) => {
1040
- if (Array.isArray(e)) {
1041
- let r = e.map((e) => s(e, t, n));
1042
- return (e) => {
1043
- for (let t of r) {
1044
- let n = t(e);
1045
- if (n) return n;
1046
- }
1047
- return !1;
1048
- };
1049
- }
1050
- let r = o(e) && e.tokens && e.input;
1051
- if (e === "" || typeof e != "string" && !r) throw TypeError("Expected pattern to be a non-empty string");
1052
- let i = t || {}, a = i.windows, c = r ? s.compileRe(e, t) : s.makeRe(e, t, !1, !0), l = c.state;
1053
- delete c.state;
1054
- let u = () => !1;
1055
- if (i.ignore) {
1056
- let e = {
1057
- ...t,
1058
- ignore: null,
1059
- onMatch: null,
1060
- onResult: null
1061
- };
1062
- u = s(i.ignore, e, n);
1063
- }
1064
- let d = (n, r = !1) => {
1065
- let { isMatch: o, match: d, output: f } = s.test(n, c, t, {
1066
- glob: e,
1067
- posix: a
1068
- }), p = {
1069
- glob: e,
1070
- state: l,
1071
- regex: c,
1072
- posix: a,
1073
- input: n,
1074
- output: f,
1075
- match: d,
1076
- isMatch: o
1077
- };
1078
- return typeof i.onResult == "function" && i.onResult(p), o === !1 ? (p.isMatch = !1, r ? p : !1) : u(n) ? (typeof i.onIgnore == "function" && i.onIgnore(p), p.isMatch = !1, r ? p : !1) : (typeof i.onMatch == "function" && i.onMatch(p), r ? p : !0);
1079
- };
1080
- return n && (d.state = l), d;
1081
- };
1082
- s.test = (e, t, n, { glob: r, posix: a } = {}) => {
1083
- if (typeof e != "string") throw TypeError("Expected input to be a string");
1084
- if (e === "") return {
1085
- isMatch: !1,
1086
- output: ""
1087
- };
1088
- let o = n || {}, c = o.format || (a ? i.toPosixSlashes : null), l = e === r, u = l && c ? c(e) : e;
1089
- return l === !1 && (u = c ? c(e) : e, l = u === r), (l === !1 || o.capture === !0) && (l = o.matchBase === !0 || o.basename === !0 ? s.matchBase(e, t, n, a) : t.exec(u)), {
1090
- isMatch: !!l,
1091
- match: l,
1092
- output: u
1093
- };
1094
- }, s.matchBase = (e, t, n) => (t instanceof RegExp ? t : s.makeRe(t, n)).test(i.basename(e)), s.isMatch = (e, t, n) => s(t, n)(e), s.parse = (e, t) => Array.isArray(e) ? e.map((e) => s.parse(e, t)) : r(e, {
1095
- ...t,
1096
- fastpaths: !1
1097
- }), s.scan = (e, t) => n(e, t), s.compileRe = (e, t, n = !1, r = !1) => {
1098
- if (n === !0) return e.output;
1099
- let i = t || {}, a = i.contains ? "" : "^", o = i.contains ? "" : "$", c = `${a}(?:${e.output})${o}`;
1100
- e && e.negated === !0 && (c = `^(?!${c}).*$`);
1101
- let l = s.toRegex(c, t);
1102
- return r === !0 && (l.state = e), l;
1103
- }, s.makeRe = (e, t = {}, n = !1, i = !1) => {
1104
- if (!e || typeof e != "string") throw TypeError("Expected a non-empty string");
1105
- let a = {
1106
- negated: !1,
1107
- fastpaths: !0
1108
- };
1109
- return t.fastpaths !== !1 && (e[0] === "." || e[0] === "*") && (a.output = r.fastpaths(e, t)), a.output || (a = r(e, t)), s.compileRe(a, t, n, i);
1110
- }, s.toRegex = (e, t) => {
1111
- try {
1112
- let n = t || {};
1113
- return new RegExp(e, n.flags || (n.nocase ? "i" : ""));
1114
- } catch (e) {
1115
- if (t && t.debug === !0) throw e;
1116
- return /$^/;
1117
- }
1118
- }, s.constants = a, t.exports = s;
1119
- })), E = /* @__PURE__ */ e(((e, t) => {
1120
- var n = T(), r = S();
1121
- function i(e, t, i = !1) {
1122
- return t && (t.windows === null || t.windows === void 0) && (t = {
1123
- ...t,
1124
- windows: r.isWindows()
1125
- }), n(e, t, i);
1126
- }
1127
- Object.assign(i, n), t.exports = i;
1128
- })), D = null;
1129
- function O(e, t) {
1130
- if (!t || t.length === 0) return [c(e, "src")];
225
+ //#region src/dev-watcher.ts
226
+ var S = null;
227
+ function C(e, t) {
228
+ if (!t || t.length === 0) return [s(e, "src")];
1131
229
  let n = /* @__PURE__ */ new Set();
1132
230
  for (let e of t) {
1133
231
  let t = e.replace(/^\.\//, "").split("*")[0].replace(/\/+$/, "");
1134
232
  n.add(t || ".");
1135
233
  }
1136
- return [...n].map((t) => c(e, t));
234
+ return [...n].map((t) => s(e, t));
1137
235
  }
1138
- function k(e) {
1139
- D && D();
1140
- let { cwd: t, compiledDir: n, delay: i = 1e3, include: a, exclude: o, parallelCompile: s } = e, l = c(t, n), u = E(), d = o?.length ? u(o) : () => !1, f = { cwd: t };
1141
- s && (f.parallelCompile = !0);
1142
- let p = b(f, i);
1143
- p();
1144
- let m = O(t, a).map((e) => r(e, { recursive: !0 }, (t, n) => {
1145
- n && /\.[jt]sx?$/.test(n) && (n.includes("node_modules") || n.includes(".next") || c(e, n).startsWith(l) || d(n) || p());
1146
- })), h = () => {
1147
- for (let e of m) e.close();
1148
- D = null;
236
+ function w(e) {
237
+ S && S();
238
+ let { cwd: t, compiledDir: r, delay: i = 1e3, include: a, exclude: o, parallelCompile: c } = e, l = s(t, r), u = p(import.meta.url)("picomatch"), d = o?.length ? u(o) : () => !1, f = { cwd: t };
239
+ c && (f.parallelCompile = !0);
240
+ let m = x(f, i);
241
+ m();
242
+ let h = C(t, a).map((e) => n(e, { recursive: !0 }, (t, n) => {
243
+ n && /\.[jt]sx?$/.test(n) && (n.includes("node_modules") || n.includes(".next") || s(e, n).startsWith(l) || d(n) || m());
244
+ })), g = () => {
245
+ for (let e of h) e.close();
246
+ S = null;
1149
247
  };
1150
- return D = h, h;
248
+ return S = g, g;
1151
249
  }
1152
250
  //#endregion
1153
251
  //#region src/with-fluenti.ts
1154
- function A(e) {
1155
- if (e && !j(e)) return M({}, e);
252
+ function T(e) {
253
+ if (e && !E(e)) return D({}, e);
1156
254
  let t = e ?? {};
1157
255
  return function(e) {
1158
- return M(t, e ?? {});
256
+ return D(t, e ?? {});
1159
257
  };
1160
258
  }
1161
- function j(e) {
259
+ function E(e) {
1162
260
  return [
1163
261
  "config",
1164
262
  "serverModule",
@@ -1168,10 +266,10 @@ function j(e) {
1168
266
  "loaderEnforce"
1169
267
  ].some((t) => t in e);
1170
268
  }
1171
- function M(e, n) {
1172
- let r = process.cwd(), i = h(r, e), o = i.fluentiConfig, s = o.compileOutDir;
1173
- t(c(r, s)) || console.warn(`\n[fluenti] Compiled catalogs not found at ${s}.\nRun: npx fluenti extract && npx fluenti compile\n`);
1174
- let l = g(r, i), u = c(typeof __dirname < "u" ? __dirname : a(new URL(import.meta.url).pathname), "loader.js"), d = n.webpack, f = !1, p = Object.fromEntries([
269
+ function D(t, n) {
270
+ let r = process.cwd(), a = h(r, t), o = a.fluentiConfig, l = o.compileOutDir;
271
+ e(s(r, l)) || console.warn(`\n[fluenti] Compiled catalogs not found at ${l}.\nRun: npx fluenti extract && npx fluenti compile\n`);
272
+ let u = g(r, a), d = s(typeof __dirname < "u" ? __dirname : i(c(import.meta.url)), "loader.js"), f = n.webpack, p = !1, m = Object.fromEntries([
1175
273
  "*.ts",
1176
274
  "*.tsx",
1177
275
  "*.js",
@@ -1179,48 +277,50 @@ function M(e, n) {
1179
277
  ].map((e) => [e, {
1180
278
  condition: { not: "foreign" },
1181
279
  loaders: ["@fluenti/next/loader"]
1182
- }])), m = "./" + l.replace(r + "/", "").replace(r + "\\", ""), _ = { "@fluenti/next": m }, v = process.env.NODE_ENV === "development" || process.argv.some((e) => e === "dev"), y = o.devAutoCompile ?? !0;
1183
- if (v && y) {
280
+ }])), _ = "./" + u.replace(r + "/", "").replace(r + "\\", ""), v = { "@fluenti/next": _ }, y = process.env.NODE_ENV === "development" || process.argv.some((e) => e === "dev"), b = o.devAutoCompile ?? !0;
281
+ if (y && b) {
1184
282
  let e = {
1185
283
  cwd: r,
1186
- compiledDir: s,
284
+ compiledDir: l,
1187
285
  delay: o.devAutoCompileDelay ?? 1e3
1188
286
  };
1189
- o.parallelCompile && (e.parallelCompile = !0), o.include && (e.include = o.include), o.exclude && (e.exclude = o.exclude), k(e);
287
+ o.parallelCompile && (e.parallelCompile = !0), o.include && (e.include = o.include), o.exclude && (e.exclude = o.exclude), w(e);
1190
288
  }
1191
289
  return {
1192
290
  ...n,
1193
- turbopack: N(n.turbopack, {
1194
- rules: p,
1195
- resolveAlias: _
291
+ turbopack: O(n.turbopack, {
292
+ rules: m,
293
+ resolveAlias: v
1196
294
  }),
1197
- webpack(t, n) {
1198
- let i = e.loaderEnforce === void 0 && !("loaderEnforce" in e) ? "pre" : e.loaderEnforce;
1199
- t.module.rules.push({
295
+ webpack(e, n) {
296
+ let i = t.loaderEnforce === void 0 && !("loaderEnforce" in t) ? "pre" : t.loaderEnforce;
297
+ e.module.rules.push({
1200
298
  test: /\.[jt]sx?$/,
1201
299
  ...i ? { enforce: i } : {},
1202
300
  exclude: [/node_modules/, /\.next/],
1203
301
  use: [{
1204
- loader: u,
1205
- options: { serverModulePath: l }
302
+ loader: d,
303
+ options: { serverModulePath: u }
1206
304
  }]
1207
- }), t.resolve = t.resolve ?? {}, t.resolve.alias = t.resolve.alias ?? {}, t.resolve.alias["@fluenti/next$"] = l;
305
+ }), e.resolve = e.resolve ?? {}, e.resolve.alias = e.resolve.alias ?? {}, e.resolve.alias["@fluenti/next$"] = u;
1208
306
  let a = o.buildAutoCompile ?? !0;
1209
- return !n.dev && a && (t.plugins = t.plugins ?? [], t.plugins.push({ apply(e) {
307
+ return !n.dev && a && (e.plugins = e.plugins ?? [], e.plugins.push({ apply(e) {
1210
308
  e.hooks.beforeRun.tapPromise("fluenti-compile", async () => {
1211
- if (!f) {
1212
- f = !0;
1213
- try {
1214
- let { runCompile: e } = await import("@fluenti/cli");
1215
- await e(r, o.parallelCompile ? { parallel: !0 } : void 0);
1216
- } catch {}
309
+ if (p) return;
310
+ p = !0;
311
+ let e;
312
+ try {
313
+ e = await import("@fluenti/cli");
314
+ } catch {
315
+ return;
1217
316
  }
317
+ await e.runCompile(r, o.parallelCompile ? { parallel: !0 } : void 0);
1218
318
  });
1219
- } })), d ? d(t, n) : t;
319
+ } })), f ? f(e, n) : e;
1220
320
  }
1221
321
  };
1222
322
  }
1223
- function N(e, t) {
323
+ function O(e, t) {
1224
324
  let n = e ?? {}, r = n.rules ?? {}, i = Object.keys(t.rules).filter((e) => e in r);
1225
325
  return i.length > 0 && console.warn(`[fluenti] Your turbopack.rules override Fluenti's loader for: ${i.join(", ")}.\n Fluenti's t\`\` transform will NOT run on these file types.\n If this is intentional, you can suppress this warning with { devAutoCompile: false }.`), {
1226
326
  ...n,
@@ -1236,12 +336,12 @@ function N(e, t) {
1236
336
  }
1237
337
  //#endregion
1238
338
  //#region src/index.ts
1239
- var P = "[fluenti] `withFluenti()` must be configured in next.config.ts before importing from \"@fluenti/next\".";
1240
- function F() {
1241
- throw Error(P);
339
+ var k = "[fluenti] `withFluenti()` must be configured in next.config.ts before importing from \"@fluenti/next\".";
340
+ function A() {
341
+ throw Error(k);
1242
342
  }
1243
- var I = F, L = F, R = F, z = F, B = F, V = F, H = F, U = F, W = F;
343
+ var j = A, M = A, N = A, P = A, F = A, I = A, L = A, R = A, z = A;
1244
344
  //#endregion
1245
- export { H as DateTime, W as I18nProvider, U as NumberFormat, B as Plural, V as Select, z as Trans, L as getI18n, I as setLocale, R as t, A as withFluenti };
345
+ export { L as DateTime, z as I18nProvider, R as NumberFormat, F as Plural, I as Select, P as Trans, M as getI18n, j as setLocale, N as t, T as withFluenti };
1246
346
 
1247
347
  //# sourceMappingURL=index.js.map