@staticbolt/core 1.0.0-beta.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,485 @@
1
+ import { i as CUSTOM_ATTRIBUTES, t as Log } from "./logger-BuxMGhij.mjs";
2
+ import { NodeType } from "@staticbolt/node-html-parser";
3
+ import c from "chalk";
4
+ import { Node as Node$1 } from "postcss";
5
+ import _generator from "@babel/generator";
6
+ import _traverse from "@babel/traverse";
7
+ import boxen from "boxen";
8
+ import { common, createEmphasize } from "emphasize";
9
+ import { readFileSync } from "node:fs";
10
+ import { readFile } from "node:fs/promises";
11
+ import { createHash } from "node:crypto";
12
+
13
+ //#region src/types/metadata.ts
14
+ const METADATA_TYPES = Object.freeze({
15
+ Script: "Script",
16
+ HTML: "Html",
17
+ Markdown: "Markdown",
18
+ CSS: "Style",
19
+ SVG: "Svg",
20
+ Package: "Package",
21
+ TextAsset: "TextAsset",
22
+ BinaryAsset: "BinaryAsset",
23
+ WebAppManifest: "WebAppManifest"
24
+ });
25
+
26
+ //#endregion
27
+ //#region src/helpers/is-script-type.ts
28
+ const allowedTypes = new Set([
29
+ "module",
30
+ "text/javascript",
31
+ "application/javascript",
32
+ "text/ecmascript",
33
+ "application/ecmascript",
34
+ "application/x-javascript"
35
+ ]);
36
+ function isScriptType(type) {
37
+ return !type || allowedTypes.has(type.toLowerCase());
38
+ }
39
+
40
+ //#endregion
41
+ //#region src/utilities/metadata-utilities.ts
42
+ function isScriptMetadata(metadata) {
43
+ return metadata?.type === METADATA_TYPES.Script;
44
+ }
45
+ function isPackageMetadata(metadata) {
46
+ return metadata?.type === METADATA_TYPES.Package;
47
+ }
48
+ function isHtmlMetadata(metadata) {
49
+ return metadata?.type === METADATA_TYPES.HTML;
50
+ }
51
+ function isStyleMetadata(metadata) {
52
+ return metadata?.type === METADATA_TYPES.CSS;
53
+ }
54
+ function isSvgMetadata(metadata) {
55
+ return metadata?.type === METADATA_TYPES.SVG;
56
+ }
57
+ function isMarkdownMetadata(metadata) {
58
+ return metadata?.type === METADATA_TYPES.Markdown;
59
+ }
60
+ function isTextAssetMetadata(metadata) {
61
+ return metadata?.type === METADATA_TYPES.TextAsset;
62
+ }
63
+ function isBinaryAssetMetadata(metadata) {
64
+ return metadata?.type === METADATA_TYPES.BinaryAsset;
65
+ }
66
+ function isWebManifestMetadata(metadata) {
67
+ return metadata.type === METADATA_TYPES.WebAppManifest;
68
+ }
69
+ /**
70
+ * Returns script-related metadata entries.
71
+ *
72
+ * - If the input is ScriptMetadata, it returns it directly.
73
+ * - If the input is HtmlMetadata, it scans <script> tags in the AST and resolves their associated ScriptMetadata using the metadata
74
+ * ID attribute.
75
+ */
76
+ function filterScriptMetadata(metadata) {
77
+ const result = [];
78
+ if (isScriptMetadata(metadata)) {
79
+ result.push({ metadata });
80
+ return result;
81
+ }
82
+ if (isHtmlMetadata(metadata)) {
83
+ const scriptTags = metadata.ast.querySelectorAll("script");
84
+ for (const scriptTag of scriptTags) {
85
+ const scriptId = scriptTag.getAttribute(CUSTOM_ATTRIBUTES.MetadataID);
86
+ if (!scriptId) continue;
87
+ if (!isScriptType(scriptTag.getAttribute("type"))) continue;
88
+ const scriptMetadata = metadata.scriptsMetadataList.get(scriptId);
89
+ if (!scriptMetadata) continue;
90
+ result.push({
91
+ metadata: scriptMetadata,
92
+ htmlMetadata: metadata,
93
+ tag: scriptTag
94
+ });
95
+ }
96
+ }
97
+ return result;
98
+ }
99
+ /**
100
+ * Returns style-related metadata entries.
101
+ *
102
+ * - If the input is StyleMetadata, it returns it directly.
103
+ * - If the input is HtmlMetadata, it scans <style> tags in the AST and resolves their associated StyleMetadata using the metadata
104
+ * ID attribute.
105
+ */
106
+ function filterStyleMetadata(metadata) {
107
+ const result = [];
108
+ if (isStyleMetadata(metadata)) {
109
+ result.push({ metadata });
110
+ return result;
111
+ }
112
+ if (isHtmlMetadata(metadata)) {
113
+ const styleTags = metadata.ast.querySelectorAll("style");
114
+ for (const styleTag of styleTags) {
115
+ const styleId = styleTag.getAttribute(CUSTOM_ATTRIBUTES.MetadataID) || "";
116
+ const styleMetadata = metadata.stylesMetadataList.get(styleId);
117
+ if (!styleMetadata) continue;
118
+ result.push({
119
+ metadata: styleMetadata,
120
+ htmlMetadata: metadata,
121
+ tag: styleTag
122
+ });
123
+ }
124
+ }
125
+ return result;
126
+ }
127
+
128
+ //#endregion
129
+ //#region src/helpers/babel-fixed-imports.ts
130
+ const generator = typeof _generator === "function" ? _generator : _generator.default;
131
+ const traverse = typeof _traverse === "function" ? _traverse : _traverse.default;
132
+
133
+ //#endregion
134
+ //#region src/utilities/highlight-code.ts
135
+ /** - Highlight code string for terminal */
136
+ function highlightCode(code, { lang = "ts", maxCodeLength = 170, maxLineLength = 110, boxed = true } = {}) {
137
+ const isTruncated = code.length > maxCodeLength;
138
+ if (isTruncated) code = code.slice(0, Math.max(0, maxCodeLength));
139
+ const lines = code.split("\n");
140
+ let withNewLines = "";
141
+ for (const line of lines) {
142
+ if (line.length <= maxLineLength) {
143
+ withNewLines += line + "\n";
144
+ continue;
145
+ }
146
+ const words = line.split(" ");
147
+ let currentLine = "";
148
+ for (const word of words) {
149
+ if (currentLine.length + word.length <= maxLineLength) {
150
+ currentLine += word + " ";
151
+ continue;
152
+ }
153
+ withNewLines += currentLine + "\n";
154
+ currentLine = word + " ";
155
+ }
156
+ withNewLines += currentLine + "\n";
157
+ }
158
+ let highlighted = createEmphasize(common).highlight(lang, withNewLines.trim()).value;
159
+ if (isTruncated) highlighted += "\n" + c.inverse(" ... ");
160
+ if (!boxed) return highlighted;
161
+ return boxen(highlighted, {
162
+ padding: .5,
163
+ borderStyle: "round",
164
+ borderColor: "white",
165
+ dimBorder: true
166
+ });
167
+ }
168
+
169
+ //#endregion
170
+ //#region src/utilities/print-formatted-error.ts
171
+ var PrintFormattedError = class PrintFormattedError {
172
+ options = {};
173
+ constructor(options = {}) {
174
+ Object.assign(this.options, options);
175
+ }
176
+ static create(options = {}) {
177
+ return new PrintFormattedError(options).print;
178
+ }
179
+ print = (...messageAndErrorWithOptions) => {
180
+ const options = { ...this.options };
181
+ const messagesArray = [];
182
+ for (const item of messageAndErrorWithOptions) {
183
+ if (typeof item === "string") {
184
+ messagesArray.push(item);
185
+ continue;
186
+ }
187
+ if (item instanceof Error) {
188
+ messagesArray.push(`\n${item.message}`);
189
+ continue;
190
+ }
191
+ Object.assign(options, item);
192
+ }
193
+ let message = "";
194
+ if (options.filePath) message += c.italic(options.filePath) + "\n";
195
+ const functionName = options.function?.name ?? options.functionName;
196
+ if (functionName) message += c.dim(`[${functionName}] `);
197
+ message += messagesArray.join(" ");
198
+ const codeFromNode = options.node && nodeToString(options.node);
199
+ const code = options.code ?? codeFromNode?.code;
200
+ const lang = options.lang ?? codeFromNode?.lang;
201
+ const codeBox = code && lang ? highlightCode(code, { lang }) : "";
202
+ if (codeBox) message += "\n" + codeBox;
203
+ if (options.level === "warning") {
204
+ Log.warn(message);
205
+ return;
206
+ }
207
+ Log.error(message);
208
+ };
209
+ };
210
+ const printFmtError = PrintFormattedError.create();
211
+ function isHtmlNode(node) {
212
+ return "nodeType" in node && typeof node.nodeType === "number";
213
+ }
214
+ function isPostcssNode(node) {
215
+ return node instanceof Node$1;
216
+ }
217
+ function nodeToString(node) {
218
+ if (isHtmlNode(node)) {
219
+ const clone = node.clone();
220
+ if (clone.nodeType === NodeType.ELEMENT_NODE) clone.removeAttribute(CUSTOM_ATTRIBUTES.MetadataID);
221
+ return {
222
+ code: clone.toString(),
223
+ lang: "html"
224
+ };
225
+ }
226
+ if (isPostcssNode(node)) return {
227
+ code: node.toString(),
228
+ lang: "css"
229
+ };
230
+ return {
231
+ code: generator(node, { jsescOption: { minimal: true } }).code,
232
+ lang: "js"
233
+ };
234
+ }
235
+
236
+ //#endregion
237
+ //#region src/utilities/value-or-error.ts
238
+ function errorsWrapper(function_) {
239
+ return (...arguments_) => {
240
+ try {
241
+ const promiseOrValue = function_(...arguments_);
242
+ if (isPromise(promiseOrValue)) return new Promise((resolve) => {
243
+ promiseOrValue.then((value) => {
244
+ resolve([value, null]);
245
+ }).catch((error) => {
246
+ resolve(handleError(error, function_.name));
247
+ });
248
+ });
249
+ return [promiseOrValue, null];
250
+ } catch (error) {
251
+ return handleError(error, function_.name);
252
+ }
253
+ };
254
+ }
255
+ function isPromise(value) {
256
+ return value && typeof value === "object" && "then" in value && typeof value.then === "function" && "catch" in value && typeof value.catch === "function";
257
+ }
258
+ function handleError(error, functionName = "") {
259
+ if (!error) return [null, /* @__PURE__ */ new Error(`[${functionName}] Unexpected error`)];
260
+ if (typeof error === "string") return [null, new Error(error)];
261
+ if (error instanceof Error) return [null, error];
262
+ if (typeof error === "object" && "message" in error && typeof error.message === "string") return [null, new Error(error.message)];
263
+ return [null, /* @__PURE__ */ new Error(`[${functionName}] Unexpected error`)];
264
+ }
265
+ const valueOrError = errorsWrapper;
266
+
267
+ //#endregion
268
+ //#region src/utilities/read-file.ts
269
+ async function safeReadFile(path, options) {
270
+ try {
271
+ return [await readFile(path, options), null];
272
+ } catch (error) {
273
+ return handleError(error, "readFile");
274
+ }
275
+ }
276
+ function safeReadFileSync(path, options) {
277
+ try {
278
+ return [readFileSync(path, options), null];
279
+ } catch (error) {
280
+ return handleError(error, "readFileSync");
281
+ }
282
+ }
283
+
284
+ //#endregion
285
+ //#region src/utilities/utilities.ts
286
+ /** `process.stdout.write` */
287
+ function print(...input) {
288
+ process.stdout.write(input.join(" "));
289
+ }
290
+ /** - Clear the line in the terminal */
291
+ function clearLn() {
292
+ if ("clearLine" in process.stdout && typeof process.stdout.clearLine === "function") {
293
+ process.stdout.clearLine(0);
294
+ process.stdout.cursorTo(0);
295
+ }
296
+ }
297
+ /** Used to assign a computed value to a variable */
298
+ function assign(function_) {
299
+ return function_();
300
+ }
301
+ /** Check if the value is an object */
302
+ function isObject(value) {
303
+ return typeof value === "object" && !Array.isArray(value) && value !== null;
304
+ }
305
+ function kebabToCamelCase(string_) {
306
+ return string_.replace(/-([a-z])/g, (_, char) => char.toUpperCase());
307
+ }
308
+ function camelCaseToKebabCase(string_) {
309
+ return string_.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
310
+ }
311
+ function capitalize(string_) {
312
+ return string_.charAt(0).toUpperCase() + string_.slice(1);
313
+ }
314
+ /**
315
+ * - Get line and column number from first match index
316
+ *
317
+ * @param code - Code string
318
+ * @param matchIndex - Matching index
319
+ * @returns - `[line, column]`
320
+ */
321
+ function getLineColumn(code, matchIndex) {
322
+ let lineNumber = 1;
323
+ let columnNumber = 1;
324
+ for (let index = 0; index < matchIndex; index++) {
325
+ if (code[index] === "\n") {
326
+ lineNumber++;
327
+ columnNumber = 1;
328
+ continue;
329
+ }
330
+ columnNumber++;
331
+ }
332
+ return [lineNumber, columnNumber];
333
+ }
334
+ /** - Human readable bytes, E.g: `1024 => 1KB` */
335
+ function humanReadableBytes(bytes) {
336
+ const units = [
337
+ "B",
338
+ "KB",
339
+ "MB",
340
+ "GB",
341
+ "TB",
342
+ "PB",
343
+ "EB",
344
+ "ZB",
345
+ "YB"
346
+ ];
347
+ let unitIndex = 0;
348
+ while (bytes >= 1024 && unitIndex < units.length - 1) {
349
+ bytes /= 1024;
350
+ unitIndex++;
351
+ }
352
+ return `${bytes.toFixed(2)} ${units[unitIndex]}`;
353
+ }
354
+ function bytesToKB(bytes) {
355
+ return bytes / 1024;
356
+ }
357
+ /** - Clamp a numeric value between min and max values. */
358
+ function clamp(value, min, max) {
359
+ return Math.min(Math.max(value, min), max);
360
+ }
361
+ function isDefined(value) {
362
+ return value !== void 0;
363
+ }
364
+ /**
365
+ * Merges all entries from `source` into `target`, mutating `target` in place.
366
+ *
367
+ * - Existing keys in `target` are overwritten by `source` values.
368
+ * - Values are **not** cloned — object references are shared between both maps after the merge.
369
+ *
370
+ * @param target - The map to be mutated with new/updated entries.
371
+ * @param source - The map whose entries are read and applied to `target`.
372
+ * @returns The mutated `target` map.
373
+ */
374
+ function mergeMaps(target, source) {
375
+ for (const [key, value] of source) target.set(key, value);
376
+ return target;
377
+ }
378
+ const cached = /* @__PURE__ */ new Map();
379
+ /** - Download from CDN */
380
+ async function downloadContent(url) {
381
+ if (cached.has(url)) return [cached.get(url), null];
382
+ const headers = {
383
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36",
384
+ Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
385
+ Referer: url
386
+ };
387
+ try {
388
+ Log.info(`Downloading content from "${url}"`);
389
+ const text = await (await fetch(url, { headers })).text();
390
+ cached.set(url, text);
391
+ return [text, null];
392
+ } catch {
393
+ return [null, /* @__PURE__ */ new Error("Error downloading q: " + url)];
394
+ }
395
+ }
396
+ function isURL(url) {
397
+ return url.startsWith("http://") || url.startsWith("https://");
398
+ }
399
+ /** Creates a shallow clone of an object while preserving its prototype and property descriptors. */
400
+ function cloneObject(object) {
401
+ return Object.create(Object.getPrototypeOf(object), Object.getOwnPropertyDescriptors(object));
402
+ }
403
+ function hashContent(content) {
404
+ return createHash("sha1").update(content).digest("hex");
405
+ }
406
+ const matchHtmlRegExp = /["'&<>]/;
407
+ function escapeHtml(input) {
408
+ const string = "" + input;
409
+ const match = matchHtmlRegExp.exec(string);
410
+ if (!match) return string;
411
+ let escape;
412
+ let html = "";
413
+ let index = 0;
414
+ let lastIndex = 0;
415
+ for (index = match.index; index < string.length; index++) {
416
+ switch (string.codePointAt(index)) {
417
+ case 34:
418
+ escape = "&quot;";
419
+ break;
420
+ case 38:
421
+ escape = "&amp;";
422
+ break;
423
+ case 39:
424
+ escape = "&#39;";
425
+ break;
426
+ case 60:
427
+ escape = "&lt;";
428
+ break;
429
+ case 62:
430
+ escape = "&gt;";
431
+ break;
432
+ default: continue;
433
+ }
434
+ if (lastIndex !== index) html += string.slice(lastIndex, index);
435
+ lastIndex = index + 1;
436
+ html += escape;
437
+ }
438
+ return lastIndex === index ? html : html + string.slice(lastIndex, index);
439
+ }
440
+
441
+ //#endregion
442
+ //#region src/helpers/dependency-tracker.ts
443
+ /**
444
+ * Tracks bidirectional dependencies between importers and their sources.\
445
+ * Handles reconciliation when dependencies change, so stale entries are automatically removed when an importer stops referencing
446
+ * a source.
447
+ */
448
+ var DependencyTracker = class {
449
+ /** Source → Set of importers that depend on it */
450
+ #sourcesToImporters = /* @__PURE__ */ new Map();
451
+ /** Importer → Set of sources it depends on */
452
+ #importerToSources = /* @__PURE__ */ new Map();
453
+ /** Updates the full set of sources for a given importer, reconciling any stale entries from previous calls. */
454
+ update(importer, sources) {
455
+ const nextSources = new Set(sources);
456
+ const previousSources = this.#importerToSources.get(importer) ?? /* @__PURE__ */ new Set();
457
+ for (const source of previousSources) if (!nextSources.has(source)) this.#sourcesToImporters.get(source)?.delete(importer);
458
+ for (const source of nextSources) {
459
+ if (!this.#sourcesToImporters.has(source)) this.#sourcesToImporters.set(source, /* @__PURE__ */ new Set());
460
+ this.#sourcesToImporters.get(source).add(importer);
461
+ }
462
+ this.#importerToSources.set(importer, nextSources);
463
+ }
464
+ /** Deletes all dependency data for a given id, whether it's acting as an importer, a source, or both (e.g. on file unlink). */
465
+ delete(id) {
466
+ this.#sourcesToImporters.delete(id);
467
+ const sources = this.#importerToSources.get(id);
468
+ if (sources) {
469
+ for (const source of sources) this.#sourcesToImporters.get(source)?.delete(id);
470
+ this.#importerToSources.delete(id);
471
+ }
472
+ }
473
+ /** Returns all importers that depend on a given source, or an empty set. */
474
+ getImporters(source) {
475
+ return this.#sourcesToImporters.get(source) ?? /* @__PURE__ */ new Set();
476
+ }
477
+ /** Returns all sources that a given importer depends on, or an empty set. */
478
+ getSources(importer) {
479
+ return this.#importerToSources.get(importer) ?? /* @__PURE__ */ new Set();
480
+ }
481
+ };
482
+
483
+ //#endregion
484
+ export { isHtmlMetadata as A, PrintFormattedError as C, filterScriptMetadata as D, traverse as E, isSvgMetadata as F, isTextAssetMetadata as I, isWebManifestMetadata as L, isPackageMetadata as M, isScriptMetadata as N, filterStyleMetadata as O, isStyleMetadata as P, isScriptType as R, valueOrError as S, generator as T, kebabToCamelCase as _, capitalize as a, safeReadFile as b, cloneObject as c, getLineColumn as d, hashContent as f, isURL as g, isObject as h, camelCaseToKebabCase as i, isMarkdownMetadata as j, isBinaryAssetMetadata as k, downloadContent as l, isDefined as m, assign as n, clamp as o, humanReadableBytes as p, bytesToKB as r, clearLn as s, DependencyTracker as t, escapeHtml as u, mergeMaps as v, printFmtError as w, safeReadFileSync as x, print as y, METADATA_TYPES as z };
485
+ //# sourceMappingURL=dependency-tracker-BuZfopIj.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependency-tracker-BuZfopIj.mjs","names":["chalk","PostcssNode","#sourcesToImporters","#importerToSources"],"sources":["../src/types/metadata.ts","../src/helpers/is-script-type.ts","../src/utilities/metadata-utilities.ts","../src/helpers/babel-fixed-imports.ts","../src/utilities/highlight-code.ts","../src/utilities/print-formatted-error.ts","../src/utilities/value-or-error.ts","../src/utilities/read-file.ts","../src/utilities/utilities.ts","../src/helpers/dependency-tracker.ts"],"sourcesContent":["import type { BabelAst, PostcssAst, Document, MarkdownAst } from \"@staticbolt/core\";\nimport type { WebAppManifest } from \"web-app-manifest\";\n\nexport const METADATA_TYPES = Object.freeze({\n Script: \"Script\",\n HTML: \"Html\",\n Markdown: \"Markdown\",\n CSS: \"Style\",\n SVG: \"Svg\",\n Package: \"Package\",\n TextAsset: \"TextAsset\",\n BinaryAsset: \"BinaryAsset\",\n WebAppManifest: \"WebAppManifest\",\n});\n\nexport type MetadataTypes = (typeof METADATA_TYPES)[keyof typeof METADATA_TYPES];\n\nexport interface MetadataBase {\n readonly type: `${Capitalize<string>}${string}`;\n\n /**\n * Relative path of the source file.\n *\n * Initially identical to `originalSource` when the metadata is created. During the build process, this value may change (e.g.,\n * if the file is moved to a different location and its links are rebased).\n */\n filePath: string;\n\n /**\n * Original relative path of the source file.\n *\n * Set when the metadata is created and never modified.\n */\n readonly id: string;\n\n readonly directDependencies: Set<string>;\n}\n\nexport interface ScriptMetadata extends MetadataBase {\n readonly type: (typeof METADATA_TYPES)[\"Script\"];\n\n /**\n * The Babel AST for the script.\n *\n * Mutated during the build process and always represents the file's current transformed state.\n */\n ast: BabelAst;\n\n /** Whether the script is a module or global */\n module: boolean;\n}\n\nexport interface StyleMetadata extends MetadataBase {\n readonly type: (typeof METADATA_TYPES)[\"CSS\"];\n\n /**\n * The PostCSS root after transformation\n *\n * Mutated during the build process and always represents the file's current transformed state.\n */\n ast: PostcssAst;\n}\n\nexport interface HtmlMetadata extends MetadataBase {\n type: (typeof METADATA_TYPES)[\"HTML\"];\n\n /**\n * The HTML AST (root element).\n *\n * Mutated during the build process and always represents the file's current transformed state\n */\n ast: Document;\n\n /** The transformed ASTs from script tags. The key is the UUID */\n scriptsMetadataList: Map<string, ScriptMetadata>;\n\n /** The transformed ASTs from script tags. The key is the UUID */\n stylesMetadataList: Map<string, StyleMetadata>;\n}\n\nexport interface SvgMetadata extends MetadataBase {\n type: (typeof METADATA_TYPES)[\"SVG\"];\n\n /**\n * The HTML AST (root element).\n *\n * Mutated during the build process and always represents the file's current transformed state\n */\n ast: Document;\n\n /** The transformed ASTs from script tags. The key is the UUID */\n stylesMetadataList: Map<string, StyleMetadata>;\n}\n\nexport interface MarkdownMetadata extends MetadataBase {\n type: (typeof METADATA_TYPES)[\"Markdown\"];\n\n /**\n * Markdown tokens and frontmatter.\n *\n * Mutated during the build process and always represents the file's current transformed state\n */\n ast: MarkdownAst;\n}\n\nexport interface WebManifestMetadata extends MetadataBase {\n type: (typeof METADATA_TYPES)[\"WebAppManifest\"];\n ast: WebAppManifest;\n}\n\nexport interface PackageMetadata extends MetadataBase {\n type: (typeof METADATA_TYPES)[\"Package\"];\n\n /** Metadata code */\n code: string;\n\n packageName: string;\n}\n\nexport interface TextAssetMetadata extends MetadataBase {\n type: (typeof METADATA_TYPES)[\"TextAsset\"];\n\n /** Metadata code */\n code: string;\n}\n\nexport interface BinaryAssetMetadata extends MetadataBase {\n type: (typeof METADATA_TYPES)[\"BinaryAsset\"];\n\n /** Raw binary content — images, fonts, wasm, etc. */\n data?: Uint8Array;\n}\n","const allowedTypes = new Set([\n \"module\",\n \"text/javascript\",\n \"application/javascript\",\n \"text/ecmascript\",\n \"application/ecmascript\",\n \"application/x-javascript\",\n]);\n\nexport function isScriptType(type: string | null) {\n return !type || allowedTypes.has(type.toLowerCase());\n}\n","import { isScriptType } from \"../helpers/is-script-type.ts\";\nimport { CUSTOM_ATTRIBUTES } from \"../types/common.ts\";\nimport { METADATA_TYPES } from \"../types/metadata.ts\";\n\nimport type {\n TextAssetMetadata,\n HtmlMetadata,\n MarkdownMetadata,\n MetadataBase,\n ScriptMetadata,\n StyleMetadata,\n SvgMetadata,\n WebManifestMetadata,\n BinaryAssetMetadata,\n PackageMetadata,\n HTMLElement,\n} from \"@staticbolt/core\";\n\nexport function isScriptMetadata(metadata: MetadataBase | undefined): metadata is ScriptMetadata {\n return metadata?.type === METADATA_TYPES.Script;\n}\n\nexport function isPackageMetadata(metadata: MetadataBase | undefined): metadata is PackageMetadata {\n return metadata?.type === METADATA_TYPES.Package;\n}\n\nexport function isHtmlMetadata(metadata: MetadataBase | undefined): metadata is HtmlMetadata {\n return metadata?.type === METADATA_TYPES.HTML;\n}\n\nexport function isStyleMetadata(metadata: MetadataBase | undefined): metadata is StyleMetadata {\n return metadata?.type === METADATA_TYPES.CSS;\n}\n\nexport function isSvgMetadata(metadata: MetadataBase | undefined): metadata is SvgMetadata {\n return metadata?.type === METADATA_TYPES.SVG;\n}\n\nexport function isMarkdownMetadata(metadata: MetadataBase | undefined): metadata is MarkdownMetadata {\n return metadata?.type === METADATA_TYPES.Markdown;\n}\n\nexport function isTextAssetMetadata(metadata: MetadataBase | undefined): metadata is TextAssetMetadata {\n return metadata?.type === METADATA_TYPES.TextAsset;\n}\n\nexport function isBinaryAssetMetadata(metadata: MetadataBase | undefined): metadata is BinaryAssetMetadata {\n return metadata?.type === METADATA_TYPES.BinaryAsset;\n}\n\nexport function isWebManifestMetadata(metadata: MetadataBase): metadata is WebManifestMetadata {\n return metadata.type === METADATA_TYPES.WebAppManifest;\n}\n\n/**\n * Returns script-related metadata entries.\n *\n * - If the input is ScriptMetadata, it returns it directly.\n * - If the input is HtmlMetadata, it scans <script> tags in the AST and resolves their associated ScriptMetadata using the metadata\n * ID attribute.\n */\nexport function filterScriptMetadata(metadata: MetadataBase) {\n const result: { metadata: ScriptMetadata; tag?: HTMLElement; htmlMetadata?: HtmlMetadata }[] = [];\n\n if (isScriptMetadata(metadata)) {\n result.push({ metadata });\n return result;\n }\n\n if (isHtmlMetadata(metadata)) {\n const scriptTags = metadata.ast.querySelectorAll(\"script\");\n\n for (const scriptTag of scriptTags) {\n const scriptId = scriptTag.getAttribute(CUSTOM_ATTRIBUTES.MetadataID);\n if (!scriptId) continue;\n\n const scriptType = scriptTag.getAttribute(\"type\");\n if (!isScriptType(scriptType)) {\n continue;\n }\n\n const scriptMetadata = metadata.scriptsMetadataList.get(scriptId);\n if (!scriptMetadata) continue;\n\n result.push({ metadata: scriptMetadata, htmlMetadata: metadata, tag: scriptTag });\n }\n }\n\n return result;\n}\n\n/**\n * Returns style-related metadata entries.\n *\n * - If the input is StyleMetadata, it returns it directly.\n * - If the input is HtmlMetadata, it scans <style> tags in the AST and resolves their associated StyleMetadata using the metadata\n * ID attribute.\n */\nexport function filterStyleMetadata(metadata: MetadataBase) {\n const result: { metadata: StyleMetadata; tag?: HTMLElement; htmlMetadata?: HtmlMetadata }[] = [];\n\n if (isStyleMetadata(metadata)) {\n result.push({ metadata });\n return result;\n }\n\n if (isHtmlMetadata(metadata)) {\n const styleTags = metadata.ast.querySelectorAll(\"style\");\n\n for (const styleTag of styleTags) {\n const styleId = styleTag.getAttribute(CUSTOM_ATTRIBUTES.MetadataID) || \"\";\n const styleMetadata = metadata.stylesMetadataList.get(styleId);\n if (!styleMetadata) continue;\n\n result.push({\n metadata: styleMetadata,\n htmlMetadata: metadata,\n tag: styleTag,\n });\n }\n }\n\n return result;\n}\n","import _generator from \"@babel/generator\";\nimport _traverse from \"@babel/traverse\";\n\nconst generator = typeof _generator === \"function\" ? _generator : _generator.default;\n\nconst traverse = typeof _traverse === \"function\" ? _traverse : _traverse.default;\n\nexport { generator, traverse };\n","import boxen from \"boxen\";\nimport chalk from \"chalk\";\nimport { common, createEmphasize } from \"emphasize\";\n\n/** - Highlight code string for terminal */\nexport function highlightCode(code: string, { lang = \"ts\", maxCodeLength = 170, maxLineLength = 110, boxed = true } = {}) {\n // Limit code length\n const isTruncated = code.length > maxCodeLength;\n if (isTruncated) code = code.slice(0, Math.max(0, maxCodeLength));\n\n // Limit line length and break on words\n const lines = code.split(\"\\n\");\n let withNewLines = \"\";\n for (const line of lines) {\n if (line.length <= maxLineLength) {\n withNewLines += line + \"\\n\";\n continue;\n }\n\n const words = line.split(\" \");\n let currentLine = \"\";\n for (const word of words) {\n if (currentLine.length + word.length <= maxLineLength) {\n currentLine += word + \" \";\n continue;\n }\n withNewLines += currentLine + \"\\n\";\n currentLine = word + \" \";\n }\n withNewLines += currentLine + \"\\n\";\n }\n\n // Highlight\n let highlighted = createEmphasize(common).highlight(lang, withNewLines.trim()).value;\n if (isTruncated) highlighted += \"\\n\" + chalk.inverse(\" ... \");\n\n if (!boxed) return highlighted;\n\n return boxen(highlighted, {\n padding: 0.5,\n borderStyle: \"round\",\n borderColor: \"white\",\n dimBorder: true,\n });\n}\n","import { NodeType } from \"@staticbolt/node-html-parser\";\nimport c from \"chalk\";\nimport { Node as PostcssNode } from \"postcss\";\n\nimport { generator } from \"../helpers/babel-fixed-imports.ts\";\nimport { CUSTOM_ATTRIBUTES } from \"../types/common.ts\";\nimport { highlightCode } from \"./highlight-code.ts\";\nimport { Log } from \"./logger.ts\";\n\nimport type { Node as BabelNode } from \"@babel/types\";\nimport type { HTMLElement, Node as HtmlNode } from \"@staticbolt/node-html-parser\";\n\ntype Node = BabelNode | PostcssNode | HtmlNode;\n\ninterface FormatErrorOptions {\n /** AST node (e.g., from Babel, PostCSS, or HTML) to convert and highlight */\n node?: Node;\n\n /** Source code to highlight (use instead of `node`) */\n code?: string;\n\n /** Language of the provided source code (required if `code` is set) */\n lang?: string;\n\n /** Path of the file where the error occurred */\n filePath?: string;\n\n /** Name of the function where the error originated */\n functionName?: string;\n\n level?: \"error\" | \"warning\";\n\n /** Function reference used to extract the function name */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n function?: (...arguments_: any[]) => any;\n}\n\ntype MessageAndError = (string | Error)[];\n\nexport class PrintFormattedError {\n options: FormatErrorOptions = {};\n\n constructor(options: FormatErrorOptions = {}) {\n Object.assign(this.options, options);\n }\n\n static create(options: FormatErrorOptions = {}) {\n return new PrintFormattedError(options).print;\n }\n\n print = (...messageAndErrorWithOptions: [...MessageAndError] | [...MessageAndError, FormatErrorOptions]) => {\n const options: FormatErrorOptions = { ...this.options };\n\n const messagesArray: string[] = [];\n for (const item of messageAndErrorWithOptions) {\n // Msg\n if (typeof item === \"string\") {\n messagesArray.push(item);\n continue;\n }\n\n // Error\n if (item instanceof Error) {\n messagesArray.push(`\\n${item.message}`);\n continue;\n }\n\n // Options\n Object.assign(options, item);\n }\n\n let message = \"\";\n\n // First file path in one line without anything else to enable vscode link parsing\n if (options.filePath) {\n message += c.italic(options.filePath) + \"\\n\";\n }\n\n // Then the function name before the messages\n const functionName = options.function?.name ?? options.functionName;\n if (functionName) {\n message += c.dim(`[${functionName}] `);\n }\n\n // Then the messages (spaced)\n message += messagesArray.join(\" \");\n\n // Now the code\n const codeFromNode = options.node && nodeToString(options.node);\n const code = options.code ?? codeFromNode?.code;\n const lang = options.lang ?? codeFromNode?.lang;\n const codeBox = code && lang ? highlightCode(code, { lang }) : \"\";\n if (codeBox) {\n message += \"\\n\" + codeBox;\n }\n\n if (options.level === \"warning\") {\n Log.warn(message);\n return;\n }\n\n Log.error(message);\n };\n}\n\nexport const printFmtError = PrintFormattedError.create();\n\nfunction isHtmlNode(node: Node): node is HtmlNode {\n return \"nodeType\" in node && typeof node.nodeType === \"number\";\n}\n\nfunction isPostcssNode(node: Node): node is PostcssNode {\n return node instanceof PostcssNode;\n}\n\nfunction nodeToString(node: Node): { code: string; lang: string } {\n if (isHtmlNode(node)) {\n const clone = node.clone();\n if (clone.nodeType === NodeType.ELEMENT_NODE) {\n (clone as HTMLElement).removeAttribute(CUSTOM_ATTRIBUTES.MetadataID);\n }\n\n return { code: clone.toString(), lang: \"html\" };\n }\n\n if (isPostcssNode(node)) {\n return { code: node.toString(), lang: \"css\" };\n }\n\n return { code: generator(node, { jsescOption: { minimal: true } }).code, lang: \"js\" };\n}\n","export type ValueOrError<T> = [T, null] | [null, Error];\n\nfunction errorsWrapper<T, A extends unknown[]>(function_: (...arguments_: A) => T | Promise<T>) {\n return (...arguments_: A) => {\n try {\n const promiseOrValue = function_(...arguments_);\n if (isPromise<T>(promiseOrValue)) {\n return new Promise(resolve => {\n promiseOrValue\n .then(value => {\n resolve([value, null]);\n })\n .catch((error: unknown) => {\n resolve(handleError(error, function_.name));\n });\n });\n }\n return [promiseOrValue, null];\n } catch (error) {\n return handleError(error, function_.name);\n }\n };\n}\n\nfunction isPromise<T>(value: T | Promise<T>): value is Promise<T> {\n return (\n value &&\n typeof value === \"object\" &&\n \"then\" in value &&\n typeof value.then === \"function\" &&\n \"catch\" in value &&\n typeof value.catch === \"function\"\n );\n}\n\nexport function handleError<T>(error: unknown, functionName = \"\"): ValueOrError<T> {\n if (!error) {\n return [null, new Error(`[${functionName}] Unexpected error`)];\n }\n\n if (typeof error === \"string\") {\n return [null, new Error(error)];\n }\n\n if (error instanceof Error) {\n return [null, error];\n }\n\n // in some cases the error is not an instance of Error but an object\n if (typeof error === \"object\" && \"message\" in error && typeof error.message === \"string\") {\n return [null, new Error(error.message)];\n }\n\n return [null, new Error(`[${functionName}] Unexpected error`)];\n}\n\ninterface goErrorsI {\n <T, A extends unknown[]>(function_: (...arguments_: A) => Promise<T>): (...arguments_: A) => Promise<ValueOrError<T>>;\n <T, A extends unknown[]>(function_: (...arguments_: A) => T): (...arguments_: A) => ValueOrError<T>;\n}\n\nexport const valueOrError = errorsWrapper as unknown as goErrorsI;\n","import type { Abortable } from \"node:events\";\nimport { readFileSync } from \"node:fs\";\nimport type { ObjectEncodingOptions, OpenMode, PathLike, PathOrFileDescriptor } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport type { FileHandle } from \"node:fs/promises\";\n\nimport { handleError } from \"./value-or-error.ts\";\n\nimport type { ValueOrError } from \"./value-or-error.ts\";\n\nexport async function safeReadFile(\n path: PathLike | FileHandle,\n options?:\n | ({\n encoding?: null | undefined;\n flag?: OpenMode | undefined;\n } & Abortable)\n | null\n): Promise<ValueOrError<Buffer>>;\n\nexport async function safeReadFile(\n path: PathLike | FileHandle,\n options:\n | ({\n encoding: BufferEncoding;\n flag?: OpenMode | undefined;\n } & Abortable)\n | BufferEncoding\n): Promise<ValueOrError<string>>;\n\nexport async function safeReadFile(\n path: PathLike | FileHandle,\n options?:\n | (ObjectEncodingOptions &\n Abortable & {\n flag?: OpenMode | undefined;\n })\n | BufferEncoding\n | null\n): Promise<ValueOrError<string | Buffer>>;\n\nexport async function safeReadFile(\n path: PathLike | FileHandle,\n options?:\n | (ObjectEncodingOptions &\n Abortable & {\n flag?: OpenMode | undefined;\n })\n | BufferEncoding\n | null\n): Promise<ValueOrError<string | Buffer>> {\n try {\n const string_ = await readFile(path, options);\n return [string_, null];\n } catch (error) {\n return handleError(error, \"readFile\");\n }\n}\n\nexport function safeReadFileSync(\n path: PathOrFileDescriptor,\n options?: {\n encoding?: null | undefined;\n flag?: string | undefined;\n } | null\n): ValueOrError<NonSharedBuffer>;\n\nexport function safeReadFileSync(\n path: PathOrFileDescriptor,\n options:\n | {\n encoding: BufferEncoding;\n flag?: string | undefined;\n }\n | BufferEncoding\n): ValueOrError<string>;\n\nexport function safeReadFileSync(\n path: PathOrFileDescriptor,\n options?:\n | (ObjectEncodingOptions & {\n flag?: string | undefined;\n })\n | BufferEncoding\n | null\n): ValueOrError<string | NonSharedBuffer>;\n\nexport function safeReadFileSync(\n path: PathOrFileDescriptor,\n options?:\n | (ObjectEncodingOptions & {\n flag?: string | undefined;\n })\n | BufferEncoding\n | null\n): ValueOrError<string | NonSharedBuffer> {\n try {\n const string_ = readFileSync(path, options);\n return [string_, null];\n } catch (error) {\n return handleError(error, \"readFileSync\");\n }\n}\n","import { createHash } from \"node:crypto\";\n\nimport { Log } from \"./logger.ts\";\n\nimport type { ValueOrError } from \"./value-or-error.ts\";\n\n/** `process.stdout.write` */\nexport function print(...input: string[]) {\n process.stdout.write(input.join(\" \"));\n}\n\n/** - Clear the line in the terminal */\nexport function clearLn() {\n if (\"clearLine\" in process.stdout && typeof process.stdout.clearLine === \"function\") {\n process.stdout.clearLine(0);\n process.stdout.cursorTo(0);\n }\n}\n\n/** Used to assign a computed value to a variable */\nexport function assign<T>(function_: () => T): T {\n return function_();\n}\n\n/** Check if the value is an object */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && !Array.isArray(value) && value !== null;\n}\n\nexport function kebabToCamelCase(string_: string): string {\n return string_.replace(/-([a-z])/g, (_, char) => (char as string).toUpperCase());\n}\n\nexport function camelCaseToKebabCase(string_: string): string {\n return string_.replace(/([a-z])([A-Z])/g, \"$1-$2\").toLowerCase();\n}\n\nexport function capitalize(string_: string): string {\n return string_.charAt(0).toUpperCase() + string_.slice(1);\n}\n\n/**\n * - Get line and column number from first match index\n *\n * @param code - Code string\n * @param matchIndex - Matching index\n * @returns - `[line, column]`\n */\nexport function getLineColumn(code: string, matchIndex: number): [number, number] {\n let lineNumber = 1;\n let columnNumber = 1;\n\n for (let index = 0; index < matchIndex; index++) {\n if (code[index] === \"\\n\") {\n lineNumber++;\n columnNumber = 1; // Reset column at each new line\n continue;\n }\n\n columnNumber++;\n }\n\n return [lineNumber, columnNumber];\n}\n\n/** - Human readable bytes, E.g: `1024 => 1KB` */\nexport function humanReadableBytes(bytes: number): string {\n const units = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"];\n let unitIndex = 0;\n while (bytes >= 1024 && unitIndex < units.length - 1) {\n bytes /= 1024;\n unitIndex++;\n }\n return `${bytes.toFixed(2)} ${units[unitIndex]}`;\n}\n\nexport function bytesToKB(bytes: number): number {\n return bytes / 1024;\n}\n\n/** - Clamp a numeric value between min and max values. */\nexport function clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n\nexport function isDefined<T>(value: T | undefined): value is T {\n return value !== undefined;\n}\n\n/**\n * Merges all entries from `source` into `target`, mutating `target` in place.\n *\n * - Existing keys in `target` are overwritten by `source` values.\n * - Values are **not** cloned — object references are shared between both maps after the merge.\n *\n * @param target - The map to be mutated with new/updated entries.\n * @param source - The map whose entries are read and applied to `target`.\n * @returns The mutated `target` map.\n */\nexport function mergeMaps<K, V>(target: Map<K, V>, source: Map<K, V>): Map<K, V> {\n for (const [key, value] of source) {\n target.set(key, value);\n }\n return target;\n}\n\nconst cached = new Map<string, string>();\n\n/** - Download from CDN */\nexport async function downloadContent(url: string): Promise<ValueOrError<string>> {\n if (cached.has(url)) {\n return [cached.get(url)!, null];\n }\n\n const headers = {\n \"User-Agent\":\n \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36\",\n Accept: \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\",\n Referer: url,\n };\n\n try {\n Log.info(`Downloading content from \"${url}\"`);\n const response = await fetch(url, { headers });\n const text = await response.text();\n cached.set(url, text);\n return [text, null];\n } catch {\n return [null, new Error(\"Error downloading q: \" + url)];\n }\n}\n\nexport function isURL(url: string): boolean {\n return url.startsWith(\"http://\") || url.startsWith(\"https://\");\n}\n\n/** Creates a shallow clone of an object while preserving its prototype and property descriptors. */\nexport function cloneObject<T extends object>(object: T): T {\n return Object.create(Object.getPrototypeOf(object) as T, Object.getOwnPropertyDescriptors(object)) as T;\n}\n\nexport function hashContent(content: string) {\n return createHash(\"sha1\").update(content).digest(\"hex\"); // full 40 chars\n}\n\nconst matchHtmlRegExp = /[\"'&<>]/;\n\nexport function escapeHtml(input: string) {\n const string = \"\" + input;\n const match = matchHtmlRegExp.exec(string);\n\n if (!match) {\n return string;\n }\n\n let escape;\n let html = \"\";\n // eslint-disable-next-line no-useless-assignment\n let index = 0;\n let lastIndex = 0;\n\n for (index = match.index; index < string.length; index++) {\n switch (string.codePointAt(index)) {\n case 34: // \"\n escape = \"&quot;\";\n break;\n case 38: // &\n escape = \"&amp;\";\n break;\n case 39: // '\n escape = \"&#39;\";\n break;\n case 60: // <\n escape = \"&lt;\";\n break;\n case 62: // >\n escape = \"&gt;\";\n break;\n default:\n continue;\n }\n\n if (lastIndex !== index) {\n html += string.slice(lastIndex, index);\n }\n\n lastIndex = index + 1;\n html += escape;\n }\n\n return lastIndex === index ? html : html + string.slice(lastIndex, index);\n}\n","/**\n * Tracks bidirectional dependencies between importers and their sources.\\\n * Handles reconciliation when dependencies change, so stale entries are automatically removed when an importer stops referencing\n * a source.\n */\nexport class DependencyTracker {\n /** Source → Set of importers that depend on it */\n readonly #sourcesToImporters = new Map<string, Set<string>>();\n\n /** Importer → Set of sources it depends on */\n readonly #importerToSources = new Map<string, Set<string>>();\n\n /** Updates the full set of sources for a given importer, reconciling any stale entries from previous calls. */\n update(importer: string, sources: Iterable<string>): void {\n const nextSources = new Set(sources);\n const previousSources = this.#importerToSources.get(importer) ?? new Set();\n\n // Remove importer from sources it no longer uses\n for (const source of previousSources) {\n if (!nextSources.has(source)) {\n this.#sourcesToImporters.get(source)?.delete(importer);\n }\n }\n\n // Add importer to newly referenced sources\n for (const source of nextSources) {\n if (!this.#sourcesToImporters.has(source)) {\n this.#sourcesToImporters.set(source, new Set());\n }\n\n this.#sourcesToImporters.get(source)!.add(importer);\n }\n\n this.#importerToSources.set(importer, nextSources);\n }\n\n /** Deletes all dependency data for a given id, whether it's acting as an importer, a source, or both (e.g. on file unlink). */\n delete(id: string): void {\n // id was a source — drop it entirely\n this.#sourcesToImporters.delete(id);\n\n // id was an importer — remove it from all sources it referenced\n const sources = this.#importerToSources.get(id);\n if (sources) {\n for (const source of sources) {\n this.#sourcesToImporters.get(source)?.delete(id);\n }\n\n this.#importerToSources.delete(id);\n }\n }\n\n /** Returns all importers that depend on a given source, or an empty set. */\n getImporters(source: string): ReadonlySet<string> {\n return this.#sourcesToImporters.get(source) ?? new Set();\n }\n\n /** Returns all sources that a given importer depends on, or an empty set. */\n getSources(importer: string): ReadonlySet<string> {\n return this.#importerToSources.get(importer) ?? new Set();\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,MAAa,iBAAiB,OAAO,OAAO;CAC1C,QAAQ;CACR,MAAM;CACN,UAAU;CACV,KAAK;CACL,KAAK;CACL,SAAS;CACT,WAAW;CACX,aAAa;CACb,gBAAgB;CACjB,CAAC;;;;ACbF,MAAM,eAAe,IAAI,IAAI;CAC3B;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAgB,aAAa,MAAqB;CAChD,OAAO,CAAC,QAAQ,aAAa,IAAI,KAAK,aAAa,CAAC;;;;;ACQtD,SAAgB,iBAAiB,UAAgE;CAC/F,OAAO,UAAU,SAAS,eAAe;;AAG3C,SAAgB,kBAAkB,UAAiE;CACjG,OAAO,UAAU,SAAS,eAAe;;AAG3C,SAAgB,eAAe,UAA8D;CAC3F,OAAO,UAAU,SAAS,eAAe;;AAG3C,SAAgB,gBAAgB,UAA+D;CAC7F,OAAO,UAAU,SAAS,eAAe;;AAG3C,SAAgB,cAAc,UAA6D;CACzF,OAAO,UAAU,SAAS,eAAe;;AAG3C,SAAgB,mBAAmB,UAAkE;CACnG,OAAO,UAAU,SAAS,eAAe;;AAG3C,SAAgB,oBAAoB,UAAmE;CACrG,OAAO,UAAU,SAAS,eAAe;;AAG3C,SAA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