"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 collapsible_list_converters_exports = {};
__export(collapsible_list_converters_exports, {
  collapsibleItemBodyConverter: () => collapsibleItemBodyConverter,
  collapsibleItemConverter: () => collapsibleItemConverter,
  collapsibleItemTitleConverter: () => collapsibleItemTitleConverter,
  collapsibleListConverter: () => collapsibleListConverter
});
module.exports = __toCommonJS(collapsible_list_converters_exports);
var import_v1 = require("./../ricos-schema/legacy/wix/rich_content/v1/index.js");
const collapsibleListConverter = {
  toPm: {
    types: [import_v1.Node_Type.COLLAPSIBLE_LIST],
    // @ts-ignore $TSFixMe
    convert: (node, visit) => ({
      type: import_v1.Node_Type.COLLAPSIBLE_LIST,
      attrs: {
        ...node.collapsibleListData,
        id: node.id
      },
      content: node.nodes.map((collapsibleItem, index) => {
        const expandState = node.collapsibleListData?.initialExpandedItems;
        return {
          type: import_v1.Node_Type.COLLAPSIBLE_ITEM,
          attrs: {
            id: collapsibleItem.id,
            isExpanded: expandState === import_v1.CollapsibleListData_InitialExpandedItems.ALL || index === 0 && expandState === import_v1.CollapsibleListData_InitialExpandedItems.FIRST,
            expandOnlyOne: !!node.collapsibleListData?.expandOnlyOne
          },
          content: visit(collapsibleItem)
        };
      })
    })
  },
  fromPm: {
    types: [import_v1.Node_Type.COLLAPSIBLE_LIST],
    // @ts-ignore $TSFixMe
    convert: (node, visit) => {
      const { attrs = {} } = node;
      const { id, ...collapsibleListData } = attrs;
      return {
        type: import_v1.Node_Type.COLLAPSIBLE_LIST,
        id,
        nodes: visit(node),
        collapsibleListData: {
          ...collapsibleListData,
          expandOnlyOne: collapsibleListData.expandOnlyOne || void 0
        }
      };
    }
  }
};
const collapsibleItemConverter = {
  toPm: {
    types: [import_v1.Node_Type.COLLAPSIBLE_ITEM],
    // @ts-ignore $TSFixMe
    convert: (node, visit) => ({
      type: import_v1.Node_Type.COLLAPSIBLE_ITEM,
      attrs: {
        id: node.id
      },
      content: visit(node)
    })
  },
  fromPm: {
    types: [import_v1.Node_Type.COLLAPSIBLE_ITEM],
    // @ts-ignore $TSFixMe
    convert: (node, visit) => {
      const { attrs = {} } = node;
      const { id } = attrs;
      return {
        type: import_v1.Node_Type.COLLAPSIBLE_ITEM,
        id,
        nodes: visit(node)
      };
    }
  }
};
const collapsibleItemTitleConverter = {
  toPm: {
    types: [import_v1.Node_Type.COLLAPSIBLE_ITEM_TITLE],
    // @ts-ignore $TSFixMe
    convert: (node, visit) => ({
      type: import_v1.Node_Type.COLLAPSIBLE_ITEM_TITLE,
      attrs: {
        id: node.id
      },
      content: visit(node)
    })
  },
  fromPm: {
    types: [import_v1.Node_Type.COLLAPSIBLE_ITEM_TITLE],
    // @ts-ignore $TSFixMe
    convert: (node, visit) => {
      const { attrs = {} } = node;
      const { id } = attrs;
      return {
        type: import_v1.Node_Type.COLLAPSIBLE_ITEM_TITLE,
        id,
        nodes: visit(node)
      };
    }
  }
};
const collapsibleItemBodyConverter = {
  toPm: {
    types: [import_v1.Node_Type.COLLAPSIBLE_ITEM_BODY],
    // @ts-ignore $TSFixMe
    convert: (node, visit) => ({
      type: import_v1.Node_Type.COLLAPSIBLE_ITEM_BODY,
      attrs: {
        id: node.id
      },
      content: visit(node)
    })
  },
  fromPm: {
    types: [import_v1.Node_Type.COLLAPSIBLE_ITEM_BODY],
    // @ts-ignore $TSFixMe
    convert: (node, visit) => {
      const { attrs = {} } = node;
      const { id } = attrs;
      return {
        type: import_v1.Node_Type.COLLAPSIBLE_ITEM_BODY,
        id,
        nodes: visit(node)
      };
    }
  }
};
//# sourceMappingURL=collapsible-list-converters.js.map
