type Constructor = new (...args: any[]) => T import { Component } from '@hatiolab/things-scene' import MCSMachine from '../mcs-machine' import MCSUnit from '../mcs-unit' export const ParentObjectMixinProperties = [ { type: 'string', label: 'parent-object-id', name: 'parentObjectId' } ] export function ParentObjectMixin>(Base: TBase): any { return class extends Base { get parentObject(): MCSMachine | MCSUnit | undefined { const { id, parentObjectId } = this.state if (parentObjectId || id) { //@ts-ignore const targets = this.root?.findAllById(parentObjectId || id) || [] for (const target of targets) { if (target instanceof MCSMachine || target instanceof MCSUnit) { return target } } } const parent = this.parent if (parent instanceof MCSMachine || parent instanceof MCSUnit) { return parent } } } }