'use strict';
import { jsx } from 'react/jsx-runtime';
import { ViewSheet } from '../../view/ViewSheet.js';
import { getResourceUrl } from '../../services/meta-navigations.js';
import { routes } from '../../../../fd-toolbox/routing/routes.js';
import { silentChangeUrl } from '../../../../fd-toolbox/routing/routers.js';
import { getOptionalPropertyValue } from '../../../../fd-toolbox/objects/property-value.js';

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", {
  value,
  configurable: true
});
function BodyExpandPropertyCell({
  cellContext,
  onRefreshItems,
  children
}) {
  const expandInfo = cellContext.internalTableColumn.expandInfo;
  const item = cellContext.row.item;
  const expandedItem = getOptionalPropertyValue(item, expandInfo.expandPropertyName);
  const resourceId = expandedItem?.id;
  const resourceName = expandInfo.resourceMeta.resourceName;
  return /* @__PURE__ */jsx(ViewSheet, {
    id: resourceId,
    resourceName,
    onRefreshItems,
    onEditClick: () => cellContext && silentChangeUrl(getResourceUrl(routes.view, resourceName, resourceId)),
    children
  });
}
__name(BodyExpandPropertyCell, "BodyExpandPropertyCell");

export { BodyExpandPropertyCell as default };
