/** @internal */
export class SchemaDynamicModifier {
    nodeSpecsProcessors;
    constructor(config) {
        this.nodeSpecsProcessors = new Map(Object.entries(config));
    }
    processNodeSpec(name, nodeSpec) {
        let updatedSpec = nodeSpec;
        this.nodeSpecsProcessors.forEach((processor, elementType) => {
            if (name === elementType &&
                processor.allowedAttrs &&
                processor.allowedAttrs.length > 0 &&
                nodeSpec) {
                updatedSpec = {
                    ...nodeSpec,
                    attrs: {
                        ...nodeSpec.attrs,
                        ...processor.allowedAttrs.reduce((acc, key) => {
                            acc[key] = { default: null };
                            return acc;
                        }, {}),
                    },
                };
            }
        });
        return updatedSpec;
    }
}
//# sourceMappingURL=SchemaDynamicModifier.js.map
