import { Layer } from './types' ; param { Array } item const handleSingleLayer = ( item ) => { if ( item . children && item . children . length == 1 && ! ( item . type == 'Mask' && item . style [ 'border-radius' ] ) ) { if ( item . children [ 0 ] . type == 'Container' || ( ! item . children [ 0 ] . type && ( item . children [ 0 ] . sign === '__li' || item . children [ 0 ] . sign === '__oth' ) ) ) { if ( ! item . children [ 0 ] . textContainer && ! item . children [ 0 ] . structure . border && item . children [ 0 ] . _class != 'artboard' && ! item . children [ 0 ] . style . transform && ! item . children [ 0 ] . style . background && ! item . children [ 0 ] . isList ) { if ( item . children [ 0 ] . children ) { item . children = JSON . parse ( JSON . stringify ( item . children [ 0 ] . children ) ) ; } else { item . children = [ ] ; } item = handleSingleLayer ( item ) ; } else if ( item . _class != 'artboard' && ! item . style . transform ) { if ( item . type === 'Container' && ! item . children [ 0 ] . structure . border && ! item . style . background && ! item . style . borderRadius ) { item = item . children [ 0 ] ; item = handleSingleLayer ( item ) ; } else if ( item . children [ 0 ] . style . background ?. color ?. alpha === 1 && ! item . style . borderRadius && item . children [ 0 ] . structure . height === item . structure . height && item . children [ 0 ] . structure . width === item . structure . width && item . children [ 0 ] . structure . x === item . structure . x && item . children [ 0 ] . structure . y === item . structure . y ) { item = item . children [ 0 ] ; item = handleSingleLayer ( item ) ; } } } else if ( item . children [ 0 ] . type == 'Image' && item . _class != 'artboard' && ! item . style [ 'transform' ] ) { if ( item . type == 'Container' ) { if ( ! item . structure . border && ! item . style . background ) { item = item . children [ 0 ] ; item = handleSingleLayer ( item ) ; } else if ( item . children [ 0 ] . structure . height === item . structure . height && item . children [ 0 ] . structure . width === item . structure . width && item . children [ 0 ] . structure . x === item . structure . x && item . children [ 0 ] . structure . y === item . structure . y && ! item . style . background ) { item = item . children [ 0 ] ; item = handleSingleLayer ( item ) ; } } } else if ( item . children [ 0 ] . type === 'Text' ) { } } return item ; } ; const handleLayer = ( data ) => { for ( let i = 0 ; i < data . length ; i ++ ) { data [ i ] = handleSingleLayer ( data [ i ] ) ; if ( Array . isArray ( data [ i ] . children ) ) { data [ i ] . children = handleLayer ( data [ i ] . children ) ; } } return data ; } ; export default handleLayer ;