import { z } from 'zod';

// 4 — поза sleep (спека сна 4): лежит в спальнике на скамейке парка; старый вьюер её не знает — при выкладке
// перезагрузить вкладки. 3 — у hello.vehicleKit обязательное поле engines (спека звуков транспорта §4.2).
export const PROTOCOL_VERSION = 4;

export const FacingSchema = z.enum(['up', 'down', 'left', 'right']);
export type Facing = z.infer<typeof FacingSchema>;

// Звук на месте (спека фонтана 3.2): источник, привязанный к предмету карты, а не к персонажу.
export const MapSoundTypeSchema = z.enum(['fountain']);
export type MapSoundType = z.infer<typeof MapSoundTypeSchema>;

// Вид звука раздвижной двери (спека звуков дверей §4.1): входная стеклянная или лифтовая; нет поля — дверь молчит.
export const DoorSoundSchema = z.enum(['entrance', 'lift']);
export type DoorSound = z.infer<typeof DoorSoundSchema>;

// Голос мотора машины (спека звуков транспорта §2 п. 4): запись по форме кузова — хэтчбек, седан, кроссовер, спорткар.
export const CarEngineSoundSchema = z.enum(['hatch', 'sedan', 'suv', 'sport']);
export type CarEngineSound = z.infer<typeof CarEngineSoundSchema>;

export const PoseSchema = z.enum(['sit', 'stand', 'play', 'sleep']);
export type Pose = z.infer<typeof PoseSchema>;

// Где подпись персонажа на месте: под спрайтом (по умолчанию) или над головой.
export const LabelPlacementSchema = z.enum(['below', 'above']);
export type LabelPlacement = z.infer<typeof LabelPlacementSchema>;

// idle и needs_input у людей — с 17.11.2026 (спека 2026-11-17-human-idle-needs-input-design.md): перерыв и ожидание ответа в мессенджере.
export const HUMAN_STATUSES = ['online', 'offline', 'meeting', 'idle', 'needs_input'] as const;
export const AGENT_STATUSES = ['working', 'idle', 'needs_input', 'offline'] as const;
export type HumanStatus = (typeof HUMAN_STATUSES)[number];
export type AgentStatus = (typeof AGENT_STATUSES)[number];

export const StatusSchema = z.enum(['online', 'offline', 'meeting', 'working', 'idle', 'needs_input']);
export type Status = z.infer<typeof StatusSchema>;

export const isHumanStatus = (s: Status): s is HumanStatus => (HUMAN_STATUSES as readonly string[]).includes(s);
export const isAgentStatus = (s: Status): s is AgentStatus => (AGENT_STATUSES as readonly string[]).includes(s);
