import { http } from './client'
import type { Tag } from '@/types'

export const tagApi = {
  /**
   * 获取标签列表
   */
  async getTags() {
    return http.get<Tag[]>('/tags')
  },

  /**
   * 重命名标签
   */
  async renameTag(oldName: string, newName: string) {
    return http.put(`/tags/${encodeURIComponent(oldName)}`, { newName })
  },

  /**
   * 删除标签
   */
  async deleteTag(name: string) {
    return http.delete<number>(`/tags/${encodeURIComponent(name)}`)
  },

  /**
   * 合并标签
   */
  async mergeTags(sourceNames: string[], targetName: string) {
    return http.post<number>('/tags/merge', { sourceNames, targetName })
  }
}

