export class NotesApi { static async getNotesList() { try { const response = await fetch('/notes_sidebar/list'); const data = await response.json(); if (!response.ok) { throw new Error(data.error || 'Failed to fetch notes list'); } return data.notes || []; } catch (error) { console.error('Error loading notes:', error); throw error; } } static async getNoteContent(noteName) { try { const response = await fetch(`/notes_sidebar/note/${encodeURIComponent(noteName)}`); const data = await response.json(); if (!response.ok) { throw new Error(data.error || 'Failed to fetch note content'); } return data.content || ''; } catch (error) { console.error('Error loading note content:', error); throw error; } } static async saveNote(noteName, content) { try { const response = await fetch(`/notes_sidebar/note/${encodeURIComponent(noteName)}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ content: content }) }); if (!response.ok) { const data = await response.json(); throw new Error(data.error || 'Failed to save note'); } return true; } catch (error) { console.error('Error saving note:', error); throw error; } } static async deleteNote(noteName) { try { const response = await fetch(`/notes_sidebar/note/${encodeURIComponent(noteName)}`, { method: 'DELETE' }); if (!response.ok) { const data = await response.json(); throw new Error(data.error || 'Failed to delete note'); } return true; } catch (error) { console.error('Error deleting note:', error); throw error; } } static async getLoras() { try { const response = await fetch('/notes_sidebar/loras'); const data = await response.json(); if (!response.ok) { throw new Error(data.error || 'Failed to fetch LoRAs list'); } return data.loras || []; } catch (error) { console.error('Error fetching LoRAs:', error); throw error; } } static async getLorasWithMetadata() { try { const response = await fetch('/notes_sidebar/loras_with_metadata'); const data = await response.json(); if (!response.ok) { throw new Error(data.error || 'Failed to fetch LoRAs with metadata'); } return data.loras || []; } catch (error) { console.error('Error fetching LoRAs with metadata:', error); throw error; } } }