package p.studio.workspaces.assets.details;

import p.packer.dtos.PackerAssetSummaryDTO;
import p.studio.workspaces.assets.metadata.AssetStudioGlyphSpecialization;
import p.studio.workspaces.assets.messages.AssetWorkspaceAssetState;
import p.studio.workspaces.assets.messages.AssetWorkspaceAssetSummary;
import p.studio.workspaces.assets.messages.AssetWorkspaceBuildParticipation;

public final class AssetListPackerMappings {
    private AssetListPackerMappings() {
    }

    public static AssetWorkspaceAssetSummary mapSummary(PackerAssetSummaryDTO summary) {
        final AssetWorkspaceAssetState state = switch (summary.state()) {
            case REGISTERED -> AssetWorkspaceAssetState.REGISTERED;
            case UNREGISTERED -> AssetWorkspaceAssetState.UNREGISTERED;
        };
        final AssetWorkspaceBuildParticipation buildParticipation = switch (summary.buildParticipation()) {
            case INCLUDED -> AssetWorkspaceBuildParticipation.INCLUDED;
            case EXCLUDED -> AssetWorkspaceBuildParticipation.EXCLUDED;
        };
        return new AssetWorkspaceAssetSummary(
                summary.assetReference(),
                summary.identity().assetName(),
                state,
                buildParticipation,
                summary.identity().assetId(),
                summary.assetFamily(),
                AssetStudioGlyphSpecialization.NONE,
                summary.identity().assetRoot(),
                summary.preloadEnabled(),
                summary.hasDiagnostics());
    }
}
