@vizejs/fresco 0.816.0 → 0.818.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.
Files changed (44) hide show
  1. package/dist/{app-CDSThgku.mjs → app-ByxmaQXv.mjs} +8 -119
  2. package/dist/app-ByxmaQXv.mjs.map +1 -0
  3. package/dist/ascii-font/index.d.mts +15 -0
  4. package/dist/ascii-font/index.d.mts.map +1 -1
  5. package/dist/ascii-font/index.mjs +0 -3
  6. package/dist/ascii-font/index.mjs.map +1 -1
  7. package/dist/components/index.d.mts +1 -1
  8. package/dist/components/index.mjs +1 -1
  9. package/dist/{components-CkggYTVQ.mjs → components-0LBWpsQe.mjs} +5 -116
  10. package/dist/components-0LBWpsQe.mjs.map +1 -0
  11. package/dist/composables/index.d.mts +3 -3
  12. package/dist/composables/index.mjs +3 -3
  13. package/dist/{composables-amARnyjm.mjs → composables-D1oKPS0m.mjs} +3 -15
  14. package/dist/composables-D1oKPS0m.mjs.map +1 -0
  15. package/dist/{index-BOV-0YqV.d.mts → index-C7_vgg04.d.mts} +64 -22
  16. package/dist/index-C7_vgg04.d.mts.map +1 -0
  17. package/dist/{index-DRDR_s-T.d.mts → index-Cb1yVHhF.d.mts} +983 -382
  18. package/dist/index-Cb1yVHhF.d.mts.map +1 -0
  19. package/dist/index.d.mts +4 -4
  20. package/dist/index.mjs +4 -30
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/qr-code/index.d.mts +29 -0
  23. package/dist/qr-code/index.d.mts.map +1 -1
  24. package/dist/qr-code/index.mjs +0 -3
  25. package/dist/qr-code/index.mjs.map +1 -1
  26. package/dist/testing/index.d.mts +23 -6
  27. package/dist/testing/index.d.mts.map +1 -1
  28. package/dist/testing/index.mjs +1 -42
  29. package/dist/testing/index.mjs.map +1 -1
  30. package/dist/{useApp-vIRJ5Th3.d.mts → useApp-CZwf8lOA.d.mts} +10 -7
  31. package/dist/useApp-CZwf8lOA.d.mts.map +1 -0
  32. package/dist/{useBoxMetrics-9FFVE-tA.mjs → useBoxMetrics-DyBYcQEp.mjs} +2 -22
  33. package/dist/useBoxMetrics-DyBYcQEp.mjs.map +1 -0
  34. package/dist/{useVirtualViewport-TxTapifg.d.mts → useVirtualViewport-CCWjx3oS.d.mts} +7 -1
  35. package/dist/useVirtualViewport-CCWjx3oS.d.mts.map +1 -0
  36. package/package.json +2 -2
  37. package/dist/app-CDSThgku.mjs.map +0 -1
  38. package/dist/components-CkggYTVQ.mjs.map +0 -1
  39. package/dist/composables-amARnyjm.mjs.map +0 -1
  40. package/dist/index-BOV-0YqV.d.mts.map +0 -1
  41. package/dist/index-DRDR_s-T.d.mts.map +0 -1
  42. package/dist/useApp-vIRJ5Th3.d.mts.map +0 -1
  43. package/dist/useBoxMetrics-9FFVE-tA.mjs.map +0 -1
  44. package/dist/useVirtualViewport-TxTapifg.d.mts.map +0 -1
@@ -1,4 +1,4 @@
1
- import { a as createVirtualViewport, i as VirtualViewportRange, n as VirtualViewport, o as useVirtualViewport, r as VirtualViewportOptions, t as VirtualScrollAlignment } from "../useVirtualViewport-TxTapifg.mjs";
2
- import { A as ImeManager, B as KeyHandler, C as useWindowSize, D as useStderr, E as UseStdoutReturn, F as useMouse, H as UseInputReturn, I as UsePasteOptions, L as usePaste, M as useIme, N as UseMouseOptions, O as useStdin, P as UseMouseReturn, R as InputHandler, S as WindowSize, T as UseStdinReturn, U as useInput, V as UseInputOptions, W as useKeyPress, _ as AnimationResult, a as KeymapStroke, b as CursorPosition, c as createKeymapResolver, d as useIsScreenReaderEnabled, f as BoxMetrics, i as KeymapResolver, j as UseImeOptions, k as useStdout, l as defineKeymap, m as useBoxMetrics, n as KeymapBinding, o as UseKeymapOptions, p as UseBoxMetricsResult, r as KeymapMatch, s as UseKeymapReturn, t as Keymap, u as useKeymap, v as UseAnimationOptions, w as UseStderrReturn, x as useCursor, y as useAnimation, z as Key } from "../index-BOV-0YqV.mjs";
3
- import { a as provideFocusScope, i as UseFocusOptions, n as useApp, o as useFocus, r as FocusManager, s as useFocusManager, t as UseAppReturn } from "../useApp-vIRJ5Th3.mjs";
1
+ import { a as createVirtualViewport, i as VirtualViewportRange, n as VirtualViewport, o as useVirtualViewport, r as VirtualViewportOptions, t as VirtualScrollAlignment } from "../useVirtualViewport-CCWjx3oS.mjs";
2
+ import { A as ImeManager, B as KeyHandler, C as useWindowSize, D as useStderr, E as UseStdoutReturn, F as useMouse, H as UseInputReturn, I as UsePasteOptions, L as usePaste, M as useIme, N as UseMouseOptions, O as useStdin, P as UseMouseReturn, R as InputHandler, S as WindowSize, T as UseStdinReturn, U as useInput, V as UseInputOptions, W as useKeyPress, _ as AnimationResult, a as KeymapStroke, b as CursorPosition, c as createKeymapResolver, d as useIsScreenReaderEnabled, f as BoxMetrics, i as KeymapResolver, j as UseImeOptions, k as useStdout, l as defineKeymap, m as useBoxMetrics, n as KeymapBinding, o as UseKeymapOptions, p as UseBoxMetricsResult, r as KeymapMatch, s as UseKeymapReturn, t as Keymap, u as useKeymap, v as UseAnimationOptions, w as UseStderrReturn, x as useCursor, y as useAnimation, z as Key } from "../index-C7_vgg04.mjs";
3
+ import { a as provideFocusScope, i as UseFocusOptions, n as useApp, o as useFocus, r as FocusManager, s as useFocusManager, t as UseAppReturn } from "../useApp-CZwf8lOA.mjs";
4
4
  export { type AnimationResult, type BoxMetrics, type CursorPosition, type FocusManager, type ImeManager, type InputHandler, type Key, type KeyHandler, type Keymap, type KeymapBinding, type KeymapMatch, type KeymapResolver, type KeymapStroke, type UseAnimationOptions, type UseAppReturn, type UseBoxMetricsResult, type UseFocusOptions, type UseImeOptions, type UseInputOptions, type UseInputReturn, type UseKeymapOptions, type UseKeymapReturn, type UseMouseOptions, type UseMouseReturn, type UsePasteOptions, type UseStderrReturn, type UseStdinReturn, type UseStdoutReturn, type VirtualScrollAlignment, type VirtualViewport, type VirtualViewportOptions, type VirtualViewportRange, type WindowSize, createKeymapResolver, createVirtualViewport, defineKeymap, provideFocusScope, useAnimation, useApp, useBoxMetrics, useCursor, useFocus, useFocusManager, useIme, useInput, useIsScreenReaderEnabled, useKeyPress, useKeymap, useMouse, usePaste, useStderr, useStdin, useStdout, useVirtualViewport, useWindowSize };
@@ -1,4 +1,4 @@
1
- import { A as useFocusManager, C as useStdin, N as useApp, O as provideFocusScope, S as useStderr, k as useFocus, w as useStdout, y as useCursor } from "../app-CDSThgku.mjs";
2
- import { a as useInput, c as useIsScreenReaderEnabled, i as useMouse, n as createVirtualViewport, o as useKeyPress, r as useVirtualViewport, s as usePaste, t as useBoxMetrics } from "../useBoxMetrics-9FFVE-tA.mjs";
3
- import { a as useWindowSize, i as useAnimation, n as defineKeymap, o as useIme, r as useKeymap, t as createKeymapResolver } from "../composables-amARnyjm.mjs";
1
+ import { A as useFocusManager, C as useStdin, O as provideFocusScope, P as useApp, S as useStderr, k as useFocus, w as useStdout, y as useCursor } from "../app-ByxmaQXv.mjs";
2
+ import { a as useInput, c as useIsScreenReaderEnabled, i as useMouse, n as createVirtualViewport, o as useKeyPress, r as useVirtualViewport, s as usePaste, t as useBoxMetrics } from "../useBoxMetrics-DyBYcQEp.mjs";
3
+ import { a as useWindowSize, i as useAnimation, n as defineKeymap, o as useIme, r as useKeymap, t as createKeymapResolver } from "../composables-D1oKPS0m.mjs";
4
4
  export { createKeymapResolver, createVirtualViewport, defineKeymap, provideFocusScope, useAnimation, useApp, useBoxMetrics, useCursor, useFocus, useFocusManager, useIme, useInput, useIsScreenReaderEnabled, useKeyPress, useKeymap, useMouse, usePaste, useStderr, useStdin, useStdout, useVirtualViewport, useWindowSize };
@@ -1,10 +1,7 @@
1
- import { N as useApp } from "./app-CDSThgku.mjs";
2
- import { a as useInput } from "./useBoxMetrics-9FFVE-tA.mjs";
1
+ import { P as useApp } from "./app-ByxmaQXv.mjs";
2
+ import { a as useInput } from "./useBoxMetrics-DyBYcQEp.mjs";
3
3
  import { computed, onMounted, onUnmounted, reactive, readonly, ref, toValue, watch } from "vue";
4
4
  //#region src/composables/useIme.ts
5
- /**
6
- * useIme - IME (Input Method Editor) composable
7
- */
8
5
  const MODE_DISPLAY = {
9
6
  direct: "A",
10
7
  hiragana: "あ",
@@ -133,9 +130,6 @@ function useIme(options = {}) {
133
130
  }
134
131
  //#endregion
135
132
  //#region src/composables/useWindowSize.ts
136
- /**
137
- * useWindowSize - terminal dimensions.
138
- */
139
133
  function useWindowSize() {
140
134
  const { width, height } = useApp();
141
135
  return reactive({
@@ -149,9 +143,6 @@ function useWindowSize() {
149
143
  }
150
144
  //#endregion
151
145
  //#region src/composables/useAnimation.ts
152
- /**
153
- * useAnimation - Ink-compatible shared animation state.
154
- */
155
146
  const defaultAnimationInterval = 100;
156
147
  const maximumTimerInterval = 2147483647;
157
148
  const animationSubscribers = /* @__PURE__ */ new Map();
@@ -290,7 +281,6 @@ function sequenceKey(sequence) {
290
281
  ].filter(Boolean).join("+");
291
282
  }).join(" ");
292
283
  }
293
- /** Validate and freeze a typed command map. */
294
284
  function defineKeymap(bindings) {
295
285
  const seen = /* @__PURE__ */ new Set();
296
286
  const normalized = bindings.map((binding) => {
@@ -306,7 +296,6 @@ function defineKeymap(bindings) {
306
296
  });
307
297
  return Object.freeze(normalized);
308
298
  }
309
- /** Stateful matcher for single chords, Emacs multi-chords, and Vim-style sequences. */
310
299
  function createKeymapResolver(keymap) {
311
300
  let pending = [];
312
301
  const matchingBindings = (sequence) => keymap().filter((binding) => binding.sequence.length >= sequence.length && sequence.every((stroke, index) => strokesEqual(stroke, binding.sequence[index])));
@@ -340,7 +329,6 @@ function createKeymapResolver(keymap) {
340
329
  }
341
330
  };
342
331
  }
343
- /** Subscribe a typed command keymap to Fresco's normalized input stream. */
344
332
  function useKeymap(options) {
345
333
  const active = computed(() => toValue(options.active) ?? true);
346
334
  const resolver = createKeymapResolver(() => toValue(options.keymap));
@@ -377,4 +365,4 @@ function useKeymap(options) {
377
365
  //#endregion
378
366
  export { useWindowSize as a, useAnimation as i, defineKeymap as n, useIme as o, useKeymap as r, createKeymapResolver as t };
379
367
 
380
- //# sourceMappingURL=composables-amARnyjm.mjs.map
368
+ //# sourceMappingURL=composables-D1oKPS0m.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composables-D1oKPS0m.mjs","names":[],"sources":["../src/composables/useIme.ts","../src/composables/useWindowSize.ts","../src/composables/useAnimation.ts","../src/composables/useKeymap.ts"],"sourcesContent":["/**\n * useIme - IME (Input Method Editor) composable\n */\n\nimport { ref, computed, type Ref } from \"vue\";\n\n/** Initial composition mode and optional mode, preedit, and commit notifications. */\nexport interface UseImeOptions {\n /** Initial composition mode; the manager still starts disabled. @default \"direct\" */\n mode?: ImeMode;\n /** Receive composition-mode changes. @default undefined */\n onModeChange?: (mode: ImeMode) => void;\n /** Receive updated preedit text and cursor state. @default undefined */\n onCompositionUpdate?: (text: string, cursor: number) => void;\n /** Receive committed composition text. @default undefined */\n onCommit?: (text: string) => void;\n}\n\n/** Composition-mode identifiers exposed by the terminal input manager. */\nexport type ImeMode =\n | \"direct\"\n | \"hiragana\"\n | \"katakana\"\n | \"half-katakana\"\n | \"full-alpha\"\n | \"pinyin\"\n | \"hangul\";\n\n/** Composition activation, preedit, cursor, candidate state, and synchronous editing commands. */\nexport interface ImeManager {\n /** Whether IME is active */\n isActive: Ref<boolean>;\n /** Current input mode */\n mode: Ref<ImeMode>;\n /** Whether currently composing */\n isComposing: Ref<boolean>;\n /** Preedit text */\n preedit: Ref<string>;\n /** Cursor position in preedit */\n preeditCursor: Ref<number>;\n /** Candidate list */\n candidates: Ref<string[]>;\n /** Selected candidate index */\n selectedCandidate: Ref<number>;\n /** Mode display name */\n modeDisplay: Ref<string>;\n /** Enable IME */\n enable: () => void;\n /** Disable IME */\n disable: () => void;\n /** Set input mode */\n setMode: (mode: ImeMode) => void;\n /** Handle key event for IME */\n handleKey: (key: string, modifiers: { ctrl: boolean; alt: boolean }) => boolean;\n /** Commit current composition */\n commit: () => void;\n /** Cancel current composition */\n cancel: () => void;\n /** Select next candidate */\n nextCandidate: () => void;\n /** Select previous candidate */\n prevCandidate: () => void;\n /** Select candidate by number (1-9) */\n selectCandidate: (num: number) => void;\n}\n\nconst MODE_DISPLAY: Record<ImeMode, string> = {\n direct: \"A\",\n hiragana: \"あ\",\n katakana: \"ア\",\n \"half-katakana\": \"ア\",\n \"full-alpha\": \"A\",\n pinyin: \"拼\",\n hangul: \"한\",\n};\n\n/** Create initially disabled composition state with caller-supplied conversion candidates. */\nexport function useIme(options: UseImeOptions = {}): ImeManager {\n const { mode: initialMode = \"direct\", onModeChange, onCompositionUpdate, onCommit } = options;\n\n const isActive = ref(false);\n const mode = ref<ImeMode>(initialMode);\n const isComposing = ref(false);\n const preedit = ref(\"\");\n const preeditCursor = ref(0);\n const candidates = ref<string[]>([]);\n const selectedCandidate = ref(0);\n\n const modeDisplay = computed(() => MODE_DISPLAY[mode.value] ?? \"A\");\n\n const enable = () => {\n isActive.value = true;\n };\n\n const disable = () => {\n isActive.value = false;\n cancel();\n };\n\n const setMode = (newMode: ImeMode) => {\n if (mode.value !== newMode) {\n cancel();\n mode.value = newMode;\n onModeChange?.(newMode);\n }\n };\n\n const handleKey = (key: string, modifiers: { ctrl: boolean; alt: boolean }): boolean => {\n if (!isActive.value || mode.value === \"direct\") {\n return false;\n }\n\n // IME mode toggle (usually Ctrl+Space or similar)\n // If we're here, mode is not 'direct' (filtered above), so toggle to 'direct'\n if (modifiers.ctrl && key === \" \") {\n setMode(\"direct\");\n return true;\n }\n\n // Handle composition\n if (isComposing.value) {\n switch (key) {\n case \"enter\":\n commit();\n return true;\n case \"escape\":\n cancel();\n return true;\n case \"backspace\":\n if (preedit.value.length > 0) {\n preedit.value = preedit.value.slice(0, -1);\n preeditCursor.value = Math.min(preeditCursor.value, preedit.value.length);\n onCompositionUpdate?.(preedit.value, preeditCursor.value);\n return true;\n }\n break;\n case \"space\":\n // Convert / select candidate\n if (candidates.value.length > 0) {\n nextCandidate();\n return true;\n }\n break;\n }\n\n // Number for candidate selection\n if (/^[1-9]$/.test(key)) {\n selectCandidate(parseInt(key, 10));\n return true;\n }\n }\n\n // Start/continue composition for printable characters\n if (key.length === 1 && !modifiers.ctrl && !modifiers.alt) {\n if (!isComposing.value) {\n isComposing.value = true;\n }\n preedit.value += key;\n preeditCursor.value = preedit.value.length;\n onCompositionUpdate?.(preedit.value, preeditCursor.value);\n return true;\n }\n\n return false;\n };\n\n const commit = () => {\n if (preedit.value) {\n const text = candidates.value[selectedCandidate.value] ?? preedit.value;\n onCommit?.(text);\n }\n preedit.value = \"\";\n preeditCursor.value = 0;\n candidates.value = [];\n selectedCandidate.value = 0;\n isComposing.value = false;\n };\n\n const cancel = () => {\n preedit.value = \"\";\n preeditCursor.value = 0;\n candidates.value = [];\n selectedCandidate.value = 0;\n isComposing.value = false;\n };\n\n const nextCandidate = () => {\n if (candidates.value.length > 0) {\n selectedCandidate.value = (selectedCandidate.value + 1) % candidates.value.length;\n }\n };\n\n const prevCandidate = () => {\n if (candidates.value.length > 0) {\n selectedCandidate.value =\n (selectedCandidate.value - 1 + candidates.value.length) % candidates.value.length;\n }\n };\n\n const selectCandidate = (num: number) => {\n if (num >= 1 && num <= candidates.value.length) {\n selectedCandidate.value = num - 1;\n commit();\n }\n };\n\n return {\n isActive,\n mode,\n isComposing,\n preedit,\n preeditCursor,\n candidates,\n selectedCandidate,\n modeDisplay,\n enable,\n disable,\n setMode,\n handleKey,\n commit,\n cancel,\n nextCandidate,\n prevCandidate,\n selectCandidate,\n };\n}\n","/**\n * useWindowSize - terminal dimensions.\n */\n\nimport { reactive } from \"vue\";\nimport { useApp } from \"./useApp.js\";\n\n/** Reactive terminal dimensions exposed as column and row getters. */\nexport interface WindowSize {\n columns: number;\n rows: number;\n}\n\n/** Read application dimensions through reactive column and row getters. */\nexport function useWindowSize() {\n const { width, height } = useApp();\n\n return reactive({\n get columns() {\n return width.value;\n },\n get rows() {\n return height.value;\n },\n }) as WindowSize;\n}\n","/**\n * useAnimation - Ink-compatible shared animation state.\n */\n\nimport { computed, onMounted, onUnmounted, reactive, watch } from \"vue\";\n\n/** Tick interval and activation for component-scoped shared animation scheduling. */\nexport interface UseAnimationOptions {\n /** Tick interval in milliseconds; finite values clamp to 1 through 2,147,483,647 and nonfinite values use 100. @default 100 */\n interval?: number;\n /** Whether the shared animation subscription is active. @default true */\n isActive?: boolean;\n}\n\n/** Reactive frame count, elapsed milliseconds, last tick delta, and reset command. */\nexport interface AnimationResult {\n frame: number;\n time: number;\n delta: number;\n reset: () => void;\n}\n\nconst defaultAnimationInterval = 100;\nconst maximumTimerInterval = 2_147_483_647;\n\ntype AnimationCallback = (currentTime: number) => void;\n\ninterface AnimationSubscriber {\n callback: AnimationCallback;\n interval: number;\n startTime: number;\n nextDueTime: number;\n}\n\nconst animationSubscribers = new Map<AnimationCallback, AnimationSubscriber>();\nlet animationTimer: ReturnType<typeof setTimeout> | null = null;\n\nfunction currentTime(): number {\n return performance.now();\n}\n\nfunction normalizeAnimationInterval(interval: number): number {\n if (!Number.isFinite(interval)) {\n return defaultAnimationInterval;\n }\n\n return Math.min(maximumTimerInterval, Math.max(1, interval));\n}\n\nfunction clearAnimationTimer() {\n if (!animationTimer) return;\n clearTimeout(animationTimer);\n animationTimer = null;\n}\n\nfunction scheduleAnimationTick() {\n clearAnimationTimer();\n if (animationSubscribers.size === 0) return;\n\n let nextDueTime = Number.POSITIVE_INFINITY;\n for (const subscriber of animationSubscribers.values()) {\n nextDueTime = Math.min(nextDueTime, subscriber.nextDueTime);\n }\n\n animationTimer = setTimeout(\n () => {\n animationTimer = null;\n const now = currentTime();\n\n for (const subscriber of animationSubscribers.values()) {\n if (now < subscriber.nextDueTime) continue;\n\n subscriber.callback(now);\n\n const elapsedTime = now - subscriber.startTime;\n const elapsedFrames = Math.floor(elapsedTime / subscriber.interval) + 1;\n subscriber.nextDueTime = subscriber.startTime + elapsedFrames * subscriber.interval;\n }\n\n scheduleAnimationTick();\n },\n Math.max(0, nextDueTime - currentTime()),\n );\n}\n\nfunction subscribeToAnimation(callback: AnimationCallback, interval: number) {\n const startTime = currentTime();\n animationSubscribers.set(callback, {\n callback,\n interval,\n startTime,\n nextDueTime: startTime + interval,\n });\n scheduleAnimationTick();\n\n return {\n startTime,\n unsubscribe() {\n animationSubscribers.delete(callback);\n scheduleAnimationTick();\n },\n };\n}\n\n/** Subscribe after mount to shared animation ticks; restart measurements on option changes and unsubscribe on unmount. */\nexport function useAnimation(options: UseAnimationOptions = {}): AnimationResult {\n const safeInterval = computed(() =>\n normalizeAnimationInterval(options.interval ?? defaultAnimationInterval),\n );\n const active = computed(() => options.isActive ?? true);\n let unsubscribe: (() => void) | null = null;\n let startedAt = currentTime();\n let previousTick = startedAt;\n\n const state = reactive<AnimationResult>({\n frame: 0,\n time: 0,\n delta: 0,\n reset: () => {\n if (active.value) {\n start();\n } else {\n resetState(currentTime());\n }\n },\n });\n\n const resetState = (now: number) => {\n startedAt = now;\n previousTick = now;\n state.frame = 0;\n state.time = 0;\n state.delta = 0;\n };\n\n const tick = (now: number) => {\n const elapsed = now - startedAt;\n state.frame = Math.floor(elapsed / safeInterval.value);\n state.time = elapsed;\n state.delta = now - previousTick;\n previousTick = now;\n };\n\n const stop = () => {\n unsubscribe?.();\n unsubscribe = null;\n };\n\n const start = () => {\n stop();\n resetState(currentTime());\n const subscription = subscribeToAnimation(tick, safeInterval.value);\n startedAt = subscription.startTime;\n previousTick = subscription.startTime;\n unsubscribe = () => subscription.unsubscribe();\n };\n\n onMounted(() => {\n if (active.value) {\n start();\n }\n });\n\n watch([active, safeInterval], ([isActive]) => {\n if (isActive) {\n start();\n } else {\n stop();\n }\n });\n\n onUnmounted(stop);\n\n return state;\n}\n","import {\n computed,\n onUnmounted,\n readonly,\n ref,\n toValue,\n watch,\n type MaybeRefOrGetter,\n type Ref,\n} from \"vue\";\nimport { useInput } from \"./useInput.js\";\n\n/** One normalized key chord with exact modifier matching. */\nexport interface KeymapStroke {\n readonly key: string;\n readonly ctrl?: boolean;\n readonly alt?: boolean;\n readonly shift?: boolean;\n readonly meta?: boolean;\n}\n\n/** Command associated with a nonempty sequence of key chords. */\nexport interface KeymapBinding<Command extends string = string> {\n readonly command: Command;\n readonly sequence: readonly [KeymapStroke, ...KeymapStroke[]];\n}\n\n/** Readonly collection of terminal command bindings. */\nexport type Keymap<Command extends string = string> = readonly KeymapBinding<Command>[];\n\n/** Completed command and binding, or the current pending-prefix state. */\nexport interface KeymapMatch<Command extends string> {\n readonly command?: Command;\n readonly binding?: KeymapBinding<Command>;\n readonly pending: boolean;\n}\n\n/** Stateful key-chord sequence matcher with explicit reset. */\nexport interface KeymapResolver<Command extends string> {\n readonly pendingSequence: readonly KeymapStroke[];\n feed(stroke: KeymapStroke): KeymapMatch<Command>;\n reset(): void;\n}\n\n/** Keymap activation, partial-sequence deadline, and command delivery callback. */\nexport interface UseKeymapOptions<Command extends string> {\n readonly keymap: MaybeRefOrGetter<Keymap<Command>>;\n /** Whether this component receives command chords. @default true */\n readonly active?: MaybeRefOrGetter<boolean>;\n /** Milliseconds before clearing an incomplete sequence; zero or negative values disable deadline clearing. @default 1000 */\n readonly sequenceTimeout?: number;\n readonly onCommand: (command: Command, binding: KeymapBinding<Command>) => void;\n}\n\n/** Effective activation, readonly pending chord sequence, and reset command. */\nexport interface UseKeymapReturn {\n readonly isActive: Readonly<Ref<boolean>>;\n readonly pendingSequence: Readonly<Ref<readonly KeymapStroke[]>>;\n reset(): void;\n}\n\nfunction normalizedKey(key: string): string {\n const lower = key.toLowerCase();\n if (lower === \"return\") return \"enter\";\n if (lower === \"esc\") return \"escape\";\n if (lower === \"pagedown\") return \"pagedown\";\n if (lower === \"pageup\") return \"pageup\";\n return lower;\n}\n\nfunction normalizedStroke(stroke: KeymapStroke): Required<KeymapStroke> {\n return {\n key: normalizedKey(stroke.key),\n ctrl: stroke.ctrl ?? false,\n alt: stroke.alt ?? false,\n shift: stroke.shift ?? false,\n meta: stroke.meta ?? false,\n };\n}\n\nfunction strokesEqual(left: KeymapStroke, right: KeymapStroke): boolean {\n const normalizedLeft = normalizedStroke(left);\n const normalizedRight = normalizedStroke(right);\n return (\n normalizedLeft.key === normalizedRight.key &&\n normalizedLeft.ctrl === normalizedRight.ctrl &&\n normalizedLeft.alt === normalizedRight.alt &&\n normalizedLeft.shift === normalizedRight.shift &&\n normalizedLeft.meta === normalizedRight.meta\n );\n}\n\nfunction sequenceKey(sequence: readonly KeymapStroke[]): string {\n return sequence\n .map((stroke) => {\n const normalized = normalizedStroke(stroke);\n return [\n normalized.ctrl ? \"ctrl\" : \"\",\n normalized.alt ? \"alt\" : \"\",\n normalized.shift ? \"shift\" : \"\",\n normalized.meta ? \"meta\" : \"\",\n normalized.key,\n ]\n .filter(Boolean)\n .join(\"+\");\n })\n .join(\" \");\n}\n\n/** Validate and freeze a typed command map. */\nexport function defineKeymap<const Command extends string>(\n bindings: readonly KeymapBinding<Command>[],\n): Keymap<Command> {\n const seen = new Set<string>();\n const normalized = bindings.map((binding) => {\n if (binding.sequence.length === 0) throw new TypeError(\"keymap sequences must not be empty\");\n const sequence = binding.sequence.map(normalizedStroke) as [\n Required<KeymapStroke>,\n ...Required<KeymapStroke>[],\n ];\n const key = sequenceKey(sequence);\n if (seen.has(key)) throw new TypeError(`duplicate keymap sequence: ${key}`);\n seen.add(key);\n return Object.freeze({ command: binding.command, sequence: Object.freeze(sequence) });\n });\n return Object.freeze(normalized);\n}\n\n/** Stateful matcher for single chords, Emacs multi-chords, and Vim-style sequences. */\nexport function createKeymapResolver<Command extends string>(\n keymap: () => Keymap<Command>,\n): KeymapResolver<Command> {\n let pending: KeymapStroke[] = [];\n\n const matchingBindings = (sequence: readonly KeymapStroke[]) =>\n keymap().filter(\n (binding) =>\n binding.sequence.length >= sequence.length &&\n sequence.every((stroke, index) => strokesEqual(stroke, binding.sequence[index]!)),\n );\n\n const feed = (stroke: KeymapStroke): KeymapMatch<Command> => {\n const next = [...pending, normalizedStroke(stroke)];\n let matches = matchingBindings(next);\n let candidate = next;\n if (matches.length === 0 && pending.length > 0) {\n candidate = [normalizedStroke(stroke)];\n matches = matchingBindings(candidate);\n }\n const exact = matches.find((binding) => binding.sequence.length === candidate.length);\n if (exact) {\n pending = [];\n return { command: exact.command, binding: exact, pending: false };\n }\n pending = matches.length > 0 ? candidate : [];\n return { pending: pending.length > 0 };\n };\n\n return {\n get pendingSequence() {\n return pending;\n },\n feed,\n reset: () => {\n pending = [];\n },\n };\n}\n\n/** Subscribe a typed command keymap to Fresco's normalized input stream. */\nexport function useKeymap<Command extends string>(\n options: UseKeymapOptions<Command>,\n): UseKeymapReturn {\n const active = computed(() => toValue(options.active) ?? true);\n const resolver = createKeymapResolver(() => toValue(options.keymap));\n const pendingSequence = ref<readonly KeymapStroke[]>([]);\n const timeout = Math.max(0, options.sequenceTimeout ?? 1_000);\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const reset = () => {\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n resolver.reset();\n pendingSequence.value = [];\n };\n\n watch(\n () => toValue(options.keymap),\n () => reset(),\n );\n onUnmounted(reset);\n\n useInput({\n isActive: active,\n onKey: (key, modifiers) => {\n if (timer !== undefined) clearTimeout(timer);\n const match = resolver.feed({ key, ...modifiers });\n pendingSequence.value = [...resolver.pendingSequence];\n if (match.command !== undefined && match.binding !== undefined) {\n options.onCommand(match.command, match.binding);\n } else if (match.pending && timeout > 0) {\n timer = setTimeout(reset, timeout);\n }\n },\n });\n\n return { isActive: active, pendingSequence: readonly(pendingSequence), reset };\n}\n"],"mappings":";;;;AAkEA,MAAM,eAAwC;CAC5C,QAAQ;CACR,UAAU;CACV,UAAU;CACV,iBAAiB;CACjB,cAAc;CACd,QAAQ;CACR,QAAQ;AACV;AAGA,SAAgB,OAAO,UAAyB,CAAC,GAAe;CAC9D,MAAM,EAAE,MAAM,cAAc,UAAU,cAAc,qBAAqB,aAAa;CAEtF,MAAM,WAAW,IAAI,KAAK;CAC1B,MAAM,OAAO,IAAa,WAAW;CACrC,MAAM,cAAc,IAAI,KAAK;CAC7B,MAAM,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D,QAAQ,UAAU,MAAM,SAAS,MAAM,OAAO;QACzC,IAAI,MAAM,WAAW,UAAU,GACpC,QAAQ,WAAW,OAAO,OAAO;EAErC;CACF,CAAC;CAED,OAAO;EAAE,UAAU;EAAQ,iBAAiB,SAAS,eAAe;EAAG;CAAM;AAC/E"}
@@ -3,6 +3,7 @@ import { InjectionKey, MaybeRefOrGetter, Ref } from "vue";
3
3
  import { LayoutResultNapi } from "@vizejs/fresco-native";
4
4
 
5
5
  //#region src/composables/useInput.d.ts
6
+ /** Normalized compatibility flags for a delivered terminal key event. */
6
7
  interface Key {
7
8
  upArrow: boolean;
8
9
  downArrow: boolean;
@@ -26,6 +27,7 @@ interface Key {
26
27
  numLock: boolean;
27
28
  eventType?: "press" | "repeat" | "release";
28
29
  }
30
+ /** Receive a normalized key name and exact modifier state. */
29
31
  interface KeyHandler {
30
32
  (key: string, modifiers: {
31
33
  ctrl: boolean;
@@ -34,42 +36,48 @@ interface KeyHandler {
34
36
  meta: boolean;
35
37
  }): void;
36
38
  }
39
+ /** Activation and callbacks for key, character, paste, and composition input. */
37
40
  interface UseInputOptions {
38
- /** Whether to capture input (boolean or Ref<boolean>) */
41
+ /** Activation flag used when isActive is omitted. @default true */
39
42
  active?: boolean | Ref<boolean>;
40
- /** Whether to capture input (alias for active, boolean or Ref<boolean>) */
43
+ /** Activation flag that takes precedence over active. @default active ?? true */
41
44
  isActive?: boolean | Ref<boolean>;
42
- /** Ink-compatible input callback */
45
+ /** Receive printable input and normalized compatibility key flags. @default undefined */
43
46
  handler?: (input: string, key: Key) => void;
44
- /** Called on key press */
47
+ /** Receive normalized key names with exact modifier state. @default undefined */
45
48
  onKey?: KeyHandler;
46
- /** Called on character input */
49
+ /** Receive printable text without command modifiers. @default undefined */
47
50
  onChar?: (char: string) => void;
48
- /** Called on Enter */
51
+ /** Receive the normalized Enter key. @default undefined */
49
52
  onSubmit?: () => void;
50
- /** Called on Escape */
53
+ /** Receive the normalized Escape key. @default undefined */
51
54
  onEscape?: () => void;
52
- /** Called on arrow keys */
55
+ /** Receive normalized arrow directions. @default undefined */
53
56
  onArrow?: (direction: "up" | "down" | "left" | "right") => void;
54
- /** Called when an IME composition starts */
57
+ /** Receive the start of IME preedit. @default undefined */
55
58
  onCompositionStart?: () => void;
56
- /** Called when IME preedit text changes */
59
+ /** Receive an IME preedit update. @default undefined */
57
60
  onCompositionUpdate?: (text: string, cursor: number) => void;
58
- /** Called when IME commits text */
61
+ /** Receive committed IME composition text. @default undefined */
59
62
  onCompositionEnd?: (text: string) => void;
60
- /** Deliver Ctrl+C to this handler instead of reserving it for app exit. */
63
+ /** Whether this handler owns Ctrl+C delivery. @default false */
61
64
  captureCtrlC?: boolean;
62
65
  }
66
+ /** Mutable activation and the latest delivered key or printable text. */
63
67
  interface UseInputReturn {
64
68
  isActive: Ref<boolean>;
65
69
  lastKey: Ref<string | null>;
66
70
  enable: () => void;
67
71
  disable: () => void;
68
72
  }
73
+ /** Receive printable input with normalized compatibility key flags. */
69
74
  type InputHandler = (input: string, key: Key) => void;
75
+ /** Activation for the callback overload of useInput. */
70
76
  interface UseInputHandlerOptions {
77
+ /** Whether the callback overload receives terminal input. @default true */
71
78
  isActive?: boolean | Ref<boolean>;
72
79
  }
80
+ /** Observe normalized terminal input while active and release input watchers and mode requests when the component unmounts. */
73
81
  declare function useInput(handler: InputHandler, options?: UseInputHandlerOptions): UseInputReturn;
74
82
  declare function useInput(options?: UseInputOptions): UseInputReturn;
75
83
  /**
@@ -83,10 +91,12 @@ declare function useKeyPress(key: string, handler: () => void, options?: {
83
91
  }): void;
84
92
  //#endregion
85
93
  //#region src/composables/usePaste.d.ts
94
+ /** Activation for whole bracketed-paste delivery and terminal-mode ownership. */
86
95
  interface UsePasteOptions {
87
- /** Whether the paste handler is active */
96
+ /** Whether this handler owns whole paste delivery. @default true */
88
97
  isActive?: boolean | Ref<boolean>;
89
98
  }
99
+ /** Deliver whole paste payloads while balancing raw-mode and bracketed-paste requests; release ownership on unmount. */
90
100
  declare function usePaste(handler: (text: string) => void, options?: UsePasteOptions): {
91
101
  isActive: Ref<boolean, boolean>;
92
102
  enable: () => void;
@@ -94,10 +104,12 @@ declare function usePaste(handler: (text: string) => void, options?: UsePasteOpt
94
104
  };
95
105
  //#endregion
96
106
  //#region src/composables/useMouse.d.ts
107
+ /** External activation gate for normalized terminal mouse and wheel events. */
97
108
  interface UseMouseOptions {
98
- /** Whether the handler receives events. */
109
+ /** External activation gate; local enable cannot override a false external ref. @default true */
99
110
  isActive?: boolean | Readonly<Ref<boolean>>;
100
111
  }
112
+ /** Readonly effective activation, local enable and disable commands, and explicit watcher disposal. */
101
113
  interface UseMouseReturn {
102
114
  isActive: Readonly<Ref<boolean>>;
103
115
  /** Start delivering normalized mouse events. */
@@ -111,17 +123,20 @@ interface UseMouseReturn {
111
123
  declare function useMouse(handler: (event: MouseEvent) => void, options?: UseMouseOptions): UseMouseReturn;
112
124
  //#endregion
113
125
  //#region src/composables/useIme.d.ts
126
+ /** Initial composition mode and optional mode, preedit, and commit notifications. */
114
127
  interface UseImeOptions {
115
- /** Initial IME mode */
128
+ /** Initial composition mode; the manager still starts disabled. @default "direct" */
116
129
  mode?: ImeMode;
117
- /** Called when IME mode changes */
130
+ /** Receive composition-mode changes. @default undefined */
118
131
  onModeChange?: (mode: ImeMode) => void;
119
- /** Called when composition updates */
132
+ /** Receive updated preedit text and cursor state. @default undefined */
120
133
  onCompositionUpdate?: (text: string, cursor: number) => void;
121
- /** Called when text is committed */
134
+ /** Receive committed composition text. @default undefined */
122
135
  onCommit?: (text: string) => void;
123
136
  }
137
+ /** Composition-mode identifiers exposed by the terminal input manager. */
124
138
  type ImeMode = "direct" | "hiragana" | "katakana" | "half-katakana" | "full-alpha" | "pinyin" | "hangul";
139
+ /** Composition activation, preedit, cursor, candidate state, and synchronous editing commands. */
125
140
  interface ImeManager {
126
141
  /** Whether IME is active */
127
142
  isActive: Ref<boolean>;
@@ -161,42 +176,53 @@ interface ImeManager {
161
176
  /** Select candidate by number (1-9) */
162
177
  selectCandidate: (num: number) => void;
163
178
  }
179
+ /** Create initially disabled composition state with caller-supplied conversion candidates. */
164
180
  declare function useIme(options?: UseImeOptions): ImeManager;
165
181
  //#endregion
166
182
  //#region src/composables/useStreams.d.ts
183
+ /** Input stream, raw-mode capability, and application exit policy. */
167
184
  interface UseStdinReturn {
168
185
  stdin: NodeJS.ReadStream;
169
186
  setRawMode: (isRawMode: boolean) => void;
170
187
  isRawModeSupported: boolean;
171
188
  internal_exitOnCtrlC: boolean;
172
189
  }
190
+ /** Output stream and its configured writer. */
173
191
  interface UseStdoutReturn {
174
192
  stdout: NodeJS.WriteStream;
175
193
  write: (data: string) => void;
176
194
  }
195
+ /** Error stream and its configured writer. */
177
196
  interface UseStderrReturn {
178
197
  stderr: NodeJS.WriteStream;
179
198
  write: (data: string) => void;
180
199
  }
200
+ /** Read the application input stream and raw-mode controls. */
181
201
  declare function useStdin(): UseStdinReturn;
202
+ /** Read the application output stream and configured output writer. */
182
203
  declare function useStdout(): UseStdoutReturn;
204
+ /** Read the application error stream and configured error writer. */
183
205
  declare function useStderr(): UseStderrReturn;
184
206
  //#endregion
185
207
  //#region src/composables/useWindowSize.d.ts
186
208
  /**
187
209
  * useWindowSize - terminal dimensions.
188
210
  */
211
+ /** Reactive terminal dimensions exposed as column and row getters. */
189
212
  interface WindowSize {
190
213
  columns: number;
191
214
  rows: number;
192
215
  }
216
+ /** Read application dimensions through reactive column and row getters. */
193
217
  declare function useWindowSize(): WindowSize;
194
218
  //#endregion
195
219
  //#region src/composables/useCursor.d.ts
220
+ /** Terminal-cell coordinates for a cursor-placement request. */
196
221
  interface CursorPosition {
197
222
  x: number;
198
223
  y: number;
199
224
  }
225
+ /** Request injected cursor control, clearing that request on unmount; use a best-effort native fallback outside a cursor context. */
200
226
  declare function useCursor(): {
201
227
  setCursorPosition: (position: CursorPosition | undefined) => void;
202
228
  };
@@ -205,18 +231,21 @@ declare function useCursor(): {
205
231
  /**
206
232
  * useAnimation - Ink-compatible shared animation state.
207
233
  */
234
+ /** Tick interval and activation for component-scoped shared animation scheduling. */
208
235
  interface UseAnimationOptions {
209
- /** Time between ticks in milliseconds */
236
+ /** Tick interval in milliseconds; finite values clamp to 1 through 2,147,483,647 and nonfinite values use 100. @default 100 */
210
237
  interval?: number;
211
- /** Whether the animation is running */
238
+ /** Whether the shared animation subscription is active. @default true */
212
239
  isActive?: boolean;
213
240
  }
241
+ /** Reactive frame count, elapsed milliseconds, last tick delta, and reset command. */
214
242
  interface AnimationResult {
215
243
  frame: number;
216
244
  time: number;
217
245
  delta: number;
218
246
  reset: () => void;
219
247
  }
248
+ /** Subscribe after mount to shared animation ticks; restart measurements on option changes and unsubscribe on unmount. */
220
249
  declare function useAnimation(options?: UseAnimationOptions): AnimationResult;
221
250
  //#endregion
222
251
  //#region src/layoutMetrics.d.ts
@@ -234,27 +263,33 @@ declare function measureElement(node: DOMElement): {
234
263
  };
235
264
  //#endregion
236
265
  //#region src/composables/useBoxMetrics.d.ts
266
+ /** Last measured layout rectangle in terminal cells. */
237
267
  interface BoxMetrics {
238
268
  width: number;
239
269
  height: number;
240
270
  left: number;
241
271
  top: number;
242
272
  }
273
+ /** Measured rectangle, measurement-state flag, and an explicit refresh request. */
243
274
  interface UseBoxMetricsResult extends BoxMetrics {
244
275
  hasMeasured: boolean;
245
276
  /** Refresh from the latest completed native layout snapshot. */
246
277
  refresh(): void;
247
278
  }
279
+ /** Host node or component element accepted by terminal layout measurement. */
248
280
  type MetricTarget = DOMElement;
281
+ /** Read completed layout measurements, falling back to native measurement; poll after mount and stop on unmount. */
249
282
  declare function useBoxMetrics(ref: Ref<MetricTarget | null>): UseBoxMetricsResult;
250
283
  //#endregion
251
284
  //#region src/composables/useIsScreenReaderEnabled.d.ts
252
285
  /**
253
286
  * useIsScreenReaderEnabled - screen reader mode flag.
254
287
  */
288
+ /** Read the current screen-reader mode as a boolean snapshot. */
255
289
  declare function useIsScreenReaderEnabled(): boolean;
256
290
  //#endregion
257
291
  //#region src/composables/useKeymap.d.ts
292
+ /** One normalized key chord with exact modifier matching. */
258
293
  interface KeymapStroke {
259
294
  readonly key: string;
260
295
  readonly ctrl?: boolean;
@@ -262,28 +297,35 @@ interface KeymapStroke {
262
297
  readonly shift?: boolean;
263
298
  readonly meta?: boolean;
264
299
  }
300
+ /** Command associated with a nonempty sequence of key chords. */
265
301
  interface KeymapBinding<Command extends string = string> {
266
302
  readonly command: Command;
267
303
  readonly sequence: readonly [KeymapStroke, ...KeymapStroke[]];
268
304
  }
305
+ /** Readonly collection of terminal command bindings. */
269
306
  type Keymap<Command extends string = string> = readonly KeymapBinding<Command>[];
307
+ /** Completed command and binding, or the current pending-prefix state. */
270
308
  interface KeymapMatch<Command extends string> {
271
309
  readonly command?: Command;
272
310
  readonly binding?: KeymapBinding<Command>;
273
311
  readonly pending: boolean;
274
312
  }
313
+ /** Stateful key-chord sequence matcher with explicit reset. */
275
314
  interface KeymapResolver<Command extends string> {
276
315
  readonly pendingSequence: readonly KeymapStroke[];
277
316
  feed(stroke: KeymapStroke): KeymapMatch<Command>;
278
317
  reset(): void;
279
318
  }
319
+ /** Keymap activation, partial-sequence deadline, and command delivery callback. */
280
320
  interface UseKeymapOptions<Command extends string> {
281
321
  readonly keymap: MaybeRefOrGetter<Keymap<Command>>;
322
+ /** Whether this component receives command chords. @default true */
282
323
  readonly active?: MaybeRefOrGetter<boolean>;
283
- /** Idle time before an incomplete multi-stroke sequence is cleared. */
324
+ /** Milliseconds before clearing an incomplete sequence; zero or negative values disable deadline clearing. @default 1000 */
284
325
  readonly sequenceTimeout?: number;
285
326
  readonly onCommand: (command: Command, binding: KeymapBinding<Command>) => void;
286
327
  }
328
+ /** Effective activation, readonly pending chord sequence, and reset command. */
287
329
  interface UseKeymapReturn {
288
330
  readonly isActive: Readonly<Ref<boolean>>;
289
331
  readonly pendingSequence: Readonly<Ref<readonly KeymapStroke[]>>;
@@ -297,4 +339,4 @@ declare function createKeymapResolver<Command extends string>(keymap: () => Keym
297
339
  declare function useKeymap<Command extends string>(options: UseKeymapOptions<Command>): UseKeymapReturn;
298
340
  //#endregion
299
341
  export { ImeManager as A, KeyHandler as B, useWindowSize as C, useStderr as D, UseStdoutReturn as E, useMouse as F, UseInputReturn as H, UsePasteOptions as I, usePaste as L, useIme as M, UseMouseOptions as N, useStdin as O, UseMouseReturn as P, InputHandler as R, WindowSize as S, UseStdinReturn as T, useInput as U, UseInputOptions as V, useKeyPress as W, AnimationResult as _, KeymapStroke as a, CursorPosition as b, createKeymapResolver as c, useIsScreenReaderEnabled as d, BoxMetrics as f, measureElement as g, DOMElement as h, KeymapResolver as i, UseImeOptions as j, useStdout as k, defineKeymap as l, useBoxMetrics as m, KeymapBinding as n, UseKeymapOptions as o, UseBoxMetricsResult as p, KeymapMatch as r, UseKeymapReturn as s, Keymap as t, useKeymap as u, UseAnimationOptions as v, UseStderrReturn as w, useCursor as x, useAnimation as y, Key as z };
300
- //# sourceMappingURL=index-BOV-0YqV.d.mts.map
342
+ //# sourceMappingURL=index-C7_vgg04.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-C7_vgg04.d.mts","names":[],"sources":["../src/composables/useInput.ts","../src/composables/usePaste.ts","../src/composables/useMouse.ts","../src/composables/useIme.ts","../src/composables/useStreams.ts","../src/composables/useWindowSize.ts","../src/composables/useCursor.ts","../src/composables/useAnimation.ts","../src/layoutMetrics.ts","../src/composables/useBoxMetrics.ts","../src/composables/useIsScreenReaderEnabled.ts","../src/composables/useKeymap.ts"],"mappings":";;;;;;UAUiB,GAAA;EACf,OAAA;EACA,SAAA;EACA,SAAA;EACA,UAAA;EACA,QAAA;EACA,MAAA;EACA,IAAA;EACA,GAAA;EACA,MAAA;EACA,MAAA;EACA,IAAA;EACA,KAAA;EACA,GAAA;EACA,SAAA;EACA,MAAA;EACA,IAAA;EACA,KAAA;EACA,KAAA;EACA,QAAA;EACA,OAAA;EACA,SAAA;AAAA;;UAIe,UAAA;EAAA,CACd,GAAA,UAA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