"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const shared_esmBundler = require("../../../../../../@vue/shared/dist/shared.esm-bundler.js");
const constants = require("../constants.js");
const _private = require("../private.js");
const utils = require("../utils.js");
const cell = require("../components/cell.js");
const expandIcon = require("../components/expand-icon.js");
const vue = require("vue");
const get = require("../../../../../../lodash-es/get.js");
const CellRenderer = ({ columns, column, columnIndex, depth, expandIconProps, isScrolling, rowData, rowIndex, style, expandedRowKeys, ns, t, cellProps: _cellProps, expandColumnKey, indentSize, iconSize, rowKey }, { slots }) => {
  const cellStyle = utils.enforceUnit(style);
  if (column.placeholderSign === _private.placeholderSign) return vue.createVNode("div", {
    "class": ns.em("row-cell", "placeholder"),
    "style": cellStyle
  }, null);
  const { cellRenderer, dataKey, dataGetter } = column;
  const cellData = shared_esmBundler.isFunction(dataGetter) ? dataGetter({
    columns,
    column,
    columnIndex,
    rowData,
    rowIndex
  }) : get.default(rowData, dataKey ?? "");
  const extraCellProps = utils.tryCall(_cellProps, {
    cellData,
    columns,
    column,
    columnIndex,
    rowIndex,
    rowData
  });
  const cellProps = {
    class: ns.e("cell-text"),
    columns,
    column,
    columnIndex,
    cellData,
    isScrolling,
    rowData,
    rowIndex
  };
  const columnCellRenderer = utils.componentToSlot(cellRenderer);
  const Cell = columnCellRenderer ? columnCellRenderer(cellProps) : vue.renderSlot(slots, "default", cellProps, () => [vue.createVNode(cell.default, cellProps, null)]);
  const kls = [
    ns.e("row-cell"),
    column.class,
    column.align === constants.Alignment.CENTER && ns.is("align-center"),
    column.align === constants.Alignment.RIGHT && ns.is("align-right")
  ];
  const expandable = rowIndex >= 0 && expandColumnKey && column.key === expandColumnKey;
  const expanded = rowIndex >= 0 && expandedRowKeys.includes(rowData[rowKey]);
  let IconOrPlaceholder;
  const iconStyle = `margin-inline-start: ${depth * indentSize}px;`;
  if (expandable) if (shared_esmBundler.isObject(expandIconProps)) IconOrPlaceholder = vue.createVNode(expandIcon.default, vue.mergeProps(expandIconProps, {
    "class": [ns.e("expand-icon"), ns.is("expanded", expanded)],
    "size": iconSize,
    "expanded": expanded,
    "ariaLabel": t(expanded ? "el.table.collapseRowLabel" : "el.table.expandRowLabel"),
    "style": iconStyle,
    "expandable": true
  }), null);
  else IconOrPlaceholder = vue.createVNode("div", { "style": [iconStyle, `width: ${iconSize}px; height: ${iconSize}px;`].join(" ") }, null);
  return vue.createVNode("div", vue.mergeProps({
    "class": kls,
    "style": cellStyle
  }, extraCellProps, { "role": "cell" }), [IconOrPlaceholder, Cell]);
};
CellRenderer.inheritAttrs = false;
exports.default = CellRenderer;
