"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _chunkY45PAGZ2cjs = require('./chunk-Y45PAGZ2.cjs');


var _chunkILBP4CTUcjs = require('./chunk-ILBP4CTU.cjs');


var _chunkZUAO4DW3cjs = require('./chunk-ZUAO4DW3.cjs');


var _chunkKKOBB4X5cjs = require('./chunk-KKOBB4X5.cjs');



var _chunkZ6EUSUADcjs = require('./chunk-Z6EUSUAD.cjs');

// src/components/DataManagerTable/StringFilter.tsx
var _styled = require('@emotion/styled'); var _styled2 = _interopRequireDefault(_styled);
var _jsxruntime = require('@emotion/react/jsx-runtime');
var isStringFilterState = (state) => state.type === "string" /* STRING */;
var getDefaultStringFilterState = () => ({
  type: "string" /* STRING */,
  value: "",
  isApplied: false
});
var StringFilter = ({
  updateFilterState,
  state,
  placeholder,
  label
}) => {
  var _a;
  const handleChange = (value) => {
    updateFilterState(_chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, state), {
      value,
      isApplied: !!value
    }));
  };
  const appliedValueButtons = (_a = state.appliedValues) == null ? void 0 : _a.map((value) => {
    return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
      _chunkKKOBB4X5cjs.Button,
      {
        kind: "primary",
        size: "ExtraSmall",
        text: value,
        icon: { name: "Close" },
        iconSide: "right",
        onClick: () => {
          var _a2;
          updateFilterState(_chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, state), {
            appliedValues: (_a2 = state.appliedValues) == null ? void 0 : _a2.filter(
              (appliedValue) => appliedValue !== value
            )
          }));
        }
      },
      value
    );
  });
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
    /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY45PAGZ2cjs.Filter, { label, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
      _chunkILBP4CTUcjs.TextInput,
      {
        placeholder: placeholder || "",
        onChange: handleChange,
        value: state.value
      }
    ) }),
    !!(appliedValueButtons == null ? void 0 : appliedValueButtons.length) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AppliedButtonsContainer, { children: appliedValueButtons }) : null
  ] });
};
var AppliedButtonsContainer = _styled2.default.div`
  margin-top: ${_chunkZUAO4DW3cjs.Spacing.px.sm};
  display: flex;
  gap: ${_chunkZUAO4DW3cjs.Spacing.px.xs};
  flex-wrap: wrap;
`;





exports.isStringFilterState = isStringFilterState; exports.getDefaultStringFilterState = getDefaultStringFilterState; exports.StringFilter = StringFilter;
