/**
 * Tour Page Schema - Zod validation for tour page forms
 */

import { z } from 'zod';

export const tourPageSchema = z.object({
  project: z.unknown().optional().nullable(),
  title: z.string().max(255, 'Title too long').optional().or(z.literal('')),
  slug: z
    .string()
    .max(255, 'Slug too long')
    .regex(
      /^[a-z0-9_-]*$/i,
      'Slug can only contain letters, numbers, dashes, underscores',
    )
    .optional()
    .or(z.literal('')),
  background_asset: z.unknown().optional().nullable(),
  audio_asset: z.unknown().optional().nullable(),
  is_start_page: z.boolean().default(false),
  sort_order: z.coerce.number().int().min(0).optional().or(z.literal('')),
});

export type TourPageFormData = z.infer<typeof tourPageSchema>;

export const tourPageInitialValues: TourPageFormData = {
  project: null,
  title: '',
  slug: '',
  background_asset: null,
  audio_asset: null,
  is_start_page: false,
  sort_order: '',
};
