import { AcuityClient } from '../clients/acuity.js';

export const labelTools = [
  {
    name: 'acuity_list_labels',
    description: 'List all appointment labels',
    inputSchema: {
      type: 'object',
      properties: {},
    },
    handler: async (args: any, client: AcuityClient) => {
      const labels = await client.getLabels();
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(labels, null, 2),
          },
        ],
      };
    },
  },
  {
    name: 'acuity_get_label',
    description: 'Get a specific label by ID',
    inputSchema: {
      type: 'object',
      properties: {
        id: {
          type: 'number',
          description: 'Label ID',
        },
      },
      required: ['id'],
    },
    handler: async (args: any, client: AcuityClient) => {
      const label = await client.getLabel(args.id);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(label, null, 2),
          },
        ],
      };
    },
  },
  {
    name: 'acuity_create_label',
    description: 'Create a new appointment label',
    inputSchema: {
      type: 'object',
      properties: {
        name: {
          type: 'string',
          description: 'Label name',
        },
        color: {
          type: 'string',
          description: 'Label color (hex code)',
        },
      },
      required: ['name'],
    },
    handler: async (args: any, client: AcuityClient) => {
      const label = await client.createLabel(args);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(label, null, 2),
          },
        ],
      };
    },
  },
  {
    name: 'acuity_update_label',
    description: 'Update an existing label',
    inputSchema: {
      type: 'object',
      properties: {
        id: {
          type: 'number',
          description: 'Label ID',
        },
        name: {
          type: 'string',
          description: 'Updated name',
        },
        color: {
          type: 'string',
          description: 'Updated color',
        },
      },
      required: ['id'],
    },
    handler: async (args: any, client: AcuityClient) => {
      const { id, ...updateParams } = args;
      const label = await client.updateLabel(id, updateParams);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(label, null, 2),
          },
        ],
      };
    },
  },
  {
    name: 'acuity_delete_label',
    description: 'Delete a label',
    inputSchema: {
      type: 'object',
      properties: {
        id: {
          type: 'number',
          description: 'Label ID to delete',
        },
      },
      required: ['id'],
    },
    handler: async (args: any, client: AcuityClient) => {
      await client.deleteLabel(args.id);
      return {
        content: [
          {
            type: 'text',
            text: `Label ${args.id} deleted successfully`,
          },
        ],
      };
    },
  },
];
