#' @title Generate provenance for Visualization
#' @description Generate provenance information for visualization module.
#' @param recipe Configuration file specifying parameters.
#' @param data s2dv_cube object generated by SUNSET's Loading.R function.
#' @param graph Graph object containing provenance information.
#' @param type Type of data: "fcst" or "hcst".
#' @return List containing updated graph and parent node name.
#' @details This function generates provenance information for the visualization module based on forecast or hindcast data.

SunsetProv.Visualization <- function(recipe, graph) {

  #fcst definition
  if (!is.null(data$fcst)){
    graph_fcst <- Prov.Visualization(recipe, data, graph, type = "fcst")
  }

  #hcst definition (Dataset+Datasubset)
  graph_hcst <- Prov.Visualization(recipe, data, graph, type = "hcst")

  #obs definition
  parentnodename_obs <- graph$parentnodename$parentnodename_obs

  #Command Call and output definition
  if (!is.null(data$fcst)) {
    graph <- my_union_graph(graph_fcst$graph, graph_hcst$graph)
    graph <- SunsetProv.Command(graph, package ="Visualization",
                                version = "2.0.0",
                                fun = "modules/Visualization/Visualization.R",
                                arg.list =
                                  list(
                                       "recipe" = "Recipe",
                                       "Data" = "Data"),
                                origin.node.name
                                = c(
                                    unlist(
                                           graph_fcst$nodenames),
                                    unlist(
                                           graph_hcst$nodenames)))

    graph <- list("graph" = graph,
                  "parentnodename" =
                    list(
                         "parentnodename_fcst" = graph_fcst$parentnodename,
                         "parentnodename_hcst" = graph_hcst$parentnodename,
                         "parentnodename_obs" = parentnodename_obs))

  } else {
    graph <- graph_hcst$graph
    graph <- SunsetProv.Command(graph, package ="Visualization",
                                version = "2.0.0",
                                fun = "modules/Visualization/Visualization.R",
                                arg.list =
                                  list(
                                       "recipe" = "Recipe",
                                       "Data" = "Data"),
                                origin.node.name
                                = c(
                                    unlist(
                                           graph_hcst$nodenames)))

    graph <- list("graph" = graph,
                  "parentnodename" =
                    list(
                         "parentnodename_hcst" = graph_hcst$parentnodename,
                         "parentnodename_obs" = parentnodename_obs))
  }
  print("Visualization provenance computed")

  return(graph)


}
