export function makeRows(operations) {
    const revisionsAndSkips = [];
    const seenDays = new Set();
    for (const operation of operations) {
        if (!operation.timestampUtcMs)
            continue;
        const day = operation.timestampUtcMs.split("T")[0];
        if (!seenDays.has(day)) {
            seenDays.add(day);
            revisionsAndSkips.push({
                type: "day",
                height: 32,
                timestampUtcMs: day,
            });
        }
        revisionsAndSkips.push({
            type: "revision",
            height: 46,
            operationIndex: operation.index,
            eventId: operation.id ?? "EVENT_ID_NOT_FOUND",
            stateHash: operation.hash,
            operationType: operation.action.type,
            operationInput: operation.action.input ?? {},
            address: operation.action?.context?.signer?.user.address,
            chainId: operation.action?.context?.signer?.user.chainId,
            timestampUtcMs: operation.timestampUtcMs,
            signatures: makeSignatures(operation.action?.context?.signer?.signatures ?? []),
            errors: operation.error ? [operation.error] : undefined,
        });
        if (operation.skip > 0) {
            revisionsAndSkips.push({
                type: "skip",
                height: 34,
                operationIndex: operation.index,
                skipCount: operation.skip,
                timestampUtcMs: operation.timestampUtcMs,
            });
        }
    }
    return revisionsAndSkips;
}
export function getUniqueDatesInOrder(operations) {
    const dates = new Set();
    for (const operation of operations) {
        if (!operation.timestampUtcMs)
            continue;
        const date = operation.timestampUtcMs.split("T")[0];
        dates.add(date);
    }
    return Array.from(dates).sort((a, b) => new Date(b).getTime() - new Date(a).getTime());
}
function makeSignatureFromSignatureArray(signatureArray) {
    const [signerAddress, hash, prevStateHash, signatureBytes] = signatureArray;
    return {
        signerAddress,
        hash,
        prevStateHash,
        signatureBytes,
        isVerified: true,
    };
}
function makeSignatures(signaturesArray) {
    return signaturesArray?.map(makeSignatureFromSignatureArray);
}
//# sourceMappingURL=utils.js.map