import { __rest, __assign } from '../../node_modules/tslib/tslib.es6.js';
import React from 'react';
import { Text } from '@chakra-ui/react';

var HighlightedText = function (_a) {
    var text = _a.text, _b = _a.highlightIndices, highlightIndices = _b === void 0 ? [] : _b, textProps = __rest(_a, ["text", "highlightIndices"]);
    if (highlightIndices.length === 0)
        return (React.createElement(Text, __assign({ as: "span" }, textProps), text));
    var result = [];
    var currentIndex = 0;
    for (var _i = 0, highlightIndices_1 = highlightIndices; _i < highlightIndices_1.length; _i++) {
        var _c = highlightIndices_1[_i], start = _c[0], end = _c[1];
        // Append the non-matching part
        result.push(React.createElement(Text, __assign({ key: "non-highlight-".concat(currentIndex, "-").concat(start, "-").concat(text), as: "span" }, textProps), text.substring(currentIndex, start)));
        // Append the matching part
        result.push(React.createElement(Text, __assign({ key: "highlight-".concat(start, "-").concat(end + 1, "-").concat(text), as: "u", fontWeight: "bold" }, textProps), text.substring(start, end + 1)));
        currentIndex = end + 1;
    }
    // Append the remaining non-matching part
    result.push(React.createElement(Text, __assign({ key: "non-highlight-end-".concat(text), as: "span" }, textProps), text.substring(currentIndex)));
    return (React.createElement(Text, __assign({ as: "span" }, textProps), result));
};

export { HighlightedText as default };
//# sourceMappingURL=HighlightedText.js.map
