import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import { useCallback, useMemo, useEffect, useState, createElement } from 'react';
import { DndContext, closestCenter } from '@dnd-kit/core';
import { useSortable, SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';
import i18next from 'i18next';
import { isNotEqualDeep, isNotEmpty, noop, removeBy, findIndexBy } from '@bigbinary/neeto-cist';
import Search from '@bigbinary/neeto-icons/Search';
import Checkbox from '@bigbinary/neetoui/Checkbox';
import Dropdown from '@bigbinary/neetoui/Dropdown';
import Input from '@bigbinary/neetoui/Input';
import Label from '@bigbinary/neetoui/Label';
import Button from '@bigbinary/neetoui/Button';
import { isEmpty, prop, pluck, filter, includes, trim, toLower, assoc } from 'ramda';
import { useTranslation } from 'react-i18next';
import { n } from './inject-css-C2dztUxs.js';
import classnames from 'classnames';
import Reorder from '@bigbinary/neeto-icons/Reorder';
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
import { useQuery } from '@tanstack/react-query';
import useMutationWithInvalidation from '@bigbinary/neeto-commons-frontend/react-utils/useMutationWithInvalidation';
import axios from 'axios';

var css = ":root{--neeto-molecules-columns-menu-max-width:31.25rem}.neeto-molecules-columns__container{max-width:31.25rem;max-width:var(--neeto-molecules-columns-menu-max-width)}.neeto-molecules-columns__sortable-item .neeto-ui-cursor-grab{cursor:grab}.neeto-molecules-columns__sortable-item .neeto-ui-cursor-grab:active{cursor:grabbing}.neeto-molecules-columns__sortable-item:hover .neeto-ui-text-gray-400{color:#6b7280}.neeto-ui-dropdown--manage-columns .neeto-ui-dropdown__popup{max-height:calc(100dvh - 200px)!important}";
n(css,{});

const CSS = /*#__PURE__*/Object.freeze({
  Translate: {
    toString(transform) {
      if (!transform) {
        return;
      }

      const {
        x,
        y
      } = transform;
      return "translate3d(" + (x ? Math.round(x) : 0) + "px, " + (y ? Math.round(y) : 0) + "px, 0)";
    }

  },
  Scale: {
    toString(transform) {
      if (!transform) {
        return;
      }

      const {
        scaleX,
        scaleY
      } = transform;
      return "scaleX(" + scaleX + ") scaleY(" + scaleY + ")";
    }

  },
  Transform: {
    toString(transform) {
      if (!transform) {
        return;
      }

      return [CSS.Translate.toString(transform), CSS.Scale.toString(transform)].join(' ');
    }

  },
  Transition: {
    toString(_ref) {
      let {
        property,
        duration,
        easing
      } = _ref;
      return property + " " + duration + "ms " + easing;
    }

  }
});

function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var Item = function Item(_ref) {
  var _active$data, _over$data;
  var column = _ref.column,
    hiddenColumns = _ref.hiddenColumns,
    checkboxProps = _ref.checkboxProps,
    onToggle = _ref.onToggle,
    isTableConfigurationFetching = _ref.isTableConfigurationFetching;
  var key = column.key,
    title = column.title;
  var _useSortable = useSortable({
      id: key
    }),
    attributes = _useSortable.attributes,
    listeners = _useSortable.listeners,
    setNodeRef = _useSortable.setNodeRef,
    transform = _useSortable.transform,
    transition = _useSortable.transition,
    isDragging = _useSortable.isDragging,
    isOver = _useSortable.isOver,
    over = _useSortable.over,
    active = _useSortable.active;
  var dragStyle = {
    transform: isDragging ? CSS.Transform.toString(transform) : undefined,
    transition: transition,
    opacity: isDragging ? 0.5 : 1
  };
  var isIndicatorVisible = !isDragging && isOver;
  var draggedIndex = active === null || active === void 0 || (_active$data = active.data) === null || _active$data === void 0 || (_active$data = _active$data.current) === null || _active$data === void 0 || (_active$data = _active$data.sortable) === null || _active$data === void 0 ? void 0 : _active$data.index;
  var targetIndex = over === null || over === void 0 || (_over$data = over.data) === null || _over$data === void 0 || (_over$data = _over$data.current) === null || _over$data === void 0 || (_over$data = _over$data.sortable) === null || _over$data === void 0 ? void 0 : _over$data.index;
  return /*#__PURE__*/jsxs("div", {
    children: [/*#__PURE__*/jsx("div", {
      className: classnames({
        "neeto-ui-bg-gray-200 h-1 w-full": isIndicatorVisible && targetIndex < draggedIndex
      })
    }), /*#__PURE__*/jsx("div", {
      className: "neeto-molecules-columns__sortable-item",
      "data-cy": "column-sortable-item",
      ref: setNodeRef,
      style: dragStyle,
      children: /*#__PURE__*/jsxs(Label, {
        className: "neeto-ui-flex neeto-ui-w-full hover:neeto-ui-bg-gray-200 neeto-ui-cursor-pointer neeto-ui-items-center px-4 py-2",
        htmlFor: key,
        children: [/*#__PURE__*/jsx("div", _objectSpread$3(_objectSpread$3(_objectSpread$3({}, attributes), listeners), {}, {
          className: "neeto-ui-mr-2 neeto-ui-cursor-grab neeto-ui-flex neeto-ui-items-center",
          "data-cy": "column-drag-handle",
          children: /*#__PURE__*/jsx(Reorder, {
            className: "neeto-ui-text-gray-800",
            size: 18
          })
        })), /*#__PURE__*/jsx(Checkbox, _objectSpread$3({
          checked: !hiddenColumns.includes(key),
          "data-cy": "neeto-ui-columns-checkbox",
          disabled: isTableConfigurationFetching,
          id: key,
          label: title,
          name: key,
          onChange: onToggle
        }, checkboxProps))]
      })
    }), /*#__PURE__*/jsx("div", {
      className: classnames({
        "neeto-ui-bg-gray-200 h-1 w-full": isIndicatorVisible && targetIndex > draggedIndex
      })
    })]
  });
};

var baseUrl = "api/v1/table_configurations";
var fetch = function fetch(tableKey) {
  return axios.get("".concat(baseUrl, "/").concat(tableKey));
};
var create = function create(payload) {
  return axios.post(baseUrl, {
    tableConfiguration: payload
  });
};
var update = function update(_ref) {
  var tableKey = _ref.tableKey,
    payload = _ref.payload;
  return axios.patch("".concat(baseUrl, "/").concat(tableKey), {
    tableConfiguration: payload
  });
};
var destroy = function destroy(tableKey) {
  return axios["delete"]("".concat(baseUrl, "/").concat(tableKey));
};
var tableConfigurationApi = {
  fetch: fetch,
  create: create,
  update: update,
  destroy: destroy
};

var HIDDEN_COLUMNS_STORAGE_KEY = "neeto-molecules-hidden-columns";
var COLUMNS_ORDER_STORAGE_KEY = "neeto-molecules-columns-order";
var TABLE_CONFIGURATION_QUERY_KEY = "table-configuration";

function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var useFetchTableConfiguration = function useFetchTableConfiguration(_ref) {
  var tableKey = _ref.tableKey,
    _ref$options = _ref.options,
    options = _ref$options === void 0 ? {} : _ref$options;
  return useQuery(_objectSpread$2({
    queryKey: [TABLE_CONFIGURATION_QUERY_KEY, tableKey],
    enabled: !!tableKey,
    queryFn: function queryFn() {
      return tableConfigurationApi.fetch(tableKey);
    }
  }, options));
};
var useUpdateTableConfiguration = function useUpdateTableConfiguration(tableKey) {
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  return useMutationWithInvalidation(tableConfigurationApi.update, _objectSpread$2({
    keysToInvalidate: [[TABLE_CONFIGURATION_QUERY_KEY, tableKey]]
  }, options));
};
var useDestroyTableConfiguration = function useDestroyTableConfiguration(tableKey) {
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  return useMutationWithInvalidation(tableConfigurationApi.destroy, _objectSpread$2({
    keysToInvalidate: [[TABLE_CONFIGURATION_QUERY_KEY, tableKey]]
  }, options));
};

function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var useTableConfigurations = function useTableConfigurations(tableKey, columnData) {
  var onMutationSuccess = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : noop;
  var allowConfigurationResetOnUpdate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  var defaultHiddenColumns = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
  var _useFetchTableConfigu = useFetchTableConfiguration({
      tableKey: tableKey
    }),
    tableConfiguration = _useFetchTableConfigu.data,
    isLoading = _useFetchTableConfigu.isLoading,
    isFetching = _useFetchTableConfigu.isFetching;
  var _useUpdateTableConfig = useUpdateTableConfiguration(tableKey, {
      onSuccess: onMutationSuccess
    }),
    updateConfiguration = _useUpdateTableConfig.mutate;
  var _useDestroyTableConfi = useDestroyTableConfiguration(tableKey, {
      onSuccess: onMutationSuccess
    }),
    destroyConfiguration = _useDestroyTableConfi.mutate;
  var processColumnsWithConfiguration = useCallback(function () {
    var originalColumns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
    var existingColumnConfiguration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
    if (isEmpty(existingColumnConfiguration)) {
      return originalColumns;
    }
    var originalColumnsByKey = new Map(originalColumns === null || originalColumns === void 0 ? void 0 : originalColumns.filter(prop("key")).map(function (column) {
      return [column.key, column];
    }));
    var configurationByKey = new Map(existingColumnConfiguration.map(function (config) {
      return [config.key, config];
    }));
    var orderedConfiguredColumns = existingColumnConfiguration.map(function (config) {
      return originalColumnsByKey.get(config.key);
    }).filter(Boolean);
    var unconfiguredOriginalColumns = originalColumns.filter(function (column) {
      return column.key && !configurationByKey.has(column.key);
    });
    return [].concat(_toConsumableArray(orderedConfiguredColumns), _toConsumableArray(unconfiguredOriginalColumns));
  }, []);
  var hasAdditionalColumns = useMemo(function () {
    if (!(tableConfiguration !== null && tableConfiguration !== void 0 && tableConfiguration.columns) || !columnData) {
      return false;
    }
    var configurationKeys = pluck("key", tableConfiguration.columns).sort();
    var dataKeys = pluck("key", columnData).sort();
    return isNotEqualDeep(configurationKeys, dataKeys);
  }, [tableConfiguration, columnData]);
  var shouldApplyTableConfiguration = useMemo(function () {
    return !isLoading && (tableConfiguration === null || tableConfiguration === void 0 ? void 0 : tableConfiguration.columns) && isNotEmpty(tableConfiguration === null || tableConfiguration === void 0 ? void 0 : tableConfiguration.columns) && !hasAdditionalColumns;
  }, [tableConfiguration, isLoading, hasAdditionalColumns]);
  useEffect(function () {
    if (hasAdditionalColumns && tableConfiguration && allowConfigurationResetOnUpdate) {
      destroyConfiguration(tableKey);
    }
  }, [hasAdditionalColumns, tableKey, allowConfigurationResetOnUpdate]);
  var allProcessedColumns = useMemo(function () {
    if (!isLoading && isNotEmpty(tableConfiguration === null || tableConfiguration === void 0 ? void 0 : tableConfiguration.columns) && !hasAdditionalColumns) {
      return processColumnsWithConfiguration(columnData, tableConfiguration === null || tableConfiguration === void 0 ? void 0 : tableConfiguration.columns);
    }
    return columnData || [];
  }, [isLoading, tableConfiguration === null || tableConfiguration === void 0 ? void 0 : tableConfiguration.columns, hasAdditionalColumns, columnData, processColumnsWithConfiguration]);
  var existingColumnConfiguration = useMemo(function () {
    if (shouldApplyTableConfiguration) {
      return tableConfiguration.columns;
    }
    if (!columnData || isEmpty(columnData)) {
      return [];
    }
    return columnData.map(function (column) {
      return {
        key: column.key,
        isShown: !defaultHiddenColumns.includes(column.key)
      };
    });
  }, [shouldApplyTableConfiguration, columnData, tableConfiguration === null || tableConfiguration === void 0 ? void 0 : tableConfiguration.columns, defaultHiddenColumns]);
  var customizedColumns = useMemo(function () {
    var visibleColumnsConfig = existingColumnConfiguration.filter(prop("isShown"));
    var visibleColumnKeys = pluck("key", visibleColumnsConfig);
    return allProcessedColumns.filter(function (column) {
      return visibleColumnKeys.includes(column.key);
    });
  }, [allProcessedColumns, existingColumnConfiguration]);
  var updateColumns = function updateColumns(updatedColumns) {
    updateConfiguration({
      tableKey: tableKey,
      payload: {
        table_key: tableKey,
        columns: updatedColumns
      }
    });
  };
  var hideColumn = function hideColumn(columnKey) {
    updateColumns(existingColumnConfiguration.map(function (column) {
      return column.key === columnKey ? _objectSpread$1(_objectSpread$1({}, column), {}, {
        isShown: false
      }) : column;
    }));
  };
  var showColumn = function showColumn(columnKey) {
    updateColumns(existingColumnConfiguration.map(function (column) {
      return column.key === columnKey ? _objectSpread$1(_objectSpread$1({}, column), {}, {
        isShown: true
      }) : column;
    }));
  };
  return {
    customizedColumns: customizedColumns,
    // Only visible columns (for displaying the columns in the table)
    allProcessedColumns: allProcessedColumns,
    // All columns (for displaying the columns in the Subheader)
    isTableConfigurationLoading: isLoading,
    isTableConfigurationFetching: isFetching,
    existingColumnConfiguration: existingColumnConfiguration,
    hideColumn: hideColumn,
    showColumn: showColumn,
    updateColumns: updateColumns,
    destroyConfiguration: destroyConfiguration
  };
};

var getHidableColumns = function getHidableColumns(columnData) {
  return removeBy({
    isHidable: false
  }, columnData);
};
var filterBySearchTerm = function filterBySearchTerm(searchTerm, columns) {
  return filter(function (_ref) {
    var title = _ref.title;
    return includes(trim(toLower(searchTerm)), trim(toLower(title)));
  }, columns);
};

var _excluded = ["actionBlock", "checkboxProps", "columnData", "isSearchable", "tableKey", "noColumnMessage", "searchProps", "allowConfigurationResetOnUpdate", "onMutationSuccess", "defaultHiddenColumns"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var Columns = function Columns(_ref) {
  var actionBlock = _ref.actionBlock,
    _ref$checkboxProps = _ref.checkboxProps,
    checkboxProps = _ref$checkboxProps === void 0 ? {} : _ref$checkboxProps,
    _ref$columnData = _ref.columnData,
    columnData = _ref$columnData === void 0 ? [] : _ref$columnData,
    _ref$isSearchable = _ref.isSearchable,
    isSearchable = _ref$isSearchable === void 0 ? false : _ref$isSearchable,
    _ref$tableKey = _ref.tableKey,
    tableKey = _ref$tableKey === void 0 ? "" : _ref$tableKey,
    _ref$noColumnMessage = _ref.noColumnMessage,
    noColumnMessage = _ref$noColumnMessage === void 0 ? i18next.t("neetoMolecules.columns.noColumns") : _ref$noColumnMessage,
    _ref$searchProps = _ref.searchProps,
    searchProps = _ref$searchProps === void 0 ? {} : _ref$searchProps,
    _ref$allowConfigurati = _ref.allowConfigurationResetOnUpdate,
    allowConfigurationResetOnUpdate = _ref$allowConfigurati === void 0 ? true : _ref$allowConfigurati,
    _ref$onMutationSucces = _ref.onMutationSuccess,
    onMutationSuccess = _ref$onMutationSucces === void 0 ? noop : _ref$onMutationSucces,
    _ref$defaultHiddenCol = _ref.defaultHiddenColumns,
    defaultHiddenColumns = _ref$defaultHiddenCol === void 0 ? [] : _ref$defaultHiddenCol,
    dropdownProps = _objectWithoutProperties(_ref, _excluded);
  var Divider = Dropdown.Divider,
    Menu = Dropdown.Menu,
    MenuItem = Dropdown.MenuItem;
  var _useState = useState(""),
    _useState2 = _slicedToArray(_useState, 2),
    searchTerm = _useState2[0],
    setSearchTerm = _useState2[1];
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  var _useTableConfiguratio = useTableConfigurations(tableKey, columnData, onMutationSuccess, allowConfigurationResetOnUpdate, defaultHiddenColumns),
    allProcessedColumns = _useTableConfiguratio.allProcessedColumns,
    existingColumnConfiguration = _useTableConfiguratio.existingColumnConfiguration,
    hideColumn = _useTableConfiguratio.hideColumn,
    showColumn = _useTableConfiguratio.showColumn,
    updateColumns = _useTableConfiguratio.updateColumns,
    destroyConfiguration = _useTableConfiguratio.destroyConfiguration,
    isTableConfigurationFetching = _useTableConfiguratio.isTableConfigurationFetching;
  var hiddenColumns = pluck("key", existingColumnConfiguration.filter(function (column) {
    return !column.isShown;
  }));
  var handleDragEnd = function handleDragEnd(event) {
    var active = event.active,
      over = event.over;
    if (!over || active.id === over.id) return;
    var oldIndex = findIndexBy({
      key: active.id
    }, existingColumnConfiguration);
    var newIndex = findIndexBy({
      key: over.id
    }, existingColumnConfiguration);
    if (oldIndex === -1 || newIndex === -1) return;
    var newOrder = _toConsumableArray(existingColumnConfiguration);
    var _newOrder$splice = newOrder.splice(oldIndex, 1),
      _newOrder$splice2 = _slicedToArray(_newOrder$splice, 1),
      movedItem = _newOrder$splice2[0];
    newOrder.splice(newIndex, 0, movedItem);
    updateColumns(newOrder);
  };
  var columns = getHidableColumns(allProcessedColumns);
  var filteredColumns = filterBySearchTerm(searchTerm, columns);
  var handleHideAllColumns = function handleHideAllColumns() {
    var columnsToHideKeys = pluck("key", columns);
    updateColumns(existingColumnConfiguration.map(function (column) {
      return includes(column.key, columnsToHideKeys) ? assoc("isShown", false, column) : column;
    }));
  };
  var handleChange = function handleChange(_ref2) {
    var _ref2$target = _ref2.target,
      dataIndex = _ref2$target.name,
      checked = _ref2$target.checked;
    if (checked) showColumn(dataIndex);else hideColumn(dataIndex);
  };
  var handleSearch = function handleSearch(_ref3) {
    var value = _ref3.target.value;
    return setSearchTerm(value);
  };
  return /*#__PURE__*/jsx(Dropdown, _objectSpread(_objectSpread({
    appendTo: document.body,
    buttonSize: "medium",
    buttonStyle: "text",
    closeOnSelect: false,
    position: "bottom-end",
    onClose: function onClose() {
      return setSearchTerm("");
    }
  }, dropdownProps), {}, {
    children: /*#__PURE__*/jsx(Menu, {
      children: /*#__PURE__*/jsxs("div", {
        className: "neeto-molecules-columns__container",
        "data-cy": "customize-columns-dropdown-container",
        children: [isSearchable && /*#__PURE__*/jsx(Input, _objectSpread({
          className: "px-4 py-2",
          "data-cy": "neeto-ui-columns-search",
          "data-testid": "neeto-ui-columns-search",
          placeholder: t("neetoMolecules.columns.search"),
          prefix: /*#__PURE__*/jsx(Search, {}),
          type: "search",
          value: searchTerm,
          onChange: handleSearch
        }, searchProps)), isEmpty(filteredColumns) && /*#__PURE__*/jsx("span", {
          className: "neeto-ui-flex neeto-ui-flex-col neeto-ui-items-center neeto-ui-p-2",
          children: noColumnMessage
        }), isNotEmpty(filteredColumns) && !searchTerm && /*#__PURE__*/jsx(DndContext, {
          collisionDetection: closestCenter,
          onDragEnd: handleDragEnd,
          children: /*#__PURE__*/jsx(SortableContext, {
            items: pluck("key", filteredColumns),
            strategy: verticalListSortingStrategy,
            children: filteredColumns.map(function (column) {
              return /*#__PURE__*/createElement(Item, {
                checkboxProps: checkboxProps,
                column: column,
                hiddenColumns: hiddenColumns,
                isTableConfigurationFetching: isTableConfigurationFetching,
                key: column.key,
                onToggle: handleChange
              });
            })
          })
        }), isNotEmpty(filteredColumns) && searchTerm && filteredColumns.map(function (_ref4) {
          var key = _ref4.key,
            title = _ref4.title;
          return /*#__PURE__*/jsx(MenuItem, {
            children: /*#__PURE__*/jsx(Label, {
              className: "neeto-ui-flex neeto-ui-w-full hover:neeto-ui-bg-gray-200 neeto-ui-cursor-pointer px-4 py-2",
              htmlFor: key,
              children: /*#__PURE__*/jsx(Checkbox, _objectSpread({
                checked: !hiddenColumns.includes(key),
                "data-cy": "neeto-ui-columns-checkbox",
                id: key,
                label: title,
                name: key,
                onChange: handleChange
              }, checkboxProps))
            })
          }, key);
        }), /*#__PURE__*/jsx(Divider, {}), !!actionBlock && /*#__PURE__*/jsxs(Fragment, {
          children: [actionBlock, /*#__PURE__*/jsx(Divider, {})]
        }), /*#__PURE__*/jsxs("div", {
          className: "flex justify-end gap-2 p-1 pr-3",
          children: [/*#__PURE__*/jsx(Button, {
            "data-cy": "column-visibility-hide-all-button",
            label: t("neetoMolecules.columns.hideAll"),
            style: "tertiary",
            onClick: handleHideAllColumns
          }), /*#__PURE__*/jsx(Button, {
            "data-cy": "column-visibility-reset-button",
            label: t("neetoMolecules.columns.reset"),
            style: "secondary",
            onClick: function onClick() {
              return destroyConfiguration(tableKey);
            }
          })]
        })]
      })
    })
  }));
};
Columns.displayName = "Columns";

export { Columns as C, HIDDEN_COLUMNS_STORAGE_KEY as H, TABLE_CONFIGURATION_QUERY_KEY as T, COLUMNS_ORDER_STORAGE_KEY as a, useTableConfigurations as u };
//# sourceMappingURL=Columns-Bs-Y6jgW.js.map
