@dogsbay/format-astro 0.2.0-beta.12 → 0.2.0-beta.121
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-markdown.d.ts +8 -0
- package/dist/api-markdown.d.ts.map +1 -0
- package/dist/api-markdown.js +50 -0
- package/dist/api-markdown.js.map +1 -0
- package/dist/base-path.d.ts +93 -7
- package/dist/base-path.d.ts.map +1 -1
- package/dist/base-path.js +122 -8
- package/dist/base-path.js.map +1 -1
- package/dist/blog.d.ts +134 -0
- package/dist/blog.d.ts.map +1 -0
- package/dist/blog.js +324 -0
- package/dist/blog.js.map +1 -0
- package/dist/browser.d.ts +14 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +14 -0
- package/dist/browser.js.map +1 -0
- package/dist/canonical.d.ts +34 -0
- package/dist/canonical.d.ts.map +1 -0
- package/dist/canonical.js +107 -0
- package/dist/canonical.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -1
- package/dist/diff-decoration.d.ts +79 -0
- package/dist/diff-decoration.d.ts.map +1 -0
- package/dist/diff-decoration.js +541 -0
- package/dist/diff-decoration.js.map +1 -0
- package/dist/granularity.d.ts +83 -0
- package/dist/granularity.d.ts.map +1 -0
- package/dist/granularity.js +247 -0
- package/dist/granularity.js.map +1 -0
- package/dist/head-metadata.d.ts +26 -0
- package/dist/head-metadata.d.ts.map +1 -0
- package/dist/head-metadata.js +56 -0
- package/dist/head-metadata.js.map +1 -0
- package/dist/index.d.ts +24 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -3
- package/dist/index.js.map +1 -1
- package/dist/lead.d.ts +1 -38
- package/dist/lead.d.ts.map +1 -1
- package/dist/lead.js +3 -37
- package/dist/lead.js.map +1 -1
- package/dist/llms-txt.d.ts +53 -11
- package/dist/llms-txt.d.ts.map +1 -1
- package/dist/llms-txt.js +85 -222
- package/dist/llms-txt.js.map +1 -1
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +4 -2
- package/dist/plugins.js.map +1 -1
- package/dist/project.d.ts +377 -12
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +2263 -661
- package/dist/project.js.map +1 -1
- package/dist/redirects.d.ts +116 -0
- package/dist/redirects.d.ts.map +1 -0
- package/dist/redirects.js +224 -0
- package/dist/redirects.js.map +1 -0
- package/dist/serialize.d.ts +14 -0
- package/dist/serialize.d.ts.map +1 -1
- package/dist/serialize.js +643 -216
- package/dist/serialize.js.map +1 -1
- package/dist/sitemap.d.ts +108 -0
- package/dist/sitemap.d.ts.map +1 -0
- package/dist/sitemap.js +127 -0
- package/dist/sitemap.js.map +1 -0
- package/dist/taxonomy.d.ts +48 -1
- package/dist/taxonomy.d.ts.map +1 -1
- package/dist/taxonomy.js +46 -11
- package/dist/taxonomy.js.map +1 -1
- package/dist/theme-css.d.ts +26 -0
- package/dist/theme-css.d.ts.map +1 -0
- package/dist/theme-css.js +651 -0
- package/dist/theme-css.js.map +1 -0
- package/dist/tone-classes.d.ts +14 -0
- package/dist/tone-classes.d.ts.map +1 -0
- package/dist/tone-classes.js +30 -0
- package/dist/tone-classes.js.map +1 -0
- package/dist/write-if-changed.d.ts +21 -0
- package/dist/write-if-changed.d.ts.map +1 -0
- package/dist/write-if-changed.js +58 -0
- package/dist/write-if-changed.js.map +1 -0
- package/package.json +16 -7
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redirects — `redirect:` / `aliases:` frontmatter and the `redirects:` config
|
|
3
|
+
* key, turned into rules and then into whatever the deploy target can honour.
|
|
4
|
+
*
|
|
5
|
+
* See plans/redirects-and-aliases.md. Three things drove the design:
|
|
6
|
+
*
|
|
7
|
+
* 1. **`redirect:` was accepted everywhere and emitted nowhere.** The schema
|
|
8
|
+
* took it, `ExportPage` carried it, the sitemap excluded the page and
|
|
9
|
+
* `format-dogsbay-md` round-tripped it — and `format-astro` wrote a normal
|
|
10
|
+
* empty page. Four consumers honouring a field is what made it look
|
|
11
|
+
* supported. So the page skip lives here too, not just the rule.
|
|
12
|
+
*
|
|
13
|
+
* 2. **A rule's paths are SERVED paths.** Cloudflare matches the request path,
|
|
14
|
+
* which carries the mount prefix. `/old → /new` on a site mounted at
|
|
15
|
+
* `/blog` must be written `/blog/old → /blog/new` or it never fires.
|
|
16
|
+
*
|
|
17
|
+
* 3. **Trailing slashes decide whether a redirect costs one hop or two.**
|
|
18
|
+
* Sites serve `/guide/auth/` (docs-dev/url-shape.md). A rule targeting
|
|
19
|
+
* `/guide/auth` redirects to a path that itself redirects. Internal paths
|
|
20
|
+
* are normalized to the served form.
|
|
21
|
+
*
|
|
22
|
+
* This module is pure: it does no IO, so every rule and every refusal is
|
|
23
|
+
* testable without building a site.
|
|
24
|
+
*/
|
|
25
|
+
import { isExternalUrl, renderRedirectStub, renderRedirectsFile as renderRedirectsLines, resolveRedirects, } from "@dogsbay/site-files";
|
|
26
|
+
const VALID_STATUS = new Set([301, 302, 303, 307, 308]);
|
|
27
|
+
const isExternal = isExternalUrl;
|
|
28
|
+
/**
|
|
29
|
+
* A page slug → the path it is served at. Mirrors the emitter: pages are
|
|
30
|
+
* directories with a trailing slash, `index` is the prefix root.
|
|
31
|
+
*/
|
|
32
|
+
export function slugToServedPath(slug, prefix) {
|
|
33
|
+
const clean = slug.replace(/^\/+|\/+$/g, "").replace(/(^|\/)index$/, "");
|
|
34
|
+
const base = prefix.replace(/\/+$/, "");
|
|
35
|
+
if (!clean)
|
|
36
|
+
return `${base}/`;
|
|
37
|
+
return `${base}/${clean}/`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The site-path prefix a page's source is published under (its namespace,
|
|
41
|
+
* language and version segments, as `latest` or `en/v3`): its slug without
|
|
42
|
+
* the path the source gave it. "" for a site without those axes.
|
|
43
|
+
*/
|
|
44
|
+
export function pageUnitPrefix(page) {
|
|
45
|
+
const clean = (s) => s.replace(/^\/+|\/+$/g, "").replace(/(^|\/)index$/, "");
|
|
46
|
+
const slug = clean(page.slug);
|
|
47
|
+
const inside = clean(page.multiSource?.originalSlug ?? page.slug);
|
|
48
|
+
if (!inside)
|
|
49
|
+
return slug;
|
|
50
|
+
if (slug === inside)
|
|
51
|
+
return "";
|
|
52
|
+
return slug.endsWith(`/${inside}`) ? slug.slice(0, -inside.length - 1) : "";
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A path written in a page's front matter (`redirect:`, `aliases:`) as a site
|
|
56
|
+
* path: relative to the page's unit (its language and version), unless it
|
|
57
|
+
* already starts with it, as dogsbay-ssg reads it (issue #096). A copied
|
|
58
|
+
* version (`latest` snapshotted to `v4/`) keeps its redirects inside itself.
|
|
59
|
+
* `mount` (urlBase + basePath) may be written or not; URLs pass through.
|
|
60
|
+
*/
|
|
61
|
+
export function inPageUnit(raw, unit, mount) {
|
|
62
|
+
if (!unit || isExternal(raw))
|
|
63
|
+
return raw;
|
|
64
|
+
const t = raw.trim();
|
|
65
|
+
const cut = t.search(/[?#]/);
|
|
66
|
+
const suffix = cut < 0 ? "" : t.slice(cut);
|
|
67
|
+
let p = (cut < 0 ? t : t.slice(0, cut)).replace(/^\/+/, "");
|
|
68
|
+
const m = mount.replace(/^\/+|\/+$/g, "");
|
|
69
|
+
if (m && (p === m || p.startsWith(`${m}/`)))
|
|
70
|
+
p = p.slice(m.length).replace(/^\/+/, "");
|
|
71
|
+
if (!(p === unit || p.startsWith(`${unit}/`)))
|
|
72
|
+
p = p ? `${unit}/${p}` : unit;
|
|
73
|
+
return `/${p}${suffix}`;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Normalize an authored path to the served form: leading slash, mount prefix
|
|
77
|
+
* applied once, trailing slash unless it names a file. External URLs pass
|
|
78
|
+
* through untouched.
|
|
79
|
+
*/
|
|
80
|
+
export function normalizeTarget(raw, prefix) {
|
|
81
|
+
if (isExternal(raw))
|
|
82
|
+
return raw;
|
|
83
|
+
// A "#anchor" or "?query" stays on the target as written; only the path is
|
|
84
|
+
// normalized (it used to become "/a#x/", which matched no page).
|
|
85
|
+
const trimmed = raw.trim();
|
|
86
|
+
const cut = trimmed.search(/[?#]/);
|
|
87
|
+
const suffix = cut < 0 ? "" : trimmed.slice(cut);
|
|
88
|
+
let p = cut < 0 ? trimmed : trimmed.slice(0, cut);
|
|
89
|
+
if (!p.startsWith("/"))
|
|
90
|
+
p = `/${p}`;
|
|
91
|
+
const base = prefix.replace(/\/+$/, "");
|
|
92
|
+
if (base && p !== base && !p.startsWith(`${base}/`)) {
|
|
93
|
+
p = `${base}${p}`;
|
|
94
|
+
}
|
|
95
|
+
const last = p.split("/").pop() ?? "";
|
|
96
|
+
if (!last.includes(".") && !p.endsWith("/"))
|
|
97
|
+
p = `${p}/`;
|
|
98
|
+
return p + suffix;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Gather every declared redirect, resolve paths, and refuse the ones that
|
|
102
|
+
* would be wrong at runtime. Pure — `errors` is the caller's cue to throw.
|
|
103
|
+
*/
|
|
104
|
+
export function collectRedirects(input) {
|
|
105
|
+
const { pages, config, prefix } = input;
|
|
106
|
+
const errors = [];
|
|
107
|
+
const warnings = [];
|
|
108
|
+
const livePaths = new Set();
|
|
109
|
+
for (const page of pages) {
|
|
110
|
+
// A page that only redirects is not a live page — it is the thing being
|
|
111
|
+
// redirected away from, and emitAstroPages skips it.
|
|
112
|
+
if (!page.redirect)
|
|
113
|
+
livePaths.add(slugToServedPath(page.slug, prefix));
|
|
114
|
+
}
|
|
115
|
+
// Duplicates are resolved (and reported) by resolveRedirects.
|
|
116
|
+
const candidates = [];
|
|
117
|
+
const add = (rule) => {
|
|
118
|
+
candidates.push(rule);
|
|
119
|
+
};
|
|
120
|
+
// 1. Page frontmatter: `redirect:` (this page forwards) and `aliases:` (old
|
|
121
|
+
// paths that forward TO this page).
|
|
122
|
+
for (const page of pages) {
|
|
123
|
+
const here = slugToServedPath(page.slug, prefix);
|
|
124
|
+
// Front matter paths are relative to the page's language and version (#096).
|
|
125
|
+
const unit = pageUnitPrefix(page);
|
|
126
|
+
if (page.redirect) {
|
|
127
|
+
add({
|
|
128
|
+
from: here,
|
|
129
|
+
to: normalizeTarget(inPageUnit(page.redirect, unit, prefix), prefix),
|
|
130
|
+
status: 301,
|
|
131
|
+
origin: "frontmatter",
|
|
132
|
+
declaredBy: page.slug,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
const aliases = page.frontmatter?.aliases;
|
|
136
|
+
if (aliases !== undefined) {
|
|
137
|
+
if (!Array.isArray(aliases) || aliases.some((a) => typeof a !== "string")) {
|
|
138
|
+
errors.push(`aliases: on ${page.slug} must be a list of paths. ` +
|
|
139
|
+
`To fix: use a YAML list of strings.`);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
for (const alias of aliases) {
|
|
143
|
+
add({
|
|
144
|
+
from: normalizeTarget(inPageUnit(alias, unit, prefix), prefix),
|
|
145
|
+
to: here,
|
|
146
|
+
status: 301,
|
|
147
|
+
origin: "aliases",
|
|
148
|
+
declaredBy: page.slug,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// 2. Config, which wins over frontmatter for the same source.
|
|
155
|
+
for (const [from, value] of Object.entries(config ?? {})) {
|
|
156
|
+
const to = typeof value === "string" ? value : value.to;
|
|
157
|
+
const status = typeof value === "string" ? 301 : (value.status ?? 301);
|
|
158
|
+
if (typeof to !== "string" || !to.trim()) {
|
|
159
|
+
errors.push(`redirects: entry "${from}" has no target. To fix: give it a path or URL.`);
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
if (!VALID_STATUS.has(status)) {
|
|
163
|
+
errors.push(`redirects: entry "${from}" has status ${status}. ` +
|
|
164
|
+
`To fix: use one of ${[...VALID_STATUS].join(", ")}.`);
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
add({
|
|
168
|
+
from: normalizeTarget(from, prefix),
|
|
169
|
+
to: normalizeTarget(to, prefix),
|
|
170
|
+
status,
|
|
171
|
+
origin: "config",
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
const resolved = resolveRedirects(candidates, {
|
|
175
|
+
strict: true,
|
|
176
|
+
// A target's "#anchor" or "?query" is not part of the page it names.
|
|
177
|
+
isPage: (path) => livePaths.has(path.split(/[?#]/)[0]),
|
|
178
|
+
cloudflareLimits: true,
|
|
179
|
+
});
|
|
180
|
+
return {
|
|
181
|
+
rules: resolved.rules,
|
|
182
|
+
errors: [...errors, ...resolved.errors],
|
|
183
|
+
warnings: [...warnings, ...resolved.warnings],
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/** The `_redirects` file Workers Static Assets reads from the assets root. */
|
|
187
|
+
export function renderRedirectsFile(rules) {
|
|
188
|
+
return renderRedirectsLines(rules);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* A static stub for hosts with no redirect mechanism (GitHub Pages, plain
|
|
192
|
+
* static hosting). This is a genuine downgrade and is reported as one: the
|
|
193
|
+
* response is 200, and the redirect is a hint rather than a status code.
|
|
194
|
+
* `noindex` plus a canonical keeps crawlers pointed at the real page.
|
|
195
|
+
*/
|
|
196
|
+
export function renderMetaRefreshPage(rule, siteUrl) {
|
|
197
|
+
const canonical = siteUrl && !isExternal(rule.to)
|
|
198
|
+
? `${siteUrl.replace(/\/+$/, "")}${rule.to}`
|
|
199
|
+
: isExternal(rule.to)
|
|
200
|
+
? rule.to
|
|
201
|
+
: undefined;
|
|
202
|
+
return renderRedirectStub(rule.to, canonical);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Where a stub page goes inside `public/`, relative to it. The served path
|
|
206
|
+
* already carries the mount prefix, but `public/` is copied into the mount
|
|
207
|
+
* directory, so the prefix is stripped back off here — otherwise the stub
|
|
208
|
+
* lands at `<mount>/<mount>/old/`.
|
|
209
|
+
*/
|
|
210
|
+
export function stubPathForRule(rule, prefix) {
|
|
211
|
+
const base = prefix.replace(/\/+$/, "");
|
|
212
|
+
let p = rule.from;
|
|
213
|
+
if (base && p.startsWith(base))
|
|
214
|
+
p = p.slice(base.length);
|
|
215
|
+
p = p.replace(/^\/+|\/+$/g, "");
|
|
216
|
+
// The stub is written at this path under public/. resolveRedirects refuses
|
|
217
|
+
// such a source already; this is the last line before a file write, so a
|
|
218
|
+
// `..` that reached it some other way cannot leave the site.
|
|
219
|
+
if (p.split("/").some((seg) => seg === ".." || seg === ".") || /[\\\u0000]/.test(p)) {
|
|
220
|
+
throw new Error(`redirect source ${JSON.stringify(rule.from)} would write outside the site`);
|
|
221
|
+
}
|
|
222
|
+
return p ? `${p}/index.html` : "index.html";
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=redirects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirects.js","sourceRoot":"","sources":["../src/redirects.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,mBAAmB,IAAI,oBAAoB,EAC3C,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAuC7B,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAExD,MAAM,UAAU,GAAG,aAAa,CAAC;AAEjC;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,MAAc;IAC3D,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;IACzE,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACxC,IAAI,CAAC,KAAK;QAAE,OAAO,GAAG,IAAI,GAAG,C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,EAAE,EAAE,CAAC,CAAC;IAChC,2EAA2E;IAC3E,yEAAyE;IACzE,6DAA6D;IAC7D,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,GAAG,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACpF,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;IAC/F,CAAC;IACD,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC;AAC9C,CAAC"}
|
package/dist/serialize.d.ts
CHANGED
|
@@ -19,11 +19,25 @@ export interface AstroGenOptions {
|
|
|
19
19
|
imageOptimization?: boolean;
|
|
20
20
|
/** Controls CodeBlock title bar: true = always (default), "auto" = only with explicit title */
|
|
21
21
|
codeBlockTitle?: boolean | "auto";
|
|
22
|
+
/** A paragraph that is one titled image renders as a captioned figure (`content.imageCaptions: title`). */
|
|
23
|
+
imageCaptions?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Combined URL prefix (urlBase + basePath). When non-empty, the
|
|
26
|
+
* caller is expected to have already pre-rewritten absolute image
|
|
27
|
+
* srcs in the tree to include this prefix; the serializer uses
|
|
28
|
+
* the prefix only to strip it back off for the imageMap lookup
|
|
29
|
+
* key (which is keyed off the unprefixed publicPath built via
|
|
30
|
+
* `import.meta.glob` at runtime).
|
|
31
|
+
*/
|
|
32
|
+
combinedPrefix?: string;
|
|
22
33
|
}
|
|
34
|
+
import { TONE_CLASSES } from "./tone-classes.js";
|
|
35
|
+
export { TONE_CLASSES };
|
|
23
36
|
/** Escape for use inside an Astro {expression}. Uses JSON.stringify for safety. */
|
|
24
37
|
export declare function escapeExpr(s: string): string;
|
|
25
38
|
/** Escape for use in an HTML attribute value (double-quoted). */
|
|
26
39
|
export declare function escapeAttr(s: string): string;
|
|
40
|
+
export declare function componentAttr(name: string, value: string): string;
|
|
27
41
|
/** Escape text for use directly in an Astro template (not inside an expression). */
|
|
28
42
|
export declare function escapeTemplate(s: string): string;
|
|
29
43
|
export declare function treeToAstro(nodes: TreeNode[], options?: AstroGenOptions): AstroGenResult;
|
package/dist/serialize.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../src/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../src/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA2B,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAcxE;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,QAAQ,CAAC;AAiCpD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,+FAA+F;IAC/F,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAClC,2GAA2G;IAC3G,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,CAAC;AA8FxB,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAU5C;AAED,iEAAiE;AACjE,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE5C;AA0CD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAIjE;AA6BD,oFAAoF;AACpF,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAahD;AAID,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,cAAc,CAgDxF"}
|