package tech.easyflow.ai.permission;

import tech.easyflow.system.entity.vo.RoleCategoryAccessSnapshot;

import java.math.BigInteger;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;

public class WorkflowReadAccessSnapshot {

    private final RoleCategoryAccessSnapshot categoryAccess;
    private final Set<BigInteger> readableDeptIds;

    public WorkflowReadAccessSnapshot(RoleCategoryAccessSnapshot categoryAccess, Set<BigInteger> readableDeptIds) {
        this.categoryAccess = categoryAccess;
        this.readableDeptIds = readableDeptIds == null
                ? Collections.emptySet()
                : Collections.unmodifiableSet(new LinkedHashSet<>(readableDeptIds));
    }

    public BigInteger getAccountId() {
        return categoryAccess == null ? null : categoryAccess.getAccountId();
    }

    public boolean isSuperAdmin() {
        return categoryAccess != null && categoryAccess.isSuperAdmin();
    }

    public boolean isRestricted() {
        return categoryAccess == null || categoryAccess.isRestricted();
    }

    public Set<BigInteger> getCategoryIds() {
        return categoryAccess == null ? Collections.emptySet() : categoryAccess.getCategoryIds();
    }

    public Set<BigInteger> getReadableDeptIds() {
        return readableDeptIds;
    }
}
