function getNested(obj: any, path: string): any { return path.split(".").reduce((o, k) => o?.[k], obj); } export function applyDisplayFormat(item: any, format: string): string { if (!item || typeof item !== "object") return String(item ?? ""); return format.replace(/\{([\w.]+)\}/g, (_, key) => { const val = getNested(item, key); return val != null ? String(val) : ""; }); } /** * Resolve a media/image URL against the API base so relative paths * like `/uploads/entity_logos/x.svg` point at the backend origin. * Absolute (http/data/blob) URLs are returned untouched. */ export function resolveMediaUrl(value: string | null | undefined, baseUrl?: string): string | undefined { if (value == null || value === "") return undefined; if (value.startsWith("http") || value.startsWith("data:") || value.startsWith("blob:")) return value; if (value.startsWith("/") && baseUrl) return `${baseUrl.replace(/\/+$/, "")}${value}`; return value; }