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/ToolBarQuickFilter/index.tsx
var ToolBarQuickFilter_exports = {};
__export(ToolBarQuickFilter_exports, {
  default: () => ToolBarQuickFilter_default
});
module.exports = __toCommonJS(ToolBarQuickFilter_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_QuickFilter = __toESM(require("../../../filter/components/QuickFilter"));
var import_useRecordBoardContext = require("../../hooks/useRecordBoardContext");
var FILTER_PARAMS_FIELD = "filter";
var ToolBarQuickFilter = ({
  filterList = [],
  formFiltersPrefix = "",
  size = "large",
  phoneLayout
}) => {
  const ctx = (0, import_useRecordBoardContext.useRecordBoardContext)();
  const { searchParams, onSearch } = ctx;
  const [form] = import_antd.Form.useForm();
  const filterValue = searchParams == null ? void 0 : searchParams[FILTER_PARAMS_FIELD];
  const currentValues = (filterValue == null ? void 0 : filterValue.values) ?? {};
  (0, import_react.useEffect)(() => {
    const next = typeof currentValues === "object" && currentValues !== null ? currentValues : {};
    const byNames = filterList.reduce((acc, item) => {
      var _a;
      const composite = (_a = item == null ? void 0 : item.other) == null ? void 0 : _a.compositeFilterFieldNames;
      if (Array.isArray(composite) && composite.length > 0) {
        for (const field of composite) {
          acc[String(field)] = next[String(field)] ?? void 0;
        }
        return acc;
      }
      const name = item.name ?? item.key;
      if (name != null) acc[String(name)] = next[String(name)] ?? void 0;
      return acc;
    }, {});
    form.setFieldsValue(byNames);
  }, [currentValues, form, filterList]);
  const handleValuesChange = (0, import_react.useCallback)(
    (_, allValues) => {
      if (typeof allValues !== "object" || allValues === null) return;
      const nextFilter = {
        ...filterValue,
        values: { ...currentValues, ...allValues }
      };
      onSearch({ ...searchParams, [FILTER_PARAMS_FIELD]: nextFilter });
    },
    [searchParams, filterValue, currentValues, onSearch]
  );
  if (!Array.isArray(filterList) || filterList.length === 0) {
    return null;
  }
  return /* @__PURE__ */ import_react.default.createElement(
    import_antd.Form,
    {
      form,
      layout: "inline",
      size,
      onValuesChange: handleValuesChange,
      style: { marginRight: 0 },
      className: "record-board-toolbar-quick-filter-form"
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_QuickFilter.default,
      {
        value: { quickFilter: filterList },
        formFiltersPrefix,
        phoneLayout,
        phoneQuickFilterSlot: Boolean(phoneLayout)
      }
    )
  );
};
ToolBarQuickFilter.displayName = "RecordBoard.ToolBarQuickFilter";
var ToolBarQuickFilter_default = ToolBarQuickFilter;
