import ScriptingModule from './scriptingModule';
import { registerItems } from '../config/items';
export class ItemBehavior {
    // Register item with behaviors using the dynamic ItemBehaviorProperties
    static register(config) {
        const { id } = config;
        Object.keys(config).forEach((key) => {
            const BehaviorClass = this.registry[key];
            if (BehaviorClass && typeof BehaviorClass.registerBehavior === "function") {
                const behaviorConfig = config[key];
                if (behaviorConfig) {
                    BehaviorClass.registerBehavior({ id, ...behaviorConfig });
                }
            }
        });
    }
    // Register subclasses dynamically (either by string or class)
    static registerSubclass(typeOrClass, subclass) {
        if (typeof typeOrClass === 'string') {
            this.registry[typeOrClass] = subclass;
        }
        else {
            const className = typeOrClass.name.toLowerCase();
            this.registry[className] = typeOrClass;
        }
    }
    // Initialize registered behaviors
    static initialize() {
        Object.entries(this.registry).forEach(([key, BehaviorClass]) => {
            if (typeof BehaviorClass.initialize === "function") {
                BehaviorClass.initialize();
            }
        });
    }
}
// Registry to store item behaviors by their key
ItemBehavior.registry = {};
export default class ItemModule extends ScriptingModule {
    constructor() {
        super("ItemModule");
    }
    onInitialize() {
        registerItems();
    }
}
