export function threadsProfileUrl(username: string, profileUrl?: string) {
  const direct = profileUrl?.trim()
  if (direct) return direct
  const handle = username.trim().replace(/^@+/, '')
  if (!handle) return ''
  return `https://www.threads.net/@${encodeURIComponent(handle)}`
}

export function threadsAuthorPostUrl(author: string | undefined, permalink?: string) {
  if (permalink?.trim()) return permalink.trim()
  return threadsProfileUrl(author ?? '')
}