"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createKnowledgeGraph = createKnowledgeGraph;
exports.slugify = slugify;
exports.generateId = generateId;
const graphology_1 = require("graphology");
function createKnowledgeGraph() {
    return new graphology_1.DirectedGraph({
        multi: false,
        allowSelfLoops: false,
    });
}
const crypto_1 = require("crypto");
/**
 * Generate a UUID v4 entity ID.
 * @deprecated Use generateId() for new entities. Legacy slug-based IDs remain valid.
 */
function slugify(title, graph) {
    const base = title
        .toLowerCase()
        .trim()
        .replace(/[^a-z0-9\s-]/g, '')
        .replace(/\s+/g, '-')
        .replace(/-+/g, '-')
        .replace(/^-|-$/g, '');
    if (!base)
        return `note-${Date.now()}`;
    if (!graph.hasNode(base))
        return base;
    let n = 2;
    while (graph.hasNode(`${base}::${n}`))
        n++;
    return `${base}::${n}`;
}
/** Generate a UUID v4 entity ID. */
function generateId() {
    return (0, crypto_1.randomUUID)();
}
