import { IItemTemplate , cloneObject , getProp } from "@esri/hub-common" ; param { Object } itemTemplate private export function _ensureOptionalGroupsTemplating ( itemTemplate ) { const props = [ "collaborationGroupId" , "contentGroupId" , "followersGroupId" ] ; const tmpl = cloneObject ( itemTemplate ) ; props . forEach ( prop => { const val = getProp ( tmpl , `properties.${ prop }` ) ; if ( val ) { if ( val . match ( /^\{\{.*\}\}$/ ) ) { if ( ! val . match ( /:optional\}\}$/g ) ) { tmpl . properties [ prop ] = val . replace ( "}}" , ":optional}}" ) ; } } else { delete tmpl . properties [ prop ] ; } } } ) ; return tmpl ; }