import type { MarkerEntry } from "@/types";

export interface BookmarkRailItem {
  marker: MarkerEntry;
}

export function layoutBookmarkRail(markers: MarkerEntry[]): BookmarkRailItem[] {
  return [...markers]
    .sort((a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime())
    .map((marker) => ({ marker }));
}

export function truncateRailPreview(text: string, max = 120): string {
  const t = text.trim();
  if (t.length <= max) return t;
  return `${t.slice(0, max)}…`;
}
