export class RegistrationData {
    constructor(prototype, category, name, icon, include) {
        this.prototype = prototype;
        this.category = category;
        this.name = name;
        this.icon = icon;
        this.include = include;
    }
    create() {
        return new this.prototype.constructor();
    }
}
export function RegisterFlowStep(step, category, name, icon, include) {
    let prototype = Object.getPrototypeOf(step);
    prototype.__type = name;
    FlowStepRegistration.addRegistration(new RegistrationData(prototype, category, name, icon, include));
}
export class FlowStepRegistrationClass {
    constructor() {
        this.registrations = {};
    }
    addRegistration(data) {
        this.registrations[data.name] = data;
    }
    getByName(name) {
        return this.registrations[name];
    }
    getAll(forData) {
        let output = [];
        Object.values(this.registrations).forEach((v) => {
            if (v.include) {
                // if it has a filter, will only add if there is data and there filter passes.
                if (forData && v.include(forData))
                    output.push(v);
            }
            else {
                output.push(v);
            }
        });
        return output;
    }
    getItemsByCategories(category) {
        const itemsByCategory = this.getAll().reduce((obj, data) => {
            if (!category || (category && category === data.category)) {
                if (!obj[data.category]) {
                    obj[data.category] = [];
                }
                obj[data.category].push(data);
            }
            return obj;
        }, {});
        return itemsByCategory;
    }
}
export const FlowStepRegistration = new FlowStepRegistrationClass();
//# sourceMappingURL=RegisterFlowStep.js.map