import { InjectionToken } from '@angular/core'; import { PlotlyFigure } from '../../features/indicadores/indicadores.models'; // Narrow boundary for the official partial bundle, which ships without declarations. export interface PlotlyRuntime { react(host: HTMLElement, data: PlotlyFigure['data'], layout: PlotlyFigure['layout'], config: Record): Promise; purge(host: HTMLElement): void; Plots: { resize(host: HTMLElement): Promise }; addFrames(host: HTMLElement, frames: Record[]): Promise; deleteFrames(host: HTMLElement, indices: number[]): Promise; } let runtime: Promise | undefined; export function loadPlotly(): Promise { return runtime ??= import('plotly.js-cartesian-dist-min') .then(module => (module.default ?? module) as unknown as PlotlyRuntime) .catch(error => { runtime = undefined; throw error; }); } export const PLOTLY_LOADER = new InjectionToken<() => Promise>('PLOTLY_LOADER', { providedIn: 'root', factory: () => loadPlotly });