export const CARPLACE_BASE_PATH = '/carplace'

export function carplaceHref(path = ''): string {
  if (!path || path === '/') return CARPLACE_BASE_PATH
  return `${CARPLACE_BASE_PATH}${path.startsWith('/') ? path : `/${path}`}`
}

export function carplaceCompanyHref(slug: string): string {
  return carplaceHref(`/${encodeURIComponent(slug)}`)
}

export function carplaceVehicleHref(slug: string, vehicleId: string, query?: URLSearchParams | string): string {
  const suffix = typeof query === 'string' ? query : query?.toString()
  return `${carplaceHref(`/${encodeURIComponent(slug)}/vehicles/${encodeURIComponent(vehicleId)}`)}${suffix ? `?${suffix}` : ''}`
}

export function homepageHref(language: 'en' | 'fr' | 'ar'): string {
  return `/${language}`
}
