// (C) 2021-2026 GoodData Corporation
import { dataLoaderAbstractFactory } from "./DataLoaderAbstractFactory.js";
class WorkspacePermissionsDataLoader {
    workspace;
    cachedWorkspacePermissions;
    constructor(workspace) {
        this.workspace = workspace;
    }
    getWorkspacePermissions(backend) {
        if (!this.cachedWorkspacePermissions) {
            this.cachedWorkspacePermissions = backend
                .workspace(this.workspace)
                .permissions()
                .getPermissionsForCurrentUser()
                .catch((error) => {
                this.cachedWorkspacePermissions = undefined;
                throw error;
            });
        }
        return this.cachedWorkspacePermissions;
    }
}
/**
 * @internal
 */
export const workspacePermissionsDataLoaderFactory = dataLoaderAbstractFactory((workspace) => new WorkspacePermissionsDataLoader(workspace));
//# sourceMappingURL=WorkspacePermissionsDataLoader.js.map