/**
 * @license MIT
 * author: Cube Dev Team
 * @cube-dev/ui-kit v0.0.0-canary-032998c
 * Released under the MIT license.
 */

import { jsx as _jsx } from "react/jsx-runtime";
import { diffLines } from 'diff';
import { PrismCode } from '../PrismCode/PrismCode.js';
export function PrismDiffCode({ original, modified, ...props }) {
    // Generate the diff string
    const diff = diffLines(original, modified);
    const diffString = diff
        .map((part) => {
        const value = part.value.trimEnd();
        if (part.added) {
            return value
                .split('\n')
                .map((val) => {
                return val ? `+${val}` : '';
            })
                .join('\n');
        }
        if (part.removed) {
            return value
                .split('\n')
                .map((val) => {
                return val ? `-${val}` : '';
            })
                .join('\n');
        }
        return value
            .split('\n')
            .map((val) => {
            return val ? ` ${val}` : '';
        })
            .join('\n');
    })
        .join('\n');
    return _jsx(PrismCode, { code: diffString, ...props });
}

        