"use client"

import { createContext, useContext, type ReactNode } from "react"

export const DEFAULT_DRIVE_ROUTE_ROOT = "drive"

const DriveRouteRootContext = createContext(DEFAULT_DRIVE_ROUTE_ROOT)

export function DriveRouteRootProvider({
  routeRoot = DEFAULT_DRIVE_ROUTE_ROOT,
  children,
}: {
  routeRoot?: string
  children: ReactNode
}) {
  return (
    <DriveRouteRootContext.Provider value={routeRoot}>
      {children}
    </DriveRouteRootContext.Provider>
  )
}

export function useDriveRouteRoot(): string {
  return useContext(DriveRouteRootContext)
}

/** Demo shell may override route root via context provider. */
export function useDriveRouteRootFromDemo(): string {
  return useDriveRouteRoot()
}
