import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import * as React from 'react';
const RecursiveTranslation = ({ elements, translationString })=>{
    const regex = /(<[^>]+>.*?<\/[^>]+>)/g;
    const sections = translationString.split(regex);
    return /*#__PURE__*/ _jsxDEV("span", {
        children: sections.map((section, index)=>{
            if (elements && section.startsWith('<') && section.endsWith('>')) {
                const elementKey = section[1];
                const Element = elements[elementKey];
                if (Element) {
                    const regex = new RegExp(`<${elementKey}>(.*?)<\/${elementKey}>`, 'g');
                    const children = section.replace(regex, (_, group)=>group);
                    return /*#__PURE__*/ _jsxDEV(Element, {
                        children: /*#__PURE__*/ _jsxDEV(RecursiveTranslation, {
                            translationString: children
                        }, void 0, false, {
                            fileName: "src/elements/Translation/index.tsx",
                            lineNumber: 25,
                            columnNumber: 17
                        }, this)
                    }, index, false, {
                        fileName: "src/elements/Translation/index.tsx",
                        lineNumber: 24,
                        columnNumber: 15
                    }, this);
                }
            }
            return section;
        })
    }, void 0, false, {
        fileName: "src/elements/Translation/index.tsx",
        lineNumber: 13,
        columnNumber: 5
    }, this);
};
export const Translation = ({ elements, i18nKey, t, variables })=>{
    const stringWithVariables = t(i18nKey, variables || {});
    if (!elements) {
        return stringWithVariables;
    }
    return /*#__PURE__*/ _jsxDEV(RecursiveTranslation, {
        elements: elements,
        translationString: stringWithVariables
    }, void 0, false, {
        fileName: "src/elements/Translation/index.tsx",
        lineNumber: 51,
        columnNumber: 10
    }, this);
};

//# sourceMappingURL=index.js.map