package p.studio.workspaces.assets.messages;

import p.packer.dtos.PackerCodecConfigurationFieldDTO;
import p.packer.messages.assets.OutputCodecCatalog;
import p.packer.messages.assets.OutputFormatCatalog;

import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.Objects;

public record AssetWorkspaceAssetDetails(
        AssetWorkspaceAssetSummary summary,
        List<AssetWorkspaceAssetAction> actions,
        OutputFormatCatalog outputFormat,
        OutputCodecCatalog outputCodec,
        List<OutputCodecCatalog> availableOutputCodecs,
        Map<OutputCodecCatalog, List<PackerCodecConfigurationFieldDTO>> codecConfigurationFieldsByCodec,
        List<PackerCodecConfigurationFieldDTO> metadataFields,
        Map<String, List<Path>> inputsByRole) {

    public AssetWorkspaceAssetDetails {
        Objects.requireNonNull(summary, "summary");
        actions = List.copyOf(Objects.requireNonNull(actions, "actions"));
        outputFormat = Objects.requireNonNullElse(outputFormat, OutputFormatCatalog.UNKNOWN);
        outputCodec = Objects.requireNonNullElse(outputCodec, OutputCodecCatalog.UNKNOWN);
        availableOutputCodecs = List.copyOf(Objects.requireNonNull(availableOutputCodecs, "availableOutputCodecs"));
        codecConfigurationFieldsByCodec = Map.copyOf(Objects.requireNonNull(codecConfigurationFieldsByCodec, "codecConfigurationFieldsByCodec"));
        metadataFields = List.copyOf(Objects.requireNonNull(metadataFields, "metadataFields"));
        inputsByRole = Map.copyOf(Objects.requireNonNull(inputsByRole, "inputsByRole"));
    }
}
