import _extends from "@babel/runtime-corejs3/helpers/extends";
import _taggedTemplateLiteral from "@babel/runtime-corejs3/helpers/taggedTemplateLiteral";
var _templateObject;
import React from 'react';
import styled from 'styled-components';
import { icons } from '../common-views';
import { internals } from '../internals';
import { traverseColumn } from '../utils';
import { warnTransformsDeprecated } from './warnTransformsDeprecated';
var HeaderCellWithTips = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n  display: flex;\n  align-items: center;\n\n  .tip-icon-wrapper {\n    margin-left: 2px;\n  }\n\n  .tip-icon {\n    display: flex;\n    fill: currentColor;\n  }\n"])));
/** @deprecated transform 用法已经过时，请使用 pipeline 来对表格进行拓展 */
export function makeTipsTransform(_ref) {
  var Balloon = _ref.Balloon,
    Tooltip = _ref.Tooltip;
  warnTransformsDeprecated('makeTipsTransform');
  return traverseColumn(function (col) {
    var _a;
    if (!((_a = col.features) === null || _a === void 0 ? void 0 : _a.tips)) {
      return col;
    }
    var justifyContent = col.align === 'right' ? 'flex-end' : col.align === 'center' ? 'center' : 'flex-start';
    return _extends(_extends({}, col), {
      title: (/*#__PURE__*/React.createElement(HeaderCellWithTips, {
        style: {
          justifyContent: justifyContent
        }
      }, internals.safeRenderHeader(col), Balloon ? (
      /*#__PURE__*/
      // fusion/hippo
      React.createElement(Balloon, {
        closable: false,
        trigger: /*#__PURE__*/React.createElement("div", {
          className: "tip-icon-wrapper"
        }, /*#__PURE__*/React.createElement(icons.Info, {
          className: "tip-icon"
        }))
      }, col.features.tips)) : (
      /*#__PURE__*/
      // antd
      React.createElement(Tooltip, {
        title: col.features.tips
      }, /*#__PURE__*/React.createElement("div", {
        className: "tip-icon-wrapper"
      }, /*#__PURE__*/React.createElement(icons.Info, {
        className: "tip-icon"
      }))))))
    });
  });
}