/**
 * Resolve a public-asset path against Vite's base URL.
 *
 * In dev `import.meta.env.BASE_URL === '/'`, so `assetUrl('/images/foo.png')`
 * returns `/images/foo.png` unchanged. In production the build sets base to
 * `/arrangement/` (or whatever `--mode <slice>` was passed), and the same
 * call returns `/arrangement/images/foo.png` so the bundled assets resolve
 * correctly under the slice subpath.
 *
 * Always pass leading-slash paths — they're relative to the publicDir root.
 */
export const assetUrl = (path: string): string => {
  const base = import.meta.env.BASE_URL;
  const cleanBase = base.endsWith('/') ? base.slice(0, -1) : base;
  const cleanPath = path.startsWith('/') ? path : `/${path}`;
  return `${cleanBase}${cleanPath}`;
};
