"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var sketch_converter_exports = {};
__export(sketch_converter_exports, {
  sketchConverter: () => sketchConverter
});
module.exports = __toCommonJS(sketch_converter_exports);
var import_next_schema = require("./../../ricos-schema/next-schema/index.js");
var import_ricos_types = require("./../../ricos-types/index.js");
var import_defaults = require("./defaults.js");
const KNOWN_STYLES = new Set(Object.values(import_next_schema.SketchData_Variant));
const isStyle = (value) => typeof value === "string" && KNOWN_STYLES.has(value);
const sketchConverter = {
  fromPm: {
    type: import_ricos_types.Mark_Type.SKETCH,
    convert: (mark) => {
      const style = isStyle(mark.attrs?.style) ? mark.attrs?.style : import_defaults.DEFAULT_STYLE;
      const color = mark.attrs?.color;
      const animate = (0, import_defaults.getExplicitAnimate)(mark.attrs?.animate);
      return [
        {
          type: import_next_schema.Decoration_Type.SKETCH,
          sketchData: {
            variant: style,
            ...typeof color === "string" && { color },
            ...animate !== void 0 && { animate }
          }
        }
      ];
    }
  },
  toPm: {
    type: import_next_schema.Decoration_Type.SKETCH,
    convert: (decoration) => {
      const { sketchData } = decoration;
      if (!sketchData) {
        return void 0;
      }
      const { variant, color } = sketchData;
      const animate = (0, import_defaults.getExplicitAnimate)(sketchData.animate);
      return {
        type: import_ricos_types.Mark_Type.SKETCH,
        attrs: {
          style: variant,
          ...typeof color === "string" && { color },
          ...animate !== void 0 && { animate }
        }
      };
    }
  }
};
//# sourceMappingURL=sketch-converter.js.map
