function getNewSideMenuSchema(sideMenuSchema, searchMenuTitle) {
    const newSchema = flattenAndFilterJson(sideMenuSchema, searchMenuTitle);
    return newSchema;
}
function flattenAndFilterJson(data, targetTitle) {
    const { title, properties, ...rest } = data;
    const result = {
        title,
        ...rest,
        properties: {}
    };
    const traverse = (node)=>{
        if (!node) return;
        const isSubMenu = 'Menu.SubMenu' === node['x-component'];
        if (!isSubMenu) {
            if ('string' == typeof (null == node ? void 0 : node.title) && node.title.includes(targetTitle)) result.properties[node.name] = {
                ...node
            };
            return;
        }
        if (!node.properties) return;
        Object.values(node.properties).forEach((child)=>{
            const isSubMenu = 'Menu.SubMenu' === child['x-component'];
            if (isSubMenu) traverse(child);
            else {
                var _child_title;
                if (null == child ? void 0 : null === (_child_title = child.title) || void 0 === _child_title ? void 0 : _child_title.includes(targetTitle)) result.properties[child.name] = {
                    ...child
                };
            }
        });
    };
    traverse(data);
    return result;
}
export { getNewSideMenuSchema };
