export type Route =
  | { type: 'app' }
  | { type: 'shared'; token: string }
  | { type: 'auth-confirm' }

export function parseRoute(pathname: string = window.location.pathname): Route {
  // /s/{token} — shared document
  const shareMatch = pathname.match(/^\/s\/([a-zA-Z0-9_-]+)$/)
  if (shareMatch) {
    return { type: 'shared', token: shareMatch[1] }
  }

  // /auth/confirm — email confirmation callback
  if (pathname.startsWith('/auth/confirm')) {
    return { type: 'auth-confirm' }
  }

  return { type: 'app' }
}
