import type { ChartAnimationPhase, DomainWithMetadata, PlacedLabel, PointLabelDatum } from 'ag-charts-core';
import { type Callback, type CallbackParam, ChartAxisDirection, CleanupRegistry, type DistantObject, EventEmitter, type InternalAgColorType, LRUCache, type Point, type RequireOptional, type SeriesPluginModuleInstance } from 'ag-charts-core';
import type { AgActiveItemState, AgChartLabelFormatterParams, AgColorType, AgDrawingMode, AgInitialStateLegendOptions, AgSeriesMarkerStyle, AgSeriesTooltipRendererParams, AgSeriesVisibilityChange, FormatterPropertyType, HighlightState as PublicHighlightState, SeriesType, TextOrSegments } from 'ag-charts-types';
import type { HighlightChangeEvent, HighlightNodeDatum, LegendItemClickEvent, LegendItemDoubleClickEvent } from '../../core/eventsHub';
import type { AxisFormattableLabel } from '../../module/axisContext';
import type { ModuleContext, SeriesContext } from '../../module/moduleContext';
import { ModuleMap } from '../../module/moduleMap';
import { BBox } from '../../scene/bbox';
import { Group, TranslatableGroup } from '../../scene/group';
import { type Node } from '../../scene/node';
import type { Path } from '../../scene/shape/path';
import type { TypedEvent, TypedEventListener } from '../../util/observable';
import { Observable } from '../../util/observable';
import type { ChartAxis } from '../chartAxis';
import type { ChartMode } from '../chartMode';
import type { DataController } from '../data/dataController';
import type { DataModel, ProcessedData } from '../data/dataModel';
import { DataSet } from '../data/dataSet';
import type { ChartLegendDatum, ChartLegendType } from '../legend/legendDatum';
import type { Marker } from '../marker/marker';
import type { TooltipContent, TooltipStructuredContent } from '../tooltip/tooltip';
import type { SeriesMarker } from './seriesMarker';
import { HighlightState, type SeriesProperties } from './seriesProperties';
import type { SeriesGrouping } from './seriesStateManager';
import type { SeriesTooltip } from './seriesTooltip';
import type { DatumIndexType, INodeEvent, ISeries, NodeDataDependencies, SeriesNodeDatum, SeriesNodeEventTypes } from './seriesTypes';
import { type ShapeFillBBox } from './shapeUtil';
export interface SeriesDataEvent {
    readonly dataModel: DataModel<any, any, any>;
    readonly processedData: ProcessedData<any>;
}
/** Modes of matching user interactions to rendered nodes (e.g. hover or click) */
export declare enum SeriesNodePickMode {
    /** Pick matches based upon pick coordinates being inside a matching shape/marker. */
    EXACT_SHAPE_MATCH = 0,
    /** Pick matches based upon distance to ideal position */
    NEAREST_NODE = 1,
    /** Pick matches based upon distance from axis */
    AXIS_ALIGNED = 2
}
export type SeriesNodePickIntent = 'tooltip' | 'highlight' | 'highlight-tooltip' | 'context-menu' | 'event';
export type SeriesNodePickMatch = {
    datum: SeriesNodeDatum<DatumIndexType>;
    distance: number;
};
export type PickFocusInputs = {
    readonly datumIndex: number;
    readonly datumIndexDelta: number;
    readonly otherIndex: number;
    readonly otherIndexDelta: number;
    readonly seriesRect?: BBox;
};
export type PickFocusOutputs = {
    datumIndex: number;
    datum: SeriesNodeDatum<DatumIndexType>;
    otherIndex?: number;
    bounds: BBox | Path;
    movedBounds?: BBox;
    clipFocusBox: boolean;
};
export type PickResult = {
    pickMode: SeriesNodePickMode;
    datums: SeriesNodeDatum<DatumIndexType>[];
    distance: number;
};
export type INodeEventConstructor<TDatum extends SeriesNodeDatum<DatumIndexType>, TSeries extends Series<any, TDatum, object, any>, TEvent extends string = SeriesNodeEventTypes> = new <T extends TEvent>(type: T, event: Event, { datum }: TDatum, series: TSeries) => INodeEvent<T>;
export declare class SeriesNodeEvent<TDatum extends SeriesNodeDatum<DatumIndexType>, TEvent extends string = SeriesNodeEventTypes> implements INodeEvent<TEvent> {
    readonly type: TEvent;
    readonly event: Event;
    readonly datum: unknown;
    readonly seriesId: string;
    defaultPrevented: boolean;
    constructor(type: TEvent, event: Event, nodeDatum: TDatum, series: ISeries<DatumIndexType, TDatum, unknown, unknown>);
    preventDefault(): void;
}
export type SeriesNodeDataContext<I extends DatumIndexType, S = SeriesNodeDatum<I>, L = S> = {
    itemId: string;
    nodeData: S[];
    labelData: L[];
};
export type SeriesNodeStyleContext<TStyle> = {
    [HighlightState.None]: TStyle;
    [HighlightState.Item]: TStyle;
    [HighlightState.Series]: TStyle;
    [HighlightState.OtherSeries]: TStyle;
    [HighlightState.OtherItem]: TStyle;
};
export type SeriesDirectionKeysMapping<P extends SeriesProperties<any>> = {
    [key in ChartAxisDirection | FormatterPropertyType]?: (keyof P & string)[];
};
export declare class SeriesGroupingChangedEvent implements TypedEvent {
    series: Series<DatumIndexType, any, object, any>;
    seriesGrouping: SeriesGrouping | undefined;
    type: string;
    constructor(series: Series<DatumIndexType, any, object, any>, seriesGrouping: SeriesGrouping | undefined);
}
export type SeriesConstructorOpts<TProps extends SeriesProperties<any>> = {
    moduleCtx: ModuleContext;
    pickModes: SeriesNodePickMode[];
    propertyKeys?: SeriesDirectionKeysMapping<TProps>;
    propertyNames?: SeriesDirectionKeysMapping<TProps>;
    canHaveAxes?: boolean;
    usesPlacedLabels?: boolean;
    alwaysClip?: boolean;
};
export type UnknownSeries = Series<DatumIndexType, SeriesNodeDatum<DatumIndexType>, object, SeriesProperties<object>>;
export declare abstract class Series<TDatumIndex extends DatumIndexType, TDatum extends SeriesNodeDatum<TDatumIndex>, TOpts extends object, TProps extends SeriesProperties<TOpts>, TLabel = TDatum, TContext extends SeriesNodeDataContext<TDatumIndex, TDatum, TLabel> = SeriesNodeDataContext<TDatumIndex, TDatum, TLabel>> extends Observable implements ISeries<TDatumIndex, TDatum, TProps, TLabel> {
    static readonly className: string;
    protected cleanup: CleanupRegistry;
    abstract readonly properties: TProps;
    pickModes: SeriesNodePickMode[];
    usesPlacedLabels: boolean;
    readonly alwaysClip: boolean;
    protected hasChangesOnHighlight: boolean;
    get pickModeAxis(): 'main' | 'main-category' | undefined;
    seriesGrouping: SeriesGrouping | undefined;
    protected readonly NodeEvent: INodeEventConstructor<TDatum, any>;
    readonly internalId: string;
    get id(): string;
    readonly canHaveAxes: boolean;
    get type(): SeriesType;
    readonly contentGroup: TranslatableGroup;
    readonly highlightGroup: TranslatableGroup;
    readonly highlightNodeGroup: Group<unknown>;
    readonly highlightLabelGroup: Group<unknown>;
    readonly annotationGroup: TranslatableGroup;
    readonly labelGroup: TranslatableGroup;
    chart?: {
        mode: ChartMode;
        isMiniChart: boolean;
        flashOnUpdateEnabled: boolean;
        seriesRect?: BBox;
    };
    axes: {
        [K in ChartAxisDirection]?: ChartAxis;
    };
    directions: ChartAxisDirection[];
    private readonly propertyKeys;
    private readonly propertyNames;
    protected nodeDataRefresh: boolean;
    protected processedDataUpdated: boolean;
    protected readonly moduleMap: ModuleMap<SeriesPluginModuleInstance>;
    protected _data?: DataSet<any>;
    protected _chartData?: DataSet<any>;
    private readonly datumCallbackCache;
    connectsToYAxis: boolean;
    get focusable(): boolean;
    get data(): DataSet<any> | undefined;
    set visible(newVisibility: boolean);
    get visible(): boolean;
    get hasData(): boolean;
    get tooltipEnabled(): boolean | undefined;
    protected onDataChange(): void;
    setOptionsData(input: DataSet | undefined): void;
    isHighlightEnabled(): boolean;
    setChartData(input: DataSet | undefined): void;
    private onSeriesGroupingChange;
    getBandScalePadding(): {
        inner: number;
        outer: number;
    };
    readonly ctx: ModuleContext;
    constructor(seriesOpts: SeriesConstructorOpts<TProps>);
    attachSeries(seriesContentNode: Group, seriesNode: Group, annotationNode: Group | undefined): void;
    detachSeries(_seriesContentNode: Group | undefined, _seriesNode: Group, _annotationNode: Group | undefined): void;
    declarationOrder: number;
    private _broughtToFront;
    setSeriesIndex(index: number, forceUpdate?: boolean): boolean;
    setZIndex(zIndex: number): void;
    renderToOffscreenCanvas(): boolean;
    protected hasHighlightOpacity(): boolean;
    protected getDrawingMode(isHighlight?: boolean, highlightDrawingMode?: AgDrawingMode): AgDrawingMode;
    protected getAnimationDrawingModes(): {
        start: {
            drawingMode: AgDrawingMode;
        };
        finish: {
            drawingMode: AgDrawingMode;
        };
    };
    readonly events: EventEmitter<{
        'data-update': SeriesDataEvent;
        'data-processed': SeriesDataEvent;
    }>;
    addEventListener(type: 'seriesVisibilityChange', listener: (e: AgSeriesVisibilityChange) => void): void;
    addEventListener(type: 'seriesNodeClick', listener: (e: SeriesNodeEvent<any>) => void): void;
    addEventListener(type: 'seriesNodeDoubleClick', listener: (e: SeriesNodeEvent<any>) => void): void;
    addEventListener(type: string, listener: TypedEventListener): void;
    removeEventListener(type: 'seriesVisibilityChange', listener: (e: AgSeriesVisibilityChange) => void): void;
    removeEventListener(type: 'seriesNodeClick', listener: (e: SeriesNodeEvent<any>) => void): void;
    removeEventListener(type: 'seriesNodeDoubleClick', listener: (e: SeriesNodeEvent<any>) => void): void;
    removeEventListener(type: string, listener: TypedEventListener): void;
    hasEventListener(type: 'seriesVisibilityChange'): boolean;
    hasEventListener(type: 'seriesNodeClick'): boolean;
    hasEventListener(type: 'seriesNodeDoubleClick'): boolean;
    hasEventListener(type: string): boolean;
    updatedDomains(): void;
    destroy(): void;
    abstract resetAnimation(chartAnimationPhase: ChartAnimationPhase): void;
    private getPropertyValues;
    getKeyAxis(_direction: ChartAxisDirection): string | undefined;
    getKeys(direction: ChartAxisDirection): string[];
    getKeyProperties(direction: ChartAxisDirection): (keyof TProps & string)[];
    getNames(direction: ChartAxisDirection): (string | undefined)[];
    getFormatterContext(property: FormatterPropertyType): Array<{
        seriesId: string;
        key: string;
        name: string | undefined;
    }>;
    resolveKeyDirection(direction: ChartAxisDirection): ChartAxisDirection;
    getDomain(direction: ChartAxisDirection): DomainWithMetadata<any>;
    getRange(direction: ChartAxisDirection, visibleRange: [number, number]): [number, number] | [];
    getMinimumRangeSeries(_range: number[]): void;
    getMinimumRangeChart(_ranges: number[]): number;
    getZoomRangeFittingItems(_xVisibleRange: [number, number], _yVisibleRange: [number, number] | undefined, _minVisibleItems: number): {
        x: [number, number];
        y: [number, number] | undefined;
    } | undefined;
    getVisibleItems(_xVisibleRange: [number, number], _yVisibleRange: [number, number] | undefined, _minVisibleItems: number): number;
    abstract dataCount(): number;
    abstract getSeriesDomain(direction: ChartAxisDirection): DomainWithMetadata<any>;
    abstract getSeriesRange(direction: ChartAxisDirection, visibleRange: [number, number]): [number, number] | [];
    abstract processData(dataController: DataController): Promise<void> | void;
    abstract createNodeData(): TContext | undefined;
    abstract findNodeDatum(itemIdOrIndex: AgActiveItemState['itemId']): SeriesNodeDatum<DatumIndexType> | undefined;
    toCanvasFromMidPoint(nodeDatum: {
        midPoint?: Point;
    }): Point;
    markNodeDataDirty(): void;
    private visibleMaybeChanged;
    abstract update(opts: {
        seriesRect?: BBox;
    }): Promise<void> | void;
    getOpacity(): number;
    getHighlightState(highlightedDatum: HighlightNodeDatum | undefined, isHighlight?: boolean, datumIndex?: TDatumIndex, legendItemValues?: string[]): HighlightState;
    getHighlightStateString(datum: HighlightNodeDatum | undefined, isHighlight?: boolean, datumIndex?: TDatumIndex, legendItemValues?: string[]): PublicHighlightState;
    protected onChangeHighlight(event: HighlightChangeEvent): void;
    bringToFront(): boolean;
    isSeriesHighlighted(highlightedDatum: HighlightNodeDatum | undefined, _legendItemValues?: string[]): boolean;
    protected isItemHighlighted(highlightedDatum?: HighlightNodeDatum, datumIndex?: TDatumIndex): boolean | undefined;
    getHighlightStyle(isHighlight?: boolean, datumIndex?: TDatumIndex, highlightState?: HighlightState, legendItemValues?: string[]): Partial<TOpts & {
        fill: AgColorType;
        fillOpacity: number;
        stroke: string;
        strokeWidth: number;
        strokeOpacity: number;
        lineDash: number[];
        lineDashOffset: number;
        opacity: number;
    }>;
    protected resolveMarkerDrawingModeForState(drawingMode: AgDrawingMode, style?: AgSeriesMarkerStyle): AgDrawingMode;
    protected abstract hasItemStylers(): boolean;
    filterItemStylerFillParams(fill: AgColorType | undefined): InternalAgColorType | undefined;
    protected getModuleTooltipParams(): object;
    abstract getTooltipContent(datumIndex: TDatumIndex, removeThisDatum: TDatum | undefined): TooltipContent | undefined;
    protected _pickNodeCache: LRUCache<PickResult | undefined, string>;
    pickNodes(point: Point, intent: SeriesNodePickIntent, exactMatchOnly?: boolean): PickResult | undefined;
    protected pickNodesExactShape(point: Point): SeriesNodeDatum<DatumIndexType>[];
    protected pickNodeClosestDatum(_point: Point): SeriesNodePickMatch | undefined;
    pickNodeNearestDistantObject<T extends Node & DistantObject>(point: Point, items: Iterable<T>): SeriesNodePickMatch | undefined;
    protected pickNodeMainAxisFirst(_point: Point, _requireCategoryAxis: boolean): SeriesNodePickMatch | undefined;
    isPointInArea?(x: number, y: number): boolean;
    getLabelData(): (TLabel & PointLabelDatum)[];
    updatePlacedLabelData(_labels: PlacedLabel<TLabel>[]): void;
    private readonly fireEventWrapper;
    protected fireEvent<TEvent extends TypedEvent>(event: TEvent): void;
    fireNodeClickEvent(event: Event, datum: TDatum): boolean;
    fireNodeDoubleClickEvent(event: Event, datum: TDatum): boolean;
    createNodeContextMenuActionEvent(event: Event, datum: TDatum): INodeEvent<'nodeContextMenuAction'>;
    onLegendInitialState(legendType: ChartLegendType, initialState: AgInitialStateLegendOptions | undefined): void;
    onLegendItemClick(event: LegendItemClickEvent): void;
    onLegendItemDoubleClick(event: LegendItemDoubleClickEvent): void;
    abstract getLegendData<T extends ChartLegendType>(legendType: T): ChartLegendDatum<T>[];
    abstract getLegendData(legendType: ChartLegendType): ChartLegendDatum<ChartLegendType>[];
    protected toggleSeriesItem(enabled: boolean, legendType: ChartLegendType, itemId: string | number | undefined, legendItemName: string | undefined, legendEvent?: {
        legendItemName?: string;
    }): void;
    isEnabled(): boolean;
    getModuleMap(): ModuleMap<SeriesPluginModuleInstance>;
    createModuleContext(): SeriesContext;
    protected getAxisValueText(axis: ChartAxis, source: 'tooltip', value: any, datum: any, key: string, legendItemName: string | undefined, allowNull?: boolean): string;
    protected getLabelText<TParams extends object>(value: any, datum: any, key: string, property: FormatterPropertyType, domain: any[], label: AxisFormattableLabel<AgChartLabelFormatterParams<any> & RequireOptional<TParams>>, baseParams: RequireOptional<TParams> & Omit<AgChartLabelFormatterParams<any>, 'seriesId'>, allowNullValue?: boolean): TextOrSegments;
    getMarkerStyle<TParams>(marker: SeriesMarker<TParams>, { datumIndex, datum, point }: Partial<TDatum>, params?: TParams, opts?: {
        highlightState?: HighlightState;
        isHighlight?: boolean;
        checkForHighlight?: boolean;
        resolveMarkerSubPath?: string[];
        resolveStyler?: boolean;
    }, defaultOverrideStyle?: AgSeriesMarkerStyle & {
        size: number;
    }, inheritedStyle?: AgSeriesMarkerStyle): AgSeriesMarkerStyle & {
        size: number;
    };
    protected applyMarkerStyle(style: AgSeriesMarkerStyle, markerNode: Marker, point: {
        x: number;
        y: number;
        size?: number;
        focusSize?: number;
    } | undefined, fillBBox?: ShapeFillBBox, { applyTranslation, selected }?: {
        applyTranslation?: boolean | undefined;
        selected?: boolean | undefined;
    }): void;
    protected _nodeDataDependencies?: NodeDataDependencies;
    get nodeDataDependencies(): NodeDataDependencies;
    protected checkResize(newSeriesRect?: BBox): boolean;
    pickFocus(_opts: PickFocusInputs): PickFocusOutputs | undefined;
    resetDatumCallbackCache(): void;
    cachedDatumCallback<T>(id: any, fn: () => T): T | undefined;
    cachedCallWithContext<F extends Callback>(fn: F, params: CallbackParam<F>): ReturnType<F> | undefined;
    callWithContext<F extends Callback>(fn: F, params: CallbackParam<F>): ReturnType<F>;
    protected formatTooltipWithContext<P extends AgSeriesTooltipRendererParams<any>, Tooltip extends SeriesTooltip<P>>(tooltip: Tooltip, content: TooltipStructuredContent, params: RequireOptional<P>): TooltipContent;
    abstract getCategoryValue(datumIndex: TDatumIndex): any;
    abstract datumIndexForCategoryValue(categoryValue: any): TDatumIndex | undefined;
    minTimeInterval(): number | undefined;
    needsDataModelDiff(): boolean;
}
