@aintela/bi 0.2.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 (175) hide show
  1. package/README.md +299 -0
  2. package/dist/BiClientProvider-CWJochvi.js +219 -0
  3. package/dist/BiClientProvider-CWJochvi.js.map +1 -0
  4. package/dist/ChartCardDefaultsContext-Cl5T25H0.js +32 -0
  5. package/dist/ChartCardDefaultsContext-Cl5T25H0.js.map +1 -0
  6. package/dist/ChartContext-C_f_6khG.js +14 -0
  7. package/dist/ChartContext-C_f_6khG.js.map +1 -0
  8. package/dist/DashboardParametersContext-Clv--79U.js +39 -0
  9. package/dist/DashboardParametersContext-Clv--79U.js.map +1 -0
  10. package/dist/cards/ChartCard.d.ts +62 -0
  11. package/dist/cards/DataTableCard.d.ts +55 -0
  12. package/dist/cards/GaugeCard.d.ts +20 -0
  13. package/dist/cards/GaugeGroup.d.ts +12 -0
  14. package/dist/cards/MapBubbles.d.ts +35 -0
  15. package/dist/cards/MapConnections.d.ts +28 -0
  16. package/dist/cards/MetricCard.d.ts +15 -0
  17. package/dist/cards/MetricGroupCard.d.ts +10 -0
  18. package/dist/cards/TreeMapCard.d.ts +15 -0
  19. package/dist/cards/geoLayers.d.ts +23 -0
  20. package/dist/cards/index.d.ts +24 -0
  21. package/dist/cards/licenseGuard.d.ts +9 -0
  22. package/dist/cards/mapUtils.d.ts +23 -0
  23. package/dist/cards/useContainerRectangle.d.ts +9 -0
  24. package/dist/cards/worldMapPath.d.ts +7 -0
  25. package/dist/cards.d.ts +2 -0
  26. package/dist/cards.js +28 -0
  27. package/dist/cards.js.map +1 -0
  28. package/dist/client/BiClient.d.ts +160 -0
  29. package/dist/client/BiClientProvider.d.ts +21 -0
  30. package/dist/client/index.d.ts +4 -0
  31. package/dist/client.d.ts +2 -0
  32. package/dist/client.js +11 -0
  33. package/dist/client.js.map +1 -0
  34. package/dist/composer/environment/environmentDom.d.ts +31 -0
  35. package/dist/composer/environment/types.d.ts +67 -0
  36. package/dist/composer/icons/cardTypeIcons.d.ts +31 -0
  37. package/dist/composer/index.d.ts +66 -0
  38. package/dist/composer/llm/ExampleCardSketch.d.ts +22 -0
  39. package/dist/composer/llm/ExamplePad.d.ts +18 -0
  40. package/dist/composer/llm/PrototypePad.d.ts +13 -0
  41. package/dist/composer/llm/useDashboardPad.d.ts +25 -0
  42. package/dist/composer/models/catalog.d.ts +33 -0
  43. package/dist/composer/models/sketchModels.d.ts +102 -0
  44. package/dist/composer/models/utils.d.ts +9 -0
  45. package/dist/composer/pad/CardSketch.d.ts +25 -0
  46. package/dist/composer/pad/ClonedComponent.d.ts +13 -0
  47. package/dist/composer/pad/DashboardPad.d.ts +38 -0
  48. package/dist/composer/pad/DashboardPadEditor.d.ts +35 -0
  49. package/dist/composer/pad/DashboardPadSketch.d.ts +31 -0
  50. package/dist/composer/pad/DatasetParameterizationControls.d.ts +34 -0
  51. package/dist/composer/pad/FilterSketch.d.ts +10 -0
  52. package/dist/composer/pad/HoverButton.d.ts +12 -0
  53. package/dist/composer/pad/TitleSketch.d.ts +19 -0
  54. package/dist/composer/pad/ToolBox.d.ts +11 -0
  55. package/dist/composer/store/ComposerProvider.d.ts +36 -0
  56. package/dist/composer/store/createComposerStore.d.ts +107 -0
  57. package/dist/composer/store/drafts.d.ts +20 -0
  58. package/dist/composer/view/ComposerChatBinding.d.ts +10 -0
  59. package/dist/composer/view/ComposerView.d.ts +49 -0
  60. package/dist/composer/view/DashboardPin.d.ts +3 -0
  61. package/dist/composer/view/DashboardSidePanel.d.ts +10 -0
  62. package/dist/composer/view/DrawablePrompt.d.ts +22 -0
  63. package/dist/composer/view/EntryEmptyState.d.ts +22 -0
  64. package/dist/composer/view/SpotlightOverlay.d.ts +21 -0
  65. package/dist/composer/view/composerAnimations.d.ts +11 -0
  66. package/dist/composer/view/composerTypes.d.ts +18 -0
  67. package/dist/composer/view/data/suggestions.d.ts +10 -0
  68. package/dist/composer/view/data/templates.d.ts +33 -0
  69. package/dist/composer/view/surfaces.d.ts +19 -0
  70. package/dist/composer/view/useComposerChatBridge.d.ts +43 -0
  71. package/dist/composer.d.ts +2 -0
  72. package/dist/composer.js +99 -0
  73. package/dist/composer.js.map +1 -0
  74. package/dist/createBiTheme-TyUv_UHM.js +93 -0
  75. package/dist/createBiTheme-TyUv_UHM.js.map +1 -0
  76. package/dist/data/ChartCardDefaultsContext.d.ts +43 -0
  77. package/dist/data/dataUtils.d.ts +152 -0
  78. package/dist/data/index.d.ts +5 -0
  79. package/dist/data/queryModel.d.ts +23 -0
  80. package/dist/data.d.ts +2 -0
  81. package/dist/data.js +37 -0
  82. package/dist/data.js.map +1 -0
  83. package/dist/dataUtils-CAUE5uZY.js +372 -0
  84. package/dist/dataUtils-CAUE5uZY.js.map +1 -0
  85. package/dist/filters/VizAutoComplete.d.ts +23 -0
  86. package/dist/filters/VizDatePicker.d.ts +9 -0
  87. package/dist/filters/VizDateRangePicker.d.ts +14 -0
  88. package/dist/filters/VizSelect.d.ts +12 -0
  89. package/dist/filters/VizTextField.d.ts +8 -0
  90. package/dist/filters/VizTriggerButton.d.ts +9 -0
  91. package/dist/filters/filterFactory.d.ts +30 -0
  92. package/dist/filters/friendlyName.d.ts +4 -0
  93. package/dist/filters/index.d.ts +15 -0
  94. package/dist/filters.d.ts +2 -0
  95. package/dist/filters.js +15 -0
  96. package/dist/filters.js.map +1 -0
  97. package/dist/grid/BiErrorBoundary.d.ts +24 -0
  98. package/dist/grid/ChartContext.d.ts +14 -0
  99. package/dist/grid/GridCard.d.ts +45 -0
  100. package/dist/grid/GridCardPlaceHolder.d.ts +8 -0
  101. package/dist/grid/GridLayout.d.ts +147 -0
  102. package/dist/grid/gridModels.d.ts +33 -0
  103. package/dist/grid/index.d.ts +14 -0
  104. package/dist/grid/types.d.ts +23 -0
  105. package/dist/grid/useGridConfigTranslator.d.ts +72 -0
  106. package/dist/grid.d.ts +2 -0
  107. package/dist/grid.js +20 -0
  108. package/dist/grid.js.map +1 -0
  109. package/dist/hooks/DashboardParametersContext.d.ts +32 -0
  110. package/dist/hooks/index.d.ts +8 -0
  111. package/dist/hooks/useDashboardData.d.ts +20 -0
  112. package/dist/hooks/useDashboardLazyData.d.ts +79 -0
  113. package/dist/hooks.d.ts +2 -0
  114. package/dist/hooks.js +16 -0
  115. package/dist/hooks.js.map +1 -0
  116. package/dist/index-BYc79sSy.js +131 -0
  117. package/dist/index-BYc79sSy.js.map +1 -0
  118. package/dist/index-C6JQ6770.js +4545 -0
  119. package/dist/index-C6JQ6770.js.map +1 -0
  120. package/dist/index-CZbCaXMC.js +15 -0
  121. package/dist/index-CZbCaXMC.js.map +1 -0
  122. package/dist/index-D3OoOPjl.js +259 -0
  123. package/dist/index-D3OoOPjl.js.map +1 -0
  124. package/dist/index-D7Oo_dC-.js +94 -0
  125. package/dist/index-D7Oo_dC-.js.map +1 -0
  126. package/dist/index-D7tVPX8d.js +347 -0
  127. package/dist/index-D7tVPX8d.js.map +1 -0
  128. package/dist/index-DGyvUtY3.js +494 -0
  129. package/dist/index-DGyvUtY3.js.map +1 -0
  130. package/dist/index-DOpx0R4Y.js +41 -0
  131. package/dist/index-DOpx0R4Y.js.map +1 -0
  132. package/dist/index-wtSLspPh.js +1065 -0
  133. package/dist/index-wtSLspPh.js.map +1 -0
  134. package/dist/index.d.ts +12 -0
  135. package/dist/index.js +236 -0
  136. package/dist/index.js.map +1 -0
  137. package/dist/inline/Chart.d.ts +29 -0
  138. package/dist/inline/IFrame.d.ts +19 -0
  139. package/dist/inline/Metric.d.ts +16 -0
  140. package/dist/inline/MetricGroup.d.ts +11 -0
  141. package/dist/inline/index.d.ts +9 -0
  142. package/dist/inline/parseKnownNumbers.d.ts +11 -0
  143. package/dist/inline.d.ts +2 -0
  144. package/dist/inline.js +9 -0
  145. package/dist/inline.js.map +1 -0
  146. package/dist/runtime/IDashboardDefinition.d.ts +22 -0
  147. package/dist/runtime/biModuleSurface.d.ts +2 -0
  148. package/dist/runtime/createBiUiTools.d.ts +74 -0
  149. package/dist/runtime/index.d.ts +9 -0
  150. package/dist/runtime/loadDashboardBundle.d.ts +32 -0
  151. package/dist/runtime/registerBiModules.d.ts +36 -0
  152. package/dist/runtime/version.d.ts +6 -0
  153. package/dist/runtime.d.ts +2 -0
  154. package/dist/runtime.js +19 -0
  155. package/dist/runtime.js.map +1 -0
  156. package/dist/style.css +1 -0
  157. package/dist/theme/BiThemeBridge.d.ts +32 -0
  158. package/dist/theme/biPalette.d.ts +23 -0
  159. package/dist/theme/createBiTheme.d.ts +25 -0
  160. package/dist/theme/index.d.ts +5 -0
  161. package/dist/theme.d.ts +2 -0
  162. package/dist/theme.js +15 -0
  163. package/dist/theme.js.map +1 -0
  164. package/dist/version-DnqajORq.js +83 -0
  165. package/dist/version-DnqajORq.js.map +1 -0
  166. package/dist/viewer/ScriptDashboardViewer.d.ts +82 -0
  167. package/dist/viewer/ScriptDashboardViewerVertical.d.ts +24 -0
  168. package/dist/viewer/cardMetadata.d.ts +15 -0
  169. package/dist/viewer/index.d.ts +8 -0
  170. package/dist/viewer/models.d.ts +67 -0
  171. package/dist/viewer/useDashboardBundle.d.ts +73 -0
  172. package/dist/viewer.d.ts +2 -0
  173. package/dist/viewer.js +9 -0
  174. package/dist/viewer.js.map +1 -0
  175. package/package.json +196 -0
@@ -0,0 +1,19 @@
1
+ import { default as React } from 'react';
2
+ export interface IFrameExpandInfo {
3
+ name: string;
4
+ url: string;
5
+ }
6
+ export interface IFrameProps {
7
+ id?: string;
8
+ name: string;
9
+ /** HTML artifact file name (e.g. a folium map). */
10
+ src: string;
11
+ sessionId?: string;
12
+ partial?: boolean;
13
+ height?: number | string;
14
+ /** Called from the expand affordance. When omitted the frame URL opens in a new tab. */
15
+ onExpand?: (info: IFrameExpandInfo) => void;
16
+ }
17
+ /** HTML artifact card used by `present_iframe`. URL resolved through the injected `BiClient`. */
18
+ export declare const IFrame: React.FC<IFrameProps>;
19
+ export default IFrame;
@@ -0,0 +1,16 @@
1
+ import { default as React } from 'react';
2
+ export interface MetricProps {
3
+ preview?: boolean;
4
+ previousValue?: string;
5
+ currentValue: string;
6
+ prefix?: string;
7
+ suffix?: string;
8
+ differenceStyle?: 'Percentage' | 'Value';
9
+ description?: string;
10
+ /** Material Icons ligature name (the host must load the Material Icons font). */
11
+ icon?: string;
12
+ partial?: boolean;
13
+ }
14
+ /** KPI tile used by `present_metric` / `present_metric_group`. */
15
+ export declare const Metric: React.FC<MetricProps>;
16
+ export default Metric;
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+ export interface MetricGroupProps {
3
+ children: React.ReactNode;
4
+ title?: string;
5
+ materialIcon?: string;
6
+ footNote?: string;
7
+ partial?: boolean;
8
+ }
9
+ /** A row of `Metric` tiles (`present_metric_group`). */
10
+ export declare const MetricGroup: React.FC<MetricGroupProps>;
11
+ export default MetricGroup;
@@ -0,0 +1,9 @@
1
+ export { Chart } from './Chart';
2
+ export type { ChartProps, ChartExpandInfo } from './Chart';
3
+ export { Metric } from './Metric';
4
+ export type { MetricProps } from './Metric';
5
+ export { MetricGroup } from './MetricGroup';
6
+ export type { MetricGroupProps } from './MetricGroup';
7
+ export { IFrame } from './IFrame';
8
+ export type { IFrameProps, IFrameExpandInfo } from './IFrame';
9
+ export { parseKnownNumbers } from './parseKnownNumbers';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Splits a formatted figure such as `"R$ 1.234,56"` or `"12,5%"` into a
3
+ * currency/percent prefix + suffix and a JS number. Mirrors the chat library's
4
+ * `parseKnownNumbers` (`src/utils/stringUtils.ts`), which is not part of its
5
+ * public `@aintela/chat/utils` surface — so it lives here.
6
+ */
7
+ export declare function parseKnownNumbers(text?: string): {
8
+ prefix?: string;
9
+ suffix?: string;
10
+ number?: number;
11
+ };
@@ -0,0 +1,2 @@
1
+ export * from './inline/index'
2
+ export {}
package/dist/inline.js ADDED
@@ -0,0 +1,9 @@
1
+ import { C as s, I as e, M as o, a as p, p as t } from "./index-BYc79sSy.js";
2
+ export {
3
+ s as Chart,
4
+ e as IFrame,
5
+ o as Metric,
6
+ p as MetricGroup,
7
+ t as parseKnownNumbers
8
+ };
9
+ //# sourceMappingURL=inline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,22 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+ import { GridCardProps } from '../grid/GridCard';
3
+ /** One card as a compiled dashboard bundle declares it. */
4
+ export interface DashboardCardDefinition {
5
+ key: string;
6
+ title?: string;
7
+ specificType?: string;
8
+ category?: string;
9
+ element: ReactElement<GridCardProps>;
10
+ }
11
+ export interface DataSourceDefinition {
12
+ key: string;
13
+ queryHash: string;
14
+ requiredParams?: string[];
15
+ optionalFilters?: string[];
16
+ }
17
+ /** The class a dashboard bundle exports as its default. */
18
+ export interface IDashboardDefinition {
19
+ getDataSources?(): DataSourceDefinition[];
20
+ getCardsList(): DashboardCardDefinition[];
21
+ getDashboardStyle(): ReactNode;
22
+ }
@@ -0,0 +1,2 @@
1
+ /** Every runtime export of the package, merged into one object (later spreads win on a name clash). */
2
+ export declare function getBiModuleSurface(): Record<string, unknown>;
@@ -0,0 +1,74 @@
1
+ import { UiToolRegistryBuilder } from '@aintela/chat/components';
2
+ import { ChartExpandInfo, IFrameExpandInfo } from '../inline';
3
+ import { BiClient } from '../client';
4
+ import { DashboardEnvironment } from '../composer/environment/types';
5
+ /**
6
+ * The explorer's visual vocabulary as `uiTools` registry entries. The chat
7
+ * library owns the plumbing (routing `[KernelUiFunction]` calls, unwrapping
8
+ * args, replay); here we only declare WHAT to draw per tool name.
9
+ *
10
+ * `present_dashboard` and `present_tsx` are deliberately NOT registered — the
11
+ * dashboard hand-off belongs to the dashboard slice and `present_tsx`'s
12
+ * compiled-JS sibling-event plumbing is host policy. Both are added by the
13
+ * host on the returned builder:
14
+ *
15
+ * const uiTools = createBiUiTools({ client })
16
+ * .render('present_dashboard', (a) => <ScriptDashboardViewer dashboardId={a.id} />)
17
+ * .build();
18
+ */
19
+ export interface CreateBiUiToolsOptions {
20
+ /**
21
+ * Client whose `artifactUrl` / `iframeUrl` resolve the images. When
22
+ * omitted the renderers rely on an ambient `<BiClientProvider>` above the
23
+ * chat pane (which is how a host also passes the session id).
24
+ */
25
+ client?: BiClient;
26
+ /** Expand handlers (a lightbox, an artifact panel). Default: open in a new tab. */
27
+ onExpandChart?: (info: ChartExpandInfo) => void;
28
+ onExpandIframe?: (info: IFrameExpandInfo) => void;
29
+ /** Start from an existing builder to chain more tools before these. */
30
+ builder?: UiToolRegistryBuilder;
31
+ /**
32
+ * The composer's environment (`useComposerEnvironment()` /
33
+ * `environmentFromStore(store)`). When supplied, the three ACTION tools
34
+ * the dashboard agent calls are registered too: `refresh_dashboard`,
35
+ * `present_dashboard_pad` (`definitionJson` + `mode`) and `present_guide`
36
+ * (`stepsJson`). Without it they are left to the host, like `present_dashboard`.
37
+ */
38
+ environment?: Partial<DashboardEnvironment>;
39
+ }
40
+ export interface PresentMetricArgs {
41
+ currentValue: string;
42
+ previousValue?: string;
43
+ prefix?: string;
44
+ suffix?: string;
45
+ differenceStyle?: 'Percentage' | 'Value';
46
+ description?: string;
47
+ icon?: string;
48
+ }
49
+ export declare function normalizeMetricArgs(raw: unknown): PresentMetricArgs;
50
+ export interface PresentChartArgs {
51
+ src?: string;
52
+ name?: string;
53
+ alt?: string;
54
+ reasoning?: string;
55
+ naked?: boolean;
56
+ }
57
+ export interface PresentMetricGroupArgs {
58
+ title?: string;
59
+ materialIcon?: string;
60
+ footNote?: string;
61
+ metrics?: unknown[];
62
+ }
63
+ export interface PresentIframeArgs {
64
+ src?: string;
65
+ name?: string;
66
+ }
67
+ export interface PresentDashboardPadArgs {
68
+ definitionJson?: string;
69
+ mode?: 'create' | 'update' | string;
70
+ }
71
+ export interface PresentGuideArgs {
72
+ stepsJson?: string;
73
+ }
74
+ export declare function createBiUiTools(options?: CreateBiUiToolsOptions): UiToolRegistryBuilder;
@@ -0,0 +1,9 @@
1
+ export { registerBiModules, resetBiModuleRegistration } from './registerBiModules';
2
+ export type { RegisterBiModulesOptions } from './registerBiModules';
3
+ export { getBiModuleSurface } from './biModuleSurface';
4
+ export { loadDashboardBundle, instantiateDashboardBundle, evaluateDashboardBundle, getHostModules, seedHostModules, getRegisteredSpecifiers, hashBundleCode, clearBundleCaches, } from './loadDashboardBundle';
5
+ export type { DashboardBundleResult } from './loadDashboardBundle';
6
+ export { createBiUiTools, normalizeMetricArgs } from './createBiUiTools';
7
+ export type { CreateBiUiToolsOptions, PresentMetricArgs, PresentChartArgs, PresentMetricGroupArgs, PresentIframeArgs, PresentDashboardPadArgs, PresentGuideArgs } from './createBiUiTools';
8
+ export type { IDashboardDefinition, DashboardCardDefinition, DataSourceDefinition } from './IDashboardDefinition';
9
+ export { BI_RUNTIME_VERSION } from './version';
@@ -0,0 +1,32 @@
1
+ import { BiClient } from '../client';
2
+ import { DashboardCardDefinition, IDashboardDefinition } from './IDashboardDefinition';
3
+ import * as React from 'react';
4
+ /** Called by `registerBiModules`. Invalidates the resolved map so the next bundle load rebuilds it. */
5
+ export declare function seedHostModules(specifiers: string[], extra?: Record<string, unknown>): void;
6
+ /** Specifiers `registerBiModules` has seeded so far (test/diagnostic seam). */
7
+ export declare function getRegisteredSpecifiers(): string[];
8
+ export declare function getHostModules(): Promise<Record<string, unknown>>;
9
+ /** FNV-1a 32-bit + length. Not cryptographic; only detects a changed bundle. */
10
+ export declare function hashBundleCode(code: string): string;
11
+ /** Test seam. */
12
+ export declare function clearBundleCaches(): void;
13
+ /**
14
+ * Evaluates CJS bundle code against the host-module map and returns its
15
+ * default export (or the whole `exports` object). Exposed so a host with its
16
+ * own transport can skip `loadDashboardBundle`.
17
+ */
18
+ export declare function evaluateDashboardBundle(code: string, cacheKey?: string): Promise<unknown>;
19
+ /**
20
+ * Fetches a CJS dashboard bundle through the client and executes it in a
21
+ * sandboxed scope with the host's React and this library.
22
+ *
23
+ * @returns the bundle's default export (typically a class implementing `IDashboardDefinition`)
24
+ */
25
+ export declare function loadDashboardBundle(client: BiClient, sessionId: string, dashboardId: string): Promise<unknown>;
26
+ export interface DashboardBundleResult {
27
+ instance: IDashboardDefinition;
28
+ cards: DashboardCardDefinition[];
29
+ style: React.ReactNode;
30
+ }
31
+ /** Loads a bundle, instantiates the class it exports, returns cards + style node. */
32
+ export declare function instantiateDashboardBundle(client: BiClient, sessionId: string, scriptFileName: string): Promise<DashboardBundleResult>;
@@ -0,0 +1,36 @@
1
+ export interface RegisterBiModulesOptions {
2
+ /**
3
+ * The module specifiers LLM-emitted code imports from. The compiled
4
+ * snippet does `__scope["<specifier>"].X` and a bundle does
5
+ * `require("<specifier>")`, so every string here must match what the
6
+ * template / instruction files told the model to write.
7
+ *
8
+ * AIA starts clean: `['@aintela/bi']`. Envision must keep resolving the
9
+ * legacy keys forever (persisted sessions + content-hashed bundles):
10
+ * `['@aintela/bi', '@envision/ui-library', '@envision/ui-library/components', …]`.
11
+ */
12
+ specifiers: string[];
13
+ /**
14
+ * Extra values merged into the surface under every specifier AND into the
15
+ * bare-identifier scope — e.g. Envision's `VizLibrary` compat shim, or a
16
+ * host's own components the instructions mention.
17
+ */
18
+ extraScope?: Record<string, unknown>;
19
+ /**
20
+ * Extra `require()` targets for dashboard bundles keyed by specifier
21
+ * (`{ 'date-fns': dateFns, lodash }`). Not in the live-TSX scope.
22
+ */
23
+ extraHostModules?: Record<string, unknown>;
24
+ }
25
+ /**
26
+ * Makes this library resolvable from LLM-generated code:
27
+ * 1. `extendModuleRegistry(specifier, surface)` once per specifier (live TSX imports);
28
+ * 2. `extendDefaultScope(surface)` once (bare identifiers, no import line);
29
+ * 3. seeds the dashboard-bundle loader's host-module map under the same specifiers.
30
+ *
31
+ * Idempotent per specifier — call it at app start, before the first chat turn
32
+ * or bundle renders.
33
+ */
34
+ export declare function registerBiModules(options: RegisterBiModulesOptions): void;
35
+ /** Test seam. */
36
+ export declare function resetBiModuleRegistration(): void;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The package version, so a host can log a mismatch against the server-side
3
+ * `AIntelA.Bi.Agents` version at handshake (the instruction files describe
4
+ * THIS React API). Kept in sync with package.json by `tests/runtime/version.test.ts`.
5
+ */
6
+ export declare const BI_RUNTIME_VERSION = "0.2.0";
@@ -0,0 +1,2 @@
1
+ export * from './runtime/index'
2
+ export {}
@@ -0,0 +1,19 @@
1
+ import { B as s, c as o, n as r, r as d, a as t } from "./version-DnqajORq.js";
2
+ import { a0 as l, ab as u, ad as n, ae as B, af as c, ai as g, aj as M, an as h, ax as f } from "./index-C6JQ6770.js";
3
+ export {
4
+ s as BI_RUNTIME_VERSION,
5
+ l as clearBundleCaches,
6
+ o as createBiUiTools,
7
+ u as evaluateDashboardBundle,
8
+ n as getBiModuleSurface,
9
+ B as getHostModules,
10
+ c as getRegisteredSpecifiers,
11
+ g as hashBundleCode,
12
+ M as instantiateDashboardBundle,
13
+ h as loadDashboardBundle,
14
+ r as normalizeMetricArgs,
15
+ d as registerBiModules,
16
+ t as resetBiModuleRegistration,
17
+ f as seedHostModules
18
+ };
19
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ :root{--grid-card-padding: 15px;--grid-card-padding-mobile: 10px;--grid-card-gap: 15px;--grid-card-gap-mobile: 12px}.grid-card,.grid-card-nohandle,.grid-card-naked{--kpi-accent: var(--bi-accent);--kpi-accent-light: var(--bi-text-2);--kpi-glow: var(--bi-accent-soft);--chart-accent: var(--bi-accent);--chart-accent-light: var(--bi-text-2);--chart-glow: var(--bi-accent-soft);--table-accent: var(--bi-accent);--table-accent-light: var(--bi-text-2);--table-glow: var(--bi-accent-soft);--iframe-accent: var(--bi-accent);--iframe-accent-light: var(--bi-text-2);--iframe-glow: var(--bi-accent-soft);--info-accent: var(--bi-accent);--info-accent-light: var(--bi-text-2);--info-glow: var(--bi-accent-soft);--info-color: var(--bi-text-2);--grid-card-accent: var(--bi-accent);--grid-card-accent-light: var(--bi-accent-border);--grid-card-accent-dark: var(--bi-accent-soft)}.grid-card,.grid-card-nohandle{position:relative;background-color:var(--bi-card-bg);border:1px solid var(--bi-card-border);color:var(--bi-text-1)}.grid-card:active{cursor:grabbing}.grid-card:hover:before{opacity:.6}.grid-card:after{content:"";position:absolute;bottom:4px;right:4px;width:12px;height:12px;border-right:2px solid var(--bi-card-border-strong);border-bottom:2px solid var(--bi-card-border-strong);border-bottom-right-radius:var(--bi-radius);opacity:.3;transition:opacity .2s ease;pointer-events:none}.grid-card:hover:after{opacity:1}.grid-card .react-resizable-handle{opacity:0;transition:opacity .2s ease}.grid-card:hover .react-resizable-handle{opacity:1}.react-grid-placeholder{background:var(--bi-overlay)!important;border:1px dashed var(--bi-card-border-strong)!important;border-radius:var(--bi-radius);opacity:1!important}.grid-card-with-header{padding:0}.grid-card-with-header .grid-card-header{flex-shrink:0}.grid-card-with-header .grid-card-content{flex:1;min-height:0;overflow:auto}.grid-card-header{display:flex;align-items:center;justify-content:space-between;padding:10px 14px 6px;border-bottom:none;background:transparent}.grid-card-title{margin:0;font-weight:500;font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--bi-text-2)}.grid-card-icon{display:none;align-items:center;justify-content:center;margin-left:12px;opacity:.7}.grid-card-icon .material-icons{font-size:20px}.grid-card-content{padding:5px 6px 3px;height:100%}.grid-card-content-naked{padding:0;height:100%}.grid-card-content>*{height:100%}.grid-card-content-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:8px}.grid-card-kpi,.grid-card-chart,.grid-card-table,.grid-card-info,.grid-card-iframe{border:1px solid var(--bi-card-border);border-radius:var(--card-radius, 14px);transition:border-color .15s ease,box-shadow .15s ease}.grid-card-details{border:0 solid transparent;transition:box-shadow .2s ease,border-color .2s ease;font-style:italic}.grid-card-kpi .grid-card-icon{background-color:var(--kpi-glow);color:var(--kpi-accent)}.grid-card-kpi .grid-card-title{color:var(--kpi-accent-light)}.grid-card-chart .grid-card-icon{background-color:var(--chart-glow);color:var(--chart-accent)}.grid-card-chart .grid-card-title{color:var(--chart-accent-light)}.grid-card-chart{align-content:center}.grid-card-table .grid-card-icon{background-color:var(--table-glow);color:var(--table-accent)}.grid-card-table .grid-card-title{color:var(--table-accent-light)}.grid-card-info .grid-card-icon{background-color:var(--info-glow);color:var(--info-color)}.grid-card-info .grid-card-title{color:var(--info-accent-light)}.grid-card-iframe .grid-card-icon{background-color:var(--iframe-glow);color:var(--iframe-accent)}.grid-card-iframe .grid-card-title{color:var(--iframe-accent-light)}.grid-card-naked.ds-card,.grid-card-naked{background-color:transparent;border:1px solid transparent;border-radius:var(--bi-radius);box-shadow:none;transform:none}.grid-card-naked.ds-card:hover,.grid-card-naked:hover{transform:none;box-shadow:none;border:1px solid transparent}.grid-card-naked:after{display:none}.grid-card-naked .grid-card-naked-resize-handle{position:absolute;bottom:4px;right:4px;width:12px;height:12px;border-right:2px solid var(--bi-card-border-strong);border-bottom:2px solid var(--bi-card-border-strong);border-bottom-right-radius:var(--bi-radius);opacity:.1;transition:opacity .2s ease;pointer-events:none;z-index:10}.grid-card-naked:hover .grid-card-naked-resize-handle{opacity:1}.grid-card-naked:before{content:"";position:absolute;top:4px;left:50%;transform:translate(-50%);width:28px;height:3px;border-radius:2px;background-color:var(--bi-grid-line);opacity:0;transition:opacity .2s ease;pointer-events:none;z-index:5}.grid-card-naked:hover:before{opacity:.6}.grid-card-naked .cardDragHandle{display:none}.grid-card-naked .react-resizable-handle{opacity:1;transition:opacity .2s ease}.grid-card-naked:hover .react-resizable-handle{opacity:.6}.grid-card-custom{border:1px solid var(--bi-card-border);border-left:3px solid var(--grid-card-accent);transition:box-shadow .2s ease,border-color .2s ease}.grid-card-custom:hover{border-radius:var(--bi-radius-sm);border-top:2px solid var(--grid-card-accent);border-right:2px solid var(--grid-card-accent);border-bottom:2px solid var(--grid-card-accent)}.grid-card-custom .grid-card-icon{background-color:var(--grid-card-accent-dark);color:var(--grid-card-accent)}.grid-card-custom .grid-card-title{color:var(--grid-card-accent-light)}.dscard-placeholder{border:1px dashed var(--bi-card-border-strong);background-color:var(--bi-surface-1)}.dscard-placeholder-naked{border:1px dashed transparent;background-color:transparent}@media(max-width:768px){.grid-card-content-grid{grid-template-columns:1fr}}.class-positive{background-color:var(--bi-positive-soft)}.class-negative{background-color:var(--bi-negative-soft)}@keyframes bi-shimmer{0%{stroke-opacity:.3}to{stroke-opacity:.9}}.parallax-wrapper{height:100%;overflow-x:hidden;overflow-y:auto;perspective:2px;perspective-origin:center}.parallax-group{position:relative;height:100%;transform-style:preserve-3d;display:flex;justify-content:center;align-items:center}.parallax-layer{position:absolute;top:0;left:0;right:0;bottom:0}.layer-bg{transform:translateZ(-5px) scale(1);z-index:1}.layer-fg{transform:translateZ(0) scale(1);z-index:2}.svgElement{transform:translateZ(-5px) scale(1);z-index:1;stroke:var(--bi-text-disabled);animation:bi-shimmer .6s infinite alternate;border-radius:1px}.grid-card .recharts-rectangle{filter:brightness(.95) saturate(.95)}.grid-card .recharts-cartesian-grid line{stroke:var(--bi-grid-line)}.grid-card .recharts-cartesian-axis-tick-value{fill:var(--bi-text-2);font-size:.75rem}.grid-card .recharts-cartesian-axis-line,.grid-card .recharts-cartesian-axis-tick-line{stroke:var(--bi-grid-line)}.grid-card .recharts-legend-item-text{color:var(--bi-text-2)!important;font-size:12px}.grid-card .recharts-tooltip-wrapper .recharts-default-tooltip{background-color:var(--bi-card-bg)!important;border:1px solid var(--bi-card-border)!important;border-radius:var(--bi-radius);font-size:12px}.grid-card .recharts-tooltip-wrapper .recharts-default-tooltip .recharts-tooltip-label{color:var(--bi-text-1)}.grid-card .recharts-tooltip-wrapper .recharts-default-tooltip .recharts-tooltip-item{color:var(--bi-text-2)!important}.grid-card .recharts-tooltip-cursor{fill:var(--bi-hover)!important}.grid-card .recharts-active-bar{fill-opacity:.85;filter:brightness(1.1)}.ds-section{margin-bottom:24px}.ds-card{background-color:var(--bi-card-bg);border-radius:var(--bi-radius);border:1px solid var(--bi-card-border);position:relative;overflow:hidden;transition:transform .15s ease,box-shadow .15s ease,border-color .15s ease}.ds-card-nohover{transform:none}.ds-card:hover{transform:translateY(-2px);box-shadow:var(--bi-shadow)}.ds-card-header{display:flex;align-items:center;position:relative;padding:2px 10px;justify-content:space-between;margin-bottom:4px}.ds-card-title{font-size:.875rem;font-weight:500;color:var(--bi-text-2);text-transform:uppercase;letter-spacing:.05em;margin:0}.ds-card-icon{width:32px;height:32px;display:flex;align-items:center;justify-content:center;border-radius:var(--bi-radius);font-size:16px;background-color:var(--bi-accent-soft);color:var(--bi-accent)}.ds-card-body{flex:1;padding-left:5px;padding-right:5px}.ds-card-footer{margin-top:16px;padding-top:12px;border-top:1px solid var(--bi-card-border);display:flex;align-items:center;justify-content:space-between;font-size:.875rem;color:var(--bi-text-2)}.kpi-change{display:inline-flex;align-items:center;gap:4px;font-size:.875rem;font-weight:500;padding:2px 6px;border-radius:var(--bi-radius-sm)}.kpi-change-up{background-color:var(--bi-positive-soft);color:var(--bi-positive)}.kpi-change-down{background-color:var(--bi-negative-soft);color:var(--bi-negative)}.kpi-change-flat,.kpi-change-neutral{background-color:var(--bi-neutral-soft);color:var(--bi-neutral)}.quick-stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:5px}.quick-stat,.quick-stat-nohover{display:flex;align-items:center;gap:12px;padding:12px;background-color:var(--bi-surface-1);border-radius:var(--bi-radius);transition:background-color .15s ease}.quick-stat-nohover{background-color:inherit}.quick-stat:hover{background-color:var(--bi-surface-2)}.quick-stat-icon{width:48px;height:48px;display:flex;align-items:center;justify-content:center;border-radius:var(--bi-radius);font-size:20px;flex-shrink:0}.quick-stat-icon.kpi{background-color:var(--bi-accent-soft);color:var(--bi-accent)}.quick-stat-content{flex:1;min-width:0;align-items:flex-start}.quick-stat-value{font-size:1.25rem;font-weight:700;color:var(--bi-text-1);line-height:1.2}.quick-stat-value .thousand,.quick-stat-value .million,.quick-stat-value .billion{font-size:.7em;opacity:.7;margin-left:2px}.quick-stat-label{font-size:.875rem;color:var(--bi-text-2);line-height:1.3;margin-top:2px;max-height:70px;overflow:hidden}.quick-stat-label p{margin:0}@media(max-width:768px){.quick-stats{grid-template-columns:1fr}.quick-stat-icon{width:40px;height:40px;font-size:18px}}@media print{.ds-card{break-inside:avoid;box-shadow:none}.ds-card:hover{transform:none;box-shadow:none}}.dscard-placeholder{height:100%;border:1px dashed var(--bi-sketch-dash);border-radius:var(--bi-radius, 10px);text-align:center;align-content:center}.dscard-placeholder-naked{height:100%;border:1px dashed var(--bi-sketch-dash-faint);border-radius:var(--bi-radius, 10px);text-align:center;align-content:center;background-color:transparent!important}.grid-card-sketch-add{border:0}.content-sketch-add-cell{height:100px;width:70%;align-content:center;border-radius:var(--bi-radius, 10px);background-color:var(--bi-card-bg)}.content-sketch-add-row{height:50%;width:100%;border-radius:var(--bi-radius, 10px);align-content:center;background-color:var(--bi-card-bg)}.react-grid-placeholder-example{background:var(--bi-overlay)!important;border:1px dashed var(--bi-sketch-dash);border-radius:var(--bi-radius-sm, 8px);opacity:1!important}.llm-env-highlight-active{outline:2px solid var(--bi-highlight-outline)!important;outline-offset:2px;box-shadow:0 0 0 4px var(--bi-highlight-glow)!important;transition:outline-color .2s ease,box-shadow .2s ease}.llm-env-card-sketch .Mui-selected{background-color:var(--bi-sketch-selection)!important}
@@ -0,0 +1,32 @@
1
+ import { default as React } from 'react';
2
+ import { Theme } from '@mui/material/styles';
3
+ /**
4
+ * The CSS custom properties the package's stylesheets consume
5
+ * (`GridLayout.css`, `inline.css`, `composer.css`). Every value is derived from the MUI theme —
6
+ * the stylesheets themselves contain no colour.
7
+ */
8
+ export declare function computeBiCssVars(theme: Theme): Record<string, string>;
9
+ export interface BiThemeBridgeProps {
10
+ /**
11
+ * With children: renders a wrapper `div` carrying the variables as inline
12
+ * style, so the theme applies to that subtree only (several themes may
13
+ * coexist on one page). Without children: writes the variables onto
14
+ * `document.documentElement` on mount and updates them when the theme
15
+ * changes.
16
+ */
17
+ children?: React.ReactNode;
18
+ className?: string;
19
+ style?: React.CSSProperties;
20
+ }
21
+ /**
22
+ * Publishes the theme-derived CSS custom properties the package stylesheets
23
+ * read. Mount it once inside your `<ThemeProvider>` (either around the BI
24
+ * surface, or childless at the app root).
25
+ */
26
+ export declare const BiThemeBridge: React.FC<BiThemeBridgeProps>;
27
+ /**
28
+ * Hook form of the bridge: applies the variables to `target` (default:
29
+ * `document.documentElement`) for as long as the calling component is mounted.
30
+ */
31
+ export declare function useBiCssVars(target?: HTMLElement | null): Record<string, string>;
32
+ export default BiThemeBridge;
@@ -0,0 +1,23 @@
1
+ /** The BI-specific slice of the MUI palette. */
2
+ export interface BiPalette {
3
+ /** Categorical series colours, used in order by charts, pies, treemaps and map bubbles. */
4
+ series: string[];
5
+ /** "Good" trend / gauge band. */
6
+ positive: string;
7
+ /** "Bad" trend / gauge band. */
8
+ negative: string;
9
+ /** Flat trend / neutral band. */
10
+ neutral: string;
11
+ }
12
+ declare module '@mui/material/styles' {
13
+ interface Palette {
14
+ bi: BiPalette;
15
+ }
16
+ interface PaletteOptions {
17
+ bi?: Partial<BiPalette>;
18
+ }
19
+ }
20
+ /** Series set tuned for a light canvas (deeper, more saturated hues). */
21
+ export declare const biLightPalette: BiPalette;
22
+ /** Series set tuned for a dark canvas (the legacy Envision v2 chart palette, extended). */
23
+ export declare const biDarkPalette: BiPalette;
@@ -0,0 +1,25 @@
1
+ import { Theme, ThemeOptions } from '@mui/material/styles';
2
+ import { BiPalette } from './biPalette';
3
+ /**
4
+ * Resolve the BI palette for a theme without mutating it: the host's
5
+ * `palette.bi` wins field by field, the mode-appropriate default fills the
6
+ * gaps. Safe to call on a theme that never heard of `palette.bi`.
7
+ */
8
+ export declare function resolveBiPalette(theme: Theme): BiPalette;
9
+ /**
10
+ * Returns a theme whose `palette.bi` is fully populated. When the host already
11
+ * set every field this is the same theme instance; otherwise a new theme is
12
+ * derived with `createTheme(theme, { palette: { bi } })` so every other
13
+ * theme field is preserved.
14
+ */
15
+ export declare function withBiPalette(theme: Theme): Theme;
16
+ /**
17
+ * `createTheme` with the BI augmentation applied. Accepts either a finished
18
+ * theme (`createBiTheme(myTheme)`) or plain `ThemeOptions`
19
+ * (`createBiTheme({ palette: { mode: 'light' } })`).
20
+ */
21
+ export declare function createBiTheme(base?: Theme | ThemeOptions): Theme;
22
+ /** i-th series colour of the theme's BI palette, wrapping around. */
23
+ export declare function biSeriesColor(theme: Theme, index: number): string;
24
+ /** Hook form of {@link resolveBiPalette} — reads the ambient MUI theme. */
25
+ export declare function useBiPalette(): BiPalette;
@@ -0,0 +1,5 @@
1
+ export { biLightPalette, biDarkPalette } from './biPalette';
2
+ export type { BiPalette } from './biPalette';
3
+ export { createBiTheme, withBiPalette, resolveBiPalette, biSeriesColor, useBiPalette } from './createBiTheme';
4
+ export { BiThemeBridge, useBiCssVars, computeBiCssVars } from './BiThemeBridge';
5
+ export type { BiThemeBridgeProps } from './BiThemeBridge';
@@ -0,0 +1,2 @@
1
+ export * from './theme/index'
2
+ export {}
package/dist/theme.js ADDED
@@ -0,0 +1,15 @@
1
+ import { b as s, a as t, c as i, d as r, r as B, u as o, w as l } from "./createBiTheme-TyUv_UHM.js";
2
+ import { B as u, c as P, u as b } from "./index-D7Oo_dC-.js";
3
+ export {
4
+ u as BiThemeBridge,
5
+ s as biDarkPalette,
6
+ t as biLightPalette,
7
+ i as biSeriesColor,
8
+ P as computeBiCssVars,
9
+ r as createBiTheme,
10
+ B as resolveBiPalette,
11
+ b as useBiCssVars,
12
+ o as useBiPalette,
13
+ l as withBiPalette
14
+ };
15
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1,83 @@
1
+ var g = Object.defineProperty;
2
+ var o = (t, n) => g(t, "name", { value: n, configurable: !0 });
3
+ import { extendModuleRegistry as M, extendDefaultScope as _, createUiToolRegistry as y } from "@aintela/chat/components";
4
+ import { ad as S, ax as B } from "./index-C6JQ6770.js";
5
+ import { jsx as l } from "react/jsx-runtime";
6
+ import { Box as b } from "@mui/material";
7
+ import { M as m, a as I, C as E, I as R } from "./index-BYc79sSy.js";
8
+ import { B as V } from "./BiClientProvider-CWJochvi.js";
9
+ const f = /* @__PURE__ */ new Set();
10
+ function z(t) {
11
+ const n = { ...S(), ...t.extraScope ?? {} }, r = t.specifiers.filter((a) => !f.has(a));
12
+ for (const a of r)
13
+ M(a, n), f.add(a);
14
+ (r.length > 0 || t.extraScope) && _(n), B(t.specifiers, t.extraHostModules);
15
+ }
16
+ o(z, "registerBiModules");
17
+ function G() {
18
+ f.clear();
19
+ }
20
+ o(G, "resetBiModuleRegistration");
21
+ function h(t) {
22
+ const n = t ?? {}, r = /* @__PURE__ */ o((a) => {
23
+ const c = n[a] ?? n[a.charAt(0).toUpperCase() + a.slice(1)];
24
+ return c == null ? void 0 : String(c);
25
+ }, "g");
26
+ return {
27
+ currentValue: r("currentValue") ?? "",
28
+ previousValue: r("previousValue"),
29
+ prefix: r("prefix"),
30
+ suffix: r("suffix"),
31
+ differenceStyle: r("differenceStyle"),
32
+ description: r("description"),
33
+ icon: r("icon")
34
+ };
35
+ }
36
+ o(h, "normalizeMetricArgs");
37
+ function x(t, n) {
38
+ let r = t;
39
+ for (let a = 0; a < 2 && typeof r == "string"; a++)
40
+ try {
41
+ r = JSON.parse(r);
42
+ } catch {
43
+ return n;
44
+ }
45
+ return r ?? n;
46
+ }
47
+ o(x, "parseJsonArg");
48
+ function P(t = {}) {
49
+ const { client: n, onExpandChart: r, onExpandIframe: a } = t, c = /* @__PURE__ */ o((e) => {
50
+ const s = /* @__PURE__ */ l(b, { sx: { my: 1 }, children: e });
51
+ return n ? /* @__PURE__ */ l(V, { client: n, children: s }) : s;
52
+ }, "wrap"), p = (t.builder ?? y()).render("present_metric", (e) => {
53
+ const s = h(e);
54
+ return s.currentValue ? c(/* @__PURE__ */ l(m, { partial: !1, ...s })) : null;
55
+ }).render("present_metric_group", (e) => {
56
+ var s;
57
+ return (s = e.metrics) != null && s.length ? c(
58
+ /* @__PURE__ */ l(I, { partial: !1, title: e.title, materialIcon: e.materialIcon, footNote: e.footNote, children: e.metrics.map((u, d) => /* @__PURE__ */ l(m, { partial: !1, ...h(u) }, d)) })
59
+ ) : null;
60
+ }).render("present_chart", (e) => e.src ? c(/* @__PURE__ */ l(E, { src: e.src, name: e.name, alt: e.alt, reasoning: e.reasoning, naked: e.naked, onExpand: r })) : null).render("present_iframe", (e) => !e.src || !e.name ? null : c(/* @__PURE__ */ l(R, { partial: !1, src: e.src, name: e.name, onExpand: a }))), i = t.environment;
61
+ return i ? p.action("refresh_dashboard", () => {
62
+ var e;
63
+ (e = i.refreshDashboard) == null || e.call(i);
64
+ }, { status: "Dashboard atualizado" }).action("present_dashboard_pad", (e) => {
65
+ var u, d;
66
+ const s = x(e.definitionJson, {});
67
+ e.mode === "create" ? (u = i.createDashboardPad) == null || u.call(i, s) : (d = i.updateDashboardPad) == null || d.call(i, s);
68
+ }, { status: "Rascunho atualizado" }).action("present_guide", (e) => {
69
+ var u;
70
+ const s = x(e.stepsJson, []);
71
+ Array.isArray(s) && s.length > 0 && ((u = i.showGuide) == null || u.call(i, s));
72
+ }, { status: "Guia iniciado" }) : p;
73
+ }
74
+ o(P, "createBiUiTools");
75
+ const T = "0.2.0";
76
+ export {
77
+ T as B,
78
+ G as a,
79
+ P as c,
80
+ h as n,
81
+ z as r
82
+ };
83
+ //# sourceMappingURL=version-DnqajORq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-DnqajORq.js","sources":["../src/runtime/registerBiModules.ts","../src/runtime/createBiUiTools.tsx","../src/runtime/version.ts"],"sourcesContent":["import { extendModuleRegistry, extendDefaultScope } from '@aintela/chat/components';\nimport { getBiModuleSurface } from './biModuleSurface';\nimport { seedHostModules } from './loadDashboardBundle';\n\nexport interface RegisterBiModulesOptions {\n /**\n * The module specifiers LLM-emitted code imports from. The compiled\n * snippet does `__scope[\"<specifier>\"].X` and a bundle does\n * `require(\"<specifier>\")`, so every string here must match what the\n * template / instruction files told the model to write.\n *\n * AIA starts clean: `['@aintela/bi']`. Envision must keep resolving the\n * legacy keys forever (persisted sessions + content-hashed bundles):\n * `['@aintela/bi', '@envision/ui-library', '@envision/ui-library/components', …]`.\n */\n specifiers: string[];\n /**\n * Extra values merged into the surface under every specifier AND into the\n * bare-identifier scope — e.g. Envision's `VizLibrary` compat shim, or a\n * host's own components the instructions mention.\n */\n extraScope?: Record<string, unknown>;\n /**\n * Extra `require()` targets for dashboard bundles keyed by specifier\n * (`{ 'date-fns': dateFns, lodash }`). Not in the live-TSX scope.\n */\n extraHostModules?: Record<string, unknown>;\n}\n\nconst registeredKeys = new Set<string>();\n\n/**\n * Makes this library resolvable from LLM-generated code:\n * 1. `extendModuleRegistry(specifier, surface)` once per specifier (live TSX imports);\n * 2. `extendDefaultScope(surface)` once (bare identifiers, no import line);\n * 3. seeds the dashboard-bundle loader's host-module map under the same specifiers.\n *\n * Idempotent per specifier — call it at app start, before the first chat turn\n * or bundle renders.\n */\nexport function registerBiModules(options: RegisterBiModulesOptions): void {\n const surface = { ...getBiModuleSurface(), ...(options.extraScope ?? {}) };\n\n const fresh = options.specifiers.filter((s) => !registeredKeys.has(s));\n for (const specifier of fresh) {\n extendModuleRegistry(specifier, surface);\n registeredKeys.add(specifier);\n }\n if (fresh.length > 0 || options.extraScope) {\n extendDefaultScope(surface);\n }\n seedHostModules(options.specifiers, options.extraHostModules);\n}\n\n/** Test seam. */\nexport function resetBiModuleRegistration(): void {\n registeredKeys.clear();\n}\n","import React from 'react';\nimport { Box } from '@mui/material';\nimport { createUiToolRegistry } from '@aintela/chat/components';\nimport type { UiToolRegistryBuilder } from '@aintela/chat/components';\nimport { Chart, Metric, MetricGroup, IFrame } from '../inline';\nimport type { ChartExpandInfo, IFrameExpandInfo } from '../inline';\nimport { BiClientProvider, type BiClient } from '../client';\nimport type { DashboardEnvironment, GuideStep } from '../composer/environment/types';\n\n/**\n * The explorer's visual vocabulary as `uiTools` registry entries. The chat\n * library owns the plumbing (routing `[KernelUiFunction]` calls, unwrapping\n * args, replay); here we only declare WHAT to draw per tool name.\n *\n * `present_dashboard` and `present_tsx` are deliberately NOT registered — the\n * dashboard hand-off belongs to the dashboard slice and `present_tsx`'s\n * compiled-JS sibling-event plumbing is host policy. Both are added by the\n * host on the returned builder:\n *\n * const uiTools = createBiUiTools({ client })\n * .render('present_dashboard', (a) => <ScriptDashboardViewer dashboardId={a.id} />)\n * .build();\n */\nexport interface CreateBiUiToolsOptions {\n /**\n * Client whose `artifactUrl` / `iframeUrl` resolve the images. When\n * omitted the renderers rely on an ambient `<BiClientProvider>` above the\n * chat pane (which is how a host also passes the session id).\n */\n client?: BiClient;\n /** Expand handlers (a lightbox, an artifact panel). Default: open in a new tab. */\n onExpandChart?: (info: ChartExpandInfo) => void;\n onExpandIframe?: (info: IFrameExpandInfo) => void;\n /** Start from an existing builder to chain more tools before these. */\n builder?: UiToolRegistryBuilder;\n /**\n * The composer's environment (`useComposerEnvironment()` /\n * `environmentFromStore(store)`). When supplied, the three ACTION tools\n * the dashboard agent calls are registered too: `refresh_dashboard`,\n * `present_dashboard_pad` (`definitionJson` + `mode`) and `present_guide`\n * (`stepsJson`). Without it they are left to the host, like `present_dashboard`.\n */\n environment?: Partial<DashboardEnvironment>;\n}\n\n// present_metric uses camelCase params, but present_metric_group's items come\n// from a C# class serialised PascalCase. Read either casing.\nexport interface PresentMetricArgs {\n currentValue: string;\n previousValue?: string;\n prefix?: string;\n suffix?: string;\n differenceStyle?: 'Percentage' | 'Value';\n description?: string;\n icon?: string;\n}\n\nexport function normalizeMetricArgs(raw: unknown): PresentMetricArgs {\n const o = (raw ?? {}) as Record<string, unknown>;\n const g = (k: string): string | undefined => {\n const v = o[k] ?? o[k.charAt(0).toUpperCase() + k.slice(1)];\n return v == null ? undefined : String(v);\n };\n return {\n currentValue: g('currentValue') ?? '',\n previousValue: g('previousValue'),\n prefix: g('prefix'),\n suffix: g('suffix'),\n differenceStyle: g('differenceStyle') as 'Percentage' | 'Value' | undefined,\n description: g('description'),\n icon: g('icon'),\n };\n}\n\nexport interface PresentChartArgs { src?: string; name?: string; alt?: string; reasoning?: string; naked?: boolean }\nexport interface PresentMetricGroupArgs { title?: string; materialIcon?: string; footNote?: string; metrics?: unknown[] }\nexport interface PresentIframeArgs { src?: string; name?: string }\nexport interface PresentDashboardPadArgs { definitionJson?: string; mode?: 'create' | 'update' | string }\nexport interface PresentGuideArgs { stepsJson?: string }\n\n/** JSON text that may have been encoded once or twice on the way through the tool call. */\nfunction parseJsonArg<T>(raw: string | undefined, fallback: T): T {\n let value: unknown = raw;\n for (let i = 0; i < 2 && typeof value === 'string'; i++) {\n try {\n value = JSON.parse(value);\n } catch {\n return fallback;\n }\n }\n return (value ?? fallback) as T;\n}\n\nexport function createBiUiTools(options: CreateBiUiToolsOptions = {}): UiToolRegistryBuilder {\n const { client, onExpandChart, onExpandIframe } = options;\n const wrap = (node: React.ReactNode): React.ReactNode => {\n const boxed = <Box sx={{ my: 1 }}>{node}</Box>;\n return client ? <BiClientProvider client={client}>{boxed}</BiClientProvider> : boxed;\n };\n\n const builder = (options.builder ?? createUiToolRegistry())\n .render<PresentMetricArgs>('present_metric', (args) => {\n const m = normalizeMetricArgs(args);\n if (!m.currentValue) return null;\n return wrap(<Metric partial={false} {...m} />);\n })\n .render<PresentMetricGroupArgs>('present_metric_group', (a) => {\n if (!a.metrics?.length) return null;\n return wrap(\n <MetricGroup partial={false} title={a.title} materialIcon={a.materialIcon} footNote={a.footNote}>\n {a.metrics.map((raw, i) => (\n <Metric key={i} partial={false} {...normalizeMetricArgs(raw)} />\n ))}\n </MetricGroup>,\n );\n })\n .render<PresentChartArgs>('present_chart', (a) => {\n if (!a.src) return null;\n return wrap(<Chart src={a.src} name={a.name} alt={a.alt} reasoning={a.reasoning} naked={a.naked} onExpand={onExpandChart} />);\n })\n .render<PresentIframeArgs>('present_iframe', (a) => {\n if (!a.src || !a.name) return null;\n return wrap(<IFrame partial={false} src={a.src} name={a.name} onExpand={onExpandIframe} />);\n });\n\n const env = options.environment;\n if (!env) return builder;\n\n // Action tools: side effects on the composer, fired once per tool-call id\n // by the chat library; the status chip shows after a successful run.\n return builder\n .action('refresh_dashboard', () => {\n env.refreshDashboard?.();\n }, { status: 'Dashboard atualizado' })\n .action<PresentDashboardPadArgs>('present_dashboard_pad', (a) => {\n const def = parseJsonArg<Record<string, unknown>>(a.definitionJson, {});\n if (a.mode === 'create') env.createDashboardPad?.(def as never);\n else env.updateDashboardPad?.(def as never);\n }, { status: 'Rascunho atualizado' })\n .action<PresentGuideArgs>('present_guide', (a) => {\n const steps = parseJsonArg<GuideStep[]>(a.stepsJson, []);\n if (Array.isArray(steps) && steps.length > 0) env.showGuide?.(steps);\n }, { status: 'Guia iniciado' });\n}\n","/**\n * The package version, so a host can log a mismatch against the server-side\n * `AIntelA.Bi.Agents` version at handshake (the instruction files describe\n * THIS React API). Kept in sync with package.json by `tests/runtime/version.test.ts`.\n */\nexport const BI_RUNTIME_VERSION = '0.2.0';\n"],"names":["registeredKeys","registerBiModules","options","surface","getBiModuleSurface","fresh","s","specifier","extendModuleRegistry","extendDefaultScope","seedHostModules","__name","resetBiModuleRegistration","normalizeMetricArgs","raw","o","g","k","v","parseJsonArg","fallback","value","i","createBiUiTools","client","onExpandChart","onExpandIframe","wrap","node","boxed","Box","jsx","BiClientProvider","builder","createUiToolRegistry","args","m","Metric","a","_a","MetricGroup","Chart","IFrame","env","def","_b","steps","BI_RUNTIME_VERSION"],"mappings":"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"}