/** Supported daily post frequency (project timezone). */
export type PostsPerDay = 1 | 2 | 3 | 4 | 5;

export const POSTS_PER_DAY_OPTIONS: PostsPerDay[] = [1, 2, 3, 4, 5];

export function isPostsPerDay(value: unknown): value is PostsPerDay {
  return typeof value === "number" && POSTS_PER_DAY_OPTIONS.includes(value as PostsPerDay);
}

/** Coerce legacy 1|2 or invalid values to a valid schedule count. */
export function normalizePostsPerDay(value: unknown, fallback: PostsPerDay = 2): PostsPerDay {
  if (isPostsPerDay(value)) return value;
  return fallback;
}
