import React, {
  useCallback,
  useEffect,
  useState,
  forwardRef,
  useImperativeHandle,
} from 'react';
import { CnDetailInfo as UICnDetailInfo } from '@cainiaofe/cn-ui-m';
import { batchCalculateTextExprValue, isDesignMode } from '@/common/util/util';
import { dataOriginStatic } from '@/common/util/const';
import isPlainObject from 'lodash/isPlainObject';

const CnDetailInfo = forwardRef((props, ref) => {
  if (!UICnDetailInfo) {
    return null;
  }

  let extraProps = {};
  const { dataOrigin, staticInfo, _context } = props;
  if (dataOrigin === dataOriginStatic && isPlainObject(staticInfo)) {
    extraProps = {
      ...batchCalculateTextExprValue(staticInfo, {
        recordDataSource: {},
        state: _context?.state,
      }),
    };
  }
  const isDesign = isDesignMode(props);
  return <UICnDetailInfo {...extraProps} />;
});
CnDetailInfo.displayName = 'CnDetailInfo';
export default CnDetailInfo;
