/**
 * Sticky Note Creation
 *
 * Creates new sticky notes in brain.db.
 *
 * @task T5280
 * @epic T5267
 */
import { getBrainAccessor } from '../store/brain-accessor.js';
import { generateStickyId } from './id.js';
/**
 * Convert database row to StickyNote interface.
 */
function rowToStickyNote(row) {
    return {
        id: row.id,
        content: row.content,
        createdAt: row.createdAt,
        updatedAt: row.updatedAt ?? undefined,
        tags: row.tagsJson ? JSON.parse(row.tagsJson) : [],
        status: row.status,
        convertedTo: row.convertedToJson ? JSON.parse(row.convertedToJson) : undefined,
        color: row.color ?? undefined,
        priority: row.priority ?? undefined,
        sourceType: row.sourceType ?? 'sticky-note',
    };
}
/**
 * Create a new sticky note.
 *
 * @param params - Creation parameters
 * @param projectRoot - Project root path
 * @returns The created sticky note
 */
export async function addSticky(params, projectRoot) {
    const accessor = await getBrainAccessor(projectRoot);
    const id = await generateStickyId(projectRoot);
    const row = await accessor.addStickyNote({
        id,
        content: params.content,
        tagsJson: params.tags ? JSON.stringify(params.tags) : null,
        status: 'active',
        color: params.color ?? null,
        priority: params.priority ?? null,
    });
    return rowToStickyNote(row);
}
//# sourceMappingURL=create.js.map