/** Effektives Ablaufprofil für Kombination im Coach/in der Planung */

export function effectiveComboMethodProfile(catalogDict, planningSnapshot) {
  const cat =
    catalogDict && typeof catalogDict === 'object' && !Array.isArray(catalogDict)
      ? catalogDict
      : {}
  if (
    planningSnapshot !== null &&
    planningSnapshot !== undefined &&
    typeof planningSnapshot === 'object' &&
    !Array.isArray(planningSnapshot)
  ) {
    return { ...planningSnapshot }
  }
  return { ...cat }
}

export function comboPlanningProfileJsonForEditor(catalogDict, planningSnapshot) {
  const o = effectiveComboMethodProfile(catalogDict, planningSnapshot)
  try {
    return JSON.stringify(Object.keys(o).length ? o : {})
  } catch {
    return '{}'
  }
}
