import { useCallback, useEffect, useMemo, useState } from "react"; import { ExternalLink, ImageOff, RefreshCw, Send } from "lucide-react"; import { api } from "../api.js"; import { useAuth } from "../App.jsx"; import { Badge, Button, cx, Empty, ErrorNote, fmt, fmtDate, Spinner, Stat, StatCell, StatRow, timeAgo } from "../ui.jsx"; const PLATFORMS = { instagram: { name: "Instagram", color: "#d62976" }, facebook: { name: "Facebook", color: "#1877f2" }, youtube: { name: "YouTube", color: "#ff0000" }, tiktok: { name: "TikTok", color: "#010101" }, gbp: { name: "Google Business", color: "#4285f4" }, linkedin: { name: "LinkedIn", color: "#0a66c2" }, pinterest: { name: "Pinterest", color: "#e60023" }, threads: { name: "Threads", color: "#000000" }, reddit: { name: "Reddit", color: "#ff4500" }, }; const COLS = [["reach", "Reach"], ["views", "Views"], ["likes", "Likes"], ["comments", "Comments"], ["saves", "Saves"], ["shares", "Shares"]]; const SORTS = { newest: "Newest first", interactions: "Most interactions", reach: "Most reach", views: "Most views" }; const PAGE = 50; const isVideo = (m) => /\.(mp4|mov|m4v|webm)$/i.test(String(m || "")); function Thumb({ item }) { const [broken, setBroken] = useState(false); const local = item.media ? `/api/schedule/media?path=${encodeURIComponent(item.media)}` : null; const p = PLATFORMS[item.platform] || { name: item.platform, color: "#6b6e78" }; const box = "size-14 rounded-md shrink-0 overflow-hidden bg-canvas border border-line"; if (!broken && item.thumb) return setBroken(true)} />; if (local && isVideo(item.media)) return