"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AllStaticReader = void 0;
const policy_engine_1 = require("@solidlab/policy-engine");
const IdentifierMap_1 = require("../util/map/IdentifierMap");
const PermissionReader_1 = require("./PermissionReader");
/**
 * PermissionReader which sets all permissions to true or false
 * independently of the identifier and requested permissions.
 */
class AllStaticReader extends PermissionReader_1.PermissionReader {
    permissionMap;
    constructor(allow) {
        super();
        this.permissionMap = Object.freeze({
            [policy_engine_1.PERMISSIONS.Read]: allow,
            [policy_engine_1.PERMISSIONS.Modify]: allow,
            [policy_engine_1.PERMISSIONS.Append]: allow,
            [policy_engine_1.PERMISSIONS.Create]: allow,
            [policy_engine_1.PERMISSIONS.Delete]: allow,
        });
    }
    async handle({ requestedModes }) {
        const availablePermissions = new IdentifierMap_1.IdentifierMap();
        for (const [identifier] of requestedModes) {
            availablePermissions.set(identifier, this.permissionMap);
        }
        return availablePermissions;
    }
}
exports.AllStaticReader = AllStaticReader;
//# sourceMappingURL=AllStaticReader.js.map