"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 smart_block_converter_exports = {};
__export(smart_block_converter_exports, {
  smartBlockConverter: () => smartBlockConverter
});
module.exports = __toCommonJS(smart_block_converter_exports);
var import_v1 = require("./../ricos-schema/legacy/wix/rich_content/v1/index.js");
var import_uncreachable = require("./../_shared/uncreachable.js");
var import_consts = require("./consts.js");
const smartBlockConverter = {
  toPm: {
    types: [import_v1.Node_Type.SMART_BLOCK],
    // @ts-expect-error next node type
    convert: (node, visit) => {
      const data = node.smartBlockData;
      return {
        type: import_v1.Node_Type.SMART_BLOCK,
        attrs: {
          id: node.id,
          type: data?.type ?? import_consts.SMART_BLOCK_DEFAULTS.type,
          columnSize: data?.columnSize ?? import_consts.SMART_BLOCK_DEFAULTS.columnSize,
          orientation: data?.orientation ?? null,
          backgroundColor: data?.backgroundColor ?? null,
          borderColor: data?.borderColor ?? null,
          borderWidth: data?.borderWidth ?? null,
          borderRadius: data?.borderRadius ?? null
        },
        content: visit(node)
      };
    }
  },
  fromPm: {
    types: [import_v1.Node_Type.SMART_BLOCK],
    // @ts-expect-error next node type
    convert: (node, visit) => {
      const { attrs } = node;
      const { id } = attrs;
      return {
        type: import_v1.Node_Type.SMART_BLOCK,
        id,
        smartBlockData: smartBlockDataPerVariant(attrs),
        nodes: visit?.(node)
      };
    }
  }
};
const smartBlockDataPerVariant = (attrs) => {
  const { columnSize, orientation, borderColor, borderWidth, borderRadius } = attrs;
  const type = attrs.type ?? import_consts.SMART_BLOCK_DEFAULTS.type;
  switch (type) {
    case "SOLID_BOXES":
    case "STATS":
    case "BAR_STATS":
    case "CIRCLE_STATS":
    case "SIDE_LINE_TEXT":
    case "TOP_LINE_TEXT":
    case "NUMBERED_BOXES":
    case "OUTLINE_BOXES_WITH_TOP_CIRCLE":
    case "PROCESS_STEPS":
    case "STAR_RATING":
    case "QUOTE_BOXES":
    case "CIRCLE":
    case "PYRAMID":
    case "STAIRCASE":
    case "VERTICAL_FUNNEL":
      return {
        type,
        columnSize: columnSize ?? void 0
      };
    case "SOLID_BOXES_ALTERNATING":
    case "SMALL_BULLETS":
    case "ARROW_BULLETS":
    case "TIMELINE":
    case "MINIMAL_TIMELINE":
    case "PILLS":
      return {
        type,
        columnSize: columnSize ?? void 0,
        orientation: orientation ?? void 0
      };
    case "BIG_BULLETS":
      return {
        type,
        columnSize: columnSize ?? void 0,
        orientation: orientation ?? void 0
      };
    case "SOLID_JOINED_BOXES":
      return {
        type,
        columnSize: columnSize ?? void 0,
        borderColor: borderColor ?? void 0,
        borderWidth: borderWidth ?? void 0,
        borderRadius: borderRadius ?? void 0
      };
    default: {
      (0, import_uncreachable.unreachable)(type);
      return {
        type,
        columnSize: columnSize ?? void 0
      };
    }
  }
};
//# sourceMappingURL=smart-block-converter.js.map
