@velastack/patterns 0.7.1 → 0.9.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.
Files changed (41) hide show
  1. package/dist/chunks/{collections-BrEA7a62.js → collections-DZOuRpvS.js} +6 -1
  2. package/dist/chunks/collections-DZOuRpvS.js.map +1 -0
  3. package/dist/chunks/currency.server-Bb2Ndutg.js +180 -0
  4. package/dist/chunks/currency.server-Bb2Ndutg.js.map +1 -0
  5. package/dist/chunks/generate-B-cqjI-U.js +86 -0
  6. package/dist/chunks/generate-B-cqjI-U.js.map +1 -0
  7. package/dist/chunks/{generate.runtime-1ldXcpiD.js → generate.runtime-BC6CBKh6.js} +2 -2
  8. package/dist/chunks/{generate.runtime-1ldXcpiD.js.map → generate.runtime-BC6CBKh6.js.map} +1 -1
  9. package/dist/chunks/{generate.runtime-WeDv05E2.js → generate.runtime-BDbotRNZ.js} +2 -2
  10. package/dist/chunks/{generate.runtime-WeDv05E2.js.map → generate.runtime-BDbotRNZ.js.map} +1 -1
  11. package/dist/chunks/{generate.runtime-BOl3LpPB.js → generate.runtime-BnqS_Zq8.js} +84 -158
  12. package/dist/chunks/generate.runtime-BnqS_Zq8.js.map +1 -0
  13. package/dist/chunks/{generate.runtime-CHQ_MQJQ.js → generate.runtime-C7tlPKH1.js} +2 -2
  14. package/dist/chunks/{generate.runtime-CHQ_MQJQ.js.map → generate.runtime-C7tlPKH1.js.map} +1 -1
  15. package/dist/chunks/{generate.runtime-CGjDfO1P.js → generate.runtime-Cj-5fzbQ.js} +2 -2
  16. package/dist/chunks/{generate.runtime-CGjDfO1P.js.map → generate.runtime-Cj-5fzbQ.js.map} +1 -1
  17. package/dist/chunks/{generate.runtime-CHS5lyHL.js → generate.runtime-DG9Lp3vR.js} +40 -35
  18. package/dist/chunks/generate.runtime-DG9Lp3vR.js.map +1 -0
  19. package/dist/chunks/{generate.runtime-Dq6yS7tN.js → generate.runtime-Du84quuK.js} +2 -2
  20. package/dist/chunks/{generate.runtime-Dq6yS7tN.js.map → generate.runtime-Du84quuK.js.map} +1 -1
  21. package/dist/chunks/{generate.runtime-aKNvrk3M.js → generate.runtime-X-uAteso.js} +131 -101
  22. package/dist/chunks/generate.runtime-X-uAteso.js.map +1 -0
  23. package/dist/chunks/load-function-Dmkhg1pQ.js +79 -0
  24. package/dist/chunks/load-function-Dmkhg1pQ.js.map +1 -0
  25. package/dist/chunks/root-layout.svelte-CUVbnlX-.js +302 -0
  26. package/dist/chunks/root-layout.svelte-CUVbnlX-.js.map +1 -0
  27. package/dist/chunks/site-VrqOvuiU.js +149 -0
  28. package/dist/chunks/site-VrqOvuiU.js.map +1 -0
  29. package/dist/index.js +682 -679
  30. package/dist/index.js.map +1 -1
  31. package/package.json +1 -1
  32. package/dist/chunks/collections-BrEA7a62.js.map +0 -1
  33. package/dist/chunks/generate-BOQA-Flq.js +0 -171
  34. package/dist/chunks/generate-BOQA-Flq.js.map +0 -1
  35. package/dist/chunks/generate-CO88bEvs.js +0 -76
  36. package/dist/chunks/generate-CO88bEvs.js.map +0 -1
  37. package/dist/chunks/generate.runtime-BOl3LpPB.js.map +0 -1
  38. package/dist/chunks/generate.runtime-CHS5lyHL.js.map +0 -1
  39. package/dist/chunks/generate.runtime-aKNvrk3M.js.map +0 -1
  40. package/dist/chunks/site-Dw2KIRJu.js +0 -108
  41. package/dist/chunks/site-Dw2KIRJu.js.map +0 -1
@@ -0,0 +1,149 @@
1
+ import { a as e } from "./util-BLYliuUK.js";
2
+ import { n as t } from "./logger-CQONztPm.js";
3
+ import { i as n } from "./pocketbase-BtN-wL8f.js";
4
+ import r from "node:fs";
5
+ import i from "node:path";
6
+ //#region src/runtime/site.ts
7
+ function a(e) {
8
+ return i.join(e, "src", "lib", "site.ts");
9
+ }
10
+ var o = [
11
+ "currency",
12
+ "country",
13
+ "currencies"
14
+ ];
15
+ function s(e, t = "http://localhost:5173", n = {}) {
16
+ let r = typeof n == "string" ? { currency: n } : n, i = o.filter((e) => r[e] !== void 0).map((e) => l(e, r[e])), a = [
17
+ `\tname: ${_(e)},`,
18
+ `\turl: ${_(t)}`,
19
+ ...i.map((e) => e.join("\n"))
20
+ ];
21
+ return [
22
+ "/**",
23
+ " * Site-wide metadata, and the one place the app's name and public URL live.",
24
+ " *",
25
+ " * Set `url` to where the site is deployed: canonical links, Open Graph images",
26
+ " * and feeds are built from it, including in prerendered pages. With a backend,",
27
+ " * `vela dev` and `vela deploy` copy `name` into PocketBase's application name",
28
+ " * for the emails it sends, so change it here rather than in the admin panel.",
29
+ " */",
30
+ "export const site = {",
31
+ ...a.map((e, t) => t < a.length - 1 ? c(e) : e),
32
+ "};",
33
+ ""
34
+ ].join("\n");
35
+ }
36
+ function c(e) {
37
+ return e.endsWith(",") ? e : `${e},`;
38
+ }
39
+ function l(e, t) {
40
+ switch (e) {
41
+ case "currency": return [" /** ISO 4217: the currency the business prices in and is paid in. */", `\tcurrency: ${_(t)}`];
42
+ case "country": return [" /** ISO 3166-1: the country the business is in; prices format for it. */", `\tcountry: ${_(t)}`];
43
+ case "currencies": return [" /** Other currencies prices are shown in, as estimates at the day's rate. */", `\tcurrencies: [${t.map(_).join(", ")}]`];
44
+ }
45
+ }
46
+ var u = Intl.supportedValuesOf("currency");
47
+ function d(e) {
48
+ if (typeof e != "string") return null;
49
+ let t = e.trim().toUpperCase();
50
+ return /^[A-Z]{3}$/.test(t) && u.includes(t) ? t : null;
51
+ }
52
+ function f(e) {
53
+ if (typeof e != "string") return null;
54
+ let t = e.trim().toUpperCase();
55
+ return /^[A-Z]{2}$/.test(t) ? new Intl.DisplayNames(["en"], { type: "region" }).of(t) === t ? null : t : null;
56
+ }
57
+ function p(e, t) {
58
+ let n = Array.isArray(e) ? e : typeof e == "string" ? e.split(/[,\s]+/) : null;
59
+ if (!n) return null;
60
+ let r = [];
61
+ for (let e of n) {
62
+ if (e === "" || e === void 0) continue;
63
+ let n = d(e);
64
+ if (!n) return null;
65
+ n !== t && !r.includes(n) && r.push(n);
66
+ }
67
+ return r;
68
+ }
69
+ var m = /export const site = \{\n([\s\S]*?)\n\};/;
70
+ function h(e, t, n) {
71
+ let r = m.exec(e);
72
+ if (!r || RegExp(`^\\s*${t}\\s*:`, "m").test(r[1])) return null;
73
+ let i = r[1].replace(/,?\s*$/, ",");
74
+ return e.replace(r[0], `export const site = {\n${i}\n${l(t, n).join("\n")}\n};`);
75
+ }
76
+ function g(e) {
77
+ let t;
78
+ try {
79
+ t = r.readFileSync(a(e), "utf8");
80
+ } catch {
81
+ return {};
82
+ }
83
+ let n = (e, n) => RegExp(`^\\s*${e}\\s*:\\s*['"](${n})['"]`, "m").exec(t)?.[1], i = /^\s*currencies\s*:\s*\[([^\]]*)\]/m.exec(t)?.[1], o = {}, s = n("currency", "[A-Za-z]{3}");
84
+ s && (o.currency = s);
85
+ let c = n("country", "[A-Za-z]{2}");
86
+ return c && (o.country = c), i !== void 0 && (o.currencies = [...i.matchAll(/['"]([A-Za-z]{3})['"]/g)].map((e) => e[1])), o;
87
+ }
88
+ function _(e) {
89
+ return `'${e.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
90
+ }
91
+ async function v(e) {
92
+ if (e.features.backend) try {
93
+ let t;
94
+ if (await n(e.root, async (e) => {
95
+ t = (await e.settings.getAll()).meta?.appName;
96
+ }), typeof t == "string" && t.trim()) return t;
97
+ } catch {}
98
+ try {
99
+ let t = JSON.parse(r.readFileSync(i.join(e.root, "package.json"), "utf8"));
100
+ if (typeof t.name == "string" && t.name.trim()) return t.name;
101
+ } catch {}
102
+ return "My App";
103
+ }
104
+ async function y(n) {
105
+ let i = a(n.root);
106
+ return r.existsSync(i) ? null : (t(n).info("Creating src/lib/site.ts"), {
107
+ path: i,
108
+ language: e(i),
109
+ content: s(await v(n)),
110
+ status: "success"
111
+ });
112
+ }
113
+ async function b(n, i) {
114
+ let c = a(n.root), l = o.filter((e) => i[e] !== void 0);
115
+ if (!r.existsSync(c)) return l.length === 0 ? {
116
+ file: null,
117
+ business: {}
118
+ } : (t(n).info("Creating src/lib/site.ts"), {
119
+ file: {
120
+ path: c,
121
+ language: e(c),
122
+ content: s(await v(n), void 0, i),
123
+ status: "success"
124
+ },
125
+ business: i
126
+ });
127
+ let u = g(n.root), d = r.readFileSync(c, "utf8"), f = [];
128
+ for (let e of l) {
129
+ if (u[e] !== void 0) continue;
130
+ let t = h(d, e, i[e]);
131
+ t !== null && (d = t, f.push(e), u[e] = i[e]);
132
+ }
133
+ return f.length === 0 ? {
134
+ file: null,
135
+ business: u
136
+ } : (t(n).info(`Adding ${f.join(", ")} to src/lib/site.ts`), {
137
+ file: {
138
+ path: c,
139
+ language: e(c),
140
+ content: d,
141
+ status: "success"
142
+ },
143
+ business: u
144
+ });
145
+ }
146
+ //#endregion
147
+ export { d as a, p as i, y as n, s as o, f as r, a as s, b as t };
148
+
149
+ //# sourceMappingURL=site-VrqOvuiU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"site-VrqOvuiU.js","names":["languageFromPath","getLogger","withPocketbase","fs","path","sitePath","root","BUSINESS_KEYS","siteModule","declared","business","lines","key","propertyLines","properties","quote","name","url","entry","i","ensureComma","value","SUPPORTED_CURRENCIES","normalizeCurrency","raw","code","normalizeCountry","normalizeCurrencies","entries","codes","home","SITE_OBJECT","withSiteProperty","match","source","body","siteBusiness","text","shape","list","currency","country","m","existingName","options","appName","pb","pkg","ensureSiteFile","file","ensureSiteBusiness","wanted","existing","added","next"],"sources":["../../src/runtime/site.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options } from \"../core/types\";\nimport { getLogger } from \"../core/logger\";\nimport { languageFromPath } from \"../core/util\";\nimport { withPocketbase } from \"./pocketbase\";\n\n/** Where every VelaStack app keeps its name and public URL. */\nexport function sitePath(root: string): string {\n return path.join(root, \"src\", \"lib\", \"site.ts\");\n}\n\n/**\n * What a business declares about itself in `src/lib/site.ts`, next to the\n * app's name: the currency it prices in and is paid in, the country it is in\n * (prices format for it: `es-MX`, not `es`) and the other currencies it shows\n * prices in, as estimates. Every property is optional; a payments provider\n * asks for what it needs.\n */\nexport interface SiteBusiness {\n /** ISO 4217, e.g. `MXN`. */\n currency?: string;\n /** ISO 3166-1 alpha-2, e.g. `MX`. */\n country?: string;\n /** ISO 4217 codes the site also shows prices in; empty means the home currency only. */\n currencies?: string[];\n}\n\ntype BusinessKey = keyof SiteBusiness;\n\nconst BUSINESS_KEYS: BusinessKey[] = [\"currency\", \"country\", \"currencies\"];\n\n/**\n * `src/lib/site.ts` as the CLI templates ship it (`site.template.ts`), with\n * the placeholders filled in, plus whatever the business declares.\n */\nexport function siteModule(\n name: string,\n url = \"http://localhost:5173\",\n business: SiteBusiness | string = {},\n): string {\n // The old third argument was the currency alone.\n const declared: SiteBusiness =\n typeof business === \"string\" ? { currency: business } : business;\n const lines = BUSINESS_KEYS.filter((key) => declared[key] !== undefined).map(\n (key) => propertyLines(key, declared[key]!),\n );\n const properties = [\n `\\tname: ${quote(name)},`,\n `\\turl: ${quote(url)}`,\n ...lines.map((entry) => entry.join(\"\\n\")),\n ];\n return [\n \"/**\",\n \" * Site-wide metadata, and the one place the app's name and public URL live.\",\n \" *\",\n \" * Set `url` to where the site is deployed: canonical links, Open Graph images\",\n \" * and feeds are built from it, including in prerendered pages. With a backend,\",\n \" * `vela dev` and `vela deploy` copy `name` into PocketBase's application name\",\n \" * for the emails it sends, so change it here rather than in the admin panel.\",\n \" */\",\n \"export const site = {\",\n // Every property but the last ends in a comma.\n ...properties.map((entry, i) =>\n i < properties.length - 1 ? ensureComma(entry) : entry,\n ),\n \"};\",\n \"\",\n ].join(\"\\n\");\n}\n\nfunction ensureComma(entry: string): string {\n return entry.endsWith(\",\") ? entry : `${entry},`;\n}\n\n/** A property's lines: its doc comment, then `key: value` with no trailing comma. */\nfunction propertyLines(key: BusinessKey, value: string | string[]): string[] {\n switch (key) {\n case \"currency\":\n return [\n \"\\t/** ISO 4217: the currency the business prices in and is paid in. */\",\n `\\tcurrency: ${quote(value as string)}`,\n ];\n case \"country\":\n return [\n \"\\t/** ISO 3166-1: the country the business is in; prices format for it. */\",\n `\\tcountry: ${quote(value as string)}`,\n ];\n case \"currencies\":\n return [\n \"\\t/** Other currencies prices are shown in, as estimates at the day's rate. */\",\n `\\tcurrencies: [${(value as string[]).map(quote).join(\", \")}]`,\n ];\n }\n}\n\nconst SUPPORTED_CURRENCIES = (\n Intl as unknown as {\n supportedValuesOf: (key: \"currency\") => string[];\n }\n).supportedValuesOf(\"currency\");\n\n/** A three-letter code `Intl` knows, upper-cased; anything else is refused. */\nexport function normalizeCurrency(raw: unknown): string | null {\n if (typeof raw !== \"string\") return null;\n const code = raw.trim().toUpperCase();\n if (!/^[A-Z]{3}$/.test(code)) return null;\n // Any well-formed code formats, so ask for the list of real ones. Node has\n // had it since 18; the repo's ES2020 lib types just don't declare it.\n return SUPPORTED_CURRENCIES.includes(code) ? code : null;\n}\n\n/** A two-letter ISO 3166-1 code, upper-cased; anything else is refused. */\nexport function normalizeCountry(raw: unknown): string | null {\n if (typeof raw !== \"string\") return null;\n const code = raw.trim().toUpperCase();\n if (!/^[A-Z]{2}$/.test(code)) return null;\n // `Intl.DisplayNames` knows every region; an unknown one comes back as is.\n const names = new Intl.DisplayNames([\"en\"], { type: \"region\" });\n return names.of(code) !== code ? code : null;\n}\n\n/**\n * A list of currency codes, from an array or a comma-separated string,\n * upper-cased and deduplicated; `null` when any entry is not a currency.\n * `home` is left out: the business's own currency is never a display one.\n */\nexport function normalizeCurrencies(\n raw: unknown,\n home?: string,\n): string[] | null {\n const entries = Array.isArray(raw)\n ? raw\n : typeof raw === \"string\"\n ? raw.split(/[,\\s]+/)\n : null;\n if (!entries) return null;\n const codes: string[] = [];\n for (const entry of entries) {\n if (entry === \"\" || entry === undefined) continue;\n const code = normalizeCurrency(entry);\n if (!code) return null;\n if (code !== home && !codes.includes(code)) codes.push(code);\n }\n return codes;\n}\n\nconst SITE_OBJECT = /export const site = \\{\\n([\\s\\S]*?)\\n\\};/;\n\n/**\n * `src/lib/site.ts` with `key` added as the object's last property, or\n * `null` when it already has one (a project's declaration is never changed\n * behind its back) or has no `export const site = { ... };` to add it to.\n */\nexport function withSiteProperty(\n source: string,\n key: BusinessKey,\n value: string | string[],\n): string | null {\n const match = SITE_OBJECT.exec(source);\n if (!match || new RegExp(`^\\\\s*${key}\\\\s*:`, \"m\").test(match[1])) return null;\n const body = match[1].replace(/,?\\s*$/, \",\");\n return source.replace(\n match[0],\n `export const site = {\\n${body}\\n${propertyLines(key, value).join(\"\\n\")}\\n};`,\n );\n}\n\n/** `withSiteProperty` for the currency, as the Phase 1.5 code called it. */\nexport function withSiteCurrency(\n source: string,\n currency: string,\n): string | null {\n return withSiteProperty(source, \"currency\", currency);\n}\n\n/** What `src/lib/site.ts` declares about the business, if anything. */\nexport function siteBusiness(root: string): SiteBusiness {\n let source: string;\n try {\n source = fs.readFileSync(sitePath(root), \"utf8\");\n } catch {\n return {};\n }\n const text = (key: string, shape: string) =>\n new RegExp(`^\\\\s*${key}\\\\s*:\\\\s*['\"](${shape})['\"]`, \"m\").exec(source)?.[1];\n const list = /^\\s*currencies\\s*:\\s*\\[([^\\]]*)\\]/m.exec(source)?.[1];\n const business: SiteBusiness = {};\n const currency = text(\"currency\", \"[A-Za-z]{3}\");\n if (currency) business.currency = currency;\n const country = text(\"country\", \"[A-Za-z]{2}\");\n if (country) business.country = country;\n if (list !== undefined) {\n business.currencies = [...list.matchAll(/['\"]([A-Za-z]{3})['\"]/g)].map(\n (m) => m[1],\n );\n }\n return business;\n}\n\n/** The currency `src/lib/site.ts` declares, if any. */\nexport function siteCurrency(root: string): string | null {\n return siteBusiness(root).currency ?? null;\n}\n\n/** Single-quoted, as the templates write their strings. */\nfunction quote(value: string): string {\n return `'${value.replace(/\\\\/g, \"\\\\\\\\\").replace(/'/g, \"\\\\'\")}'`;\n}\n\n/**\n * The name a project created before `site.ts` existed already goes by.\n *\n * Those projects kept it in PocketBase's settings, so that is asked first; the\n * package name is the fallback for a project without a backend, or one whose\n * database can't be reached.\n */\nasync function existingName(options: Options): Promise<string> {\n if (options.features.backend) {\n try {\n let appName: unknown;\n await withPocketbase(options.root, async (pb) => {\n const settings = (await pb.settings.getAll()) as {\n meta?: { appName?: unknown };\n };\n appName = settings.meta?.appName;\n });\n if (typeof appName === \"string\" && appName.trim()) return appName;\n } catch {\n // No database to ask; fall through to package.json.\n }\n }\n\n try {\n const pkg = JSON.parse(\n fs.readFileSync(path.join(options.root, \"package.json\"), \"utf8\"),\n ) as { name?: unknown };\n if (typeof pkg.name === \"string\" && pkg.name.trim()) return pkg.name;\n } catch {\n // No package.json to name the site after; the placeholder stands.\n }\n return \"My App\";\n}\n\n/**\n * Create `src/lib/site.ts` for a pattern whose files import `#lib/site.js`, when\n * the project doesn't have one yet. Every template ships it; projects created\n * before that read the app name from `locals.meta` instead.\n *\n * Returns null when the file exists, so an existing one is never overwritten.\n */\nexport async function ensureSiteFile(options: Options): Promise<File | null> {\n const file = sitePath(options.root);\n if (fs.existsSync(file)) return null;\n\n getLogger(options).info(\"Creating src/lib/site.ts\");\n return {\n path: file,\n language: languageFromPath(file),\n content: siteModule(await existingName(options)),\n status: \"success\",\n };\n}\n\n/**\n * Make `src/lib/site.ts` declare what the business says about itself: create\n * the file with it, or add the properties an existing one lacks. A property\n * already there is kept, whatever `business` says; the result says what the\n * file declares after the call, and the file to write, if anything changed.\n */\nexport async function ensureSiteBusiness(\n options: Options,\n business: SiteBusiness,\n): Promise<{ file: File | null; business: SiteBusiness }> {\n const file = sitePath(options.root);\n const wanted = BUSINESS_KEYS.filter((key) => business[key] !== undefined);\n if (!fs.existsSync(file)) {\n if (wanted.length === 0) return { file: null, business: {} };\n getLogger(options).info(\"Creating src/lib/site.ts\");\n return {\n file: {\n path: file,\n language: languageFromPath(file),\n content: siteModule(await existingName(options), undefined, business),\n status: \"success\",\n },\n business,\n };\n }\n\n const existing = siteBusiness(options.root);\n let source = fs.readFileSync(file, \"utf8\");\n const added: string[] = [];\n for (const key of wanted) {\n if (existing[key] !== undefined) continue;\n const next = withSiteProperty(source, key, business[key]!);\n if (next === null) continue;\n source = next;\n added.push(key);\n (existing as Record<string, unknown>)[key] = business[key];\n }\n if (added.length === 0) return { file: null, business: existing };\n getLogger(options).info(`Adding ${added.join(\", \")} to src/lib/site.ts`);\n return {\n file: {\n path: file,\n language: languageFromPath(file),\n content: source,\n status: \"success\",\n },\n business: existing,\n };\n}\n\n/** `ensureSiteBusiness` for the currency alone, as the Phase 1.5 code called it. */\nexport async function ensureSiteCurrency(\n options: Options,\n currency: string,\n): Promise<{ file: File | null; currency: string }> {\n const { file, business } = await ensureSiteBusiness(options, { currency });\n return { file, currency: business.currency ?? currency };\n}\n"],"mappings":";;;;;;AAQA,SAAgBK,EAAS,GAAsB;CAC7C,OAAOD,EAAK,KAAKE,GAAM,OAAO,OAAO,SAAS;AAChD;AAoBA,IAAMC,IAA+B;CAAC;CAAY;CAAW;AAAY;AAMzE,SAAgBC,EACd,GACA,IAAM,yBACN,IAAkC,CAAC,GAC3B;CAER,IAAMC,IACJ,OAAOC,KAAa,WAAW,EAAE,UAAUA,EAAS,IAAIA,GACpDC,IAAQJ,EAAc,QAAQ,MAAQE,EAASG,OAAS,KAAA,CAAS,CAAC,CAAC,KACtE,MAAQC,EAAcD,GAAKH,EAASG,EAAK,CAC5C,GACME,IAAa;EACjB,WAAWC,EAAMC,CAAI,EAAE;EACvB,UAAUD,EAAME,CAAG;EACnB,GAAGN,EAAM,KAAK,MAAUO,EAAM,KAAK,IAAI,CAAC;CAC1C;CACA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA,GAAGJ,EAAW,KAAK,GAAO,MACxBK,IAAIL,EAAW,SAAS,IAAIM,EAAYF,CAAK,IAAIA,CACnD;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;AACb;AAEA,SAASE,EAAY,GAAuB;CAC1C,OAAOF,EAAM,SAAS,GAAG,IAAIA,IAAQ,GAA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