// (C) 2020-2026 GoodData Corporation
import { insightVisualizationUrl } from "@gooddata/sdk-model";
import { AreaChartDescriptor } from "./pluggableVisualizations/areaChart/AreaChartDescriptor.js";
import { BarChartDescriptor } from "./pluggableVisualizations/barChart/BarChartDescriptor.js";
import { BubbleChartDescriptor } from "./pluggableVisualizations/bubbleChart/BubbleChartDescriptor.js";
import { BulletChartDescriptor } from "./pluggableVisualizations/bulletChart/BulletChartDescriptor.js";
import { ColumnChartDescriptor } from "./pluggableVisualizations/columnChart/ColumnChartDescriptor.js";
import { ComboChartDescriptor } from "./pluggableVisualizations/comboChart/ComboChartDescriptor.js";
import { ComboChartDescriptorDeprecated } from "./pluggableVisualizations/comboChart/ComboChartDescriptorDeprecated.js";
import { DependencyWheelChartDescriptor } from "./pluggableVisualizations/dependencyWheelChart/DependencyWheelChartDescriptor.js";
import { DonutChartDescriptor } from "./pluggableVisualizations/donutChart/DonutChartDescriptor.js";
import { FunnelChartDescriptor } from "./pluggableVisualizations/funnelChart/FunnelChartDescriptor.js";
import { GeoAreaChartDescriptor } from "./pluggableVisualizations/geoAreaChart/GeoAreaChartDescriptor.js";
import { GeoPushpinChartDescriptor } from "./pluggableVisualizations/geoChart/GeoPushpinChartDescriptor.js";
import { GeoPushpinChartNextDescriptor } from "./pluggableVisualizations/geoChartNext/GeoPushpinChartNextDescriptor.js";
import { HeadlineDescriptor } from "./pluggableVisualizations/headline/HeadlineDescriptor.js";
import { HeatmapDescriptor } from "./pluggableVisualizations/heatMap/HeatmapDescriptor.js";
import { LineChartDescriptor } from "./pluggableVisualizations/lineChart/LineChartDescriptor.js";
import { PieChartDescriptor } from "./pluggableVisualizations/pieChart/PieChartDescriptor.js";
import { PivotTableDescriptor } from "./pluggableVisualizations/pivotTable/PivotTableDescriptor.js";
import { PivotTableNextDescriptor } from "./pluggableVisualizations/pivotTableNext/PivotTableNextDescriptor.js";
import { PyramidChartDescriptor } from "./pluggableVisualizations/pyramidChart/PyramidChartDescriptor.js";
import { RepeaterDescriptor } from "./pluggableVisualizations/repeater/RepeaterDescriptor.js";
import { SankeyChartDescriptor } from "./pluggableVisualizations/sankeyChart/SankeyChartDescriptor.js";
import { ScatterPlotDescriptor } from "./pluggableVisualizations/scatterPlot/ScatterPlotDescriptor.js";
import { TreemapDescriptor } from "./pluggableVisualizations/treeMap/TreemapDescriptor.js";
import { UnknownVisualizationDescriptor } from "./pluggableVisualizations/UnknownVisualizationDescriptor.js";
import { WaterfallChartDescriptor } from "./pluggableVisualizations/waterfallChart/WaterfallChartDescriptor.js";
import { XirrDescriptor } from "./pluggableVisualizations/xirr/XirrDescriptor.js";
/**
 * @internal
 */
export class CatalogViaTypeToClassMap {
    mapping;
    constructor(mapping) {
        this.mapping = mapping;
    }
    forUri(uri, enablePivotTableNext, enableGeoPushpinNext) {
        let sanitizedUri = uri;
        if (enablePivotTableNext && uri === "local:table") {
            sanitizedUri = "local:tablenext";
        }
        else if (enableGeoPushpinNext && uri === "local:pushpin") {
            sanitizedUri = "local:pushpinnext";
        }
        const VisType = this.findInMapping(sanitizedUri);
        if (!VisType) {
            console.warn(`Unknown visualization class: ${uri}. The reason may be that the visualization type is incompatible with dashboard plugins. Try removing the plugins from this dashboard or use different visualization type.`);
            return new UnknownVisualizationDescriptor(uri);
        }
        return new VisType();
    }
    hasDescriptorForUri(uri) {
        return !!this.findInMapping(uri);
    }
    forInsight(insight, enablePivotTableNext, enableGeoPushpinNext) {
        /*
         * the URIs follow "local:visualizationType" format
         */
        const vizClass = insightVisualizationUrl(insight);
        return this.forUri(vizClass, enablePivotTableNext, enableGeoPushpinNext);
    }
    hasDescriptorForInsight(insight) {
        const visClassUri = insightVisualizationUrl(insight);
        return this.hasDescriptorForUri(visClassUri);
    }
    findInMapping(uri) {
        const split = uri.split(":");
        const key = split.at(-1);
        return this.mapping[key];
    }
}
//
// Default static catalog implementation
//
/**
 * Compile-time pluggable visualization 'catalog'.
 */
const DefaultVisualizations = {
    bar: BarChartDescriptor,
    bullet: BulletChartDescriptor,
    column: ColumnChartDescriptor,
    line: LineChartDescriptor,
    area: AreaChartDescriptor,
    pie: PieChartDescriptor,
    donut: DonutChartDescriptor,
    table: PivotTableDescriptor,
    headline: HeadlineDescriptor,
    scatter: ScatterPlotDescriptor,
    bubble: BubbleChartDescriptor,
    heatmap: HeatmapDescriptor,
    combo: ComboChartDescriptorDeprecated, // old combo chart
    combo2: ComboChartDescriptor, // new combo chart
    treemap: TreemapDescriptor,
    funnel: FunnelChartDescriptor,
    pyramid: PyramidChartDescriptor,
    pushpin: GeoPushpinChartDescriptor,
    sankey: SankeyChartDescriptor,
    dependencywheel: DependencyWheelChartDescriptor,
    waterfall: WaterfallChartDescriptor,
    repeater: RepeaterDescriptor,
    tablenext: PivotTableNextDescriptor,
    pushpinnext: GeoPushpinChartNextDescriptor,
    choropleth: GeoAreaChartDescriptor,
};
/**
 * Default pluggable visualization catalog. This is implemented using static lookup table between vis type
 * and the actual plug vis implementation.
 *
 * @alpha
 */
export const DefaultVisualizationCatalog = new CatalogViaTypeToClassMap(DefaultVisualizations);
/**
 * Pluggable visualization catalog containing all available visualizations.
 *
 * @alpha
 */
export const FullVisualizationCatalog = new CatalogViaTypeToClassMap({
    ...DefaultVisualizations,
    xirr: XirrDescriptor,
});
//# sourceMappingURL=VisualizationCatalog.js.map