import { z } from 'zod';

// Token param validation
export const profileTokenSchema = z.object({
  token: z.string().min(32).max(128),
});

// Self-update — only these fields are editable by the contact
export const profileSelfUpdateSchema = z.object({
  displayName: z.string().min(1).max(200).optional(),
  firstName: z.string().max(100).optional().nullable(),
  lastName: z.string().max(100).optional().nullable(),
  email: z.string().email().max(200).optional().nullable().or(z.literal('')),
  phone: z.string().max(30).optional().nullable(),
  emailOptOut: z.boolean().optional(),
  smsOptOut: z.boolean().optional(),
  address: z.string().min(1).max(500).optional().nullable().or(z.literal('')),
});

// Activity query params
export const profileActivitySchema = z.object({
  page: z.coerce.number().int().positive().default(1),
  limit: z.coerce.number().int().positive().max(50).default(20),
});

// Password verification for protected profile links
export const profilePasswordSchema = z.object({
  password: z.string().min(1).max(128),
});

export type ProfilePasswordInput = z.infer<typeof profilePasswordSchema>;
export type ProfileSelfUpdateInput = z.infer<typeof profileSelfUpdateSchema>;
export type ProfileActivityInput = z.infer<typeof profileActivitySchema>;
