import { z } from "zod";
import { dateSchema } from "../habits/contracts";
import { dayNumber } from "../habits/calendar";

export const shareInput = z.object({
  habitIds: z.array(z.string().uuid()).min(1).max(6).refine(ids => new Set(ids).size === ids.length),
  from: dateSchema,
  to: dateSchema,
}).strict().refine(v => v.from <= v.to && dayNumber(v.to) - dayNumber(v.from) < 366, "Choose up to 366 days in chronological order");

export type ShareData = {
  from: string; to: string; timezone: string;
  botAvatarUrl?: string | null;
  habits: {
    name: string; color: string; completed: number; scheduled: number;
    legend: { empty: string; partial: string[]; complete: string };
    days: { date: string; color: string; due: boolean; complete: boolean; ratio: number | null }[];
  }[];
};
export type DiscordConnection = { connected: boolean; name?: string; channelUrl?: string; message?: string };
export type Delivery = { status: "sent" | "uncertain"; messageUrl?: string };
