import { type Atom, type ExtractAtomArgs, type ExtractAtomResult, type ExtractAtomValue, type PrimitiveAtom, type SetStateAction, useAtom, type WritableAtom, } from "jotai" import type * as React from "react" type SetAtom = (...args: Args) => Result export function WithAtom(props: { atom: WritableAtom children: ( value: Awaited, setAtom: SetAtom, ) => React.ReactNode }): React.ReactNode export function WithAtom(props: { atom: PrimitiveAtom children: ( value: Awaited, setAtom: SetAtom<[SetStateAction], void>, ) => React.ReactNode }): React.ReactNode export function WithAtom(props: { atom: Atom children: (value: Awaited, setAtom: never) => React.ReactNode }): React.ReactNode export function WithAtom< AtomType extends WritableAtom, >(props: { atom: AtomType children: ( value: Awaited>, setAtom: SetAtom< ExtractAtomArgs, ExtractAtomResult >, ) => React.ReactNode }): React.ReactNode export function WithAtom>(props: { atom: AtomType children: ( value: Awaited>, setAtom: never, ) => React.ReactNode }): React.ReactNode export function WithAtom({ atom, children, }: { atom: Atom | WritableAtom children: ( value: Awaited, setAtom: SetAtom | never, ) => React.ReactNode }) { const [value, setAtom] = useAtom(atom as WritableAtom) return children(value, setAtom) }