// (C) 2025-2026 GoodData Corporation
import { PluggableGeoAreaChart } from "./PluggableGeoAreaChart.js";
import { executionConfigInsightConversion, getInsightToPropsConverter, getReactEmbeddingCodeGenerator, insightConversion, sdkModelPropMetas, } from "../../../utils/embeddingCodeGenerator/index.js";
import { BaseChartDescriptor } from "../baseChart/BaseChartDescriptor.js";
import { chartAdditionalFactories } from "../chartCodeGenUtils.js";
import { MAX_VISUALIZATION_HEIGHT, MIDDLE_VISUALIZATION_HEIGHT } from "../constants.js";
import { geoConfigFromInsight } from "../geoChartNext/geoConfigBuilder.js";
import { buildGeoChartNextGlobalFilters, buildGeoChartNextLayers, } from "../geoChartNext/geoEmbeddingLayers.js";
/**
 * @alpha
 */
export class GeoAreaChartDescriptor extends BaseChartDescriptor {
    getFactory() {
        return (params) => new PluggableGeoAreaChart(params);
    }
    getSizeInfo(_insight, layoutDescriptor, settings) {
        return {
            width: {
                default: 6,
                min: 6,
                max: layoutDescriptor.gridColumnsCount,
            },
            height: {
                default: this.getDefaultHeight(settings),
                min: this.getDefaultHeight(settings),
                max: this.getMaxHeight(settings),
            },
        };
    }
    getDefaultHeight(_settings) {
        return MIDDLE_VISUALIZATION_HEIGHT;
    }
    getMaxHeight(_settings) {
        return MAX_VISUALIZATION_HEIGHT;
    }
    geoChartEmbeddingCodeGenerator = getReactEmbeddingCodeGenerator({
        component: {
            importType: "named",
            name: "GeoChartNext",
            package: "@gooddata/sdk-ui-geo/next",
        },
        insightToProps: getInsightToPropsConverter({
            type: insightConversion("type", { cardinality: "scalar" }, () => "area"),
            layers: insightConversion("layers", {
                typeImport: {
                    importType: "named",
                    name: "IGeoLayer",
                    package: "@gooddata/sdk-ui-geo/next",
                },
                cardinality: "array",
            }, (insight) => buildGeoChartNextLayers(insight, "area")),
            filters: insightConversion("filters", sdkModelPropMetas.Filter.Multiple, buildGeoChartNextGlobalFilters),
            config: insightConversion("config", {
                typeImport: {
                    importType: "named",
                    name: "IGeoAreaChartConfig",
                    package: "@gooddata/sdk-ui-geo/next",
                },
                cardinality: "scalar",
            }, geoConfigFromInsight),
            execConfig: executionConfigInsightConversion("execConfig"),
        }),
        additionalFactories: chartAdditionalFactories({
            getColorMappingPredicatePackage: "@gooddata/sdk-ui-geo",
        }),
    });
    getEmbeddingCode = (insight, config) => {
        const layers = buildGeoChartNextLayers(insight, "area");
        if (!layers.length) {
            return "";
        }
        return this.geoChartEmbeddingCodeGenerator(insight, config);
    };
    getMeta() {
        return {
            documentationUrl: "https://www.gooddata.com/docs/gooddata-ui/latest/references/visual_components/geo_area_chart",
            supportsExport: true,
            supportsZooming: false,
        };
    }
}
//# sourceMappingURL=GeoAreaChartDescriptor.js.map