"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "renderCodeRows", {
    enumerable: true,
    get: function() {
        return renderCodeRows;
    }
});
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
const _reactsyntaxhighlighter = require("react-syntax-highlighter");
const _CodeAreatokens = require("../CodeArea.tokens");
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
const isLineNumberNode = (node)=>Array.isArray(node?.properties?.className) && node?.properties?.className.includes('linenumber');
const renderCodeRows = ({ rows, stylesheet, useInlineStyles })=>rows.map((row, rowIndex)=>{
        const children = row.children || [];
        const [firstChild, ...restChildren] = children;
        const hasLineNumber = isLineNumberNode(firstChild);
        const codeChildren = hasLineNumber ? restChildren : children;
        const lineClassName = hasLineNumber ? _CodeAreatokens.classes.line : `${_CodeAreatokens.classes.line} ${_CodeAreatokens.classes.lineWithoutNumber}`;
        return /*#__PURE__*/ _react.default.createElement("span", {
            key: `code-line-${rowIndex}`,
            className: lineClassName
        }, hasLineNumber && (0, _reactsyntaxhighlighter.createElement)({
            node: firstChild,
            stylesheet,
            useInlineStyles,
            key: `line-number-${rowIndex}`
        }), /*#__PURE__*/ _react.default.createElement("span", {
            className: _CodeAreatokens.classes.lineContent
        }, codeChildren.map((node, nodeIndex)=>(0, _reactsyntaxhighlighter.createElement)({
                node,
                stylesheet,
                useInlineStyles,
                key: `line-${rowIndex}-segment-${nodeIndex}`
            }))));
    });
