@atomic-ui/design-tokens 0.2.0 → 0.5.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.
- package/README.md +3 -3
- package/dist/{chunk-ZTASNIBX.js → chunk-UN6JX6X6.js} +9 -9
- package/dist/chunk-UN6JX6X6.js.map +1 -0
- package/dist/css.d.ts +2 -2
- package/dist/css.js +1 -1
- package/dist/index.js +1 -1
- package/dist/tailwind.d.ts +2 -2
- package/dist/tailwind.js +4 -4
- package/dist/tailwind.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-ZTASNIBX.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @atomic-ui/design-tokens
|
|
2
2
|
|
|
3
|
-
The tokens every
|
|
3
|
+
The tokens every Impakt component reads, and the derivation that produces them from
|
|
4
4
|
the handful of values a partner sets.
|
|
5
5
|
|
|
6
6
|
A brand authors around twenty **inputs**. Eighty-five **tokens** come out, and the
|
|
@@ -87,12 +87,12 @@ Margins and gutters name steps on the spacing scale, such as `'4'` or `'6'`, rat
|
|
|
87
87
|
pixels, so they follow `shape.spaceBase`. Each has a default, so a brand that sets none
|
|
88
88
|
of this looks as it did before.
|
|
89
89
|
|
|
90
|
-
`toStylesheet` emits them as `--
|
|
90
|
+
`toStylesheet` emits them as `--impakt-layout-*` tokens, plus an `impakt-page` class. An
|
|
91
91
|
app puts that class on the element its pages fill, and the content is then centred,
|
|
92
92
|
held to the page width, and given the brand's margin for each size of screen:
|
|
93
93
|
|
|
94
94
|
```tsx
|
|
95
|
-
<main className="
|
|
95
|
+
<main className="impakt-page"><RouterView … /></main>
|
|
96
96
|
```
|
|
97
97
|
|
|
98
98
|
## Commands
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// packages/design-tokens/src/css.ts
|
|
2
|
-
var PREFIX = "--
|
|
2
|
+
var PREFIX = "--impakt";
|
|
3
3
|
var cssVarName = (path) => `${PREFIX}-${path.replace(/\./g, "-")}`;
|
|
4
4
|
function toStyleProperties(tokens) {
|
|
5
5
|
const out = {};
|
|
@@ -10,25 +10,25 @@ function toCssDeclarations(tokens, indent = " ") {
|
|
|
10
10
|
return Object.entries(tokens).map(([path, value]) => `${indent}${cssVarName(path)}: ${value};`).join("\n");
|
|
11
11
|
}
|
|
12
12
|
var PAGE_FRAME = [
|
|
13
|
-
`.
|
|
13
|
+
`.impakt-page {
|
|
14
14
|
box-sizing: border-box;
|
|
15
15
|
inline-size: 100%;
|
|
16
|
-
max-inline-size: calc(${"var(--
|
|
16
|
+
max-inline-size: calc(${"var(--impakt-layout-page-width, 1200px)"} + 2 * ${"var(--impakt-layout-margin-desktop, 64px)"});
|
|
17
17
|
margin-inline: auto;
|
|
18
|
-
padding-inline: var(--
|
|
18
|
+
padding-inline: var(--impakt-layout-margin-phone, 16px);
|
|
19
19
|
}`,
|
|
20
20
|
`@media (min-width: 40rem) {
|
|
21
|
-
.
|
|
21
|
+
.impakt-page { padding-inline: var(--impakt-layout-margin-tablet, 32px); }
|
|
22
22
|
}`,
|
|
23
23
|
`@media (min-width: 64rem) {
|
|
24
|
-
.
|
|
24
|
+
.impakt-page { padding-inline: var(--impakt-layout-margin-desktop, 64px); }
|
|
25
25
|
}`,
|
|
26
26
|
// A node hidden on one size of screen (its `hideOn`), at the grid's phone breakpoint.
|
|
27
27
|
`@media (max-width: 40rem) {
|
|
28
|
-
[data-
|
|
28
|
+
[data-impakt-hide-on="phone"] { display: none !important; }
|
|
29
29
|
}`,
|
|
30
30
|
`@media (min-width: 40.0625rem) {
|
|
31
|
-
[data-
|
|
31
|
+
[data-impakt-hide-on="wide"] { display: none !important; }
|
|
32
32
|
}`
|
|
33
33
|
].join("\n");
|
|
34
34
|
function fontFaceCss(fonts) {
|
|
@@ -64,4 +64,4 @@ export {
|
|
|
64
64
|
toStylesheet,
|
|
65
65
|
escapeStyleText
|
|
66
66
|
};
|
|
67
|
-
//# sourceMappingURL=chunk-
|
|
67
|
+
//# sourceMappingURL=chunk-UN6JX6X6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/css.ts"],"sourcesContent":["/**\n * Tokens → CSS custom properties.\n *\n * One emitter, used by both paths. The house theme is written to a stylesheet\n * at build time and a partner's brand is emitted at runtime from a published\n * document, and if those were two pieces of code they would drift — quietly,\n * because nothing would compare them. The same reasoning as the delivery API's\n * export command, which issues a real request rather than re-implementing the\n * response.\n */\nimport type { TokenSet } from './derive';\nimport type { WebFont } from './inputs';\n\n/** The namespace. Every property this package emits starts with it. */\nexport const PREFIX = '--impakt';\n\n/** `color.text.on-brand` → `--impakt-color-text-on-brand`. */\nexport const cssVarName = (path: string): string => `${PREFIX}-${path.replace(/\\./g, '-')}`;\n\n/** Tokens as a style object, for a runtime `style={}` or `element.style`. */\nexport function toStyleProperties(tokens: TokenSet): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [path, value] of Object.entries(tokens)) out[cssVarName(path)] = value;\n return out;\n}\n\n/** Tokens as declarations, for a stylesheet or a `<style>` block. */\nexport function toCssDeclarations(tokens: TokenSet, indent = ' '): string {\n return Object.entries(tokens)\n .map(([path, value]) => `${indent}${cssVarName(path)}: ${value};`)\n .join('\\n');\n}\n\nexport interface StylesheetOptions {\n /** Defaults to `:root`. A preview frame or a brand switcher passes its own. */\n selector?: string;\n fonts?: WebFont[];\n}\n\n/**\n * A complete stylesheet: the faces the brand needs, then its properties.\n *\n * `@font-face` travels with the brand rather than being compiled into one\n * app's stylesheet, because a partner brings its own typeface and the shell\n * cannot know in advance what it is.\n */\n/**\n * The page frame a brand's layout describes, as a class an app puts on the\n * element its pages fill: the content no wider than the page width, centred,\n * with the brand's margin for each size of screen between it and the edge.\n * The breakpoints are the ones the grid stacks at.\n */\nexport const PAGE_FRAME = [\n `.impakt-page {\\n box-sizing: border-box;\\n inline-size: 100%;\\n max-inline-size: calc(${'var(--impakt-layout-page-width, 1200px)'} + 2 * ${'var(--impakt-layout-margin-desktop, 64px)'});\\n margin-inline: auto;\\n padding-inline: var(--impakt-layout-margin-phone, 16px);\\n}`,\n `@media (min-width: 40rem) {\\n .impakt-page { padding-inline: var(--impakt-layout-margin-tablet, 32px); }\\n}`,\n `@media (min-width: 64rem) {\\n .impakt-page { padding-inline: var(--impakt-layout-margin-desktop, 64px); }\\n}`,\n // A node hidden on one size of screen (its `hideOn`), at the grid's phone breakpoint.\n `@media (max-width: 40rem) {\\n [data-impakt-hide-on=\"phone\"] { display: none !important; }\\n}`,\n `@media (min-width: 40.0625rem) {\\n [data-impakt-hide-on=\"wide\"] { display: none !important; }\\n}`,\n].join('\\n');\n\n/** The `@font-face` rules for a brand's font files. */\nexport function fontFaceCss(fonts: readonly WebFont[]): string {\n return fonts.filter((f) => f.url).map((f) => {\n const lines = [\n ` font-family: ${JSON.stringify(f.family)};`,\n ` src: url(${JSON.stringify(f.url)}) format(\"${/\\.woff(\\?|#|$)/i.test(f.url) ? 'woff' : 'woff2'}\");`,\n ` font-display: ${f.display ?? 'swap'};`,\n ];\n if (f.weight) lines.push(` font-weight: ${f.weight};`);\n if (f.style) lines.push(` font-style: ${f.style};`);\n return `@font-face {\\n${lines.join('\\n')}\\n}`;\n }).join('\\n\\n');\n}\n\nexport function toStylesheet(tokens: TokenSet, options: StylesheetOptions = {}): string {\n const { selector = ':root', fonts = [] } = options;\n const faces = fontFaceCss(fonts);\n return [...(faces ? [faces] : []), `${selector} {\\n${toCssDeclarations(tokens)}\\n}`, PAGE_FRAME].join('\\n\\n') + '\\n';\n}\n\n/**\n * Escape a stylesheet for inline injection.\n *\n * A brand is authored content, and authored content reaches a `<style>` block\n * here. `</style>` inside a font family name would close the element and start\n * an injection; the font-family value is already JSON-quoted above, and this is\n * the second line of defence for whoever writes the third emitter.\n */\nexport const escapeStyleText = (css: string): string => css.replace(/<\\/(style)/gi, '<\\\\/$1');\n"],"mappings":";AAcO,IAAM,SAAS;AAGf,IAAM,aAAa,CAAC,SAAyB,GAAG,MAAM,IAAI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AQ,CAAC,EAAE,IAAI;AAC3C,QAAM,QAAQ,YAAY,KAAK;AAC/B,SAAO,CAAC,GAAI,QAAQ,CAAC,KAAK,IAAI,CAAC,GAAI,GAAG,QAAQ;AAAA,EAAO,kBAAkB,MAAM,CAAC;AAAA,IAAO,UAAU,EAAE,KAAK,MAAM,IAAI;AAClH;AAUO,IAAM,kBAAkB,CAAC,QAAwB,IAAI,QAAQ,gBAAgB,QAAQ;","names":[]}
|
package/dist/css.d.ts
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
import type { TokenSet } from './derive';
|
|
12
12
|
import type { WebFont } from './inputs';
|
|
13
13
|
/** The namespace. Every property this package emits starts with it. */
|
|
14
|
-
export declare const PREFIX = "--
|
|
15
|
-
/** `color.text.on-brand` → `--
|
|
14
|
+
export declare const PREFIX = "--impakt";
|
|
15
|
+
/** `color.text.on-brand` → `--impakt-color-text-on-brand`. */
|
|
16
16
|
export declare const cssVarName: (path: string) => string;
|
|
17
17
|
/** Tokens as a style object, for a runtime `style={}` or `element.style`. */
|
|
18
18
|
export declare function toStyleProperties(tokens: TokenSet): Record<string, string>;
|
package/dist/css.js
CHANGED
package/dist/index.js
CHANGED
package/dist/tailwind.d.ts
CHANGED
package/dist/tailwind.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
cssVarName
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UN6JX6X6.js";
|
|
4
4
|
|
|
5
5
|
// packages/design-tokens/src/tailwind.ts
|
|
6
6
|
var v = (path, fallback) => fallback ? `var(${cssVarName(path)}, ${fallback})` : `var(${cssVarName(path)})`;
|
|
7
|
-
var
|
|
7
|
+
var impaktPreset = {
|
|
8
8
|
theme: {
|
|
9
9
|
extend: {
|
|
10
10
|
colors: {
|
|
@@ -61,9 +61,9 @@ var impktPreset = {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
-
var tailwind_default =
|
|
64
|
+
var tailwind_default = impaktPreset;
|
|
65
65
|
export {
|
|
66
66
|
tailwind_default as default,
|
|
67
|
-
|
|
67
|
+
impaktPreset
|
|
68
68
|
};
|
|
69
69
|
//# sourceMappingURL=tailwind.js.map
|
package/dist/tailwind.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tailwind.ts"],"sourcesContent":["/**\n * A Tailwind preset pointing at the custom properties.\n *\n * It maps Tailwind's scales onto `var(--
|
|
1
|
+
{"version":3,"sources":["../src/tailwind.ts"],"sourcesContent":["/**\n * A Tailwind preset pointing at the custom properties.\n *\n * It maps Tailwind's scales onto `var(--impakt-*)` rather than onto values, so a\n * shell that still uses Tailwind picks up a brand change at runtime like\n * everything else. Shipping resolved values here would bake one brand into the\n * build and quietly reintroduce the per-brand stylesheet this is meant to\n * remove.\n *\n * Typed loosely on purpose: the package does not depend on Tailwind, and a\n * preset is a plain object.\n */\nimport { cssVarName } from './css';\n\nconst v = (path: string, fallback?: string): string =>\n fallback ? `var(${cssVarName(path)}, ${fallback})` : `var(${cssVarName(path)})`;\n\nexport const impaktPreset = {\n theme: {\n extend: {\n colors: {\n brand: {\n DEFAULT: v('color.brand.default'),\n hover: v('color.brand.hover'),\n active: v('color.brand.active'),\n subtle: v('color.brand.subtle'),\n on: v('color.brand.on'),\n },\n accent: { DEFAULT: v('color.accent.default'), on: v('color.accent.on') },\n surface: {\n page: v('color.surface.page'),\n card: v('color.surface.card'),\n header: v('color.surface.header'),\n footer: v('color.surface.footer'),\n subtle: v('color.surface.subtle'),\n inset: v('color.surface.inset'),\n },\n content: {\n DEFAULT: v('color.text.default'),\n muted: v('color.text.muted'),\n placeholder: v('color.text.placeholder'),\n heading: v('color.text.heading'),\n link: v('color.text.link'),\n },\n line: { DEFAULT: v('color.border.default'), strong: v('color.border.strong') },\n danger: v('color.status.danger.default'),\n warning: v('color.status.warning.default'),\n success: v('color.status.success.default'),\n info: v('color.status.info.default'),\n },\n fontFamily: {\n sans: v('font.family.body'),\n heading: v('font.family.heading'),\n },\n fontSize: Object.fromEntries(\n ['2xs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl'].map((s) => [s, v(`font.size.${s}`)]),\n ),\n borderRadius: {\n none: v('radius.none'),\n sm: v('radius.sm'),\n DEFAULT: v('radius.md'),\n lg: v('radius.lg'),\n xl: v('radius.xl'),\n full: v('radius.full'),\n },\n spacing: Object.fromEntries(\n Array.from({ length: 11 }, (_, i) => [String(i), v(`space.${i}`)]),\n ),\n minWidth: { target: v('target.min') },\n minHeight: { target: v('target.min') },\n boxShadow: { focus: v('focus.ring.shadow') },\n },\n },\n};\n\nexport default impaktPreset;\n"],"mappings":";;;;;AAcA,IAAM,IAAI,CAAC,MAAc,aACvB,WAAW,OAAO,WAAW,IAAI,CAAC,KAAK,QAAQ,MAAM,OAAO,WAAW,IAAI,CAAC;AAEvE,IAAM,eAAe;AAAA,EAC1B,OAAO;AAAA,IACL,QAAQ;AAAA,MACN,QAAQ;AAAA,QACN,OAAO;AAAA,UACL,SAAS,EAAE,qBAAqB;AAAA,UAChC,OAAO,EAAE,mBAAmB;AAAA,UAC5B,QAAQ,EAAE,oBAAoB;AAAA,UAC9B,QAAQ,EAAE,oBAAoB;AAAA,UAC9B,IAAI,EAAE,gBAAgB;AAAA,QACxB;AAAA,QACA,QAAQ,EAAE,SAAS,EAAE,sBAAsB,GAAG,IAAI,EAAE,iBAAiB,EAAE;AAAA,QACvE,SAAS;AAAA,UACP,MAAM,EAAE,oBAAoB;AAAA,UAC5B,MAAM,EAAE,oBAAoB;AAAA,UAC5B,QAAQ,EAAE,sBAAsB;AAAA,UAChC,QAAQ,EAAE,sBAAsB;AAAA,UAChC,QAAQ,EAAE,sBAAsB;AAAA,UAChC,OAAO,EAAE,qBAAqB;AAAA,QAChC;AAAA,QACA,SAAS;AAAA,UACP,SAAS,EAAE,oBAAoB;AAAA,UAC/B,OAAO,EAAE,kBAAkB;AAAA,UAC3B,aAAa,EAAE,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/design-tokens",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The design tokens every
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "The design tokens every Impakt component reads, and the derivation that turns a partner's handful of brand inputs into the whole set.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/matthill8286/impkt-design-system.git",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/css.ts"],"sourcesContent":["/**\n * Tokens → CSS custom properties.\n *\n * One emitter, used by both paths. The house theme is written to a stylesheet\n * at build time and a partner's brand is emitted at runtime from a published\n * document, and if those were two pieces of code they would drift — quietly,\n * because nothing would compare them. The same reasoning as the delivery API's\n * export command, which issues a real request rather than re-implementing the\n * response.\n */\nimport type { TokenSet } from './derive';\nimport type { WebFont } from './inputs';\n\n/** The namespace. Every property this package emits starts with it. */\nexport const PREFIX = '--impkt';\n\n/** `color.text.on-brand` → `--impkt-color-text-on-brand`. */\nexport const cssVarName = (path: string): string => `${PREFIX}-${path.replace(/\\./g, '-')}`;\n\n/** Tokens as a style object, for a runtime `style={}` or `element.style`. */\nexport function toStyleProperties(tokens: TokenSet): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [path, value] of Object.entries(tokens)) out[cssVarName(path)] = value;\n return out;\n}\n\n/** Tokens as declarations, for a stylesheet or a `<style>` block. */\nexport function toCssDeclarations(tokens: TokenSet, indent = ' '): string {\n return Object.entries(tokens)\n .map(([path, value]) => `${indent}${cssVarName(path)}: ${value};`)\n .join('\\n');\n}\n\nexport interface StylesheetOptions {\n /** Defaults to `:root`. A preview frame or a brand switcher passes its own. */\n selector?: string;\n fonts?: WebFont[];\n}\n\n/**\n * A complete stylesheet: the faces the brand needs, then its properties.\n *\n * `@font-face` travels with the brand rather than being compiled into one\n * app's stylesheet, because a partner brings its own typeface and the shell\n * cannot know in advance what it is.\n */\n/**\n * The page frame a brand's layout describes, as a class an app puts on the\n * element its pages fill: the content no wider than the page width, centred,\n * with the brand's margin for each size of screen between it and the edge.\n * The breakpoints are the ones the grid stacks at.\n */\nexport const PAGE_FRAME = [\n `.impkt-page {\\n box-sizing: border-box;\\n inline-size: 100%;\\n max-inline-size: calc(${'var(--impkt-layout-page-width, 1200px)'} + 2 * ${'var(--impkt-layout-margin-desktop, 64px)'});\\n margin-inline: auto;\\n padding-inline: var(--impkt-layout-margin-phone, 16px);\\n}`,\n `@media (min-width: 40rem) {\\n .impkt-page { padding-inline: var(--impkt-layout-margin-tablet, 32px); }\\n}`,\n `@media (min-width: 64rem) {\\n .impkt-page { padding-inline: var(--impkt-layout-margin-desktop, 64px); }\\n}`,\n // A node hidden on one size of screen (its `hideOn`), at the grid's phone breakpoint.\n `@media (max-width: 40rem) {\\n [data-impkt-hide-on=\"phone\"] { display: none !important; }\\n}`,\n `@media (min-width: 40.0625rem) {\\n [data-impkt-hide-on=\"wide\"] { display: none !important; }\\n}`,\n].join('\\n');\n\n/** The `@font-face` rules for a brand's font files. */\nexport function fontFaceCss(fonts: readonly WebFont[]): string {\n return fonts.filter((f) => f.url).map((f) => {\n const lines = [\n ` font-family: ${JSON.stringify(f.family)};`,\n ` src: url(${JSON.stringify(f.url)}) format(\"${/\\.woff(\\?|#|$)/i.test(f.url) ? 'woff' : 'woff2'}\");`,\n ` font-display: ${f.display ?? 'swap'};`,\n ];\n if (f.weight) lines.push(` font-weight: ${f.weight};`);\n if (f.style) lines.push(` font-style: ${f.style};`);\n return `@font-face {\\n${lines.join('\\n')}\\n}`;\n }).join('\\n\\n');\n}\n\nexport function toStylesheet(tokens: TokenSet, options: StylesheetOptions = {}): string {\n const { selector = ':root', fonts = [] } = options;\n const faces = fontFaceCss(fonts);\n return [...(faces ? [faces] : []), `${selector} {\\n${toCssDeclarations(tokens)}\\n}`, PAGE_FRAME].join('\\n\\n') + '\\n';\n}\n\n/**\n * Escape a stylesheet for inline injection.\n *\n * A brand is authored content, and authored content reaches a `<style>` block\n * here. `</style>` inside a font family name would close the element and start\n * an injection; the font-family value is already JSON-quoted above, and this is\n * the second line of defence for whoever writes the third emitter.\n */\nexport const escapeStyleText = (css: string): string => css.replace(/<\\/(style)/gi, '<\\\\/$1');\n"],"mappings":";AAcO,IAAM,SAAS;AAGf,IAAM,aAAa,CAAC,SAAyB,GAAG,MAAM,IAAI,KAAK,QAAQ,OAAO,GAAG,CAAC;AAGlF,SAAS,kBAAkB,QAA0C;AAC1E,QAAM,MAA8B,CAAC;AACrC,aAAW,CAAC,MAAM,KAAK,KAAK,OAAO,QAAQ,MAAM,EAAG,KAAI,WAAW,IAAI,CAAC,IAAI;AAC5E,SAAO;AACT;AAGO,SAAS,kBAAkB,QAAkB,SAAS,MAAc;AACzE,SAAO,OAAO,QAAQ,MAAM,EACzB,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,GAAG,MAAM,GAAG,WAAW,IAAI,CAAC,KAAK,KAAK,GAAG,EAChE,KAAK,IAAI;AACd;AAqBO,IAAM,aAAa;AAAA,EACxB;AAAA;AAAA;AAAA,0BAA2F,wCAAwC,UAAU,0CAA0C;AAAA;AAAA;AAAA;AAAA,EACvL;AAAA;AAAA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAEA;AAAA;AAAA;AAAA,EACA;AAAA;AAAA;AACF,EAAE,KAAK,IAAI;AAGJ,SAAS,YAAY,OAAmC;AAC7D,SAAO,MAAM,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,MAAM;AAC3C,UAAM,QAAQ;AAAA,MACZ,kBAAkB,KAAK,UAAU,EAAE,MAAM,CAAC;AAAA,MAC1C,cAAc,KAAK,UAAU,EAAE,GAAG,CAAC,aAAa,kBAAkB,KAAK,EAAE,GAAG,IAAI,SAAS,OAAO;AAAA,MAChG,mBAAmB,EAAE,WAAW,MAAM;AAAA,IACxC;AACA,QAAI,EAAE,OAAQ,OAAM,KAAK,kBAAkB,EAAE,MAAM,GAAG;AACtD,QAAI,EAAE,MAAO,OAAM,KAAK,iBAA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