import { Decoration_Type, SketchData_Variant } from "./../../ricos-schema/next-schema/index.js";
import { Mark_Type } from "./../../ricos-types/index.js";
import { DEFAULT_STYLE, getExplicitAnimate } from "./defaults.js";
const KNOWN_STYLES = new Set(Object.values(SketchData_Variant));
const isStyle = (value) => typeof value === "string" && KNOWN_STYLES.has(value);
const sketchConverter = {
  fromPm: {
    type: Mark_Type.SKETCH,
    convert: (mark) => {
      const style = isStyle(mark.attrs?.style) ? mark.attrs?.style : DEFAULT_STYLE;
      const color = mark.attrs?.color;
      const animate = getExplicitAnimate(mark.attrs?.animate);
      return [
        {
          type: Decoration_Type.SKETCH,
          sketchData: {
            variant: style,
            ...typeof color === "string" && { color },
            ...animate !== void 0 && { animate }
          }
        }
      ];
    }
  },
  toPm: {
    type: Decoration_Type.SKETCH,
    convert: (decoration) => {
      const { sketchData } = decoration;
      if (!sketchData) {
        return void 0;
      }
      const { variant, color } = sketchData;
      const animate = getExplicitAnimate(sketchData.animate);
      return {
        type: Mark_Type.SKETCH,
        attrs: {
          style: variant,
          ...typeof color === "string" && { color },
          ...animate !== void 0 && { animate }
        }
      };
    }
  }
};
export {
  sketchConverter
};
//# sourceMappingURL=sketch-converter.js.map
