import { FC, memo } from 'react'

export type BasePluginSettings = {
    enabled?: boolean
}

export const wrapPlugin = <S,>(Component: FC<S>, defaultEnabled?: boolean) => {
    const wrappedComponent = memo<S & BasePluginSettings>(({ enabled, ...props }) => {
        if (!(enabled ?? defaultEnabled)) return <></>

        return <Component {...(props as S)} />
    })

    return wrappedComponent
}
