"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseRepository = void 0;
class BaseRepository {
    db;
    dbManager;
    constructor(dbManager) {
        this.dbManager = dbManager;
        this.db = dbManager.getDatabase();
    }
    calculateSize(value) {
        return Buffer.byteLength(value, 'utf8');
    }
    generateId() {
        // Using crypto.randomUUID() for better performance if available
        if (typeof crypto !== 'undefined' && crypto.randomUUID) {
            return crypto.randomUUID();
        }
        // Fallback to uuid v4 pattern
        return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
            const r = (Math.random() * 16) | 0;
            const v = c === 'x' ? r : (r & 0x3) | 0x8;
            return v.toString(16);
        });
    }
    getCurrentTimestamp() {
        return new Date().toISOString();
    }
}
exports.BaseRepository = BaseRepository;
