import type * as Godot from "godot"
import * as React from "react"


export type Component<T extends Godot.Node> = React.FunctionComponent<Props<T>>
export type Props<T extends Godot.Node> = {
    // biome-ignore lint/complexity/noBannedTypes: using Function here is completely fine
    [K in keyof T as T[K] extends Function ? never : K]?: T[K]
}

export interface InstrinsicAttributes {
    readonly children?: React.ReactNode
    readonly name?: string
}

export const make = <T extends Godot.Node>(
    class_: new (...args: any[]) => T
): Component<T> => {
    const f = (props: Props<T>) => React.createElement("element", { ...props, class: class_ })
    f.displayName = class_.name
    return f
}
