'use strict';
import { c } from 'react/compiler-runtime';
import { jsx } from 'react/jsx-runtime';
import { useState, useEffect } from 'react';
import { ViewSheet } from '../../view/ViewSheet.js';
import { findAndSetCustomViewCellAction } from './ViewCell.funcs.js';

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", {
  value,
  configurable: true
});
function ViewCell(t0) {
  const $ = c(9);
  const {
    cellContext,
    children,
    onRefreshResources,
    onViewClick
  } = t0;
  const [customAction, setCustomAction] = useState();
  let t1;
  let t2;
  if ($[0] !== cellContext) {
    t1 = () => {
      findAndSetCustomViewCellAction(cellContext, setCustomAction);
    };
    t2 = [cellContext];
    $[0] = cellContext;
    $[1] = t1;
    $[2] = t2;
  } else {
    t1 = $[1];
    t2 = $[2];
  }
  useEffect(t1, t2);
  let t3;
  if ($[3] !== cellContext || $[4] !== children || $[5] !== customAction || $[6] !== onRefreshResources || $[7] !== onViewClick) {
    t3 = customAction ? jsx("div", {
      onClick: () => customAction.onCellAction?.(cellContext),
      children
    }) : jsx(ViewSheet, {
      id: cellContext.row.item.id,
      resourceName: cellContext.tableInstance.uiResourceMeta?.resourceMeta.resourceName,
      onRefreshItems: onRefreshResources,
      onEditClick: onViewClick,
      children
    });
    $[3] = cellContext;
    $[4] = children;
    $[5] = customAction;
    $[6] = onRefreshResources;
    $[7] = onViewClick;
    $[8] = t3;
  } else {
    t3 = $[8];
  }
  return t3;
}
__name(ViewCell, "ViewCell");

export { ViewCell };
