import { cloneObject , getProp } from "@esri/hub-common" ; import { convertRow } from "./convert-row" ; import { extractAssets } from "./extract-assets" ; import { ISection , IRow } from "./types" ; param { ISection } section export function convertSection ( section ) { const { rows , assets } = section . rows . reduce ( toTemplatizedRows , { assets : [ ] , rows : [ ] } ) ; const result = { section : cloneObject ( section ) as ISection , assets } ; result . section . rows = rows ; if ( sectionHasBackgroundFile ( section ) ) { result . assets . push ( ... extractAssets ( section . style . background ) ) ; } return result ; } function toTemplatizedRows ( acc , row ) { const { assets , cards } = convertRow ( row ) ; acc . assets . push ( ... assets ) ; acc . rows . push ( { cards } ) ; return acc ; } function sectionHasBackgroundFile ( clonedSection ) { return getProp ( clonedSection , "style.background.fileSrc" ) ; }