import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2019-2025 GoodData Corporation
import { messages } from "../../../../locales.js";
import { DEFAULT_NUMBER_OF_CLUSTERS } from "../../../constants/scatter.js";
import { InputControl } from "../InputControl.js";
const validPositiveNumberHigherThanZero = /^[1-9][0-9]*$/;
export function NumberOfClustersControl({ disabled, valuePath, properties, pushData, }) {
    return (_jsx(InputControl, { valuePath: valuePath, labelText: messages["clusteringAmount"].id, placeholder: messages["clusteringAmountPlaceholder"].id, type: "number", value: properties?.controls?.["clustering"]?.numberOfClusters ?? `${DEFAULT_NUMBER_OF_CLUSTERS}`, disabled: disabled, properties: properties, pushData: pushData, validateFn: (value) => {
            // Only numbers or empty value is valid input
            return value === "" || validPositiveNumberHigherThanZero.test(value);
        }, transformFn: (value) => {
            const isValid = validPositiveNumberHigherThanZero.test(value);
            // For invalid or empty input, transform to default value.
            if (value === "" || !isValid) {
                return `${DEFAULT_NUMBER_OF_CLUSTERS}`;
            }
            return value;
        } }));
}
//# sourceMappingURL=NumberOfClustersControl.js.map