export function chunksToUIChunks(chunks) {
    const ignoredIndexes = [];
    const waitingMessage = {
        id: 'waitingMessage',
        type: 'waitingMessage',
        items: []
    };
    const parsedChunks = [
        waitingMessage
    ];
    chunks.forEach((chunk, i)=>{
        if (chunk.type === 'text') {
            waitingMessage.items.push(chunk);
        } else if (chunk.type === 'skeletonGroup') {
            chunk.items.forEach((item)=>{
                const chunkIndex = chunks.findIndex((x)=>x.id === item.id);
                if (chunkIndex !== -1) {
                    ignoredIndexes.push(chunkIndex);
                    parsedChunks.push(chunks[chunkIndex]);
                } else {
                    parsedChunks.push({
                        ...item,
                        type: 'skeleton',
                        forType: item.type
                    });
                }
            });
        } else if (!ignoredIndexes.includes(i)) {
            parsedChunks.push(chunk);
        }
    });
    if (ignoredIndexes.length > 0) {
        // remove waiting text
        return parsedChunks.filter((x)=>x !== waitingMessage);
    }
    return parsedChunks;
}

//# sourceMappingURL=utils.js.map