@chances-ai/tui 15.0.0 → 17.0.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/dist/app.d.ts +1 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +54 -9
- package/dist/app.js.map +1 -1
- package/dist/code-view.js +1 -1
- package/dist/code-view.js.map +1 -1
- package/dist/diff-view.js +1 -1
- package/dist/diff-view.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/select-multi.d.ts +36 -0
- package/dist/select-multi.d.ts.map +1 -0
- package/dist/select-multi.js +104 -0
- package/dist/select-multi.js.map +1 -0
- package/dist/select.d.ts +5 -1
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +14 -6
- package/dist/select.js.map +1 -1
- package/dist/theme.d.ts +15 -101
- package/dist/theme.d.ts.map +1 -1
- package/dist/theme.js +18 -109
- package/dist/theme.js.map +1 -1
- package/dist/tool-message.js +1 -1
- package/dist/tool-message.js.map +1 -1
- package/dist/user-question.d.ts +26 -0
- package/dist/user-question.d.ts.map +1 -0
- package/dist/user-question.js +140 -0
- package/dist/user-question.js.map +1 -0
- package/package.json +7 -6
- package/dist/diff-model.d.ts +0 -64
- package/dist/diff-model.d.ts.map +0 -1
- package/dist/diff-model.js +0 -156
- package/dist/diff-model.js.map +0 -1
- package/dist/frame-scheduler.d.ts +0 -44
- package/dist/frame-scheduler.d.ts.map +0 -1
- package/dist/frame-scheduler.js +0 -58
- package/dist/frame-scheduler.js.map +0 -1
- package/dist/highlight-to-segments.d.ts +0 -18
- package/dist/highlight-to-segments.d.ts.map +0 -1
- package/dist/highlight-to-segments.js +0 -224
- package/dist/highlight-to-segments.js.map +0 -1
- package/dist/tool-line.d.ts +0 -33
- package/dist/tool-line.d.ts.map +0 -1
- package/dist/tool-line.js +0 -168
- package/dist/tool-line.js.map +0 -1
- package/dist/view-model.d.ts +0 -219
- package/dist/view-model.d.ts.map +0 -1
- package/dist/view-model.js +0 -460
- package/dist/view-model.js.map +0 -1
package/dist/theme.d.ts
CHANGED
|
@@ -1,106 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* `theme
|
|
7
|
-
*
|
|
8
|
-
* Colors are emitted as Ink-compatible `rgb(r,g,b)` strings; Ink renders them
|
|
9
|
-
* through chalk, which downsamples truecolor → 256/16 by the terminal's
|
|
10
|
-
* detected level. We therefore keep ONE truecolor palette per mode and let
|
|
11
|
-
* chalk degrade — there is no hand-rolled 16-ANSI fallback table (5.9 §0).
|
|
12
|
-
*
|
|
13
|
-
* `NO_COLOR` (https://no-color.org) is honored explicitly here because chalk
|
|
14
|
-
* 5 / Ink 7 only read the `--no-color` *flag*, not the env var (codex R1
|
|
15
|
-
* MUST-2): when set, `resolveTheme` returns a palette whose every color is
|
|
16
|
-
* `undefined`, so components emit no `color`/`backgroundColor` and meaning is
|
|
17
|
-
* carried by glyphs + sigils alone (the diff `+`/`-`, the `⏺`/`⎿` shapes).
|
|
18
|
-
*
|
|
19
|
-
* Dark RGB values are the facts of claude-code's `darkTheme` visual language
|
|
20
|
-
* (verified `~/Projects/github/claude-code/src/utils/theme.ts`); light values
|
|
21
|
-
* track its `lightTheme`. Syntax colors are an OneDark-ish set legible on the
|
|
22
|
-
* respective background.
|
|
2
|
+
* (v17 M0) TUI theme shim. The pure visual-language tokens + functions now live
|
|
3
|
+
* in `@chances-ai/ui-core` (browser-safe — no `node:*`, no `process.*`). This
|
|
4
|
+
* module re-exports them and adds the TUI's Node-bound conveniences: the
|
|
5
|
+
* `process.env`-defaulting `isNoColor` / `resolveTheme`, and the
|
|
6
|
+
* `process.platform`-derived `GLYPHS` constant. Keeping the same `./theme.js`
|
|
7
|
+
* specifier means every TUI component import is unchanged.
|
|
23
8
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/** Errors (dot, message body). */
|
|
32
|
-
error?: string;
|
|
33
|
-
/** Amber warnings. */
|
|
34
|
-
warning?: string;
|
|
35
|
-
/** Permission dialog rule + title. */
|
|
36
|
-
permission?: string;
|
|
37
|
-
/** Plan-mode badge. */
|
|
38
|
-
planMode?: string;
|
|
39
|
-
/** auto-edit / yolo badge (violet). */
|
|
40
|
-
autoAccept?: string;
|
|
41
|
-
/** Bash tool accent (pink). */
|
|
42
|
-
bashPink?: string;
|
|
43
|
-
/** Full-line diff backgrounds. */
|
|
44
|
-
diffAddedBg?: string;
|
|
45
|
-
diffRemovedBg?: string;
|
|
46
|
-
/** Word-level (intra-line) diff backgrounds — brighter than the line bg. */
|
|
47
|
-
diffAddedWordBg?: string;
|
|
48
|
-
diffRemovedWordBg?: string;
|
|
49
|
-
/** User-message bubble background. */
|
|
50
|
-
userMessageBg?: string;
|
|
51
|
-
/** Stalled-spinner red (interpolation target when no token for ~3s). */
|
|
52
|
-
stall?: string;
|
|
53
|
-
synKeyword?: string;
|
|
54
|
-
synString?: string;
|
|
55
|
-
synComment?: string;
|
|
56
|
-
synNumber?: string;
|
|
57
|
-
synFunction?: string;
|
|
58
|
-
synType?: string;
|
|
59
|
-
synLiteral?: string;
|
|
60
|
-
synTitle?: string;
|
|
61
|
-
synAttr?: string;
|
|
62
|
-
}
|
|
63
|
-
/** Theme selection as it arrives from config. `'auto'` resolves to `'dark'` in
|
|
64
|
-
* v14 (terminal-background detection is a later lever). */
|
|
65
|
-
export type ThemeSetting = "dark" | "light" | "auto";
|
|
66
|
-
/** `NO_COLOR` (https://no-color.org): present and NON-EMPTY ⇒ disable color,
|
|
67
|
-
* regardless of value. An empty string does NOT disable (per the spec). */
|
|
9
|
+
import { type Glyphs, type Theme, type ThemeSetting } from "@chances-ai/ui-core";
|
|
10
|
+
export type { Theme, ThemeSetting, Glyphs, NoColorEnv } from "@chances-ai/ui-core";
|
|
11
|
+
export { makeGlyphs, SPINNER_FRAMES, SPINNER_STATIC } from "@chances-ai/ui-core";
|
|
12
|
+
/** Glyph set for the running platform (`process.platform`). */
|
|
13
|
+
export declare const GLYPHS: Glyphs;
|
|
14
|
+
/** `NO_COLOR` check defaulting to `process.env` (TUI convenience over the pure
|
|
15
|
+
* ui-core `isNoColor(env)` — https://no-color.org). */
|
|
68
16
|
export declare function isNoColor(env?: NodeJS.ProcessEnv): boolean;
|
|
69
|
-
/**
|
|
70
|
-
*
|
|
71
|
-
* the light palette and `'dark'`/`'auto'`/undefined → dark.
|
|
72
|
-
*/
|
|
17
|
+
/** Resolve a palette, defaulting the env to `process.env` (TUI convenience over
|
|
18
|
+
* the pure ui-core `resolveTheme(setting, env)`). */
|
|
73
19
|
export declare function resolveTheme(setting: ThemeSetting | undefined, env?: NodeJS.ProcessEnv): Theme;
|
|
74
|
-
export interface Glyphs {
|
|
75
|
-
/** Tool/turn status dot. `⏺` aligns well only on macOS terminals; `●`
|
|
76
|
-
* elsewhere (matches claude-code `figures.ts` BLACK_CIRCLE). */
|
|
77
|
-
dot: string;
|
|
78
|
-
/** Result continuation L-branch. */
|
|
79
|
-
branch: string;
|
|
80
|
-
/** Input + selection prompt caret. */
|
|
81
|
-
prompt: string;
|
|
82
|
-
/** Blockquote bar. */
|
|
83
|
-
blockquote: string;
|
|
84
|
-
/** Plan-mode badge symbol. */
|
|
85
|
-
plan: string;
|
|
86
|
-
/** Accept-edits / auto badge symbol. */
|
|
87
|
-
accept: string;
|
|
88
|
-
/** Success tick. */
|
|
89
|
-
tick: string;
|
|
90
|
-
/** Horizontal rule fill. */
|
|
91
|
-
hr: string;
|
|
92
|
-
/** Unordered-list bullet. */
|
|
93
|
-
bullet: string;
|
|
94
|
-
/** Progress "thinking" glyph (also the brightest spinner frame). */
|
|
95
|
-
thinking: string;
|
|
96
|
-
arrowDown: string;
|
|
97
|
-
arrowUp: string;
|
|
98
|
-
}
|
|
99
|
-
/** Build the glyph set for a platform. Exported as a function so tests can pin
|
|
100
|
-
* both the darwin (`⏺`) and non-darwin (`●`) dot without monkey-patching. */
|
|
101
|
-
export declare function makeGlyphs(platform?: NodeJS.Platform): Glyphs;
|
|
102
|
-
export declare const GLYPHS: Glyphs;
|
|
103
|
-
export declare const SPINNER_FRAMES: readonly string[];
|
|
104
|
-
/** Static glyph shown instead of the animation under reduced-motion / NO_COLOR. */
|
|
105
|
-
export declare const SPINNER_STATIC = "\u25CF";
|
|
106
20
|
//# sourceMappingURL=theme.d.ts.map
|
package/dist/theme.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAIL,KAAK,MAAM,EACX,KAAK,KAAK,EACV,KAAK,YAAY,EAClB,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEjF,+DAA+D;AAC/D,eAAO,MAAM,MAAM,EAAE,MAAqC,CAAC;AAE3D;wDACwD;AACxD,wBAAgB,SAAS,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAIvE;AAED;sDACsD;AACtD,wBAAgB,YAAY,CAC1B,OAAO,EAAE,YAAY,GAAG,SAAS,EACjC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,KAAK,CAEP"}
|
package/dist/theme.js
CHANGED
|
@@ -1,116 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* `theme
|
|
7
|
-
*
|
|
8
|
-
* Colors are emitted as Ink-compatible `rgb(r,g,b)` strings; Ink renders them
|
|
9
|
-
* through chalk, which downsamples truecolor → 256/16 by the terminal's
|
|
10
|
-
* detected level. We therefore keep ONE truecolor palette per mode and let
|
|
11
|
-
* chalk degrade — there is no hand-rolled 16-ANSI fallback table (5.9 §0).
|
|
12
|
-
*
|
|
13
|
-
* `NO_COLOR` (https://no-color.org) is honored explicitly here because chalk
|
|
14
|
-
* 5 / Ink 7 only read the `--no-color` *flag*, not the env var (codex R1
|
|
15
|
-
* MUST-2): when set, `resolveTheme` returns a palette whose every color is
|
|
16
|
-
* `undefined`, so components emit no `color`/`backgroundColor` and meaning is
|
|
17
|
-
* carried by glyphs + sigils alone (the diff `+`/`-`, the `⏺`/`⎿` shapes).
|
|
18
|
-
*
|
|
19
|
-
* Dark RGB values are the facts of claude-code's `darkTheme` visual language
|
|
20
|
-
* (verified `~/Projects/github/claude-code/src/utils/theme.ts`); light values
|
|
21
|
-
* track its `lightTheme`. Syntax colors are an OneDark-ish set legible on the
|
|
22
|
-
* respective background.
|
|
2
|
+
* (v17 M0) TUI theme shim. The pure visual-language tokens + functions now live
|
|
3
|
+
* in `@chances-ai/ui-core` (browser-safe — no `node:*`, no `process.*`). This
|
|
4
|
+
* module re-exports them and adds the TUI's Node-bound conveniences: the
|
|
5
|
+
* `process.env`-defaulting `isNoColor` / `resolveTheme`, and the
|
|
6
|
+
* `process.platform`-derived `GLYPHS` constant. Keeping the same `./theme.js`
|
|
7
|
+
* specifier means every TUI component import is unchanged.
|
|
23
8
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
planMode: "rgb(72,150,140)",
|
|
31
|
-
autoAccept: "rgb(175,135,255)",
|
|
32
|
-
bashPink: "rgb(253,93,177)",
|
|
33
|
-
diffAddedBg: "rgb(34,92,43)",
|
|
34
|
-
diffRemovedBg: "rgb(122,41,54)",
|
|
35
|
-
diffAddedWordBg: "rgb(56,166,96)",
|
|
36
|
-
diffRemovedWordBg: "rgb(179,89,107)",
|
|
37
|
-
userMessageBg: "rgb(55,55,55)",
|
|
38
|
-
stall: "rgb(171,43,63)",
|
|
39
|
-
synKeyword: "rgb(198,120,221)",
|
|
40
|
-
synString: "rgb(152,195,121)",
|
|
41
|
-
synComment: "rgb(106,115,125)",
|
|
42
|
-
synNumber: "rgb(209,154,102)",
|
|
43
|
-
synFunction: "rgb(97,175,239)",
|
|
44
|
-
synType: "rgb(229,192,123)",
|
|
45
|
-
synLiteral: "rgb(86,182,194)",
|
|
46
|
-
synTitle: "rgb(97,175,239)",
|
|
47
|
-
synAttr: "rgb(209,154,102)",
|
|
48
|
-
};
|
|
49
|
-
const lightTheme = {
|
|
50
|
-
accent: "rgb(215,119,87)",
|
|
51
|
-
success: "rgb(44,122,57)",
|
|
52
|
-
error: "rgb(171,43,63)",
|
|
53
|
-
warning: "rgb(150,108,30)",
|
|
54
|
-
permission: "rgb(87,105,247)",
|
|
55
|
-
planMode: "rgb(0,102,102)",
|
|
56
|
-
autoAccept: "rgb(135,0,255)",
|
|
57
|
-
bashPink: "rgb(255,0,135)",
|
|
58
|
-
diffAddedBg: "rgb(105,219,124)",
|
|
59
|
-
diffRemovedBg: "rgb(255,168,180)",
|
|
60
|
-
diffAddedWordBg: "rgb(47,157,68)",
|
|
61
|
-
diffRemovedWordBg: "rgb(209,69,75)",
|
|
62
|
-
userMessageBg: "rgb(240,240,240)",
|
|
63
|
-
stall: "rgb(171,43,63)",
|
|
64
|
-
synKeyword: "rgb(166,38,164)",
|
|
65
|
-
synString: "rgb(80,161,79)",
|
|
66
|
-
synComment: "rgb(160,161,167)",
|
|
67
|
-
synNumber: "rgb(152,104,1)",
|
|
68
|
-
synFunction: "rgb(64,120,242)",
|
|
69
|
-
synType: "rgb(193,132,1)",
|
|
70
|
-
synLiteral: "rgb(1,132,188)",
|
|
71
|
-
synTitle: "rgb(64,120,242)",
|
|
72
|
-
synAttr: "rgb(152,104,1)",
|
|
73
|
-
};
|
|
74
|
-
/** Every color undefined ⇒ no color props emitted (glyphs/sigils carry meaning). */
|
|
75
|
-
const noColorTheme = {};
|
|
76
|
-
/** `NO_COLOR` (https://no-color.org): present and NON-EMPTY ⇒ disable color,
|
|
77
|
-
* regardless of value. An empty string does NOT disable (per the spec). */
|
|
9
|
+
import { makeGlyphs, isNoColor as isNoColorCore, resolveTheme as resolveThemeCore, } from "@chances-ai/ui-core";
|
|
10
|
+
export { makeGlyphs, SPINNER_FRAMES, SPINNER_STATIC } from "@chances-ai/ui-core";
|
|
11
|
+
/** Glyph set for the running platform (`process.platform`). */
|
|
12
|
+
export const GLYPHS = makeGlyphs(process.platform);
|
|
13
|
+
/** `NO_COLOR` check defaulting to `process.env` (TUI convenience over the pure
|
|
14
|
+
* ui-core `isNoColor(env)` — https://no-color.org). */
|
|
78
15
|
export function isNoColor(env = process.env) {
|
|
79
|
-
|
|
80
|
-
|
|
16
|
+
// Project to the narrow `NoColorEnv` (ui-core reads only NO_COLOR); a bare
|
|
17
|
+
// `process.env` (index-signature-only) isn't structurally assignable.
|
|
18
|
+
return isNoColorCore({ NO_COLOR: env.NO_COLOR });
|
|
81
19
|
}
|
|
82
|
-
/**
|
|
83
|
-
*
|
|
84
|
-
* the light palette and `'dark'`/`'auto'`/undefined → dark.
|
|
85
|
-
*/
|
|
20
|
+
/** Resolve a palette, defaulting the env to `process.env` (TUI convenience over
|
|
21
|
+
* the pure ui-core `resolveTheme(setting, env)`). */
|
|
86
22
|
export function resolveTheme(setting, env = process.env) {
|
|
87
|
-
|
|
88
|
-
return noColorTheme;
|
|
89
|
-
return setting === "light" ? lightTheme : darkTheme;
|
|
90
|
-
}
|
|
91
|
-
/** Build the glyph set for a platform. Exported as a function so tests can pin
|
|
92
|
-
* both the darwin (`⏺`) and non-darwin (`●`) dot without monkey-patching. */
|
|
93
|
-
export function makeGlyphs(platform = process.platform) {
|
|
94
|
-
return {
|
|
95
|
-
dot: platform === "darwin" ? "⏺" : "●",
|
|
96
|
-
branch: "⎿",
|
|
97
|
-
prompt: "❯",
|
|
98
|
-
blockquote: "▎",
|
|
99
|
-
plan: "⏸",
|
|
100
|
-
accept: "⏵⏵",
|
|
101
|
-
tick: "✓",
|
|
102
|
-
hr: "─",
|
|
103
|
-
bullet: "•",
|
|
104
|
-
thinking: "✻",
|
|
105
|
-
arrowDown: "↓",
|
|
106
|
-
arrowUp: "↑",
|
|
107
|
-
};
|
|
23
|
+
return resolveThemeCore(setting, { NO_COLOR: env.NO_COLOR });
|
|
108
24
|
}
|
|
109
|
-
export const GLYPHS = makeGlyphs();
|
|
110
|
-
/** Spinner pulse: 6 frames then their reverse = a 12-step in/out pulse
|
|
111
|
-
* (claude-code `Spinner.tsx` `[...frames, ...reversed]`). Tick ~120 ms. */
|
|
112
|
-
const SPINNER_BASE = ["·", "✢", "✱", "✶", "✻", "✽"];
|
|
113
|
-
export const SPINNER_FRAMES = [...SPINNER_BASE, ...[...SPINNER_BASE].reverse()];
|
|
114
|
-
/** Static glyph shown instead of the animation under reduced-motion / NO_COLOR. */
|
|
115
|
-
export const SPINNER_STATIC = "●";
|
|
116
25
|
//# sourceMappingURL=theme.js.map
|
package/dist/theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,UAAU,EACV,SAAS,IAAI,aAAa,EAC1B,YAAY,IAAI,gBAAgB,GAIjC,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEjF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,MAAM,GAAW,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE3D;wDACwD;AACxD,MAAM,UAAU,SAAS,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC5D,2EAA2E;IAC3E,sEAAsE;IACtE,OAAO,aAAa,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;AACnD,CAAC;AAED;sDACsD;AACtD,MAAM,UAAU,YAAY,CAC1B,OAAiC,EACjC,MAAyB,OAAO,CAAC,GAAG;IAEpC,OAAO,gBAAgB,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC/D,CAAC"}
|
package/dist/tool-message.js
CHANGED
|
@@ -12,7 +12,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
12
12
|
*/
|
|
13
13
|
import { Box, Text } from "ink";
|
|
14
14
|
import { DiffView } from "./diff-view.js";
|
|
15
|
-
import { toolDisplayName } from "
|
|
15
|
+
import { toolDisplayName } from "@chances-ai/ui-core";
|
|
16
16
|
import { useTheme } from "./theme-context.js";
|
|
17
17
|
/** Left indent (cols) the embedded diff sits under the `⎿` branch. */
|
|
18
18
|
const DIFF_INDENT = 5;
|
package/dist/tool-message.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-message.js","sourceRoot":"","sources":["../src/tool-message.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"tool-message.js","sourceRoot":"","sources":["../src/tool-message.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAEhC,OAAO,EAAE,QA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,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAC5B,MAAC,IAAI,IAAS,KAAK,EAAE,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,KAAK,KAAK,aAChF,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,EACzC,IAAI,KAFI,CAAC,CAGL,CACR,CAAC,EACD,IAAI,CAAC,CAAC,CAAC,CACN,KAAC,GAAG,IAAC,WAAW,EAAE,WAAW,YAG3B,KAAC,QAAQ,IAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,WAAW,EAAE,CAAC,GAAG,WAAW,GAAI,GACvF,CACP,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC;AAED;;kDAEkD;AAClD,SAAS,YAAY,CAAC,MAAc;IAClC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,MAAM,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type JSX } from "react";
|
|
2
|
+
import type { QuestionDecision, QuestionSpec } from "@chances-ai/tools";
|
|
3
|
+
import { type SelectOption } from "./select.js";
|
|
4
|
+
/**
|
|
5
|
+
* (5.10b B2) The model-driven chooser for the `ask_user_question` tool. Rides the
|
|
6
|
+
* `vm.pending` permission seam (NOT `openModal`) so detach + resolver
|
|
7
|
+
* serialization hold (codex R1). Mirrors claude-code's QuestionView: a tab per
|
|
8
|
+
* question, single-select → {@link Select} / multi-select → {@link SelectMulti},
|
|
9
|
+
* an optional side-by-side Markdown preview, a UI-injected "Other" free-text row
|
|
10
|
+
* (the model never declares it — schema-locked), and auto-submit for a lone
|
|
11
|
+
* single-select question. No `useInput` of its own — everything routes through
|
|
12
|
+
* the ink-ext bus (Select / Modal contexts).
|
|
13
|
+
*/
|
|
14
|
+
/** Sentinel for the UI-injected free-text "Other" row. */
|
|
15
|
+
export declare const OTHER_VALUE = "__other__";
|
|
16
|
+
/** Options for a question = the model's options + the injected "Other…" row. */
|
|
17
|
+
export declare function buildOptions(q: QuestionSpec): SelectOption<string>[];
|
|
18
|
+
/** Whether a (single-select) question renders a side-by-side Markdown preview. */
|
|
19
|
+
export declare function questionHasPreview(q: QuestionSpec): boolean;
|
|
20
|
+
export interface QuestionViewProps {
|
|
21
|
+
questions: QuestionSpec[];
|
|
22
|
+
onSubmit: (decision: QuestionDecision) => void;
|
|
23
|
+
onCancel: () => void;
|
|
24
|
+
}
|
|
25
|
+
export declare function QuestionView({ questions, onSubmit, onCancel }: QuestionViewProps): JSX.Element;
|
|
26
|
+
//# sourceMappingURL=user-question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-question.d.ts","sourceRoot":"","sources":["../src/user-question.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAExE,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAKxD;;;;;;;;;GASG;AAEH,0DAA0D;AAC1D,eAAO,MAAM,WAAW,cAAc,CAAC;AAEvC,gFAAgF;AAChF,wBAAgB,YAAY,CAAC,CAAC,EAAE,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC,EAAE,CAOpE;AAED,kFAAkF;AAClF,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,YAAY,GAAG,OAAO,CAE3D;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,QAAQ,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC/C,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,wBAAgB,YAAY,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAsL9F"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from "ink";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { useKeybinding, useKeybindingContext, useTextInput } from "@chances-ai/ink-ext";
|
|
5
|
+
import { Select } from "./select.js";
|
|
6
|
+
import { SelectMulti } from "./select-multi.js";
|
|
7
|
+
import { Markdown } from "./markdown.js";
|
|
8
|
+
import { useTheme } from "./theme-context.js";
|
|
9
|
+
/**
|
|
10
|
+
* (5.10b B2) The model-driven chooser for the `ask_user_question` tool. Rides the
|
|
11
|
+
* `vm.pending` permission seam (NOT `openModal`) so detach + resolver
|
|
12
|
+
* serialization hold (codex R1). Mirrors claude-code's QuestionView: a tab per
|
|
13
|
+
* question, single-select → {@link Select} / multi-select → {@link SelectMulti},
|
|
14
|
+
* an optional side-by-side Markdown preview, a UI-injected "Other" free-text row
|
|
15
|
+
* (the model never declares it — schema-locked), and auto-submit for a lone
|
|
16
|
+
* single-select question. No `useInput` of its own — everything routes through
|
|
17
|
+
* the ink-ext bus (Select / Modal contexts).
|
|
18
|
+
*/
|
|
19
|
+
/** Sentinel for the UI-injected free-text "Other" row. */
|
|
20
|
+
export const OTHER_VALUE = "__other__";
|
|
21
|
+
/** Options for a question = the model's options + the injected "Other…" row. */
|
|
22
|
+
export function buildOptions(q) {
|
|
23
|
+
const base = q.options.map((o) => ({
|
|
24
|
+
label: o.label,
|
|
25
|
+
value: o.label,
|
|
26
|
+
description: o.description,
|
|
27
|
+
}));
|
|
28
|
+
return [...base, { label: "Other…", value: OTHER_VALUE }];
|
|
29
|
+
}
|
|
30
|
+
/** Whether a (single-select) question renders a side-by-side Markdown preview. */
|
|
31
|
+
export function questionHasPreview(q) {
|
|
32
|
+
return !q.multiSelect && q.options.some((o) => typeof o.preview === "string" && o.preview.trim() !== "");
|
|
33
|
+
}
|
|
34
|
+
export function QuestionView({ questions, onSubmit, onCancel }) {
|
|
35
|
+
const { theme } = useTheme();
|
|
36
|
+
const total = questions.length;
|
|
37
|
+
// A lone single-select question auto-submits (claude-code's hideSubmitTab).
|
|
38
|
+
const showSubmitTab = total > 1 || questions.some((q) => q.multiSelect);
|
|
39
|
+
const submitIndex = total; // tab index of the Submit step (only when showSubmitTab)
|
|
40
|
+
const maxIndex = showSubmitTab ? submitIndex : total - 1;
|
|
41
|
+
const [index, setIndex] = useState(0);
|
|
42
|
+
const [answers, setAnswers] = useState({});
|
|
43
|
+
// Non-null while editing the "Other" free-text for the current question; holds
|
|
44
|
+
// the already-picked non-Other labels (multi-select) the typed text appends to.
|
|
45
|
+
const [otherBase, setOtherBase] = useState(null);
|
|
46
|
+
const [otherText, setOtherText] = useState("");
|
|
47
|
+
const [focusedLabel, setFocusedLabel] = useState(undefined);
|
|
48
|
+
// (codex R2 SHOULD-FIX #1) Per-question multi-select draft. SelectMulti is
|
|
49
|
+
// remounted on every tab switch, so without lifting its selection here, ticking
|
|
50
|
+
// options → switching tabs → coming back would silently lose the answer.
|
|
51
|
+
const [multiDraft, setMultiDraft] = useState({});
|
|
52
|
+
const editingOther = otherBase !== null;
|
|
53
|
+
const q = index < total ? questions[index] : undefined;
|
|
54
|
+
const atSubmit = showSubmitTab && index === submitIndex;
|
|
55
|
+
const finish = (final) => {
|
|
56
|
+
onSubmit({ kind: "question", answers: final });
|
|
57
|
+
};
|
|
58
|
+
const recordAndAdvance = (labels) => {
|
|
59
|
+
if (!q)
|
|
60
|
+
return;
|
|
61
|
+
const next = { ...answers, [q.question]: labels };
|
|
62
|
+
setAnswers(next);
|
|
63
|
+
setOtherBase(null);
|
|
64
|
+
setOtherText("");
|
|
65
|
+
if (!showSubmitTab) {
|
|
66
|
+
finish(next); // lone single-select → auto-submit
|
|
67
|
+
}
|
|
68
|
+
else if (index < total - 1) {
|
|
69
|
+
setIndex(index + 1);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
setIndex(submitIndex);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
// Tab navigation (Left/Right), disabled while editing the Other field.
|
|
76
|
+
useKeybinding("select:prevTab", () => setIndex((i) => Math.max(0, i - 1)), {
|
|
77
|
+
context: "Select",
|
|
78
|
+
active: !editingOther,
|
|
79
|
+
});
|
|
80
|
+
useKeybinding("select:nextTab", () => setIndex((i) => Math.min(maxIndex, i + 1)), {
|
|
81
|
+
context: "Select",
|
|
82
|
+
active: !editingOther,
|
|
83
|
+
});
|
|
84
|
+
// "Other" free-text sub-mode (Modal context masks the list below).
|
|
85
|
+
useKeybindingContext("Modal", editingOther);
|
|
86
|
+
useTextInput("Modal", (input, key) => {
|
|
87
|
+
if (key.backspace || key.delete)
|
|
88
|
+
setOtherText((t) => t.slice(0, -1));
|
|
89
|
+
else if (input && !key.ctrl && !key.meta)
|
|
90
|
+
setOtherText((t) => t + input);
|
|
91
|
+
}, { active: editingOther });
|
|
92
|
+
useKeybinding("modal:accept", () => {
|
|
93
|
+
const text = otherText.trim();
|
|
94
|
+
const base = otherBase ?? [];
|
|
95
|
+
recordAndAdvance(text ? [...base, text] : base);
|
|
96
|
+
}, { context: "Modal", active: editingOther });
|
|
97
|
+
useKeybinding("modal:cancel", () => {
|
|
98
|
+
setOtherBase(null);
|
|
99
|
+
setOtherText("");
|
|
100
|
+
}, { context: "Modal", active: editingOther });
|
|
101
|
+
const tabBar = (_jsxs(Box, { children: [questions.map((qq, i) => {
|
|
102
|
+
const answered = (answers[qq.question]?.length ?? 0) > 0;
|
|
103
|
+
const current = i === index;
|
|
104
|
+
return (_jsxs(Text, { color: current ? theme.permission : undefined, bold: current, children: [answered ? "☑" : "☐", " ", qq.header, " "] }, qq.question));
|
|
105
|
+
}), showSubmitTab ? (_jsx(Text, { color: atSubmit ? theme.permission : undefined, bold: atSubmit, children: "\u23CE Submit" })) : null] }));
|
|
106
|
+
let body;
|
|
107
|
+
if (atSubmit) {
|
|
108
|
+
body = (_jsx(Select, { heading: "Review and submit your answers", options: [{ label: "Submit answers", value: "submit" }], onSelect: () => finish(answers), onCancel: onCancel, active: !editingOther }));
|
|
109
|
+
}
|
|
110
|
+
else if (q && q.multiSelect) {
|
|
111
|
+
const qKey = q.question;
|
|
112
|
+
body = (_jsx(SelectMulti, { heading: q.question, options: buildOptions(q), selected: multiDraft[qKey] ?? [], onChange: (v) => setMultiDraft((d) => ({ ...d, [qKey]: v })), onSubmit: (values) => {
|
|
113
|
+
const nonOther = values.filter((v) => v !== OTHER_VALUE);
|
|
114
|
+
if (values.includes(OTHER_VALUE))
|
|
115
|
+
setOtherBase(nonOther);
|
|
116
|
+
else
|
|
117
|
+
recordAndAdvance(nonOther);
|
|
118
|
+
}, onCancel: onCancel, active: !editingOther }));
|
|
119
|
+
}
|
|
120
|
+
else if (q) {
|
|
121
|
+
const selectEl = (_jsx(Select, { heading: q.question, options: buildOptions(q), onSelect: (value) => {
|
|
122
|
+
if (value === OTHER_VALUE)
|
|
123
|
+
setOtherBase([]);
|
|
124
|
+
else
|
|
125
|
+
recordAndAdvance([value]);
|
|
126
|
+
}, onCancel: onCancel, onFocusChange: setFocusedLabel, active: !editingOther }));
|
|
127
|
+
if (questionHasPreview(q)) {
|
|
128
|
+
const previewText = q.options.find((o) => o.label === focusedLabel)?.preview ?? "";
|
|
129
|
+
body = (_jsxs(Box, { children: [_jsx(Box, { width: "50%", children: selectEl }), _jsx(Box, { width: "50%", marginLeft: 1, paddingX: 1, flexDirection: "column", borderStyle: "round", borderColor: theme.permission, children: previewText ? _jsx(Markdown, { text: previewText }) : _jsx(Text, { dimColor: true, children: "(no preview)" }) })] }));
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
body = selectEl;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
body = _jsx(Text, { dimColor: true, children: "no questions" });
|
|
137
|
+
}
|
|
138
|
+
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [tabBar, _jsx(Box, { marginTop: 1, children: body }), editingOther ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: theme.permission, children: "Type your own answer (Enter to confirm, Esc to go back):" }), _jsxs(Text, { children: ["> ", otherText] })] })) : null] }));
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=user-question.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-question.js","sourceRoot":"","sources":["../src/user-question.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAY,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,EAAE,MAAM,EAAqB,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C;;;;;;;;;GASG;AAEH,0DAA0D;AAC1D,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC;AAEvC,gFAAgF;AAChF,MAAM,UAAU,YAAY,CAAC,CAAe;IAC1C,MAAM,IAAI,GAA2B,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAA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CAAC,YAAG,IAAI,GAAO,EAC9B,YAAY,CAAC,CAAC,CAAC,CACd,MAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,aAAa,EAAC,QAAQ,aACvC,KAAC,IAAI,IAAC,KAAK,EAAE,KAAK,CAAC,UAAU,yEAAiE,EAC9F,MAAC,IAAI,eACF,IAAI,EACJ,SAAS,IACL,IACH,CACP,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chances-ai/tui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -14,17 +14,18 @@
|
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@chances-ai/ink-ext": "
|
|
18
|
-
"@chances-ai/plugin-api": "
|
|
19
|
-
"@chances-ai/runtime": "
|
|
20
|
-
"@chances-ai/tools": "
|
|
17
|
+
"@chances-ai/ink-ext": "17.0.0",
|
|
18
|
+
"@chances-ai/plugin-api": "17.0.0",
|
|
19
|
+
"@chances-ai/runtime": "17.0.0",
|
|
20
|
+
"@chances-ai/tools": "17.0.0",
|
|
21
|
+
"@chances-ai/ui-core": "17.0.0",
|
|
21
22
|
"marked": "^18.0.0",
|
|
22
23
|
"highlight.js": "^11.11.1",
|
|
23
24
|
"diff": "^9.0.0",
|
|
24
25
|
"string-width": "^8.2.1"
|
|
25
26
|
},
|
|
26
27
|
"peerDependencies": {
|
|
27
|
-
"ink": "^7.0.
|
|
28
|
+
"ink": "^7.0.5",
|
|
28
29
|
"react": "^19.2"
|
|
29
30
|
},
|
|
30
31
|
"scripts": {
|
package/dist/diff-model.d.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* (5.9 / v14) Pure parser that turns the `linesDiff` text block (carried in a
|
|
3
|
-
* write/edit `tool:permission` summary — see `view-model.ts`) into structured,
|
|
4
|
-
* renderable rows. NO React/Ink here — this is the correctness core, fully
|
|
5
|
-
* unit-tested in isolation.
|
|
6
|
-
*
|
|
7
|
-
* `linesDiff` (`packages/tools/src/diff.ts`) emits, in order:
|
|
8
|
-
* `@@ -start,rem +start,add @@`
|
|
9
|
-
* `- <removed line>` × rem
|
|
10
|
-
* `+ <added line>` × add
|
|
11
|
-
* — i.e. ALL removes then ALL adds, NO context lines; with a `… (N lines
|
|
12
|
-
* elided)` marker injected in the middle when the block exceeds its 14-body-row
|
|
13
|
-
* cap (so a full block is up to 15 lines incl. the header — codex R1 SHOULD-5).
|
|
14
|
-
*
|
|
15
|
-
* Line numbers (codex R1 MUST-1): `write` diffs are whole-file-anchored
|
|
16
|
-
* (`linesDiff(before, content)`), so `@@ -start` is the real file line — render
|
|
17
|
-
* the gutter. `edit` diffs are `find`↔`replace` snippets, so `@@ -1` is
|
|
18
|
-
* snippet-relative — the caller passes `anchored: false` and no gutter is shown.
|
|
19
|
-
*/
|
|
20
|
-
/** Threshold above which a remove/add pair renders as whole-line (not word-level).
|
|
21
|
-
* Matches claude-code `StructuredDiff/Fallback.tsx` `CHANGE_THRESHOLD`. */
|
|
22
|
-
export declare const CHANGE_THRESHOLD = 0.4;
|
|
23
|
-
export interface WordSeg {
|
|
24
|
-
text: string;
|
|
25
|
-
/** True ⇒ this word was added (on an add row) or removed (on a remove row). */
|
|
26
|
-
changed: boolean;
|
|
27
|
-
}
|
|
28
|
-
export interface DiffRow {
|
|
29
|
-
kind: "add" | "remove" | "elision";
|
|
30
|
-
/** Code content with the `+`/`-`/space sigil stripped (the raw elision text
|
|
31
|
-
* for `kind:"elision"`). */
|
|
32
|
-
text: string;
|
|
33
|
-
/** Assigned line number, or null when unanchored (edit) or an elision row. */
|
|
34
|
-
lineNo: number | null;
|
|
35
|
-
/** Word-level segments when this row is part of a sub-threshold pair; null ⇒
|
|
36
|
-
* render the whole line with the line background. */
|
|
37
|
-
words: WordSeg[] | null;
|
|
38
|
-
}
|
|
39
|
-
export interface ParsedDiff {
|
|
40
|
-
rows: DiffRow[];
|
|
41
|
-
/** The hunk's old start line (1-based) parsed from the `@@` header, or null. */
|
|
42
|
-
startLine: number | null;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Detect whether a text block is a renderable diff (the non-diff guard, 5.9 §3):
|
|
46
|
-
* true only when it contains a `@@ -d +d @@` hunk header.
|
|
47
|
-
*/
|
|
48
|
-
export declare function looksLikeDiff(text: string): boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Parse a `linesDiff` block. `anchored` (write=true, edit=false) controls
|
|
51
|
-
* whether line numbers are assigned. Returns rows in source order with
|
|
52
|
-
* word-level segments computed for sub-threshold remove/add pairs.
|
|
53
|
-
*/
|
|
54
|
-
export declare function parseDiff(text: string, opts: {
|
|
55
|
-
anchored: boolean;
|
|
56
|
-
}): ParsedDiff;
|
|
57
|
-
/**
|
|
58
|
-
* Word-level segments for one side of a pair. `side:"remove"` keeps common +
|
|
59
|
-
* removed words; `side:"add"` keeps common + added words. Returns null when the
|
|
60
|
-
* pair changed more than {@link CHANGE_THRESHOLD} of its total length (render
|
|
61
|
-
* whole-line instead).
|
|
62
|
-
*/
|
|
63
|
-
export declare function wordSegs(removeText: string, addText: string, side: "add" | "remove"): WordSeg[] | null;
|
|
64
|
-
//# sourceMappingURL=diff-model.d.ts.map
|
package/dist/diff-model.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"diff-model.d.ts","sourceRoot":"","sources":["../src/diff-model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH;4EAC4E;AAC5E,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,+EAA+E;IAC/E,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;IACnC;iCAC6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB;0DACsD;IACtD,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,gFAAgF;IAChF,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAQD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEnD;AAOD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,GAAG,UAAU,CAuB/E;AAqED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,QAAQ,GAAG,OAAO,EAAE,GAAG,IAAI,CAiBtG"}
|