/**
 * Copyright IBM Corp. 2020, 2026
 *
 * This source code is licensed under the Apache-2.0 license found in the
 * LICENSE file in the root directory of this source tree.
 */

import { blockClass, checkIsValid } from "../../utils/util.js";
import React from "react";
import PropTypes from "prop-types";
import { TextArea, TextInput } from "@carbon/react";

//#region src/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.tsx
/**
* Copyright IBM Corp. 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
const ConditionBuilderItemText = ({ conditionState, onChange, config, type }) => {
	const inputProps = {
		...config,
		hideLabel: true,
		value: checkIsValid(conditionState.value) ? conditionState.value : "",
		id: conditionState.property?.replace(/\s/g, ""),
		onChange: (evt) => {
			onChange(evt.target.value);
		},
		labelText: conditionState.property
	};
	return /* @__PURE__ */ React.createElement("div", { className: `${blockClass}__item-text` }, type == "textarea" ? /* @__PURE__ */ React.createElement(TextArea, inputProps) : /* @__PURE__ */ React.createElement(TextInput, inputProps));
};
ConditionBuilderItemText.propTypes = {
	conditionState: PropTypes.object,
	config: PropTypes.object,
	onChange: PropTypes.func,
	type: PropTypes.string
};

//#endregion
export { ConditionBuilderItemText };