@travisennis/acai 0.0.3 → 0.0.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.
Files changed (316) hide show
  1. package/README.md +225 -6
  2. package/dist/api/exa/index.d.ts +177 -0
  3. package/dist/api/exa/index.d.ts.map +1 -0
  4. package/dist/api/exa/index.js +439 -0
  5. package/dist/cli.d.ts +3 -2
  6. package/dist/cli.d.ts.map +1 -0
  7. package/dist/commands/application-log-command.d.ts +1 -0
  8. package/dist/commands/application-log-command.d.ts.map +1 -0
  9. package/dist/commands/application-log-command.js +5 -3
  10. package/dist/commands/clear-command.d.ts +1 -0
  11. package/dist/commands/clear-command.d.ts.map +1 -0
  12. package/dist/commands/clear-command.js +2 -3
  13. package/dist/commands/compact-command.d.ts +1 -0
  14. package/dist/commands/compact-command.d.ts.map +1 -0
  15. package/dist/commands/compact-command.js +1 -1
  16. package/dist/commands/copy-command.d.ts +1 -0
  17. package/dist/commands/copy-command.d.ts.map +1 -0
  18. package/dist/commands/copy-command.js +3 -2
  19. package/dist/commands/edit-command.d.ts +1 -0
  20. package/dist/commands/edit-command.d.ts.map +1 -0
  21. package/dist/commands/edit-command.js +7 -5
  22. package/dist/commands/edit-prompt-command.d.ts +2 -1
  23. package/dist/commands/edit-prompt-command.d.ts.map +1 -0
  24. package/dist/commands/edit-prompt-command.js +15 -7
  25. package/dist/commands/exit-command.d.ts +13 -2
  26. package/dist/commands/exit-command.d.ts.map +1 -0
  27. package/dist/commands/exit-command.js +14 -2
  28. package/dist/commands/files-command.d.ts +1 -0
  29. package/dist/commands/files-command.d.ts.map +1 -0
  30. package/dist/commands/files-command.js +9 -8
  31. package/dist/commands/generate-rules-command.d.ts +1 -0
  32. package/dist/commands/generate-rules-command.d.ts.map +1 -0
  33. package/dist/commands/generate-rules-command.js +4 -3
  34. package/dist/commands/health-command.d.ts +3 -1
  35. package/dist/commands/health-command.d.ts.map +1 -0
  36. package/dist/commands/health-command.js +42 -5
  37. package/dist/commands/help-command.d.ts +1 -0
  38. package/dist/commands/help-command.d.ts.map +1 -0
  39. package/dist/commands/help-command.js +2 -3
  40. package/dist/commands/init-command.d.ts +1 -0
  41. package/dist/commands/init-command.d.ts.map +1 -0
  42. package/dist/commands/init-command.js +1 -2
  43. package/dist/commands/last-log-command.d.ts +1 -0
  44. package/dist/commands/last-log-command.d.ts.map +1 -0
  45. package/dist/commands/last-log-command.js +12 -17
  46. package/dist/commands/list-tools-command.d.ts +3 -0
  47. package/dist/commands/list-tools-command.d.ts.map +1 -0
  48. package/dist/commands/list-tools-command.js +61 -0
  49. package/dist/commands/manager.d.ts +7 -2
  50. package/dist/commands/manager.d.ts.map +1 -0
  51. package/dist/commands/manager.js +43 -6
  52. package/dist/commands/model-command.d.ts +1 -0
  53. package/dist/commands/model-command.d.ts.map +1 -0
  54. package/dist/commands/model-command.js +5 -5
  55. package/dist/commands/paste-command.d.ts +1 -0
  56. package/dist/commands/paste-command.d.ts.map +1 -0
  57. package/dist/commands/paste-command.js +6 -5
  58. package/dist/commands/prompt-command.d.ts +2 -1
  59. package/dist/commands/prompt-command.d.ts.map +1 -0
  60. package/dist/commands/prompt-command.js +62 -8
  61. package/dist/commands/reset-command.d.ts +1 -0
  62. package/dist/commands/reset-command.d.ts.map +1 -0
  63. package/dist/commands/reset-command.js +1 -1
  64. package/dist/commands/rules-command.d.ts +1 -0
  65. package/dist/commands/rules-command.d.ts.map +1 -0
  66. package/dist/commands/rules-command.js +5 -3
  67. package/dist/commands/save-command.d.ts +1 -0
  68. package/dist/commands/save-command.d.ts.map +1 -0
  69. package/dist/commands/save-command.js +1 -1
  70. package/dist/commands/shell-command.d.ts +3 -0
  71. package/dist/commands/shell-command.d.ts.map +1 -0
  72. package/dist/commands/shell-command.js +60 -0
  73. package/dist/commands/types.d.ts +9 -6
  74. package/dist/commands/types.d.ts.map +1 -0
  75. package/dist/commands/usage-command.d.ts +1 -0
  76. package/dist/commands/usage-command.d.ts.map +1 -0
  77. package/dist/commands/usage-command.js +2 -3
  78. package/dist/config.d.ts +22 -34
  79. package/dist/config.d.ts.map +1 -0
  80. package/dist/config.js +61 -15
  81. package/dist/conversation-analyzer.d.ts +2 -1
  82. package/dist/conversation-analyzer.d.ts.map +1 -0
  83. package/dist/dedent.d.ts +1 -0
  84. package/dist/dedent.d.ts.map +1 -0
  85. package/dist/execution/index.d.ts +112 -0
  86. package/dist/execution/index.d.ts.map +1 -0
  87. package/dist/execution/index.js +432 -0
  88. package/dist/formatting.d.ts +2 -13
  89. package/dist/formatting.d.ts.map +1 -0
  90. package/dist/formatting.js +5 -64
  91. package/dist/index.d.ts +1 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.js +14 -4
  94. package/dist/logger.d.ts +1 -0
  95. package/dist/logger.d.ts.map +1 -0
  96. package/dist/mentions.d.ts +4 -0
  97. package/dist/mentions.d.ts.map +1 -0
  98. package/dist/mentions.js +42 -10
  99. package/dist/messages.d.ts +8 -20
  100. package/dist/messages.d.ts.map +1 -0
  101. package/dist/messages.js +33 -53
  102. package/dist/middleware/audit-message.d.ts +1 -0
  103. package/dist/middleware/audit-message.d.ts.map +1 -0
  104. package/dist/middleware/index.d.ts +1 -0
  105. package/dist/middleware/index.d.ts.map +1 -0
  106. package/dist/middleware/rate-limit.d.ts +1 -0
  107. package/dist/middleware/rate-limit.d.ts.map +1 -0
  108. package/dist/models/ai-config.d.ts +1 -0
  109. package/dist/models/ai-config.d.ts.map +1 -0
  110. package/dist/models/anthropic-provider.d.ts +1 -0
  111. package/dist/models/anthropic-provider.d.ts.map +1 -0
  112. package/dist/models/deepseek-provider.d.ts +1 -0
  113. package/dist/models/deepseek-provider.d.ts.map +1 -0
  114. package/dist/models/google-provider.d.ts +1 -0
  115. package/dist/models/google-provider.d.ts.map +1 -0
  116. package/dist/models/groq-provider.d.ts +20 -0
  117. package/dist/models/groq-provider.d.ts.map +1 -0
  118. package/dist/models/groq-provider.js +31 -0
  119. package/dist/models/manager.d.ts +1 -0
  120. package/dist/models/manager.d.ts.map +1 -0
  121. package/dist/models/openai-provider.d.ts +2 -1
  122. package/dist/models/openai-provider.d.ts.map +1 -0
  123. package/dist/models/openrouter-provider.d.ts +31 -22
  124. package/dist/models/openrouter-provider.d.ts.map +1 -0
  125. package/dist/models/openrouter-provider.js +115 -1
  126. package/dist/models/providers.d.ts +4 -5
  127. package/dist/models/providers.d.ts.map +1 -0
  128. package/dist/models/providers.js +7 -3
  129. package/dist/models/xai-provider.d.ts +1 -0
  130. package/dist/models/xai-provider.d.ts.map +1 -0
  131. package/dist/parsing.d.ts +2 -1
  132. package/dist/parsing.d.ts.map +1 -0
  133. package/dist/prompts/manager.d.ts +14 -2
  134. package/dist/prompts/manager.d.ts.map +1 -0
  135. package/dist/prompts.d.ts +1 -0
  136. package/dist/prompts.d.ts.map +1 -0
  137. package/dist/prompts.js +17 -11
  138. package/dist/repl/display-tool-messages.d.ts +4 -0
  139. package/dist/repl/display-tool-messages.d.ts.map +1 -0
  140. package/dist/repl/display-tool-messages.js +55 -0
  141. package/dist/repl/display-tool-use.d.ts +14 -0
  142. package/dist/repl/display-tool-use.d.ts.map +1 -0
  143. package/dist/repl/display-tool-use.js +63 -0
  144. package/dist/repl/get-prompt-header.d.ts +8 -0
  145. package/dist/repl/get-prompt-header.d.ts.map +1 -0
  146. package/dist/repl/get-prompt-header.js +38 -0
  147. package/dist/repl/tool-call-repair.d.ts +4 -0
  148. package/dist/repl/tool-call-repair.d.ts.map +1 -0
  149. package/dist/repl/tool-call-repair.js +50 -0
  150. package/dist/repl-prompt.d.ts +1 -0
  151. package/dist/repl-prompt.d.ts.map +1 -0
  152. package/dist/repl.d.ts +8 -4
  153. package/dist/repl.d.ts.map +1 -0
  154. package/dist/repl.js +108 -252
  155. package/dist/terminal/ansi-styles.d.ts +77 -0
  156. package/dist/terminal/ansi-styles.d.ts.map +1 -0
  157. package/dist/terminal/ansi-styles.js +215 -0
  158. package/dist/terminal/checkbox-prompt.d.ts +36 -0
  159. package/dist/terminal/checkbox-prompt.d.ts.map +1 -0
  160. package/dist/terminal/checkbox-prompt.js +362 -0
  161. package/dist/terminal/default-theme.d.ts +6 -0
  162. package/dist/terminal/default-theme.d.ts.map +1 -0
  163. package/dist/terminal/default-theme.js +182 -0
  164. package/dist/terminal/east-asian-width.d.ts +8 -0
  165. package/dist/terminal/east-asian-width.d.ts.map +1 -0
  166. package/dist/terminal/east-asian-width.js +409 -0
  167. package/dist/terminal/editor-prompt.d.ts +10 -0
  168. package/dist/terminal/editor-prompt.d.ts.map +1 -0
  169. package/dist/terminal/editor-prompt.js +61 -0
  170. package/dist/terminal/errors.d.ts +19 -0
  171. package/dist/terminal/errors.d.ts.map +1 -0
  172. package/dist/terminal/errors.js +37 -0
  173. package/dist/terminal/formatting.d.ts +1 -11
  174. package/dist/terminal/formatting.d.ts.map +1 -0
  175. package/dist/terminal/formatting.js +4 -20
  176. package/dist/terminal/highlight/index.d.ts +53 -0
  177. package/dist/terminal/highlight/index.d.ts.map +1 -0
  178. package/dist/terminal/highlight/index.js +90 -0
  179. package/dist/terminal/highlight/theme.d.ts +233 -0
  180. package/dist/terminal/highlight/theme.d.ts.map +1 -0
  181. package/dist/terminal/highlight/theme.js +83 -0
  182. package/dist/terminal/index.d.ts +16 -9
  183. package/dist/terminal/index.d.ts.map +1 -0
  184. package/dist/terminal/index.js +42 -126
  185. package/dist/terminal/input-prompt.d.ts +16 -0
  186. package/dist/terminal/input-prompt.d.ts.map +1 -0
  187. package/dist/terminal/input-prompt.js +181 -0
  188. package/dist/terminal/markdown-utils.d.ts +1 -0
  189. package/dist/terminal/markdown-utils.d.ts.map +1 -0
  190. package/dist/terminal/markdown.d.ts +1 -0
  191. package/dist/terminal/markdown.d.ts.map +1 -0
  192. package/dist/terminal/markdown.js +17 -12
  193. package/dist/terminal/search-prompt.d.ts +20 -0
  194. package/dist/terminal/search-prompt.d.ts.map +1 -0
  195. package/dist/terminal/search-prompt.js +279 -0
  196. package/dist/terminal/select-prompt.d.ts +26 -0
  197. package/dist/terminal/select-prompt.d.ts.map +1 -0
  198. package/dist/terminal/select-prompt.js +298 -0
  199. package/dist/terminal/string-width.d.ts +7 -0
  200. package/dist/terminal/string-width.d.ts.map +1 -0
  201. package/dist/terminal/string-width.js +61 -0
  202. package/dist/terminal/strip-ansi.d.ts +2 -0
  203. package/dist/terminal/strip-ansi.d.ts.map +1 -0
  204. package/dist/terminal/strip-ansi.js +20 -0
  205. package/dist/terminal/style.d.ts +191 -0
  206. package/dist/terminal/style.d.ts.map +1 -0
  207. package/dist/terminal/style.js +259 -0
  208. package/dist/terminal/supports-color.d.ts +1 -0
  209. package/dist/terminal/supports-color.d.ts.map +1 -0
  210. package/dist/terminal/supports-hyperlinks.d.ts +1 -3
  211. package/dist/terminal/supports-hyperlinks.d.ts.map +1 -0
  212. package/dist/terminal/supports-hyperlinks.js +1 -1
  213. package/dist/terminal/types.d.ts +1 -37
  214. package/dist/terminal/types.d.ts.map +1 -0
  215. package/dist/terminal/wrap-ansi.d.ts +8 -0
  216. package/dist/terminal/wrap-ansi.d.ts.map +1 -0
  217. package/dist/terminal/wrap-ansi.js +190 -0
  218. package/dist/{token-utils.d.ts → tokens/counter.d.ts} +1 -0
  219. package/dist/tokens/counter.d.ts.map +1 -0
  220. package/dist/{token-utils.js → tokens/counter.js} +1 -1
  221. package/dist/tokens/manage-output.d.ts +34 -0
  222. package/dist/tokens/manage-output.d.ts.map +1 -0
  223. package/dist/tokens/manage-output.js +44 -0
  224. package/dist/{token-tracker.d.ts → tokens/tracker.d.ts} +1 -0
  225. package/dist/tokens/tracker.d.ts.map +1 -0
  226. package/dist/tool-executor.d.ts +28 -0
  227. package/dist/tool-executor.d.ts.map +1 -0
  228. package/dist/tool-executor.js +74 -0
  229. package/dist/tools/agent.d.ts +3 -2
  230. package/dist/tools/agent.d.ts.map +1 -0
  231. package/dist/tools/agent.js +7 -4
  232. package/dist/tools/bash-utils.d.ts +7 -0
  233. package/dist/tools/bash-utils.d.ts.map +1 -0
  234. package/dist/tools/bash-utils.js +212 -0
  235. package/dist/tools/bash.d.ts +9 -7
  236. package/dist/tools/bash.d.ts.map +1 -0
  237. package/dist/tools/bash.js +95 -212
  238. package/dist/tools/code-interpreter.d.ts +1 -0
  239. package/dist/tools/code-interpreter.d.ts.map +1 -0
  240. package/dist/tools/code-interpreter.js +33 -8
  241. package/dist/tools/delete-file.d.ts +5 -3
  242. package/dist/tools/delete-file.d.ts.map +1 -0
  243. package/dist/tools/delete-file.js +47 -33
  244. package/dist/tools/directory-tree.d.ts +10 -1
  245. package/dist/tools/directory-tree.d.ts.map +1 -0
  246. package/dist/tools/directory-tree.js +91 -8
  247. package/dist/tools/dynamic-tool-loader.d.ts +12 -0
  248. package/dist/tools/dynamic-tool-loader.d.ts.map +1 -0
  249. package/dist/tools/dynamic-tool-loader.js +280 -0
  250. package/dist/tools/dynamic-tool-parser.d.ts +20 -0
  251. package/dist/tools/dynamic-tool-parser.d.ts.map +1 -0
  252. package/dist/tools/dynamic-tool-parser.js +21 -0
  253. package/dist/tools/edit-file.d.ts +10 -2
  254. package/dist/tools/edit-file.d.ts.map +1 -0
  255. package/dist/tools/edit-file.js +117 -40
  256. package/dist/tools/file-editing-utils.d.ts +2 -0
  257. package/dist/tools/file-editing-utils.d.ts.map +1 -0
  258. package/dist/tools/file-editing-utils.js +135 -0
  259. package/dist/tools/filesystem-utils.d.ts +6 -21
  260. package/dist/tools/filesystem-utils.d.ts.map +1 -0
  261. package/dist/tools/filesystem-utils.js +96 -148
  262. package/dist/tools/git-utils.d.ts +1 -0
  263. package/dist/tools/git-utils.d.ts.map +1 -0
  264. package/dist/tools/grep.d.ts +5 -3
  265. package/dist/tools/grep.d.ts.map +1 -0
  266. package/dist/tools/grep.js +67 -27
  267. package/dist/tools/index.d.ts +10 -14
  268. package/dist/tools/index.d.ts.map +1 -0
  269. package/dist/tools/index.js +33 -22
  270. package/dist/tools/move-file.d.ts +1 -0
  271. package/dist/tools/move-file.d.ts.map +1 -0
  272. package/dist/tools/move-file.js +12 -5
  273. package/dist/tools/read-file.d.ts +2 -1
  274. package/dist/tools/read-file.d.ts.map +1 -0
  275. package/dist/tools/read-file.js +13 -6
  276. package/dist/tools/read-multiple-files.d.ts +2 -1
  277. package/dist/tools/read-multiple-files.d.ts.map +1 -0
  278. package/dist/tools/read-multiple-files.js +90 -9
  279. package/dist/tools/save-file.d.ts +5 -3
  280. package/dist/tools/save-file.d.ts.map +1 -0
  281. package/dist/tools/save-file.js +64 -36
  282. package/dist/tools/think.d.ts +1 -0
  283. package/dist/tools/think.d.ts.map +1 -0
  284. package/dist/tools/think.js +5 -1
  285. package/dist/tools/types.d.ts +14 -1
  286. package/dist/tools/types.d.ts.map +1 -0
  287. package/dist/tools/web-fetch.d.ts +4 -2
  288. package/dist/tools/web-fetch.d.ts.map +1 -0
  289. package/dist/tools/web-fetch.js +2 -2
  290. package/dist/tools/web-search.d.ts +2 -1
  291. package/dist/tools/web-search.d.ts.map +1 -0
  292. package/dist/tools/web-search.js +46 -11
  293. package/dist/utils/filesystem.d.ts +23 -0
  294. package/dist/utils/filesystem.d.ts.map +1 -0
  295. package/dist/utils/filesystem.js +140 -0
  296. package/dist/utils/filetype-detection.d.ts +3 -0
  297. package/dist/utils/filetype-detection.d.ts.map +1 -0
  298. package/dist/utils/filetype-detection.js +112 -0
  299. package/dist/utils/glob.d.ts +52 -0
  300. package/dist/utils/glob.d.ts.map +1 -0
  301. package/dist/utils/glob.js +376 -0
  302. package/dist/utils/ignore.d.ts +104 -0
  303. package/dist/utils/ignore.d.ts.map +1 -0
  304. package/dist/utils/ignore.js +649 -0
  305. package/dist/utils/process.d.ts +10 -1
  306. package/dist/utils/process.d.ts.map +1 -0
  307. package/dist/utils/process.js +104 -5
  308. package/dist/utils/zod-utils.d.ts +4 -0
  309. package/dist/utils/zod-utils.d.ts.map +1 -0
  310. package/dist/utils/zod-utils.js +7 -0
  311. package/dist/version.d.ts +1 -0
  312. package/dist/version.d.ts.map +1 -0
  313. package/package.json +32 -30
  314. package/dist/tools/command-validation.d.ts +0 -12
  315. package/dist/tools/command-validation.js +0 -113
  316. /package/dist/{token-tracker.js → tokens/tracker.js} +0 -0
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Custom error classes for terminal prompts
3
+ */
4
+ export declare class PromptError extends Error {
5
+ constructor(message: string, options?: ErrorOptions);
6
+ }
7
+ export declare class PromptAbortError extends PromptError {
8
+ constructor(message?: string);
9
+ }
10
+ export declare class PromptCancelError extends PromptError {
11
+ constructor(message?: string);
12
+ }
13
+ export declare class PromptValidationError extends PromptError {
14
+ constructor(message: string);
15
+ }
16
+ export declare function isAbortError(error: unknown): error is PromptAbortError;
17
+ export declare function isCancelError(error: unknown): error is PromptCancelError;
18
+ export declare function isPromptError(error: unknown): error is PromptError;
19
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../source/terminal/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIpD;AAED,qBAAa,gBAAiB,SAAQ,WAAW;gBACnC,OAAO,SAAmB;CAIvC;AAED,qBAAa,iBAAkB,SAAQ,WAAW;gBACpC,OAAO,SAA6B;CAIjD;AAED,qBAAa,qBAAsB,SAAQ,WAAW;gBACxC,OAAO,EAAE,MAAM;CAI5B;AAGD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAEtE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAExE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Custom error classes for terminal prompts
3
+ */
4
+ export class PromptError extends Error {
5
+ constructor(message, options) {
6
+ super(message, options);
7
+ this.name = "PromptError";
8
+ }
9
+ }
10
+ export class PromptAbortError extends PromptError {
11
+ constructor(message = "Prompt aborted") {
12
+ super(message);
13
+ this.name = "PromptAbortError";
14
+ }
15
+ }
16
+ export class PromptCancelError extends PromptError {
17
+ constructor(message = "Prompt cancelled by user") {
18
+ super(message);
19
+ this.name = "PromptCancelError";
20
+ }
21
+ }
22
+ export class PromptValidationError extends PromptError {
23
+ constructor(message) {
24
+ super(message);
25
+ this.name = "PromptValidationError";
26
+ }
27
+ }
28
+ // Type guards for error handling
29
+ export function isAbortError(error) {
30
+ return error instanceof Error && error.name === "PromptAbortError";
31
+ }
32
+ export function isCancelError(error) {
33
+ return error instanceof Error && error.name === "PromptCancelError";
34
+ }
35
+ export function isPromptError(error) {
36
+ return error instanceof PromptError;
37
+ }
@@ -29,20 +29,10 @@ export declare function getTerminalSize(): {
29
29
  * Word wrap text to the specified width
30
30
  */
31
31
  export declare function wordWrap(text: string, width: number): string;
32
- export declare const ESC = "\u001B[";
33
- export declare const OSC = "\u001B]";
34
- export declare const BEL = "\u0007";
35
- export declare const SEP = ";";
36
32
  export declare const link: (text: string, url: string) => string;
37
33
  export declare const image: (data: string | Buffer, options?: {
38
34
  width?: number | string;
39
35
  height?: number | string;
40
36
  preserveAspectRatio?: boolean;
41
37
  }) => string;
42
- export declare function ansiRegex({ onlyFirst }?: {
43
- onlyFirst?: boolean | undefined;
44
- }): RegExp;
45
- /**
46
- * Strip ANSI escape sequences from a string
47
- */
48
- export declare function stripAnsi(s: string): string;
38
+ //# sourceMappingURL=formatting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../source/terminal/formatting.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAGlC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAM7C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAMpD;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAgBnE;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI5D;AA2CD,eAAO,MAAM,IAAI,GAAI,MAAM,MAAM,EAAE,KAAK,MAAM,WAO7C,CAAC;AAEF,eAAO,MAAM,KAAK,GAChB,MAAM,MAAM,GAAG,MAAM,EACrB,UAAS;IACP,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC1B,WAiBP,CAAC"}
@@ -99,10 +99,10 @@ function wrapLine(line, width) {
99
99
  }
100
100
  return wrappedLines.join("\n");
101
101
  }
102
- export const ESC = "\u001B[";
103
- export const OSC = "\u001B]";
104
- export const BEL = "\u0007";
105
- export const SEP = ";";
102
+ // const ESC = "\u001B[";
103
+ const OSC = "\u001B]";
104
+ const BEL = "\u0007";
105
+ const SEP = ";";
106
106
  export const link = (text, url) => {
107
107
  if (supportsHyperlinks.stdout) {
108
108
  return [OSC, "8", SEP, SEP, url, BEL, text, OSC, "8", SEP, SEP, BEL].join("");
@@ -122,19 +122,3 @@ export const image = (data, options = {}) => {
122
122
  }
123
123
  return `${returnValue}:${Buffer.from(data).toString("base64")}${BEL}`;
124
124
  };
125
- export function ansiRegex({ onlyFirst = false } = {}) {
126
- // Valid string terminator sequences are BEL, ESC\, and 0x9c
127
- const st = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
128
- const pattern = [
129
- `[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${st})`,
130
- "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))",
131
- ].join("|");
132
- return new RegExp(pattern, onlyFirst ? undefined : "g");
133
- }
134
- /**
135
- * Strip ANSI escape sequences from a string
136
- */
137
- export function stripAnsi(s) {
138
- // biome-ignore lint/suspicious/noControlCharactersInRegex: need to detect ansi control characters
139
- return s.replace(/\x1B\[[0-?]*[ -/]*[@-~]/g, "");
140
- }
@@ -0,0 +1,53 @@
1
+ import type { Theme } from "./theme.ts";
2
+ /**
3
+ * Options passed to [[highlight]]
4
+ */
5
+ interface HighlightOptions {
6
+ /**
7
+ * Can be a name, file extension, alias etc. If omitted, tries to auto-detect language.
8
+ */
9
+ language?: string;
10
+ /**
11
+ * When present and evaluates to a true value, forces highlighting to finish even in case of
12
+ * detecting illegal syntax for the language instead of throwing an exception.
13
+ */
14
+ ignoreIllegals?: boolean;
15
+ /**
16
+ * Optional array of language names and aliases restricting detection to only those languages.
17
+ */
18
+ languageSubset?: string[];
19
+ /**
20
+ * Supply a custom theme where you override language tokens with own formatter functions. Every
21
+ * token that is not overriden falls back to the [[DEFAULT_THEME]]
22
+ */
23
+ theme: Theme;
24
+ }
25
+ /**
26
+ * Apply syntax highlighting to `code` with ASCII color codes. The language is automatically
27
+ * detected if not set.
28
+ *
29
+ * ```ts
30
+ * import {highlight} from './terminal/highlight/index.ts';
31
+ * import * as fs from 'node:fs';
32
+ *
33
+ * fs.readFile('package.json', 'utf-8', (err: any, json: string) => {
34
+ * console.log('package.json:');
35
+ * console.log(highlight(json));
36
+ * });
37
+ * ```
38
+ *
39
+ * @param code The code to highlight
40
+ * @param options Optional options
41
+ */
42
+ export declare function highlight(code: string, options: HighlightOptions): string;
43
+ /**
44
+ * Returns all supported languages
45
+ */
46
+ export declare function listLanguages(): string[];
47
+ /**
48
+ * Returns true if the language is supported
49
+ * @param name A language name, alias or file extension
50
+ */
51
+ export declare function supportsLanguage(name: string): boolean;
52
+ export {};
53
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/terminal/highlight/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAyDxC;;GAEG;AACH,UAAU,gBAAgB;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B;;;OAGG;IACH,KAAK,EAAE,KAAK,CAAC;CACd;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAWzE;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,EAAE,CAExC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD"}
@@ -0,0 +1,90 @@
1
+ import hljs from "highlight.js";
2
+ import * as parse5 from "parse5";
3
+ import { adapter as htmlparser2Adapter } from "parse5-htmlparser2-tree-adapter";
4
+ /**
5
+ * Identity function for tokens that should not be styled (returns the input string as-is).
6
+ */
7
+ const plain = (codePart) => codePart;
8
+ function colorizeNode(node, theme, context) {
9
+ switch (node.type) {
10
+ case "text": {
11
+ const text = node.data;
12
+ if (context === undefined) {
13
+ return (theme.default || plain)(text);
14
+ }
15
+ return text;
16
+ }
17
+ case "tag": {
18
+ const element = node;
19
+ const hljsClass = /hljs-(\w+)/.exec(element.attribs?.["class"] || "");
20
+ if (hljsClass) {
21
+ const token = hljsClass[1];
22
+ if (token) {
23
+ const nodeData = element.childNodes
24
+ ?.map((childNode) => colorizeNode(childNode, theme, token))
25
+ .join("") || "";
26
+ const themeToken = theme[token];
27
+ const themeFn = themeToken || plain;
28
+ return themeFn(nodeData);
29
+ }
30
+ }
31
+ // Return the data itself when the class name isn't prefixed with a highlight.js token prefix.
32
+ // This is common in instances of sublanguages (JSX, Markdown Code Blocks, etc.)
33
+ return (element.childNodes
34
+ ?.map((childNode) => colorizeNode(childNode, theme))
35
+ .join("") || "");
36
+ }
37
+ }
38
+ throw new Error(`Invalid node type ${node.type}`);
39
+ }
40
+ function colorize(code, theme) {
41
+ const fragment = parse5.parseFragment(code, {
42
+ treeAdapter: htmlparser2Adapter,
43
+ });
44
+ return (fragment.childNodes
45
+ ?.map((node) => colorizeNode(node, theme))
46
+ .join("") || "");
47
+ }
48
+ /**
49
+ * Apply syntax highlighting to `code` with ASCII color codes. The language is automatically
50
+ * detected if not set.
51
+ *
52
+ * ```ts
53
+ * import {highlight} from './terminal/highlight/index.ts';
54
+ * import * as fs from 'node:fs';
55
+ *
56
+ * fs.readFile('package.json', 'utf-8', (err: any, json: string) => {
57
+ * console.log('package.json:');
58
+ * console.log(highlight(json));
59
+ * });
60
+ * ```
61
+ *
62
+ * @param code The code to highlight
63
+ * @param options Optional options
64
+ */
65
+ export function highlight(code, options) {
66
+ let html;
67
+ if (options.language) {
68
+ html = hljs.highlight(code, {
69
+ language: options.language,
70
+ ignoreIllegals: options.ignoreIllegals,
71
+ }).value;
72
+ }
73
+ else {
74
+ html = hljs.highlightAuto(code, options.languageSubset).value;
75
+ }
76
+ return colorize(html, options.theme);
77
+ }
78
+ /**
79
+ * Returns all supported languages
80
+ */
81
+ export function listLanguages() {
82
+ return hljs.listLanguages();
83
+ }
84
+ /**
85
+ * Returns true if the language is supported
86
+ * @param name A language name, alias or file extension
87
+ */
88
+ export function supportsLanguage(name) {
89
+ return !!hljs.getLanguage(name);
90
+ }
@@ -0,0 +1,233 @@
1
+ /**
2
+ * A generic interface that holds all available language tokens.
3
+ */
4
+ interface Tokens<T> {
5
+ /**
6
+ * keyword in a regular Algol-style language
7
+ */
8
+ keyword?: T;
9
+ /**
10
+ * built-in or library object (constant, class, function)
11
+ */
12
+ built_in?: T;
13
+ /**
14
+ * user-defined type in a language with first-class syntactically significant types, like Haskell
15
+ */
16
+ type?: T;
17
+ /**
18
+ * special identifier for a built-in value ("true", "false", "null")
19
+ */
20
+ literal?: T;
21
+ /**
22
+ * number, including units and modifiers, if any.
23
+ */
24
+ number?: T;
25
+ /**
26
+ * literal regular expression
27
+ */
28
+ regexp?: T;
29
+ /**
30
+ * literal string, character
31
+ */
32
+ string?: T;
33
+ /**
34
+ * parsed section inside a literal string
35
+ */
36
+ subst?: T;
37
+ /**
38
+ * symbolic constant, interned string, goto label
39
+ */
40
+ symbol?: T;
41
+ /**
42
+ * class or class-level declaration (interfaces, traits, modules, etc)
43
+ */
44
+ class?: T;
45
+ /**
46
+ * function or method declaration
47
+ */
48
+ function?: T;
49
+ /**
50
+ * name of a class or a function at the place of declaration
51
+ */
52
+ title?: T;
53
+ /**
54
+ * block of function arguments (parameters) at the place of declaration
55
+ */
56
+ params?: T;
57
+ /**
58
+ * comment
59
+ */
60
+ comment?: T;
61
+ /**
62
+ * documentation markup within comments
63
+ */
64
+ doctag?: T;
65
+ /**
66
+ * flags, modifiers, annotations, processing instructions, preprocessor directive, etc
67
+ */
68
+ meta?: T;
69
+ /**
70
+ * keyword or built-in within meta construct
71
+ */
72
+ "meta-keyword"?: T;
73
+ /**
74
+ * string within meta construct
75
+ */
76
+ "meta-string"?: T;
77
+ /**
78
+ * heading of a section in a config file, heading in text markup
79
+ */
80
+ section?: T;
81
+ /**
82
+ * XML/HTML tag
83
+ */
84
+ tag?: T;
85
+ /**
86
+ * name of an XML tag, the first word in an s-expression
87
+ */
88
+ name?: T;
89
+ /**
90
+ * s-expression name from the language standard library
91
+ */
92
+ "builtin-name"?: T;
93
+ /**
94
+ * name of an attribute with no language defined semantics (keys in JSON, setting names in .ini), also sub-attribute within another highlighted object, like XML tag
95
+ */
96
+ attr?: T;
97
+ /**
98
+ * name of an attribute followed by a structured value part, like CSS properties
99
+ */
100
+ attribute?: T;
101
+ /**
102
+ * variable in a config or a template file, environment var expansion in a script
103
+ */
104
+ variable?: T;
105
+ /**
106
+ * list item bullet in text markup
107
+ */
108
+ bullet?: T;
109
+ /**
110
+ * code block in text markup
111
+ */
112
+ code?: T;
113
+ /**
114
+ * emphasis in text markup
115
+ */
116
+ emphasis?: T;
117
+ /**
118
+ * strong emphasis in text markup
119
+ */
120
+ strong?: T;
121
+ /**
122
+ * mathematical formula in text markup
123
+ */
124
+ formula?: T;
125
+ /**
126
+ * hyperlink in text markup
127
+ */
128
+ link?: T;
129
+ /**
130
+ * quotation in text markup
131
+ */
132
+ quote?: T;
133
+ /**
134
+ * tag selector in CSS
135
+ */
136
+ "selector-tag"?: T;
137
+ /**
138
+ * #id selector in CSS
139
+ */
140
+ "selector-id"?: T;
141
+ /**
142
+ * .class selector in CSS
143
+ */
144
+ "selector-class"?: T;
145
+ /**
146
+ * [attr] selector in CSS
147
+ */
148
+ "selector-attr"?: T;
149
+ /**
150
+ * :pseudo selector in CSS
151
+ */
152
+ "selector-pseudo"?: T;
153
+ /**
154
+ * tag of a template language
155
+ */
156
+ "template-tag"?: T;
157
+ /**
158
+ * variable in a template language
159
+ */
160
+ "template-variable"?: T;
161
+ /**
162
+ * added or changed line in a diff
163
+ */
164
+ addition?: T;
165
+ /**
166
+ * deleted line in a diff
167
+ */
168
+ deletion?: T;
169
+ }
170
+ /**
171
+ * Passed to [[highlight]] as the `theme` option. A theme is a map of language tokens to a function
172
+ * that takes in string value of the token and returns a new string with colorization applied
173
+ * (typically a [style](https://github.com/chalk/chalk) style), but you can also provide your own
174
+ * formatting functions.
175
+ *
176
+ * Example:
177
+ * ```ts
178
+ * import {Theme, plain} from './highlight/theme.ts';
179
+ * import style from '../terminal/style.ts';
180
+ *
181
+ * const myTheme: Theme = {
182
+ * keyword: style.red.bold,
183
+ * addition: style.green,
184
+ * deletion: style.red.strikethrough,
185
+ * number: plain
186
+ * };
187
+ * ```
188
+ */
189
+ export interface Theme extends Tokens<(codePart: string) => string> {
190
+ /**
191
+ * things not matched by any token
192
+ */
193
+ default?: (codePart: string) => string;
194
+ }
195
+ /**
196
+ * Stringifies a [[Theme]] with formatter functions to a JSON string.
197
+ *
198
+ * ```ts
199
+ * import style from '../terminal/style.ts';
200
+ * import {stringify} from './highlight/theme.ts';
201
+ * import * as fs from 'node:fs';
202
+ *
203
+ * const myTheme: Theme = {
204
+ * keyword: style.red.bold,
205
+ * addition: style.green,
206
+ * deletion: style.red.strikethrough,
207
+ * number: plain
208
+ * }
209
+ * const json = stringify(myTheme);
210
+ * fs.writeFile('mytheme.json', json, (err: any) => {
211
+ * if (err) throw err;
212
+ * console.log('Theme saved');
213
+ * });
214
+ * ```
215
+ */
216
+ export declare function stringify(theme: Theme): string;
217
+ /**
218
+ * Parses a JSON string into a [[Theme]] with formatter functions.
219
+ *
220
+ * ```ts
221
+ * import * as fs from 'node:fs';
222
+ * import {parse, highlight} from './highlight/index.ts';
223
+ *
224
+ * fs.readFile('mytheme.json', 'utf-8', (err: any, json: string) => {
225
+ * if (err) throw err;
226
+ * const code = highlight('SELECT * FROM table', {theme: parse(json)});
227
+ * console.log(code);
228
+ * });
229
+ * ```
230
+ */
231
+ export declare function parse(json: string): Theme;
232
+ export {};
233
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../source/terminal/highlight/theme.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,83 @@
1
+ import style from "../style.js";
2
+ /**
3
+ * Identity function for tokens that should not be styled (returns the input string as-is).
4
+ * See [[Theme]] for an example.
5
+ */
6
+ const plain = (codePart) => codePart;
7
+ /**
8
+ * Converts a [[JsonTheme]] with string values to a [[Theme]] with formatter functions. Used by [[parse]].
9
+ */
10
+ function fromJson(json) {
11
+ const theme = {};
12
+ for (const key of Object.keys(json)) {
13
+ // biome-ignore lint/suspicious/noExplicitAny: Dynamic theme access needed for highlight compatibility
14
+ const styleValue = json[key];
15
+ if (Array.isArray(styleValue)) {
16
+ // biome-ignore lint/suspicious/noExplicitAny: Dynamic theme access needed for highlight compatibility
17
+ theme[key] = styleValue.reduce((previous, current) =>
18
+ // biome-ignore lint/suspicious/noExplicitAny: Dynamic theme access needed for highlight compatibility
19
+ current === "plain" ? plain : previous[current], style);
20
+ }
21
+ else {
22
+ // biome-ignore lint/suspicious/noExplicitAny: Dynamic theme access needed for highlight compatibility
23
+ theme[key] = style[styleValue];
24
+ }
25
+ }
26
+ return theme;
27
+ }
28
+ /**
29
+ * Converts a [[Theme]] with formatter functions to a [[JsonTheme]] with string values. Used by [[stringify]].
30
+ */
31
+ function toJson(theme) {
32
+ // biome-ignore lint/suspicious/noExplicitAny: Dynamic theme access needed for highlight compatibility
33
+ const jsonTheme = {};
34
+ for (const key of Object.keys(theme)) {
35
+ // biome-ignore lint/suspicious/noExplicitAny: Dynamic theme access needed for highlight compatibility
36
+ const style = theme[key];
37
+ if (style?._styles) {
38
+ jsonTheme[key] = style._styles;
39
+ }
40
+ }
41
+ return jsonTheme;
42
+ }
43
+ /**
44
+ * Stringifies a [[Theme]] with formatter functions to a JSON string.
45
+ *
46
+ * ```ts
47
+ * import style from '../terminal/style.ts';
48
+ * import {stringify} from './highlight/theme.ts';
49
+ * import * as fs from 'node:fs';
50
+ *
51
+ * const myTheme: Theme = {
52
+ * keyword: style.red.bold,
53
+ * addition: style.green,
54
+ * deletion: style.red.strikethrough,
55
+ * number: plain
56
+ * }
57
+ * const json = stringify(myTheme);
58
+ * fs.writeFile('mytheme.json', json, (err: any) => {
59
+ * if (err) throw err;
60
+ * console.log('Theme saved');
61
+ * });
62
+ * ```
63
+ */
64
+ export function stringify(theme) {
65
+ return JSON.stringify(toJson(theme));
66
+ }
67
+ /**
68
+ * Parses a JSON string into a [[Theme]] with formatter functions.
69
+ *
70
+ * ```ts
71
+ * import * as fs from 'node:fs';
72
+ * import {parse, highlight} from './highlight/index.ts';
73
+ *
74
+ * fs.readFile('mytheme.json', 'utf-8', (err: any, json: string) => {
75
+ * if (err) throw err;
76
+ * const code = highlight('SELECT * FROM table', {theme: parse(json)});
77
+ * console.log(code);
78
+ * });
79
+ * ```
80
+ */
81
+ export function parse(json) {
82
+ return fromJson(JSON.parse(json));
83
+ }
@@ -4,8 +4,9 @@
4
4
  * Provides a user interface for interacting with Claude Code in the terminal.
5
5
  * Handles input/output, formatting, and display.
6
6
  */
7
- import { type ChalkInstance } from "chalk";
8
- import type { SpinnerInstance, TerminalConfig } from "./types.ts";
7
+ import { type StyleInstance } from "./style.ts";
8
+ import type { TerminalConfig } from "./types.ts";
9
+ export declare function getShell(): string;
9
10
  /**
10
11
  * Initialize the terminal interface
11
12
  */
@@ -15,7 +16,6 @@ export declare function initTerminal(config?: Partial<TerminalConfig>): Terminal
15
16
  */
16
17
  export declare class Terminal {
17
18
  private config;
18
- private activeSpinners;
19
19
  private terminalWidth;
20
20
  private terminalHeight;
21
21
  private isInteractive;
@@ -34,6 +34,16 @@ export declare class Terminal {
34
34
  * Clear the terminal screen
35
35
  */
36
36
  clear(): void;
37
+ /**
38
+ * Start progress indicator in terminal
39
+ * Sends terminal escape sequence to show progress animation
40
+ */
41
+ startProgress(): void;
42
+ /**
43
+ * Stop progress indicator in terminal
44
+ * Sends terminal escape sequence to hide progress animation
45
+ */
46
+ stopProgress(): void;
37
47
  /**
38
48
  * Display formatted content
39
49
  */
@@ -65,9 +75,9 @@ export declare class Terminal {
65
75
  write(input: string): void;
66
76
  writeln(input: string): void;
67
77
  lineBreak(): void;
68
- header(header: string, chalkFn?: ChalkInstance): void;
78
+ header(header: string, styleFn?: StyleInstance): void;
69
79
  box(header: string, content: string): Promise<void>;
70
- hr(chalkFn?: ChalkInstance): void;
80
+ hr(styleFn?: StyleInstance): void;
71
81
  /**
72
82
  * Create a clickable link in the terminal if supported
73
83
  */
@@ -79,10 +89,6 @@ export declare class Terminal {
79
89
  header?: string[];
80
90
  colWidths?: number[];
81
91
  }): void;
82
- /**
83
- * Create a spinner for showing progress
84
- */
85
- spinner(text: string, id?: string): SpinnerInstance;
86
92
  /**
87
93
  * Displays a horizontal progress bar in the console.
88
94
  * @param current The current value.
@@ -92,3 +98,4 @@ export declare class Terminal {
92
98
  private formatMarkdown;
93
99
  }
94
100
  export * from "./types.ts";
101
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/terminal/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,OAAc,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,wBAAgB,QAAQ,WAEvB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAE,OAAO,CAAC,cAAc,CAAM,GAAG,QAAQ,CAyB3E;AAED;;GAEG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,aAAa,CAAU;gBAEnB,MAAM,EAAE,cAAc;IAoBlC;;OAEG;IACH,kBAAkB;IAclB,QAAQ,CAAC,KAAK,EAAE,MAAM;IAItB,OAAO,IAAI,MAAM;IAWjB;;OAEG;IACH,cAAc,IAAI,IAAI;IAmCtB;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;;OAGG;IACH,aAAa,IAAI,IAAI;IAIrB;;;OAGG;IACH,YAAY,IAAI,IAAI;IAIpB;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,UAAQ,GAAG,IAAI;IAI5C;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAQhC;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAQ3B;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAQ9B;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAQ3B;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAQ5B;;OAEG;IACH,KAAK,IAAI,IAAI;IAoBb,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI1B,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI5B,SAAS;IAIT,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,aAA0B,GAAG,IAAI;IAQ3D,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoCzD,EAAE,CAAC,OAAO,GAAE,aAA0B,GAAG,IAAI;IAK7C;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAIvC;;OAEG;IACH,KAAK,CACH,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,EAC3B,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;KAAO,GACxD,IAAI;IAuEP;;;;OAIG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAiDxD,OAAO,CAAC,cAAc;CASvB;AAGD,cAAc,YAAY,CAAC"}