import { createVNode as _createVNode } from "vue";
import { CheckOutlined } from "@ant-design/icons-vue";
import { arrayType, boolType, funcType, stringType } from "@antdv/pro-utils";
import { Tooltip } from "ant-design-vue";
import { defineComponent } from "vue";
const Tag = defineComponent({
  name: "Tag",
  props: {
    color: stringType().isRequired,
    check: boolType().isRequired,
    className: stringType(),
    onClick: funcType()
  },
  setup(props) {
    return () => {
      return _createVNode("div", {
        "class": props.className,
        "onClick": props.onClick,
        "style": {
          backgroundColor: props.color
        }
      }, [props.check ? _createVNode(CheckOutlined, null, null) : ""]);
    };
  }
});
const themeColorProps = {
  colorList: arrayType(),
  prefixCls: stringType().isRequired,
  value: stringType().isRequired,
  onChange: funcType().isRequired,
  formatMessage: funcType().isRequired,
  hashId: stringType().isRequired
};
const ThemeColor = defineComponent({
  name: "ThemeColor",
  props: themeColorProps,
  setup(props) {
    return () => {
      const {
        value,
        colorList,
        onChange,
        prefixCls,
        formatMessage,
        hashId
      } = props;
      if (!colorList || (colorList == null ? void 0 : colorList.length) < 1) {
        return null;
      }
      const baseClassName = `${prefixCls}-theme-color`;
      return _createVNode("div", {
        "class": `${baseClassName} ${hashId}`.trim()
      }, [colorList == null ? void 0 : colorList.map(({
        key,
        color,
        title
      }) => {
        if (!key) return null;
        return _createVNode(Tooltip, {
          "key": color,
          "title": title != null ? title : formatMessage({
            id: `app.setting.themecolor.${key}`
          })
        }, {
          default: () => [_createVNode(Tag, {
            "className": `${baseClassName}-block ${hashId}`.trim(),
            "color": color,
            "check": value === color,
            "onClick": () => onChange && onChange(color)
          }, null)]
        });
      })]);
    };
  }
});
export {
  ThemeColor,
  themeColorProps
};
