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/pisellDataSourceContainer/components/ColumnsSetting/index.tsx
var ColumnsSetting_exports = {};
__export(ColumnsSetting_exports, {
  COLUMNS_SHARED_STATE_KEYS: () => COLUMNS_SHARED_STATE_KEYS,
  default: () => ColumnsSetting_default
});
module.exports = __toCommonJS(ColumnsSetting_exports);
var import_react = __toESM(require("react"));
var import_withContainer = __toESM(require("../../utils/withContainer"));
var import_ColumnsSetting = __toESM(require("../../../table/Actions/component/ColumnsSetting"));
var import_utils = require("./utils");
var COLUMNS_SHARED_STATE_KEYS = {
  columnsValue: (instanceId) => `${instanceId}:columns:value`,
  columnsChange: (instanceId) => `${instanceId}:columns:change`
};
var WithColumnsSetting = (0, import_react.forwardRef)(
  (props, ref) => {
    const { refManager, scopeId = "table", __id } = props;
    const [value, setValue] = (0, import_react.useState)([]);
    (0, import_react.useImperativeHandle)(ref, () => ({}), []);
    (0, import_react.useEffect)(() => {
      const unsubscribe = refManager.subscribeSharedState(
        COLUMNS_SHARED_STATE_KEYS.columnsValue(scopeId),
        setValue
      );
      return unsubscribe;
    }, [refManager, scopeId]);
    const onChange = (newValue) => {
      const typedValue = newValue;
      setValue(typedValue);
      refManager.setSharedState(
        COLUMNS_SHARED_STATE_KEYS.columnsChange(scopeId),
        typedValue
      );
      if (__id) {
        (0, import_utils.saveColumnSettingToLocal)({
          componentId: __id,
          columnSetting: typedValue.map((col, index) => ({
            key: col.key,
            dataIndex: col.dataIndex,
            title: col.title,
            titleString: col.titleString,
            isShow: col.isShow,
            sortIndex: col.sortIndex ?? index,
            fixed: col.fixed
          }))
        });
      }
    };
    return /* @__PURE__ */ import_react.default.createElement(import_ColumnsSetting.default, { value, onChange });
  }
);
var ColumnsSetting_default = (0, import_withContainer.default)(WithColumnsSetting, "columnsSetting");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  COLUMNS_SHARED_STATE_KEYS
});
