import s from "../components/data-cell-content/DataCellContent.js";
import d from "react";
import o from "../../table/utils/getNestedValue.js";
function y(g) {
  return g.map((e) => ({
    // Use dataIndex as accessorKey
    accessorKey: e.dataIndex,
    id: e.key,
    // Ensure we use the key as the column ID
    // Use title as header
    header: e.title,
    // Convert render function to cell renderer if it exists
    cell: e.render ? (r) => {
      var n;
      const t = r.getValue(), i = r.row.original, a = (n = e.render) == null ? void 0 : n.call(e, t, i, r.row.index);
      return typeof a == "string" || typeof a == "number" ? d.createElement(s, { text: a.toString(), align: e.align }) : a;
    } : (r) => {
      const t = r.getValue();
      return typeof t == "string" || typeof t == "number" ? d.createElement(s, { text: t.toString(), align: e.align }) : t;
    },
    // Pass through width if it exists
    ...e.width !== void 0 ? { size: e.width } : {},
    // Default size if not specified
    // Add sorting configuration if sorter exists
    ...e.sorter ? {
      enableSorting: !0,
      sortingFn: ((r, t) => {
        if (typeof e.sorter == "boolean") {
          const a = o(r.original, e.dataIndex) ?? "", n = o(t.original, e.dataIndex) ?? "";
          return a < n ? -1 : a > n ? 1 : 0;
        }
        const i = e.sorter;
        return i(r.original, t.original);
      })
    } : {},
    // Add meta information for styling and sorting configuration
    meta: {
      className: e.className,
      align: e.align,
      defaultSortOrder: e.defaultSortOrder
    }
  }));
}
export {
  y as default
};
//# sourceMappingURL=convertToColumnDef.js.map
