import { definePmNodeConverter } from "./../../pm-converters/types.js";
import { stripCheckedFromListItemNodes } from "./../../ricos-common-plugins/list-item/strip-checked-from-list-item-nodes.js";
import { Node_Type } from "./../../ricos-schema/next-schema/index.js";
const bulletedListDataDefaults = { indentation: 0, offset: 0 };
const bulletedListConverter = definePmNodeConverter({
  toPm: {
    types: [Node_Type.BULLETED_LIST],
    convert: (node, visit) => {
      const dataWithDefaults = Object.entries(bulletedListDataDefaults).reduce((acc, [key, defaultValue]) => {
        acc[key] = node.bulletedListData?.[key] ?? defaultValue;
        return acc;
      }, {});
      return {
        type: Node_Type.BULLETED_LIST,
        attrs: {
          ...dataWithDefaults,
          id: node.id
        },
        content: visit?.(node)
      };
    }
  },
  fromPm: {
    types: [Node_Type.BULLETED_LIST],
    convert: (node, visit) => {
      const { attrs = {} } = node;
      const { id, ...data } = attrs;
      return {
        type: Node_Type.BULLETED_LIST,
        id,
        nodes: stripCheckedFromListItemNodes(visit?.(node) ?? []),
        bulletedListData: Object.keys(data).reduce((acc, key) => {
          if (data[key] !== bulletedListDataDefaults[key]) {
            acc[key] = data[key];
          }
          return acc;
        }, {})
      };
    }
  }
});
export {
  bulletedListConverter
};
//# sourceMappingURL=bulleted-list-converter.js.map
