import { createContext, type PropsWithChildren, useContext } from 'react'
import {
getDeviceModelImageUrl,
getDeviceModelName,
} from 'lib/seam/components/SupportedDevices/device-models.js'
import type { DeviceModelSummary } from 'lib/seam/ecosystem/types.js'
import { useEcosystemDeviceModelSummaries } from 'lib/seam/ecosystem/use-ecosystem-device-model-summaries.js'
import { getRequirementKinds } from './presentation.js'
const AccessoryContext = createContext<{
models: DeviceModelSummary[]
isLoading: boolean
isError: boolean
} | null>(null)
/** One batched lookup per catalog, shared by every expanded provider. */
export function AccessoryCatalog({
slugs,
children,
}: PropsWithChildren<{ slugs: string[] }>): JSX.Element {
const { deviceModels, isLoading, isError } = useEcosystemDeviceModelSummaries(
{
slugs,
enabled: slugs.length > 0,
}
)
return (
{label}
{catalog.isLoading ? (Loading accessories…
) : ( <> {models.length > 0 && (Some accessory details couldn’t be loaded.
)} > )}