/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-e694c50 | Cube Dev Team */
//#region src/utils/react/nullableValue.ts
function castNullableStringValue(props) {
	return castNullableField(props, ["value", "defaultValue"], "string", (v) => String(v));
}
function castNullableNumberValue(props) {
	return castNullableField(props, ["value", "defaultValue"], "number", (v) => Number(v));
}
function castNullableArrayValue(props) {
	return castNullableField(props, ["value", "defaultValue"], "object", (v) => Array.isArray(v) ? v : []);
}
function castNullableIsSelected(props) {
	return castNullableField(props, ["isSelected", "defaultSelected"], "boolean", (v) => !!v);
}
function castNullableField(props, keys, type, cast) {
	props = { ...props };
	keys.forEach((key) => {
		if (props[key] === null) props[key] = void 0;
		if (type && cast && props[key] != null && typeof props[key] != type) {
			props[key] = cast(props[key]);
			console.warn("Wrong value type in", props, "in keys", JSON.stringify(keys));
		}
	});
	return props;
}

//#endregion
export { castNullableArrayValue, castNullableIsSelected, castNullableNumberValue, castNullableStringValue };
//# sourceMappingURL=nullableValue.js.map