{"version":3,"file":"compat.cjs","names":["LineChart","BarChart","PieChart","normalizeData","axisUnits","StepAxis","AutoScaleAxis","isNumeric","serialMap","safeHasProperty","getHighLow","Svg","findAll","normalizeData","LineChart","BarChart","PieChart","core","compat"],"sources":["../src/chart/types.ts","../src/core/data/range.ts","../src/compat/index.ts","../src/compat/global.ts","../src/compat/entry.ts"],"sourcesContent":["import type { PipelineOptions } from '../pipeline/phases';\nimport type {\n  AllPhasesListener,\n  PhaseListener,\n  PhaseListeners,\n  PhaseName\n} from '../pipeline/types';\nimport type { Keyframes, Renderer } from '../render/types';\nimport type { SceneNode } from '../scene/node';\nimport type { ResponsiveSet } from '../responsive/responsive';\n\n/**\n * The custom events a chart can emit, by name, with their payloads. The\n * core emits only `responsive`. A plugin that emits events of its own\n * declares them here (TypeScript merges your declaration into Chartist's),\n * so `on()`, `off()` and `emit()` check the names and payloads:\n *\n * ```ts\n * declare module 'chartist' {\n *   interface ChartEvents {\n *     'legend:click': { readonly seriesIndex: number };\n *   }\n * }\n * ```\n *\n * `chartist/compat` declares the 1.x events (`draw`, `created`, …).\n */\nexport interface ChartEvents {\n  /**\n   * Responsive entries changed which overrides apply: the config before\n   * and after (`chart()`), or the options before and after (presets).\n   */\n  responsive:\n    | {\n        readonly previousConfig: ChartConfig;\n        readonly currentConfig: ChartConfig;\n      }\n    | { readonly previousOptions: unknown; readonly currentOptions: unknown };\n}\n\n/**\n * The name of a custom event: a key of {@link ChartEvents}. Plugins list\n * the names they emit in `provides`.\n */\nexport type CustomEventName = keyof ChartEvents & string;\n\n/**\n * A plugin: a name and an `install` function that registers listeners on\n * the chart. Plugins go into `plugins`, in the config of {@link chart} or\n * the options of the presets. They install in order, so with two\n * listeners on the same event, the earlier plugin's runs first.\n *\n * For options, write a function that takes them and returns the plugin, or\n * read them from the second argument of `install` and pass the plugin\n * with {@link withOptions}.\n *\n * @example\n * ```ts\n * import { barChart, type ChartPlugin } from 'chartist';\n *\n * // Bars at or above the limit get the class ct-over.\n * const threshold = (limit: number): ChartPlugin => ({\n *   name: 'threshold',\n *   install(chart) {\n *     chart.on('compose', current => {\n *       if (current.role !== 'bar') {\n *         return;\n *       }\n *       const { value } = current.ctx;\n *       const y =\n *         typeof value === 'number'\n *           ? value\n *           : value && 'y' in value\n *             ? value.y\n *             : undefined;\n *       return y !== undefined && y >= limit\n *         ? current.addClass('ct-over')\n *         : undefined;\n *     });\n *   }\n * });\n *\n * barChart('#chart', { series: [[5, 4, 3, 7]] }, { plugins: [threshold(5)] });\n * ```\n */\nexport interface ChartPlugin<TOptions = unknown> {\n  /** Names the plugin. Prefix your custom events with it to keep them apart. */\n  readonly name: string;\n  /**\n   * The custom events this plugin emits with `chart.emit()`, each declared\n   * in {@link ChartEvents}. They're known before any plugin installs, so\n   * another plugin may listen to them.\n   */\n  readonly provides?: readonly CustomEventName[];\n  /**\n   * Sets the plugin up: runs once, before the first render, with the\n   * chart's handle. Listeners registered here stay for every later render,\n   * after updates and resizes too, and `off(name)` without a listener\n   * leaves them alone: remove one with its reference.\n   *\n   * Return a function to undo what `install` set up outside the chart,\n   * such as a listener on the document: `destroy()` calls it once, after\n   * the chart's output is removed. `detach()` doesn't.\n   * @param chart The chart's handle, to listen to events and emit them.\n   * @param options The options of a `[plugin, options]` entry, if any.\n   * @returns A cleanup function for `destroy()`, or anything else, which is\n   *   ignored (so `install: chart => chart.on(…)` stays valid).\n   */\n  install(chart: ChartHandle, options?: TOptions): unknown;\n  /**\n   * Gives the keyframes of a node's update animation, for nodes that don't\n   * move well number by number, such as a path the plugin draws. A\n   * renderer that animates updates (`smilAnimations()` from\n   * `chartist/live`) asks it once per update, never per frame, with the\n   * progress points of the chart's easing: 0 is the previous node, 1 the\n   * new one, and points beyond them come from an easing that overshoots.\n   * Plugins are asked in their order, before the layer that drew the node;\n   * the first one that returns keyframes wins.\n   *\n   * @example\n   * ```ts\n   * import type { ChartPlugin } from 'chartist';\n   *\n   * // Turns the gauge needle the plugin draws (its angle in `ct:angle`),\n   * // instead of morphing its path.\n   * const needle: ChartPlugin = {\n   *   name: 'needle',\n   *   install() {},\n   *   keyframes(previous, next, progress) {\n   *     if (!next.classes.includes('needle')) {\n   *       return undefined;\n   *     }\n   *     const from = Number(previous.attrs['ct:angle']);\n   *     const to = Number(next.attrs['ct:angle']);\n   *     return progress.map(p => ({\n   *       transform: `rotate(${from + (to - from) * p} 100 100)`\n   *     }));\n   *   }\n   * };\n   * ```\n   * @param previous The node in the previous scene\n   * @param next The node in the new scene\n   * @param progress The progress points to give attributes for\n   * @returns One set of attributes per progress point, or nothing.\n   */\n  keyframes?(\n    previous: SceneNode,\n    next: SceneNode,\n    progress: readonly number[]\n  ): Keyframes | undefined;\n}\n\n/**\n * A plugin paired with its options, as {@link withOptions} creates it.\n * `install` receives the options as its second argument.\n */\nexport type PluginWithOptions<TOptions = unknown> = readonly [\n  ChartPlugin<TOptions>,\n  TOptions\n];\n\n/**\n * An entry of a chart's `plugins`: a plugin, or a plugin with its options.\n * Prefer {@link withOptions} (it checks the options) or a function that\n * returns a plugin over a bare `[plugin, options]` pair. A 1.x plugin (a\n * plain function) throws; convert it with `fromLegacyPlugin()` from\n * `chartist/compat`.\n */\nexport type PluginEntry =\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  ChartPlugin<any> | PluginWithOptions<any>;\n\n/**\n * The config of {@link chart}: the data, the layers that draw it and the\n * axes they draw on, plus size, padding, plugins and listeners.\n *\n * Without `axes`, layers draw into the whole chart area; the pie layer\n * needs `coordinates: 'polar'`. {@link toScene} takes the same config.\n */\nexport interface ChartConfig extends PipelineOptions {\n  /**\n   * Plugins to install before the first render, in order: plugins, or\n   * plugins with their options from {@link withOptions}.\n   */\n  readonly plugins?: readonly PluginEntry[];\n  /**\n   * Phase listeners by phase name (or `'*'` for all phases). They're\n   * registered before the first render, so they see it too.\n   */\n  readonly on?: PhaseListeners;\n  /** Turns the scene into output; the DOM renderer by default. */\n  readonly renderer?: Renderer;\n  /**\n   * Overrides that apply while their condition matches, created with\n   * `responsive([...])`: entries of a media query string or a\n   * `container()` condition, and a partial config. The chart renders again\n   * when the matching entries change.\n   */\n  readonly responsive?: ResponsiveSet<ChartOverrides>;\n}\n\n/**\n * The part of a {@link ChartConfig} that responsive entries can override:\n * everything but `responsive`, `plugins`, `on` and `renderer`. The\n * matching entries merge over the config in order, shallowly.\n */\nexport type ChartOverrides = Partial<\n  Omit<ChartConfig, 'responsive' | 'plugins' | 'on' | 'renderer'>\n>;\n\n/**\n * The handle {@link chart} returns: update or remove the chart, and listen\n * to its events. Plugins get the same handle in `install`. The methods\n * other than `destroy` and `emit` return the handle, so calls chain.\n */\nexport interface ChartHandle {\n  /** The element the chart renders into (undefined in `toScene`). */\n  readonly container?: Element;\n  /**\n   * Shallow-merges the changes into the config and renders again. Plugins\n   * and listeners stay; `plugins` and `on` can't change.\n   */\n  update(config: Partial<Omit<ChartConfig, 'plugins' | 'on'>>): this;\n  /**\n   * Stops reacting to container size changes (and media queries in\n   * presets). The output and the listeners stay.\n   */\n  detach(): this;\n  /** Detaches, removes the output and clears all listeners. */\n  destroy(): void;\n  /**\n   * Emits a custom event (declared in {@link ChartEvents}), e.g. from a\n   * plugin. Phase names are reserved: emitting one throws.\n   */\n  emit<K extends CustomEventName>(name: K, payload: ChartEvents[K]): void;\n  /**\n   * Listens to a phase event, which fires on every render. Listeners of\n   * `resolve` to `scene` may return a new payload to change what's drawn;\n   * `compose` listeners may return `null` to drop a node.\n   */\n  on<K extends PhaseName>(name: K, listener: PhaseListener<K>): this;\n  /** Listens to every phase event, with the phase name and its payload. */\n  on(name: '*', listener: AllPhasesListener): this;\n  /** Listens to a custom event, declared in {@link ChartEvents}. */\n  on<K extends CustomEventName>(\n    name: K,\n    listener: (payload: ChartEvents[K]) => void\n  ): this;\n  /**\n   * Removes a phase listener, whoever added it. Without a listener,\n   * removes the listeners of the phase added through `on` and the\n   * config's `on`; plugins keep theirs.\n   */\n  off<K extends PhaseName>(name: K, listener?: PhaseListener<K>): this;\n  /**\n   * Removes a listener of all phases, or without a listener, those added\n   * through `on`.\n   */\n  off(name: '*', listener?: AllPhasesListener): this;\n  /**\n   * Removes a custom event listener, or without a listener, the event's\n   * listeners added through `on`.\n   */\n  off<K extends CustomEventName>(\n    name: K,\n    listener?: (payload: ChartEvents[K]) => void\n  ): this;\n}\n\n/**\n * Pairs a plugin with its options for a chart's `plugins`, and checks the\n * options against the plugin's options type. `install` receives them as\n * its second argument.\n *\n * @example\n * ```ts\n * import { lineChart, withOptions, type ChartPlugin } from 'chartist';\n *\n * const lastPoint: ChartPlugin<{ className: string }> = {\n *   name: 'last-point',\n *   install(chart, options) {\n *     chart.on('compose', current => {\n *       if (current.role !== 'series') {\n *         return;\n *       }\n *       const last = current.children.at(-1);\n *       return last && options\n *         ? current.replace(last, last.addClass(options.className))\n *         : undefined;\n *     });\n *   }\n * };\n *\n * lineChart(\n *   '#chart',\n *   { series: [[1, 3, 2, 5]] },\n *   { plugins: [withOptions(lastPoint, { className: 'ct-last' })] }\n * );\n * ```\n */\nexport function withOptions<TOptions>(\n  plugin: ChartPlugin<TOptions>,\n  options: TOptions\n): PluginWithOptions<TOptions> {\n  return [plugin, options];\n}\n\n/**\n * The handle without event typing, for code that routes event names it\n * doesn't know (the 1.x chart classes, compat). Internal.\n */\nexport interface UntypedEvents {\n  on(name: string, listener: (payload: unknown) => void): unknown;\n  off(name: string, listener?: (payload: unknown) => void): unknown;\n  emit(name: string, payload?: unknown): void;\n}\n\n/** The same handle, seen without event typing. Internal. */\nexport const untyped = (handle: ChartHandle): UntypedEvents =>\n  handle as unknown as UntypedEvents;\n","/**\n * Repairs a value range that's empty because high is at or below low, from\n * flat data or a misconfigured `high`/`low`: sets the bound on the other\n * side of zero to 0, or gives `0` to `1` when there are no values. Chart\n * code that overrides a bound after `getHighLow` calls it again.\n *\n * @param highLow The range to check.\n * @returns The range, or the repaired one.\n */\nexport function nonEmptyRange(highLow: {\n  readonly high: number;\n  readonly low: number;\n}): { high: number; low: number } {\n  const { high, low } = highLow;\n  if (high > low) {\n    return { high, low };\n  }\n  if (low === 0) {\n    // Both are 0.\n    return { high: 1, low };\n  }\n  if (low < 0) {\n    // The same negative value for both.\n    return { high: 0, low };\n  }\n  if (high > 0) {\n    // The same positive value for both.\n    return { high, low: 0 };\n  }\n  // No values: high and low are still -Number.MAX_VALUE and Number.MAX_VALUE.\n  return { high: 1, low: 0 };\n}\n","/**\n * The compat plugin: 1.x events, `Svg` wrappers and 1.x plugins on v2\n * charts. Opt-in: `plugins: [compat]`, or convert a 1.x plugin with\n * `fromLegacyPlugin()`.\n *\n * Imports only from the package root, so the built `chartist/compat` entry\n * shares the core with `chartist` instead of bundling a copy.\n */\nimport {\n  AutoScaleAxis,\n  BarChart,\n  LineChart,\n  PieChart,\n  Svg,\n  StepAxis,\n  axisUnits,\n  findAll,\n  getHighLow,\n  isNumeric,\n  normalizeData,\n  safeHasProperty,\n  serialMap,\n  type ChartHandle,\n  type ChartPlugin,\n  type ChartRect,\n  type Data,\n  type Layout,\n  type PresetState,\n  type NormalizedSeries,\n  type AxisLabelContext,\n  type PieLabelContext,\n  type RoleNode,\n  type SceneNode\n} from '../index';\nimport { untyped } from '../chart/types';\nimport { nonEmptyRange } from '../core/data/range';\nimport type {\n  AnimationEvent,\n  AreaDrawEvent,\n  AxesDrawEvent,\n  BarChartCreatedEvent,\n  BarDrawEvent,\n  DataEvent,\n  LineChartCreatedEvent,\n  LineDrawEvent,\n  OptionsChangedEvent,\n  PieChartCreatedEvent,\n  PointDrawEvent,\n  SliceDrawEvent,\n  SliceLabelDrawEvent\n} from '../index';\n\n// With chartist/compat, the 1.x events are typed on every chart handle.\ndeclare module '../chart/types' {\n  interface ChartEvents {\n    /**\n     * 1.x: the chart's data, before the first render (`type: 'initial'`)\n     * and after an update with new data (`type: 'update'`). Listeners can\n     * change it in place. Needs the {@link compat} plugin.\n     */\n    data: DataEvent;\n    /**\n     * 1.x: the responsive options changed, with the options before and\n     * after. Needs the {@link compat} plugin.\n     */\n    optionsChanged: OptionsChangedEvent;\n    /**\n     * 1.x: an element was drawn: a grid line, label, point, line, area,\n     * bar or slice, with its live `element`. Check `type` to narrow it.\n     * Needs the {@link compat} plugin.\n     */\n    draw:\n      | PointDrawEvent\n      | LineDrawEvent\n      | AreaDrawEvent\n      | BarDrawEvent\n      | SliceDrawEvent\n      | SliceLabelDrawEvent\n      | AxesDrawEvent;\n    /**\n     * 1.x: the chart is drawn and in the DOM, after its `draw` events,\n     * with the `svg`, the chart area and the axes. Needs the {@link compat}\n     * plugin.\n     */\n    created:\n      | LineChartCreatedEvent\n      | BarChartCreatedEvent\n      | PieChartCreatedEvent;\n    /**\n     * 1.x: an SMIL animation began, started with `animate()` on an element\n     * of the chart, such as the `element` of a `draw` event. Needs the\n     * {@link compat} plugin.\n     */\n    animationBegin: AnimationEvent;\n    /**\n     * 1.x: an SMIL animation ended, started with `animate()` on an element\n     * of the chart. Needs the {@link compat} plugin.\n     */\n    animationEnd: AnimationEvent;\n  }\n}\n\n/** The 1.x events the compat plugin emits. */\nconst LEGACY_EVENTS = [\n  'data',\n  'optionsChanged',\n  'draw',\n  'created',\n  'animationBegin',\n  'animationEnd'\n] as const;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype LegacyPlugin = (chart: any, options?: any) => void;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyOptions = any;\n\ninterface CompatState {\n  preset?: PresetState<Data, AnyOptions>;\n  /** The data object of the last `data` event, and its mutable copy. */\n  source?: unknown;\n  copy?: Data;\n  layout?: Layout;\n  svg?: Svg;\n  /** 1.x chart instances whose `svg` field follows the chart's. */\n  instances: { svg?: Svg }[];\n}\n\nconst states = new WeakMap<ChartHandle, CompatState>();\n\n/**\n * Where `Svg#animate()` looks for the emitter of an element's animations\n * when it gets none (on the element or an ancestor). The core reads the\n * same global symbol.\n */\nconst ANIMATION_EMITTER = Symbol.for('chartist.animationEmitter');\n\n/**\n * Where a preset's chart handle holds its preset state from the moment\n * plugins install. The core sets the same global symbol.\n */\nconst PRESET_STATE = Symbol.for('chartist.presetState');\n\n/**\n * Set on the chart handle, so the chart never hands its renderer the\n * previous render: 1.x draw listeners and plugins expect new elements on\n * every render. The core reads the same global symbol.\n */\nconst REPLACES_OUTPUT = Symbol.for('chartist.replacesOutput');\n\nconst presetOf = (handle: ChartHandle) =>\n  (handle as { [PRESET_STATE]?: PresetState<Data, AnyOptions> })[PRESET_STATE];\n\n/** The 1.x class of each preset, for 0.x and 1.x type checks in plugins. */\nconst CLASSES: Record<string, { prototype: object }> = {\n  line: LineChart,\n  bar: BarChart,\n  pie: PieChart\n};\n\n/** Copies plain arrays and objects; other values are kept by reference. */\nfunction mutableCopy<T>(value: T): T {\n  if (Array.isArray(value)) {\n    return value.map(mutableCopy) as T;\n  }\n  if (value && typeof value === 'object') {\n    const proto = Object.getPrototypeOf(value);\n    if (proto === Object.prototype || proto === null) {\n      return Object.fromEntries(\n        Object.entries(value).map(([key, entry]) => [key, mutableCopy(entry)])\n      ) as T;\n    }\n  }\n  return value;\n}\n\nconst isLegacyAxisClass = (\n  type: unknown\n): type is new (...args: unknown[]) => unknown =>\n  typeof type === 'function' &&\n  typeof (type as { prototype?: { projectValue?: unknown } }).prototype\n    ?.projectValue === 'function';\n\nfunction chartRectOf(layout: Layout): ChartRect {\n  const { area, padding } = layout;\n  return {\n    x1: area.x1,\n    x2: area.x2,\n    y1: area.y1,\n    y2: area.y2,\n    padding,\n    width() {\n      return this.x2 - this.x1;\n    },\n    height() {\n      return this.y1 - this.y2;\n    }\n  };\n}\n\n/** The 1.x axes, constructed as 1.x `LineChart.createChart` does. */\nfunction lineAxes(options: AnyOptions, data: Data, chartRect: ChartRect) {\n  const normalized = normalizeData(\n    data as Data<NormalizedSeries[]>,\n    options.reverseData,\n    true\n  );\n  const series = normalized.series as NormalizedSeries[];\n  const axisX = isLegacyAxisClass(options.axisX.type)\n    ? new options.axisX.type(axisUnits.x, series, chartRect, options.axisX)\n    : new StepAxis(axisUnits.x, series, chartRect, {\n        ...options.axisX,\n        ticks: normalized.labels,\n        stretch: options.fullWidth\n      });\n  const axisY = isLegacyAxisClass(options.axisY.type)\n    ? new options.axisY.type(axisUnits.y, series, chartRect, options.axisY)\n    : new AutoScaleAxis(axisUnits.y, series, chartRect, {\n        ...options.axisY,\n        high: isNumeric(options.high) ? options.high : options.axisY.high,\n        low: isNumeric(options.low) ? options.low : options.axisY.low\n      });\n  return { axisX, axisY };\n}\n\n/** Sums per index across series, as 1.x `BarChart` stacks them. */\nfunction serialSums(series: NormalizedSeries[]) {\n  return serialMap(series, (...values) =>\n    values.reduce<{ x: number; y: number }>(\n      (sum, value) => ({\n        x: sum.x + (safeHasProperty(value, 'x') ? (value.x as number) : 0),\n        y: sum.y + (safeHasProperty(value, 'y') ? (value.y as number) : 0)\n      }),\n      { x: 0, y: 0 }\n    )\n  );\n}\n\n/** The 1.x axes, constructed as 1.x `BarChart.createChart` does. */\nfunction barAxes(options: AnyOptions, data: Data, chartRect: ChartRect) {\n  const horizontal = Boolean(options.horizontalBars);\n  const valueDimension = horizontal ? 'x' : 'y';\n  const labelDimension = horizontal ? 'y' : 'x';\n  const normalized = normalizeData(\n    data as Data<NormalizedSeries[]>,\n    options.reverseData,\n    valueDimension,\n    true\n  );\n  const series = normalized.series as NormalizedSeries[];\n  const found =\n    options.stackBars && options.stackMode !== true && series.length\n      ? getHighLow([serialSums(series)], options, valueDimension)\n      : getHighLow(series, options, valueDimension);\n  // The chart-level bounds win, but can empty the range again (#1057).\n  const highLow = nonEmptyRange({\n    high: typeof options.high === 'number' ? options.high : found.high,\n    low: typeof options.low === 'number' ? options.low : found.low\n  });\n  const valueOptions = horizontal ? options.axisX : options.axisY;\n  const labelOptions = horizontal ? options.axisY : options.axisX;\n  const ValueAxis = isLegacyAxisClass(valueOptions.type)\n    ? valueOptions.type\n    : AutoScaleAxis;\n  const valueAxis = new ValueAxis(\n    axisUnits[valueDimension],\n    series,\n    chartRect,\n    {\n      ...valueOptions,\n      highLow,\n      referenceValue: 0\n    }\n  );\n  const labelAxis = isLegacyAxisClass(labelOptions.type)\n    ? new labelOptions.type(\n        axisUnits[labelDimension],\n        series,\n        chartRect,\n        labelOptions\n      )\n    : new StepAxis(axisUnits[labelDimension], series, chartRect, {\n        ticks:\n          options.distributeSeries && options.stackBars\n            ? normalized.labels.slice(0, 1)\n            : normalized.labels\n      });\n  return horizontal\n    ? { axisX: valueAxis, axisY: labelAxis }\n    : { axisX: labelAxis, axisY: valueAxis };\n}\n\nconst AXES: Record<\n  string,\n  (\n    options: AnyOptions,\n    data: Data,\n    chartRect: ChartRect\n  ) => { axisX: unknown; axisY: unknown }\n> = {\n  line: lineAxes,\n  bar: barAxes,\n  // Pie charts have no axes.\n  pie: () => ({ axisX: undefined, axisY: undefined })\n};\n\n/** 1.x `draw` payloads in 1.x order, then `created`. */\nfunction emitDrawEvents(\n  handle: ChartHandle,\n  state: CompatState,\n  scene: SceneNode,\n  svgElement: Element,\n  elementOf: (node: SceneNode) => Element | undefined\n) {\n  const options = state.preset?.options as AnyOptions;\n  const data = (state.copy ?? state.preset?.data) as Data;\n  const chartRect = chartRectOf(state.layout!);\n  const { axisX, axisY } = AXES[state.preset!.kind](options, data, chartRect);\n  const axisOf = (dimension?: string) => (dimension === 'x' ? axisX : axisY);\n  const wrap = (element: Element) => new Svg(element);\n  const draw = (payload: Record<string, unknown>) =>\n    untyped(handle).emit('draw', payload);\n  const parts = (node: SceneNode) => {\n    const element = elementOf(node)!;\n    return { element: wrap(element), group: wrap(element.parentElement!) };\n  };\n\n  // Axes: per tick its grid line, then its label, in the order the axes\n  // appear in the chart (X first for lines, the label axis first for bars).\n  const grids = findAll(scene, { role: 'grid' });\n  // Only axis labels; pie labels belong to their slice.\n  const allLabels = findAll(scene, { role: 'label' });\n  const labels = allLabels.filter(\n    (n): n is RoleNode<'label'> & { ctx: AxisLabelContext } =>\n      n.ctx.kind === 'axis'\n  );\n  const sliceLabels = allLabels.filter(\n    (n): n is RoleNode<'label'> & { ctx: PieLabelContext } =>\n      n.ctx.kind === 'pie'\n  );\n  const order = [\n    ...new Set([...grids, ...labels].map(n => n.ctx.axis.dimension))\n  ];\n  for (const dimension of order) {\n    const onAxis = (node: { ctx: { axis: { dimension: string } } }) =>\n      node.ctx.axis.dimension === dimension;\n    const indexes = [\n      ...new Set([...grids, ...labels].filter(onAxis).map(n => n.ctx.index))\n    ].sort((a, b) => a - b);\n    for (const index of indexes) {\n      const grid = grids.find(n => onAxis(n) && n.ctx.index === index);\n      if (grid) {\n        const { x1, y1, x2, y2 } = grid.attrs;\n        draw({\n          type: 'grid',\n          axis: axisOf(dimension),\n          index,\n          ...parts(grid),\n          x1,\n          y1,\n          x2,\n          y2\n        });\n      }\n      const label = labels.find(n => onAxis(n) && n.ctx.index === index);\n      if (label) {\n        const { x, y, width, height } = label.attrs;\n        draw({\n          type: 'label',\n          axis: axisOf(dimension),\n          index,\n          ...parts(label),\n          text: label.ctx.text,\n          x,\n          y,\n          width,\n          height\n        });\n      }\n    }\n  }\n  for (const background of findAll(scene, { role: 'gridBackground' })) {\n    draw({ type: 'gridBackground', ...parts(background) });\n  }\n\n  // Series: points, then the line, then the areas in creation order.\n  const rawSeries = (data.series ?? []) as unknown[];\n  for (const series of findAll(scene, { role: 'series' })) {\n    const seriesIndex = series.ctx.seriesIndex;\n    const original =\n      rawSeries[\n        options.reverseData ? rawSeries.length - 1 - seriesIndex : seriesIndex\n      ];\n    const common = { series: original, seriesIndex, axisX, axisY };\n    const children = series.children;\n    const slice = children.find(n => n.role === 'slice');\n    if (slice) {\n      const ctx = slice.ctx;\n      draw({\n        type: 'slice',\n        value: ctx.value,\n        totalDataSum: ctx.totalDataSum,\n        index: ctx.index,\n        meta: ctx.meta,\n        series: ctx.series,\n        ...parts(slice),\n        path: ctx.path.clone(),\n        center: ctx.center,\n        radius: ctx.radius,\n        startAngle: ctx.startAngle,\n        endAngle: ctx.endAngle,\n        chartRect\n      });\n      const label = sliceLabels.find(n => n.ctx.index === ctx.index);\n      if (label) {\n        const labelCtx = label.ctx;\n        draw({\n          type: 'label',\n          index: labelCtx.index,\n          ...parts(label),\n          text: labelCtx.text,\n          chartRect,\n          series: labelCtx.series,\n          meta: labelCtx.meta,\n          x: labelCtx.x,\n          y: labelCtx.y\n        });\n      }\n      continue;\n    }\n    for (const barNode of children.filter(n => n.role === 'bar')) {\n      const ctx = barNode.ctx!;\n      draw({\n        type: 'bar',\n        value: ctx.value,\n        index: ctx.valueIndex,\n        meta: ctx.meta,\n        series: ctx.series,\n        seriesIndex,\n        axisX,\n        axisY,\n        chartRect,\n        ...parts(barNode),\n        x1: ctx.x1,\n        y1: ctx.y1,\n        x2: ctx.x2,\n        y2: ctx.y2\n      });\n    }\n    for (const point of children.filter(n => n.role === 'point')) {\n      const ctx = point.ctx!;\n      draw({\n        type: 'point',\n        value: ctx.value,\n        index: ctx.valueIndex,\n        meta: ctx.meta,\n        ...common,\n        ...parts(point),\n        x: ctx.x,\n        y: ctx.y,\n        chartRect\n      });\n    }\n    const shapes = [\n      ...children.filter(n => n.role === 'line'),\n      // Areas are inserted first, so the DOM order is the reverse.\n      ...children.filter(n => n.role === 'area').reverse()\n    ];\n    for (const shape of shapes) {\n      const ctx = shape.ctx!;\n      draw({\n        type: shape.role,\n        values: ctx.values,\n        path: ctx.path.clone(),\n        chartRect,\n        index: seriesIndex,\n        ...common,\n        meta: ctx.meta,\n        ...parts(shape)\n      });\n    }\n  }\n\n  // 0.x plugins also read `bounds`, the value axis's scale, which 0.x\n  // passed next to the axes (auto scale axes only, as in 0.x).\n  const valueAxis = options.horizontalBars ? axisX : axisY;\n  untyped(handle).emit(\n    'created',\n    state.preset!.kind === 'pie'\n      ? { chartRect, svg: wrap(svgElement), options }\n      : {\n          chartRect,\n          axisX,\n          axisY,\n          bounds: (valueAxis as { bounds?: unknown }).bounds,\n          svg: wrap(svgElement),\n          options\n        }\n  );\n}\n\n/** Turns the 1.x events on for a chart, once. */\nfunction enable(handle: ChartHandle): CompatState {\n  const existing = states.get(handle);\n  if (existing) {\n    return existing;\n  }\n  const state: CompatState = { instances: [] };\n  states.set(handle, state);\n  (handle as { [REPLACES_OUTPUT]?: boolean })[REPLACES_OUTPUT] = true;\n\n  handle.on('resolve', ({ config }) => {\n    state.preset = config.preset as CompatState['preset'];\n    if (config.data !== state.source) {\n      // 1.x data handlers mutate the data; they get a copy, and the copy\n      // is used from now on (as 1.x keeps its mutated data).\n      state.copy = mutableCopy(config.data) as Data;\n      untyped(handle).emit('data', {\n        type: state.source === undefined ? 'initial' : 'update',\n        data: state.copy\n      });\n      state.source = config.data;\n    }\n    return { config: { ...config, data: state.copy as typeof config.data } };\n  });\n  handle.on('layout', layout => {\n    state.layout = layout;\n  });\n  handle.on('responsive', change =>\n    'previousOptions' in change\n      ? untyped(handle).emit('optionsChanged', {\n          previousOptions: change.previousOptions,\n          currentOptions: change.currentOptions\n        })\n      : undefined\n  );\n  handle.on('mount', ({ scene, output, elementOf }) => {\n    const svg = (output as { svg?: Element }).svg;\n    if (!svg) {\n      throw new Error('Chartist: the compat plugin requires the DOM renderer');\n    }\n    state.svg = new Svg(svg);\n    // Set before the draw events, so listeners can query the chart.\n    for (const instance of state.instances) {\n      instance.svg = state.svg;\n    }\n    // Animations of the chart's elements emit animationBegin and\n    // animationEnd on the chart, as 1.x did with the chart's emitter.\n    (svg as { [ANIMATION_EMITTER]?: unknown })[ANIMATION_EMITTER] = {\n      emit: (event: string, payload: unknown) =>\n        untyped(handle).emit(event, payload)\n    };\n    if (state.preset) {\n      emitDrawEvents(handle, state, scene, svg, elementOf);\n    }\n  });\n  return state;\n}\n\n/** 1.x `optionsProvider`: the options in effect, after responsive options. */\nfunction optionsProviderOf(getOptions: () => unknown) {\n  return {\n    getCurrentOptions: getOptions,\n    // The preset watches the media queries and stops on `detach()`.\n    removeMediaQueryListeners: () => undefined\n  };\n}\n\n/**\n * A 1.x-style chart object for 1.x plugins on the functional API. For a\n * preset it is an instance of the preset's 1.x class (without running its\n * constructor), so type checks such as `chart instanceof LineChart` hold;\n * for `chart()` compositions a plain object.\n */\nfunction legacyChart(handle: ChartHandle, state: CompatState) {\n  const preset = presetOf(handle);\n  const chart = {\n    get container() {\n      return handle.container;\n    },\n    get data() {\n      return state.copy ?? preset?.data;\n    },\n    get options() {\n      return preset?.options;\n    },\n    get svg() {\n      return state.svg;\n    },\n    eventEmitter: {\n      on: (event: string, listener: (payload: unknown) => void) =>\n        untyped(handle).on(event, listener),\n      off: (event: string, listener?: (payload: unknown) => void) =>\n        untyped(handle).off(event, listener),\n      emit: (event: string, payload: unknown) =>\n        untyped(handle).emit(event, payload)\n    },\n    optionsProvider: optionsProviderOf(() => preset?.options),\n    on(event: string, listener: (payload: unknown) => void) {\n      untyped(handle).on(event, listener);\n      return chart;\n    },\n    off(event: string, listener?: (payload: unknown) => void) {\n      untyped(handle).off(event, listener);\n      return chart;\n    },\n    update(data?: unknown, options?: unknown, override?: boolean) {\n      if (preset) {\n        preset.update(data as never, options as never, override);\n      } else {\n        handle.update(data ? { data: data as never } : {});\n      }\n      return chart;\n    },\n    detach() {\n      if (preset) {\n        preset.detach();\n      } else {\n        handle.detach();\n      }\n      return chart;\n    }\n  };\n  // The fields above are own properties, so they shadow the class's.\n  const type = preset && CLASSES[preset.kind];\n  return type ? Object.setPrototypeOf(chart, type.prototype) : chart;\n}\n\n/**\n * Runs a 1.x plugin function as a v2 plugin, with the given chart object.\n * Used by the 1.x chart classes, which pass themselves.\n */\nfunction legacyPlugin(\n  plugin: LegacyPlugin,\n  options?: unknown,\n  chart?: unknown\n): ChartPlugin {\n  return {\n    name: plugin.name || 'legacy-plugin',\n    provides: LEGACY_EVENTS,\n    install(handle) {\n      const state = enable(handle);\n      if (chart) {\n        // A 1.x chart instance: keep its `svg` field current, as 1.x did.\n        state.instances.push(chart as { svg?: Svg });\n        // The 1.x classes run on a preset and have no options provider;\n        // plugins call it for the options in effect.\n        const instance = chart as { optionsProvider?: unknown };\n        if (!instance.optionsProvider) {\n          instance.optionsProvider = optionsProviderOf(\n            () => presetOf(handle)?.options\n          );\n        }\n      }\n      const chartObject = chart ?? legacyChart(handle, state);\n      // As 1.x: plugins without options are called with the chart only.\n      if (options === undefined) {\n        plugin(chartObject);\n      } else {\n        plugin(chartObject, options);\n      }\n    }\n  };\n}\n\n/**\n * The compat plugin. Restores the 1.x events (`data`, `optionsChanged`,\n * `draw`, `created`, `animationBegin`, `animationEnd`) with 1.x payloads.\n * With it, the 1.x chart classes also run 1.x plugin functions.\n *\n * Add it to `plugins`, of a 1.x class, a preset or `chart()`. The `draw`\n * events come in the 1.x order, right after the chart is in the DOM, so\n * `element` is a live element; then `created`. Animations started with\n * `animate()` on the chart's elements emit `animationBegin` and\n * `animationEnd`. Importing\n * `chartist/compat` also types the 1.x events on every chart handle. It\n * needs the DOM renderer, and the `draw` and `created` events need a\n * chart made by a preset or a 1.x class.\n *\n * @example\n * ```ts\n * import { lineChart } from 'chartist';\n * import { compat } from 'chartist/compat';\n *\n * const chart = lineChart(\n *   '#chart',\n *   {\n *     labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],\n *     series: [[12, 9, 7, 8, 5]]\n *   },\n *   { plugins: [compat] }\n * );\n *\n * // Registered after the first render, so it runs from the next one on.\n * chart.on('draw', data => {\n *   if (data.type === 'point' && data.index === 4) {\n *     data.element.addClass('is-friday');\n *   }\n * });\n * ```\n */\nexport const compat: ChartPlugin & { legacyPlugin: typeof legacyPlugin } = {\n  name: 'compat',\n  provides: LEGACY_EVENTS,\n  install: handle => void enable(handle),\n  legacyPlugin\n};\n\n/**\n * Converts a 1.x plugin function into a v2 plugin for `chart()` and the\n * preset functions. It turns the 1.x events on for the chart and calls the\n * plugin with a 1.x-style chart object (`container`, `data`, `options`,\n * `svg`, `eventEmitter`, `on`, `off`, `update`, `detach`). You don't need\n * {@link compat} in the list as well.\n *\n * @param plugin The 1.x plugin: a function that gets the chart (and its\n * options)\n * @param options The plugin's options; without them, the plugin is called\n * with the chart only, as in 1.x\n * @example\n * ```ts\n * import { lineChart, type Plugin } from 'chartist';\n * import { fromLegacyPlugin } from 'chartist/compat';\n *\n * // A 1.x plugin: a function that gets the chart and its options.\n * const caption: Plugin = (chart, options) => {\n *   chart.on('created', () => {\n *     chart.container.setAttribute('aria-label', options.text);\n *   });\n * };\n *\n * lineChart(\n *   '#chart',\n *   { series: [[1, 3, 2, 4]] },\n *   { plugins: [fromLegacyPlugin(caption, { text: 'Visitors per week' })] }\n * );\n * ```\n */\nexport function fromLegacyPlugin(\n  plugin: LegacyPlugin,\n  options?: unknown\n): ChartPlugin {\n  return legacyPlugin(plugin, options);\n}\n\n// The types of the 1.x events and plugins this plugin turns on.\nexport type * from './types';\n","/**\n * The global `Chartist` that plugin scripts of the 0.x and 1.x era read.\n * They register on `Chartist.plugins`, check the chart type with\n * `instanceof Chartist.Line`, and call helpers such as `Chartist.extend`.\n * Importing `chartist/compat` (any build: module, CommonJS or the UMD\n * script) sets this up, so such a script works when it loads after it.\n *\n * The names are added to the global only, never exported: the module\n * builds keep the 1.x and v2 names.\n */\nimport * as core from '../index';\nimport {\n  BarChart,\n  LineChart,\n  PieChart,\n  normalizeData,\n  type Data\n} from '../index';\n\n/**\n * 0.x: the values of each series as plain numbers (`undefined` for holes),\n * normalized as the 1.x charts do; reversed when `reverse` is true. Line\n * and bar data give an array per series, pie data one array.\n */\nexport function getDataArray(\n  data: Data,\n  reverse?: boolean\n): (number | undefined)[] | (number | undefined)[][] {\n  return normalizeData(data as Data<never>, reverse).series as\n    | (number | undefined)[]\n    | (number | undefined)[][];\n}\n\n/** The 0.x names plugin scripts use, next to the library's own. */\nconst LEGACY_NAMES = {\n  // 0.x names of the chart classes, for `chart instanceof Chartist.Line`.\n  Line: LineChart,\n  Bar: BarChart,\n  Pie: PieChart,\n  getDataArray\n};\n\ntype Root = { Chartist?: Record<string, unknown>; document?: unknown };\n\n/**\n * Adds the core, compat and the 0.x names to the global `Chartist`, only\n * what it lacks: a global set by the UMD build or by plugin scripts keeps\n * its values, and `plugins` keeps what scripts registered. If the global\n * belongs to another copy of Chartist (say the UMD build next to these\n * modules), it is left alone with a warning: mixing two copies breaks the\n * plugins' type checks. Outside a browser it does nothing.\n */\nexport function installGlobal(\n  compat: Record<string, unknown>,\n  root: Root = globalThis as Root\n): void {\n  if (root.document === undefined) {\n    return;\n  }\n  const existing = root.Chartist;\n  if (existing && 'LineChart' in existing && existing.LineChart !== LineChart) {\n    // A hint for developers, as the warnings for 1.x events without compat.\n    // eslint-disable-next-line no-console\n    console.warn(\n      'Chartist: the global `Chartist` belongs to another copy of Chartist, so chartist/compat leaves it alone. Load Chartist once: as modules, or as the UMD build with compat.umd.js.'\n    );\n    return;\n  }\n  const target = existing ?? (root.Chartist = {});\n  const add = (name: string, value: unknown) => {\n    if (!(name in target)) {\n      target[name] = value;\n    }\n  };\n  for (const [name, value] of Object.entries(core)) {\n    add(name, value);\n  }\n  for (const [name, value] of Object.entries(compat)) {\n    add(name, value);\n  }\n  add('plugins', {});\n  for (const [name, value] of Object.entries(LEGACY_NAMES)) {\n    add(name, value);\n  }\n}\n","/**\n * The published entry of `chartist/compat`, in every build. Next to the\n * compat API, importing it sets up the global `Chartist` for plugin\n * scripts of the 0.x and 1.x era (see ./global.ts). That's why\n * package.json lists the compat files under `sideEffects`.\n */\nimport * as compat from './index';\nimport { installGlobal } from './global';\n\nexport * from './index';\n\ninstallGlobal(compat);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8TA,MAAa,WAAW,WACtB;;;;;;;;;;;;ACtTF,SAAgB,cAAc,SAGI;CAChC,MAAM,EAAE,MAAM,QAAQ;CACtB,IAAI,OAAO,KACT,OAAO;EAAE;EAAM;CAAI;CAErB,IAAI,QAAQ,GAEV,OAAO;EAAE,MAAM;EAAG;CAAI;CAExB,IAAI,MAAM,GAER,OAAO;EAAE,MAAM;EAAG;CAAI;CAExB,IAAI,OAAO,GAET,OAAO;EAAE;EAAM,KAAK;CAAE;CAGxB,OAAO;EAAE,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