import { LenraComponent as IComponent } from "../gen/response.js"; export { IComponent } export abstract class Component { protected model: T; constructor(model: T) { this.model = model; } toJSON(): T { return this.model; } protected setListener( event: string, name: string, props?: { [k: string]: unknown } ) { this.model[event] = { _type: "listener", name, }; if (props !== undefined) this.model[event].props = props; return this; } static normalize(child: Component | T): T { if (child instanceof Component) { return child.toJSON(); } return child; } }