flexdesk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +195 -0
- package/THIRD_PARTY_LICENSES.md +53 -0
- package/css/base.css +3439 -0
- package/css/flexdesk.css +5797 -0
- package/css/overrides.css +2349 -0
- package/css/reset.css +46 -0
- package/css/tokens.css +137 -0
- package/dist/charts.js +780 -0
- package/dist/charts.js.map +7 -0
- package/dist/chunk-3PHCPZHT.js +222 -0
- package/dist/chunk-3PHCPZHT.js.map +7 -0
- package/dist/chunk-CT4YXXLP.js +1770 -0
- package/dist/chunk-CT4YXXLP.js.map +7 -0
- package/dist/chunk-DRYCDMEG.js +2217 -0
- package/dist/chunk-DRYCDMEG.js.map +7 -0
- package/dist/chunk-DVU44T77.js +855 -0
- package/dist/chunk-DVU44T77.js.map +7 -0
- package/dist/chunk-FL5KFNQH.js +640 -0
- package/dist/chunk-FL5KFNQH.js.map +7 -0
- package/dist/chunk-FOOS3T5L.js +117 -0
- package/dist/chunk-FOOS3T5L.js.map +7 -0
- package/dist/chunk-JYWURG5T.js +32 -0
- package/dist/chunk-JYWURG5T.js.map +7 -0
- package/dist/chunk-TLZUUFOE.js +276 -0
- package/dist/chunk-TLZUUFOE.js.map +7 -0
- package/dist/chunk-UCJ2WD4D.js +625 -0
- package/dist/chunk-UCJ2WD4D.js.map +7 -0
- package/dist/chunk-WVFGV5FT.js +205 -0
- package/dist/chunk-WVFGV5FT.js.map +7 -0
- package/dist/core.js +1098 -0
- package/dist/core.js.map +7 -0
- package/dist/editor.js +1661 -0
- package/dist/editor.js.map +7 -0
- package/dist/flexdesk.css +5797 -0
- package/dist/host.js +132 -0
- package/dist/host.js.map +7 -0
- package/dist/reset.css +46 -0
- package/dist/tile_registry-6WZPTUZV.js +28 -0
- package/dist/tile_registry-6WZPTUZV.js.map +7 -0
- package/dist/tiles.js +2068 -0
- package/dist/tiles.js.map +7 -0
- package/dist/tokens.css +137 -0
- package/dist/widgets.js +5438 -0
- package/dist/widgets.js.map +7 -0
- package/dist/wm.js +4830 -0
- package/dist/wm.js.map +7 -0
- package/package.json +80 -0
- package/src/charts/chart_types.js +699 -0
- package/src/charts/data_series_plot_window.js +761 -0
- package/src/charts/downsample.js +119 -0
- package/src/charts/plot_config.js +176 -0
- package/src/charts/plot_popout_window.js +1560 -0
- package/src/charts/plotly_wrapper.js +432 -0
- package/src/core/event_bus.js +230 -0
- package/src/core/logging.js +300 -0
- package/src/core/settings.js +813 -0
- package/src/core/state_guard.js +382 -0
- package/src/core/state_guard_config.js +309 -0
- package/src/core/state_machine.js +258 -0
- package/src/editor/editor_pane.js +264 -0
- package/src/editor/monaco_editor_factory.js +449 -0
- package/src/editor/monaco_loader.js +74 -0
- package/src/editor/notebook_search.js +460 -0
- package/src/editor/notebook_tab_bar.js +456 -0
- package/src/editor/notebook_undo_manager.js +108 -0
- package/src/editor/split_pane_container.js +197 -0
- package/src/help/help_modal.js +409 -0
- package/src/help/help_registry.js +65 -0
- package/src/host/host.js +69 -0
- package/src/host/pywebview_host.js +133 -0
- package/src/tiles/config_schema.js +256 -0
- package/src/tiles/layout_persistence.js +662 -0
- package/src/tiles/tile_base.js +785 -0
- package/src/tiles/tile_grid.js +905 -0
- package/src/tiles/tile_registry.js +136 -0
- package/src/tiling/command_palette.js +328 -0
- package/src/tiling/content_registry.js +110 -0
- package/src/tiling/desktops.js +133 -0
- package/src/tiling/entity_sources.js +179 -0
- package/src/tiling/keymap.js +156 -0
- package/src/tiling/kind_taxonomy.js +172 -0
- package/src/tiling/landing_table.js +717 -0
- package/src/tiling/loading_overlay.js +33 -0
- package/src/tiling/nav_panel.js +142 -0
- package/src/tiling/page_factory.js +215 -0
- package/src/tiling/panel_keys.js +145 -0
- package/src/tiling/shell.js +437 -0
- package/src/tiling/tile_breadcrumb.js +222 -0
- package/src/tiling/tile_renderer.js +459 -0
- package/src/tiling/tile_tab_menu.js +340 -0
- package/src/tiling/tile_tree.js +880 -0
- package/src/tiling/wm.js +1352 -0
- package/src/ui/base/component_base.js +30 -0
- package/src/ui/base/controller_base.js +48 -0
- package/src/ui/base/page_base.js +102 -0
- package/src/ui/components/about_dialog.js +224 -0
- package/src/ui/components/action_dropdown.js +389 -0
- package/src/ui/components/attribute_list_editor.js +652 -0
- package/src/ui/components/autocomplete_field.js +732 -0
- package/src/ui/components/computing_status_window.js +81 -0
- package/src/ui/components/confirm_dialog.js +307 -0
- package/src/ui/components/context_menu.js +87 -0
- package/src/ui/components/data_table.js +2228 -0
- package/src/ui/components/detail_header.js +177 -0
- package/src/ui/components/drag_reorder.js +0 -0
- package/src/ui/components/gallery_picker.js +147 -0
- package/src/ui/components/inline_renamer.js +129 -0
- package/src/ui/components/managed_window.js +804 -0
- package/src/ui/components/modal.js +512 -0
- package/src/ui/components/notification_history.js +264 -0
- package/src/ui/components/slide_out_panel.js +185 -0
- package/src/ui/components/slider_field.js +122 -0
- package/src/ui/components/sortable_list.js +309 -0
- package/src/ui/components/table_state_store.js +81 -0
- package/src/ui/components/toast.js +59 -0
- package/src/ui/components/tree_view.js +460 -0
- package/src/ui/components/window_taskbar.js +143 -0
- package/src/ui/controllers/panel_state_machine.js +634 -0
- package/src/ui/controllers/window_chrome_controller.js +659 -0
- package/src/ui/notification_center.js +576 -0
- package/src/ui/utils/overlay_scrollbar.js +492 -0
- package/src/ui/utils/raf_resize_observer.js +31 -0
- package/src/ui/utils/tooltip_service.js +406 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/charts/plotly_wrapper.js", "../src/charts/chart_types.js", "../src/charts/plot_config.js", "../src/charts/plot_popout_window.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Plotly.js Wrapper\n *\n * Provides lazy loading of Plotly.js and helper functions for chart operations.\n * Supports streaming updates via Plotly.extendTraces() and Plotly.react().\n */\n\nimport { createRafResizeObserver } from '../ui/utils/raf_resize_observer.js';\n\n// Where Plotly lives is the CONSUMER's business, not the library's.\n//\n// This was `const PLOTLY_LOCAL = 'vendor/plotly/plotly-2.35.2.min.js'` \u2014 a\n// relative path into one particular application's directory tree. It happens to\n// work for EcoAgent and would 404 for anyone else, and the failure would arrive\n// as an empty chart with a console error, at runtime, only on the screens that\n// plot something.\n//\n// Plotly stays a PEER dependency: 4.4 MB that @flexdesk/charts refuses to bundle.\n//\n// There is NO DEFAULT. Leaving one in place would only have meant leaving\n// EcoAgent's exact versioned filename in the library \u2014 the same bug wearing a\n// setter \u2014 and it would fail for everyone else as an empty chart and a console\n// error, at runtime, on the screens that plot something.\n//\n// ensurePlotly() short-circuits when `window.Plotly` is already defined, which is\n// how EcoAgent works: it preloads Plotly with a <script> tag in index.html and\n// never reaches the loader below. A consumer that does not preload calls\n// setPlotlySource() instead. A consumer that does neither now gets told so.\nlet _plotlySrc = null;\n\n/** Point the loader at your copy of Plotly. Call before the first chart renders. */\nexport function setPlotlySource(src) {\n if (typeof src === 'string' && src) _plotlySrc = src;\n}\n\n// Loading promise for singleton pattern\nlet _plotlyLoadPromise = null;\n\n// Workarounds for Plotly.js 2.35.x running in Chromium-based pywebview.\nlet _plotlyPatchesInstalled = false;\nfunction _installPlotlyPatches() {\n if (_plotlyPatchesInstalled) return;\n _plotlyPatchesInstalled = true;\n\n // Plotly's internal mousemove handler assigns event.target which is\n // read-only in modern browsers. Replace the native getter with a\n // getter/setter pair so the assignment succeeds silently.\n const targetDesc = Object.getOwnPropertyDescriptor(Event.prototype, 'target');\n if (targetDesc && targetDesc.get && !targetDesc.set) {\n const origGetter = targetDesc.get;\n Object.defineProperty(Event.prototype, 'target', {\n configurable: true,\n enumerable: true,\n get() {\n return this._plotlyTarget ?? origGetter.call(this);\n },\n set(v) {\n this._plotlyTarget = v;\n }\n });\n }\n\n // Plotly calls getImageData() repeatedly on 2D canvases without the\n // willReadFrequently hint, triggering a Chromium performance warning.\n // Patch getContext to inject the hint for all 2D contexts.\n const _origGetContext = HTMLCanvasElement.prototype.getContext;\n HTMLCanvasElement.prototype.getContext = function (type, attrs) {\n if (type === '2d') {\n attrs = Object.assign({ willReadFrequently: true }, attrs);\n }\n return _origGetContext.call(this, type, attrs);\n };\n}\n\n// Run immediately on module import so the patches are active before any Plotly\n// chart is created (including during workspace hydration) \u2014 but ONLY in a DOM.\n//\n// Unguarded, this monkey-patched HTMLCanvasElement.prototype at module scope, so\n// `import '@flexdesk/charts'` threw `ReferenceError: HTMLCanvasElement is not defined`\n// the instant anything imported it outside a browser. That is the third module in\n// this library caught doing DOM work on import (see inline_renamer.js and\n// tooltip_service.js), and all three were found by the same test: one that does\n// nothing but import each entry point. A library whose entry point cannot be\n// imported without a DOM cannot be unit-tested, server-rendered, or loaded in a\n// worker.\nif (typeof HTMLCanvasElement !== 'undefined') {\n _installPlotlyPatches();\n}\n\n/**\n * Dark theme layout defaults matching EcoSim UI\n */\nexport const DARK_THEME_LAYOUT = {\n paper_bgcolor: 'transparent',\n plot_bgcolor: 'transparent',\n font: {\n family: 'Inter, -apple-system, BlinkMacSystemFont, sans-serif',\n size: 11,\n color: '#cccccc'\n },\n margin: { l: 50, r: 20, t: 30, b: 40 },\n legend: {\n bgcolor: 'rgba(0,0,0,0)',\n font: { color: '#cccccc' }\n },\n xaxis: {\n gridcolor: '#333333',\n linecolor: '#444444',\n tickcolor: '#666666',\n zerolinecolor: '#444444'\n },\n yaxis: {\n gridcolor: '#333333',\n linecolor: '#444444',\n tickcolor: '#666666',\n zerolinecolor: '#444444'\n },\n // Hover tooltip styling for dark theme\n hoverlabel: {\n bgcolor: '#1e2228',\n bordercolor: '#444444',\n font: {\n family: 'Inter, -apple-system, BlinkMacSystemFont, sans-serif',\n size: 12,\n color: '#e0e0e0'\n }\n },\n // 3D scene defaults\n scene: {\n xaxis: {\n gridcolor: '#333333',\n linecolor: '#444444',\n backgroundcolor: 'rgba(0,0,0,0)'\n },\n yaxis: {\n gridcolor: '#333333',\n linecolor: '#444444',\n backgroundcolor: 'rgba(0,0,0,0)'\n },\n zaxis: {\n gridcolor: '#333333',\n linecolor: '#444444',\n backgroundcolor: 'rgba(0,0,0,0)'\n },\n bgcolor: 'rgba(0,0,0,0)'\n }\n};\n\n/**\n * Default Plotly config options\n */\nexport const DEFAULT_CONFIG = {\n responsive: true,\n displaylogo: false,\n displayModeBar: false, // Hide modebar completely\n scrollZoom: true, // Allow zoom with scroll wheel instead\n toImageButtonOptions: {\n format: 'png',\n filename: 'ecosim_chart',\n scale: 2\n }\n};\n\n/**\n * Load Plotly.js from CDN.\n * Uses singleton pattern to avoid multiple loads.\n * @returns {Promise<Plotly>} The Plotly library object\n */\nexport async function ensurePlotly() {\n // Already loaded\n if (typeof Plotly !== 'undefined') {\n return Plotly;\n }\n\n // Loading in progress\n if (_plotlyLoadPromise) {\n return _plotlyLoadPromise;\n }\n\n if (!_plotlySrc) {\n throw new Error(\n '[twm/charts] Plotly is not loaded and no source is configured. '\n + 'Either load Plotly yourself (a <script> tag that sets window.Plotly), '\n + 'or call setPlotlySource(\"/path/to/plotly.min.js\") before rendering a chart.');\n }\n\n // Start loading \u2014 temporarily hide AMD define so Plotly sets window.Plotly\n // instead of registering itself as an AMD module (conflicts with Monaco loader).\n _plotlyLoadPromise = new Promise((resolve, reject) => {\n const savedDefine = window.define;\n window.define = undefined;\n\n const script = document.createElement('script');\n script.src = _plotlySrc;\n script.async = true;\n\n script.onload = () => {\n window.define = savedDefine;\n if (typeof Plotly !== 'undefined') {\n console.log('[PlotlyWrapper] Plotly.js loaded successfully');\n resolve(Plotly);\n } else {\n reject(new Error('Plotly.js loaded but Plotly global not found'));\n }\n };\n\n script.onerror = () => {\n window.define = savedDefine;\n reject(new Error(`Failed to load Plotly.js from ${_plotlySrc} \u2014 `\n + 'call setPlotlySource() with the path to your copy.'));\n };\n\n document.head.appendChild(script);\n });\n\n return _plotlyLoadPromise;\n}\n\n/**\n * Create a new Plotly chart.\n * @param {HTMLElement} container - Container element for the chart\n * @param {Array} data - Array of trace objects\n * @param {Object} layout - Layout configuration\n * @param {Object} config - Plotly config options\n * @returns {Promise<HTMLElement>} The chart element\n */\nexport async function createChart(container, data, layout = {}, config = {}) {\n const Plotly = await ensurePlotly();\n\n const mergedLayout = {\n ...DARK_THEME_LAYOUT,\n ...layout\n };\n\n const mergedConfig = {\n ...DEFAULT_CONFIG,\n ...config\n };\n\n return Plotly.newPlot(container, data, mergedLayout, mergedConfig);\n}\n\n/**\n * Update chart data and layout efficiently.\n * Uses Plotly.react() which is optimized for updates.\n * @param {HTMLElement} container - Chart container\n * @param {Array} data - New trace data\n * @param {Object} layout - Layout updates\n */\nexport async function updateChart(container, data, layout = {}) {\n const Plotly = await ensurePlotly();\n\n const mergedLayout = {\n ...DARK_THEME_LAYOUT,\n ...layout\n };\n\n return Plotly.react(container, data, mergedLayout);\n}\n\n/**\n * Extend traces with new data points (for streaming).\n * More efficient than full update for appending data.\n * @param {HTMLElement} container - Chart container\n * @param {Object} update - Data to extend: { x: [[...]], y: [[...]] }\n * @param {Array<number>} traceIndices - Which traces to extend\n * @param {number} maxPoints - Maximum points to keep (optional)\n */\nexport async function extendTraces(container, update, traceIndices, maxPoints = null) {\n const Plotly = await ensurePlotly();\n\n if (maxPoints) {\n return Plotly.extendTraces(container, update, traceIndices, maxPoints);\n }\n return Plotly.extendTraces(container, update, traceIndices);\n}\n\n/**\n * Relayout chart (update layout only, no data change).\n * @param {HTMLElement} container - Chart container\n * @param {Object} layoutUpdate - Layout properties to update\n */\nexport async function relayout(container, layoutUpdate) {\n const Plotly = await ensurePlotly();\n return Plotly.relayout(container, layoutUpdate);\n}\n\n/**\n * Restyle traces (update trace properties without full redraw).\n * @param {HTMLElement} container - Chart container\n * @param {Object} styleUpdate - Style properties to update\n * @param {Array<number>} traceIndices - Which traces to update\n */\nexport async function restyle(container, styleUpdate, traceIndices) {\n const Plotly = await ensurePlotly();\n return Plotly.restyle(container, styleUpdate, traceIndices);\n}\n\n/**\n * Delete all traces and release resources.\n * @param {HTMLElement} container - Chart container\n */\nexport async function purge(container) {\n const Plotly = await ensurePlotly();\n return Plotly.purge(container);\n}\n\n/**\n * Check if container has a Plotly chart.\n * @param {HTMLElement} container - Container element\n * @returns {boolean}\n */\nexport function hasPlot(container) {\n return container && container._fullLayout !== undefined;\n}\n\n/**\n * Resize chart to fit container.\n * Call this when container size changes.\n * @param {HTMLElement} container - Chart container\n */\nexport async function resize(container) {\n const Plotly = await ensurePlotly();\n return Plotly.Plots.resize(container);\n}\n\n/**\n * Convert hex color to rgba.\n * @param {string} hex - Hex color code\n * @param {number} alpha - Alpha value (0-1)\n * @returns {string} rgba color string\n */\nexport function hexToRgba(hex, alpha = 1) {\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n if (!result) return hex;\n const r = parseInt(result[1], 16);\n const g = parseInt(result[2], 16);\n const b = parseInt(result[3], 16);\n return `rgba(${r}, ${g}, ${b}, ${alpha})`;\n}\n\n// Solarized theme colors matching legacy plot_node.js\nexport const COLOR_PALETTE = [\n '#268bd2', // Solarized Blue\n '#d33682', // Solarized Magenta\n '#cb4b16', // Solarized Orange\n '#2aa198', // Solarized Cyan\n '#6a5acd', // SlateBlue/Purple\n '#7a7d80', // Gray\n '#9fb6cf', // Gray-Blue\n];\n\n/**\n * Get color from palette by index.\n * @param {number} index - Series index\n * @returns {string} Color hex code\n */\nexport function getSeriesColor(index) {\n return COLOR_PALETTE[index % COLOR_PALETTE.length];\n}\n\n/**\n * Create a Plotly chart with deferred rendering support.\n * Handles zero-dimension containers by waiting for valid dimensions via ResizeObserver.\n * @param {HTMLElement} container - Container element for the chart\n * @param {Array} traces - Array of trace objects\n * @param {Object} layout - Layout configuration\n * @param {Object} config - Plotly config options\n * @returns {Promise<{element: HTMLElement, cleanup: Function}>} Chart element and cleanup function\n */\nexport async function createChartDeferred(container, traces, layout = {}, config = {}) {\n const Plotly = await ensurePlotly();\n\n const mergedLayout = {\n ...DARK_THEME_LAYOUT,\n ...layout\n };\n\n const mergedConfig = {\n ...DEFAULT_CONFIG,\n ...config\n };\n\n const w = container.offsetWidth;\n const h = container.offsetHeight;\n\n // Cleanup function to return\n let resizeObserver = null;\n const cleanup = () => {\n if (resizeObserver) {\n resizeObserver.disconnect();\n resizeObserver = null;\n }\n };\n\n // If dimensions are valid, render immediately\n if (w > 0 && h > 0) {\n await Plotly.newPlot(container, traces, mergedLayout, mergedConfig);\n // Still set up resize observer for ongoing resizes\n resizeObserver = createRafResizeObserver(() => {\n if (hasPlot(container)) {\n Plotly.Plots.resize(container).catch(() => {});\n }\n });\n resizeObserver.observe(container);\n return { element: container, cleanup };\n }\n\n // Dimensions are zero - wait for valid dimensions via ResizeObserver\n return new Promise((resolve) => {\n let rendered = false;\n resizeObserver = createRafResizeObserver((entries) => {\n for (const entry of entries) {\n const { width, height } = entry.contentRect;\n if (width > 0 && height > 0) {\n if (!rendered) {\n rendered = true;\n Plotly.newPlot(container, traces, mergedLayout, mergedConfig).then(() => {\n resolve({ element: container, cleanup });\n }).catch(() => {\n resolve({ element: container, cleanup });\n });\n } else if (hasPlot(container)) {\n // Handle subsequent resizes\n Plotly.Plots.resize(container).catch(() => {});\n }\n }\n }\n });\n resizeObserver.observe(container);\n });\n}\n", "/**\n * Chart Types and Trace Configurations\n *\n * Defines trace configurations for Plotly.js and provides mapping\n * from Chart.js options to Plotly equivalents.\n */\n\nimport { getSeriesColor, hexToRgba } from './plotly_wrapper.js';\n\n/**\n * Available 2D chart types\n */\nexport const CHART_TYPES_2D = Object.freeze([\n { value: 'line', label: 'Line' },\n { value: 'bar', label: 'Bar' },\n { value: 'scatter', label: 'Scatter' },\n { value: 'area', label: 'Area' },\n { value: 'area-stacked', label: 'Area (Stacked %)' },\n { value: 'phase', label: 'Phase' },\n]);\n\n/**\n * Available 3D chart types\n */\nexport const CHART_TYPES_3D = Object.freeze([\n { value: 'scatter3d', label: '3D Scatter' },\n { value: 'line3d', label: '3D Line' },\n { value: 'surface', label: '3D Surface' },\n]);\n\n/**\n * All chart types combined\n */\nexport const ALL_CHART_TYPES = Object.freeze([...CHART_TYPES_2D, ...CHART_TYPES_3D]);\n\n/**\n * Check if chart type is 3D\n * @param {string} chartType\n * @returns {boolean}\n */\nexport function is3DChart(chartType) {\n return ['scatter3d', 'line3d', 'surface'].includes(chartType);\n}\n\n/**\n * Line style mapping (Chart.js borderDash to Plotly dash)\n */\nconst LINE_DASH_MAP = {\n solid: 'solid',\n dashed: 'dash',\n dotted: 'dot',\n};\n\n/**\n * Interpolation mapping (Chart.js to Plotly line shape)\n */\nconst INTERPOLATION_MAP = {\n linear: 'linear',\n step: 'hv', // horizontal-vertical step\n cubic: 'spline', // smooth spline\n auto: 'linear',\n};\n\n/**\n * Build a Plotly trace from series configuration.\n * @param {Object} options\n * @param {string} options.chartType - Chart type (line, bar, scatter, area, scatter3d, etc.)\n * @param {Array} options.x - X-axis data\n * @param {Array} options.y - Y-axis data\n * @param {Array} [options.z] - Z-axis data (for 3D charts)\n * @param {string} options.name - Series name/label\n * @param {string} [options.color] - Series color (hex)\n * @param {number} [options.lineWidth] - Line width in pixels\n * @param {string} [options.lineStyle] - Line style: solid, dashed, dotted\n * @param {string} [options.interpolation] - Interpolation: linear, step, cubic\n * @param {string} [options.yAxisId] - Y-axis identifier (y, y2, y3, etc.)\n * @param {boolean} [options.showMarkers] - Show data point markers\n * @param {number} [options.seriesIndex] - Index for default color selection\n * @returns {Object} Plotly trace object\n */\nexport function buildTrace(options) {\n const {\n chartType = 'line',\n x = [],\n y = [],\n z = null,\n name = 'Series',\n color = null,\n lineWidth = 2,\n lineStyle = 'solid',\n interpolation = 'linear',\n yAxisId = 'y',\n showMarkers = false,\n seriesIndex = 0,\n stackGroup = null,\n } = options;\n\n const seriesColor = color || getSeriesColor(seriesIndex);\n\n // Determine Plotly trace type and mode\n let plotlyType, mode;\n switch (chartType) {\n case 'line':\n plotlyType = 'scatter';\n mode = showMarkers ? 'lines+markers' : 'lines';\n break;\n case 'scatter':\n plotlyType = 'scatter';\n mode = 'markers';\n break;\n case 'area':\n case 'area-stacked':\n plotlyType = 'scatter';\n mode = showMarkers ? 'lines+markers' : 'lines';\n break;\n case 'phase':\n plotlyType = 'scatter';\n mode = 'lines+markers';\n break;\n case 'bar':\n plotlyType = 'bar';\n mode = undefined;\n break;\n case 'scatter3d':\n plotlyType = 'scatter3d';\n mode = 'markers';\n break;\n case 'line3d':\n plotlyType = 'scatter3d';\n mode = showMarkers ? 'lines+markers' : 'lines';\n break;\n case 'surface':\n plotlyType = 'surface';\n mode = undefined;\n break;\n default:\n plotlyType = 'scatter';\n mode = showMarkers ? 'lines+markers' : 'lines';\n }\n\n // Build base trace\n const trace = {\n type: plotlyType,\n name,\n x,\n y,\n };\n\n // Add mode if applicable\n if (mode) {\n trace.mode = mode;\n }\n\n // Add z-axis data for 3D charts\n if (z && is3DChart(chartType)) {\n // Surface charts require z to be a 2D array\n // If z is 1D (time series data), use mesh3d with Delaunay triangulation\n if (chartType === 'surface') {\n const zIs2D = Array.isArray(z) && z.length > 0 && Array.isArray(z[0]);\n if (zIs2D) {\n trace.z = z;\n } else {\n // Use mesh3d with Delaunay triangulation for 1D scattered points\n console.info('[chart_types] Surface chart with 1D z data - using mesh3d with Delaunay triangulation');\n trace.type = 'mesh3d';\n trace.x = x;\n trace.y = y;\n trace.z = z;\n trace.alphahull = 0; // Delaunay triangulation (convex hull = -1, 0 = Delaunay)\n trace.opacity = 0.8;\n trace.color = seriesColor;\n trace.flatshading = true;\n trace.lighting = {\n ambient: 0.6,\n diffuse: 0.5,\n specular: 0.2,\n };\n // Skip surface-specific config below\n return trace;\n }\n } else {\n trace.z = z;\n }\n }\n\n // Phase chart: line with small markers\n if (chartType === 'phase') {\n trace.line = {\n color: seriesColor,\n width: lineWidth,\n dash: LINE_DASH_MAP[lineStyle] || 'solid',\n };\n trace.marker = {\n color: seriesColor,\n size: 3,\n };\n return trace;\n }\n\n // Line configuration (for line/area charts)\n if (['line', 'area', 'area-stacked', 'line3d'].includes(chartType)) {\n trace.line = {\n color: seriesColor,\n width: lineWidth,\n dash: LINE_DASH_MAP[lineStyle] || 'solid',\n shape: INTERPOLATION_MAP[interpolation] || 'linear',\n };\n }\n\n // Marker configuration\n if (['scatter', 'scatter3d'].includes(chartType) || showMarkers) {\n trace.marker = {\n color: seriesColor,\n size: chartType === 'scatter3d' ? 4 : 6,\n };\n }\n\n // Normalized stacked area: each Y-axis is its own stack group, each summing to 1.\n if (chartType === 'area-stacked') {\n trace.stackgroup = yAxisId;\n trace.groupnorm = 'fraction';\n trace.fillcolor = hexToRgba(seriesColor, 0.5);\n trace.line = { ...(trace.line || {}), width: 0.5, color: seriesColor };\n trace.mode = 'lines';\n }\n // Fill for area charts (non-stacked)\n else if (chartType === 'area' && !stackGroup) {\n trace.fill = 'tozeroy';\n trace.fillcolor = hexToRgba(seriesColor, 0.3);\n }\n // Stacked area via explicit stackGroup on any chart type\n else if (stackGroup) {\n trace.stackgroup = stackGroup;\n trace.fillcolor = hexToRgba(seriesColor, 0.5);\n trace.line = { ...(trace.line || {}), width: 0.5, color: seriesColor };\n trace.mode = 'lines';\n }\n\n // Bar color\n if (chartType === 'bar') {\n trace.marker = {\n color: seriesColor,\n };\n }\n\n // Surface colorscale\n if (chartType === 'surface') {\n trace.colorscale = 'Viridis';\n trace.showscale = true;\n }\n\n // Y-axis assignment (for multi-axis support)\n if (!is3DChart(chartType) && yAxisId && yAxisId !== 'y') {\n trace.yaxis = yAxisId;\n }\n\n return trace;\n}\n\n/**\n * Build layout for Y-axis based on configuration.\n * @param {Object} options\n * @param {string} options.axisId - Axis identifier (y, y2, y3, etc.)\n * @param {string} [options.title] - Axis title\n * @param {string} [options.position] - Axis position: left or right\n * @param {string} [options.scaleType] - Scale type: linear or log\n * @param {number} [options.min] - Minimum value\n * @param {number} [options.max] - Maximum value\n * @param {number} [options.step] - Tick step size\n * @param {boolean} [options.showGrid] - Show grid lines\n * @param {number|null} [options.axisPosition] - Explicit position in normalized coords (0-1), null for default\n * @returns {Object} Plotly axis layout object\n */\nexport function buildYAxisLayout(options) {\n const {\n axisId = 'yaxis',\n title = '',\n position = 'left',\n scaleType = 'linear',\n min = null,\n max = null,\n step = null,\n showGrid = true,\n axisPosition = null,\n } = options;\n\n const layout = {\n title: { text: title },\n type: scaleType === 'log' ? 'log' : 'linear',\n side: position,\n gridcolor: 'rgba(255,255,255,0.05)',\n linecolor: 'rgba(255,255,255,0.08)',\n tickcolor: 'rgba(255,255,255,0.3)',\n zerolinecolor: 'rgba(255,255,255,0.06)',\n showgrid: showGrid,\n automargin: true, // Auto-expand margin for tick labels\n };\n\n // Set range if min/max provided.\n // Both bounds: fixed range (autorange off).\n // One-sided: use autorangeoptions so Plotly auto-ranges within data but respects the cap/floor.\n // Plotly does not accept null in a range array \u2014 [null, max] silently sets the lower bound to 0.\n if (min !== null && max !== null) {\n layout.autorange = false;\n layout.range = [min, max];\n } else if (min !== null || max !== null) {\n layout.autorange = true;\n layout.autorangeoptions = {};\n if (min !== null) layout.autorangeoptions.minallowed = min;\n if (max !== null) layout.autorangeoptions.maxallowed = max;\n }\n\n // Set tick step if provided\n if (step !== null && step > 0) {\n layout.dtick = step;\n }\n\n // For secondary axes, overlay on the first y-axis\n if (axisId !== 'yaxis') {\n layout.overlaying = 'y';\n layout.anchor = 'free';\n\n // Use explicit position if provided (for proper multi-axis layout)\n // axisPosition is in normalized figure coordinates (0-1)\n if (axisPosition !== null) {\n layout.position = axisPosition;\n } else {\n // Fallback: position at domain edge (0 for left, 1 for right)\n layout.position = position === 'left' ? 0 : 1;\n }\n }\n\n return layout;\n}\n\n/**\n * Build X-axis layout.\n * @param {Object} options\n * @param {string} [options.title] - Axis title\n * @param {string} [options.scaleType] - Scale type: linear or log\n * @param {number} [options.min] - Minimum value\n * @param {number} [options.max] - Maximum value\n * @returns {Object} Plotly xaxis layout object\n */\nexport function buildXAxisLayout(options) {\n const {\n title = 'Time',\n scaleType = 'linear',\n min = null,\n max = null,\n } = options;\n\n const layout = {\n title: { text: title },\n type: scaleType === 'log' ? 'log' : 'linear',\n gridcolor: 'rgba(255,255,255,0.05)',\n linecolor: 'rgba(255,255,255,0.08)',\n tickcolor: 'rgba(255,255,255,0.3)',\n zerolinecolor: 'rgba(255,255,255,0.06)',\n automargin: true,\n };\n\n if (min !== null || max !== null) {\n layout.range = [min, max];\n }\n\n return layout;\n}\n\n/**\n * Build 3D scene layout.\n * @param {Object} options\n * @param {string} [options.xTitle] - X-axis title\n * @param {string} [options.yTitle] - Y-axis title\n * @param {string} [options.zTitle] - Z-axis title\n * @param {string} [options.zScale] - Z-axis scale type: 'linear' or 'log'\n * @param {number} [options.zMin] - Z-axis minimum value\n * @param {number} [options.zMax] - Z-axis maximum value\n * @param {number} [options.zStep] - Z-axis tick step size\n * @returns {Object} Plotly scene layout object\n */\nexport function build3DSceneLayout(options) {\n const {\n xTitle = 'X',\n yTitle = 'Y',\n zTitle = 'Z',\n zScale = 'linear',\n zMin = null,\n zMax = null,\n zStep = null,\n } = options;\n\n const zaxis = {\n title: { text: zTitle },\n type: zScale === 'log' ? 'log' : 'linear',\n gridcolor: 'rgba(255,255,255,0.05)',\n linecolor: 'rgba(255,255,255,0.08)',\n backgroundcolor: 'rgba(0,0,0,0)',\n };\n\n // Set range if min/max provided\n if (zMin !== null || zMax !== null) {\n zaxis.range = [zMin, zMax];\n }\n\n // Set tick step if provided\n if (zStep !== null && zStep > 0) {\n zaxis.dtick = zStep;\n }\n\n return {\n xaxis: {\n title: { text: xTitle },\n gridcolor: 'rgba(255,255,255,0.05)',\n linecolor: 'rgba(255,255,255,0.08)',\n backgroundcolor: 'rgba(0,0,0,0)',\n },\n yaxis: {\n title: { text: yTitle },\n gridcolor: 'rgba(255,255,255,0.05)',\n linecolor: 'rgba(255,255,255,0.08)',\n backgroundcolor: 'rgba(0,0,0,0)',\n },\n zaxis,\n bgcolor: 'rgba(0,0,0,0)',\n };\n}\n\n/**\n * Build legend layout.\n * @param {string} position - Legend position: top, bottom, left, right, hidden\n * @returns {Object} Plotly legend layout\n */\nexport function buildLegendLayout(position) {\n if (position === 'hidden') {\n return { showlegend: false };\n }\n\n const baseLayout = {\n showlegend: true,\n bgcolor: 'rgba(0,0,0,0)',\n font: { color: '#cccccc' },\n };\n\n switch (position) {\n case 'top':\n return {\n ...baseLayout,\n legend: {\n ...baseLayout,\n orientation: 'h',\n y: 1.1,\n yanchor: 'bottom',\n x: 0.5,\n xanchor: 'center',\n },\n };\n case 'bottom':\n return {\n ...baseLayout,\n legend: {\n ...baseLayout,\n orientation: 'h',\n y: -0.15,\n yanchor: 'top',\n x: 0.5,\n xanchor: 'center',\n },\n };\n case 'left':\n return {\n ...baseLayout,\n legend: {\n ...baseLayout,\n orientation: 'v',\n x: -0.15,\n xanchor: 'right',\n y: 0.5,\n yanchor: 'middle',\n },\n };\n case 'right':\n default:\n return {\n ...baseLayout,\n legend: {\n ...baseLayout,\n orientation: 'v',\n x: 1.02,\n xanchor: 'left',\n y: 0.5,\n yanchor: 'middle',\n },\n };\n }\n}\n\n/**\n * Build Plotly layout shapes + annotations for reference lines and shaded x-bands.\n *\n * @param {Object} opts\n * @param {Array<{yAxisId?:string, value:number, label?:string, color?:string, lineStyle?:string, lineWidth?:number, labelX?:number}>} [opts.referenceLines]\n * Horizontal threshold lines drawn across the plot, anchored to a specific Y axis.\n * `yAxisId` matches an axis id in sp.yAxes[].id; omitted \u2192 first axis.\n * @param {Array<{x0:number, x1:number, label?:string, color?:string, opacity?:number, labelY?:number, labelColor?:string}>} [opts.shadedBands]\n * Vertical stripes (rectangles spanning full y range) to mark policy/recession periods.\n * @param {Object<string,string>} [opts.yRefByAxisId]\n * Mapping from subplot yAxes[i].id \u2192 Plotly yref ('y', 'y2', ...).\n * @returns {{shapes: Array, annotations: Array}}\n */\nexport function buildOverlayShapes(opts = {}) {\n const { referenceLines = [], shadedBands = [], yRefByAxisId = {} } = opts;\n const shapes = [];\n const annotations = [];\n const dashMap = { solid: 'solid', dashed: 'dash', dotted: 'dot', dashdot: 'dashdot' };\n\n for (const band of shadedBands) {\n if (band.x0 == null || band.x1 == null) continue;\n shapes.push({\n type: 'rect',\n xref: 'x',\n yref: 'paper',\n x0: band.x0,\n x1: band.x1,\n y0: 0,\n y1: 1,\n fillcolor: band.color || 'rgba(255, 200, 0, 0.08)',\n line: { width: 0 },\n opacity: band.opacity ?? 1,\n layer: 'below',\n });\n if (band.label) {\n annotations.push({\n x: (band.x0 + band.x1) / 2,\n y: band.labelY ?? 1.0,\n xref: 'x',\n yref: 'paper',\n text: band.label,\n showarrow: false,\n font: { size: 9, color: band.labelColor || 'rgba(255,255,255,0.55)' },\n xanchor: 'center',\n yanchor: 'bottom',\n });\n }\n }\n\n const firstYRef = Object.values(yRefByAxisId)[0] || 'y';\n for (const ref of referenceLines) {\n if (ref.value == null || !Number.isFinite(ref.value)) continue;\n const yRef = (ref.yAxisId && yRefByAxisId[ref.yAxisId]) || firstYRef;\n const color = ref.color || 'rgba(255, 120, 120, 0.75)';\n shapes.push({\n type: 'line',\n xref: 'paper',\n yref: yRef,\n x0: 0,\n x1: 1,\n y0: ref.value,\n y1: ref.value,\n line: {\n color,\n width: ref.lineWidth ?? 1.5,\n dash: dashMap[ref.lineStyle || 'dashed'] || 'dash',\n },\n layer: 'above',\n });\n if (ref.label) {\n annotations.push({\n x: ref.labelX ?? 0.015,\n y: ref.value,\n xref: 'paper',\n yref: yRef,\n text: ref.label,\n showarrow: false,\n font: { size: 10, color },\n xanchor: 'left',\n yanchor: 'bottom',\n bgcolor: 'rgba(20,22,26,0.6)',\n borderpad: 2,\n });\n }\n }\n\n return { shapes, annotations };\n}\n\n/**\n * Create a fan chart trace with confidence bands.\n * @param {Object} options\n * @param {Array} options.x - X-axis data (time)\n * @param {Array} options.upper - Upper bound data\n * @param {Array} options.lower - Lower bound data\n * @param {string} options.color - Band color\n * @param {number} options.opacity - Fill opacity\n * @param {string} [options.name] - Band name for legend\n * @returns {Array} Array of two traces (lower bound + fill to upper)\n */\nexport function buildFanBandTraces(options) {\n const { x, upper, lower, color, opacity = 0.2, name = '' } = options;\n\n // Lower bound line (invisible, for fill reference)\n const lowerTrace = {\n type: 'scatter',\n x,\n y: lower,\n mode: 'lines',\n line: { width: 0 },\n showlegend: false,\n hoverinfo: 'skip',\n };\n\n // Upper bound with fill to lower\n const upperTrace = {\n type: 'scatter',\n x,\n y: upper,\n mode: 'lines',\n line: { width: 0 },\n fill: 'tonexty',\n fillcolor: hexToRgba(color, opacity),\n name: name || `${(opacity * 100).toFixed(0)}% Band`,\n showlegend: !!name,\n };\n\n return [lowerTrace, upperTrace];\n}\n\n/**\n * Create a histogram trace.\n * @param {Object} options\n * @param {Array} options.x - Data values\n * @param {number} options.nbins - Number of bins\n * @param {string} options.color - Bar color\n * @param {string} [options.name] - Series name\n * @returns {Object} Plotly histogram trace\n */\nexport function buildHistogramTrace(options) {\n const { x, nbins = 20, color, name = 'Distribution' } = options;\n\n return {\n type: 'histogram',\n x,\n nbinsx: nbins,\n marker: { color },\n name,\n };\n}\n\n/**\n * Create a box plot trace.\n * @param {Object} options\n * @param {Array} options.y - Data values\n * @param {string} [options.x] - Category/time label\n * @param {string} options.color - Box color\n * @param {string} [options.name] - Series name\n * @returns {Object} Plotly box trace\n */\nexport function buildBoxTrace(options) {\n const { y, x = null, color, name = '' } = options;\n\n const trace = {\n type: 'box',\n y,\n marker: { color },\n name,\n boxpoints: false, // Don't show individual points\n };\n\n if (x !== null) {\n trace.x = Array.isArray(x) ? x : [x];\n }\n\n return trace;\n}\n\n/**\n * Create a heatmap trace.\n * @param {Object} options\n * @param {Array} options.z - 2D array of values\n * @param {Array} [options.x] - X labels\n * @param {Array} [options.y] - Y labels\n * @param {string} [options.colorscale] - Plotly colorscale name\n * @returns {Object} Plotly heatmap trace\n */\nexport function buildHeatmapTrace(options) {\n const { z, x = null, y = null, colorscale = 'RdBu' } = options;\n\n const trace = {\n type: 'heatmap',\n z,\n colorscale,\n showscale: true,\n };\n\n if (x) trace.x = x;\n if (y) trace.y = y;\n\n return trace;\n}\n", "/**\n * plot_config.js \u2014 the shape of a plot, independent of what is being plotted.\n *\n * Subplot grid layouts, the default subplot, the legacy-format migration, and the\n * NaN strategies (gap / zero / hold / interpolate). Not one line of it knows what\n * an economy is.\n *\n * It lived in ui/js/notebook/cells/plot_cell.js \u2014 an EcoAgent notebook cell with\n * 60 domain words in it \u2014 and that single import was the only thing keeping the\n * plot windows out of @flexdesk/charts. Five modules imported these helpers THROUGH the\n * cell, which is how you end up with a chart library that depends on a notebook.\n *\n * plot_cell.js re-exports everything here, so its existing importers are unchanged.\n */\n\nimport { getSeriesColor } from './plotly_wrapper.js';\n\n\nlet _uid = 0;\nfunction uid(prefix = 'p') { return `${prefix}-${++_uid}-${Date.now().toString(36)}`; }\n\n/**\n * Apply NaN handling strategy to a data array.\n * @param {number[]} data\n * @param {'gap'|'zero'|'hold'|'interpolate'} strategy\n * @param {number[]} xData \u2014 for interpolation\n * @returns {Array}\n */\nfunction applyNanHandling(data, strategy, xData) {\n const isMissing = (v) => v === null || v === undefined || (typeof v === 'number' && !Number.isFinite(v));\n\n if (strategy === 'zero') return data.map(v => isMissing(v) ? 0 : v);\n\n if (strategy === 'hold') {\n const result = [];\n let last = null;\n for (const v of data) {\n if (isMissing(v)) result.push(last);\n else { last = v; result.push(v); }\n }\n return result;\n }\n\n if (strategy === 'interpolate') {\n const result = [...data];\n for (let i = 0; i < result.length; i++) {\n if (!isMissing(result[i])) continue;\n let left = -1, right = -1;\n for (let j = i - 1; j >= 0; j--) { if (!isMissing(result[j])) { left = j; break; } }\n for (let j = i + 1; j < result.length; j++) { if (!isMissing(result[j])) { right = j; break; } }\n if (left >= 0 && right >= 0 && xData) {\n const frac = (xData[i] - xData[left]) / (xData[right] - xData[left]);\n result[i] = result[left] + frac * (result[right] - result[left]);\n } else if (left >= 0) {\n result[i] = result[left];\n } else if (right >= 0) {\n result[i] = result[right];\n } else {\n result[i] = null;\n }\n }\n return result;\n }\n\n // 'gap' (default) \u2014 replace with null for Plotly gap rendering\n return data.map(v => isMissing(v) ? null : v);\n}\n\n// \u2500\u2500\u2500 Layout templates (matching figure_cell.js) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst PLOT_LAYOUTS = Object.freeze({\n '1x1': { label: 'Single', slots: 1, grid: { columns: '1fr', rows: '1fr' }, areas: [{ slot: 0, gridArea: '1/1/2/2' }] },\n '1x2': { label: 'Side by side', slots: 2, grid: { columns: '1fr 1fr', rows: '1fr' }, areas: [{ slot: 0, gridArea: '1/1/2/2' }, { slot: 1, gridArea: '1/2/2/3' }] },\n '2x1': { label: 'Stacked', slots: 2, grid: { columns: '1fr', rows: '1fr 1fr' }, areas: [{ slot: 0, gridArea: '1/1/2/2' }, { slot: 1, gridArea: '2/1/3/2' }] },\n '2x2': { label: '2\\u00d72 Grid', slots: 4, grid: { columns: '1fr 1fr', rows: '1fr 1fr' }, areas: [{ slot: 0, gridArea: '1/1/2/2' }, { slot: 1, gridArea: '1/2/2/3' }, { slot: 2, gridArea: '2/1/3/2' }, { slot: 3, gridArea: '2/2/3/3' }] },\n '1x3': { label: 'Three columns', slots: 3, grid: { columns: '1fr 1fr 1fr', rows: '1fr' }, areas: [{ slot: 0, gridArea: '1/1/2/2' }, { slot: 1, gridArea: '1/2/2/3' }, { slot: 2, gridArea: '1/3/2/4' }] },\n 'wide-top': { label: '1 + 2', slots: 3, grid: { columns: '1fr 1fr', rows: '1fr 1fr' }, areas: [{ slot: 0, gridArea: '1/1/2/3' }, { slot: 1, gridArea: '2/1/3/2' }, { slot: 2, gridArea: '2/2/3/3' }] },\n 'wide-bottom': { label: '2 + 1', slots: 3, grid: { columns: '1fr 1fr', rows: '1fr 1fr' }, areas: [{ slot: 0, gridArea: '1/1/2/2' }, { slot: 1, gridArea: '1/2/2/3' }, { slot: 2, gridArea: '2/1/3/3' }] },\n});\n\nfunction makeDefaultSubplot(index) {\n return {\n id: uid('sp'),\n displayName: '',\n chartType: 'line',\n legendPosition: 'hidden',\n interpolation: 'linear',\n nanHandling: 'gap',\n showDataPoints: false,\n showHpTrend: false,\n showHpCycle: false,\n hpLambda: 1600,\n xAxis: { useTime: true, variable: '' },\n zAxis: null,\n yAxes: [{\n id: uid('y'),\n label: '',\n scale: 'linear',\n position: 'left',\n min: null,\n max: null,\n step: null,\n series: [],\n }],\n };\n}\n\nfunction migrateData(data) {\n // Already in multi-layout format\n if (data?.layout && Array.isArray(data?.subplots)) {\n // Migrate caption \u2192 description (old field name)\n if ('caption' in data && !('description' in data)) {\n data.description = data.caption;\n data.caption = '';\n }\n return data;\n }\n\n // Migrate legacy single-chart format \u2192 multi-layout with one subplot\n const legacySingle = migrateSingleChart(data);\n return {\n layout: '1x1',\n subplots: [{ id: uid('sp'), ...legacySingle }],\n caption: '',\n description: data?.caption ?? data?.description ?? '',\n doc: data?.doc ?? '',\n };\n}\n\n/** Migrate legacy flat series[]/variables[] to yAxes[] single-chart format. */\nfunction migrateSingleChart(data) {\n if (data?.yAxes) {\n return {\n displayName: data.displayName ?? '',\n chartType: data.chartType ?? 'line',\n legendPosition: data.legendPosition ?? 'hidden',\n interpolation: data.interpolation ?? 'linear',\n nanHandling: data.nanHandling ?? 'gap',\n showDataPoints: data.showDataPoints ?? false,\n yAxes: data.yAxes,\n };\n }\n\n const series = data?.series ?? data?.variables?.map((v, i) => ({\n variable: v, label: '', color: getSeriesColor(i),\n })) ?? [];\n\n return {\n displayName: data?.title ?? data?.displayName ?? '',\n chartType: data?.chartType ?? data?.widgetType ?? 'line',\n legendPosition: data?.legendPosition ?? 'hidden',\n interpolation: data?.interpolation ?? 'linear',\n nanHandling: data?.nanHandling ?? 'gap',\n showDataPoints: data?.showDataPoints ?? false,\n yAxes: [{\n id: uid('y'),\n label: data?.yLabel ?? '',\n scale: 'linear',\n position: 'left',\n min: null,\n max: null,\n series: series.map((s, i) => ({\n id: s.id ?? uid('s'),\n variable: s.variable ?? '',\n label: s.label ?? '',\n color: s.color ?? getSeriesColor(i),\n lineWidth: s.lineWidth ?? 2,\n lineStyle: s.lineStyle ?? 'solid',\n stackGroup: s.stackGroup ?? null,\n ...(s.overlay ? { overlay: s.overlay } : {}),\n })),\n }],\n };\n}\n\nexport { uid, applyNanHandling, PLOT_LAYOUTS, makeDefaultSubplot, migrateData, migrateSingleChart };\n", "/**\n * Plot Popout Window\n *\n * Opens a plot in a separate draggable/resizable ManagedWindow with two tabs:\n * - Plot tab: Interactive Plotly chart grid with modebar controls\n * - Data tab: Table showing all series using the unified DataTable component\n *\n * Uses the PlotCell data model (multi-layout subplots) as its canonical format.\n * All plot window contexts (notebook, dashboard, documentation) use this single\n * implementation.\n *\n * Features:\n * - Multi-subplot grid layouts (1x1, 1x2, 2x1, 2x2, 1x3, wide-top, wide-bottom)\n * - Series visibility toggle panel\n * - Zoom/pan toolbar with zoom in/out, autoscale, reset\n * - PyWebView integration for file downloads (CSV, PNG)\n * - NotificationCenter integration for user feedback\n * - Live streaming updates while the data source is running\n * - HP filter trend/cycle decomposition\n * - ETL actuals overlay support\n */\n\nimport { ManagedWindow } from '../ui/components/managed_window.js';\nimport { DataTable } from '../ui/components/data_table.js';\nimport { createRafResizeObserver } from '../ui/utils/raf_resize_observer.js';\nimport {\n ensurePlotly,\n purge,\n getSeriesColor,\n} from './plotly_wrapper.js';\nimport {\n buildTrace,\n buildYAxisLayout,\n buildLegendLayout,\n buildOverlayShapes,\n} from './chart_types.js';\nimport {\n PLOT_LAYOUTS,\n migrateData,\n applyNanHandling,\n} from './plot_config.js';\n\nexport class PlotPopoutWindow {\n /**\n * @param {Object} options\n * @param {string} options.id - Unique window identifier\n * @param {string} options.title - Window title\n * @param {Object} options.plotConfig - PlotCell format: { layout, subplots }\n * @param {Function} options.getResults - Returns { time: number[], series: { [key]: number[] } }\n * @param {Object} options.services - { eventBus, logger }\n * @param {Object} [options.host] - A Host (ui/js/host/host.js). Its `dialogs`\n * capability backs Export PNG/CSV; absent => Blob download fallback.\n * @param {Function} [options.onClose] - Called when window closes\n * @param {Object} [options.actuals] - ETL overlay data { seriesId: { years, values } }\n * @param {Function} [options.configRenderer] - (container) => void \u2014 renders config panel\n */\n constructor({ id, title, plotConfig, getResults, services, host, onClose, actuals,\n configRenderer,\n // The window used to listen for 'simulation:run:completed' and tell\n // the user to \"run simulation first\". A chart window does not know\n // that its data comes from a simulation; the app that opens it does.\n refreshEvent = 'data:changed',\n emptyMessage = 'No data yet.',\n tableEmptyMessage = 'No data yet.' }) {\n this._id = id;\n this._title = title || 'Plot';\n this._plotConfig = migrateData(plotConfig);\n this._getResults = getResults;\n this._services = services;\n this._host = host || null;\n this._onClose = onClose ?? (() => {});\n this._actuals = actuals ?? null;\n this._configRenderer = configRenderer ?? null;\n this.refreshEvent = refreshEvent;\n // TWO messages, not one. The chart says \"No data \u2014 run simulation first.\"\n // and the data table underneath says \"Run simulation to see data\". Folding\n // them into a single option would have quietly rewritten one of them, which\n // is the kind of change a pixel gate catches only if a captured view happens\n // to be showing an empty plot.\n this.emptyMessage = emptyMessage;\n this.tableEmptyMessage = tableEmptyMessage;\n\n this._window = null;\n this._contentEl = null;\n this._chartDivs = [];\n this._gridEl = null;\n this._activeTab = 'plot';\n this._eventDisposers = [];\n this._resizeObserver = null;\n this._chartCreated = false;\n this._lastResults = null;\n\n // Data table\n this._dataTable = null;\n this._dataTableContainer = null;\n this._tableHeaders = [];\n this._tableRows = [];\n\n // DOM refs\n this._plotTab = null;\n this._dataTab = null;\n this._configTab = null;\n this._plotContent = null;\n this._dataContent = null;\n this._configContent = null;\n this._toolbarActions = null;\n this._zoomBtn = null;\n this._panBtn = null;\n\n // Series visibility toggle\n this._hiddenSeries = new Set();\n this._allSeriesInfo = [];\n this._allSeriesLabels = [];\n this._seriesToggleBtn = null;\n this._seriesTogglePanel = null;\n this._seriesTogglePanelVisible = false;\n this._lastTogglePanelSignature = null;\n this._outsideClickHandler = null;\n\n this._renderPending = false;\n\n // Live-update toggle: when true, window re-renders on streaming events\n this._liveUpdate = true;\n this._liveBtn = null;\n }\n\n get isVisible() { return this._window?.isVisible ?? false; }\n\n async show() {\n if (this._window?.isVisible) {\n this._window.bringToFront();\n return;\n }\n\n await ensurePlotly();\n this.#createWindow();\n this.#subscribeEvents();\n this.#setupResizeObserver();\n await this.#render();\n }\n\n bringToFront() { this._window?.bringToFront?.(); }\n\n close() { this._window?.close?.(); }\n\n /** Update plot config and re-render. */\n updateConfig(plotConfig) {\n this._plotConfig = migrateData(plotConfig);\n this.#buildSubplotGrid();\n this.#scheduleRender();\n }\n\n /** Update actuals overlay data and re-render. */\n setActuals(actuals) {\n this._actuals = actuals;\n this.#scheduleRender();\n }\n\n // \u2500\u2500 Window creation \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n #createWindow() {\n this._contentEl = this.#buildContent();\n\n this._window = new ManagedWindow({\n id: `plot-window-${this._id}`,\n title: this._title,\n icon: 'monitoring',\n content: this._contentEl,\n minWidth: 500,\n minHeight: 400,\n defaultWidth: 800,\n defaultHeight: 600,\n canMinimize: true,\n canMaximize: true,\n canResize: true,\n canDrag: true,\n onClose: () => { this.#dispose(); this._onClose(); },\n });\n\n this._window.show();\n }\n\n #buildContent() {\n const container = document.createElement('div');\n container.className = 'twm-plot-window-container';\n\n // Tab header\n const tabHeader = document.createElement('div');\n tabHeader.className = 'twm-code-tabs-header';\n\n const tabs = document.createElement('div');\n tabs.className = 'tabs twm-code-tabs';\n\n this._plotTab = document.createElement('button');\n this._plotTab.className = 'twm-code-tab active';\n this._plotTab.type = 'button';\n this._plotTab.textContent = 'Plot';\n this._plotTab.addEventListener('click', () => this.#switchTab('plot'));\n\n this._dataTab = document.createElement('button');\n this._dataTab.className = 'twm-code-tab';\n this._dataTab.type = 'button';\n this._dataTab.textContent = 'Data';\n this._dataTab.addEventListener('click', () => this.#switchTab('data'));\n\n tabs.appendChild(this._plotTab);\n tabs.appendChild(this._dataTab);\n\n if (this._configRenderer) {\n this._configTab = document.createElement('button');\n this._configTab.className = 'twm-code-tab';\n this._configTab.type = 'button';\n this._configTab.textContent = 'Config';\n this._configTab.addEventListener('click', () => this.#switchTab('config'));\n tabs.appendChild(this._configTab);\n }\n\n // Toolbar (visible when Plot tab is active)\n this._toolbarActions = document.createElement('div');\n this._toolbarActions.className = 'twm-plot-window-toolbar';\n\n // Drag mode group\n const dragGroup = this.#toolbarGroup();\n this._zoomBtn = this.#toolbarBtn('search', 'Zoom', () => this.#setDragMode('zoom'));\n this._zoomBtn.classList.add('twm-is-active');\n this._panBtn = this.#toolbarBtn('pan_tool', 'Pan', () => this.#setDragMode('pan'));\n dragGroup.appendChild(this._zoomBtn);\n dragGroup.appendChild(this._panBtn);\n this._toolbarActions.appendChild(dragGroup);\n\n // Zoom control group\n const zoomGroup = this.#toolbarGroup();\n zoomGroup.appendChild(this.#toolbarBtn('zoom_in', 'Zoom in', () => this.#zoom(0.5)));\n zoomGroup.appendChild(this.#toolbarBtn('zoom_out', 'Zoom out', () => this.#zoom(2)));\n zoomGroup.appendChild(this.#toolbarBtn('zoom_out_map', 'Autoscale', () => this.#autoscale()));\n zoomGroup.appendChild(this.#toolbarBtn('home', 'Reset axes', () => this.#autoscale()));\n this._toolbarActions.appendChild(zoomGroup);\n\n // Spacer\n const spacer = document.createElement('div');\n spacer.style.flex = '1';\n this._toolbarActions.appendChild(spacer);\n\n // Action buttons group\n const actionsGroup = this.#toolbarGroup();\n\n // Live-update toggle\n this._liveBtn = this.#toolbarBtn('stream', 'Live update \u2014 click to lock', () => this.#toggleLiveUpdate());\n this._liveBtn.classList.add('twm-is-active');\n actionsGroup.appendChild(this._liveBtn);\n\n // Series visibility toggle\n const toggleSeriesBtn = this.#toolbarBtn('visibility', 'Toggle series visibility', () => this.#toggleSeriesPanel());\n this._seriesToggleBtn = toggleSeriesBtn;\n actionsGroup.appendChild(toggleSeriesBtn);\n\n // Download PNG\n actionsGroup.appendChild(this.#toolbarBtn('image', 'Download plot as PNG', () => this.#downloadPNG()));\n\n // Download CSV\n actionsGroup.appendChild(this.#toolbarBtn('download', 'Download data as CSV', () => this.#downloadCSV()));\n\n this._toolbarActions.appendChild(actionsGroup);\n\n tabHeader.appendChild(tabs);\n tabHeader.appendChild(this._toolbarActions);\n\n // Tab content area\n const content = document.createElement('div');\n content.className = 'twm-plot-window-content';\n\n // Plot tab content\n this._plotContent = document.createElement('div');\n this._plotContent.className = 'twm-plot-tab-content active';\n this._plotContent.setAttribute('data-tab', 'plot');\n this._plotContent.style.cssText = 'display:flex; flex-direction:column;';\n\n this._gridEl = document.createElement('div');\n this._gridEl.className = 'twm-plot-window-chart';\n this._plotContent.appendChild(this._gridEl);\n\n this.#buildSubplotGrid();\n\n // Data tab content\n this._dataContent = document.createElement('div');\n this._dataContent.className = 'twm-plot-tab-content';\n this._dataContent.setAttribute('data-tab', 'data');\n this._dataContent.style.cssText = 'display:none; flex-direction:column;';\n\n this._dataTableContainer = document.createElement('div');\n this._dataTableContainer.style.cssText = 'flex:1; min-height:0; display:flex; flex-direction:column;';\n this._dataContent.appendChild(this._dataTableContainer);\n\n content.appendChild(this._plotContent);\n content.appendChild(this._dataContent);\n\n // Config tab content (optional)\n if (this._configRenderer) {\n this._configContent = document.createElement('div');\n this._configContent.className = 'twm-plot-tab-content';\n this._configContent.setAttribute('data-tab', 'config');\n this._configContent.style.cssText = 'display:none; flex-direction:column; overflow:auto; padding:8px 12px;';\n this._configRenderer(this._configContent);\n content.appendChild(this._configContent);\n }\n\n // Series visibility dropdown panel (initially hidden)\n this._seriesTogglePanel = document.createElement('div');\n this._seriesTogglePanel.className = 'twm-plot-series-toggle-panel';\n this._seriesTogglePanel.style.display = 'none';\n\n container.appendChild(tabHeader);\n container.appendChild(content);\n container.appendChild(this._seriesTogglePanel);\n\n return container;\n }\n\n // \u2500\u2500 Subplot grid \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n #buildSubplotGrid() {\n if (!this._gridEl) return;\n\n // Purge existing charts\n for (const div of this._chartDivs) {\n if (div && window.Plotly) {\n try { purge(div); } catch (_) {}\n }\n }\n this._gridEl.innerHTML = '';\n this._chartDivs = [];\n\n const tmpl = PLOT_LAYOUTS[this._plotConfig.layout] || PLOT_LAYOUTS['1x1'];\n this._gridEl.style.display = 'grid';\n this._gridEl.style.gridTemplateColumns = tmpl.grid.columns;\n this._gridEl.style.gridTemplateRows = tmpl.grid.rows;\n this._gridEl.style.gap = '4px';\n this._gridEl.style.height = '100%';\n this._gridEl.style.width = '100%';\n\n for (let i = 0; i < tmpl.slots; i++) {\n const div = document.createElement('div');\n div.className = 'plot-tile-chart';\n div.style.gridArea = tmpl.areas[i].gridArea;\n div.style.minHeight = '0';\n this._gridEl.appendChild(div);\n this._chartDivs.push(div);\n }\n\n this._chartCreated = false;\n }\n\n // \u2500\u2500 Toolbar helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n #toolbarGroup() {\n const g = document.createElement('div');\n g.className = 'twm-plot-window-toolbar__group';\n return g;\n }\n\n #toolbarBtn(icon, tooltip, onClick) {\n const btn = document.createElement('button');\n btn.className = 'twm-btn-icon twm-has-tooltip';\n btn.type = 'button';\n btn.setAttribute('data-tooltip', tooltip);\n btn.innerHTML = `<span class=\"material-symbols-outlined\">${icon}</span>`;\n if (onClick) btn.addEventListener('click', (e) => { e.stopPropagation(); onClick(); });\n return btn;\n }\n\n // \u2500\u2500 Plotly toolbar actions \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n #setDragMode(mode) {\n if (!this._chartCreated) return;\n for (const div of this._chartDivs) {\n if (div._fullLayout) {\n window.Plotly.relayout(div, { dragmode: mode }).catch(() => {});\n }\n }\n this._zoomBtn?.classList.toggle('twm-is-active', mode === 'zoom');\n this._panBtn?.classList.toggle('twm-is-active', mode === 'pan');\n }\n\n #zoom(factor) {\n for (const div of this._chartDivs) {\n if (!div._fullLayout) continue;\n const xa = div._fullLayout.xaxis;\n const ya = div._fullLayout.yaxis;\n if (!xa || !ya) continue;\n\n const xr = xa.range;\n const yr = ya.range;\n const xMid = (xr[0] + xr[1]) / 2;\n const yMid = (yr[0] + yr[1]) / 2;\n const xHalf = (xr[1] - xr[0]) / 2 * factor;\n const yHalf = (yr[1] - yr[0]) / 2 * factor;\n\n window.Plotly.relayout(div, {\n 'xaxis.range': [xMid - xHalf, xMid + xHalf],\n 'yaxis.range': [yMid - yHalf, yMid + yHalf],\n }).catch(() => {});\n }\n }\n\n #autoscale() {\n for (const div of this._chartDivs) {\n if (!div._fullLayout) continue;\n window.Plotly.relayout(div, {\n 'xaxis.autorange': true,\n 'yaxis.autorange': true,\n }).catch(() => {});\n }\n }\n\n #setupResizeObserver() {\n if (!this._plotContent) return;\n this._resizeObserver = createRafResizeObserver(() => {\n if (this._activeTab === 'plot' && this._chartCreated && window.Plotly) {\n for (const div of this._chartDivs) {\n if (div._fullLayout) {\n Plotly.Plots.resize(div).catch(() => {});\n }\n }\n }\n });\n this._resizeObserver.observe(this._plotContent);\n }\n\n #switchTab(tabName) {\n this._activeTab = tabName;\n\n this._plotTab.classList.toggle('active', tabName === 'plot');\n this._dataTab.classList.toggle('active', tabName === 'data');\n this._configTab?.classList.toggle('active', tabName === 'config');\n\n if (this._toolbarActions) {\n this._toolbarActions.style.display = tabName === 'plot' ? '' : 'none';\n }\n\n this._plotContent.style.display = tabName === 'plot' ? 'flex' : 'none';\n this._dataContent.style.display = tabName === 'data' ? 'flex' : 'none';\n if (this._configContent) {\n this._configContent.style.display = tabName === 'config' ? 'flex' : 'none';\n }\n\n if (tabName === 'plot' && this._chartCreated && window.Plotly) {\n for (const div of this._chartDivs) {\n if (div._fullLayout) {\n Plotly.Plots.resize(div).catch(() => {});\n }\n }\n }\n\n if (tabName === 'data') {\n this.#renderDataTable();\n }\n }\n\n // \u2500\u2500 Series visibility toggle \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n #toggleSeriesPanel() {\n if (this._seriesTogglePanelVisible) {\n this.#hideSeriesPanel();\n } else {\n this.#showSeriesPanel();\n }\n }\n\n #showSeriesPanel() {\n if (!this._seriesTogglePanel || !this._seriesToggleBtn) return;\n\n const btnRect = this._seriesToggleBtn.getBoundingClientRect();\n const containerRect = this._contentEl.getBoundingClientRect();\n\n this._seriesTogglePanel.style.top = `${btnRect.bottom - containerRect.top + 4}px`;\n this._seriesTogglePanel.style.right = `${containerRect.right - btnRect.right}px`;\n this._seriesTogglePanel.style.display = '';\n this._seriesTogglePanelVisible = true;\n\n this._seriesToggleBtn.classList.add('twm-is-active');\n this.#rebuildSeriesToggleList();\n\n this._outsideClickHandler = (e) => {\n if (!this._seriesTogglePanel.contains(e.target) &&\n !this._seriesToggleBtn.contains(e.target)) {\n this.#hideSeriesPanel();\n }\n };\n requestAnimationFrame(() => {\n document.addEventListener('pointerdown', this._outsideClickHandler, true);\n });\n }\n\n #hideSeriesPanel() {\n if (this._seriesTogglePanel) {\n this._seriesTogglePanel.style.display = 'none';\n }\n this._seriesTogglePanelVisible = false;\n this._lastTogglePanelSignature = null;\n this._seriesToggleBtn?.classList.remove('twm-is-active');\n\n if (this._outsideClickHandler) {\n document.removeEventListener('pointerdown', this._outsideClickHandler, true);\n this._outsideClickHandler = null;\n }\n }\n\n #rebuildSeriesToggleList() {\n const panel = this._seriesTogglePanel;\n if (!panel) return;\n panel.innerHTML = '';\n\n // Header with \"All\" / \"None\" actions\n const header = document.createElement('div');\n header.className = 'twm-plot-series-toggle-panel__header';\n\n const title = document.createElement('span');\n title.className = 'twm-plot-series-toggle-panel__title';\n title.textContent = 'Series';\n header.appendChild(title);\n\n const headerActions = document.createElement('div');\n headerActions.className = 'twm-plot-series-toggle-panel__header-actions';\n\n const showAllBtn = document.createElement('button');\n showAllBtn.className = 'twm-plot-series-toggle-panel__action';\n showAllBtn.type = 'button';\n showAllBtn.textContent = 'All';\n showAllBtn.addEventListener('click', () => {\n this._hiddenSeries.clear();\n this.#rebuildSeriesToggleList();\n this.#scheduleRender();\n });\n\n const hideAllBtn = document.createElement('button');\n hideAllBtn.className = 'twm-plot-series-toggle-panel__action';\n hideAllBtn.type = 'button';\n hideAllBtn.textContent = 'None';\n hideAllBtn.addEventListener('click', () => {\n for (const label of this._allSeriesLabels) {\n this._hiddenSeries.add(label);\n }\n this.#rebuildSeriesToggleList();\n this.#scheduleRender();\n });\n\n headerActions.appendChild(showAllBtn);\n headerActions.appendChild(hideAllBtn);\n header.appendChild(headerActions);\n panel.appendChild(header);\n\n // Split series into model vs overlay\n const modelSeries = this._allSeriesInfo.filter(s => !s.isOverlay);\n const overlaySeries = this._allSeriesInfo.filter(s => s.isOverlay);\n\n const buildItem = ({ label, color, lineStyle }) => {\n const item = document.createElement('label');\n item.className = 'twm-plot-series-toggle-panel__item';\n\n const cb = document.createElement('input');\n cb.type = 'checkbox';\n cb.checked = !this._hiddenSeries.has(label);\n cb.addEventListener('change', () => {\n if (cb.checked) this._hiddenSeries.delete(label);\n else this._hiddenSeries.add(label);\n this.#scheduleRender();\n });\n\n const dashMap = { solid: '', dashed: '4,2', dotted: '1,2' };\n const indicator = document.createElement('div');\n indicator.className = 'twm-plot-series-toggle-panel__line-indicator';\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 28 14');\n const line = document.createElementNS('http://www.w3.org/2000/svg', 'line');\n line.setAttribute('x1', '3');\n line.setAttribute('y1', '7');\n line.setAttribute('x2', '25');\n line.setAttribute('y2', '7');\n line.setAttribute('stroke', color || '#888');\n line.setAttribute('stroke-width', '2');\n line.setAttribute('stroke-linecap', 'round');\n const dash = dashMap[lineStyle] || '';\n if (dash) line.setAttribute('stroke-dasharray', dash);\n svg.appendChild(line);\n indicator.appendChild(svg);\n\n const text = document.createElement('span');\n text.className = 'twm-plot-series-toggle-panel__label';\n text.textContent = label;\n text.title = label;\n\n item.appendChild(cb);\n item.appendChild(indicator);\n item.appendChild(text);\n return item;\n };\n\n // Model series section\n const list = document.createElement('div');\n list.className = 'twm-plot-series-toggle-panel__list';\n\n const subplotGroups = new Map();\n for (const info of modelSeries) {\n if (!subplotGroups.has(info.subplotIndex)) {\n subplotGroups.set(info.subplotIndex, []);\n }\n subplotGroups.get(info.subplotIndex).push(info);\n }\n\n const multipleSubplots = subplotGroups.size > 1;\n\n for (const [spIdx, seriesList] of subplotGroups) {\n if (multipleSubplots) {\n const spName = seriesList[0]?.subplotName || `Subplot ${spIdx + 1}`;\n const spHeader = document.createElement('div');\n spHeader.className = 'twm-plot-series-toggle-panel__axis-label';\n spHeader.textContent = spName;\n list.appendChild(spHeader);\n }\n\n for (const info of seriesList) {\n list.appendChild(buildItem(info));\n }\n }\n\n panel.appendChild(list);\n\n // Overlays section (only if any exist)\n if (overlaySeries.length > 0) {\n const ovList = document.createElement('div');\n ovList.className = 'twm-plot-series-toggle-panel__list';\n\n const ovHeader = document.createElement('div');\n ovHeader.className = 'twm-plot-series-toggle-panel__axis-label';\n ovHeader.textContent = 'Overlays';\n ovList.appendChild(ovHeader);\n\n for (const info of overlaySeries) {\n ovList.appendChild(buildItem(info));\n }\n\n panel.appendChild(ovList);\n }\n }\n\n // \u2500\u2500 Event subscriptions \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n #subscribeEvents() {\n const { eventBus } = this._services;\n if (!eventBus) return;\n\n this._eventDisposers.push(\n eventBus.on('streaming:delta', () => {\n if (this._liveUpdate) this.#scheduleRender();\n })\n );\n this._eventDisposers.push(\n eventBus.on('streaming:complete', () => {\n if (this._liveUpdate) this.#scheduleRender();\n })\n );\n // Final analytics arrive asynchronously after streaming:complete\n // (backend fetch + transform). Without this, the popout window may\n // render stale data from a previous run when the dashboard tab\n // didn't receive streaming deltas (e.g. user was on another tab).\n this._eventDisposers.push(\n eventBus.on(this.refreshEvent, () => {\n if (this._liveUpdate) this.#scheduleRender();\n })\n );\n }\n\n #toggleLiveUpdate() {\n this._liveUpdate = !this._liveUpdate;\n if (this._liveBtn) {\n this._liveBtn.classList.toggle('twm-is-active', this._liveUpdate);\n const icon = this._liveBtn.querySelector('.material-symbols-outlined');\n if (icon) icon.textContent = this._liveUpdate ? 'stream' : 'lock';\n this._liveBtn.title = this._liveUpdate\n ? 'Live update \u2014 click to lock'\n : 'Locked \u2014 click for live update';\n }\n // If switching back to live, immediately render latest data\n if (this._liveUpdate) this.#scheduleRender();\n }\n\n #scheduleRender() {\n if (this._renderPending) return;\n this._renderPending = true;\n requestAnimationFrame(() => {\n this._renderPending = false;\n this.#render();\n });\n }\n\n // \u2500\u2500 Rendering \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n async #render() {\n if (!this._window?.isVisible) return;\n\n const results = this._getResults?.();\n if (!results) return;\n\n this._lastResults = results;\n\n // Build series info for toggle panel\n this.#collectSeriesInfo();\n\n // Render all subplot charts\n this.#renderAllCharts(results);\n\n // Update table data\n this.#updateTableData(results);\n\n if (this._activeTab === 'data') {\n this.#renderDataTable();\n }\n }\n\n #collectSeriesInfo() {\n this._allSeriesInfo = [];\n this._allSeriesLabels = [];\n\n const subplots = this._plotConfig.subplots ?? [];\n for (let spIdx = 0; spIdx < subplots.length; spIdx++) {\n const sp = subplots[spIdx];\n for (const axis of sp.yAxes ?? []) {\n for (const s of axis.series ?? []) {\n const label = s.label || s.variable || 'Series';\n this._allSeriesInfo.push({\n label,\n color: s.color || getSeriesColor(this._allSeriesInfo.length),\n lineStyle: s.lineStyle || 'solid',\n subplotIndex: spIdx,\n subplotName: sp.displayName || `Subplot ${spIdx + 1}`,\n });\n this._allSeriesLabels.push(label);\n\n // Include overlay in toggle list\n if (s.overlay?.etlKey) {\n const ovLabel = s.overlay.label || `${label} (actual)`;\n this._allSeriesInfo.push({\n label: ovLabel,\n color: s.overlay.color || s.color || getSeriesColor(this._allSeriesInfo.length),\n lineStyle: s.overlay.lineStyle || 'dashed',\n subplotIndex: spIdx,\n subplotName: sp.displayName || `Subplot ${spIdx + 1}`,\n isOverlay: true,\n });\n this._allSeriesLabels.push(ovLabel);\n }\n }\n }\n }\n\n // Prune hidden labels that no longer exist\n for (const label of this._hiddenSeries) {\n if (!this._allSeriesLabels.includes(label)) {\n this._hiddenSeries.delete(label);\n }\n }\n\n // Update toggle panel if visible\n if (this._seriesTogglePanelVisible) {\n const newSig = this._allSeriesInfo.map(s => `${s.subplotIndex}|${s.label}|${s.lineStyle}`).join('\\x00');\n if (newSig !== this._lastTogglePanelSignature) {\n this._lastTogglePanelSignature = newSig;\n this.#rebuildSeriesToggleList();\n }\n }\n\n // Update toggle button icon\n if (this._seriesToggleBtn) {\n const icon = this._seriesToggleBtn.querySelector('.material-symbols-outlined');\n if (icon) {\n icon.textContent = this._hiddenSeries.size > 0 ? 'visibility_off' : 'visibility';\n }\n }\n }\n\n #renderAllCharts(results) {\n if (!window.Plotly) return;\n\n const subplots = this._plotConfig.subplots ?? [];\n for (let i = 0; i < this._chartDivs.length; i++) {\n const chartDiv = this._chartDivs[i];\n const sp = subplots[i];\n if (!chartDiv) continue;\n if (!sp) {\n chartDiv.innerHTML = '<div class=\"twm-plot-no-data\" style=\"color:rgba(255,255,255,0.3);text-align:center;padding:16px;\">No subplot configured.</div>';\n continue;\n }\n this.#renderSubplotChart(chartDiv, sp, results);\n }\n }\n\n async #renderSubplotChart(chartDiv, sp, results) {\n const { time, series } = results;\n const traces = [];\n const layoutAxes = {};\n const yRefByAxisId = {};\n let axisCount = 0;\n\n for (const axis of sp.yAxes ?? []) {\n axisCount++;\n const yAxisKey = axisCount === 1 ? 'yaxis' : `yaxis${axisCount}`;\n const yRef = axisCount === 1 ? 'y' : `y${axisCount}`;\n if (axis.id) yRefByAxisId[axis.id] = yRef;\n\n layoutAxes[yAxisKey] = buildYAxisLayout({\n axisId: yAxisKey,\n title: axis.label || '',\n position: axis.position || 'left',\n scaleType: axis.scale || 'linear',\n min: axis.min,\n max: axis.max,\n showGrid: (sp.yAxes ?? []).length === 1,\n axisPosition: axisCount > 1 ? (axis.position === 'right' ? 1 : 0) : null,\n });\n\n for (const s of axis.series ?? []) {\n if (!s.variable) continue;\n\n const label = s.label || s.variable;\n\n // Skip hidden series\n if (this._hiddenSeries.has(label)) continue;\n\n // Resolve variable: try result key (paper multi-scenario), exact, then bare (without namespace prefix)\n let rawY = series?.[s._resultKey ?? s.variable];\n if (!rawY && s._resultKey) {\n rawY = series?.[s.variable];\n }\n if (!rawY) {\n const dotIdx = s.variable.indexOf('.');\n if (dotIdx >= 0) rawY = series?.[s.variable.slice(dotIdx + 1)];\n }\n if (!rawY) continue;\n\n const y = Array.isArray(rawY) ? applyNanHandling(rawY, sp.nanHandling ?? 'gap', time) : rawY;\n const seriesTime = s._resultTime ?? time;\n traces.push(buildTrace({\n chartType: sp.chartType || 'line',\n x: seriesTime,\n y,\n name: label,\n color: s.color,\n lineWidth: s.lineWidth ?? 2,\n lineStyle: s.lineStyle ?? 'solid',\n interpolation: sp.interpolation ?? 'linear',\n yAxisId: yRef,\n showMarkers: sp.showDataPoints ?? false,\n stackGroup: s.stackGroup ?? null,\n }));\n\n // Per-series overlay trace (ETL actuals)\n if (s.overlay?.etlKey && this._actuals?.[s.id]) {\n const ovLabel = s.overlay.label || `${label} (actual)`;\n if (!this._hiddenSeries.has(ovLabel)) {\n const act = this._actuals[s.id];\n if (act?.years?.length) {\n const ov = s.overlay;\n const dashMap = { dashed: 'dash', dotted: 'dot', solid: 'solid' };\n traces.push({\n type: 'scatter',\n mode: ov.mode || 'markers+lines',\n x: act.years,\n y: act.values,\n name: ov.label || `${label} (actual)`,\n yaxis: yRef === 'y' ? undefined : yRef,\n line: {\n color: ov.color || s.color,\n width: ov.lineWidth ?? 2,\n dash: dashMap[ov.lineStyle] || 'dash',\n },\n marker: {\n color: ov.color || s.color,\n size: 4,\n symbol: 'circle',\n },\n showlegend: true,\n });\n }\n }\n }\n }\n }\n\n // HP filter traces\n if ((sp.showHpTrend || sp.showHpCycle) && window.pywebview?.api?.hp_filter) {\n const hpLambda = sp.hpLambda ?? 1600;\n for (const trace of [...traces]) {\n if (trace.type && trace.type !== 'scatter' && trace.type !== 'scattergl') continue;\n try {\n const hpResult = await window.pywebview.api.hp_filter({\n data: trace.y,\n lambda: hpLambda,\n });\n if (!hpResult?.ok) continue;\n const { trend, cycle } = hpResult;\n const origColor = trace.line?.color || trace.marker?.color || getSeriesColor(0);\n if (sp.showHpTrend && trend) {\n traces.push({\n x: trace.x, y: trend, type: 'scatter', mode: 'lines',\n name: `${trace.name} (HP Trend)`,\n yaxis: trace.yaxis || 'y',\n line: { color: origColor, width: 2, dash: 'dash' },\n showlegend: true,\n });\n }\n if (sp.showHpCycle && cycle) {\n traces.push({\n x: trace.x, y: cycle, type: 'scatter', mode: 'lines',\n name: `${trace.name} (HP Cycle)`,\n yaxis: trace.yaxis || 'y',\n line: { color: origColor, width: 1, dash: 'dot' },\n showlegend: true,\n });\n }\n } catch (_) { /* ignore HP filter failures */ }\n }\n }\n\n if (traces.length === 0 && this._hiddenSeries.size === 0) {\n chartDiv.innerHTML = `<div class=\"twm-plot-no-data\" style=\"color:rgba(255,255,255,0.3);text-align:center;padding:16px;font-size:11px;\">${this.emptyMessage}</div>`;\n return;\n }\n\n // Popout windows have space \u2014 always show legend\n const legendPos = sp.legendPosition === 'hidden' ? 'top' : (sp.legendPosition ?? 'top');\n const legend = buildLegendLayout(legendPos);\n\n // Clip the x-axis to the data's time range so overlays don't run past t0\u2013t1\n const xRange = time?.length >= 2 ? [time[0], time[time.length - 1]] : undefined;\n\n const { shapes, annotations } = buildOverlayShapes({\n referenceLines: sp.referenceLines,\n shadedBands: sp.shadedBands,\n yRefByAxisId,\n });\n\n const layout = {\n ...layoutAxes,\n ...(shapes.length ? { shapes } : {}),\n ...(annotations.length ? { annotations } : {}),\n xaxis: {\n gridcolor: 'rgba(255,255,255,0.05)',\n linecolor: 'rgba(255,255,255,0.08)',\n tickcolor: 'rgba(255,255,255,0.3)',\n zerolinecolor: 'rgba(255,255,255,0.06)',\n automargin: true,\n ...(xRange ? { range: xRange } : {}),\n },\n ...legend,\n paper_bgcolor: 'transparent',\n plot_bgcolor: 'transparent',\n font: { family: 'Inter, -apple-system, BlinkMacSystemFont, sans-serif', color: '#cccccc', size: 11 },\n margin: { t: 10, r: 20, b: 40, l: 50 },\n hoverlabel: {\n bgcolor: '#1e2228',\n bordercolor: '#444444',\n font: { family: 'Inter, -apple-system, BlinkMacSystemFont, sans-serif', color: '#cccccc' },\n },\n autosize: true,\n hovermode: 'x unified',\n };\n\n // Guard: skip if div is detached or zero-size\n if (!chartDiv.isConnected || chartDiv.offsetWidth === 0) return;\n\n try {\n await Plotly.react(chartDiv, traces, layout, { responsive: true, displayModeBar: false });\n this._chartCreated = true;\n } catch (_) {\n // Plotly can throw if div is removed mid-render\n }\n }\n\n // \u2500\u2500 Data table \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n #updateTableData(results) {\n if (!results) {\n this._tableHeaders = [];\n this._tableRows = [];\n return;\n }\n\n const headers = ['Time'];\n const seriesColumns = [];\n const { time, series } = results;\n const subplots = this._plotConfig.subplots ?? [];\n\n for (const sp of subplots) {\n for (const axis of sp.yAxes ?? []) {\n for (const s of axis.series ?? []) {\n if (!s.variable) continue;\n const label = s.label || s.variable;\n let rawY = series?.[s._resultKey ?? s.variable];\n if (!rawY && s._resultKey) {\n rawY = series?.[s.variable];\n }\n if (!rawY) {\n const dotIdx = s.variable.indexOf('.');\n if (dotIdx >= 0) rawY = series?.[s.variable.slice(dotIdx + 1)];\n }\n if (!rawY) continue;\n headers.push(label);\n seriesColumns.push(rawY);\n }\n }\n }\n\n const rows = [];\n for (let i = 0; i < time.length; i++) {\n const row = [time[i]];\n for (const col of seriesColumns) {\n row.push(Array.isArray(col) ? col[i] : null);\n }\n rows.push(row);\n }\n\n this._tableHeaders = headers;\n this._tableRows = rows;\n }\n\n #renderDataTable() {\n if (!this._dataTableContainer) return;\n\n if (!this._dataTable) {\n this._dataTable = new DataTable(this._dataTableContainer, {\n headers: this._tableHeaders,\n rows: this._tableRows,\n pageSize: 100,\n pagination: true,\n selectable: true,\n copyable: true,\n sortable: true,\n filterable: true,\n readonly: false,\n emptyMessage: this.tableEmptyMessage,\n services: this._services,\n host: this._host,\n });\n this._dataTable.render();\n } else {\n this._dataTable.setData({\n headers: this._tableHeaders,\n rows: this._tableRows,\n });\n }\n }\n\n // \u2500\u2500 Downloads \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n async #downloadCSV() {\n if (this._tableRows.length === 0) {\n this.#notify('Download', 'No data available to download.', 'warn');\n return;\n }\n\n const filename = `${this._title.replace(/[^a-z0-9]/gi, '_')}_data.csv`;\n\n const lines = [this._tableHeaders.join(',')];\n for (const row of this._tableRows) {\n lines.push(row.map(val => this.#csvEscape(val)).join(','));\n }\n const csv = lines.join('\\n');\n\n // null <=> the host has no save dialog behind its `dialogs` capability\n // (host.js). Fall back; do not report it as a failed save.\n const dialogs = this._host?.dialogs;\n let result = null;\n if (dialogs) {\n try {\n result = await dialogs.saveFile({ data: csv, filename, kind: 'csv' });\n } catch (err) {\n console.error('[PlotPopoutWindow] CSV download failed:', err);\n this.#notify('Download', 'Failed to save file', 'error');\n return;\n }\n }\n if (result) {\n if (result.ok) {\n this.#notify('Download', `Saved ${this._tableRows.length} rows to ${result.path}`, 'success');\n } else if (!result.cancelled) {\n this.#notify('Download', result.error || 'Failed to save file', 'error');\n }\n return;\n }\n\n const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });\n const url = URL.createObjectURL(blob);\n const link = document.createElement('a');\n link.href = url;\n link.download = filename;\n link.click();\n URL.revokeObjectURL(url);\n this.#notify('Download', 'Download started', 'info');\n }\n\n #csvEscape(value) {\n if (value == null) return '';\n const str = String(value);\n if (str.includes(',') || str.includes('\"') || str.includes('\\n')) {\n return `\"${str.replace(/\"/g, '\"\"')}\"`;\n }\n return str;\n }\n\n async #downloadPNG() {\n // For multi-subplot, capture the grid container as a whole\n // Fall back to first chart div if only one subplot\n const targetDiv = this._chartDivs.length === 1 ? this._chartDivs[0] : this._chartDivs[0];\n if (!targetDiv || !window.Plotly || !this._chartCreated) {\n this.#notify('Download', 'Plot not ready', 'warn');\n return;\n }\n\n const filename = `${this._title.replace(/[^a-z0-9]/gi, '_')}.png`;\n\n try {\n const pngDataUrl = await window.Plotly.toImage(targetDiv, {\n format: 'png',\n width: 1920,\n height: 1080,\n scale: 2,\n });\n\n // null <=> no save dialog behind the capability (host.js) -> fall back.\n const dialogs = this._host?.dialogs;\n const result = dialogs\n ? await dialogs.saveFile({ data: pngDataUrl.split(',')[1], filename, kind: 'png' })\n : null;\n if (result) {\n if (result.ok) {\n this.#notify('Download', `Plot saved to ${result.path}`, 'success');\n } else if (!result.cancelled) {\n this.#notify('Download', result.error || 'Failed to save image', 'error');\n }\n } else {\n const link = document.createElement('a');\n link.href = pngDataUrl;\n link.download = filename;\n link.click();\n this.#notify('Download', 'PNG download started', 'info');\n }\n } catch (err) {\n this._services.logger?.warn?.('[PlotPopoutWindow] PNG download failed', err);\n this.#notify('Download', 'Failed to generate PNG', 'error');\n }\n }\n\n // \u2500\u2500 Utilities \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n #notify(title, message, severity = 'info') {\n this._services.eventBus?.emit?.('toast:show', {\n title,\n message,\n type: severity,\n });\n }\n\n // \u2500\u2500 Cleanup \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n #dispose() {\n if (this._dataTable) {\n this._dataTable.dispose();\n this._dataTable = null;\n }\n\n this.#hideSeriesPanel();\n\n if (this._resizeObserver) {\n this._resizeObserver.disconnect();\n this._resizeObserver = null;\n }\n\n for (const disposer of this._eventDisposers) {\n try { disposer?.dispose?.(); } catch (_) {}\n }\n this._eventDisposers = [];\n\n for (const div of this._chartDivs) {\n if (div && window.Plotly) {\n try { purge(div); } catch (_) {}\n }\n }\n\n this._window = null;\n this._contentEl = null;\n this._gridEl = null;\n this._chartDivs = [];\n this._plotTab = null;\n this._dataTab = null;\n this._plotContent = null;\n this._dataContent = null;\n this._dataTableContainer = null;\n this._toolbarActions = null;\n this._zoomBtn = null;\n this._panBtn = null;\n this._seriesToggleBtn = null;\n this._seriesTogglePanel = null;\n this._lastTogglePanelSignature = null;\n this._hiddenSeries = null;\n this._allSeriesInfo = null;\n this._allSeriesLabels = null;\n this._chartCreated = false;\n this._lastResults = null;\n }\n}\n\n// \u2500\u2500 Singleton window manager \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst _openWindows = new Map();\n\n/**\n * Open or focus a plot popout window.\n *\n * @param {Object} options\n * @param {string} options.id - Unique window identifier\n * @param {string} options.title - Window title\n * @param {Object} options.plotConfig - PlotCell format: { layout, subplots }\n * @param {Function} options.getResults - Returns { time: number[], series: { [key]: number[] } }\n * @param {Object} options.services - { eventBus, logger }\n * @param {Object} [options.actuals] - ETL overlay data\n * @returns {PlotPopoutWindow}\n */\nexport async function openPlotPopoutWindow(options) {\n const { id } = options;\n let win = _openWindows.get(id);\n if (win?.isVisible) {\n win.bringToFront();\n return win;\n }\n\n // Forward the WHOLE options object. This used to destructure a fixed list of\n // eight names and rebuild the object from them, which means every option added\n // to the constructor from now on would be silently dropped on its way through\n // the factory \u2014 including `refreshEvent`, whose loss would show up as a plot\n // window that simply stops updating, with no error anywhere.\n win = new PlotPopoutWindow({\n ...options,\n onClose: () => _openWindows.delete(id),\n });\n _openWindows.set(id, win);\n\n await win.show();\n return win;\n}\n\n// \u2500\u2500 Raw-traces window (for dashboard tile expand) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * Open a ManagedWindow with pre-built Plotly traces.\n *\n * Reuses the same toolbar, tab layout, and download logic as PlotPopoutWindow\n * but accepts ready-made `{ traces, layout }` instead of plotConfig + getResults.\n * Used by dashboard tile widgets whose getExpandData() returns raw Plotly specs.\n *\n * @param {Object} options\n * @param {string} options.id - Unique window identifier\n * @param {string} options.title - Window title\n * @param {Array} options.traces - Plotly trace objects\n * @param {Object} options.layout - Plotly layout object\n * @param {Array} [options.tableHeaders] - Column headers for Data tab\n * @param {Array} [options.tableRows] - Row data for Data tab\n * @param {Object} [options.services] - { eventBus, logger }\n * @param {Object} [options.host] - A Host (ui/js/host/host.js); backs Export PNG/CSV.\n * @returns {{ close: Function, bringToFront: Function }}\n */\nexport async function openRawTracesWindow({ id, title, traces, layout, frames, tableHeaders, tableRows, services, host }) {\n const existing = _openWindows.get(id);\n if (existing?.isVisible) {\n existing.bringToFront();\n return existing;\n }\n\n await ensurePlotly();\n\n // State\n let chartDiv = null;\n let chartCreated = false;\n let resizeObserver = null;\n let dataTable = null;\n let managedWindow = null;\n\n // \u2500\u2500 Build content DOM \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n const container = document.createElement('div');\n container.className = 'twm-plot-window-container';\n\n // Tab header\n const tabHeader = document.createElement('div');\n tabHeader.className = 'twm-code-tabs-header';\n\n const tabs = document.createElement('div');\n tabs.className = 'tabs twm-code-tabs';\n\n const plotTab = document.createElement('button');\n plotTab.className = 'twm-code-tab active';\n plotTab.type = 'button';\n plotTab.textContent = 'Plot';\n\n const dataTab = document.createElement('button');\n dataTab.className = 'twm-code-tab';\n dataTab.type = 'button';\n dataTab.textContent = 'Data';\n\n tabs.appendChild(plotTab);\n tabs.appendChild(dataTab);\n\n // Toolbar (same layout as PlotPopoutWindow)\n const toolbar = document.createElement('div');\n toolbar.className = 'twm-plot-window-toolbar';\n\n const spacer = document.createElement('div');\n spacer.style.flex = '1';\n toolbar.appendChild(spacer);\n\n const actionsGroup = document.createElement('div');\n actionsGroup.className = 'twm-plot-window-toolbar__group';\n\n const mkBtn = (icon, tooltip, onClick) => {\n const btn = document.createElement('button');\n btn.className = 'twm-btn-icon twm-has-tooltip';\n btn.type = 'button';\n btn.setAttribute('data-tooltip', tooltip);\n btn.innerHTML = `<span class=\"material-symbols-outlined\">${icon}</span>`;\n btn.addEventListener('click', (e) => { e.stopPropagation(); onClick(); });\n return btn;\n };\n\n actionsGroup.appendChild(mkBtn('image', 'Download plot as PNG', downloadPNG));\n actionsGroup.appendChild(mkBtn('download', 'Download data as CSV', downloadCSV));\n toolbar.appendChild(actionsGroup);\n\n tabHeader.appendChild(tabs);\n tabHeader.appendChild(toolbar);\n\n // Tab content\n const content = document.createElement('div');\n content.className = 'twm-plot-window-content';\n\n const plotContent = document.createElement('div');\n plotContent.className = 'twm-plot-tab-content active';\n plotContent.setAttribute('data-tab', 'plot');\n plotContent.style.cssText = 'display:flex; flex-direction:column;';\n\n chartDiv = document.createElement('div');\n chartDiv.className = 'twm-plot-window-chart';\n plotContent.appendChild(chartDiv);\n\n const dataContent = document.createElement('div');\n dataContent.className = 'twm-plot-tab-content';\n dataContent.setAttribute('data-tab', 'data');\n dataContent.style.cssText = 'display:none; flex-direction:column;';\n\n const dataTableContainer = document.createElement('div');\n dataTableContainer.style.cssText = 'flex:1; min-height:0; display:flex; flex-direction:column;';\n dataContent.appendChild(dataTableContainer);\n\n content.appendChild(plotContent);\n content.appendChild(dataContent);\n\n container.appendChild(tabHeader);\n container.appendChild(content);\n\n // Tab switching\n plotTab.addEventListener('click', () => {\n plotTab.classList.add('active');\n dataTab.classList.remove('active');\n toolbar.style.display = '';\n plotContent.style.display = 'flex';\n dataContent.style.display = 'none';\n if (chartCreated && window.Plotly && chartDiv) {\n try { window.Plotly.Plots.resize(chartDiv); } catch (_) {}\n }\n });\n\n dataTab.addEventListener('click', () => {\n dataTab.classList.add('active');\n plotTab.classList.remove('active');\n toolbar.style.display = 'none';\n plotContent.style.display = 'none';\n dataContent.style.display = 'flex';\n if (!dataTable && tableHeaders?.length) {\n dataTable = new DataTable(dataTableContainer, {\n headers: tableHeaders,\n rows: tableRows || [],\n pagination: true,\n pageSize: 100,\n selectable: true,\n copyable: true,\n sortable: true,\n filterable: true,\n readonly: true,\n emptyMessage: 'No data available',\n services,\n host,\n });\n dataTable.render();\n }\n });\n\n // \u2500\u2500 Create window \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n function dispose() {\n if (resizeObserver) { resizeObserver.disconnect(); resizeObserver = null; }\n if (dataTable) { dataTable.dispose(); dataTable = null; }\n if (chartDiv && window.Plotly) { try { purge(chartDiv); } catch (_) {} }\n chartDiv = null;\n chartCreated = false;\n managedWindow = null;\n _openWindows.delete(id);\n }\n\n managedWindow = new ManagedWindow({\n id: `raw-plot-${id}`,\n title: title || 'Chart',\n icon: 'monitoring',\n content: container,\n minWidth: 500,\n minHeight: 400,\n defaultWidth: 800,\n defaultHeight: 600,\n canMinimize: true,\n canMaximize: true,\n canResize: true,\n canDrag: true,\n onClose: dispose,\n });\n\n const handle = {\n get isVisible() { return managedWindow?.isVisible ?? false; },\n bringToFront() { managedWindow?.bringToFront?.(); },\n close() { managedWindow?.close?.(); },\n };\n\n _openWindows.set(id, handle);\n managedWindow.show();\n\n // Render plot\n const defaultMargin = { l: 60, r: 30, t: 40, b: 60 };\n const plotLayout = {\n paper_bgcolor: 'transparent',\n plot_bgcolor: 'transparent',\n font: { family: 'Inter, -apple-system, BlinkMacSystemFont, sans-serif', color: '#cccccc', size: 11 },\n hoverlabel: {\n bgcolor: '#1e2228',\n bordercolor: '#444444',\n font: { family: 'Inter, -apple-system, BlinkMacSystemFont, sans-serif', color: '#cccccc' },\n },\n autosize: true,\n hovermode: 'x unified',\n ...layout,\n margin: { ...defaultMargin, ...(layout?.margin || {}) },\n };\n\n await window.Plotly.newPlot(chartDiv, traces, plotLayout, {\n responsive: true,\n displayModeBar: true,\n displaylogo: false,\n modeBarButtonsToRemove: ['lasso2d', 'select2d', 'toImage'],\n });\n if (Array.isArray(frames) && frames.length) {\n try { await window.Plotly.addFrames(chartDiv, frames); }\n catch (err) { console.warn('[openRawTracesWindow] addFrames failed:', err); }\n }\n chartCreated = true;\n\n // Resize observer\n resizeObserver = createRafResizeObserver(() => {\n if (chartDiv && chartCreated && window.Plotly) {\n try { window.Plotly.Plots.resize(chartDiv); } catch (_) {}\n }\n });\n resizeObserver.observe(plotContent);\n\n // \u2500\u2500 Download helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n function notify(ntitle, message, severity = 'info') {\n services?.eventBus?.emit?.('toast:show', { title: ntitle, message, type: severity });\n }\n\n async function downloadPNG() {\n if (!chartDiv || !chartCreated || !window.Plotly) {\n notify('Download', 'Plot not ready', 'warn');\n return;\n }\n const filename = `${(title || 'chart').replace(/[^a-z0-9]/gi, '_')}.png`;\n try {\n const dataUrl = await window.Plotly.toImage(chartDiv, {\n format: 'png', width: 1920, height: 1080, scale: 2,\n });\n // null <=> no save dialog behind the capability (host.js) -> fall back.\n const dialogs = host?.dialogs;\n const result = dialogs\n ? await dialogs.saveFile({ data: dataUrl.split(',')[1], filename, kind: 'png' })\n : null;\n if (result) {\n if (result.ok) notify('Download', `Plot saved to ${result.path}`, 'success');\n else if (!result.cancelled) notify('Download', result.error || 'Failed to save image', 'error');\n } else {\n const link = document.createElement('a');\n link.href = dataUrl;\n link.download = filename;\n link.click();\n notify('Download', 'PNG download started', 'info');\n }\n } catch (err) {\n console.error('[openRawTracesWindow] PNG download failed:', err);\n notify('Download', 'Failed to generate PNG', 'error');\n }\n }\n\n async function downloadCSV() {\n if (!tableRows?.length) {\n notify('Download', 'No data available to download', 'warn');\n return;\n }\n const filename = `${(title || 'data').replace(/[^a-z0-9]/gi, '_')}_data.csv`;\n const csvEscape = (val) => {\n if (val == null) return '';\n const str = String(val);\n return (str.includes(',') || str.includes('\"') || str.includes('\\n'))\n ? `\"${str.replace(/\"/g, '\"\"')}\"` : str;\n };\n const lines = [(tableHeaders || []).join(',')];\n for (const row of tableRows) lines.push(row.map(csvEscape).join(','));\n const csv = lines.join('\\n');\n\n // null <=> no save dialog behind the capability (host.js) -> fall back.\n const dialogs = host?.dialogs;\n let result = null;\n if (dialogs) {\n try {\n result = await dialogs.saveFile({ data: csv, filename, kind: 'csv' });\n } catch (err) {\n console.error('[openRawTracesWindow] CSV download failed:', err);\n notify('Download', 'Failed to save file', 'error');\n return;\n }\n }\n if (result) {\n if (result.ok) notify('Download', `Saved ${tableRows.length} rows to ${result.path}`, 'success');\n else if (!result.cancelled) notify('Download', result.error || 'Failed to save file', 'error');\n } else {\n const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });\n const url = URL.createObjectURL(blob);\n const link = document.createElement('a');\n link.href = url;\n link.download = filename;\n link.click();\n URL.revokeObjectURL(url);\n notify('Download', 'Download started', 'info');\n }\n }\n\n return handle;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;AA4BA,IAAI,aAAa;AAGV,SAAS,gBAAgB,KAAK;AACjC,MAAI,OAAO,QAAQ,YAAY,IAAK,cAAa;AACrD;AAGA,IAAI,qBAAqB;AAGzB,IAAI,0BAA0B;AAC9B,SAAS,wBAAwB;AAC7B,MAAI,wBAAyB;AAC7B,4BAA0B;AAK1B,QAAM,aAAa,OAAO,yBAAyB,MAAM,WAAW,QAAQ;AAC5E,MAAI,cAAc,WAAW,OAAO,CAAC,WAAW,KAAK;AACjD,UAAM,aAAa,WAAW;AAC9B,WAAO,eAAe,MAAM,WAAW,UAAU;AAAA,MAC7C,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,MAAM;AACF,eAAO,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