@allyhub/sdk 0.0.0-stage → 0.1.0-alpha.5
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/LICENSE +241 -0
- package/NOTICE +81 -0
- package/README.md +16 -2
- package/client.d.ts +86 -0
- package/dist/anim.d.ts +41 -0
- package/dist/anim.d.ts.map +1 -0
- package/dist/anim.js +75 -0
- package/dist/anim.js.map +1 -0
- package/dist/define.d.ts +75 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +95 -0
- package/dist/define.js.map +1 -0
- package/dist/dom.d.ts +210 -0
- package/dist/dom.d.ts.map +1 -0
- package/dist/dom.js +457 -0
- package/dist/dom.js.map +1 -0
- package/dist/fit.d.ts +24 -0
- package/dist/fit.d.ts.map +1 -0
- package/dist/fit.js +60 -0
- package/dist/fit.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/media.d.ts +9 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +27 -0
- package/dist/media.js.map +1 -0
- package/dist/messages.d.ts +39 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +2 -0
- package/dist/messages.js.map +1 -0
- package/dist/noise.d.ts +15 -0
- package/dist/noise.d.ts.map +1 -0
- package/dist/noise.js +233 -0
- package/dist/noise.js.map +1 -0
- package/dist/parts.d.ts +140 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +414 -0
- package/dist/parts.js.map +1 -0
- package/dist/paths.d.ts +85 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +720 -0
- package/dist/paths.js.map +1 -0
- package/dist/piece.d.ts +64 -0
- package/dist/piece.d.ts.map +1 -0
- package/dist/piece.js +38 -0
- package/dist/piece.js.map +1 -0
- package/dist/props.d.ts +81 -0
- package/dist/props.d.ts.map +1 -0
- package/dist/props.js +35 -0
- package/dist/props.js.map +1 -0
- package/dist/text.d.ts +13 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +38 -0
- package/dist/text.js.map +1 -0
- package/package.json +61 -3
package/dist/define.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { LAYER_BRAND, } from "@allyhub/engine/stage";
|
|
2
|
+
/**
|
|
3
|
+
* Layer options share one object with a component's props, so these names
|
|
4
|
+
* are reserved: a component cannot have props called this.
|
|
5
|
+
*/
|
|
6
|
+
export const LAYER_OPTIONS = ["at", "until", "dur", "z"];
|
|
7
|
+
/** Where props hold times, from their schema; undefined when none do. */
|
|
8
|
+
export function timeShape(props) {
|
|
9
|
+
const of = (s) => {
|
|
10
|
+
if (s.type === "time")
|
|
11
|
+
return true;
|
|
12
|
+
if (s.type === "list")
|
|
13
|
+
return of(s.of);
|
|
14
|
+
if (s.type === "object")
|
|
15
|
+
return timeShape(s.fields);
|
|
16
|
+
return undefined;
|
|
17
|
+
};
|
|
18
|
+
const out = {};
|
|
19
|
+
for (const [k, s] of Object.entries(props)) {
|
|
20
|
+
const shape = s ? of(s) : undefined;
|
|
21
|
+
if (shape !== undefined)
|
|
22
|
+
out[k] = shape;
|
|
23
|
+
}
|
|
24
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
25
|
+
}
|
|
26
|
+
/** The layer options of an options object, and the rest. */
|
|
27
|
+
function splitLayer(opts) {
|
|
28
|
+
const { at, until, dur, z, ...rest } = opts;
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
...(at === undefined ? {} : { at }),
|
|
32
|
+
...(until === undefined ? {} : { until }),
|
|
33
|
+
...(dur === undefined ? {} : { dur }),
|
|
34
|
+
...(z === undefined ? {} : { z }),
|
|
35
|
+
},
|
|
36
|
+
rest,
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
/** Makes a component: a function that returns a graphic layer. */
|
|
40
|
+
export function defineComponent(def) {
|
|
41
|
+
const names = [
|
|
42
|
+
...Object.keys(def.props ?? {}),
|
|
43
|
+
...Object.keys(def.defaults ?? {}),
|
|
44
|
+
...Object.values(def.examples ?? {}).flatMap((e) => Object.keys(e)),
|
|
45
|
+
];
|
|
46
|
+
const clash = [...new Set(names.filter((k) => LAYER_OPTIONS.includes(k)))];
|
|
47
|
+
if (clash.length > 0) {
|
|
48
|
+
throw new Error(`${def.name}: ${clash.join(", ")} is a layer option, not a prop name`);
|
|
49
|
+
}
|
|
50
|
+
const times = timeShape(def.props ?? {});
|
|
51
|
+
const make = (opts) => {
|
|
52
|
+
const [layer, rest] = splitLayer(opts);
|
|
53
|
+
// Word references in time() props are seconds by the time mount runs.
|
|
54
|
+
const props = { ...def.defaults, ...rest };
|
|
55
|
+
return {
|
|
56
|
+
[LAYER_BRAND]: "graphic",
|
|
57
|
+
...layer,
|
|
58
|
+
component: def.name,
|
|
59
|
+
props,
|
|
60
|
+
...(times ? { times } : {}),
|
|
61
|
+
mount: (el, p, ctx) => {
|
|
62
|
+
def.mount(el, p, ctx);
|
|
63
|
+
},
|
|
64
|
+
render: (el, t, p, ctx) => {
|
|
65
|
+
def.render(el, t, p, ctx);
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
const info = {
|
|
70
|
+
name: def.name,
|
|
71
|
+
label: def.label ?? def.name,
|
|
72
|
+
...(def.summary === undefined ? {} : { summary: def.summary }),
|
|
73
|
+
props: Object.fromEntries(Object.entries(def.props ?? {}).filter((e) => e[1] !== undefined)),
|
|
74
|
+
examples: def.examples ?? {},
|
|
75
|
+
hidden: def.hidden ?? false,
|
|
76
|
+
};
|
|
77
|
+
return Object.assign(make, { componentName: def.name, info });
|
|
78
|
+
}
|
|
79
|
+
/** A graphic layer written directly in the output, for what no component does. */
|
|
80
|
+
export function custom(opts) {
|
|
81
|
+
const [layer] = splitLayer(opts);
|
|
82
|
+
return {
|
|
83
|
+
[LAYER_BRAND]: "graphic",
|
|
84
|
+
...layer,
|
|
85
|
+
component: "custom",
|
|
86
|
+
props: {},
|
|
87
|
+
mount: (el, _props, ctx) => {
|
|
88
|
+
opts.mount?.(el, ctx);
|
|
89
|
+
},
|
|
90
|
+
render: (el, t, _props, ctx) => {
|
|
91
|
+
opts.render(el, t, ctx);
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=define.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GAKZ,MAAM,uBAAuB,CAAC;AAkE/B;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAsB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AAE5E,yEAAyE;AACzE,MAAM,UAAU,SAAS,CACvB,KAAuD;IAEvD,MAAM,EAAE,GAAG,CAAC,CAAa,EAAgC,EAAE;QACzD,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM;YAAE,OAAO,IAAI,CAAC;QACnC,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM;YAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACvC,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACpD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IACF,MAAM,GAAG,GAAc,EAAE,CAAC;IAC1B,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3C,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACpC,IAAI,KAAK,KAAK,SAAS;YAAE,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IAC1C,CAAC;IACD,OAAO,MAAM,CAAC,I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, type StageContext } from "@allyhub/engine/stage";
|
|
2
|
+
/** Inline styles: camelCase or `--custom` properties; numbers are pixels. */
|
|
3
|
+
export type Style = Partial<Record<string, string | number>>;
|
|
4
|
+
export declare function h(tag: string, style?: Style, children?: (Node | string)[], cls?: string): HTMLElement;
|
|
5
|
+
export declare function css(el: HTMLElement | SVGElement, style: Style): void;
|
|
6
|
+
/**
|
|
7
|
+
* Chinese has no spaces, so a line can break inside a word. Mark word
|
|
8
|
+
* boundaries (Intl.Segmenter, the browser's own dictionary) with zero-width
|
|
9
|
+
* spaces; with `word-break: keep-all` lines then break only between words.
|
|
10
|
+
*/
|
|
11
|
+
export declare function wordBreaks(value: string): string;
|
|
12
|
+
export declare const text: (v: unknown) => string;
|
|
13
|
+
export declare const list: (v: unknown) => string[];
|
|
14
|
+
export interface Layout {
|
|
15
|
+
W: number;
|
|
16
|
+
H: number;
|
|
17
|
+
/** Type scale: the frame's short side / 1080 (1 in every preset and platform profile). */
|
|
18
|
+
k: number;
|
|
19
|
+
orient: "landscape" | "portrait" | "square";
|
|
20
|
+
/** The side margin: max(margin, the covered left and right edges). */
|
|
21
|
+
pad: number;
|
|
22
|
+
/** The content box's edges, in the frame's pixels: clear of the covered areas, with a gap. */
|
|
23
|
+
top: number;
|
|
24
|
+
bottom: number;
|
|
25
|
+
left: number;
|
|
26
|
+
right: number;
|
|
27
|
+
}
|
|
28
|
+
/** What layout() may change: the margin and the gaps by the covered edges (see contentEdges). */
|
|
29
|
+
export type LayoutOptions = ContentOptions;
|
|
30
|
+
/**
|
|
31
|
+
* Layout of the stage for the current format: the type scale and the
|
|
32
|
+
* content box (the same box as ctx.content). With the defaults, in
|
|
33
|
+
* pixels: pad = max(margin, safe.left, safe.right), with margin 120 × k
|
|
34
|
+
* in a landscape frame and 84 × k otherwise; top = max(pad, safe.top +
|
|
35
|
+
* 30 × k); bottom = H − max(pad, safe.bottom + 20 × k); left = pad;
|
|
36
|
+
* right = W − pad. `opts` changes the margin and the gaps.
|
|
37
|
+
*/
|
|
38
|
+
export declare function layout(ctx: StageContext, opts?: LayoutOptions): Layout;
|
|
39
|
+
/** A full-stage absolutely positioned box over the content area. */
|
|
40
|
+
export declare function contentBox(L: Layout, style?: Style): HTMLElement;
|
|
41
|
+
/** Text block that keeps its words together and wraps by width. */
|
|
42
|
+
export declare function textBlock(value: string, { size, weight, color, font, lineHeight, align, }: {
|
|
43
|
+
size: number;
|
|
44
|
+
weight?: number;
|
|
45
|
+
color?: string;
|
|
46
|
+
font?: string;
|
|
47
|
+
lineHeight?: number;
|
|
48
|
+
align?: "left" | "center" | "right";
|
|
49
|
+
}): HTMLElement;
|
|
50
|
+
/** How marked() draws each kind of mark, unless it is given another style. */
|
|
51
|
+
export declare const MARK_STYLES: Readonly<Record<InlineMark["kind"], Style>>;
|
|
52
|
+
/**
|
|
53
|
+
* A line with its marks drawn: a span holding the line's runs in order,
|
|
54
|
+
* a plain run as text and a marked one as a span with `data-mark` (its
|
|
55
|
+
* kinds, "strong", "strong em"…) and the style of each kind, `styles`
|
|
56
|
+
* over MARK_STYLES. A string is read with readMarks() (`**strong**`,
|
|
57
|
+
* `*em*`, `~~struck~~`, `` `code` ``); a text already read is taken with
|
|
58
|
+
* the marks it has. Put it in any block: textBlock("", { size }).append(…),
|
|
59
|
+
* h("div", style, [marked(line)]).
|
|
60
|
+
*/
|
|
61
|
+
export declare function marked(value: string | {
|
|
62
|
+
text: string;
|
|
63
|
+
marks?: readonly InlineMark[];
|
|
64
|
+
}, styles?: Partial<Record<InlineMark["kind"], Style>>): HTMLElement;
|
|
65
|
+
/** Children of el by data-ak attribute, in document order. */
|
|
66
|
+
export declare function all(el: HTMLElement, name: string): HTMLElement[];
|
|
67
|
+
export declare function one(el: HTMLElement, name: string): HTMLElement | null;
|
|
68
|
+
export declare function tag(el: HTMLElement, name: string): HTMLElement;
|
|
69
|
+
/**
|
|
70
|
+
* The largest font size in [min, max] at which el fits its width and is at
|
|
71
|
+
* most maxHeight tall. Layout depends only on the format and the text, so
|
|
72
|
+
* mount calls this once.
|
|
73
|
+
*/
|
|
74
|
+
export declare function fitTo(el: HTMLElement, { min, max, maxHeight }: {
|
|
75
|
+
min: number;
|
|
76
|
+
max: number;
|
|
77
|
+
maxHeight: number;
|
|
78
|
+
}): number;
|
|
79
|
+
/** What fitLines searches within, and the box the text must fit. */
|
|
80
|
+
export interface FitLinesOptions {
|
|
81
|
+
/** The most lines the text may take. */
|
|
82
|
+
lines: number;
|
|
83
|
+
/** Smallest font size in px. */
|
|
84
|
+
min: number;
|
|
85
|
+
/** Largest font size in px. */
|
|
86
|
+
max: number;
|
|
87
|
+
/** The box's width in px, set as the element's width. Default: the element's own width (required for a text). */
|
|
88
|
+
width?: number;
|
|
89
|
+
/** The box's height in px: the text is at most this tall too. Default: no limit. */
|
|
90
|
+
height?: number;
|
|
91
|
+
/** How close to the largest size the search gets, in px (default `FIT_LINES_PRECISION`, 0.5). */
|
|
92
|
+
precision?: number;
|
|
93
|
+
}
|
|
94
|
+
/** What fitLines found. */
|
|
95
|
+
export interface FitLines {
|
|
96
|
+
/** The font size, set on the element: the largest that fits, else `min`. */
|
|
97
|
+
size: number;
|
|
98
|
+
/** False when even `min` takes more lines, or is wider or taller than the box. */
|
|
99
|
+
fits: boolean;
|
|
100
|
+
/** The text of each line at that size, as the browser broke it (`textLines`). */
|
|
101
|
+
lines: string[];
|
|
102
|
+
}
|
|
103
|
+
export declare const FIT_LINES_PRECISION = 0.5;
|
|
104
|
+
/**
|
|
105
|
+
* The text of each line of el as the browser broke it, top to bottom:
|
|
106
|
+
* spaces collapsed, zero-width spaces (`wordBreaks`) left out. el must be
|
|
107
|
+
* in the page.
|
|
108
|
+
*/
|
|
109
|
+
export declare function textLines(el: HTMLElement): string[];
|
|
110
|
+
/**
|
|
111
|
+
* The largest font size in [min, max] at which the text takes at most
|
|
112
|
+
* `lines` lines and fits the box's width (no word sticks out) and, given
|
|
113
|
+
* `height`, its height, measured in the page. Pass an element in the page
|
|
114
|
+
* (its font size is set, and its width when `width` is given), or a text and
|
|
115
|
+
* the style it will be drawn with (measured in a hidden element, removed
|
|
116
|
+
* after; `width` is required): set the same style and the size found.
|
|
117
|
+
* Layout depends only on the format and the text, so call it in mount.
|
|
118
|
+
*/
|
|
119
|
+
export declare function fitLines(el: HTMLElement, opts: FitLinesOptions): FitLines;
|
|
120
|
+
export declare function fitLines(text: string, opts: FitLinesOptions & {
|
|
121
|
+
style?: Style;
|
|
122
|
+
}): FitLines;
|
|
123
|
+
type Box = readonly [x: number, y: number, w: number, h: number];
|
|
124
|
+
/** What freeAreas keeps clear of, and where it looks. */
|
|
125
|
+
export interface FreeAreaOptions {
|
|
126
|
+
/**
|
|
127
|
+
* The rectangle to look in, in the frame's pixels; default the content
|
|
128
|
+
* box of layout(ctx) (clear of the covered areas, with its margins).
|
|
129
|
+
*/
|
|
130
|
+
within?: Box;
|
|
131
|
+
/** Keep clear of every face at t (ctx.faces); default true. */
|
|
132
|
+
faces?: boolean;
|
|
133
|
+
/** Keep clear of the text of the layers listed before (ctx.texts); default true. */
|
|
134
|
+
texts?: boolean;
|
|
135
|
+
/** Keep clear of the covered areas (ctx.covered); default true. */
|
|
136
|
+
covered?: boolean;
|
|
137
|
+
/** Pixels kept around each thing avoided; default 24 × the type scale. */
|
|
138
|
+
margin?: number;
|
|
139
|
+
/** Leave out areas lower than this, pixels; default 0. */
|
|
140
|
+
minHeight?: number;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The empty areas of the frame at part time t: bands across `within`
|
|
144
|
+
* (the content box by default) where no face, other layer's text or
|
|
145
|
+
* covered area is, each `[x, y, w, h]` in the frame's pixels, tallest
|
|
146
|
+
* first. A measurement: use it, or not, as you place things. Draws the
|
|
147
|
+
* layers listed before this one, so call it in mount.
|
|
148
|
+
*/
|
|
149
|
+
export declare function freeAreas(ctx: StageContext, t: number, opts?: FreeAreaOptions): [number, number, number, number][];
|
|
150
|
+
/** A spot for a caption block's top: a place in the content box, or a y in pixels. */
|
|
151
|
+
export type CaptionSpot = "bottom" | "middle" | "top" | number;
|
|
152
|
+
/** What captionTop tries and keeps clear of. */
|
|
153
|
+
export interface CaptionTopOptions {
|
|
154
|
+
/** The spots to try, in order; default ["bottom", "top", "middle"]. */
|
|
155
|
+
prefer?: readonly CaptionSpot[];
|
|
156
|
+
/** Keep clear of faces (ctx.faces); default true. */
|
|
157
|
+
faces?: boolean;
|
|
158
|
+
/** Keep clear of the text of the layers listed before (ctx.texts); default true. */
|
|
159
|
+
texts?: boolean;
|
|
160
|
+
/** Pixels kept from a face; default 24 × the type scale. */
|
|
161
|
+
faceGap?: number;
|
|
162
|
+
/** Pixels kept from other text (often on a panel); default 48 × the type scale. */
|
|
163
|
+
textGap?: number;
|
|
164
|
+
/** Seconds between the moments of the cue it looks at; default 0.1. */
|
|
165
|
+
step?: number;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Where a caption block w × h pixels (centred across the frame) can go
|
|
169
|
+
* for one cue: the first spot in `prefer`, else just above or below
|
|
170
|
+
* another layer's text, clear of that text and of the faces over the
|
|
171
|
+
* whole cue; when none is clear of both, the least text covered, then
|
|
172
|
+
* the least face. Returns the block's top in pixels, inside the content
|
|
173
|
+
* box. A tool: call it in mount, once per cue, if you want a measured
|
|
174
|
+
* place; nothing places captions on its own.
|
|
175
|
+
*/
|
|
176
|
+
export declare function captionTop(ctx: StageContext, L: Layout, cue: Pick<CaptionTrackCue, "start" | "end">, w: number, h: number, opts?: CaptionTopOptions): number;
|
|
177
|
+
/**
|
|
178
|
+
* The look's background and text colours sorted into the lighter and the
|
|
179
|
+
* darker, as variables: text over footage can be light on a dark outline
|
|
180
|
+
* in any look. Measures the look, so call it in mount.
|
|
181
|
+
*/
|
|
182
|
+
export declare function lightDark(el: HTMLElement): {
|
|
183
|
+
light: string;
|
|
184
|
+
dark: string;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Words to stress, as you choose them: matched as said, case, accents
|
|
188
|
+
* and punctuation ignored, whole words; a phrase ("free trial") marks
|
|
189
|
+
* each of its words, and Chinese or Japanese may match inside a word.
|
|
190
|
+
*/
|
|
191
|
+
export type Emphasis = readonly string[];
|
|
192
|
+
/** The emoji a word brings, keyed like Emphasis. */
|
|
193
|
+
export type WordEmoji = Readonly<Record<string, string>>;
|
|
194
|
+
type CueWords = readonly CaptionTrackCue["words"][number][];
|
|
195
|
+
/** For each of a cue's words, whether `emphasis` names it. */
|
|
196
|
+
export declare function emphasized(words: CueWords, emphasis: Emphasis | undefined): boolean[];
|
|
197
|
+
/**
|
|
198
|
+
* For each of a cue's words, the emoji it brings ("" for none): a phrase's
|
|
199
|
+
* goes to its last word, and the first key that names a word wins.
|
|
200
|
+
*/
|
|
201
|
+
export declare function wordEmoji(words: CueWords, emoji: WordEmoji | undefined): string[];
|
|
202
|
+
/**
|
|
203
|
+
* An emoji to draw beside or above a word: in the look's emoji font
|
|
204
|
+
* (`var(--ak-font-emoji)`, colour emoji the stage has, the same on every
|
|
205
|
+
* computer), upright at regular weight, without the capitals or the
|
|
206
|
+
* outline of the line it sits in.
|
|
207
|
+
*/
|
|
208
|
+
export declare function emojiEl(value: string, style?: Style): HTMLElement;
|
|
209
|
+
export {};
|
|
210
|
+
//# sourceMappingURL=dom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAQ/B,6EAA6E;AAC7E,MAAM,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;AAE7D,wBAAgB,CAAC,CACf,GAAG,EAAE,MAAM,EACX,KAAK,GAAE,KAAU,EACjB,QAAQ,GAAE,CAAC,IAAI,GAAG,MAAM,CAA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