import { jsx as _jsx } from "react/jsx-runtime";
import { get } from "lodash";
import sanitizeHtml from "sanitize-html";
import { css } from "styled-components";
import { truncatedLineStyle } from "./truncatedLineStyle";
export function SanitizeHtml({ result, path, isTruncate = true, }) {
    const hihglithTextLines = result.highlight[path];
    const text = get(result.source, path);
    const sanitizedHTML = sanitizeHtml(text);
    const createMarkup = () => {
        return {
            __html: sanitizedHTML,
        };
    };
    return (_jsx("div", { className: "openk9-container-sanitize", children: _jsx("div", { className: "openk9-container-sanitize-truncate", css: css `
          ${hihglithTextLines && isTruncate ? truncatedLineStyle : ""};
        `, children: _jsx("div", { className: "openk9-container-sanitize-text-style", css: css `
            height: auto;
            word-wrap: ${isTruncate ? "break-word" : ""};
            word-break: ${isTruncate ? "break-word" : ""};
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: inherit;
          `, children: _jsx("div", { dangerouslySetInnerHTML: createMarkup() }) }) }) }));
}
