"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializerTokens = void 0;
const const_1 = require("./const.js");
exports.serializerTokens = {
    [const_1.ListNode.ListItem]: (state, node) => {
        state.renderContent(node);
    },
    [const_1.ListNode.BulletList]: (state, node) => {
        state.renderList(node, '  ', (_i, li) => {
            const markup = getMarkup({ item: li, list: node, type: 'bullet' });
            return markup + ' ';
        });
    },
    [const_1.ListNode.OrderedList]: (state, node) => {
        const start = node.attrs[const_1.ListsAttr.Order] || 1;
        const maxW = String(start + node.childCount - 1).length;
        const space = state.repeat(' ', maxW + 2);
        state.renderList(node, space, (i, li) => {
            const nStr = String(start + i);
            const markup = getMarkup({ item: li, list: node, type: 'ordered' });
            return state.repeat(' ', maxW - nStr.length) + nStr + markup + ' ';
        });
    },
};
function getMarkup({ item, list, type, }) {
    const defs = const_1.Markup[type];
    let value = item.attrs[const_1.ListsAttr.Markup];
    if (!defs.values.includes(value))
        value = list.attrs[const_1.ListsAttr.Markup];
    if (!defs.values.includes(value))
        value = defs.default;
    return value;
}
//# sourceMappingURL=serializer.js.map
