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

export function createFormsTools(client: AcuityClient) {
  return {
    acuity_list_forms: {
      description: 'List all intake forms',
      inputSchema: z.object({}),
      handler: async () => {
        const forms = await client.listForms();
        return {
          content: [{
            type: 'text',
            text: JSON.stringify(forms, null, 2)
          }]
        };
      }
    },

    acuity_get_form_fields: {
      description: 'Get fields for a specific form',
      inputSchema: z.object({
        formId: z.number().describe('Form ID')
      }),
      handler: async (args: any) => {
        const fields = await client.getFormFields(args.formId);
        return {
          content: [{
            type: 'text',
            text: JSON.stringify(fields, null, 2)
          }]
        };
      }
    },

    acuity_get_intake_form_responses: {
      description: 'Get intake form responses for an appointment',
      inputSchema: z.object({
        appointmentId: z.number().describe('Appointment ID')
      }),
      handler: async (args: any) => {
        const responses = await client.getIntakeFormResponses(args.appointmentId);
        return {
          content: [{
            type: 'text',
            text: JSON.stringify(responses, null, 2)
          }]
        };
      }
    }
  };
}
