semiotic 3.4.2 → 3.5.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 (160) hide show
  1. package/CLAUDE.md +114 -9
  2. package/README.md +45 -4
  3. package/ai/behaviorContracts.cjs +311 -0
  4. package/ai/chartSuggestions.cjs +291 -0
  5. package/ai/cli.js +255 -30
  6. package/ai/componentMetadata.cjs +107 -0
  7. package/ai/dist/mcp-server.js +907 -227
  8. package/ai/schema.json +3954 -2537
  9. package/ai/system-prompt.md +23 -4
  10. package/dist/components/LinkedCharts.d.ts +5 -1
  11. package/dist/components/Tooltip/Tooltip.d.ts +1 -1
  12. package/dist/components/charts/custom/NetworkCustomChart.d.ts +64 -0
  13. package/dist/components/charts/custom/OrdinalCustomChart.d.ts +71 -0
  14. package/dist/components/charts/custom/XYCustomChart.d.ts +59 -0
  15. package/dist/components/charts/geo/ChoroplethMap.d.ts +93 -2
  16. package/dist/components/charts/geo/DistanceCartogram.d.ts +51 -4
  17. package/dist/components/charts/geo/FlowMap.d.ts +55 -0
  18. package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +53 -0
  19. package/dist/components/charts/index.d.ts +6 -0
  20. package/dist/components/charts/network/ChordDiagram.d.ts +34 -2
  21. package/dist/components/charts/network/CirclePack.d.ts +36 -1
  22. package/dist/components/charts/network/ForceDirectedGraph.d.ts +130 -2
  23. package/dist/components/charts/network/OrbitDiagram.d.ts +37 -0
  24. package/dist/components/charts/network/SankeyDiagram.d.ts +51 -2
  25. package/dist/components/charts/network/TreeDiagram.d.ts +37 -2
  26. package/dist/components/charts/network/Treemap.d.ts +36 -2
  27. package/dist/components/charts/ordinal/BarChart.d.ts +111 -1
  28. package/dist/components/charts/ordinal/BoxPlot.d.ts +31 -0
  29. package/dist/components/charts/ordinal/DonutChart.d.ts +36 -0
  30. package/dist/components/charts/ordinal/DotPlot.d.ts +31 -0
  31. package/dist/components/charts/ordinal/FunnelChart.d.ts +40 -0
  32. package/dist/components/charts/ordinal/GaugeChart.d.ts +45 -0
  33. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +38 -0
  34. package/dist/components/charts/ordinal/Histogram.d.ts +95 -0
  35. package/dist/components/charts/ordinal/LikertChart.d.ts +42 -0
  36. package/dist/components/charts/ordinal/PieChart.d.ts +90 -1
  37. package/dist/components/charts/ordinal/RidgelinePlot.d.ts +27 -0
  38. package/dist/components/charts/ordinal/StackedBarChart.d.ts +38 -0
  39. package/dist/components/charts/ordinal/SwarmPlot.d.ts +36 -0
  40. package/dist/components/charts/ordinal/SwimlaneChart.d.ts +60 -0
  41. package/dist/components/charts/ordinal/ViolinPlot.d.ts +32 -0
  42. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +22 -4
  43. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +5 -2
  44. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +24 -3
  45. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +12 -0
  46. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +14 -0
  47. package/dist/components/charts/realtime/defaultRealtimeTooltip.d.ts +43 -0
  48. package/dist/components/charts/realtime/resolveWindowSize.d.ts +26 -0
  49. package/dist/components/charts/shared/chartSpecs.d.ts +91 -0
  50. package/dist/components/charts/shared/colorPalettes.d.ts +62 -0
  51. package/dist/components/charts/shared/colorUtils.d.ts +9 -10
  52. package/dist/components/charts/shared/numberFormat.d.ts +58 -0
  53. package/dist/components/charts/shared/sparseArray.d.ts +27 -0
  54. package/dist/components/charts/shared/streamPropsHelpers.d.ts +113 -0
  55. package/dist/components/charts/shared/timeFormat.d.ts +60 -0
  56. package/dist/components/charts/shared/useChartSetup.d.ts +8 -0
  57. package/dist/components/charts/shared/useCustomChartSetup.d.ts +84 -0
  58. package/dist/components/charts/shared/useFrameImperativeHandle.d.ts +28 -0
  59. package/dist/components/charts/shared/useOrdinalStreaming.d.ts +6 -19
  60. package/dist/components/charts/shared/useStreamingLegend.d.ts +27 -11
  61. package/dist/components/charts/shared/validateProps.d.ts +2 -2
  62. package/dist/components/charts/shared/validationMap.d.ts +2 -1
  63. package/dist/components/charts/shared/withChartWrapper.d.ts +13 -4
  64. package/dist/components/charts/xy/AreaChart.d.ts +30 -1
  65. package/dist/components/charts/xy/CandlestickChart.d.ts +33 -6
  66. package/dist/components/charts/xy/ConnectedScatterplot.d.ts +24 -0
  67. package/dist/components/charts/xy/MinimapChart.d.ts +51 -0
  68. package/dist/components/charts/xy/MultiAxisLineChart.d.ts +27 -0
  69. package/dist/components/charts/xy/QuadrantChart.d.ts +21 -0
  70. package/dist/components/charts/xy/Scatterplot.d.ts +34 -2
  71. package/dist/components/charts/xy/ScatterplotMatrix.d.ts +16 -0
  72. package/dist/components/charts/xy/StackedAreaChart.d.ts +49 -1
  73. package/dist/components/realtime/types.d.ts +2 -4
  74. package/dist/components/recipes/bullet.d.ts +86 -0
  75. package/dist/components/recipes/calendar.d.ts +43 -0
  76. package/dist/components/recipes/dagre.d.ts +56 -0
  77. package/dist/components/recipes/flextree.d.ts +55 -0
  78. package/dist/components/recipes/marimekko.d.ts +55 -0
  79. package/dist/components/recipes/parallelCoordinates.d.ts +97 -0
  80. package/dist/components/recipes/recipeUtils.d.ts +27 -0
  81. package/dist/components/recipes/waffle.d.ts +46 -0
  82. package/dist/components/semiotic-ai.d.ts +4 -0
  83. package/dist/components/semiotic-network.d.ts +3 -0
  84. package/dist/components/semiotic-ordinal.d.ts +3 -0
  85. package/dist/components/semiotic-recipes.d.ts +24 -0
  86. package/dist/components/semiotic-xy.d.ts +3 -0
  87. package/dist/components/semiotic.d.ts +2 -2
  88. package/dist/components/server/renderToStaticSVG.d.ts +8 -2
  89. package/dist/components/server/serverChartConfigs.d.ts +47 -1
  90. package/dist/components/server/staticAnnotations.d.ts +6 -0
  91. package/dist/components/store/ObservationStore.d.ts +1 -3
  92. package/dist/components/store/SelectionStore.d.ts +1 -3
  93. package/dist/components/store/ThemeStore.d.ts +4 -4
  94. package/dist/components/store/TooltipStore.d.ts +1 -3
  95. package/dist/components/store/createStore.d.ts +4 -2
  96. package/dist/components/stream/CanvasHitTester.d.ts +10 -8
  97. package/dist/components/stream/DataSourceAdapter.d.ts +9 -0
  98. package/dist/components/stream/GeoPipelineStore.d.ts +9 -0
  99. package/dist/components/stream/GeoTileRenderer.d.ts +14 -0
  100. package/dist/components/stream/NetworkPipelineStore.d.ts +25 -0
  101. package/dist/components/stream/OrdinalPipelineStore.d.ts +12 -0
  102. package/dist/components/stream/PipelineStore.d.ts +51 -0
  103. package/dist/components/stream/SVGOverlay.d.ts +12 -0
  104. package/dist/components/stream/SceneGraph.d.ts +15 -1
  105. package/dist/components/stream/SceneToSVG.d.ts +1 -1
  106. package/dist/components/stream/categoryDomain.d.ts +4 -0
  107. package/dist/components/stream/composeOverlays.d.ts +15 -0
  108. package/dist/components/stream/customLayout.d.ts +76 -0
  109. package/dist/components/stream/customLayoutPalette.d.ts +29 -0
  110. package/dist/components/stream/geoTypes.d.ts +13 -0
  111. package/dist/components/stream/hoverUtils.d.ts +4 -10
  112. package/dist/components/stream/networkCustomLayout.d.ts +67 -0
  113. package/dist/components/stream/networkTypes.d.ts +45 -0
  114. package/dist/components/stream/ordinalCustomLayout.d.ts +84 -0
  115. package/dist/components/stream/ordinalTypes.d.ts +35 -1
  116. package/dist/components/stream/renderers/barFunnelCanvasRenderer.d.ts +9 -1
  117. package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +92 -0
  118. package/dist/components/stream/sampleCurvePath.d.ts +9 -0
  119. package/dist/components/stream/types.d.ts +44 -1
  120. package/dist/components/stream/useHydration.d.ts +89 -0
  121. package/dist/components/stream/useStableShallow.d.ts +1 -0
  122. package/dist/components/stream/xySceneBuilders/types.d.ts +4 -0
  123. package/dist/geo.min.js +2 -1
  124. package/dist/geo.module.min.js +2 -1
  125. package/dist/network.min.js +2 -1
  126. package/dist/network.module.min.js +2 -1
  127. package/dist/ordinal.min.js +2 -1
  128. package/dist/ordinal.module.min.js +2 -1
  129. package/dist/realtime.min.js +2 -1
  130. package/dist/realtime.module.min.js +2 -1
  131. package/dist/semiotic-ai.d.ts +69 -65
  132. package/dist/semiotic-ai.min.js +2 -1
  133. package/dist/semiotic-ai.module.min.js +2 -1
  134. package/dist/semiotic-data.d.ts +4 -4
  135. package/dist/semiotic-geo.d.ts +15 -15
  136. package/dist/semiotic-network.d.ts +19 -16
  137. package/dist/semiotic-ordinal.d.ts +31 -28
  138. package/dist/semiotic-realtime.d.ts +17 -17
  139. package/dist/semiotic-recipes.d.ts +24 -0
  140. package/dist/semiotic-recipes.min.js +1 -0
  141. package/dist/semiotic-recipes.module.min.js +1 -0
  142. package/dist/semiotic-server.d.ts +6 -6
  143. package/dist/semiotic-statisticalOverlays-C3DsOgr_.js +1 -0
  144. package/dist/semiotic-themes.d.ts +3 -3
  145. package/dist/semiotic-themes.min.js +2 -1
  146. package/dist/semiotic-themes.module.min.js +2 -1
  147. package/dist/semiotic-utils.d.ts +23 -23
  148. package/dist/semiotic-utils.min.js +2 -1
  149. package/dist/semiotic-utils.module.min.js +2 -1
  150. package/dist/semiotic-xy.d.ts +27 -24
  151. package/dist/semiotic.d.ts +63 -63
  152. package/dist/semiotic.min.js +2 -1
  153. package/dist/semiotic.module.min.js +2 -1
  154. package/dist/server.min.js +1 -1
  155. package/dist/server.module.min.js +1 -1
  156. package/dist/test-utils/canvasMock.d.ts +34 -5
  157. package/dist/xy.min.js +2 -1
  158. package/dist/xy.module.min.js +2 -1
  159. package/package.json +38 -17
  160. package/dist/semiotic-statisticalOverlays-Ckd_jM8z.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semiotic",
3
- "version": "3.4.2",
3
+ "version": "3.5.0",
4
4
  "mcpName": "io.github.nteract/semiotic",
5
5
  "description": "React data visualization library with built-in MCP server for AI-assisted chart generation",
6
6
  "main": "dist/semiotic.min.js",
@@ -78,6 +78,12 @@
78
78
  "require": "./dist/semiotic-utils.min.js",
79
79
  "default": "./dist/semiotic-utils.module.min.js"
80
80
  },
81
+ "./recipes": {
82
+ "types": "./dist/semiotic-recipes.d.ts",
83
+ "import": "./dist/semiotic-recipes.module.min.js",
84
+ "require": "./dist/semiotic-recipes.min.js",
85
+ "default": "./dist/semiotic-recipes.module.min.js"
86
+ },
81
87
  "./package.json": "./package.json"
82
88
  },
83
89
  "files": [
@@ -87,6 +93,9 @@
87
93
  "ai/schema.json",
88
94
  "ai/system-prompt.md",
89
95
  "ai/examples.md",
96
+ "ai/componentMetadata.cjs",
97
+ "ai/behaviorContracts.cjs",
98
+ "ai/chartSuggestions.cjs",
90
99
  "ai/cli.js",
91
100
  "ai/dist/*.js",
92
101
  "CLAUDE.md",
@@ -104,10 +113,11 @@
104
113
  "test:visual:update": "playwright test --update-snapshots",
105
114
  "bench": "vitest bench",
106
115
  "bench:ui": "vitest bench --ui",
107
- "bench:baseline": "vitest bench --run && node scripts/save-baseline.js",
108
- "bench:compare": "vitest bench --run && node scripts/compare-baseline.js",
109
- "serve-examples": "npm run dist && parcel serve integration-tests/index.html integration-tests/xy-examples/index.html integration-tests/ordinal-examples/index.html integration-tests/network-examples/index.html integration-tests/hoc-legend-examples/index.html integration-tests/coordinated-examples/index.html integration-tests/accessibility-examples/index.html integration-tests/geo-examples/index.html integration-tests/realtime-examples/index.html integration-tests/streaming-regression-examples/index.html integration-tests/themed-examples/index.html integration-tests/background-graphics-examples/index.html integration-tests/histogram-theme-stroke-examples/index.html integration-tests/primitive-theme-matrix-examples/index.html integration-tests/status-scale-theme-examples/index.html integration-tests/primitive-props-examples/index.html integration-tests/chart-modes-examples/index.html --dist-dir .parcel-cache/integration-tests",
110
- "serve-examples:ci": "parcel serve integration-tests/index.html integration-tests/xy-examples/index.html integration-tests/ordinal-examples/index.html integration-tests/network-examples/index.html integration-tests/hoc-legend-examples/index.html integration-tests/coordinated-examples/index.html integration-tests/accessibility-examples/index.html integration-tests/geo-examples/index.html integration-tests/realtime-examples/index.html integration-tests/streaming-regression-examples/index.html integration-tests/themed-examples/index.html integration-tests/background-graphics-examples/index.html integration-tests/histogram-theme-stroke-examples/index.html integration-tests/primitive-theme-matrix-examples/index.html integration-tests/status-scale-theme-examples/index.html integration-tests/primitive-props-examples/index.html integration-tests/chart-modes-examples/index.html --dist-dir .parcel-cache/integration-tests",
116
+ "bench:baseline": "node scripts/save-bench-baseline.mjs",
117
+ "bench:compare": "node scripts/compare-bench-baseline.mjs",
118
+ "bench:pr-vs-main": "node scripts/bench-pr-vs-main.mjs",
119
+ "serve-examples": "npm run dist && parcel serve integration-tests/index.html integration-tests/xy-examples/index.html integration-tests/ordinal-examples/index.html integration-tests/network-examples/index.html integration-tests/hoc-legend-examples/index.html integration-tests/coordinated-examples/index.html integration-tests/accessibility-examples/index.html integration-tests/geo-examples/index.html integration-tests/realtime-examples/index.html integration-tests/streaming-regression-examples/index.html integration-tests/themed-examples/index.html integration-tests/background-graphics-examples/index.html integration-tests/histogram-theme-stroke-examples/index.html integration-tests/primitive-theme-matrix-examples/index.html integration-tests/status-scale-theme-examples/index.html integration-tests/primitive-props-examples/index.html integration-tests/chart-modes-examples/index.html integration-tests/ssr-parity-examples/index.html --dist-dir .parcel-cache/integration-tests",
120
+ "serve-examples:ci": "parcel serve integration-tests/index.html integration-tests/xy-examples/index.html integration-tests/ordinal-examples/index.html integration-tests/network-examples/index.html integration-tests/hoc-legend-examples/index.html integration-tests/coordinated-examples/index.html integration-tests/accessibility-examples/index.html integration-tests/geo-examples/index.html integration-tests/realtime-examples/index.html integration-tests/streaming-regression-examples/index.html integration-tests/themed-examples/index.html integration-tests/background-graphics-examples/index.html integration-tests/histogram-theme-stroke-examples/index.html integration-tests/primitive-theme-matrix-examples/index.html integration-tests/status-scale-theme-examples/index.html integration-tests/primitive-props-examples/index.html integration-tests/chart-modes-examples/index.html integration-tests/ssr-parity-examples/index.html --dist-dir .parcel-cache/integration-tests",
111
121
  "dist": "node --max-old-space-size=8192 scripts/build.mjs",
112
122
  "dist:prod": "node --max-old-space-size=8192 scripts/build.mjs --production",
113
123
  "lint": "eslint src",
@@ -121,15 +131,32 @@
121
131
  "website:start:clean": "npm run clean && npm run dist:prod && parcel serve --target website --no-cache",
122
132
  "generate:ssr-gallery": "npx tsx scripts/ssr-gallery.tsx > docs/public/ssr-gallery.html 2>/dev/null",
123
133
  "generate:demo-gifs": "node -e \"try{require.resolve('sharp');require.resolve('gifenc')}catch{console.log('Skipping GIF generation (sharp/gifenc not installed)');process.exit(0)}\" && npx tsx scripts/generate-demo-gifs.ts",
124
- "website:build": "npm run dist:prod && npm run docs:api:json && npm run generate:ssr-gallery && npm run generate:demo-gifs && parcel build --target website && node scripts/prerender.mjs",
134
+ "website:build": "npm run dist:prod && npm run docs:api:json && npm run generate:ssr-gallery && npm run generate:demo-gifs && parcel build --target website && node scripts/prerender.mjs && npm run check:docs-routes",
125
135
  "build:mcp": "esbuild ai/mcp-server.ts --bundle --platform=node --target=node18 --format=cjs --outfile=ai/dist/mcp-server.js --external:react --external:react-dom --external:semiotic --external:semiotic/ai --external:semiotic/geo --banner:js='#!/usr/bin/env node'",
126
136
  "docs:api": "typedoc",
127
- "docs:api:json": "typedoc --json docs/public/api/api.json",
137
+ "docs:api:json": "typedoc --json docs/public/api/api.json && node scripts/generate-component-descriptions.mjs",
138
+ "docs:descriptions:json": "node scripts/generate-component-descriptions.mjs",
128
139
  "typescript": "tsc --noEmit",
140
+ "typescript:mcp": "tsc -p tsconfig.mcp.json --noEmit",
129
141
  "size": "size-limit",
130
- "check:schema": "node scripts/check-schema-freshness.js",
131
- "release:check": "npm run lint && npm run typescript && npm run test && npm run check:schema && npm run dist:prod && npm pack --dry-run",
132
- "prepublishOnly": "npm run lint && npm run typescript && npm run test && npm run check:schema && rm -rf dist && npm run dist:prod"
142
+ "check:pack": "node scripts/smoke-pack.mjs",
143
+ "check:api-surface": "node scripts/check-api-surface.mjs",
144
+ "docs:api-surface": "node scripts/generate-api-surface.mjs",
145
+ "docs:ai-contracts": "node scripts/generate-ai-behavior-contracts.mjs",
146
+ "check:claude-md-coverage": "node scripts/check-claude-md-coverage.js",
147
+ "check:context7": "node scripts/check-context7.mjs",
148
+ "check:mcp-registry": "node scripts/check-mcp-registry.mjs",
149
+ "check:surface": "node scripts/check-surface-parity.js",
150
+ "check:ai-contracts": "node scripts/generate-ai-behavior-contracts.mjs --check",
151
+ "check:ssr": "node scripts/check-ssr-alignment.js",
152
+ "check:chart-specs": "npx tsx scripts/check-chart-specs.ts",
153
+ "docs:chart-specs:schema": "npx tsx scripts/regenerate-schema.ts",
154
+ "check:test-quality": "node scripts/check-test-quality-gate.mjs",
155
+ "check:jsdoc-coverage": "node scripts/check-jsdoc-coverage.mjs",
156
+ "check:ai-examples-coverage": "node scripts/check-ai-examples-coverage.mjs",
157
+ "check:docs-routes": "node scripts/check-docs-routes.mjs",
158
+ "release:check": "npm run lint && npm run typescript && npm run typescript:mcp && npm run test && npm run check:chart-specs && npm run check:claude-md-coverage && npm run check:context7 && npm run check:mcp-registry && npm run check:surface && npm run check:ai-contracts && npm run check:ssr && npm run check:test-quality && npm run check:jsdoc-coverage && npm run check:ai-examples-coverage && npm run dist:prod && npm run size && npm run check:pack && npm pack --dry-run",
159
+ "prepublishOnly": "npm run lint && npm run typescript && npm run typescript:mcp && npm run test && npm run check:chart-specs && npm run check:claude-md-coverage && npm run check:context7 && npm run check:mcp-registry && npm run check:surface && npm run check:ai-contracts && npm run check:ssr && npm run check:test-quality && npm run check:jsdoc-coverage && npm run check:ai-examples-coverage && rm -rf dist && npm run dist:prod && npm run size"
133
160
  },
134
161
  "targets": {
135
162
  "website": {
@@ -146,6 +173,7 @@
146
173
  "semiotic": "./src/components/semiotic.ts",
147
174
  "semiotic/geo": "./src/components/semiotic-geo.ts",
148
175
  "semiotic/utils": "./src/components/semiotic-utils.ts",
176
+ "semiotic/recipes": "./src/components/semiotic-recipes.ts",
149
177
  "react-router-dom": "react-router"
150
178
  },
151
179
  "repository": {
@@ -223,16 +251,13 @@
223
251
  "@types/d3-brush": "^3.0.0",
224
252
  "@types/d3-chord": "^3.0.0",
225
253
  "@types/d3-force": "^3.0.0",
226
- "@types/d3-format": "^3.0.0",
227
254
  "@types/d3-geo": "^3.1.0",
228
255
  "@types/d3-hierarchy": "^3.1.0",
229
256
  "@types/d3-interpolate": "^3.0.0",
230
257
  "@types/d3-quadtree": "^3.0.6",
231
258
  "@types/d3-scale": "^4.0.9",
232
- "@types/d3-scale-chromatic": "^3.1.0",
233
259
  "@types/d3-selection": "^3.0.0",
234
260
  "@types/d3-shape": "^3.1.0",
235
- "@types/d3-time-format": "^4.0.0",
236
261
  "@types/d3-zoom": "^3.0.8",
237
262
  "@types/node": "^22.19.17",
238
263
  "@types/react": "^19.2.14",
@@ -292,17 +317,13 @@
292
317
  "d3-brush": "^3.0.0",
293
318
  "d3-chord": "^3.0.1",
294
319
  "d3-force": "^3.0.0",
295
- "d3-format": "^3.1.0",
296
320
  "d3-geo": "^3.1.1",
297
321
  "d3-hierarchy": "^3.1.2",
298
322
  "d3-interpolate": "^3.0.1",
299
323
  "d3-quadtree": "^3.0.1",
300
324
  "d3-scale": "^4.0.2",
301
- "d3-scale-chromatic": "^3.1.0",
302
325
  "d3-selection": "^3.0.0",
303
326
  "d3-shape": "^3.2.0",
304
- "d3-tile": "^1.0.0",
305
- "d3-time-format": "^4.1.0",
306
327
  "d3-zoom": "^3.0.0",
307
328
  "regression": "^2.0.1",
308
329
  "topojson-client": "^3.1.0",
@@ -1 +0,0 @@
1
- import{darkenColor as t,lightenColor as o}from"./semiotic.module.min.js";import"react/jsx-runtime";import"react";import"d3-selection";import"d3-brush";import"d3-scale";import"d3-quadtree";import"d3-scale-chromatic";import"d3-array";import"d3-hierarchy";import"d3-shape";import"regression";import"d3-interpolate";import"d3-force";import"d3-chord";const e="__forecastSegment";function n(t,o){return"function"==typeof o?o(t):!!t[o]}function s(t){var o,e,n;return[{type:"anomaly-band",threshold:null!==(o=t.threshold)&&void 0!==o?o:2,showBand:!1!==t.showBand,fill:t.bandColor||"#6366f1",fillOpacity:null!==(e=t.bandOpacity)&&void 0!==e?e:.1,anomalyColor:t.anomalyColor||"#ef4444",anomalyRadius:null!==(n=t.anomalyRadius)&&void 0!==n?n:6,label:t.label}]}function a(t,o,s,a,r){return(i=a).isTraining||i.isForecast||i.isAnomaly||i.upperBounds||i.lowerBounds?function(t,o,s,a,r){var i,l,c,p;const{isTraining:f,isForecast:u,isAnomaly:h,upperBounds:d,lowerBounds:y,color:b="#6366f1",bandOpacity:g=.15,anomalyColor:m="#ef4444",anomalyRadius:O=6,label:j}=a,v=t.map(t=>{let o="observed";return u&&n(t,u)?o="forecast":f&&n(t,f)&&(o="training"),Object.assign(Object.assign({},t),{[e]:o})}),k=a._groupBy,_=[];if(k){const t=new Map;for(const o of v){const e=null!==(i=o[k])&&void 0!==i?i:"__default";t.has(e)||t.set(e,[]),t.get(e).push(o)}const o=[];for(const[,n]of t)for(let t=0;n.length-1>t;t++)n[t][e]!==n[t+1][e]&&(o.push(Object.assign(Object.assign({},n[t+1]),{[e]:n[t][e]})),o.push(Object.assign(Object.assign({},n[t]),{[e]:n[t+1][e]})));_.push(...v,...o)}else for(let t=0;v.length>t;t++)_.push(v[t]),v.length-1>t&&v[t][e]!==v[t+1][e]&&(_.push(Object.assign(Object.assign({},v[t+1]),{[e]:v[t][e]})),_.push(Object.assign(Object.assign({},v[t]),{[e]:v[t+1][e]})));if(a.trainUnderline){const t=[];for(const o of _)"training"===o[e]&&t.push(Object.assign(Object.assign({},o),{[e]:"training-base"}));_.unshift(...t)}const w=[];if(d&&y){const t="string"==typeof d?d:"__envUpper",o="string"==typeof y?y:"__envLower";if("function"==typeof d||"function"==typeof y)for(const e of _)"function"==typeof d&&(e[t]=d(e)),"function"==typeof y&&(e[o]=y(e));w.push({type:"envelope",upperAccessor:t,lowerAccessor:o,fill:b,fillOpacity:g,label:j})}if(h){const t=a.anomalyStyle,o={type:"highlight",filter:t=>n(t,h)};t?(o.style=t,o.r=O):"function"==typeof m?(o.style=t=>{const o=m(t);return{stroke:o,strokeWidth:1.5,fill:o,fillOpacity:.7}},o.r=O):(o.color=m,o.r=O,o.style={stroke:m,strokeWidth:1.5,fill:m,fillOpacity:.7}),w.push(o)}return r&&w.push({type:"anomaly-band",threshold:null!==(l=r.threshold)&&void 0!==l?l:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(c=r.bandOpacity)&&void 0!==c?c:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(p=r.anomalyRadius)&&void 0!==p?p:6,label:r.label}),{processedData:_,annotations:w}}(t,0,0,a,r):function(t,o,n,s,a){var r,i,l;const{trainEnd:c,steps:p=10,confidence:f=.95,color:u="#6366f1",bandOpacity:h=.15,label:d}=s;if(null==c)return{processedData:t,annotations:[]};const y=[],b=[];for(const n of t)n[o]>c?b.push(Object.assign(Object.assign({},n),{[e]:"observed"})):y.push(Object.assign(Object.assign({},n),{[e]:"training"}));const g=y.map(t=>[t[o],t[n]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,o)=>t[0]-o[0]),m=[],O=[];if(g.length>=3){const s=g.length;let a=0,r=0,i=0,l=0;for(const[t,o]of g)a+=t,r+=o,i+=t*t,l+=t*o;const c=s*i-a*a;if(Math.abs(c)>1e-12){const i=(s*l-a*r)/c,y=(r-i*a)/s,b=t=>y+i*t,j=g.map(([t,o])=>o-b(t)).reduce((t,o)=>t+o*o,0),v=Math.sqrt(j/Math.max(s-2,1)),k=g.reduce((t,o)=>t+o[0],0)/s,_=g.reduce((t,o)=>t+Math.pow(o[0]-k,2),0),w=.99>f?.95>f?.9>f?1:1.645:1.96:2.576,B=t.map(t=>t[o]).filter(t=>null!=t&&isFinite(t)),C=Math.max(...B),D=g.length>1?(g[s-1][0]-g[0][0])/(s-1):1;for(let t=1;p>=t;t++){const a=C+t*D,r=b(a),i=v*Math.sqrt(1+1/s+(_>0?Math.pow(a-k,2)/_:0))*w;O.push({[o]:a,[n]:r,[e]:"forecast",__forecastUpper:r+i,__forecastLower:r-i})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:u,fillOpacity:h,label:d})}}m.push({type:"x-threshold",x:c,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),a&&m.push({type:"anomaly-band",threshold:null!==(r=a.threshold)&&void 0!==r?r:2,showBand:!1!==a.showBand,fill:a.bandColor||"#6366f1",fillOpacity:null!==(i=a.bandOpacity)&&void 0!==i?i:.1,anomalyColor:a.anomalyColor||"#ef4444",anomalyRadius:null!==(l=a.anomalyRadius)&&void 0!==l?l:6,label:a.label});const j=[];if(j.push(...y),y.length>0&&b.length>0&&j.push(Object.assign(Object.assign({},y[y.length-1]),{[e]:"observed"})),j.push(...b),O.length>0){const t=b.length>0?b[b.length-1]:y[y.length-1];t&&j.push(Object.assign(Object.assign({},t),{[e]:"forecast"})),j.push(...O)}return{processedData:j,annotations:m}}(t,o,s,a,r);var i}function r(n,s){var a,r;const i=null!==(a=s.trainDasharray)&&void 0!==a?a:"8,4",l=null!==(r=s.forecastDasharray)&&void 0!==r?r:"4,4",c=s.color||"#6366f1",p=s.trainOpacity,f=s.forecastOpacity,u=s.trainStroke,h=s.trainLinecap,d=s.trainUnderline;return s=>{const a=n(s),r=s[e];if("training"===r){let o=a.stroke;return"darken"===u?o=t(a.stroke||"#666",.5):u&&(o=u),Object.assign(Object.assign(Object.assign(Object.assign({},a),{stroke:o,strokeDasharray:i}),h&&{strokeLinecap:h}),null!=p&&{strokeOpacity:p})}if("training-base"===r){let t=a.stroke||"#666";return"lighten"===d&&(t=o(t,.4)),Object.assign(Object.assign({},a),{stroke:t,strokeDasharray:void 0})}return"forecast"===r?Object.assign(Object.assign(Object.assign({},a),{stroke:c,strokeDasharray:l}),null!=f&&{strokeOpacity:f}):a}}export{e as SEGMENT_FIELD,s as buildAnomalyAnnotations,a as buildForecast,r as createSegmentLineStyle,t as darkenColor,o as lightenColor};