var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/pisellRecordBoard/shellFrame/ToolBarReset/index.tsx
var ToolBarReset_exports = {};
__export(ToolBarReset_exports, {
  default: () => ToolBarReset_default
});
module.exports = __toCommonJS(ToolBarReset_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_icons = require("@ant-design/icons");
var import_utils = require("@pisell/utils");
var import_useRecordBoardContext = require("../../hooks/useRecordBoardContext");
var import_locales = require("../../../../locales");
var import_index = require("./index.less");
function getResetButtonText() {
  const key = "pisell2.recordBoard.toolbar.reset";
  const u = import_utils.locales.getText(key);
  return u && u !== key ? u : (0, import_locales.getText)(key) || (0, import_locales.getText)("record-board-toolbar-reset");
}
var FILTER_PARAMS_FIELD = "filter";
var SORT_PARAMS_FIELD = "sort";
var ToolBarReset = ({
  size = "large",
  type = "default",
  children
}) => {
  const defaultResetText = getResetButtonText();
  const { searchParams, onSearch, onReset, setFilterResetKey } = (0, import_useRecordBoardContext.useRecordBoardContext)();
  const handleReset = (0, import_react.useCallback)(() => {
    setFilterResetKey == null ? void 0 : setFilterResetKey((prev) => prev + 1);
    const currentFilter = searchParams == null ? void 0 : searchParams[FILTER_PARAMS_FIELD];
    const nextParams = {
      ...searchParams,
      [FILTER_PARAMS_FIELD]: {
        ...currentFilter,
        quickFilter: [],
        otherFilter: (currentFilter == null ? void 0 : currentFilter.otherFilter) ?? [],
        values: {}
      },
      [SORT_PARAMS_FIELD]: void 0
    };
    onSearch(nextParams);
    onReset == null ? void 0 : onReset();
  }, [searchParams, onSearch, onReset, setFilterResetKey]);
  return /* @__PURE__ */ import_react.default.createElement(
    import_antd.Button,
    {
      className: "record-board-toolbar-reset",
      type,
      icon: /* @__PURE__ */ import_react.default.createElement(import_icons.ReloadOutlined, null),
      onClick: handleReset,
      size
    },
    children ?? defaultResetText
  );
};
ToolBarReset.displayName = "RecordBoard.ToolBarReset";
var ToolBarReset_default = ToolBarReset;
