export function parseTemplateString(str) {
    const results = [];
    const regex = /(\${[^}]+})/g;
    let lastIndex = 0;
    let match;
    while ((match = regex.exec(str)) != null) {
        const startIndex = match.index;
        const endIndex = regex.lastIndex;
        if (startIndex > lastIndex) {
            results.push({
                type: "string",
                value: str.substring(lastIndex, startIndex),
                startIndex: lastIndex,
                endIndex: startIndex,
            });
        }
        // this doesnt really happen, but we've gotta appease the type checker
        const fullExpression = match[1];
        if (!fullExpression) {
            continue;
        }
        // dont want the ${}
        const expressionContent = fullExpression.substring(2, fullExpression.length - 1);
        results.push({
            type: "expression",
            value: expressionContent,
            startIndex,
            endIndex,
        });
        lastIndex = endIndex;
    }
    if (lastIndex < str.length) {
        results.push({
            type: "string",
            value: str.substring(lastIndex),
            startIndex: lastIndex,
            endIndex: str.length,
        });
    }
    if (str.length === 0 && results.length === 0) {
        results.push({ type: "string", value: "", startIndex: 0, endIndex: 0 });
    }
    return results;
}
//# sourceMappingURL=template-strings.js.map