import { Decoration_Type } from "./../ricos-schema/next-schema/index.js";
import { Mark_Type } from "./../ricos-types/index.js";
const textColorConverter = {
  fromPm: {
    type: Mark_Type.COLOR_FOREGROUND,
    convert: (mark) => {
      const textColor = mark.attrs?.color;
      if (!textColor) {
        return [];
      }
      return [
        {
          type: Decoration_Type.COLOR,
          colorData: {
            foreground: textColor
          }
        }
      ];
    }
  },
  toPm: {
    type: Decoration_Type.COLOR,
    convert: (decoration) => {
      const { colorData } = decoration;
      const textColor = colorData?.foreground;
      if (!textColor) {
        return void 0;
      }
      return {
        type: Mark_Type.COLOR_FOREGROUND,
        attrs: { color: textColor }
      };
    }
  }
};
const backgroundColorConverter = {
  fromPm: {
    type: Mark_Type.COLOR_BACKGROUND,
    convert: (mark) => {
      const backgroundColor = mark.attrs?.color;
      if (!backgroundColor) {
        return [];
      }
      return [
        {
          type: Decoration_Type.COLOR,
          colorData: { background: backgroundColor }
        }
      ];
    }
  },
  toPm: {
    type: Decoration_Type.COLOR,
    convert: (decoration) => {
      const { colorData } = decoration;
      const backgroundColor = colorData?.background;
      if (!backgroundColor) {
        return void 0;
      }
      return {
        type: Mark_Type.COLOR_BACKGROUND,
        attrs: { color: backgroundColor }
      };
    }
  }
};
export {
  backgroundColorConverter,
  textColorConverter
};
//# sourceMappingURL=color-converter.js.map
