export function getAudioUrl(localValue: unknown, type: string): string {
  if (type === 'fileAudioLink') {
    return (localValue as string) ?? '';
  }
  return (localValue as { url?: string })?.url ?? '';
}

export function haveAudioValue(localValue: unknown, type: string): boolean {
  if (type === 'fileAudioLink') {
    return !!localValue;
  }
  return !!(localValue as { url?: string })?.url;
}

export function clearAudioValue(type: string): string | Record<string, never> {
  if (type === 'fileAudioLink') {
    return '';
  }
  return {};
}

export function mapAudioUploadValue(json: { url?: string }, type: string) {
  if (type === 'fileAudioLink') {
    return json.url ?? '';
  }
  return json;
}
