import { componentAtomTree } from '../../types' ; const generateCleanComponentAtomTree = ( inputObj ) : componentAtomTree => { const obj = { } as componentAtomTree ; let counter = 0 ; const innerClean = ( inputObj , outputObj , counter = 0 ) => { if ( ( inputObj . tag === 0 || inputObj . tag === 2 ) && inputObj . name !== 'RecoilRoot' && inputObj . name !== 'Batcher' && inputObj . name !== 'RecoilizeDebugger' && inputObj . name !== 'CssBaseline' ) { if ( Object . keys ( obj ) . length === 0 ) { outputObj . children = [ ] ; outputObj . name = inputObj . name ; outputObj . recoilNodes = inputObj . recoilNodes ; outputObj . tag = inputObj . tag ; outputObj = outputObj . children ; } else { const deepCopy = JSON . parse ( JSON . stringify ( inputObj ) ) ; deepCopy . children = [ ] ; outputObj . push ( deepCopy ) ; if ( outputObj . length > 1 ) { outputObj = outputObj [ outputObj . length - 1 ] . children ; } else { outputObj = outputObj [ 0 ] . children ; } } } for ( let i = 0 ; i < inputObj . children . length ; i ++ ) { innerClean ( inputObj . children [ i ] , outputObj , counter ) ; } return outputObj ; } ; innerClean ( inputObj , obj , counter ) ; if ( inputObj . actualDuration ) { obj . actualDuration = inputObj . actualDuration ; } return obj ; } ; export default generateCleanComponentAtomTree ;