Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_chunk = require("../../chunk-BN4qSVkS.cjs");
const require_components_ButtonRow = require("../ButtonRow.cjs");
const require_components_DataManagerTable_Filter = require("./Filter.cjs");
require("./filters.cjs");
const require_components_NumberInput = require("../NumberInput.cjs");
let _emotion_styled = require("@emotion/styled");
_emotion_styled = require_chunk.__toESM(_emotion_styled);
let react = require("react");
let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
let _lightsparkdev_core = require("@lightsparkdev/core");
//#region src/components/DataManagerTable/CurrencyFilter.tsx
const isCurrencyFilterState = (state) => state.type === "currency";
const getDefaultCurrencyFilterState = () => ({
	type: "currency",
	min_amount: null,
	max_amount: null,
	isApplied: false
});
const CurrencyFilter = ({ updateFilterState, state, label }) => {
	const [filterRangeType, setFilterRangeType] = (0, react.useState)("Less than");
	const isMinDisplayed = filterRangeType !== "Less than";
	const isMaxDisplayed = filterRangeType !== "More than";
	const handleMinChange = (value) => {
		updateFilterState({
			...state,
			min_amount: value ? {
				value: parseInt(value),
				unit: _lightsparkdev_core.CurrencyUnit.SATOSHI
			} : null,
			isApplied: state.max_amount !== null || !!value
		});
	};
	const handleMaxChange = (value) => {
		updateFilterState({
			...state,
			max_amount: value ? {
				value: parseInt(value),
				unit: _lightsparkdev_core.CurrencyUnit.SATOSHI
			} : null,
			isApplied: state.min_amount !== null || !!value
		});
	};
	const handleClick = (type) => {
		setFilterRangeType(type);
		updateFilterState({
			...state,
			min_amount: null,
			max_amount: null,
			isApplied: false
		});
	};
	return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)(require_components_DataManagerTable_Filter.Filter, {
		label,
		children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(NumberButtonRowContainer, {
			smSticky: false,
			bottomBorder: false,
			buttons: [
				{
					text: "Less than",
					kind: filterRangeType === "Less than" ? "primary" : void 0,
					onClick: () => handleClick("Less than"),
					size: "ExtraSmall"
				},
				{
					text: "Between",
					kind: filterRangeType === "Between" ? "primary" : void 0,
					onClick: () => handleClick("Between"),
					size: "ExtraSmall"
				},
				{
					text: "More than",
					kind: filterRangeType === "More than" ? "primary" : void 0,
					onClick: () => handleClick("More than"),
					size: "ExtraSmall"
				}
			]
		}), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)(InputContainer, { children: [
			isMinDisplayed && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_components_NumberInput.NumberInput, {
				placeholder: "0",
				onChange: handleMinChange,
				value: state.min_amount?.value?.toString() || "",
				icon: {
					name: "Satoshi",
					side: "left",
					width: 8
				},
				typography: { color: "black" },
				allowNegativeValue: true
			}),
			isMinDisplayed && isMaxDisplayed && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(Divider, {}),
			isMaxDisplayed && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_components_NumberInput.NumberInput, {
				placeholder: "0",
				onChange: handleMaxChange,
				value: state.max_amount?.value?.toString() || "",
				icon: {
					name: "Satoshi",
					side: "left",
					width: 8
				},
				typography: { color: "black" },
				allowNegativeValue: true
			})
		] })]
	}) });
};
const NumberButtonRowContainer = (0, _emotion_styled.default)(require_components_ButtonRow.ButtonRow)`
  padding: 0px !important;
`;
const InputContainer = _emotion_styled.default.div`
  display: flex;
  flex-direction: row;
  margin-top: 24px;
  gap: 10px;
  align-items: center;
`;
const Divider = _emotion_styled.default.div`
  height: 4px;
  width: 12px;
  flex-shrink: 0;
  border-radius: 999px;
  background-color: ${({ theme }) => theme.c1Neutral};
`;
//#endregion
exports.CurrencyFilter = CurrencyFilter;
exports.getDefaultCurrencyFilterState = getDefaultCurrencyFilterState;
exports.isCurrencyFilterState = isCurrencyFilterState;
