@weapp-tailwindcss/engine 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4199 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ let node_fs = require("node:fs");
24
+ let node_path = require("node:path");
25
+ node_path = __toESM(node_path, 1);
26
+ let node_process = require("node:process");
27
+ node_process = __toESM(node_process, 1);
28
+ let node_module = require("node:module");
29
+ let node_url = require("node:url");
30
+ let micromatch = require("micromatch");
31
+ micromatch = __toESM(micromatch, 1);
32
+ let node_fs_promises = require("node:fs/promises");
33
+ let postcss = require("postcss");
34
+ postcss = __toESM(postcss, 1);
35
+ //#region src/v4/node-adapter.ts
36
+ const nodeModulePromiseCache = /* @__PURE__ */ new Map();
37
+ const designSystemPromiseCache = /* @__PURE__ */ new Map();
38
+ function unique(values) {
39
+ return Array.from(new Set(Array.from(values).filter(Boolean).map((value) => node_path.default.resolve(value))));
40
+ }
41
+ function createRequireBase(base) {
42
+ return node_path.default.join(base, "package.json");
43
+ }
44
+ function isRelativeSpecifier(id) {
45
+ return id.startsWith("./") || id.startsWith("../") || id === "." || id === "..";
46
+ }
47
+ function isAbsoluteSpecifier(id) {
48
+ return node_path.default.isAbsolute(id);
49
+ }
50
+ function isCssSpecifier(id) {
51
+ return node_path.default.extname(id) === ".css";
52
+ }
53
+ function createCssResolutionCandidates(id) {
54
+ if (isCssSpecifier(id)) return [id];
55
+ return [`${id}/index.css`, id];
56
+ }
57
+ function createFallbackCssResolver(baseCandidates) {
58
+ const bases = unique(baseCandidates);
59
+ return async (id) => {
60
+ if (isRelativeSpecifier(id) || isAbsoluteSpecifier(id)) return;
61
+ for (const base of bases) {
62
+ const requireFromBase = (0, node_module.createRequire)(createRequireBase(base));
63
+ for (const candidate of createCssResolutionCandidates(id)) try {
64
+ return requireFromBase.resolve(candidate);
65
+ } catch {}
66
+ }
67
+ };
68
+ }
69
+ async function importResolvedModule(resolved) {
70
+ return import((0, node_url.pathToFileURL)(resolved).href);
71
+ }
72
+ async function importTailwindNodeFromBase(base) {
73
+ try {
74
+ return await importResolvedModule((0, node_module.createRequire)(createRequireBase(base)).resolve("@tailwindcss/node"));
75
+ } catch {
76
+ return;
77
+ }
78
+ }
79
+ async function importFallbackTailwindNode() {
80
+ return import("@tailwindcss/node");
81
+ }
82
+ async function loadTailwindV4NodeModule(baseCandidates) {
83
+ const bases = unique(baseCandidates);
84
+ const cacheKey = JSON.stringify(bases);
85
+ const cached = nodeModulePromiseCache.get(cacheKey);
86
+ if (cached) return cached;
87
+ const promise = (async () => {
88
+ for (const base of bases) {
89
+ const loaded = await importTailwindNodeFromBase(base);
90
+ if (loaded) return loaded;
91
+ }
92
+ return importFallbackTailwindNode();
93
+ })();
94
+ nodeModulePromiseCache.set(cacheKey, promise);
95
+ promise.catch(() => {
96
+ if (nodeModulePromiseCache.get(cacheKey) === promise) nodeModulePromiseCache.delete(cacheKey);
97
+ });
98
+ return promise;
99
+ }
100
+ function createDesignSystemCacheKey(css, bases) {
101
+ return JSON.stringify({
102
+ css,
103
+ bases: unique(bases)
104
+ });
105
+ }
106
+ function getTailwindV4DesignSystemCacheKey(source) {
107
+ return createDesignSystemCacheKey(source.css, [source.base, ...source.baseFallbacks]);
108
+ }
109
+ async function createTailwindV4DesignSystem(source) {
110
+ const bases = unique([source.base, ...source.baseFallbacks]);
111
+ if (bases.length === 0) throw new Error("No base directories provided for Tailwind CSS v4 design system.");
112
+ const node = await loadTailwindV4NodeModule([source.projectRoot, ...bases]);
113
+ let lastError;
114
+ for (const base of bases) try {
115
+ return await node.__unstable__loadDesignSystem(source.css, { base });
116
+ } catch (error) {
117
+ lastError = error;
118
+ }
119
+ if (lastError instanceof Error) throw lastError;
120
+ throw new Error("Failed to load Tailwind CSS v4 design system.");
121
+ }
122
+ async function loadTailwindV4DesignSystem(source, options) {
123
+ if (options?.cache === false) return createTailwindV4DesignSystem(source);
124
+ const cacheKey = getTailwindV4DesignSystemCacheKey(source);
125
+ const cached = designSystemPromiseCache.get(cacheKey);
126
+ if (cached) return cached;
127
+ const promise = createTailwindV4DesignSystem(source);
128
+ designSystemPromiseCache.set(cacheKey, promise);
129
+ promise.catch(() => {
130
+ if (designSystemPromiseCache.get(cacheKey) === promise) designSystemPromiseCache.delete(cacheKey);
131
+ });
132
+ return promise;
133
+ }
134
+ async function compileTailwindV4Source(source) {
135
+ const bases = unique([source.base, ...source.baseFallbacks]);
136
+ if (bases.length === 0) throw new Error("No base directories provided for Tailwind CSS v4 compiler.");
137
+ const node = await loadTailwindV4NodeModule([source.projectRoot, ...bases]);
138
+ let lastError;
139
+ for (const base of bases) {
140
+ const dependencies = new Set(source.dependencies);
141
+ try {
142
+ return {
143
+ compiled: await node.compile(source.css, {
144
+ base,
145
+ customCssResolver: createFallbackCssResolver([source.projectRoot, ...bases]),
146
+ onDependency(dependency) {
147
+ dependencies.add(node_path.default.resolve(dependency));
148
+ }
149
+ }),
150
+ dependencies
151
+ };
152
+ } catch (error) {
153
+ lastError = error;
154
+ }
155
+ }
156
+ if (lastError instanceof Error) throw lastError;
157
+ throw new Error("Failed to compile Tailwind CSS v4 source.");
158
+ }
159
+ //#endregion
160
+ //#region src/v4/source-scan/sources.ts
161
+ const TAILWIND_V4_IGNORED_CONTENT_DIRS = [
162
+ ".git",
163
+ ".hg",
164
+ ".jj",
165
+ ".next",
166
+ ".parcel-cache",
167
+ ".pnpm-store",
168
+ ".svelte-kit",
169
+ ".svn",
170
+ ".turbo",
171
+ ".venv",
172
+ ".vercel",
173
+ ".yarn",
174
+ "__pycache__",
175
+ "node_modules",
176
+ "venv"
177
+ ];
178
+ const TAILWIND_V4_IGNORED_EXTENSIONS = [
179
+ "less",
180
+ "lock",
181
+ "sass",
182
+ "scss",
183
+ "styl",
184
+ "log"
185
+ ];
186
+ const TAILWIND_V4_IGNORED_FILES = [
187
+ "package-lock.json",
188
+ "pnpm-lock.yaml",
189
+ "bun.lockb",
190
+ ".gitignore",
191
+ ".env",
192
+ ".env.*"
193
+ ];
194
+ const TAILWIND_V4_AUTO_SOURCE_SCAN_PATTERN = "**/*";
195
+ function uniqueResolvedPaths(values) {
196
+ const result = [];
197
+ for (const value of values) {
198
+ if (!value) continue;
199
+ const resolved = node_path.default.resolve(value);
200
+ if (!result.includes(resolved)) result.push(resolved);
201
+ }
202
+ return result;
203
+ }
204
+ function toPosixPath(value) {
205
+ return value.replaceAll(node_path.default.sep, "/");
206
+ }
207
+ function resolveSourceScanPath(value) {
208
+ const resolved = node_path.default.resolve(value);
209
+ try {
210
+ return node_fs.realpathSync.native(resolved);
211
+ } catch {
212
+ return resolved;
213
+ }
214
+ }
215
+ function normalizeGlobPattern(pattern) {
216
+ return pattern.startsWith("./") ? pattern.slice(2) : pattern;
217
+ }
218
+ function hasGlobMagic(value) {
219
+ return /[*?[\]{}()!+@]/.test(value);
220
+ }
221
+ function splitStaticGlobPrefix(pattern) {
222
+ const segments = normalizeGlobPattern(pattern).split(/[\\/]+/);
223
+ const prefix = [];
224
+ const rest = [];
225
+ let reachedGlob = false;
226
+ for (const segment of segments) {
227
+ if (!reachedGlob && segment && !hasGlobMagic(segment)) {
228
+ prefix.push(segment);
229
+ continue;
230
+ }
231
+ reachedGlob = true;
232
+ rest.push(segment);
233
+ }
234
+ return {
235
+ prefix,
236
+ rest
237
+ };
238
+ }
239
+ async function pathExistsAsDirectory(file) {
240
+ try {
241
+ return (await (0, node_fs_promises.stat)(file)).isDirectory();
242
+ } catch {
243
+ return false;
244
+ }
245
+ }
246
+ function createTailwindV4DefaultIgnoreSources(base) {
247
+ return [
248
+ ...TAILWIND_V4_IGNORED_CONTENT_DIRS.map((pattern) => ({
249
+ base,
250
+ pattern: `**/${pattern}/**`,
251
+ negated: true
252
+ })),
253
+ ...TAILWIND_V4_IGNORED_EXTENSIONS.map((extension) => ({
254
+ base,
255
+ pattern: `**/*.${extension}`,
256
+ negated: true
257
+ })),
258
+ ...TAILWIND_V4_IGNORED_FILES.map((pattern) => ({
259
+ base,
260
+ pattern: `**/${pattern}`,
261
+ negated: true
262
+ }))
263
+ ];
264
+ }
265
+ function createTailwindV4RootSources(root, fallbackBase) {
266
+ if (root === "none") return [];
267
+ if (root === null) return [{
268
+ base: fallbackBase,
269
+ pattern: TAILWIND_V4_AUTO_SOURCE_SCAN_PATTERN,
270
+ negated: false
271
+ }];
272
+ return [{
273
+ ...root,
274
+ negated: false
275
+ }];
276
+ }
277
+ function createTailwindV4CompiledSourceEntries(root, sources, fallbackBase) {
278
+ return [...createTailwindV4RootSources(root, fallbackBase), ...sources];
279
+ }
280
+ async function resolveTailwindV4SourceEntry(sourcePath, base, negated, defaultPattern = TAILWIND_V4_AUTO_SOURCE_SCAN_PATTERN) {
281
+ const absoluteSource = node_path.default.isAbsolute(sourcePath) ? node_path.default.resolve(sourcePath) : node_path.default.resolve(base, sourcePath);
282
+ if (await pathExistsAsDirectory(absoluteSource)) return {
283
+ base: absoluteSource,
284
+ negated,
285
+ pattern: normalizeGlobPattern(defaultPattern)
286
+ };
287
+ if (node_path.default.isAbsolute(sourcePath)) return {
288
+ base: node_path.default.dirname(absoluteSource),
289
+ negated,
290
+ pattern: normalizeGlobPattern(node_path.default.basename(absoluteSource))
291
+ };
292
+ const { prefix, rest } = splitStaticGlobPrefix(sourcePath);
293
+ if (prefix.length > 0 && rest.length > 0) return {
294
+ base: node_path.default.resolve(base, ...prefix),
295
+ negated,
296
+ pattern: normalizeGlobPattern(rest.join("/"))
297
+ };
298
+ return {
299
+ base,
300
+ negated,
301
+ pattern: normalizeGlobPattern(sourcePath)
302
+ };
303
+ }
304
+ async function normalizeTailwindV4SourceEntries(sources, options = {}) {
305
+ const cwd = options.cwd ? node_path.default.resolve(options.cwd) : node_process.default.cwd();
306
+ return Promise.all(sources.map((source) => resolveTailwindV4SourceEntry(source.pattern, source.base ? node_path.default.resolve(source.base) : cwd, source.negated, options.defaultPattern)));
307
+ }
308
+ function expandBracePattern(pattern) {
309
+ const index = pattern.indexOf("{");
310
+ if (index === -1) return [pattern];
311
+ const rest = pattern.slice(index);
312
+ let depth = 0;
313
+ let endIndex = -1;
314
+ for (let i = 0; i < rest.length; i++) {
315
+ const char = rest[i];
316
+ if (char === "\\") {
317
+ i += 1;
318
+ continue;
319
+ }
320
+ if (char === "{") {
321
+ depth += 1;
322
+ continue;
323
+ }
324
+ if (char === "}") {
325
+ depth -= 1;
326
+ if (depth === 0) {
327
+ endIndex = i;
328
+ break;
329
+ }
330
+ }
331
+ }
332
+ if (endIndex === -1) return [pattern];
333
+ const prefix = pattern.slice(0, index);
334
+ const inner = rest.slice(1, endIndex);
335
+ const suffix = rest.slice(endIndex + 1);
336
+ const parts = [];
337
+ const stack = [];
338
+ let lastPos = 0;
339
+ for (let i = 0; i < inner.length; i++) {
340
+ const char = inner[i];
341
+ if (char === "\\") {
342
+ i += 1;
343
+ continue;
344
+ }
345
+ if (char === "{") {
346
+ stack.push("}");
347
+ continue;
348
+ }
349
+ if (char === "}" && stack[stack.length - 1] === "}") {
350
+ stack.pop();
351
+ continue;
352
+ }
353
+ if (char === "," && stack.length === 0) {
354
+ parts.push(inner.slice(lastPos, i));
355
+ lastPos = i + 1;
356
+ }
357
+ }
358
+ parts.push(inner.slice(lastPos));
359
+ return parts.flatMap((part) => expandBracePattern(`${prefix}${part}${suffix}`));
360
+ }
361
+ function expandTailwindV4SourceEntryBraces(sources) {
362
+ return sources.flatMap((source) => {
363
+ const base = node_path.default.resolve(source.base);
364
+ return expandBracePattern(source.pattern).map((pattern) => ({
365
+ base,
366
+ pattern,
367
+ negated: source.negated
368
+ }));
369
+ });
370
+ }
371
+ function normalizeTailwindV4ScannerSources(sources, cwd, ignoredSources = []) {
372
+ return expandTailwindV4SourceEntryBraces([...sources?.length ? sources : [{
373
+ base: cwd,
374
+ pattern: TAILWIND_V4_AUTO_SOURCE_SCAN_PATTERN,
375
+ negated: false
376
+ }], ...ignoredSources]);
377
+ }
378
+ function resolveTailwindV4SourceBaseCandidates(projectRoot, base, baseFallbacks) {
379
+ return uniqueResolvedPaths([
380
+ base,
381
+ projectRoot,
382
+ ...baseFallbacks
383
+ ]);
384
+ }
385
+ //#endregion
386
+ //#region src/v4/source-scan/matcher.ts
387
+ function normalizeEntryPattern(entry) {
388
+ return node_path.default.isAbsolute(entry.pattern) ? toPosixPath(node_path.default.relative(resolveSourceScanPath(entry.base), entry.pattern)) : normalizeGlobPattern(entry.pattern);
389
+ }
390
+ function isFileMatchedByTailwindV4SourceEntry(file, entry) {
391
+ const relative = toPosixPath(node_path.default.relative(resolveSourceScanPath(entry.base), file));
392
+ return Boolean(relative) && !relative.startsWith("../") && !node_path.default.isAbsolute(relative) && micromatch.default.isMatch(relative, normalizeEntryPattern(entry));
393
+ }
394
+ function isFileExcludedByTailwindV4SourceEntries(file, entries) {
395
+ if (!entries?.length) return false;
396
+ const resolvedFile = resolveSourceScanPath(file);
397
+ return entries.some((entry) => entry.negated && isFileMatchedByTailwindV4SourceEntry(resolvedFile, entry));
398
+ }
399
+ function isFileMatchedByTailwindV4SourceEntries(file, entries) {
400
+ if (!entries?.length) return true;
401
+ const positiveEntries = entries.filter((entry) => !entry.negated);
402
+ const negativeEntries = entries.filter((entry) => entry.negated);
403
+ if (positiveEntries.length === 0) return false;
404
+ const resolvedFile = resolveSourceScanPath(file);
405
+ if (!positiveEntries.some((entry) => isFileMatchedByTailwindV4SourceEntry(resolvedFile, entry))) return false;
406
+ return !negativeEntries.some((entry) => isFileMatchedByTailwindV4SourceEntry(resolvedFile, entry));
407
+ }
408
+ function createTailwindV4SourceEntryMatcher(entries) {
409
+ if (!entries?.length) return;
410
+ return (file) => isFileMatchedByTailwindV4SourceEntries(file, entries);
411
+ }
412
+ function createTailwindV4SourceExclusionMatcher(entries) {
413
+ if (!entries?.length) return;
414
+ return (file) => isFileExcludedByTailwindV4SourceEntries(file, entries);
415
+ }
416
+ function groupTailwindV4SourceEntriesByBase(entries) {
417
+ const entriesByBase = /* @__PURE__ */ new Map();
418
+ for (const entry of entries) {
419
+ const base = node_path.default.resolve(entry.base);
420
+ const group = entriesByBase.get(base) ?? [];
421
+ group.push({
422
+ ...entry,
423
+ base,
424
+ pattern: normalizeGlobPattern(entry.pattern)
425
+ });
426
+ entriesByBase.set(base, group);
427
+ }
428
+ return entriesByBase;
429
+ }
430
+ async function expandTailwindV4SourceEntries(entries, resolveFiles) {
431
+ if (entries.length === 0) return [];
432
+ const files = /* @__PURE__ */ new Set();
433
+ await Promise.all([...groupTailwindV4SourceEntriesByBase(entries).entries()].map(async ([base, group]) => {
434
+ const matched = await resolveFiles({
435
+ cwd: base,
436
+ sources: group
437
+ });
438
+ for (const file of matched) files.add(node_path.default.resolve(file));
439
+ }));
440
+ return [...files].filter((file) => !isFileExcludedByTailwindV4SourceEntries(file, entries));
441
+ }
442
+ function mergeTailwindV4SourceEntries(...entries) {
443
+ const result = [];
444
+ const seen = /* @__PURE__ */ new Set();
445
+ for (const group of entries) for (const entry of group ?? []) {
446
+ const normalized = {
447
+ base: node_path.default.resolve(entry.base),
448
+ pattern: normalizeGlobPattern(entry.pattern),
449
+ negated: entry.negated
450
+ };
451
+ const key = JSON.stringify(normalized);
452
+ if (seen.has(key)) continue;
453
+ seen.add(key);
454
+ result.push(normalized);
455
+ }
456
+ return result;
457
+ }
458
+ //#endregion
459
+ //#region src/extraction/oxide.ts
460
+ let oxideImportPromise;
461
+ function createOxideRuntimeDependencyError(cause) {
462
+ return new Error([
463
+ "@weapp-tailwindcss/engine could not load @tailwindcss/oxide, which is required for source candidate scanning.",
464
+ "This dependency should be installed automatically by @weapp-tailwindcss/engine.",
465
+ "Reinstall dependencies without disabling optional dependencies, or install @tailwindcss/oxide@^4.3.3 manually if your package manager omitted it."
466
+ ].join(" "), { cause });
467
+ }
468
+ async function importOxide() {
469
+ try {
470
+ return await import("@tailwindcss/oxide");
471
+ } catch (error) {
472
+ throw createOxideRuntimeDependencyError(error);
473
+ }
474
+ }
475
+ function getOxideModule() {
476
+ oxideImportPromise ??= importOxide();
477
+ oxideImportPromise.catch(() => {
478
+ oxideImportPromise = void 0;
479
+ });
480
+ return oxideImportPromise;
481
+ }
482
+ //#endregion
483
+ //#region src/extraction/project-report.ts
484
+ function buildLineOffsets(content) {
485
+ const offsets = [0];
486
+ for (let i = 0; i < content.length; i++) if (content[i] === "\n") offsets.push(i + 1);
487
+ if (offsets[offsets.length - 1] !== content.length) offsets.push(content.length);
488
+ return offsets;
489
+ }
490
+ function resolveLineMeta(content, offsets, index) {
491
+ let low = 0;
492
+ let high = offsets.length - 1;
493
+ while (low <= high) {
494
+ const mid = Math.floor((low + high) / 2);
495
+ const start = offsets[mid];
496
+ if (start === void 0) break;
497
+ const nextStart = offsets[mid + 1] ?? content.length;
498
+ if (index < start) {
499
+ high = mid - 1;
500
+ continue;
501
+ }
502
+ if (index >= nextStart) {
503
+ low = mid + 1;
504
+ continue;
505
+ }
506
+ const line = mid + 1;
507
+ const column = index - start + 1;
508
+ const lineEnd = content.indexOf("\n", start);
509
+ return {
510
+ line,
511
+ column,
512
+ lineText: content.slice(start, lineEnd === -1 ? content.length : lineEnd)
513
+ };
514
+ }
515
+ const lastStart = offsets[offsets.length - 2] ?? 0;
516
+ return {
517
+ line: offsets.length - 1,
518
+ column: index - lastStart + 1,
519
+ lineText: content.slice(lastStart)
520
+ };
521
+ }
522
+ function toExtension(filename) {
523
+ return node_path.default.extname(filename).replace(/^\./, "") || "txt";
524
+ }
525
+ function toRelativeFile(cwd, filename) {
526
+ const relative = node_path.default.relative(cwd, filename).replaceAll(node_path.default.sep, "/");
527
+ return relative === "" ? node_path.default.basename(filename) : relative;
528
+ }
529
+ function createTokenLocation(input) {
530
+ const info = resolveLineMeta(input.content, input.offsets, input.position);
531
+ const relativeFile = toRelativeFile(input.cwd, input.file);
532
+ return {
533
+ rawCandidate: input.candidate,
534
+ file: input.file,
535
+ relativeFile,
536
+ extension: input.extension,
537
+ start: input.position,
538
+ end: input.position + input.candidate.length,
539
+ length: input.candidate.length,
540
+ line: info.line,
541
+ column: info.column,
542
+ lineText: info.lineText
543
+ };
544
+ }
545
+ //#endregion
546
+ //#region src/v4/bare-arbitrary-values/escape.ts
547
+ function escapeCssClassName(value) {
548
+ let result = "";
549
+ for (let index = 0; index < value.length; index++) {
550
+ const codeUnit = value.charCodeAt(index);
551
+ const character = value.charAt(index);
552
+ if (codeUnit === 0) {
553
+ result += "�";
554
+ continue;
555
+ }
556
+ if (codeUnit >= 1 && codeUnit <= 31 || codeUnit === 127 || index === 0 && codeUnit >= 48 && codeUnit <= 57 || index === 1 && codeUnit >= 48 && codeUnit <= 57 && value.charCodeAt(0) === 45) {
557
+ result += `\\${codeUnit.toString(16)} `;
558
+ continue;
559
+ }
560
+ if (codeUnit >= 128 || codeUnit === 45 || codeUnit === 95 || codeUnit >= 48 && codeUnit <= 57 || codeUnit >= 65 && codeUnit <= 90 || codeUnit >= 97 && codeUnit <= 122) {
561
+ result += character;
562
+ continue;
563
+ }
564
+ result += `\\${character}`;
565
+ }
566
+ return result;
567
+ }
568
+ //#endregion
569
+ //#region src/v4/bare-arbitrary-values/syntax.ts
570
+ const HEX_ESCAPE_RE = /^[\da-f]$/i;
571
+ function splitVariantPrefix(candidate) {
572
+ let depth = 0;
573
+ let quote;
574
+ let lastSeparator = -1;
575
+ for (let index = 0; index < candidate.length; index++) {
576
+ const character = candidate[index];
577
+ if (character === "\\") {
578
+ index++;
579
+ continue;
580
+ }
581
+ if (quote) {
582
+ if (character === quote) quote = void 0;
583
+ continue;
584
+ }
585
+ if (character === "\"" || character === "'") {
586
+ quote = character;
587
+ continue;
588
+ }
589
+ if (character === "[" || character === "(" || character === "{") {
590
+ depth++;
591
+ continue;
592
+ }
593
+ if (character === "]" || character === ")" || character === "}") {
594
+ depth = Math.max(0, depth - 1);
595
+ continue;
596
+ }
597
+ if (depth === 0 && character === ":") lastSeparator = index;
598
+ }
599
+ if (lastSeparator === -1) return {
600
+ prefix: "",
601
+ body: candidate
602
+ };
603
+ return {
604
+ prefix: candidate.slice(0, lastSeparator + 1),
605
+ body: candidate.slice(lastSeparator + 1)
606
+ };
607
+ }
608
+ function isBalancedFunctionValue(value) {
609
+ let depth = 0;
610
+ let quote;
611
+ for (let index = 0; index < value.length; index++) {
612
+ const character = value[index];
613
+ if (character === "\\") {
614
+ index++;
615
+ continue;
616
+ }
617
+ if (quote) {
618
+ if (character === quote) quote = void 0;
619
+ continue;
620
+ }
621
+ if (character === "\"" || character === "'") {
622
+ quote = character;
623
+ continue;
624
+ }
625
+ if (character === "(") {
626
+ depth++;
627
+ continue;
628
+ }
629
+ if (character === ")") {
630
+ depth--;
631
+ if (depth < 0) return false;
632
+ }
633
+ }
634
+ return depth === 0 && quote === void 0;
635
+ }
636
+ function isEscapedAt(value, index) {
637
+ let slashCount = 0;
638
+ for (let slashIndex = index - 1; slashIndex >= 0 && value[slashIndex] === "\\"; slashIndex--) slashCount++;
639
+ return slashCount % 2 === 1;
640
+ }
641
+ function isBalancedBareArbitraryBody(value) {
642
+ let depth = 0;
643
+ let quote;
644
+ for (let index = 0; index < value.length; index++) {
645
+ const character = value[index];
646
+ if (isEscapedAt(value, index)) continue;
647
+ if (quote) {
648
+ if (character === quote) quote = void 0;
649
+ continue;
650
+ }
651
+ if (character === "\"" || character === "'") {
652
+ quote = character;
653
+ continue;
654
+ }
655
+ if (character === "(" || character === "{") {
656
+ depth++;
657
+ continue;
658
+ }
659
+ if (character === ")" || character === "}") {
660
+ depth--;
661
+ if (depth < 0) return false;
662
+ }
663
+ }
664
+ return depth === 0 && quote === void 0;
665
+ }
666
+ function isHexColorValue(value) {
667
+ return /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6,8})$/i.test(value);
668
+ }
669
+ function isQuotedValue(value) {
670
+ const quote = value[0];
671
+ if (quote !== "\"" && quote !== "'" || value[value.length - 1] !== quote) return false;
672
+ let escaped = false;
673
+ for (let index = 1; index < value.length - 1; index++) {
674
+ const character = value[index];
675
+ if (escaped) {
676
+ escaped = false;
677
+ continue;
678
+ }
679
+ if (character === "\\") escaped = true;
680
+ }
681
+ return !escaped;
682
+ }
683
+ function normalizeEscapedValue(value) {
684
+ let result = "";
685
+ for (let index = 0; index < value.length; index++) {
686
+ const character = value[index];
687
+ if (character !== "\\") {
688
+ result += character;
689
+ continue;
690
+ }
691
+ const nextCharacter = value[index + 1];
692
+ if (nextCharacter === void 0) {
693
+ result += character;
694
+ continue;
695
+ }
696
+ if (HEX_ESCAPE_RE.test(nextCharacter)) {
697
+ let hex = "";
698
+ let nextIndex = index + 1;
699
+ while (nextIndex < value.length && hex.length < 6) {
700
+ const hexCharacter = value[nextIndex];
701
+ if (hexCharacter === void 0 || !HEX_ESCAPE_RE.test(hexCharacter)) break;
702
+ hex += hexCharacter;
703
+ nextIndex++;
704
+ }
705
+ if (/[\t\n\f\r ]/.test(value[nextIndex] ?? "")) nextIndex++;
706
+ const decoded = String.fromCodePoint(Number.parseInt(hex, 16));
707
+ result += decoded === "_" ? "\\_" : decoded;
708
+ index = nextIndex - 1;
709
+ continue;
710
+ }
711
+ result += nextCharacter === "_" ? "\\_" : nextCharacter;
712
+ index++;
713
+ }
714
+ return result;
715
+ }
716
+ //#endregion
717
+ //#region src/v4/bare-arbitrary-values/resolve.ts
718
+ const DEFAULT_BARE_ARBITRARY_VALUE_UNITS = [
719
+ "%",
720
+ "px",
721
+ "rpx",
722
+ "rem",
723
+ "em",
724
+ "vw",
725
+ "vh",
726
+ "vmin",
727
+ "vmax",
728
+ "dvw",
729
+ "dvh",
730
+ "svw",
731
+ "svh",
732
+ "lvw",
733
+ "lvh",
734
+ "ch",
735
+ "ex",
736
+ "lh",
737
+ "rlh",
738
+ "fr",
739
+ "deg",
740
+ "rad",
741
+ "turn",
742
+ "s",
743
+ "ms"
744
+ ];
745
+ const NUMBER_RE = /^-?(?:\d+|\d*\.\d+)$/;
746
+ const FUNCTION_VALUE_RE = /^[a-z_-][\w-]*\(/i;
747
+ const ASPECT_RATIO_RE = /^\d+\/\d+$/;
748
+ function normalizeBareArbitraryValueOptions(options) {
749
+ if (options === false || options === void 0 || options === null) return;
750
+ const units = options === true ? DEFAULT_BARE_ARBITRARY_VALUE_UNITS : options.units ?? DEFAULT_BARE_ARBITRARY_VALUE_UNITS;
751
+ const normalizedUnits = [...new Set(units.filter((unit) => typeof unit === "string" && unit.length > 0))];
752
+ if (normalizedUnits.length === 0) return;
753
+ return { units: normalizedUnits.sort((a, b) => b.length - a.length) };
754
+ }
755
+ function isBareArbitraryValuesEnabled(options) {
756
+ return normalizeBareArbitraryValueOptions(options) !== void 0;
757
+ }
758
+ function resolveValueWithUnit(body, units) {
759
+ const value = normalizeEscapedValue(body);
760
+ for (const unit of units) {
761
+ if (!value.endsWith(unit)) continue;
762
+ const numberPart = value.slice(0, -unit.length);
763
+ if (NUMBER_RE.test(numberPart)) return `${numberPart}${unit}`;
764
+ }
765
+ }
766
+ function resolveArbitraryValue(utility, body, units) {
767
+ const value = normalizeEscapedValue(body);
768
+ const withUnit = resolveValueWithUnit(value, units);
769
+ if (withUnit) return withUnit;
770
+ if (utility === "aspect" && ASPECT_RATIO_RE.test(value)) return value;
771
+ if (isHexColorValue(value)) return value;
772
+ if (isQuotedValue(value)) return value;
773
+ if (FUNCTION_VALUE_RE.test(value) && value.endsWith(")") && isBalancedFunctionValue(value)) {
774
+ if (utility === "text" && /^var\(/i.test(value)) return `color:${value}`;
775
+ return value;
776
+ }
777
+ }
778
+ function resolveUtilityAndValue(body, units) {
779
+ let depth = 0;
780
+ let quote;
781
+ for (let index = body.length - 1; index > 0; index--) {
782
+ const character = body[index];
783
+ if (isEscapedAt(body, index)) continue;
784
+ if (quote) {
785
+ if (character === quote) quote = void 0;
786
+ continue;
787
+ }
788
+ if (character === "\"" || character === "'") {
789
+ quote = character;
790
+ continue;
791
+ }
792
+ if (character === ")" || character === "}") {
793
+ depth++;
794
+ continue;
795
+ }
796
+ if (character === "(" || character === "{") {
797
+ depth = Math.max(0, depth - 1);
798
+ continue;
799
+ }
800
+ if (depth > 0 || character !== "-") continue;
801
+ const utility = body.slice(0, index);
802
+ const rawValue = body.slice(index + 1);
803
+ if (!utility || !rawValue) continue;
804
+ const value = resolveArbitraryValue(utility, rawValue, units);
805
+ if (value) return {
806
+ utility,
807
+ value
808
+ };
809
+ }
810
+ }
811
+ function resolveBareArbitraryValueCandidate(candidate, options) {
812
+ const normalizedOptions = normalizeBareArbitraryValueOptions(options);
813
+ if (!normalizedOptions || !candidate || candidate.includes("[") || candidate.includes("]")) return;
814
+ const { prefix, body } = splitVariantPrefix(candidate);
815
+ const important = body.startsWith("!") ? "!" : "";
816
+ let normalizedBody = important ? body.slice(1) : body;
817
+ const negative = normalizedBody.startsWith("-") ? "-" : "";
818
+ if (negative) normalizedBody = normalizedBody.slice(1);
819
+ if (!isBalancedBareArbitraryBody(normalizedBody)) return;
820
+ const resolved = resolveUtilityAndValue(normalizedBody, normalizedOptions.units);
821
+ if (!resolved) return;
822
+ return {
823
+ candidate,
824
+ canonicalCandidate: `${prefix}${important}${negative}${resolved.utility}-[${resolved.value}]`
825
+ };
826
+ }
827
+ //#endregion
828
+ //#region src/v4/bare-arbitrary-values/extract.ts
829
+ const ESCAPED_WHITESPACE_RE = /\\[nrt]/g;
830
+ function isBareArbitrarySourceSplitter(char) {
831
+ return /\s/.test(char);
832
+ }
833
+ function isQuoteBoundary(content, start, index) {
834
+ const tokenPrefix = content.slice(start, index);
835
+ return tokenPrefix.length === 0 || !tokenPrefix.endsWith("-");
836
+ }
837
+ function trimBareArbitrarySourceToken(token, start) {
838
+ let nextToken = token;
839
+ let nextStart = start;
840
+ while (nextToken.length > 0 && /^[<{([]$/.test(nextToken[0])) {
841
+ nextToken = nextToken.slice(1);
842
+ nextStart++;
843
+ }
844
+ while (nextToken.length > 0 && /^[>\],;]$/.test(nextToken[nextToken.length - 1])) nextToken = nextToken.slice(0, -1);
845
+ return {
846
+ token: nextToken,
847
+ start: nextStart
848
+ };
849
+ }
850
+ function pushBareArbitrarySourceCandidate(result, token, start, options) {
851
+ const trimmed = trimBareArbitrarySourceToken(token, start);
852
+ if (!trimmed.token || trimmed.token.includes("=") || trimmed.token.includes("[") || trimmed.token.includes("]")) return;
853
+ if (!resolveBareArbitraryValueCandidate(trimmed.token, options)) return;
854
+ result.push({
855
+ rawCandidate: trimmed.token,
856
+ start: trimmed.start,
857
+ end: trimmed.start + trimmed.token.length
858
+ });
859
+ }
860
+ function extractBareArbitraryValueSourceCandidatesWithPositions(content, options) {
861
+ if (!isBareArbitraryValuesEnabled(options)) return [];
862
+ const normalized = content.includes("\\") ? content.replace(ESCAPED_WHITESPACE_RE, " ") : content;
863
+ const result = [];
864
+ let depth = 0;
865
+ let quote;
866
+ let start = 0;
867
+ for (let index = 0; index < normalized.length; index++) {
868
+ const char = normalized[index];
869
+ if (char === void 0) continue;
870
+ if (char === "\\") {
871
+ index++;
872
+ continue;
873
+ }
874
+ if (quote) {
875
+ if (char === quote) quote = void 0;
876
+ } else if ((char === "\"" || char === "'" || char === "`") && !isQuoteBoundary(normalized, start, index)) quote = char;
877
+ else if (char === "(" || char === "{" || char === "[") depth++;
878
+ else if (char === ")" || char === "}" || char === "]") depth = Math.max(0, depth - 1);
879
+ if (!isBareArbitrarySourceSplitter(char) && !((char === "\"" || char === "'" || char === "`") && depth === 0 && isQuoteBoundary(normalized, start, index))) continue;
880
+ pushBareArbitrarySourceCandidate(result, normalized.slice(start, index), start, options);
881
+ start = index + 1;
882
+ }
883
+ pushBareArbitrarySourceCandidate(result, normalized.slice(start), start, options);
884
+ return result;
885
+ }
886
+ function extractBareArbitraryValueSourceCandidates(content, options) {
887
+ return [...new Set(extractBareArbitraryValueSourceCandidatesWithPositions(content, options).map((candidate) => candidate.rawCandidate))];
888
+ }
889
+ //#endregion
890
+ //#region src/extraction/segments.ts
891
+ function createBareArbitraryValueCandidateContexts(content, extension, offset, options) {
892
+ return extractBareArbitraryValueSourceCandidatesWithPositions(content, options?.bareArbitraryValues).map((candidate) => ({
893
+ content,
894
+ extension,
895
+ localStart: candidate.start,
896
+ rawCandidate: candidate.rawCandidate,
897
+ start: candidate.start + offset,
898
+ end: candidate.end + offset
899
+ }));
900
+ }
901
+ function joinSourceSegments(segments) {
902
+ const joinedSegments = [];
903
+ const parts = [];
904
+ let joinedStart = 0;
905
+ for (const segment of segments) {
906
+ if (parts.length > 0) {
907
+ parts.push("\n");
908
+ joinedStart++;
909
+ }
910
+ parts.push(segment.content);
911
+ joinedSegments.push({
912
+ ...segment,
913
+ joinedStart
914
+ });
915
+ joinedStart += segment.content.length;
916
+ }
917
+ return {
918
+ content: parts.join(""),
919
+ segments: joinedSegments
920
+ };
921
+ }
922
+ function findJoinedSourceSegment(segments, start) {
923
+ let low = 0;
924
+ let high = segments.length - 1;
925
+ while (low <= high) {
926
+ const mid = Math.floor((low + high) / 2);
927
+ const segment = segments[mid];
928
+ if (segment === void 0) break;
929
+ if (start < segment.joinedStart) {
930
+ high = mid - 1;
931
+ continue;
932
+ }
933
+ if (start >= segment.joinedStart + segment.content.length) {
934
+ low = mid + 1;
935
+ continue;
936
+ }
937
+ return segment;
938
+ }
939
+ }
940
+ async function extractBatchedSourceSegmentCandidates(segments, extension, extractRawCandidatesWithPositions, options) {
941
+ if (segments.length === 0) return [];
942
+ const joined = joinSourceSegments(segments);
943
+ const rawCandidates = await extractRawCandidatesWithPositions(joined.content, extension, options);
944
+ const candidates = [];
945
+ for (const candidate of rawCandidates) {
946
+ const segment = findJoinedSourceSegment(joined.segments, candidate.start);
947
+ if (segment === void 0 || candidate.end > segment.joinedStart + segment.content.length) continue;
948
+ const segmentOffset = candidate.start - segment.joinedStart;
949
+ candidates.push({
950
+ content: joined.content,
951
+ extension,
952
+ localStart: candidate.start,
953
+ rawCandidate: candidate.rawCandidate,
954
+ skipHtmlContextChecks: true,
955
+ start: segment.start + segmentOffset,
956
+ end: segment.start + segmentOffset + candidate.rawCandidate.length
957
+ });
958
+ }
959
+ return candidates;
960
+ }
961
+ //#endregion
962
+ //#region src/extraction/css.ts
963
+ const CSS_APPLY_RE = /@apply\s+([^;{}]+)/g;
964
+ async function extractCssApplyCandidates(content, extension, extractRawCandidatesWithPositions, options) {
965
+ const candidates = [];
966
+ CSS_APPLY_RE.lastIndex = 0;
967
+ let match = CSS_APPLY_RE.exec(content);
968
+ while (match !== null) {
969
+ const applyParams = match[1] ?? "";
970
+ const applyParamsStart = match.index + match[0].indexOf(applyParams);
971
+ const applyCandidates = await extractRawCandidatesWithPositions(applyParams, extension);
972
+ candidates.push(...applyCandidates.map((candidate) => ({
973
+ content: applyParams,
974
+ extension: "html",
975
+ localStart: candidate.start,
976
+ rawCandidate: candidate.rawCandidate,
977
+ skipHtmlContextChecks: true,
978
+ start: candidate.start + applyParamsStart,
979
+ end: candidate.end + applyParamsStart
980
+ })));
981
+ candidates.push(...createBareArbitraryValueCandidateContexts(applyParams, "html", applyParamsStart, options));
982
+ match = CSS_APPLY_RE.exec(content);
983
+ }
984
+ return candidates;
985
+ }
986
+ //#endregion
987
+ //#region src/extraction/js-string-ranges.ts
988
+ function skipQuotedJsContent(content, index, quote) {
989
+ index++;
990
+ while (index < content.length) {
991
+ const char = content[index];
992
+ if (char === "\\") {
993
+ index += 2;
994
+ continue;
995
+ }
996
+ if (char === quote) return index + 1;
997
+ index++;
998
+ }
999
+ return index;
1000
+ }
1001
+ function createJsStringStaticRanges(content) {
1002
+ const ranges = [];
1003
+ let quote;
1004
+ let stringStart = -1;
1005
+ let templateExpressionDepth = 0;
1006
+ for (let index = 0; index < content.length; index++) {
1007
+ const char = content[index];
1008
+ const next = content[index + 1];
1009
+ if (quote && char === "\\") {
1010
+ index++;
1011
+ continue;
1012
+ }
1013
+ if (quote === "`" && templateExpressionDepth > 0) {
1014
+ if (char === "\"" || char === "'") {
1015
+ index = skipQuotedJsContent(content, index, char) - 1;
1016
+ continue;
1017
+ }
1018
+ if (char === "`") {
1019
+ index = skipQuotedJsContent(content, index, "`") - 1;
1020
+ continue;
1021
+ }
1022
+ if (char === "{") {
1023
+ templateExpressionDepth++;
1024
+ continue;
1025
+ }
1026
+ if (char === "}") {
1027
+ templateExpressionDepth--;
1028
+ continue;
1029
+ }
1030
+ continue;
1031
+ }
1032
+ if (quote) {
1033
+ if (quote === "`" && char === "$" && next === "{") {
1034
+ ranges.push({
1035
+ start: stringStart,
1036
+ end: index
1037
+ });
1038
+ templateExpressionDepth = 1;
1039
+ index++;
1040
+ continue;
1041
+ }
1042
+ if (char === quote) {
1043
+ ranges.push({
1044
+ start: stringStart,
1045
+ end: index
1046
+ });
1047
+ quote = void 0;
1048
+ stringStart = -1;
1049
+ }
1050
+ continue;
1051
+ }
1052
+ if (char === "\"" || char === "'" || char === "`") {
1053
+ quote = char;
1054
+ stringStart = index + 1;
1055
+ }
1056
+ }
1057
+ if (quote !== void 0 && templateExpressionDepth === 0) ranges.push({
1058
+ start: stringStart,
1059
+ end: content.length
1060
+ });
1061
+ return ranges;
1062
+ }
1063
+ function isCandidateInsideJsStringStaticRanges(ranges, start) {
1064
+ let low = 0;
1065
+ let high = ranges.length - 1;
1066
+ while (low <= high) {
1067
+ const mid = Math.floor((low + high) / 2);
1068
+ const range = ranges[mid];
1069
+ if (range === void 0) break;
1070
+ if (start < range.start) {
1071
+ high = mid - 1;
1072
+ continue;
1073
+ }
1074
+ if (start >= range.end) {
1075
+ low = mid + 1;
1076
+ continue;
1077
+ }
1078
+ return true;
1079
+ }
1080
+ return false;
1081
+ }
1082
+ function createJsStringSourceSegments(content, offset) {
1083
+ return createJsStringStaticRanges(content).filter((range) => range.end > range.start).map((range) => ({
1084
+ content: content.slice(range.start, range.end),
1085
+ start: offset + range.start
1086
+ }));
1087
+ }
1088
+ //#endregion
1089
+ //#region src/extraction/raw-candidate-cache.ts
1090
+ const DEFAULT_RAW_CANDIDATE_CACHE_LIMIT = 64;
1091
+ function resolveRawCandidateCacheLimit(rawLimit) {
1092
+ if (rawLimit === void 0) return DEFAULT_RAW_CANDIDATE_CACHE_LIMIT;
1093
+ const limit = Number.parseInt(rawLimit, 10);
1094
+ return Number.isFinite(limit) && limit > 0 ? limit : DEFAULT_RAW_CANDIDATE_CACHE_LIMIT;
1095
+ }
1096
+ const RAW_CANDIDATE_CACHE_LIMIT = resolveRawCandidateCacheLimit(node_process.default.env["TWM_ENGINE_RAW_CANDIDATE_CACHE_LIMIT"]);
1097
+ const rawCandidateCache = /* @__PURE__ */ new Map();
1098
+ function createRawCandidateCacheKey(sources, options) {
1099
+ return JSON.stringify({
1100
+ sources: sources ?? null,
1101
+ bareArbitraryValues: options?.bareArbitraryValues ?? null
1102
+ });
1103
+ }
1104
+ async function createRawCandidateFileFingerprint(files) {
1105
+ if (!files?.length) return "";
1106
+ return (await Promise.all(files.map(async (file) => {
1107
+ try {
1108
+ const stats = await node_fs.promises.stat(file);
1109
+ return `${file}:${stats.size}:${stats.mtimeMs}`;
1110
+ } catch {
1111
+ return `${file}:missing`;
1112
+ }
1113
+ }))).sort().join("|");
1114
+ }
1115
+ function getRawCandidateCacheEntry(cacheKey, fingerprint) {
1116
+ const cached = rawCandidateCache.get(cacheKey);
1117
+ if (cached?.fingerprint !== fingerprint) return;
1118
+ rawCandidateCache.delete(cacheKey);
1119
+ rawCandidateCache.set(cacheKey, cached);
1120
+ return cached;
1121
+ }
1122
+ function setRawCandidateCacheEntry(cacheKey, fingerprint, candidates) {
1123
+ rawCandidateCache.set(cacheKey, {
1124
+ fingerprint,
1125
+ candidates
1126
+ });
1127
+ while (rawCandidateCache.size > RAW_CANDIDATE_CACHE_LIMIT) {
1128
+ const oldestKey = rawCandidateCache.keys().next().value;
1129
+ if (oldestKey === void 0) break;
1130
+ rawCandidateCache.delete(oldestKey);
1131
+ }
1132
+ }
1133
+ //#endregion
1134
+ //#region ../../node_modules/.pnpm/entities@8.0.0/node_modules/entities/dist/decode-codepoint.js
1135
+ const decodeMap = /* @__PURE__ */ new Map([
1136
+ [0, 65533],
1137
+ [128, 8364],
1138
+ [130, 8218],
1139
+ [131, 402],
1140
+ [132, 8222],
1141
+ [133, 8230],
1142
+ [134, 8224],
1143
+ [135, 8225],
1144
+ [136, 710],
1145
+ [137, 8240],
1146
+ [138, 352],
1147
+ [139, 8249],
1148
+ [140, 338],
1149
+ [142, 381],
1150
+ [145, 8216],
1151
+ [146, 8217],
1152
+ [147, 8220],
1153
+ [148, 8221],
1154
+ [149, 8226],
1155
+ [150, 8211],
1156
+ [151, 8212],
1157
+ [152, 732],
1158
+ [153, 8482],
1159
+ [154, 353],
1160
+ [155, 8250],
1161
+ [156, 339],
1162
+ [158, 382],
1163
+ [159, 376]
1164
+ ]);
1165
+ /**
1166
+ * Replace the given code point with a replacement character if it is a
1167
+ * surrogate or is outside the valid range. Otherwise return the code
1168
+ * point unchanged.
1169
+ * @param codePoint Unicode code point to convert.
1170
+ */
1171
+ function replaceCodePoint(codePoint) {
1172
+ if (codePoint >= 55296 && codePoint <= 57343 || codePoint > 1114111) return 65533;
1173
+ return decodeMap.get(codePoint) ?? codePoint;
1174
+ }
1175
+ //#endregion
1176
+ //#region ../../node_modules/.pnpm/entities@8.0.0/node_modules/entities/dist/internal/decode-shared.js
1177
+ /**
1178
+ * Shared base64 decode helper for generated decode data.
1179
+ * Assumes global atob is available.
1180
+ * @param input Input string to encode or decode.
1181
+ */
1182
+ function decodeBase64(input) {
1183
+ const binary = atob(input);
1184
+ const evenLength = binary.length & -2;
1185
+ const out = new Uint16Array(evenLength / 2);
1186
+ for (let index = 0, outIndex = 0; index < evenLength; index += 2) {
1187
+ const lo = binary.charCodeAt(index);
1188
+ const hi = binary.charCodeAt(index + 1);
1189
+ out[outIndex++] = lo | hi << 8;
1190
+ }
1191
+ return out;
1192
+ }
1193
+ //#endregion
1194
+ //#region ../../node_modules/.pnpm/entities@8.0.0/node_modules/entities/dist/generated/decode-data-html.js
1195
+ /** Packed HTML decode trie data. */
1196
+ const htmlDecodeTree = /* #__PURE__ */ decodeBase64("QR08ALkAAgH6AYsDNQR2BO0EPgXZBQEGLAbdBxMISQrvCmQLfQurDKQNLw4fD4YPpA+6D/IPAAAAAAAAAAAAAAAAKhBMEY8TmxUWF2EYLBkxGuAa3RsJHDscWR8YIC8jSCSIJcMl6ie3Ku8rEC0CLjoupS7kLgAIRU1hYmNmZ2xtbm9wcnN0dVQAWgBeAGUAaQBzAHcAfgCBAIQAhwCSAJoAoACsALMAbABpAGcAO4DGAMZAUAA7gCYAJkBjAHUAdABlADuAwQDBQHIiZXZlAAJhAAFpeW0AcgByAGMAO4DCAMJAEGRyAADgNdgE3XIAYQB2AGUAO4DAAMBA8CFoYZFj4SFjcgBhZAAAoFMqAAFncIsAjgBvAG4ABGFmAADgNdg43fAlbHlGdW5jdGlvbgCgYSBpAG4AZwA7gMUAxUAAAWNzpACoAHIAAOA12Jzc6SFnbgCgVCJpAGwAZABlADuAwwDDQG0AbAA7gMQAxEAABGFjZWZvcnN1xQDYANoA7QDxAPYA+QD8AAABY3LJAM8AayNzbGFzaAAAoBYidgHTANUAAKDnKmUAZAAAoAYjeQARZIABY3J0AOAA5QDrAGEidXNlAACgNSLuI291bGxpcw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73Lv8uAi8MLxAvEy8YLx0vIi9jInV0ZQB6YQABYXn7Lv4u8iFvbn5hN2RvAHQAfGEAAWV0Bi8KL3QAcgDmAB8QYQC2Y3IAAOA12DfdYwB5ADZk5yJyYXJyAKDdIXAAZgAA4DXYa91jAHIAAOA12M/cAAFqbiYvKC8AoA0gagAAoAwg");
1197
+ //#endregion
1198
+ //#region ../../node_modules/.pnpm/entities@8.0.0/node_modules/entities/dist/generated/decode-data-xml.js
1199
+ /** Packed XML decode trie data. */
1200
+ const xmlDecodeTree = /* #__PURE__ */ decodeBase64("AAJhZ2xxBwARABMAFQBtAg0AAAAAAA8AcAAmYG8AcwAnYHQAPmB0ADxg9SFvdCJg");
1201
+ //#endregion
1202
+ //#region ../../node_modules/.pnpm/entities@8.0.0/node_modules/entities/dist/internal/bin-trie-flags.js
1203
+ /**
1204
+ * Bit flags & masks for the binary trie encoding used for entity decoding.
1205
+ *
1206
+ * Bit layout (16 bits total):
1207
+ * 15..14 VALUE_LENGTH (+1 encoding; 0 => no value)
1208
+ * 13 FLAG13. If valueLength>0: semicolon required flag (implicit ';').
1209
+ * If valueLength==0: compact run flag.
1210
+ * 12..7 BRANCH_LENGTH Branch length (0 => single branch in 6..0 if jumpOffset==char) OR run length (when compact run)
1211
+ * 6..0 JUMP_TABLE Jump offset (jump table) OR single-branch char code OR first run char
1212
+ */
1213
+ var BinTrieFlags;
1214
+ (function(BinTrieFlags) {
1215
+ BinTrieFlags[BinTrieFlags["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
1216
+ BinTrieFlags[BinTrieFlags["FLAG13"] = 8192] = "FLAG13";
1217
+ BinTrieFlags[BinTrieFlags["BRANCH_LENGTH"] = 8064] = "BRANCH_LENGTH";
1218
+ BinTrieFlags[BinTrieFlags["JUMP_TABLE"] = 127] = "JUMP_TABLE";
1219
+ })(BinTrieFlags || (BinTrieFlags = {}));
1220
+ //#endregion
1221
+ //#region ../../node_modules/.pnpm/entities@8.0.0/node_modules/entities/dist/decode.js
1222
+ var CharCodes$1;
1223
+ (function(CharCodes) {
1224
+ CharCodes[CharCodes["NUM"] = 35] = "NUM";
1225
+ CharCodes[CharCodes["SEMI"] = 59] = "SEMI";
1226
+ CharCodes[CharCodes["EQUALS"] = 61] = "EQUALS";
1227
+ CharCodes[CharCodes["ZERO"] = 48] = "ZERO";
1228
+ CharCodes[CharCodes["NINE"] = 57] = "NINE";
1229
+ CharCodes[CharCodes["LOWER_A"] = 97] = "LOWER_A";
1230
+ CharCodes[CharCodes["LOWER_F"] = 102] = "LOWER_F";
1231
+ CharCodes[CharCodes["LOWER_X"] = 120] = "LOWER_X";
1232
+ CharCodes[CharCodes["LOWER_Z"] = 122] = "LOWER_Z";
1233
+ CharCodes[CharCodes["UPPER_A"] = 65] = "UPPER_A";
1234
+ CharCodes[CharCodes["UPPER_F"] = 70] = "UPPER_F";
1235
+ CharCodes[CharCodes["UPPER_Z"] = 90] = "UPPER_Z";
1236
+ })(CharCodes$1 || (CharCodes$1 = {}));
1237
+ /** Bit that needs to be set to convert an upper case ASCII character to lower case */
1238
+ const TO_LOWER_BIT = 32;
1239
+ function isNumber(code) {
1240
+ return code >= CharCodes$1.ZERO && code <= CharCodes$1.NINE;
1241
+ }
1242
+ function isHexadecimalCharacter(code) {
1243
+ return code >= CharCodes$1.UPPER_A && code <= CharCodes$1.UPPER_F || code >= CharCodes$1.LOWER_A && code <= CharCodes$1.LOWER_F;
1244
+ }
1245
+ function isAsciiAlphaNumeric(code) {
1246
+ return code >= CharCodes$1.UPPER_A && code <= CharCodes$1.UPPER_Z || code >= CharCodes$1.LOWER_A && code <= CharCodes$1.LOWER_Z || isNumber(code);
1247
+ }
1248
+ /**
1249
+ * Checks if the given character is a valid end character for an entity in an attribute.
1250
+ *
1251
+ * Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.
1252
+ * See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
1253
+ * @param code Code point to decode.
1254
+ */
1255
+ function isEntityInAttributeInvalidEnd(code) {
1256
+ return code === CharCodes$1.EQUALS || isAsciiAlphaNumeric(code);
1257
+ }
1258
+ var EntityDecoderState;
1259
+ (function(EntityDecoderState) {
1260
+ EntityDecoderState[EntityDecoderState["EntityStart"] = 0] = "EntityStart";
1261
+ EntityDecoderState[EntityDecoderState["NumericStart"] = 1] = "NumericStart";
1262
+ EntityDecoderState[EntityDecoderState["NumericDecimal"] = 2] = "NumericDecimal";
1263
+ EntityDecoderState[EntityDecoderState["NumericHex"] = 3] = "NumericHex";
1264
+ EntityDecoderState[EntityDecoderState["NamedEntity"] = 4] = "NamedEntity";
1265
+ })(EntityDecoderState || (EntityDecoderState = {}));
1266
+ /**
1267
+ * Decoding mode for named entities.
1268
+ */
1269
+ var DecodingMode;
1270
+ (function(DecodingMode) {
1271
+ /** Entities in text nodes that can end with any character. */
1272
+ DecodingMode[DecodingMode["Legacy"] = 0] = "Legacy";
1273
+ /** Only allow entities terminated with a semicolon. */
1274
+ DecodingMode[DecodingMode["Strict"] = 1] = "Strict";
1275
+ /** Entities in attributes have limitations on ending characters. */
1276
+ DecodingMode[DecodingMode["Attribute"] = 2] = "Attribute";
1277
+ })(DecodingMode || (DecodingMode = {}));
1278
+ /**
1279
+ * Token decoder with support of writing partial entities.
1280
+ */
1281
+ var EntityDecoder = class {
1282
+ decodeTree;
1283
+ emitCodePoint;
1284
+ errors;
1285
+ constructor(decodeTree, emitCodePoint, errors) {
1286
+ this.decodeTree = decodeTree;
1287
+ this.emitCodePoint = emitCodePoint;
1288
+ this.errors = errors;
1289
+ }
1290
+ /** The current state of the decoder. */
1291
+ state = EntityDecoderState.EntityStart;
1292
+ /** Characters that were consumed while parsing an entity. */
1293
+ consumed = 1;
1294
+ /**
1295
+ * The result of the entity.
1296
+ *
1297
+ * Either the result index of a numeric entity, or the codepoint of a
1298
+ * numeric entity.
1299
+ */
1300
+ result = 0;
1301
+ /** The current index in the decode tree. */
1302
+ treeIndex = 0;
1303
+ /** The number of characters that were consumed in excess. */
1304
+ excess = 1;
1305
+ /** The mode in which the decoder is operating. */
1306
+ decodeMode = DecodingMode.Strict;
1307
+ /** The number of characters that have been consumed in the current run. */
1308
+ runConsumed = 0;
1309
+ /**
1310
+ * Resets the instance to make it reusable.
1311
+ * @param decodeMode Entity decoding mode to use.
1312
+ */
1313
+ startEntity(decodeMode) {
1314
+ this.decodeMode = decodeMode;
1315
+ this.state = EntityDecoderState.EntityStart;
1316
+ this.result = 0;
1317
+ this.treeIndex = 0;
1318
+ this.excess = 1;
1319
+ this.consumed = 1;
1320
+ this.runConsumed = 0;
1321
+ }
1322
+ /**
1323
+ * Write an entity to the decoder. This can be called multiple times with partial entities.
1324
+ * If the entity is incomplete, the decoder will return -1.
1325
+ *
1326
+ * Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
1327
+ * entity is incomplete, and resume when the next string is written.
1328
+ * @param input The string containing the entity (or a continuation of the entity).
1329
+ * @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
1330
+ * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
1331
+ */
1332
+ write(input, offset) {
1333
+ switch (this.state) {
1334
+ case EntityDecoderState.EntityStart:
1335
+ if (input.charCodeAt(offset) === CharCodes$1.NUM) {
1336
+ this.state = EntityDecoderState.NumericStart;
1337
+ this.consumed += 1;
1338
+ return this.stateNumericStart(input, offset + 1);
1339
+ }
1340
+ this.state = EntityDecoderState.NamedEntity;
1341
+ return this.stateNamedEntity(input, offset);
1342
+ case EntityDecoderState.NumericStart: return this.stateNumericStart(input, offset);
1343
+ case EntityDecoderState.NumericDecimal: return this.stateNumericDecimal(input, offset);
1344
+ case EntityDecoderState.NumericHex: return this.stateNumericHex(input, offset);
1345
+ case EntityDecoderState.NamedEntity: return this.stateNamedEntity(input, offset);
1346
+ }
1347
+ }
1348
+ /**
1349
+ * Switches between the numeric decimal and hexadecimal states.
1350
+ *
1351
+ * Equivalent to the `Numeric character reference state` in the HTML spec.
1352
+ * @param input The string containing the entity (or a continuation of the entity).
1353
+ * @param offset The current offset.
1354
+ * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
1355
+ */
1356
+ stateNumericStart(input, offset) {
1357
+ if (offset >= input.length) return -1;
1358
+ if ((input.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes$1.LOWER_X) {
1359
+ this.state = EntityDecoderState.NumericHex;
1360
+ this.consumed += 1;
1361
+ return this.stateNumericHex(input, offset + 1);
1362
+ }
1363
+ this.state = EntityDecoderState.NumericDecimal;
1364
+ return this.stateNumericDecimal(input, offset);
1365
+ }
1366
+ /**
1367
+ * Parses a hexadecimal numeric entity.
1368
+ *
1369
+ * Equivalent to the `Hexademical character reference state` in the HTML spec.
1370
+ * @param input The string containing the entity (or a continuation of the entity).
1371
+ * @param offset The current offset.
1372
+ * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
1373
+ */
1374
+ stateNumericHex(input, offset) {
1375
+ while (offset < input.length) {
1376
+ const char = input.charCodeAt(offset);
1377
+ if (isNumber(char) || isHexadecimalCharacter(char)) {
1378
+ const digit = char <= CharCodes$1.NINE ? char - CharCodes$1.ZERO : (char | TO_LOWER_BIT) - CharCodes$1.LOWER_A + 10;
1379
+ this.result = this.result * 16 + digit;
1380
+ this.consumed++;
1381
+ offset++;
1382
+ } else return this.emitNumericEntity(char, 3);
1383
+ }
1384
+ return -1;
1385
+ }
1386
+ /**
1387
+ * Parses a decimal numeric entity.
1388
+ *
1389
+ * Equivalent to the `Decimal character reference state` in the HTML spec.
1390
+ * @param input The string containing the entity (or a continuation of the entity).
1391
+ * @param offset The current offset.
1392
+ * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
1393
+ */
1394
+ stateNumericDecimal(input, offset) {
1395
+ while (offset < input.length) {
1396
+ const char = input.charCodeAt(offset);
1397
+ if (isNumber(char)) {
1398
+ this.result = this.result * 10 + (char - CharCodes$1.ZERO);
1399
+ this.consumed++;
1400
+ offset++;
1401
+ } else return this.emitNumericEntity(char, 2);
1402
+ }
1403
+ return -1;
1404
+ }
1405
+ /**
1406
+ * Validate and emit a numeric entity.
1407
+ *
1408
+ * Implements the logic from the `Hexademical character reference start
1409
+ * state` and `Numeric character reference end state` in the HTML spec.
1410
+ * @param lastCp The last code point of the entity. Used to see if the
1411
+ * entity was terminated with a semicolon.
1412
+ * @param expectedLength The minimum number of characters that should be
1413
+ * consumed. Used to validate that at least one digit
1414
+ * was consumed.
1415
+ * @returns The number of characters that were consumed.
1416
+ */
1417
+ emitNumericEntity(lastCp, expectedLength) {
1418
+ if (this.consumed <= expectedLength) {
1419
+ this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);
1420
+ return 0;
1421
+ }
1422
+ if (lastCp === CharCodes$1.SEMI) this.consumed += 1;
1423
+ else if (this.decodeMode === DecodingMode.Strict) return 0;
1424
+ this.emitCodePoint(replaceCodePoint(this.result), this.consumed);
1425
+ if (this.errors) {
1426
+ if (lastCp !== CharCodes$1.SEMI) this.errors.missingSemicolonAfterCharacterReference();
1427
+ this.errors.validateNumericCharacterReference(this.result);
1428
+ }
1429
+ return this.consumed;
1430
+ }
1431
+ /**
1432
+ * Parses a named entity.
1433
+ *
1434
+ * Equivalent to the `Named character reference state` in the HTML spec.
1435
+ * @param input The string containing the entity (or a continuation of the entity).
1436
+ * @param offset The current offset.
1437
+ * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
1438
+ */
1439
+ stateNamedEntity(input, offset) {
1440
+ const { decodeTree } = this;
1441
+ let current = decodeTree[this.treeIndex];
1442
+ let valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
1443
+ while (offset < input.length) {
1444
+ if (valueLength === 0 && (current & BinTrieFlags.FLAG13) !== 0) {
1445
+ const runLength = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
1446
+ if (this.runConsumed === 0) {
1447
+ const firstChar = current & BinTrieFlags.JUMP_TABLE;
1448
+ if (input.charCodeAt(offset) !== firstChar) return this.result === 0 ? 0 : this.emitNotTerminatedNamedEntity();
1449
+ offset++;
1450
+ this.excess++;
1451
+ this.runConsumed++;
1452
+ }
1453
+ while (this.runConsumed < runLength) {
1454
+ if (offset >= input.length) return -1;
1455
+ const charIndexInPacked = this.runConsumed - 1;
1456
+ const packedWord = decodeTree[this.treeIndex + 1 + (charIndexInPacked >> 1)];
1457
+ const expectedChar = charIndexInPacked % 2 === 0 ? packedWord & 255 : packedWord >> 8 & 255;
1458
+ if (input.charCodeAt(offset) !== expectedChar) {
1459
+ this.runConsumed = 0;
1460
+ return this.result === 0 ? 0 : this.emitNotTerminatedNamedEntity();
1461
+ }
1462
+ offset++;
1463
+ this.excess++;
1464
+ this.runConsumed++;
1465
+ }
1466
+ this.runConsumed = 0;
1467
+ this.treeIndex += 1 + (runLength >> 1);
1468
+ current = decodeTree[this.treeIndex];
1469
+ valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
1470
+ }
1471
+ if (offset >= input.length) break;
1472
+ const char = input.charCodeAt(offset);
1473
+ if (char === CharCodes$1.SEMI && valueLength !== 0 && (current & BinTrieFlags.FLAG13) !== 0) return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess);
1474
+ this.treeIndex = determineBranch(decodeTree, current, this.treeIndex + Math.max(1, valueLength), char);
1475
+ if (this.treeIndex < 0) return this.result === 0 || this.decodeMode === DecodingMode.Attribute && (valueLength === 0 || isEntityInAttributeInvalidEnd(char)) ? 0 : this.emitNotTerminatedNamedEntity();
1476
+ current = decodeTree[this.treeIndex];
1477
+ valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
1478
+ if (valueLength !== 0) {
1479
+ if (char === CharCodes$1.SEMI) return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess);
1480
+ if (this.decodeMode !== DecodingMode.Strict && (current & BinTrieFlags.FLAG13) === 0) {
1481
+ this.result = this.treeIndex;
1482
+ this.consumed += this.excess;
1483
+ this.excess = 0;
1484
+ }
1485
+ }
1486
+ offset++;
1487
+ this.excess++;
1488
+ }
1489
+ return -1;
1490
+ }
1491
+ /**
1492
+ * Emit a named entity that was not terminated with a semicolon.
1493
+ * @returns The number of characters consumed.
1494
+ */
1495
+ emitNotTerminatedNamedEntity() {
1496
+ const { result, decodeTree } = this;
1497
+ const valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14;
1498
+ this.emitNamedEntityData(result, valueLength, this.consumed);
1499
+ this.errors?.missingSemicolonAfterCharacterReference();
1500
+ return this.consumed;
1501
+ }
1502
+ /**
1503
+ * Emit a named entity.
1504
+ * @param result The index of the entity in the decode tree.
1505
+ * @param valueLength The number of bytes in the entity.
1506
+ * @param consumed The number of characters consumed.
1507
+ * @returns The number of characters consumed.
1508
+ */
1509
+ emitNamedEntityData(result, valueLength, consumed) {
1510
+ const { decodeTree } = this;
1511
+ this.emitCodePoint(valueLength === 1 ? decodeTree[result] & ~(BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13) : decodeTree[result + 1], consumed);
1512
+ if (valueLength === 3) this.emitCodePoint(decodeTree[result + 2], consumed);
1513
+ return consumed;
1514
+ }
1515
+ /**
1516
+ * Signal to the parser that the end of the input was reached.
1517
+ *
1518
+ * Remaining data will be emitted and relevant errors will be produced.
1519
+ * @returns The number of characters consumed.
1520
+ */
1521
+ end() {
1522
+ switch (this.state) {
1523
+ case EntityDecoderState.NamedEntity: return this.result !== 0 && (this.decodeMode !== DecodingMode.Attribute || this.result === this.treeIndex) ? this.emitNotTerminatedNamedEntity() : 0;
1524
+ case EntityDecoderState.NumericDecimal: return this.emitNumericEntity(0, 2);
1525
+ case EntityDecoderState.NumericHex: return this.emitNumericEntity(0, 3);
1526
+ case EntityDecoderState.NumericStart:
1527
+ this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);
1528
+ return 0;
1529
+ case EntityDecoderState.EntityStart: return 0;
1530
+ }
1531
+ }
1532
+ };
1533
+ /**
1534
+ * Determines the branch of the current node that is taken given the current
1535
+ * character. This function is used to traverse the trie.
1536
+ * @param decodeTree The trie.
1537
+ * @param current The current node.
1538
+ * @param nodeIndex Index immediately after the current node header.
1539
+ * @param char The current character.
1540
+ * @returns The index of the next node, or -1 if no branch is taken.
1541
+ */
1542
+ function determineBranch(decodeTree, current, nodeIndex, char) {
1543
+ const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
1544
+ const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
1545
+ if (branchCount === 0) return jumpOffset !== 0 && char === jumpOffset ? nodeIndex : -1;
1546
+ if (jumpOffset) {
1547
+ const value = char - jumpOffset;
1548
+ return value < 0 || value >= branchCount ? -1 : decodeTree[nodeIndex + value] - 1;
1549
+ }
1550
+ const packedKeySlots = branchCount + 1 >> 1;
1551
+ let lo = 0;
1552
+ let hi = branchCount - 1;
1553
+ while (lo <= hi) {
1554
+ const mid = lo + hi >>> 1;
1555
+ const midKey = decodeTree[nodeIndex + (mid >> 1)] >> (mid & 1) * 8 & 255;
1556
+ if (midKey < char) lo = mid + 1;
1557
+ else if (midKey > char) hi = mid - 1;
1558
+ else return decodeTree[nodeIndex + packedKeySlots + mid];
1559
+ }
1560
+ return -1;
1561
+ }
1562
+ //#endregion
1563
+ //#region ../../node_modules/.pnpm/htmlparser2@12.0.0/node_modules/htmlparser2/dist/Tokenizer.js
1564
+ var CharCodes;
1565
+ (function(CharCodes) {
1566
+ CharCodes[CharCodes["Tab"] = 9] = "Tab";
1567
+ CharCodes[CharCodes["NewLine"] = 10] = "NewLine";
1568
+ CharCodes[CharCodes["FormFeed"] = 12] = "FormFeed";
1569
+ CharCodes[CharCodes["CarriageReturn"] = 13] = "CarriageReturn";
1570
+ CharCodes[CharCodes["Space"] = 32] = "Space";
1571
+ CharCodes[CharCodes["ExclamationMark"] = 33] = "ExclamationMark";
1572
+ CharCodes[CharCodes["Number"] = 35] = "Number";
1573
+ CharCodes[CharCodes["Amp"] = 38] = "Amp";
1574
+ CharCodes[CharCodes["SingleQuote"] = 39] = "SingleQuote";
1575
+ CharCodes[CharCodes["DoubleQuote"] = 34] = "DoubleQuote";
1576
+ CharCodes[CharCodes["Dash"] = 45] = "Dash";
1577
+ CharCodes[CharCodes["Slash"] = 47] = "Slash";
1578
+ CharCodes[CharCodes["Zero"] = 48] = "Zero";
1579
+ CharCodes[CharCodes["Nine"] = 57] = "Nine";
1580
+ CharCodes[CharCodes["Semi"] = 59] = "Semi";
1581
+ CharCodes[CharCodes["Lt"] = 60] = "Lt";
1582
+ CharCodes[CharCodes["Eq"] = 61] = "Eq";
1583
+ CharCodes[CharCodes["Gt"] = 62] = "Gt";
1584
+ CharCodes[CharCodes["Questionmark"] = 63] = "Questionmark";
1585
+ CharCodes[CharCodes["UpperA"] = 65] = "UpperA";
1586
+ CharCodes[CharCodes["LowerA"] = 97] = "LowerA";
1587
+ CharCodes[CharCodes["UpperF"] = 70] = "UpperF";
1588
+ CharCodes[CharCodes["LowerF"] = 102] = "LowerF";
1589
+ CharCodes[CharCodes["UpperZ"] = 90] = "UpperZ";
1590
+ CharCodes[CharCodes["LowerZ"] = 122] = "LowerZ";
1591
+ CharCodes[CharCodes["LowerX"] = 120] = "LowerX";
1592
+ CharCodes[CharCodes["OpeningSquareBracket"] = 91] = "OpeningSquareBracket";
1593
+ })(CharCodes || (CharCodes = {}));
1594
+ /** All the states the tokenizer can be in. */
1595
+ var State;
1596
+ (function(State) {
1597
+ State[State["Text"] = 1] = "Text";
1598
+ State[State["BeforeTagName"] = 2] = "BeforeTagName";
1599
+ State[State["InTagName"] = 3] = "InTagName";
1600
+ State[State["InSelfClosingTag"] = 4] = "InSelfClosingTag";
1601
+ State[State["BeforeClosingTagName"] = 5] = "BeforeClosingTagName";
1602
+ State[State["InClosingTagName"] = 6] = "InClosingTagName";
1603
+ State[State["AfterClosingTagName"] = 7] = "AfterClosingTagName";
1604
+ State[State["BeforeAttributeName"] = 8] = "BeforeAttributeName";
1605
+ State[State["InAttributeName"] = 9] = "InAttributeName";
1606
+ State[State["AfterAttributeName"] = 10] = "AfterAttributeName";
1607
+ State[State["BeforeAttributeValue"] = 11] = "BeforeAttributeValue";
1608
+ State[State["InAttributeValueDq"] = 12] = "InAttributeValueDq";
1609
+ State[State["InAttributeValueSq"] = 13] = "InAttributeValueSq";
1610
+ State[State["InAttributeValueNq"] = 14] = "InAttributeValueNq";
1611
+ State[State["BeforeDeclaration"] = 15] = "BeforeDeclaration";
1612
+ State[State["InDeclaration"] = 16] = "InDeclaration";
1613
+ State[State["InProcessingInstruction"] = 17] = "InProcessingInstruction";
1614
+ State[State["BeforeComment"] = 18] = "BeforeComment";
1615
+ State[State["CDATASequence"] = 19] = "CDATASequence";
1616
+ State[State["DeclarationSequence"] = 20] = "DeclarationSequence";
1617
+ State[State["InSpecialComment"] = 21] = "InSpecialComment";
1618
+ State[State["InCommentLike"] = 22] = "InCommentLike";
1619
+ State[State["SpecialStartSequence"] = 23] = "SpecialStartSequence";
1620
+ State[State["InSpecialTag"] = 24] = "InSpecialTag";
1621
+ State[State["InPlainText"] = 25] = "InPlainText";
1622
+ State[State["InEntity"] = 26] = "InEntity";
1623
+ })(State || (State = {}));
1624
+ function isWhitespace$1(c) {
1625
+ return c === CharCodes.Space || c === CharCodes.NewLine || c === CharCodes.Tab || c === CharCodes.FormFeed || c === CharCodes.CarriageReturn;
1626
+ }
1627
+ function isEndOfTagSection(c) {
1628
+ return c === CharCodes.Slash || c === CharCodes.Gt || isWhitespace$1(c);
1629
+ }
1630
+ function isASCIIAlpha(c) {
1631
+ return c >= CharCodes.LowerA && c <= CharCodes.LowerZ || c >= CharCodes.UpperA && c <= CharCodes.UpperZ;
1632
+ }
1633
+ /**
1634
+ * Quote style used for parsed attributes.
1635
+ */
1636
+ var QuoteType;
1637
+ (function(QuoteType) {
1638
+ QuoteType[QuoteType["NoValue"] = 0] = "NoValue";
1639
+ QuoteType[QuoteType["Unquoted"] = 1] = "Unquoted";
1640
+ QuoteType[QuoteType["Single"] = 2] = "Single";
1641
+ QuoteType[QuoteType["Double"] = 3] = "Double";
1642
+ })(QuoteType || (QuoteType = {}));
1643
+ /**
1644
+ * Sequences used to match longer strings.
1645
+ *
1646
+ * We don't have `Script`, `Style`, or `Title` here. Instead, we re-use the *End
1647
+ * sequences with an increased offset.
1648
+ */
1649
+ const Sequences = {
1650
+ Empty: /* @__PURE__ */ new Uint8Array(0),
1651
+ Cdata: new Uint8Array([
1652
+ 67,
1653
+ 68,
1654
+ 65,
1655
+ 84,
1656
+ 65,
1657
+ 91
1658
+ ]),
1659
+ CdataEnd: new Uint8Array([
1660
+ 93,
1661
+ 93,
1662
+ 62
1663
+ ]),
1664
+ CommentEnd: new Uint8Array([
1665
+ 45,
1666
+ 45,
1667
+ 33,
1668
+ 62
1669
+ ]),
1670
+ Doctype: new Uint8Array([
1671
+ 100,
1672
+ 111,
1673
+ 99,
1674
+ 116,
1675
+ 121,
1676
+ 112,
1677
+ 101
1678
+ ]),
1679
+ IframeEnd: new Uint8Array([
1680
+ 60,
1681
+ 47,
1682
+ 105,
1683
+ 102,
1684
+ 114,
1685
+ 97,
1686
+ 109,
1687
+ 101
1688
+ ]),
1689
+ NoembedEnd: new Uint8Array([
1690
+ 60,
1691
+ 47,
1692
+ 110,
1693
+ 111,
1694
+ 101,
1695
+ 109,
1696
+ 98,
1697
+ 101,
1698
+ 100
1699
+ ]),
1700
+ NoframesEnd: new Uint8Array([
1701
+ 60,
1702
+ 47,
1703
+ 110,
1704
+ 111,
1705
+ 102,
1706
+ 114,
1707
+ 97,
1708
+ 109,
1709
+ 101,
1710
+ 115
1711
+ ]),
1712
+ Plaintext: new Uint8Array([
1713
+ 60,
1714
+ 47,
1715
+ 112,
1716
+ 108,
1717
+ 97,
1718
+ 105,
1719
+ 110,
1720
+ 116,
1721
+ 101,
1722
+ 120,
1723
+ 116
1724
+ ]),
1725
+ ScriptEnd: new Uint8Array([
1726
+ 60,
1727
+ 47,
1728
+ 115,
1729
+ 99,
1730
+ 114,
1731
+ 105,
1732
+ 112,
1733
+ 116
1734
+ ]),
1735
+ StyleEnd: new Uint8Array([
1736
+ 60,
1737
+ 47,
1738
+ 115,
1739
+ 116,
1740
+ 121,
1741
+ 108,
1742
+ 101
1743
+ ]),
1744
+ TitleEnd: new Uint8Array([
1745
+ 60,
1746
+ 47,
1747
+ 116,
1748
+ 105,
1749
+ 116,
1750
+ 108,
1751
+ 101
1752
+ ]),
1753
+ TextareaEnd: new Uint8Array([
1754
+ 60,
1755
+ 47,
1756
+ 116,
1757
+ 101,
1758
+ 120,
1759
+ 116,
1760
+ 97,
1761
+ 114,
1762
+ 101,
1763
+ 97
1764
+ ]),
1765
+ XmpEnd: new Uint8Array([
1766
+ 60,
1767
+ 47,
1768
+ 120,
1769
+ 109,
1770
+ 112
1771
+ ])
1772
+ };
1773
+ /**
1774
+ * Maps the first lowercase character of an HTML tag name to the sequence
1775
+ * used for special-tag detection. All sequences share a common layout
1776
+ * where index 2 is the first tag-name character, so matching always
1777
+ * continues from offset 3.
1778
+ */
1779
+ const specialStartSequences = /* @__PURE__ */ new Map([
1780
+ [Sequences.IframeEnd[2], Sequences.IframeEnd],
1781
+ [Sequences.NoembedEnd[2], Sequences.NoembedEnd],
1782
+ [Sequences.Plaintext[2], Sequences.Plaintext],
1783
+ [Sequences.ScriptEnd[2], Sequences.ScriptEnd],
1784
+ [Sequences.TitleEnd[2], Sequences.TitleEnd],
1785
+ [Sequences.XmpEnd[2], Sequences.XmpEnd]
1786
+ ]);
1787
+ /**
1788
+ * Tokenizer implementation used by `Parser`.
1789
+ */
1790
+ var Tokenizer = class {
1791
+ cbs;
1792
+ /** The current state the tokenizer is in. */
1793
+ state = State.Text;
1794
+ /** The read buffer. */
1795
+ buffer = "";
1796
+ /** The beginning of the section that is currently being read. */
1797
+ sectionStart = 0;
1798
+ /** The index within the buffer that we are currently looking at. */
1799
+ index = 0;
1800
+ /** The start of the last entity. */
1801
+ entityStart = 0;
1802
+ /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
1803
+ baseState = State.Text;
1804
+ /** For special parsing behavior inside of script and style tags. */
1805
+ isSpecial = false;
1806
+ /** Indicates whether the tokenizer has been paused. */
1807
+ running = true;
1808
+ /** The offset of the current buffer. */
1809
+ offset = 0;
1810
+ xmlMode;
1811
+ decodeEntities;
1812
+ recognizeSelfClosing;
1813
+ entityDecoder;
1814
+ constructor({ xmlMode = false, decodeEntities = true, recognizeSelfClosing = xmlMode }, cbs) {
1815
+ this.cbs = cbs;
1816
+ this.xmlMode = xmlMode;
1817
+ this.decodeEntities = decodeEntities;
1818
+ this.recognizeSelfClosing = recognizeSelfClosing;
1819
+ this.entityDecoder = new EntityDecoder(xmlMode ? xmlDecodeTree : htmlDecodeTree, (cp, consumed) => this.emitCodePoint(cp, consumed));
1820
+ }
1821
+ reset() {
1822
+ this.state = State.Text;
1823
+ this.buffer = "";
1824
+ this.sectionStart = 0;
1825
+ this.index = 0;
1826
+ this.baseState = State.Text;
1827
+ this.isSpecial = false;
1828
+ this.currentSequence = Sequences.Empty;
1829
+ this.sequenceIndex = 0;
1830
+ this.running = true;
1831
+ this.offset = 0;
1832
+ }
1833
+ write(chunk) {
1834
+ this.offset += this.buffer.length;
1835
+ this.buffer = chunk;
1836
+ this.parse();
1837
+ }
1838
+ end() {
1839
+ if (this.running) this.finish();
1840
+ }
1841
+ pause() {
1842
+ this.running = false;
1843
+ }
1844
+ resume() {
1845
+ this.running = true;
1846
+ if (this.index < this.buffer.length + this.offset) this.parse();
1847
+ }
1848
+ stateText(c) {
1849
+ if (c === CharCodes.Lt || !this.decodeEntities && this.fastForwardTo(CharCodes.Lt)) {
1850
+ if (this.index > this.sectionStart) this.cbs.ontext(this.sectionStart, this.index);
1851
+ this.state = State.BeforeTagName;
1852
+ this.sectionStart = this.index;
1853
+ } else if (this.decodeEntities && c === CharCodes.Amp) this.startEntity();
1854
+ }
1855
+ currentSequence = Sequences.Empty;
1856
+ sequenceIndex = 0;
1857
+ enterTagBody() {
1858
+ if (this.currentSequence === Sequences.Plaintext) {
1859
+ this.currentSequence = Sequences.Empty;
1860
+ this.state = State.InPlainText;
1861
+ } else if (this.isSpecial) {
1862
+ this.state = State.InSpecialTag;
1863
+ this.sequenceIndex = 0;
1864
+ } else this.state = State.Text;
1865
+ }
1866
+ /**
1867
+ * Match the opening tag name against an HTML text-only tag sequence.
1868
+ *
1869
+ * Some tags share an initial prefix (`script`/`style`, `title`/`textarea`,
1870
+ * `noembed`/`noframes`), so we may switch to an alternate sequence at the
1871
+ * first distinguishing byte. On a successful full match we fall back to
1872
+ * the normal tag-name state; a later `>` will enter raw-text, RCDATA, or
1873
+ * plaintext mode based on `currentSequence` / `isSpecial`.
1874
+ * @param c Current character code point.
1875
+ */
1876
+ stateSpecialStartSequence(c) {
1877
+ const lower = c | 32;
1878
+ if (this.sequenceIndex < this.currentSequence.length) {
1879
+ if (lower === this.currentSequence[this.sequenceIndex]) {
1880
+ this.sequenceIndex++;
1881
+ return;
1882
+ }
1883
+ if (this.sequenceIndex === 3) {
1884
+ if (this.currentSequence === Sequences.ScriptEnd && lower === Sequences.StyleEnd[3]) {
1885
+ this.currentSequence = Sequences.StyleEnd;
1886
+ this.sequenceIndex = 4;
1887
+ return;
1888
+ }
1889
+ if (this.currentSequence === Sequences.TitleEnd && lower === Sequences.TextareaEnd[3]) {
1890
+ this.currentSequence = Sequences.TextareaEnd;
1891
+ this.sequenceIndex = 4;
1892
+ return;
1893
+ }
1894
+ } else if (this.sequenceIndex === 4 && this.currentSequence === Sequences.NoembedEnd && lower === Sequences.NoframesEnd[4]) {
1895
+ this.currentSequence = Sequences.NoframesEnd;
1896
+ this.sequenceIndex = 5;
1897
+ return;
1898
+ }
1899
+ } else if (isEndOfTagSection(c)) {
1900
+ this.sequenceIndex = 0;
1901
+ this.state = State.InTagName;
1902
+ this.stateInTagName(c);
1903
+ return;
1904
+ }
1905
+ this.isSpecial = false;
1906
+ this.currentSequence = Sequences.Empty;
1907
+ this.sequenceIndex = 0;
1908
+ this.state = State.InTagName;
1909
+ this.stateInTagName(c);
1910
+ }
1911
+ stateCDATASequence(c) {
1912
+ if (c === Sequences.Cdata[this.sequenceIndex]) {
1913
+ if (++this.sequenceIndex === Sequences.Cdata.length) {
1914
+ this.state = State.InCommentLike;
1915
+ this.currentSequence = Sequences.CdataEnd;
1916
+ this.sequenceIndex = 0;
1917
+ this.sectionStart = this.index + 1;
1918
+ }
1919
+ } else {
1920
+ this.sequenceIndex = 0;
1921
+ if (this.xmlMode) {
1922
+ this.state = State.InDeclaration;
1923
+ this.stateInDeclaration(c);
1924
+ } else {
1925
+ this.state = State.InSpecialComment;
1926
+ this.stateInSpecialComment(c);
1927
+ }
1928
+ }
1929
+ }
1930
+ /**
1931
+ * When we wait for one specific character, we can speed things up
1932
+ * by skipping through the buffer until we find it.
1933
+ * @param c Current character code point.
1934
+ * @returns Whether the character was found.
1935
+ */
1936
+ fastForwardTo(c) {
1937
+ while (++this.index < this.buffer.length + this.offset) if (this.buffer.charCodeAt(this.index - this.offset) === c) return true;
1938
+ this.index = this.buffer.length + this.offset - 1;
1939
+ return false;
1940
+ }
1941
+ /**
1942
+ * Emit a comment token and return to the text state.
1943
+ * @param offset Number of characters in the end sequence that have already been matched.
1944
+ */
1945
+ emitComment(offset) {
1946
+ this.cbs.oncomment(this.sectionStart, this.index, offset);
1947
+ this.sequenceIndex = 0;
1948
+ this.sectionStart = this.index + 1;
1949
+ this.state = State.Text;
1950
+ }
1951
+ /**
1952
+ * Comments and CDATA end with `-->` and `]]>`.
1953
+ *
1954
+ * Their common qualities are:
1955
+ * - Their end sequences have a distinct character they start with.
1956
+ * - That character is then repeated, so we have to check multiple repeats.
1957
+ * - All characters but the start character of the sequence can be skipped.
1958
+ * @param c Current character code point.
1959
+ */
1960
+ stateInCommentLike(c) {
1961
+ if (!this.xmlMode && this.currentSequence === Sequences.CommentEnd && this.sequenceIndex <= 1 && this.index === this.sectionStart + this.sequenceIndex && c === CharCodes.Gt) this.emitComment(this.sequenceIndex);
1962
+ else if (this.currentSequence === Sequences.CommentEnd && this.sequenceIndex === 2 && c === CharCodes.Gt) this.emitComment(2);
1963
+ else if (this.currentSequence === Sequences.CommentEnd && this.sequenceIndex === this.currentSequence.length - 1 && c !== CharCodes.Gt) this.sequenceIndex = Number(c === CharCodes.Dash);
1964
+ else if (c === this.currentSequence[this.sequenceIndex]) {
1965
+ if (++this.sequenceIndex === this.currentSequence.length) {
1966
+ if (this.currentSequence === Sequences.CdataEnd) this.cbs.oncdata(this.sectionStart, this.index, 2);
1967
+ else this.cbs.oncomment(this.sectionStart, this.index, 3);
1968
+ this.sequenceIndex = 0;
1969
+ this.sectionStart = this.index + 1;
1970
+ this.state = State.Text;
1971
+ }
1972
+ } else if (this.sequenceIndex === 0) {
1973
+ if (this.fastForwardTo(this.currentSequence[0])) this.sequenceIndex = 1;
1974
+ } else if (c !== this.currentSequence[this.sequenceIndex - 1]) this.sequenceIndex = 0;
1975
+ }
1976
+ /**
1977
+ * HTML only allows ASCII alpha characters (a-z and A-Z) at the beginning of a tag name.
1978
+ *
1979
+ * XML allows a lot more characters here (@see https://www.w3.org/TR/REC-xml/#NT-NameStartChar).
1980
+ * We allow anything that wouldn't end the tag.
1981
+ * @param c Current character code point.
1982
+ */
1983
+ isTagStartChar(c) {
1984
+ return this.xmlMode ? !isEndOfTagSection(c) : isASCIIAlpha(c);
1985
+ }
1986
+ /**
1987
+ * Scan raw-text / RCDATA content for the matching end tag.
1988
+ *
1989
+ * For RCDATA tags (`<title>`, `<textarea>`) entities are decoded inline.
1990
+ * For raw-text tags (`<script>`, `<style>`, etc.) we fast-forward to `<`.
1991
+ * @param c Current character code point.
1992
+ */
1993
+ stateInSpecialTag(c) {
1994
+ if (this.sequenceIndex === this.currentSequence.length) {
1995
+ if (isEndOfTagSection(c)) {
1996
+ const endOfText = this.index - this.currentSequence.length;
1997
+ if (this.sectionStart < endOfText) {
1998
+ const actualIndex = this.index;
1999
+ this.index = endOfText;
2000
+ this.cbs.ontext(this.sectionStart, endOfText);
2001
+ this.index = actualIndex;
2002
+ }
2003
+ this.isSpecial = false;
2004
+ this.sectionStart = endOfText + 2;
2005
+ this.stateInClosingTagName(c);
2006
+ return;
2007
+ }
2008
+ this.sequenceIndex = 0;
2009
+ }
2010
+ if ((c | 32) === this.currentSequence[this.sequenceIndex]) this.sequenceIndex += 1;
2011
+ else if (this.sequenceIndex === 0) {
2012
+ if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd) {
2013
+ if (this.decodeEntities && c === CharCodes.Amp) this.startEntity();
2014
+ } else if (this.fastForwardTo(CharCodes.Lt)) this.sequenceIndex = 1;
2015
+ } else this.sequenceIndex = Number(c === CharCodes.Lt);
2016
+ }
2017
+ stateBeforeTagName(c) {
2018
+ if (c === CharCodes.ExclamationMark) {
2019
+ this.state = State.BeforeDeclaration;
2020
+ this.sectionStart = this.index + 1;
2021
+ } else if (c === CharCodes.Questionmark) {
2022
+ if (this.xmlMode) {
2023
+ this.state = State.InProcessingInstruction;
2024
+ this.sequenceIndex = 0;
2025
+ this.sectionStart = this.index + 1;
2026
+ } else {
2027
+ this.state = State.InSpecialComment;
2028
+ this.sectionStart = this.index;
2029
+ }
2030
+ } else if (this.isTagStartChar(c)) {
2031
+ this.sectionStart = this.index;
2032
+ const special = this.xmlMode || this.cbs.isInForeignContext?.() ? void 0 : specialStartSequences.get(c | 32);
2033
+ if (special === void 0) this.state = State.InTagName;
2034
+ else {
2035
+ this.isSpecial = true;
2036
+ this.currentSequence = special;
2037
+ this.sequenceIndex = 3;
2038
+ this.state = State.SpecialStartSequence;
2039
+ }
2040
+ } else if (c === CharCodes.Slash) this.state = State.BeforeClosingTagName;
2041
+ else {
2042
+ this.state = State.Text;
2043
+ this.stateText(c);
2044
+ }
2045
+ }
2046
+ stateInTagName(c) {
2047
+ if (isEndOfTagSection(c)) {
2048
+ this.cbs.onopentagname(this.sectionStart, this.index);
2049
+ this.sectionStart = -1;
2050
+ this.state = State.BeforeAttributeName;
2051
+ this.stateBeforeAttributeName(c);
2052
+ }
2053
+ }
2054
+ stateBeforeClosingTagName(c) {
2055
+ if (isWhitespace$1(c)) {
2056
+ if (this.xmlMode) {} else {
2057
+ this.state = State.InSpecialComment;
2058
+ this.sectionStart = this.index;
2059
+ }
2060
+ } else if (c === CharCodes.Gt) {
2061
+ this.state = State.Text;
2062
+ if (!this.xmlMode) this.sectionStart = this.index + 1;
2063
+ } else {
2064
+ this.state = this.isTagStartChar(c) ? State.InClosingTagName : State.InSpecialComment;
2065
+ this.sectionStart = this.index;
2066
+ }
2067
+ }
2068
+ stateInClosingTagName(c) {
2069
+ if (isEndOfTagSection(c)) {
2070
+ this.cbs.onclosetag(this.sectionStart, this.index);
2071
+ this.sectionStart = -1;
2072
+ this.state = State.AfterClosingTagName;
2073
+ this.stateAfterClosingTagName(c);
2074
+ }
2075
+ }
2076
+ stateAfterClosingTagName(c) {
2077
+ if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {
2078
+ this.state = State.Text;
2079
+ this.sectionStart = this.index + 1;
2080
+ }
2081
+ }
2082
+ stateBeforeAttributeName(c) {
2083
+ if (c === CharCodes.Gt) {
2084
+ this.cbs.onopentagend(this.index);
2085
+ this.enterTagBody();
2086
+ this.sectionStart = this.index + 1;
2087
+ } else if (c === CharCodes.Slash) this.state = State.InSelfClosingTag;
2088
+ else if (!isWhitespace$1(c)) {
2089
+ this.state = State.InAttributeName;
2090
+ this.sectionStart = this.index;
2091
+ }
2092
+ }
2093
+ /**
2094
+ * Handle `/` before `>` in an opening tag.
2095
+ *
2096
+ * In HTML mode, text-only tags ignore the self-closing flag and still enter
2097
+ * their raw-text/RCDATA/plaintext state unless self-closing tags are being
2098
+ * recognized. In XML mode, or for ordinary tags, the tokenizer returns to
2099
+ * regular text parsing after emitting the self-closing callback.
2100
+ * @param c Current character code point.
2101
+ */
2102
+ stateInSelfClosingTag(c) {
2103
+ if (c === CharCodes.Gt) {
2104
+ this.cbs.onselfclosingtag(this.index);
2105
+ this.sectionStart = this.index + 1;
2106
+ if (!this.recognizeSelfClosing) {
2107
+ this.enterTagBody();
2108
+ return;
2109
+ }
2110
+ this.state = State.Text;
2111
+ this.isSpecial = false;
2112
+ this.currentSequence = Sequences.Empty;
2113
+ } else if (!isWhitespace$1(c)) {
2114
+ this.state = State.BeforeAttributeName;
2115
+ this.stateBeforeAttributeName(c);
2116
+ }
2117
+ }
2118
+ stateInAttributeName(c) {
2119
+ if (c === CharCodes.Eq || isEndOfTagSection(c)) {
2120
+ this.cbs.onattribname(this.sectionStart, this.index);
2121
+ this.sectionStart = this.index;
2122
+ this.state = State.AfterAttributeName;
2123
+ this.stateAfterAttributeName(c);
2124
+ }
2125
+ }
2126
+ stateAfterAttributeName(c) {
2127
+ if (c === CharCodes.Eq) this.state = State.BeforeAttributeValue;
2128
+ else if (c === CharCodes.Slash || c === CharCodes.Gt) {
2129
+ this.cbs.onattribend(QuoteType.NoValue, this.sectionStart);
2130
+ this.sectionStart = -1;
2131
+ this.state = State.BeforeAttributeName;
2132
+ this.stateBeforeAttributeName(c);
2133
+ } else if (!isWhitespace$1(c)) {
2134
+ this.cbs.onattribend(QuoteType.NoValue, this.sectionStart);
2135
+ this.state = State.InAttributeName;
2136
+ this.sectionStart = this.index;
2137
+ }
2138
+ }
2139
+ stateBeforeAttributeValue(c) {
2140
+ if (c === CharCodes.DoubleQuote) {
2141
+ this.state = State.InAttributeValueDq;
2142
+ this.sectionStart = this.index + 1;
2143
+ } else if (c === CharCodes.SingleQuote) {
2144
+ this.state = State.InAttributeValueSq;
2145
+ this.sectionStart = this.index + 1;
2146
+ } else if (!isWhitespace$1(c)) {
2147
+ this.sectionStart = this.index;
2148
+ this.state = State.InAttributeValueNq;
2149
+ this.stateInAttributeValueNoQuotes(c);
2150
+ }
2151
+ }
2152
+ handleInAttributeValue(c, quote) {
2153
+ if (c === quote || !this.decodeEntities && this.fastForwardTo(quote)) {
2154
+ this.cbs.onattribdata(this.sectionStart, this.index);
2155
+ this.sectionStart = -1;
2156
+ this.cbs.onattribend(quote === CharCodes.DoubleQuote ? QuoteType.Double : QuoteType.Single, this.index + 1);
2157
+ this.state = State.BeforeAttributeName;
2158
+ } else if (this.decodeEntities && c === CharCodes.Amp) this.startEntity();
2159
+ }
2160
+ stateInAttributeValueDoubleQuotes(c) {
2161
+ this.handleInAttributeValue(c, CharCodes.DoubleQuote);
2162
+ }
2163
+ stateInAttributeValueSingleQuotes(c) {
2164
+ this.handleInAttributeValue(c, CharCodes.SingleQuote);
2165
+ }
2166
+ stateInAttributeValueNoQuotes(c) {
2167
+ if (isWhitespace$1(c) || c === CharCodes.Gt) {
2168
+ this.cbs.onattribdata(this.sectionStart, this.index);
2169
+ this.sectionStart = -1;
2170
+ this.cbs.onattribend(QuoteType.Unquoted, this.index);
2171
+ this.state = State.BeforeAttributeName;
2172
+ this.stateBeforeAttributeName(c);
2173
+ } else if (this.decodeEntities && c === CharCodes.Amp) this.startEntity();
2174
+ }
2175
+ /**
2176
+ * Distinguish between CDATA, declarations, HTML comments, and HTML bogus
2177
+ * comments after `<!`.
2178
+ *
2179
+ * In HTML mode, only real comments and doctypes stay on declaration paths;
2180
+ * everything else becomes a bogus comment terminated by the next `>`.
2181
+ * @param c Current character code point.
2182
+ */
2183
+ stateBeforeDeclaration(c) {
2184
+ if (c === CharCodes.OpeningSquareBracket) {
2185
+ this.state = State.CDATASequence;
2186
+ this.sequenceIndex = 0;
2187
+ } else if (this.xmlMode) this.state = c === CharCodes.Dash ? State.BeforeComment : State.InDeclaration;
2188
+ else if ((c | 32) === Sequences.Doctype[0]) {
2189
+ this.state = State.DeclarationSequence;
2190
+ this.currentSequence = Sequences.Doctype;
2191
+ this.sequenceIndex = 1;
2192
+ } else if (c === CharCodes.Gt) {
2193
+ this.cbs.oncomment(this.sectionStart, this.index, 0);
2194
+ this.state = State.Text;
2195
+ this.sectionStart = this.index + 1;
2196
+ } else if (c === CharCodes.Dash) this.state = State.BeforeComment;
2197
+ else this.state = State.InSpecialComment;
2198
+ }
2199
+ /**
2200
+ * Continue matching `doctype` after `<!d`.
2201
+ *
2202
+ * A full `doctype` match stays on the declaration path; any other name falls
2203
+ * back to an HTML bogus comment, which matches browser behavior for
2204
+ * non-doctype `<!...>` constructs.
2205
+ * @param c Current character code point.
2206
+ */
2207
+ stateDeclarationSequence(c) {
2208
+ if (this.sequenceIndex === this.currentSequence.length) {
2209
+ this.state = State.InDeclaration;
2210
+ this.stateInDeclaration(c);
2211
+ } else if ((c | 32) === this.currentSequence[this.sequenceIndex]) this.sequenceIndex += 1;
2212
+ else if (c === CharCodes.Gt) {
2213
+ this.cbs.oncomment(this.sectionStart, this.index, 0);
2214
+ this.state = State.Text;
2215
+ this.sectionStart = this.index + 1;
2216
+ } else this.state = State.InSpecialComment;
2217
+ }
2218
+ stateInDeclaration(c) {
2219
+ if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {
2220
+ this.cbs.ondeclaration(this.sectionStart, this.index);
2221
+ this.state = State.Text;
2222
+ this.sectionStart = this.index + 1;
2223
+ }
2224
+ }
2225
+ /**
2226
+ * XML processing instructions (`<?...?>`).
2227
+ *
2228
+ * In HTML mode `<?` is routed to `InSpecialComment` instead, so this
2229
+ * state is only reachable in XML mode.
2230
+ * @param c Current character code point.
2231
+ */
2232
+ stateInProcessingInstruction(c) {
2233
+ if (c === CharCodes.Questionmark) this.sequenceIndex = 1;
2234
+ else if (c === CharCodes.Gt && this.sequenceIndex === 1) {
2235
+ this.cbs.onprocessinginstruction(this.sectionStart, this.index - 1);
2236
+ this.sequenceIndex = 0;
2237
+ this.state = State.Text;
2238
+ this.sectionStart = this.index + 1;
2239
+ } else this.sequenceIndex = Number(this.fastForwardTo(CharCodes.Questionmark));
2240
+ }
2241
+ stateBeforeComment(c) {
2242
+ if (c === CharCodes.Dash) {
2243
+ this.state = State.InCommentLike;
2244
+ this.currentSequence = Sequences.CommentEnd;
2245
+ this.sequenceIndex = 0;
2246
+ this.sectionStart = this.index + 1;
2247
+ } else if (this.xmlMode) this.state = State.InDeclaration;
2248
+ else if (c === CharCodes.Gt) {
2249
+ this.cbs.oncomment(this.sectionStart, this.index, 0);
2250
+ this.state = State.Text;
2251
+ this.sectionStart = this.index + 1;
2252
+ } else this.state = State.InSpecialComment;
2253
+ }
2254
+ stateInSpecialComment(c) {
2255
+ if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {
2256
+ this.cbs.oncomment(this.sectionStart, this.index, 0);
2257
+ this.state = State.Text;
2258
+ this.sectionStart = this.index + 1;
2259
+ }
2260
+ }
2261
+ startEntity() {
2262
+ this.baseState = this.state;
2263
+ this.state = State.InEntity;
2264
+ this.entityStart = this.index;
2265
+ this.entityDecoder.startEntity(this.xmlMode ? DecodingMode.Strict : this.baseState === State.Text || this.baseState === State.InSpecialTag ? DecodingMode.Legacy : DecodingMode.Attribute);
2266
+ }
2267
+ stateInEntity() {
2268
+ const indexInBuffer = this.index - this.offset;
2269
+ const length = this.entityDecoder.write(this.buffer, indexInBuffer);
2270
+ if (length >= 0) {
2271
+ this.state = this.baseState;
2272
+ if (length === 0) this.index -= 1;
2273
+ } else {
2274
+ if (indexInBuffer < this.buffer.length && this.buffer.charCodeAt(indexInBuffer) === CharCodes.Amp) {
2275
+ this.state = this.baseState;
2276
+ this.index -= 1;
2277
+ return;
2278
+ }
2279
+ this.index = this.offset + this.buffer.length - 1;
2280
+ }
2281
+ }
2282
+ /**
2283
+ * Remove data that has already been consumed from the buffer.
2284
+ */
2285
+ cleanup() {
2286
+ if (this.running && this.sectionStart !== this.index) {
2287
+ if (this.state === State.Text || this.state === State.InPlainText || this.state === State.InSpecialTag && this.sequenceIndex === 0) {
2288
+ this.cbs.ontext(this.sectionStart, this.index);
2289
+ this.sectionStart = this.index;
2290
+ } else if (this.state === State.InAttributeValueDq || this.state === State.InAttributeValueSq || this.state === State.InAttributeValueNq) {
2291
+ this.cbs.onattribdata(this.sectionStart, this.index);
2292
+ this.sectionStart = this.index;
2293
+ }
2294
+ }
2295
+ }
2296
+ shouldContinue() {
2297
+ return this.index < this.buffer.length + this.offset && this.running;
2298
+ }
2299
+ /**
2300
+ * Iterates through the buffer, calling the function corresponding to the current state.
2301
+ *
2302
+ * States that are more likely to be hit are higher up, as a performance improvement.
2303
+ */
2304
+ parse() {
2305
+ while (this.shouldContinue()) {
2306
+ const c = this.buffer.charCodeAt(this.index - this.offset);
2307
+ switch (this.state) {
2308
+ case State.Text:
2309
+ this.stateText(c);
2310
+ break;
2311
+ case State.InPlainText:
2312
+ this.index = this.buffer.length + this.offset - 1;
2313
+ break;
2314
+ case State.SpecialStartSequence:
2315
+ this.stateSpecialStartSequence(c);
2316
+ break;
2317
+ case State.InSpecialTag:
2318
+ this.stateInSpecialTag(c);
2319
+ break;
2320
+ case State.CDATASequence:
2321
+ this.stateCDATASequence(c);
2322
+ break;
2323
+ case State.DeclarationSequence:
2324
+ this.stateDeclarationSequence(c);
2325
+ break;
2326
+ case State.InAttributeValueDq:
2327
+ this.stateInAttributeValueDoubleQuotes(c);
2328
+ break;
2329
+ case State.InAttributeName:
2330
+ this.stateInAttributeName(c);
2331
+ break;
2332
+ case State.InCommentLike:
2333
+ this.stateInCommentLike(c);
2334
+ break;
2335
+ case State.InSpecialComment:
2336
+ this.stateInSpecialComment(c);
2337
+ break;
2338
+ case State.BeforeAttributeName:
2339
+ this.stateBeforeAttributeName(c);
2340
+ break;
2341
+ case State.InTagName:
2342
+ this.stateInTagName(c);
2343
+ break;
2344
+ case State.InClosingTagName:
2345
+ this.stateInClosingTagName(c);
2346
+ break;
2347
+ case State.BeforeTagName:
2348
+ this.stateBeforeTagName(c);
2349
+ break;
2350
+ case State.AfterAttributeName:
2351
+ this.stateAfterAttributeName(c);
2352
+ break;
2353
+ case State.InAttributeValueSq:
2354
+ this.stateInAttributeValueSingleQuotes(c);
2355
+ break;
2356
+ case State.BeforeAttributeValue:
2357
+ this.stateBeforeAttributeValue(c);
2358
+ break;
2359
+ case State.BeforeClosingTagName:
2360
+ this.stateBeforeClosingTagName(c);
2361
+ break;
2362
+ case State.AfterClosingTagName:
2363
+ this.stateAfterClosingTagName(c);
2364
+ break;
2365
+ case State.InAttributeValueNq:
2366
+ this.stateInAttributeValueNoQuotes(c);
2367
+ break;
2368
+ case State.InSelfClosingTag:
2369
+ this.stateInSelfClosingTag(c);
2370
+ break;
2371
+ case State.InDeclaration:
2372
+ this.stateInDeclaration(c);
2373
+ break;
2374
+ case State.BeforeDeclaration:
2375
+ this.stateBeforeDeclaration(c);
2376
+ break;
2377
+ case State.BeforeComment:
2378
+ this.stateBeforeComment(c);
2379
+ break;
2380
+ case State.InProcessingInstruction:
2381
+ this.stateInProcessingInstruction(c);
2382
+ break;
2383
+ case State.InEntity: this.stateInEntity();
2384
+ }
2385
+ this.index++;
2386
+ }
2387
+ this.cleanup();
2388
+ }
2389
+ finish() {
2390
+ if (this.state === State.InEntity) {
2391
+ this.entityDecoder.end();
2392
+ this.state = this.baseState;
2393
+ }
2394
+ this.handleTrailingData();
2395
+ this.cbs.onend();
2396
+ }
2397
+ handleTrailingCommentLikeData(endIndex) {
2398
+ if (this.state !== State.InCommentLike) return false;
2399
+ if (this.currentSequence === Sequences.CdataEnd) {
2400
+ if (this.xmlMode) {
2401
+ if (this.sectionStart < endIndex) this.cbs.oncdata(this.sectionStart, endIndex, 0);
2402
+ } else {
2403
+ const cdataStart = this.sectionStart - Sequences.Cdata.length - 1;
2404
+ this.cbs.oncomment(cdataStart, endIndex, 0);
2405
+ }
2406
+ } else {
2407
+ const offset = this.xmlMode ? 0 : Math.min(this.sequenceIndex, Sequences.CommentEnd.length - 1);
2408
+ this.cbs.oncomment(this.sectionStart, endIndex, offset);
2409
+ }
2410
+ return true;
2411
+ }
2412
+ handleTrailingMarkupDeclaration(endIndex) {
2413
+ if (this.xmlMode) switch (this.state) {
2414
+ case State.InSpecialComment:
2415
+ case State.BeforeComment:
2416
+ case State.CDATASequence:
2417
+ case State.DeclarationSequence:
2418
+ case State.InDeclaration:
2419
+ this.cbs.ontext(this.sectionStart, endIndex);
2420
+ return true;
2421
+ default: return false;
2422
+ }
2423
+ switch (this.state) {
2424
+ case State.BeforeDeclaration:
2425
+ case State.InSpecialComment:
2426
+ case State.BeforeComment:
2427
+ case State.CDATASequence:
2428
+ this.cbs.oncomment(this.sectionStart, endIndex, 0);
2429
+ return true;
2430
+ case State.DeclarationSequence:
2431
+ if (this.sequenceIndex !== Sequences.Doctype.length) this.cbs.oncomment(this.sectionStart, endIndex, 0);
2432
+ return true;
2433
+ case State.InDeclaration: return true;
2434
+ default: return false;
2435
+ }
2436
+ }
2437
+ /** Handle any trailing data. */
2438
+ handleTrailingData() {
2439
+ const endIndex = this.buffer.length + this.offset;
2440
+ if (this.handleTrailingCommentLikeData(endIndex) || this.handleTrailingMarkupDeclaration(endIndex)) return;
2441
+ if (this.sectionStart >= endIndex) return;
2442
+ switch (this.state) {
2443
+ case State.InTagName:
2444
+ case State.BeforeAttributeName:
2445
+ case State.BeforeAttributeValue:
2446
+ case State.AfterAttributeName:
2447
+ case State.InAttributeName:
2448
+ case State.InAttributeValueSq:
2449
+ case State.InAttributeValueDq:
2450
+ case State.InAttributeValueNq:
2451
+ case State.InClosingTagName: break;
2452
+ default: this.cbs.ontext(this.sectionStart, endIndex);
2453
+ }
2454
+ }
2455
+ emitCodePoint(cp, consumed) {
2456
+ if (this.baseState !== State.Text && this.baseState !== State.InSpecialTag) {
2457
+ if (this.sectionStart < this.entityStart) this.cbs.onattribdata(this.sectionStart, this.entityStart);
2458
+ this.sectionStart = this.entityStart + consumed;
2459
+ this.index = this.sectionStart - 1;
2460
+ this.cbs.onattribentity(cp);
2461
+ } else {
2462
+ if (this.sectionStart < this.entityStart) this.cbs.ontext(this.sectionStart, this.entityStart);
2463
+ this.sectionStart = this.entityStart + consumed;
2464
+ this.index = this.sectionStart - 1;
2465
+ this.cbs.ontextentity(cp, this.sectionStart);
2466
+ }
2467
+ }
2468
+ };
2469
+ //#endregion
2470
+ //#region ../../node_modules/.pnpm/htmlparser2@12.0.0/node_modules/htmlparser2/dist/Parser.js
2471
+ const { fromCodePoint } = String;
2472
+ const formTags = /* @__PURE__ */ new Set([
2473
+ "input",
2474
+ "option",
2475
+ "optgroup",
2476
+ "select",
2477
+ "button",
2478
+ "datalist",
2479
+ "textarea"
2480
+ ]);
2481
+ const pTag = /* @__PURE__ */ new Set(["p"]);
2482
+ const headingTags = /* @__PURE__ */ new Set([
2483
+ "h1",
2484
+ "h2",
2485
+ "h3",
2486
+ "h4",
2487
+ "h5",
2488
+ "h6",
2489
+ "p"
2490
+ ]);
2491
+ const tableSectionTags = /* @__PURE__ */ new Set(["thead", "tbody"]);
2492
+ const ddtTags = /* @__PURE__ */ new Set(["dd", "dt"]);
2493
+ const rtpTags = /* @__PURE__ */ new Set(["rt", "rp"]);
2494
+ const openImpliesClose = /* @__PURE__ */ new Map([
2495
+ ["tr", /* @__PURE__ */ new Set([
2496
+ "tr",
2497
+ "th",
2498
+ "td"
2499
+ ])],
2500
+ ["th", /* @__PURE__ */ new Set(["th"])],
2501
+ ["td", /* @__PURE__ */ new Set([
2502
+ "thead",
2503
+ "th",
2504
+ "td"
2505
+ ])],
2506
+ ["body", /* @__PURE__ */ new Set([
2507
+ "head",
2508
+ "link",
2509
+ "script"
2510
+ ])],
2511
+ ["a", /* @__PURE__ */ new Set(["a"])],
2512
+ ["li", /* @__PURE__ */ new Set(["li"])],
2513
+ ["p", pTag],
2514
+ ["h1", headingTags],
2515
+ ["h2", headingTags],
2516
+ ["h3", headingTags],
2517
+ ["h4", headingTags],
2518
+ ["h5", headingTags],
2519
+ ["h6", headingTags],
2520
+ ["select", formTags],
2521
+ ["input", formTags],
2522
+ ["output", formTags],
2523
+ ["button", formTags],
2524
+ ["datalist", formTags],
2525
+ ["textarea", formTags],
2526
+ ["option", /* @__PURE__ */ new Set(["option"])],
2527
+ ["optgroup", /* @__PURE__ */ new Set(["optgroup", "option"])],
2528
+ ["dd", ddtTags],
2529
+ ["dt", ddtTags],
2530
+ ["address", pTag],
2531
+ ["article", pTag],
2532
+ ["aside", pTag],
2533
+ ["blockquote", pTag],
2534
+ ["details", pTag],
2535
+ ["div", pTag],
2536
+ ["dl", pTag],
2537
+ ["fieldset", pTag],
2538
+ ["figcaption", pTag],
2539
+ ["figure", pTag],
2540
+ ["footer", pTag],
2541
+ ["form", pTag],
2542
+ ["header", pTag],
2543
+ ["hr", pTag],
2544
+ ["main", pTag],
2545
+ ["nav", pTag],
2546
+ ["ol", pTag],
2547
+ ["pre", pTag],
2548
+ ["section", pTag],
2549
+ ["table", pTag],
2550
+ ["ul", pTag],
2551
+ ["rt", rtpTags],
2552
+ ["rp", rtpTags],
2553
+ ["tbody", tableSectionTags],
2554
+ ["tfoot", tableSectionTags]
2555
+ ]);
2556
+ const DOCUMENT_TYPE = "doctype";
2557
+ const voidElements = /* @__PURE__ */ new Set([
2558
+ "area",
2559
+ "base",
2560
+ "basefont",
2561
+ "br",
2562
+ "col",
2563
+ "command",
2564
+ "embed",
2565
+ "frame",
2566
+ "hr",
2567
+ "img",
2568
+ "input",
2569
+ "isindex",
2570
+ "keygen",
2571
+ "link",
2572
+ "meta",
2573
+ "param",
2574
+ "source",
2575
+ "track",
2576
+ "wbr"
2577
+ ]);
2578
+ const foreignContextElements = /* @__PURE__ */ new Set(["math", "svg"]);
2579
+ /**
2580
+ * Elements that can be used to integrate HTML content within foreign namespaces (e.g., SVG or MathML).
2581
+ *
2582
+ * Entries must use the SVG-adjusted casing (e.g. "foreignObject" not
2583
+ * "foreignobject") since they are compared against adjusted tag names.
2584
+ */
2585
+ const htmlIntegrationElements = /* @__PURE__ */ new Set([
2586
+ "mi",
2587
+ "mo",
2588
+ "mn",
2589
+ "ms",
2590
+ "mtext",
2591
+ "annotation-xml",
2592
+ "foreignObject",
2593
+ "desc",
2594
+ "title"
2595
+ ]);
2596
+ const svgTagNameAdjustments = /* @__PURE__ */ new Map([
2597
+ ["altglyph", "altGlyph"],
2598
+ ["altglyphdef", "altGlyphDef"],
2599
+ ["altglyphitem", "altGlyphItem"],
2600
+ ["animatecolor", "animateColor"],
2601
+ ["animatemotion", "animateMotion"],
2602
+ ["animatetransform", "animateTransform"],
2603
+ ["clippath", "clipPath"],
2604
+ ["feblend", "feBlend"],
2605
+ ["fecolormatrix", "feColorMatrix"],
2606
+ ["fecomponenttransfer", "feComponentTransfer"],
2607
+ ["fecomposite", "feComposite"],
2608
+ ["feconvolvematrix", "feConvolveMatrix"],
2609
+ ["fediffuselighting", "feDiffuseLighting"],
2610
+ ["fedisplacementmap", "feDisplacementMap"],
2611
+ ["fedistantlight", "feDistantLight"],
2612
+ ["fedropshadow", "feDropShadow"],
2613
+ ["feflood", "feFlood"],
2614
+ ["fefunca", "feFuncA"],
2615
+ ["fefuncb", "feFuncB"],
2616
+ ["fefuncg", "feFuncG"],
2617
+ ["fefuncr", "feFuncR"],
2618
+ ["fegaussianblur", "feGaussianBlur"],
2619
+ ["feimage", "feImage"],
2620
+ ["femerge", "feMerge"],
2621
+ ["femergenode", "feMergeNode"],
2622
+ ["femorphology", "feMorphology"],
2623
+ ["feoffset", "feOffset"],
2624
+ ["fepointlight", "fePointLight"],
2625
+ ["fespecularlighting", "feSpecularLighting"],
2626
+ ["fespotlight", "feSpotLight"],
2627
+ ["fetile", "feTile"],
2628
+ ["feturbulence", "feTurbulence"],
2629
+ ["foreignobject", "foreignObject"],
2630
+ ["glyphref", "glyphRef"],
2631
+ ["lineargradient", "linearGradient"],
2632
+ ["radialgradient", "radialGradient"],
2633
+ ["textpath", "textPath"]
2634
+ ]);
2635
+ var ForeignContext;
2636
+ (function(ForeignContext) {
2637
+ ForeignContext[ForeignContext["None"] = 0] = "None";
2638
+ ForeignContext[ForeignContext["Svg"] = 1] = "Svg";
2639
+ ForeignContext[ForeignContext["MathML"] = 2] = "MathML";
2640
+ })(ForeignContext || (ForeignContext = {}));
2641
+ const reNameEnd = /\s|\//;
2642
+ /**
2643
+ * Incremental parser implementation.
2644
+ */
2645
+ var Parser = class {
2646
+ options;
2647
+ /** The start index of the last event. */
2648
+ startIndex = 0;
2649
+ /** The end index of the last event. */
2650
+ endIndex = 0;
2651
+ /**
2652
+ * Store the start index of the current open tag,
2653
+ * so we can update the start index for attributes.
2654
+ */
2655
+ openTagStart = 0;
2656
+ tagname = "";
2657
+ attribname = "";
2658
+ attribvalue = "";
2659
+ attribs = null;
2660
+ stack = [];
2661
+ foreignContext;
2662
+ cbs;
2663
+ lowerCaseTagNames;
2664
+ lowerCaseAttributeNames;
2665
+ recognizeSelfClosing;
2666
+ /** We are parsing HTML. Inverse of the `xmlMode` option. */
2667
+ htmlMode;
2668
+ tokenizer;
2669
+ buffers = [];
2670
+ bufferOffset = 0;
2671
+ /** The index of the last written buffer. Used when resuming after a `pause()`. */
2672
+ writeIndex = 0;
2673
+ /** Indicates whether the parser has finished running / `.end` has been called. */
2674
+ ended = false;
2675
+ constructor(cbs, options = {}) {
2676
+ this.options = options;
2677
+ this.cbs = cbs ?? {};
2678
+ this.htmlMode = !this.options.xmlMode;
2679
+ this.lowerCaseTagNames = options.lowerCaseTags ?? this.htmlMode;
2680
+ this.lowerCaseAttributeNames = options.lowerCaseAttributeNames ?? this.htmlMode;
2681
+ this.recognizeSelfClosing = options.recognizeSelfClosing ?? !this.htmlMode;
2682
+ this.tokenizer = new (options.Tokenizer ?? Tokenizer)(this.options, this);
2683
+ this.foreignContext = [ForeignContext.None];
2684
+ this.cbs.onparserinit?.(this);
2685
+ }
2686
+ /**
2687
+ * @param start Start index for the current parser event.
2688
+ * @param endIndex End index for the current parser event.
2689
+ * @internal
2690
+ */
2691
+ ontext(start, endIndex) {
2692
+ const data = this.getSlice(start, endIndex);
2693
+ this.endIndex = endIndex - 1;
2694
+ this.cbs.ontext?.(data);
2695
+ this.startIndex = endIndex;
2696
+ }
2697
+ /**
2698
+ * @param cp Current Unicode code point.
2699
+ * @param endIndex End index for the current parser event.
2700
+ * @internal
2701
+ */
2702
+ ontextentity(cp, endIndex) {
2703
+ this.endIndex = endIndex - 1;
2704
+ this.cbs.ontext?.(fromCodePoint(cp));
2705
+ this.startIndex = endIndex;
2706
+ }
2707
+ /** @internal */
2708
+ isInForeignContext() {
2709
+ return this.foreignContext[0] !== ForeignContext.None;
2710
+ }
2711
+ /**
2712
+ * Checks if the current tag is a void element. Override this if you want
2713
+ * to specify your own additional void elements.
2714
+ * @param name Name of the pseudo selector.
2715
+ */
2716
+ isVoidElement(name) {
2717
+ return this.htmlMode && voidElements.has(name);
2718
+ }
2719
+ /**
2720
+ * Read a tag name from the buffer.
2721
+ *
2722
+ * When `lowerCaseTagNames` is enabled (the default in HTML mode), the name
2723
+ * is lowercased and may be adjusted for SVG casing or the `image` → `img`
2724
+ * alias.
2725
+ * @param start Start index of the tag name in the buffer.
2726
+ * @param endIndex End index of the tag name in the buffer.
2727
+ */
2728
+ readTagName(start, endIndex) {
2729
+ const name = this.lowerCaseTagNames ? this.getSlice(start, endIndex).toLowerCase() : this.getSlice(start, endIndex);
2730
+ if (!(this.lowerCaseTagNames && this.htmlMode)) return name;
2731
+ if (this.foreignContext[0] === ForeignContext.Svg) return svgTagNameAdjustments.get(name) ?? name;
2732
+ if (this.foreignContext.length > 1) {
2733
+ const adjusted = svgTagNameAdjustments.get(name);
2734
+ if (adjusted !== void 0 && this.stack.includes(adjusted)) return adjusted;
2735
+ }
2736
+ if (!this.isInForeignContext()) return name === "image" ? "img" : name;
2737
+ return name;
2738
+ }
2739
+ /**
2740
+ * @param start Start index for the current parser event.
2741
+ * @param endIndex End index for the current parser event.
2742
+ * @internal
2743
+ */
2744
+ onopentagname(start, endIndex) {
2745
+ this.endIndex = endIndex;
2746
+ this.emitOpenTag(this.readTagName(start, endIndex));
2747
+ }
2748
+ emitOpenTag(name) {
2749
+ this.openTagStart = this.startIndex;
2750
+ this.tagname = name;
2751
+ if (this.htmlMode && name === "form" && this.stack.includes("form")) {
2752
+ this.tagname = "";
2753
+ return;
2754
+ }
2755
+ const impliesClose = this.htmlMode && openImpliesClose.get(name);
2756
+ if (impliesClose) while (this.stack.length > 0 && impliesClose.has(this.stack[0])) this.popElement(true);
2757
+ if (!this.isVoidElement(name)) {
2758
+ this.stack.unshift(name);
2759
+ if (this.htmlMode) {
2760
+ if (name === "svg") this.foreignContext.unshift(ForeignContext.Svg);
2761
+ else if (name === "math") this.foreignContext.unshift(ForeignContext.MathML);
2762
+ else if (htmlIntegrationElements.has(name)) this.foreignContext.unshift(ForeignContext.None);
2763
+ }
2764
+ }
2765
+ this.cbs.onopentagname?.(name);
2766
+ if (this.cbs.onopentag) this.attribs = {};
2767
+ }
2768
+ endOpenTag(isImplied) {
2769
+ this.startIndex = this.openTagStart;
2770
+ if (this.attribs) {
2771
+ this.cbs.onopentag?.(this.tagname, this.attribs, isImplied);
2772
+ this.attribs = null;
2773
+ }
2774
+ if (this.cbs.onclosetag && this.isVoidElement(this.tagname)) this.cbs.onclosetag(this.tagname, true);
2775
+ this.tagname = "";
2776
+ }
2777
+ /**
2778
+ * @param endIndex End index for the current parser event.
2779
+ * @internal
2780
+ */
2781
+ onopentagend(endIndex) {
2782
+ this.endIndex = endIndex;
2783
+ this.endOpenTag(false);
2784
+ this.startIndex = endIndex + 1;
2785
+ }
2786
+ /**
2787
+ * @param start Start index for the current parser event.
2788
+ * @param endIndex End index for the current parser event.
2789
+ * @internal
2790
+ */
2791
+ onclosetag(start, endIndex) {
2792
+ this.endIndex = endIndex;
2793
+ const name = this.readTagName(start, endIndex);
2794
+ if (!this.isVoidElement(name)) {
2795
+ const pos = this.stack.indexOf(name);
2796
+ if (pos !== -1) {
2797
+ for (let index = 0; index < pos; index++) this.popElement(true);
2798
+ this.popElement(false);
2799
+ } else if (this.htmlMode && name === "p") {
2800
+ this.emitOpenTag("p");
2801
+ this.closeCurrentTag(true);
2802
+ }
2803
+ } else if (this.htmlMode && name === "br") {
2804
+ this.cbs.onopentagname?.("br");
2805
+ this.cbs.onopentag?.("br", {}, true);
2806
+ this.cbs.onclosetag?.("br", false);
2807
+ }
2808
+ this.startIndex = endIndex + 1;
2809
+ }
2810
+ /**
2811
+ * @param endIndex End index for the current parser event.
2812
+ * @internal
2813
+ */
2814
+ onselfclosingtag(endIndex) {
2815
+ this.endIndex = endIndex;
2816
+ if (this.recognizeSelfClosing || this.isInForeignContext()) {
2817
+ this.closeCurrentTag(false);
2818
+ this.startIndex = endIndex + 1;
2819
+ } else this.onopentagend(endIndex);
2820
+ }
2821
+ /**
2822
+ * Pop the top element off the stack, emit a close event, and maintain
2823
+ * the foreign context stack.
2824
+ * @param implied Whether this close is implied (not from an explicit end tag).
2825
+ */
2826
+ popElement(implied) {
2827
+ const element = this.stack.shift();
2828
+ if (this.htmlMode && (foreignContextElements.has(element) || htmlIntegrationElements.has(element))) this.foreignContext.shift();
2829
+ this.cbs.onclosetag?.(element, implied);
2830
+ }
2831
+ closeCurrentTag(isOpenImplied) {
2832
+ const name = this.tagname;
2833
+ this.endOpenTag(isOpenImplied);
2834
+ if (this.stack[0] === name) this.popElement(!isOpenImplied);
2835
+ }
2836
+ /**
2837
+ * @param start Start index for the current parser event.
2838
+ * @param endIndex End index for the current parser event.
2839
+ * @internal
2840
+ */
2841
+ onattribname(start, endIndex) {
2842
+ this.startIndex = start;
2843
+ const name = this.getSlice(start, endIndex);
2844
+ this.attribname = this.lowerCaseAttributeNames ? name.toLowerCase() : name;
2845
+ }
2846
+ /**
2847
+ * @param start Start index for the current parser event.
2848
+ * @param endIndex End index for the current parser event.
2849
+ * @internal
2850
+ */
2851
+ onattribdata(start, endIndex) {
2852
+ this.attribvalue += this.getSlice(start, endIndex);
2853
+ }
2854
+ /**
2855
+ * @param cp Current Unicode code point.
2856
+ * @internal
2857
+ */
2858
+ onattribentity(cp) {
2859
+ this.attribvalue += fromCodePoint(cp);
2860
+ }
2861
+ /**
2862
+ * @param quote Quote type used for the current attribute.
2863
+ * @param endIndex End index for the current parser event.
2864
+ * @internal
2865
+ */
2866
+ onattribend(quote, endIndex) {
2867
+ this.endIndex = endIndex;
2868
+ this.cbs.onattribute?.(this.attribname, this.attribvalue, quote === QuoteType.Double ? "\"" : quote === QuoteType.Single ? "'" : quote === QuoteType.NoValue ? void 0 : null);
2869
+ if (this.attribs && !Object.hasOwn(this.attribs, this.attribname)) this.attribs[this.attribname] = this.attribvalue;
2870
+ this.attribvalue = "";
2871
+ }
2872
+ getInstructionName(value) {
2873
+ const index = value.search(reNameEnd);
2874
+ let name = index < 0 ? value : value.substr(0, index);
2875
+ if (this.lowerCaseTagNames) name = name.toLowerCase();
2876
+ return name;
2877
+ }
2878
+ /**
2879
+ * @param start Start index for the current parser event.
2880
+ * @param endIndex End index for the current parser event.
2881
+ * @internal
2882
+ */
2883
+ ondeclaration(start, endIndex) {
2884
+ this.endIndex = endIndex;
2885
+ const value = this.getSlice(start, endIndex);
2886
+ if (this.cbs.onprocessinginstruction) {
2887
+ const name = this.htmlMode ? this.lowerCaseTagNames ? DOCUMENT_TYPE : value.slice(0, 7) : this.getInstructionName(value);
2888
+ this.cbs.onprocessinginstruction(`!${name}`, `!${value}`);
2889
+ }
2890
+ this.startIndex = endIndex + 1;
2891
+ }
2892
+ /**
2893
+ * @param start Start index for the current parser event.
2894
+ * @param endIndex End index for the current parser event.
2895
+ * @internal
2896
+ */
2897
+ onprocessinginstruction(start, endIndex) {
2898
+ this.endIndex = endIndex;
2899
+ const value = this.getSlice(start, endIndex);
2900
+ if (this.cbs.onprocessinginstruction) {
2901
+ const name = this.getInstructionName(value);
2902
+ this.cbs.onprocessinginstruction(`?${name}`, `?${value}`);
2903
+ }
2904
+ this.startIndex = endIndex + 1;
2905
+ }
2906
+ /**
2907
+ * @param start Start index for the current parser event.
2908
+ * @param endIndex End index for the current parser event.
2909
+ * @param offset Offset applied when computing parser indices.
2910
+ * @internal
2911
+ */
2912
+ oncomment(start, endIndex, offset) {
2913
+ this.endIndex = endIndex;
2914
+ this.cbs.oncomment?.(this.getSlice(start, endIndex - offset));
2915
+ this.cbs.oncommentend?.();
2916
+ this.startIndex = endIndex + 1;
2917
+ }
2918
+ /**
2919
+ * @param start Start index for the current parser event.
2920
+ * @param endIndex End index for the current parser event.
2921
+ * @param offset Offset applied when computing parser indices.
2922
+ * @internal
2923
+ */
2924
+ oncdata(start, endIndex, offset) {
2925
+ this.endIndex = endIndex;
2926
+ const value = this.getSlice(start, endIndex - offset);
2927
+ if (!this.htmlMode || this.options.recognizeCDATA) {
2928
+ this.cbs.oncdatastart?.();
2929
+ this.cbs.ontext?.(value);
2930
+ this.cbs.oncdataend?.();
2931
+ } else if (this.isInForeignContext()) this.cbs.ontext?.(value);
2932
+ else {
2933
+ this.cbs.oncomment?.(`[CDATA[${value}]]`);
2934
+ this.cbs.oncommentend?.();
2935
+ }
2936
+ this.startIndex = endIndex + 1;
2937
+ }
2938
+ /** @internal */
2939
+ onend() {
2940
+ if (this.cbs.onclosetag) {
2941
+ this.endIndex = this.startIndex;
2942
+ for (let index = 0; index < this.stack.length; index++) this.cbs.onclosetag(this.stack[index], true);
2943
+ }
2944
+ this.cbs.onend?.();
2945
+ }
2946
+ /**
2947
+ * Resets the parser to a blank state, ready to parse a new HTML document
2948
+ */
2949
+ reset() {
2950
+ this.cbs.onreset?.();
2951
+ this.tokenizer.reset();
2952
+ this.tagname = "";
2953
+ this.attribname = "";
2954
+ this.attribvalue = "";
2955
+ this.attribs = null;
2956
+ this.stack.length = 0;
2957
+ this.startIndex = 0;
2958
+ this.endIndex = 0;
2959
+ this.cbs.onparserinit?.(this);
2960
+ this.buffers.length = 0;
2961
+ this.foreignContext.length = 0;
2962
+ this.foreignContext.unshift(ForeignContext.None);
2963
+ this.bufferOffset = 0;
2964
+ this.writeIndex = 0;
2965
+ this.ended = false;
2966
+ }
2967
+ /**
2968
+ * Resets the parser, then parses a complete document and
2969
+ * pushes it to the handler.
2970
+ * @param data Document to parse.
2971
+ */
2972
+ parseComplete(data) {
2973
+ this.reset();
2974
+ this.end(data);
2975
+ }
2976
+ getSlice(start, end) {
2977
+ if (start === end) return "";
2978
+ while (start - this.bufferOffset >= this.buffers[0].length) this.shiftBuffer();
2979
+ let slice = this.buffers[0].slice(start - this.bufferOffset, end - this.bufferOffset);
2980
+ while (end - this.bufferOffset > this.buffers[0].length) {
2981
+ this.shiftBuffer();
2982
+ slice += this.buffers[0].slice(0, end - this.bufferOffset);
2983
+ }
2984
+ return slice;
2985
+ }
2986
+ shiftBuffer() {
2987
+ this.bufferOffset += this.buffers[0].length;
2988
+ this.writeIndex--;
2989
+ this.buffers.shift();
2990
+ }
2991
+ /**
2992
+ * Parses a chunk of data and calls the corresponding callbacks.
2993
+ * @param chunk Chunk to parse.
2994
+ */
2995
+ write(chunk) {
2996
+ if (this.ended) {
2997
+ this.cbs.onerror?.(/* @__PURE__ */ new Error(".write() after done!"));
2998
+ return;
2999
+ }
3000
+ this.buffers.push(chunk);
3001
+ if (this.tokenizer.running) {
3002
+ this.tokenizer.write(chunk);
3003
+ this.writeIndex++;
3004
+ }
3005
+ }
3006
+ /**
3007
+ * Parses the end of the buffer and clears the stack, calls onend.
3008
+ * @param chunk Optional final chunk to parse.
3009
+ */
3010
+ end(chunk) {
3011
+ if (this.ended) {
3012
+ this.cbs.onerror?.(/* @__PURE__ */ new Error(".end() after done!"));
3013
+ return;
3014
+ }
3015
+ if (chunk) this.write(chunk);
3016
+ this.ended = true;
3017
+ this.tokenizer.end();
3018
+ }
3019
+ /**
3020
+ * Pauses parsing. The parser won't emit events until `resume` is called.
3021
+ */
3022
+ pause() {
3023
+ this.tokenizer.pause();
3024
+ }
3025
+ /**
3026
+ * Resumes parsing after `pause` was called.
3027
+ */
3028
+ resume() {
3029
+ this.tokenizer.resume();
3030
+ while (this.tokenizer.running && this.writeIndex < this.buffers.length) this.tokenizer.write(this.buffers[this.writeIndex++]);
3031
+ if (this.ended) this.tokenizer.end();
3032
+ }
3033
+ };
3034
+ //#endregion
3035
+ //#region src/extraction/source-filters.ts
3036
+ const HTML_ATTRIBUTE_NAME_CANDIDATE_RE$1 = /^(?:class|className|hover-class|hoverClass)$/;
3037
+ const CSS_DIRECTIVE_CANDIDATE_RE = /^@(?:apply|tailwind|source|config|plugin|theme|utility|custom-variant|variant)$/;
3038
+ const CSS_APPLY_IMPORTANT = "!important";
3039
+ const CLASS_LIKE_CANDIDATE_RE = /[:![\]#/%._\-\d]/;
3040
+ const JS_LIKE_SOURCE_EXTENSION_RE = /^[cm]?[jt]sx?$/;
3041
+ const MIXED_TEMPLATE_SOURCE_EXTENSION_RE = /^(?:vue|uvue|nvue|svelte|mpx)$/;
3042
+ const VUE_LIKE_SOURCE_EXTENSION_RE = /^(?:vue|uvue|nvue)$/;
3043
+ const CSS_LIKE_SOURCE_EXTENSION_RE = /^(?:css|wxss|acss|jxss|ttss|qss|tyss|scss|sass|less|styl|stylus)$/;
3044
+ function isWhitespace(value) {
3045
+ return value === " " || value === "\n" || value === "\r" || value === " " || value === "\f";
3046
+ }
3047
+ function isHtmlAttributeNameCandidate(content, candidate) {
3048
+ if (!HTML_ATTRIBUTE_NAME_CANDIDATE_RE$1.test(candidate.rawCandidate)) return false;
3049
+ let index = candidate.end;
3050
+ while (isWhitespace(content[index])) index++;
3051
+ return content[index] === "=";
3052
+ }
3053
+ function isInsideHtmlTagText(content, candidate) {
3054
+ if (content.lastIndexOf("<", candidate.start) > content.lastIndexOf(">", candidate.start)) return false;
3055
+ const nextOpen = content.indexOf("<", candidate.end);
3056
+ return nextOpen !== -1 && (nextOpen < content.indexOf(">", candidate.end) || !content.includes(">", candidate.end));
3057
+ }
3058
+ function isCssDirectiveCandidate(candidate) {
3059
+ return candidate === CSS_APPLY_IMPORTANT || CSS_DIRECTIVE_CANDIDATE_RE.test(candidate);
3060
+ }
3061
+ function isClassLikeCandidate(candidate) {
3062
+ return CLASS_LIKE_CANDIDATE_RE.test(candidate);
3063
+ }
3064
+ function isCandidateInCssApplyParams(content, candidate) {
3065
+ const apply = content.lastIndexOf("@apply", candidate.start);
3066
+ if (apply === -1) return false;
3067
+ const boundary = content.slice(apply + 6, candidate.start);
3068
+ return !/[;{}]/.test(boundary);
3069
+ }
3070
+ function shouldKeepSourceCandidate(content, extension, candidate, jsStringStaticRanges, skipHtmlContextChecks = false) {
3071
+ if (!candidate.rawCandidate || isCssDirectiveCandidate(candidate.rawCandidate)) return false;
3072
+ if (CSS_LIKE_SOURCE_EXTENSION_RE.test(extension) && !isCandidateInCssApplyParams(content, candidate)) return false;
3073
+ if (!skipHtmlContextChecks) {
3074
+ if (isHtmlAttributeNameCandidate(content, candidate)) return false;
3075
+ if (isInsideHtmlTagText(content, candidate)) return false;
3076
+ }
3077
+ if (JS_LIKE_SOURCE_EXTENSION_RE.test(extension) && !isCandidateInsideJsStringStaticRanges(jsStringStaticRanges ?? createJsStringStaticRanges(content), candidate.start)) return false;
3078
+ return true;
3079
+ }
3080
+ function createLocalCandidate(candidate) {
3081
+ return {
3082
+ rawCandidate: candidate.rawCandidate,
3083
+ start: candidate.localStart,
3084
+ end: candidate.localStart + candidate.rawCandidate.length
3085
+ };
3086
+ }
3087
+ function dedupeCandidatesWithPositions(candidates) {
3088
+ const seen = /* @__PURE__ */ new Set();
3089
+ return candidates.filter((candidate) => {
3090
+ const key = `${candidate.start}:${candidate.end}:${candidate.rawCandidate}`;
3091
+ if (seen.has(key)) return false;
3092
+ seen.add(key);
3093
+ return true;
3094
+ });
3095
+ }
3096
+ //#endregion
3097
+ //#region src/extraction/sfc.ts
3098
+ const HTML_ATTRIBUTE_NAME_CANDIDATE_RE = /^(?:class|className|hover-class|hoverClass)$/;
3099
+ const HTML_BOUND_ATTRIBUTE_PREFIX_RE = /^(?::|v-bind:|bind:)/;
3100
+ const VUE_HTML_TEMPLATE_LANG_RE = /^(?:html)?$/i;
3101
+ const SFC_SCRIPT_BLOCK_RE = /<script\b[^>]*>([\s\S]*?)<\/script>/gi;
3102
+ const SFC_STYLE_BLOCK_RE = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
3103
+ const SFC_TEMPLATE_BLOCK_RE = /<template\b([^>]*)>([\s\S]*?)<\/template>/gi;
3104
+ const SFC_LANG_ATTRIBUTE_RE = /\blang\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))/i;
3105
+ function normalizeVueBoundAttributeName(name) {
3106
+ return name.replace(HTML_BOUND_ATTRIBUTE_PREFIX_RE, "");
3107
+ }
3108
+ function isVueClassAttributeNameCandidate(name) {
3109
+ return HTML_ATTRIBUTE_NAME_CANDIDATE_RE.test(normalizeVueBoundAttributeName(name));
3110
+ }
3111
+ function isVueBoundAttributeName(name) {
3112
+ return HTML_BOUND_ATTRIBUTE_PREFIX_RE.test(name);
3113
+ }
3114
+ function normalizeVueTemplateLang(lang) {
3115
+ return lang?.trim().toLowerCase() ?? "";
3116
+ }
3117
+ function getSfcBlockLang(attributes) {
3118
+ const match = SFC_LANG_ATTRIBUTE_RE.exec(attributes);
3119
+ return normalizeVueTemplateLang(match?.[1] ?? match?.[2] ?? match?.[3]);
3120
+ }
3121
+ function isVueHtmlTemplateLang(lang) {
3122
+ return VUE_HTML_TEMPLATE_LANG_RE.test(lang);
3123
+ }
3124
+ function findAttributeValueStart(attributeSource, value) {
3125
+ const equalIndex = attributeSource.indexOf("=");
3126
+ if (equalIndex === -1) return -1;
3127
+ let valueStart = equalIndex + 1;
3128
+ while (isWhitespace(attributeSource[valueStart])) valueStart++;
3129
+ const quote = attributeSource[valueStart];
3130
+ if (quote === "\"" || quote === "'") valueStart++;
3131
+ const valueIndex = attributeSource.indexOf(value, valueStart);
3132
+ return valueIndex === -1 ? valueStart : valueIndex;
3133
+ }
3134
+ async function extractJsStringSourceCandidates(content, offset, extractRawCandidatesWithPositions, options) {
3135
+ return extractBatchedSourceSegmentCandidates(createJsStringSourceSegments(content, offset), "html", extractRawCandidatesWithPositions, options);
3136
+ }
3137
+ async function extractMixedSourceScriptCandidates(content, extractRawCandidatesWithPositions, options) {
3138
+ const candidates = [];
3139
+ SFC_SCRIPT_BLOCK_RE.lastIndex = 0;
3140
+ let match = SFC_SCRIPT_BLOCK_RE.exec(content);
3141
+ while (match !== null) {
3142
+ const scriptContent = match[1] ?? "";
3143
+ const scriptStart = match.index + match[0].indexOf(scriptContent);
3144
+ candidates.push(...await extractJsStringSourceCandidates(scriptContent, scriptStart, extractRawCandidatesWithPositions, options));
3145
+ match = SFC_SCRIPT_BLOCK_RE.exec(content);
3146
+ }
3147
+ return candidates;
3148
+ }
3149
+ async function extractMixedSourceStyleCandidates(content, extractRawCandidatesWithPositions, options) {
3150
+ const candidates = [];
3151
+ SFC_STYLE_BLOCK_RE.lastIndex = 0;
3152
+ let match = SFC_STYLE_BLOCK_RE.exec(content);
3153
+ while (match !== null) {
3154
+ const styleContent = match[1] ?? "";
3155
+ const styleStart = match.index + match[0].indexOf(styleContent);
3156
+ const styleCandidates = await extractCssApplyCandidates(styleContent, "css", extractRawCandidatesWithPositions, options);
3157
+ candidates.push(...styleCandidates.map((candidate) => ({
3158
+ content: candidate.content,
3159
+ extension: candidate.extension,
3160
+ localStart: candidate.localStart,
3161
+ rawCandidate: candidate.rawCandidate,
3162
+ start: candidate.start + styleStart,
3163
+ end: candidate.end + styleStart
3164
+ })));
3165
+ match = SFC_STYLE_BLOCK_RE.exec(content);
3166
+ }
3167
+ return candidates;
3168
+ }
3169
+ async function extractVueTemplateAttributeCandidates(content, extractRawCandidatesWithPositions, options) {
3170
+ const htmlSegments = [];
3171
+ const jsSegments = [];
3172
+ const parser = new Parser({ onattribute(name, value) {
3173
+ if (!value || !isVueClassAttributeNameCandidate(name)) return;
3174
+ const attributeStart = parser.startIndex;
3175
+ const valueStartInAttribute = findAttributeValueStart(content.slice(attributeStart, parser.endIndex + 1), value);
3176
+ if (valueStartInAttribute === -1) return;
3177
+ const extension = isVueBoundAttributeName(name) ? "js" : "html";
3178
+ const valueStart = attributeStart + valueStartInAttribute;
3179
+ (extension === "js" ? jsSegments : htmlSegments).push({
3180
+ content: value,
3181
+ start: valueStart
3182
+ });
3183
+ } }, { lowerCaseAttributeNames: false });
3184
+ parser.write(content);
3185
+ parser.end();
3186
+ const jsStringSegments = jsSegments.flatMap((segment) => createJsStringSourceSegments(segment.content, segment.start));
3187
+ const [htmlCandidates, jsCandidates] = await Promise.all([extractBatchedSourceSegmentCandidates(htmlSegments, "html", extractRawCandidatesWithPositions, options), extractBatchedSourceSegmentCandidates(jsStringSegments, "html", extractRawCandidatesWithPositions, options)]);
3188
+ return [...htmlCandidates, ...jsCandidates];
3189
+ }
3190
+ async function extractVueNonHtmlTemplateCandidates(content, extractRawCandidatesWithPositions, options) {
3191
+ const candidates = [];
3192
+ SFC_TEMPLATE_BLOCK_RE.lastIndex = 0;
3193
+ let match = SFC_TEMPLATE_BLOCK_RE.exec(content);
3194
+ while (match !== null) {
3195
+ const attributes = match[1] ?? "";
3196
+ const templateContent = match[2] ?? "";
3197
+ const lang = getSfcBlockLang(attributes);
3198
+ if (isVueHtmlTemplateLang(lang)) {
3199
+ match = SFC_TEMPLATE_BLOCK_RE.exec(content);
3200
+ continue;
3201
+ }
3202
+ const templateStart = match.index + match[0].indexOf(templateContent);
3203
+ const templateCandidates = await extractRawCandidatesWithPositions(templateContent, lang, options);
3204
+ candidates.push(...templateCandidates.map((candidate) => ({
3205
+ content: templateContent,
3206
+ extension: lang,
3207
+ localStart: candidate.start,
3208
+ rawCandidate: candidate.rawCandidate,
3209
+ skipHtmlContextChecks: true,
3210
+ start: candidate.start + templateStart,
3211
+ end: candidate.end + templateStart
3212
+ })).filter((candidate) => isClassLikeCandidate(candidate.rawCandidate)));
3213
+ match = SFC_TEMPLATE_BLOCK_RE.exec(content);
3214
+ }
3215
+ return candidates;
3216
+ }
3217
+ async function extractVueLikeSourceCandidates(content, extractRawCandidatesWithPositions, options) {
3218
+ const [templateCandidates, preprocessedTemplateCandidates, scriptCandidates, styleCandidates] = await Promise.all([
3219
+ extractVueTemplateAttributeCandidates(content, extractRawCandidatesWithPositions, options),
3220
+ extractVueNonHtmlTemplateCandidates(content, extractRawCandidatesWithPositions, options),
3221
+ extractMixedSourceScriptCandidates(content, extractRawCandidatesWithPositions, options),
3222
+ extractMixedSourceStyleCandidates(content, extractRawCandidatesWithPositions, options)
3223
+ ]);
3224
+ return [
3225
+ ...templateCandidates,
3226
+ ...preprocessedTemplateCandidates,
3227
+ ...scriptCandidates,
3228
+ ...styleCandidates
3229
+ ];
3230
+ }
3231
+ //#endregion
3232
+ //#region src/extraction/candidate-extractor/raw.ts
3233
+ async function extractRawCandidatesWithPositions(content, extension = "html", options) {
3234
+ const { Scanner } = await getOxideModule();
3235
+ const candidates = new Scanner({}).getCandidatesWithPositions({
3236
+ content,
3237
+ extension
3238
+ }).map(({ candidate, position }) => ({
3239
+ rawCandidate: candidate,
3240
+ start: position,
3241
+ end: position + candidate.length
3242
+ }));
3243
+ candidates.push(...extractBareArbitraryValueSourceCandidatesWithPositions(content, options?.bareArbitraryValues));
3244
+ return dedupeCandidatesWithPositions(candidates);
3245
+ }
3246
+ async function extractSourceCandidatesWithPositions(content, extension = "html", options) {
3247
+ const normalizedExtension = extension.replace(/^\./, "");
3248
+ const candidates = VUE_LIKE_SOURCE_EXTENSION_RE.test(normalizedExtension) ? await extractVueLikeSourceCandidates(content, extractRawCandidatesWithPositions, options) : CSS_LIKE_SOURCE_EXTENSION_RE.test(normalizedExtension) ? await extractCssApplyCandidates(content, normalizedExtension, extractRawCandidatesWithPositions, options) : (await extractRawCandidatesWithPositions(content, normalizedExtension, options)).map((candidate) => ({
3249
+ ...candidate,
3250
+ content,
3251
+ extension: normalizedExtension,
3252
+ localStart: candidate.start
3253
+ }));
3254
+ if (!VUE_LIKE_SOURCE_EXTENSION_RE.test(normalizedExtension) && MIXED_TEMPLATE_SOURCE_EXTENSION_RE.test(normalizedExtension)) candidates.push(...await extractMixedSourceScriptCandidates(content, extractRawCandidatesWithPositions, options));
3255
+ const jsStringStaticRangesByContent = /* @__PURE__ */ new Map();
3256
+ function getJsStringStaticRanges(candidate) {
3257
+ if (!JS_LIKE_SOURCE_EXTENSION_RE.test(candidate.extension)) return;
3258
+ const cached = jsStringStaticRangesByContent.get(candidate.content);
3259
+ if (cached) return cached;
3260
+ const ranges = createJsStringStaticRanges(candidate.content);
3261
+ jsStringStaticRangesByContent.set(candidate.content, ranges);
3262
+ return ranges;
3263
+ }
3264
+ const seen = /* @__PURE__ */ new Set();
3265
+ return candidates.filter((candidate) => {
3266
+ if (!shouldKeepSourceCandidate(candidate.content, candidate.extension, createLocalCandidate(candidate), getJsStringStaticRanges(candidate), candidate.skipHtmlContextChecks)) return false;
3267
+ const key = `${candidate.start}:${candidate.end}:${candidate.rawCandidate}`;
3268
+ if (seen.has(key)) return false;
3269
+ seen.add(key);
3270
+ return true;
3271
+ }).map(({ rawCandidate, start, end }) => ({
3272
+ rawCandidate,
3273
+ start,
3274
+ end
3275
+ }));
3276
+ }
3277
+ async function extractSourceCandidates(content, extension = "html", options) {
3278
+ const candidates = await extractSourceCandidatesWithPositions(content, extension, options);
3279
+ return [...new Set(candidates.map((candidate) => candidate.rawCandidate))];
3280
+ }
3281
+ async function extractRawCandidates(sources, options) {
3282
+ const { Scanner } = await getOxideModule();
3283
+ const scanner = new Scanner(sources === void 0 ? {} : { sources });
3284
+ const files = scanner.files ?? [];
3285
+ const cacheKey = createRawCandidateCacheKey(sources, options);
3286
+ const fingerprint = await createRawCandidateFileFingerprint(files);
3287
+ const cached = getRawCandidateCacheEntry(cacheKey, fingerprint);
3288
+ if (cached) return [...cached.candidates];
3289
+ const scannedCandidates = scanner.scan();
3290
+ if (scannedCandidates.length === 0 && files.length > 0) {
3291
+ const changedContents = (await Promise.all(files.map(async (file) => {
3292
+ try {
3293
+ return {
3294
+ content: await node_fs.promises.readFile(file, "utf8"),
3295
+ extension: toExtension(file)
3296
+ };
3297
+ } catch {
3298
+ return;
3299
+ }
3300
+ }))).filter((entry) => entry !== void 0);
3301
+ scannedCandidates.push(...scanner.scanFiles(changedContents));
3302
+ }
3303
+ const candidates = new Set(scannedCandidates);
3304
+ if (options?.bareArbitraryValues !== void 0 && options.bareArbitraryValues !== false) await Promise.all(files.map(async (file) => {
3305
+ try {
3306
+ const content = await node_fs.promises.readFile(file, "utf8");
3307
+ const extension = toExtension(file);
3308
+ const jsStringStaticRanges = JS_LIKE_SOURCE_EXTENSION_RE.test(extension) ? createJsStringStaticRanges(content) : void 0;
3309
+ for (const candidate of extractBareArbitraryValueSourceCandidatesWithPositions(content, options.bareArbitraryValues)) if (shouldKeepSourceCandidate(content, extension, candidate, jsStringStaticRanges)) candidates.add(candidate.rawCandidate);
3310
+ } catch {}
3311
+ }));
3312
+ const result = [...candidates];
3313
+ setRawCandidateCacheEntry(cacheKey, fingerprint, result);
3314
+ return [...result];
3315
+ }
3316
+ //#endregion
3317
+ //#region src/v4/candidates/inline-source.ts
3318
+ function splitTopLevel(value, separator, options) {
3319
+ const result = [];
3320
+ let start = 0;
3321
+ let depth = 0;
3322
+ let quote;
3323
+ for (let index = 0; index < value.length; index++) {
3324
+ const character = value[index];
3325
+ if (character === "\\") {
3326
+ index++;
3327
+ continue;
3328
+ }
3329
+ if (quote) {
3330
+ if (character === quote) quote = void 0;
3331
+ continue;
3332
+ }
3333
+ if (character === "\"" || character === "'") {
3334
+ quote = character;
3335
+ continue;
3336
+ }
3337
+ if (character === "(" || character === "[" || character === "{") {
3338
+ depth++;
3339
+ continue;
3340
+ }
3341
+ if (character === ")" || character === "]" || character === "}") {
3342
+ depth = Math.max(0, depth - 1);
3343
+ continue;
3344
+ }
3345
+ if (depth === 0 && character === separator) {
3346
+ const item = value.slice(start, index).trim();
3347
+ if (item || options?.keepEmpty) result.push(item);
3348
+ start = index + 1;
3349
+ }
3350
+ }
3351
+ const item = value.slice(start).trim();
3352
+ if (item || options?.keepEmpty) result.push(item);
3353
+ return result;
3354
+ }
3355
+ const sequencePattern = /^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/;
3356
+ function expandSequence(value) {
3357
+ const match = value.match(sequencePattern);
3358
+ if (!match) return [value];
3359
+ const [, startValue, endValue, stepValue] = match;
3360
+ if (startValue === void 0 || endValue === void 0) return [value];
3361
+ const start = Number.parseInt(startValue, 10);
3362
+ const end = Number.parseInt(endValue, 10);
3363
+ let step = stepValue === void 0 ? start <= end ? 1 : -1 : Number.parseInt(stepValue, 10);
3364
+ if (step === 0) throw new Error("Step cannot be zero in Tailwind CSS v4 inline source sequence.");
3365
+ const ascending = start < end;
3366
+ if (ascending && step < 0) step = -step;
3367
+ if (!ascending && step > 0) step = -step;
3368
+ const result = [];
3369
+ for (let current = start; ascending ? current <= end : current >= end; current += step) result.push(current.toString());
3370
+ return result;
3371
+ }
3372
+ function expandInlinePattern(pattern) {
3373
+ const openIndex = pattern.indexOf("{");
3374
+ if (openIndex === -1) return [pattern];
3375
+ const prefix = pattern.slice(0, openIndex);
3376
+ const rest = pattern.slice(openIndex);
3377
+ let depth = 0;
3378
+ let closeIndex = -1;
3379
+ for (let index = 0; index < rest.length; index++) {
3380
+ const character = rest[index];
3381
+ if (character === "{") depth++;
3382
+ else if (character === "}") {
3383
+ depth--;
3384
+ if (depth === 0) {
3385
+ closeIndex = index;
3386
+ break;
3387
+ }
3388
+ }
3389
+ }
3390
+ if (closeIndex === -1) throw new Error(`The Tailwind CSS v4 inline source pattern "${pattern}" is not balanced.`);
3391
+ const body = rest.slice(1, closeIndex);
3392
+ const suffix = rest.slice(closeIndex + 1);
3393
+ const parts = sequencePattern.test(body) ? expandSequence(body) : splitTopLevel(body, ",", { keepEmpty: true }).flatMap((part) => expandInlinePattern(part));
3394
+ const suffixes = expandInlinePattern(suffix);
3395
+ const result = [];
3396
+ for (const part of parts) for (const expandedSuffix of suffixes) result.push(`${prefix}${part}${expandedSuffix}`);
3397
+ return result;
3398
+ }
3399
+ function unquoteCssString(value) {
3400
+ const quote = value[0];
3401
+ if (quote !== "\"" && quote !== "'" || value[value.length - 1] !== quote) return;
3402
+ let result = "";
3403
+ for (let index = 1; index < value.length - 1; index++) {
3404
+ const character = value[index];
3405
+ if (character === "\\") {
3406
+ index++;
3407
+ result += value[index] ?? "";
3408
+ continue;
3409
+ }
3410
+ result += character;
3411
+ }
3412
+ return result;
3413
+ }
3414
+ function extractTailwindV4InlineSourceCandidates(css) {
3415
+ const included = /* @__PURE__ */ new Set();
3416
+ const excluded = /* @__PURE__ */ new Set();
3417
+ postcss.default.parse(css).walkAtRules("source", (rule) => {
3418
+ let params = rule.params.trim();
3419
+ if (!params) return;
3420
+ let negated = false;
3421
+ if (params.startsWith("not ")) {
3422
+ negated = true;
3423
+ params = params.slice(4).trim();
3424
+ }
3425
+ if (!params.startsWith("inline(") || !params.endsWith(")")) return;
3426
+ const inlineValue = unquoteCssString(params.slice(7, -1).trim());
3427
+ if (inlineValue === void 0) return;
3428
+ const target = negated ? excluded : included;
3429
+ for (const part of splitTopLevel(inlineValue, " ")) for (const candidate of expandInlinePattern(part)) target.add(candidate);
3430
+ });
3431
+ return {
3432
+ included,
3433
+ excluded
3434
+ };
3435
+ }
3436
+ //#endregion
3437
+ //#region src/v4/candidates.ts
3438
+ function resolveValidTailwindV4Candidates(designSystem, candidates, options) {
3439
+ const validCandidates = /* @__PURE__ */ new Set();
3440
+ const parsedCandidates = [];
3441
+ const originalCandidatesByCanonical = /* @__PURE__ */ new Map();
3442
+ for (const candidate of candidates) {
3443
+ if (!candidate) continue;
3444
+ const bareArbitrary = resolveBareArbitraryValueCandidate(candidate, options?.bareArbitraryValues);
3445
+ const candidateToCheck = bareArbitrary?.canonicalCandidate ?? candidate;
3446
+ if (bareArbitrary) {
3447
+ const originalCandidates = originalCandidatesByCanonical.get(candidateToCheck) ?? /* @__PURE__ */ new Set();
3448
+ originalCandidates.add(candidate);
3449
+ originalCandidatesByCanonical.set(candidateToCheck, originalCandidates);
3450
+ }
3451
+ if (parsedCandidates.includes(candidateToCheck)) continue;
3452
+ if (designSystem.parseCandidate(candidateToCheck).length > 0) parsedCandidates.push(candidateToCheck);
3453
+ }
3454
+ if (parsedCandidates.length === 0) return validCandidates;
3455
+ const cssByCandidate = designSystem.candidatesToCss(parsedCandidates);
3456
+ for (let index = 0; index < parsedCandidates.length; index++) {
3457
+ const candidate = parsedCandidates[index];
3458
+ const candidateCss = cssByCandidate[index];
3459
+ if (candidate && typeof candidateCss === "string" && candidateCss.trim().length > 0) {
3460
+ const originalCandidates = originalCandidatesByCanonical.get(candidate);
3461
+ if (originalCandidates) {
3462
+ for (const originalCandidate of originalCandidates) validCandidates.add(originalCandidate);
3463
+ continue;
3464
+ }
3465
+ validCandidates.add(candidate);
3466
+ }
3467
+ }
3468
+ return validCandidates;
3469
+ }
3470
+ function createSelectorAliasMap(candidates, options) {
3471
+ const aliases = /* @__PURE__ */ new Map();
3472
+ for (const candidate of candidates) {
3473
+ const bareArbitrary = resolveBareArbitraryValueCandidate(candidate, options);
3474
+ if (!bareArbitrary) continue;
3475
+ const canonicalSelector = escapeCssClassName(bareArbitrary.canonicalCandidate);
3476
+ const bareSelectors = aliases.get(canonicalSelector) ?? /* @__PURE__ */ new Set();
3477
+ bareSelectors.add(escapeCssClassName(bareArbitrary.candidate));
3478
+ aliases.set(canonicalSelector, bareSelectors);
3479
+ }
3480
+ return aliases;
3481
+ }
3482
+ function replaceBareArbitraryValueSelectors(css, candidates, options) {
3483
+ const aliases = createSelectorAliasMap(candidates, options);
3484
+ if (aliases.size === 0) return css;
3485
+ if (Array.from(aliases.values()).every((bareSelectors) => bareSelectors.size === 1)) {
3486
+ let result = css;
3487
+ for (const [canonicalSelector, bareSelectors] of aliases) {
3488
+ const bareSelector = Array.from(bareSelectors)[0];
3489
+ if (bareSelector !== void 0) result = result.replaceAll(canonicalSelector, bareSelector);
3490
+ }
3491
+ return result;
3492
+ }
3493
+ const root = postcss.default.parse(css);
3494
+ root.walkRules((rule) => {
3495
+ let selectors = rule.selectors;
3496
+ for (const [canonicalSelector, bareSelectors] of aliases) selectors = selectors.flatMap((selector) => {
3497
+ if (!selector.includes(canonicalSelector)) return selector;
3498
+ return Array.from(bareSelectors, (bareSelector) => selector.replaceAll(canonicalSelector, bareSelector));
3499
+ });
3500
+ rule.selectors = selectors;
3501
+ });
3502
+ return root.toString();
3503
+ }
3504
+ function canonicalizeBareArbitraryValueCandidates(candidates, options) {
3505
+ return Array.from(candidates, (candidate) => {
3506
+ return resolveBareArbitraryValueCandidate(candidate, options)?.canonicalCandidate ?? candidate;
3507
+ });
3508
+ }
3509
+ //#endregion
3510
+ //#region src/style-candidates.ts
3511
+ async function collectTailwindStyleCandidates(options = {}) {
3512
+ const candidates = /* @__PURE__ */ new Set();
3513
+ for (const candidate of options.candidates ?? []) candidates.add(candidate);
3514
+ const extractOptions = options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues };
3515
+ for (const source of options.sources ?? []) {
3516
+ const sourceCandidates = await extractSourceCandidates(source.content, source.extension, extractOptions);
3517
+ for (const candidate of sourceCandidates) candidates.add(candidate);
3518
+ }
3519
+ return candidates;
3520
+ }
3521
+ //#endregion
3522
+ //#region src/v4/generation-artifact.ts
3523
+ function cloneSourceEntry(sourceEntry) {
3524
+ return {
3525
+ id: sourceEntry.id,
3526
+ content: sourceEntry.content,
3527
+ ...sourceEntry.extension === void 0 ? {} : { extension: sourceEntry.extension }
3528
+ };
3529
+ }
3530
+ function cloneTailwindGenerationArtifact(artifact) {
3531
+ return {
3532
+ fragments: artifact.fragments.map((fragment) => ({
3533
+ ...fragment,
3534
+ root: fragment.root.clone()
3535
+ })),
3536
+ classSet: new Set(artifact.classSet),
3537
+ rawCandidates: new Set(artifact.rawCandidates),
3538
+ dependencies: [...artifact.dependencies],
3539
+ sourceEntries: artifact.sourceEntries.map(cloneSourceEntry)
3540
+ };
3541
+ }
3542
+ function createTailwindGenerationArtifact(css, source, request, classSet, rawCandidates, dependencies) {
3543
+ const sourceId = source.dependencies[0] ?? source.base;
3544
+ return {
3545
+ fragments: [{
3546
+ id: `${sourceId}:tailwind`,
3547
+ kind: "tailwind",
3548
+ root: postcss.default.parse(css, { from: sourceId }),
3549
+ sourceId,
3550
+ order: 0
3551
+ }],
3552
+ classSet: new Set(classSet),
3553
+ rawCandidates: new Set(rawCandidates),
3554
+ dependencies: [...dependencies],
3555
+ sourceEntries: (request.sourceEntries ?? []).map(cloneSourceEntry)
3556
+ };
3557
+ }
3558
+ //#endregion
3559
+ //#region src/v4/generation-request.ts
3560
+ function toGenerationRequest(options) {
3561
+ return {
3562
+ ...options?.candidates === void 0 ? {} : { candidates: options.candidates },
3563
+ ...options?.sources === void 0 ? {} : { sourceEntries: options.sources.map((sourceEntry, index) => ({
3564
+ id: `source:${index}`,
3565
+ ...sourceEntry
3566
+ })) },
3567
+ ...options?.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues },
3568
+ ...options?.scanSources === void 0 ? {} : { scanSources: options.scanSources }
3569
+ };
3570
+ }
3571
+ function toGenerateOptions(request) {
3572
+ return {
3573
+ ...request.candidates === void 0 ? {} : { candidates: request.candidates },
3574
+ ...request.sourceEntries === void 0 ? {} : { sources: request.sourceEntries },
3575
+ ...request.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: request.bareArbitraryValues },
3576
+ ...request.scanSources === void 0 ? {} : { scanSources: request.scanSources }
3577
+ };
3578
+ }
3579
+ function resolveScanSources(options, source, compiledRoot, compiledSources) {
3580
+ if (Array.isArray(options?.scanSources)) return options.scanSources;
3581
+ if (options?.scanSources === true) return createTailwindV4CompiledSourceEntries(compiledRoot, compiledSources, source.base);
3582
+ return [];
3583
+ }
3584
+ function shouldCompileSourceEntries(options) {
3585
+ return options?.scanSources === true;
3586
+ }
3587
+ function stripCompiledSourceEntries(source) {
3588
+ if (!source.css.includes("@source") && !source.css.includes("source(")) return source;
3589
+ try {
3590
+ const root = postcss.default.parse(source.css);
3591
+ let changed = false;
3592
+ root.walkAtRules((rule) => {
3593
+ if (rule.name === "source") {
3594
+ rule.remove();
3595
+ changed = true;
3596
+ return;
3597
+ }
3598
+ if (rule.name === "import" && /\bsource\(/.test(rule.params)) {
3599
+ rule.params = rule.params.replace(/\s+source\((?:[^()]|\([^()]*\))*\)/g, "");
3600
+ changed = true;
3601
+ }
3602
+ });
3603
+ return changed ? {
3604
+ ...source,
3605
+ css: root.toString()
3606
+ } : source;
3607
+ } catch {
3608
+ return source;
3609
+ }
3610
+ }
3611
+ async function collectRawCandidates(source, options, compiledRoot, compiledSources = []) {
3612
+ const rawCandidates = /* @__PURE__ */ new Set();
3613
+ const extractOptions = options?.bareArbitraryValues === void 0 ? void 0 : { bareArbitraryValues: options.bareArbitraryValues };
3614
+ for (const candidate of options?.candidates ?? []) rawCandidates.add(candidate);
3615
+ for (const candidateSource of options?.sources ?? []) {
3616
+ const candidates = await extractRawCandidatesWithPositions(candidateSource.content, candidateSource.extension, extractOptions);
3617
+ for (const candidate of candidates) rawCandidates.add(candidate.rawCandidate);
3618
+ }
3619
+ const filesystemSources = resolveScanSources(options, source, compiledRoot, compiledSources);
3620
+ if (filesystemSources.length > 0) for (const candidate of await extractRawCandidates(filesystemSources, extractOptions)) rawCandidates.add(candidate);
3621
+ const inlineSources = extractTailwindV4InlineSourceCandidates(source.css);
3622
+ for (const candidate of inlineSources.included) rawCandidates.add(candidate);
3623
+ for (const candidate of inlineSources.excluded) rawCandidates.delete(candidate);
3624
+ return rawCandidates;
3625
+ }
3626
+ //#endregion
3627
+ //#region src/v4/generation-session.ts
3628
+ var TailwindGenerationSessionImpl = class {
3629
+ currentSource;
3630
+ runtimes = /* @__PURE__ */ new Map();
3631
+ designSystemPromise;
3632
+ disposed = false;
3633
+ constructor(source) {
3634
+ this.currentSource = source;
3635
+ }
3636
+ get source() {
3637
+ return this.currentSource;
3638
+ }
3639
+ async generate(request = {}) {
3640
+ const generated = await this.generateInternal(request);
3641
+ return cloneTailwindGenerationArtifact(createTailwindGenerationArtifact(generated.css, this.currentSource, request, generated.classSet, generated.rawCandidates, generated.dependencies));
3642
+ }
3643
+ async generateLegacy(options) {
3644
+ const generated = await this.generateInternal(toGenerationRequest(options));
3645
+ return {
3646
+ css: generated.css,
3647
+ classSet: generated.classSet,
3648
+ rawCandidates: generated.rawCandidates,
3649
+ dependencies: generated.dependencies,
3650
+ sources: generated.sources,
3651
+ root: generated.root
3652
+ };
3653
+ }
3654
+ loadDesignSystem() {
3655
+ this.assertActive();
3656
+ this.designSystemPromise ??= loadTailwindV4DesignSystem(this.currentSource, { cache: false });
3657
+ return this.designSystemPromise;
3658
+ }
3659
+ async validateCandidates(candidates) {
3660
+ return resolveValidTailwindV4Candidates(await this.loadDesignSystem(), candidates);
3661
+ }
3662
+ invalidate(change) {
3663
+ if (this.disposed) return;
3664
+ if (change.type === "source") this.currentSource = change.source;
3665
+ this.runtimes.clear();
3666
+ this.designSystemPromise = void 0;
3667
+ }
3668
+ dispose() {
3669
+ this.runtimes.clear();
3670
+ this.designSystemPromise = void 0;
3671
+ this.disposed = true;
3672
+ }
3673
+ assertActive() {
3674
+ if (this.disposed) throw new Error("Tailwind generation session has been disposed.");
3675
+ }
3676
+ getRuntime(compileSourceEntries) {
3677
+ this.assertActive();
3678
+ const cached = this.runtimes.get(compileSourceEntries);
3679
+ if (cached) return cached;
3680
+ const source = compileSourceEntries ? this.currentSource : stripCompiledSourceEntries(this.currentSource);
3681
+ const promise = Promise.all([compileTailwindV4Source(source), loadTailwindV4DesignSystem(source, { cache: false })]).then(([compiledSource, designSystem]) => ({
3682
+ compiled: compiledSource.compiled,
3683
+ dependencies: compiledSource.dependencies,
3684
+ designSystem,
3685
+ builtCandidates: /* @__PURE__ */ new Set()
3686
+ }));
3687
+ this.runtimes.set(compileSourceEntries, promise);
3688
+ promise.catch(() => {
3689
+ if (this.runtimes.get(compileSourceEntries) === promise) this.runtimes.delete(compileSourceEntries);
3690
+ });
3691
+ return promise;
3692
+ }
3693
+ async resetRuntime(compileSourceEntries) {
3694
+ this.runtimes.delete(compileSourceEntries);
3695
+ return this.getRuntime(compileSourceEntries);
3696
+ }
3697
+ async generateInternal(request) {
3698
+ this.assertActive();
3699
+ const options = toGenerateOptions(request);
3700
+ const compileSourceEntries = shouldCompileSourceEntries(options);
3701
+ let runtime = await this.getRuntime(compileSourceEntries);
3702
+ const rawCandidates = await collectRawCandidates(this.currentSource, options, runtime.compiled.root, runtime.compiled.sources);
3703
+ const classSet = resolveValidTailwindV4Candidates(runtime.designSystem, rawCandidates, { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } });
3704
+ const inlineSources = extractTailwindV4InlineSourceCandidates(this.currentSource.css);
3705
+ for (const candidate of inlineSources.excluded) classSet.delete(candidate);
3706
+ const buildCandidates = new Set(canonicalizeBareArbitraryValueCandidates(classSet, options.bareArbitraryValues));
3707
+ if ([...runtime.builtCandidates].some((candidate) => !buildCandidates.has(candidate))) runtime = await this.resetRuntime(compileSourceEntries);
3708
+ const css = replaceBareArbitraryValueSelectors(runtime.compiled.build([...buildCandidates]), classSet, options.bareArbitraryValues);
3709
+ runtime.builtCandidates = new Set(buildCandidates);
3710
+ return {
3711
+ css,
3712
+ classSet,
3713
+ rawCandidates,
3714
+ dependencies: Array.from(runtime.dependencies),
3715
+ sources: runtime.compiled.sources,
3716
+ root: runtime.compiled.root
3717
+ };
3718
+ }
3719
+ };
3720
+ function createTailwindGenerationSession(source) {
3721
+ return new TailwindGenerationSessionImpl(source);
3722
+ }
3723
+ function createTailwindV4EngineGenerationSession(source) {
3724
+ return new TailwindGenerationSessionImpl(source);
3725
+ }
3726
+ //#endregion
3727
+ //#region src/v4/engine.ts
3728
+ function createTailwindV4Engine(source) {
3729
+ const session = createTailwindV4EngineGenerationSession(source);
3730
+ return {
3731
+ source,
3732
+ loadDesignSystem() {
3733
+ return session.loadDesignSystem();
3734
+ },
3735
+ async validateCandidates(candidates) {
3736
+ return session.validateCandidates(candidates);
3737
+ },
3738
+ generate(options) {
3739
+ return session.generateLegacy(options);
3740
+ }
3741
+ };
3742
+ }
3743
+ //#endregion
3744
+ //#region src/v4/source.ts
3745
+ function resolveBase(value, fallback) {
3746
+ return value === void 0 ? fallback : node_path.default.isAbsolute(value) ? node_path.default.resolve(value) : node_path.default.resolve(fallback, value);
3747
+ }
3748
+ function uniquePaths(values) {
3749
+ const result = [];
3750
+ for (const value of values) {
3751
+ if (!value) continue;
3752
+ const resolved = node_path.default.resolve(value);
3753
+ if (!result.includes(resolved)) result.push(resolved);
3754
+ }
3755
+ return result;
3756
+ }
3757
+ function toCssImportPath(value) {
3758
+ return value.replaceAll("\\", "/");
3759
+ }
3760
+ function quoteCssImport(value) {
3761
+ return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
3762
+ }
3763
+ function isPostcssPluginSpecifier(packageName) {
3764
+ return packageName === "@tailwindcss/postcss" || /(?:^|[/\\])@tailwindcss[/\\]postcss(?:[/\\]|$)/.test(packageName) || /(?:^|[/\\])postcss(?:[/\\]|$)/i.test(packageName) || /postcss\.config\.[cm]?[jt]s$/i.test(packageName);
3765
+ }
3766
+ function createDefaultCss(packageName) {
3767
+ return `@import "${quoteCssImport(toCssImportPath(packageName && !isPostcssPluginSpecifier(packageName) ? packageName : "tailwindcss"))}";`;
3768
+ }
3769
+ async function pathExists(filePath) {
3770
+ try {
3771
+ await node_fs.promises.access(filePath);
3772
+ return true;
3773
+ } catch {
3774
+ return false;
3775
+ }
3776
+ }
3777
+ async function resolveCssEntries(entries, projectRoot, base) {
3778
+ const resolvedEntries = entries.map((entry) => ({
3779
+ original: entry,
3780
+ absolute: node_path.default.isAbsolute(entry) ? node_path.default.resolve(entry) : node_path.default.resolve(projectRoot, entry)
3781
+ }));
3782
+ const resolvedBase = base ?? node_path.default.dirname(resolvedEntries[0]?.absolute ?? projectRoot);
3783
+ const dependencies = resolvedEntries.map((entry) => entry.absolute);
3784
+ const cssParts = [];
3785
+ for (const entry of resolvedEntries) {
3786
+ if (await pathExists(entry.absolute)) {
3787
+ cssParts.push(await node_fs.promises.readFile(entry.absolute, "utf8"));
3788
+ continue;
3789
+ }
3790
+ const importPath = node_path.default.isAbsolute(entry.original) ? entry.absolute : node_path.default.relative(resolvedBase, entry.absolute);
3791
+ cssParts.push(`@import "${quoteCssImport(toCssImportPath(importPath))}";`);
3792
+ }
3793
+ return {
3794
+ base: resolvedBase,
3795
+ css: cssParts.join("\n"),
3796
+ dependencies
3797
+ };
3798
+ }
3799
+ function resolveCssSources(sources, projectRoot, base) {
3800
+ const resolvedSources = sources.map((source) => ({
3801
+ ...source,
3802
+ base: source.base === void 0 ? void 0 : resolveBase(source.base, projectRoot),
3803
+ file: source.file === void 0 ? void 0 : node_path.default.isAbsolute(source.file) ? node_path.default.resolve(source.file) : node_path.default.resolve(projectRoot, source.file),
3804
+ dependencies: source.dependencies?.map((dependency) => node_path.default.isAbsolute(dependency) ? node_path.default.resolve(dependency) : node_path.default.resolve(projectRoot, dependency)) ?? []
3805
+ }));
3806
+ const firstSource = resolvedSources[0];
3807
+ const resolvedBase = base ?? firstSource?.base ?? (firstSource?.file ? node_path.default.dirname(firstSource.file) : projectRoot);
3808
+ const dependencies = resolvedSources.flatMap((source) => [source.file, ...source.dependencies]).filter((dependency) => Boolean(dependency));
3809
+ return {
3810
+ base: resolvedBase,
3811
+ css: resolvedSources.map((source) => source.css).join("\n"),
3812
+ dependencies
3813
+ };
3814
+ }
3815
+ function normalizeResolvedSource(source) {
3816
+ const baseFallbacks = uniquePaths([
3817
+ ...source.baseFallbacks,
3818
+ source.projectRoot,
3819
+ source.cwd
3820
+ ]).filter((base) => base !== source.base);
3821
+ return {
3822
+ projectRoot: source.projectRoot,
3823
+ base: source.base,
3824
+ baseFallbacks,
3825
+ css: source.css,
3826
+ dependencies: Array.from(new Set(source.dependencies.map((dependency) => node_path.default.resolve(dependency))))
3827
+ };
3828
+ }
3829
+ async function resolveTailwindV4Source(options = {}) {
3830
+ const projectRoot = resolveBase(options.projectRoot, node_process.default.cwd());
3831
+ const cwd = resolveBase(options.cwd, projectRoot);
3832
+ const configuredBase = options.base === void 0 ? void 0 : resolveBase(options.base, projectRoot);
3833
+ const baseFallbacks = uniquePaths(options.baseFallbacks?.map((base) => resolveBase(base, projectRoot)) ?? []);
3834
+ if (options.css !== void 0) return normalizeResolvedSource({
3835
+ projectRoot,
3836
+ cwd,
3837
+ base: configuredBase ?? cwd,
3838
+ baseFallbacks,
3839
+ css: options.css,
3840
+ dependencies: []
3841
+ });
3842
+ if (options.cssEntries?.length || options.cssSources?.length) {
3843
+ const entries = options.cssEntries?.length ? await resolveCssEntries(options.cssEntries, projectRoot, configuredBase) : void 0;
3844
+ const sources = options.cssSources?.length ? resolveCssSources(options.cssSources, projectRoot, configuredBase) : void 0;
3845
+ const css = [entries?.css, sources?.css].filter(Boolean).join("\n");
3846
+ return normalizeResolvedSource({
3847
+ projectRoot,
3848
+ cwd,
3849
+ base: configuredBase ?? entries?.base ?? sources?.base ?? cwd,
3850
+ baseFallbacks,
3851
+ css,
3852
+ dependencies: [...entries?.dependencies ?? [], ...sources?.dependencies ?? []]
3853
+ });
3854
+ }
3855
+ return normalizeResolvedSource({
3856
+ projectRoot,
3857
+ cwd,
3858
+ base: configuredBase ?? cwd,
3859
+ baseFallbacks,
3860
+ css: createDefaultCss(options.packageName),
3861
+ dependencies: []
3862
+ });
3863
+ }
3864
+ //#endregion
3865
+ //#region src/v4/style-generator.ts
3866
+ function createSourceOptions(options) {
3867
+ return {
3868
+ ...options.projectRoot === void 0 ? {} : { projectRoot: options.projectRoot },
3869
+ ...options.cwd === void 0 ? {} : { cwd: options.cwd },
3870
+ ...options.base === void 0 ? {} : { base: options.base },
3871
+ ...options.baseFallbacks === void 0 ? {} : { baseFallbacks: options.baseFallbacks },
3872
+ ...options.css === void 0 ? {} : { css: options.css },
3873
+ ...options.cssSources === void 0 ? {} : { cssSources: options.cssSources },
3874
+ ...options.cssEntries === void 0 ? {} : { cssEntries: options.cssEntries },
3875
+ ...options.packageName === void 0 ? {} : { packageName: options.packageName }
3876
+ };
3877
+ }
3878
+ async function collectTailwindV4StyleCandidates(options) {
3879
+ return collectTailwindStyleCandidates({
3880
+ ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues },
3881
+ ...options.candidates === void 0 ? {} : { candidates: options.candidates },
3882
+ ...options.sources === void 0 ? {} : { sources: options.sources }
3883
+ });
3884
+ }
3885
+ async function generateTailwindV4Style(options = {}) {
3886
+ const source = options.source ?? await resolveTailwindV4Source(createSourceOptions(options));
3887
+ const candidates = await collectTailwindV4StyleCandidates(options);
3888
+ const result = await createTailwindV4Engine(source).generate({
3889
+ candidates,
3890
+ ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues },
3891
+ ...options.scanSources === void 0 ? {} : { scanSources: options.scanSources }
3892
+ });
3893
+ return {
3894
+ ...result,
3895
+ tokens: result.rawCandidates,
3896
+ source
3897
+ };
3898
+ }
3899
+ //#endregion
3900
+ Object.defineProperty(exports, "TAILWIND_V4_AUTO_SOURCE_SCAN_PATTERN", {
3901
+ enumerable: true,
3902
+ get: function() {
3903
+ return TAILWIND_V4_AUTO_SOURCE_SCAN_PATTERN;
3904
+ }
3905
+ });
3906
+ Object.defineProperty(exports, "TAILWIND_V4_IGNORED_CONTENT_DIRS", {
3907
+ enumerable: true,
3908
+ get: function() {
3909
+ return TAILWIND_V4_IGNORED_CONTENT_DIRS;
3910
+ }
3911
+ });
3912
+ Object.defineProperty(exports, "TAILWIND_V4_IGNORED_EXTENSIONS", {
3913
+ enumerable: true,
3914
+ get: function() {
3915
+ return TAILWIND_V4_IGNORED_EXTENSIONS;
3916
+ }
3917
+ });
3918
+ Object.defineProperty(exports, "TAILWIND_V4_IGNORED_FILES", {
3919
+ enumerable: true,
3920
+ get: function() {
3921
+ return TAILWIND_V4_IGNORED_FILES;
3922
+ }
3923
+ });
3924
+ Object.defineProperty(exports, "__toESM", {
3925
+ enumerable: true,
3926
+ get: function() {
3927
+ return __toESM;
3928
+ }
3929
+ });
3930
+ Object.defineProperty(exports, "buildLineOffsets", {
3931
+ enumerable: true,
3932
+ get: function() {
3933
+ return buildLineOffsets;
3934
+ }
3935
+ });
3936
+ Object.defineProperty(exports, "canonicalizeBareArbitraryValueCandidates", {
3937
+ enumerable: true,
3938
+ get: function() {
3939
+ return canonicalizeBareArbitraryValueCandidates;
3940
+ }
3941
+ });
3942
+ Object.defineProperty(exports, "collectTailwindStyleCandidates", {
3943
+ enumerable: true,
3944
+ get: function() {
3945
+ return collectTailwindStyleCandidates;
3946
+ }
3947
+ });
3948
+ Object.defineProperty(exports, "collectTailwindV4StyleCandidates", {
3949
+ enumerable: true,
3950
+ get: function() {
3951
+ return collectTailwindV4StyleCandidates;
3952
+ }
3953
+ });
3954
+ Object.defineProperty(exports, "compileTailwindV4Source", {
3955
+ enumerable: true,
3956
+ get: function() {
3957
+ return compileTailwindV4Source;
3958
+ }
3959
+ });
3960
+ Object.defineProperty(exports, "createTailwindGenerationSession", {
3961
+ enumerable: true,
3962
+ get: function() {
3963
+ return createTailwindGenerationSession;
3964
+ }
3965
+ });
3966
+ Object.defineProperty(exports, "createTailwindV4CompiledSourceEntries", {
3967
+ enumerable: true,
3968
+ get: function() {
3969
+ return createTailwindV4CompiledSourceEntries;
3970
+ }
3971
+ });
3972
+ Object.defineProperty(exports, "createTailwindV4DefaultIgnoreSources", {
3973
+ enumerable: true,
3974
+ get: function() {
3975
+ return createTailwindV4DefaultIgnoreSources;
3976
+ }
3977
+ });
3978
+ Object.defineProperty(exports, "createTailwindV4Engine", {
3979
+ enumerable: true,
3980
+ get: function() {
3981
+ return createTailwindV4Engine;
3982
+ }
3983
+ });
3984
+ Object.defineProperty(exports, "createTailwindV4RootSources", {
3985
+ enumerable: true,
3986
+ get: function() {
3987
+ return createTailwindV4RootSources;
3988
+ }
3989
+ });
3990
+ Object.defineProperty(exports, "createTailwindV4SourceEntryMatcher", {
3991
+ enumerable: true,
3992
+ get: function() {
3993
+ return createTailwindV4SourceEntryMatcher;
3994
+ }
3995
+ });
3996
+ Object.defineProperty(exports, "createTailwindV4SourceExclusionMatcher", {
3997
+ enumerable: true,
3998
+ get: function() {
3999
+ return createTailwindV4SourceExclusionMatcher;
4000
+ }
4001
+ });
4002
+ Object.defineProperty(exports, "createTokenLocation", {
4003
+ enumerable: true,
4004
+ get: function() {
4005
+ return createTokenLocation;
4006
+ }
4007
+ });
4008
+ Object.defineProperty(exports, "escapeCssClassName", {
4009
+ enumerable: true,
4010
+ get: function() {
4011
+ return escapeCssClassName;
4012
+ }
4013
+ });
4014
+ Object.defineProperty(exports, "expandTailwindV4SourceEntries", {
4015
+ enumerable: true,
4016
+ get: function() {
4017
+ return expandTailwindV4SourceEntries;
4018
+ }
4019
+ });
4020
+ Object.defineProperty(exports, "expandTailwindV4SourceEntryBraces", {
4021
+ enumerable: true,
4022
+ get: function() {
4023
+ return expandTailwindV4SourceEntryBraces;
4024
+ }
4025
+ });
4026
+ Object.defineProperty(exports, "extractBareArbitraryValueSourceCandidates", {
4027
+ enumerable: true,
4028
+ get: function() {
4029
+ return extractBareArbitraryValueSourceCandidates;
4030
+ }
4031
+ });
4032
+ Object.defineProperty(exports, "extractBareArbitraryValueSourceCandidatesWithPositions", {
4033
+ enumerable: true,
4034
+ get: function() {
4035
+ return extractBareArbitraryValueSourceCandidatesWithPositions;
4036
+ }
4037
+ });
4038
+ Object.defineProperty(exports, "extractRawCandidates", {
4039
+ enumerable: true,
4040
+ get: function() {
4041
+ return extractRawCandidates;
4042
+ }
4043
+ });
4044
+ Object.defineProperty(exports, "extractRawCandidatesWithPositions", {
4045
+ enumerable: true,
4046
+ get: function() {
4047
+ return extractRawCandidatesWithPositions;
4048
+ }
4049
+ });
4050
+ Object.defineProperty(exports, "extractSourceCandidates", {
4051
+ enumerable: true,
4052
+ get: function() {
4053
+ return extractSourceCandidates;
4054
+ }
4055
+ });
4056
+ Object.defineProperty(exports, "extractSourceCandidatesWithPositions", {
4057
+ enumerable: true,
4058
+ get: function() {
4059
+ return extractSourceCandidatesWithPositions;
4060
+ }
4061
+ });
4062
+ Object.defineProperty(exports, "extractTailwindV4InlineSourceCandidates", {
4063
+ enumerable: true,
4064
+ get: function() {
4065
+ return extractTailwindV4InlineSourceCandidates;
4066
+ }
4067
+ });
4068
+ Object.defineProperty(exports, "generateTailwindV4Style", {
4069
+ enumerable: true,
4070
+ get: function() {
4071
+ return generateTailwindV4Style;
4072
+ }
4073
+ });
4074
+ Object.defineProperty(exports, "getOxideModule", {
4075
+ enumerable: true,
4076
+ get: function() {
4077
+ return getOxideModule;
4078
+ }
4079
+ });
4080
+ Object.defineProperty(exports, "getTailwindV4DesignSystemCacheKey", {
4081
+ enumerable: true,
4082
+ get: function() {
4083
+ return getTailwindV4DesignSystemCacheKey;
4084
+ }
4085
+ });
4086
+ Object.defineProperty(exports, "groupTailwindV4SourceEntriesByBase", {
4087
+ enumerable: true,
4088
+ get: function() {
4089
+ return groupTailwindV4SourceEntriesByBase;
4090
+ }
4091
+ });
4092
+ Object.defineProperty(exports, "isBareArbitraryValuesEnabled", {
4093
+ enumerable: true,
4094
+ get: function() {
4095
+ return isBareArbitraryValuesEnabled;
4096
+ }
4097
+ });
4098
+ Object.defineProperty(exports, "isFileExcludedByTailwindV4SourceEntries", {
4099
+ enumerable: true,
4100
+ get: function() {
4101
+ return isFileExcludedByTailwindV4SourceEntries;
4102
+ }
4103
+ });
4104
+ Object.defineProperty(exports, "isFileMatchedByTailwindV4SourceEntries", {
4105
+ enumerable: true,
4106
+ get: function() {
4107
+ return isFileMatchedByTailwindV4SourceEntries;
4108
+ }
4109
+ });
4110
+ Object.defineProperty(exports, "loadTailwindV4DesignSystem", {
4111
+ enumerable: true,
4112
+ get: function() {
4113
+ return loadTailwindV4DesignSystem;
4114
+ }
4115
+ });
4116
+ Object.defineProperty(exports, "loadTailwindV4NodeModule", {
4117
+ enumerable: true,
4118
+ get: function() {
4119
+ return loadTailwindV4NodeModule;
4120
+ }
4121
+ });
4122
+ Object.defineProperty(exports, "mergeTailwindV4SourceEntries", {
4123
+ enumerable: true,
4124
+ get: function() {
4125
+ return mergeTailwindV4SourceEntries;
4126
+ }
4127
+ });
4128
+ Object.defineProperty(exports, "normalizeGlobPattern", {
4129
+ enumerable: true,
4130
+ get: function() {
4131
+ return normalizeGlobPattern;
4132
+ }
4133
+ });
4134
+ Object.defineProperty(exports, "normalizeTailwindV4ScannerSources", {
4135
+ enumerable: true,
4136
+ get: function() {
4137
+ return normalizeTailwindV4ScannerSources;
4138
+ }
4139
+ });
4140
+ Object.defineProperty(exports, "normalizeTailwindV4SourceEntries", {
4141
+ enumerable: true,
4142
+ get: function() {
4143
+ return normalizeTailwindV4SourceEntries;
4144
+ }
4145
+ });
4146
+ Object.defineProperty(exports, "replaceBareArbitraryValueSelectors", {
4147
+ enumerable: true,
4148
+ get: function() {
4149
+ return replaceBareArbitraryValueSelectors;
4150
+ }
4151
+ });
4152
+ Object.defineProperty(exports, "resolveBareArbitraryValueCandidate", {
4153
+ enumerable: true,
4154
+ get: function() {
4155
+ return resolveBareArbitraryValueCandidate;
4156
+ }
4157
+ });
4158
+ Object.defineProperty(exports, "resolveSourceScanPath", {
4159
+ enumerable: true,
4160
+ get: function() {
4161
+ return resolveSourceScanPath;
4162
+ }
4163
+ });
4164
+ Object.defineProperty(exports, "resolveTailwindV4Source", {
4165
+ enumerable: true,
4166
+ get: function() {
4167
+ return resolveTailwindV4Source;
4168
+ }
4169
+ });
4170
+ Object.defineProperty(exports, "resolveTailwindV4SourceBaseCandidates", {
4171
+ enumerable: true,
4172
+ get: function() {
4173
+ return resolveTailwindV4SourceBaseCandidates;
4174
+ }
4175
+ });
4176
+ Object.defineProperty(exports, "resolveTailwindV4SourceEntry", {
4177
+ enumerable: true,
4178
+ get: function() {
4179
+ return resolveTailwindV4SourceEntry;
4180
+ }
4181
+ });
4182
+ Object.defineProperty(exports, "resolveValidTailwindV4Candidates", {
4183
+ enumerable: true,
4184
+ get: function() {
4185
+ return resolveValidTailwindV4Candidates;
4186
+ }
4187
+ });
4188
+ Object.defineProperty(exports, "toExtension", {
4189
+ enumerable: true,
4190
+ get: function() {
4191
+ return toExtension;
4192
+ }
4193
+ });
4194
+ Object.defineProperty(exports, "toPosixPath", {
4195
+ enumerable: true,
4196
+ get: function() {
4197
+ return toPosixPath;
4198
+ }
4199
+ });