package p.studio.workspaces.assets.metadata;

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

public record AssetStudioGlyphMaterialMetadata(
        List<AssetStudioGlyphMaterialSchema> schemas,
        List<AssetStudioGlyphMaterialPalette> palettes,
        Path supportFile) {

    public AssetStudioGlyphMaterialMetadata {
        schemas = List.copyOf(Objects.requireNonNull(schemas, "schemas"));
        palettes = List.copyOf(Objects.requireNonNull(palettes, "palettes"));
        supportFile = supportFile == null ? null : supportFile.toAbsolutePath().normalize();
    }

    public Optional<AssetStudioGlyphMaterialSchema> findSchema(String schemaId) {
        return schemas.stream().filter(schema -> schema.schemaId().equals(schemaId)).findFirst();
    }
}
