'use strict';
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
//Set initial map size to 1Gb
// eslint-disable-next-line no-magic-numbers
const MAP_SIZE = 1024 * 1024 * 1024;
//allow up to 1,000 named data bases in an environment
const MAX_DBS = 10000;
const MAX_READERS = 2048;
const envMngr = __importStar(require("../environment/environmentManager.js"));
const terms = __importStar(require("../../utility/hdbTerms.js"));
envMngr.initSync();
class OpenEnvironmentObject {
    static MAX_DBS = MAX_DBS;
    path;
    mapSize;
    maxDbs;
    maxReaders;
    sharedStructuresKey;
    readOnly;
    trackMetrics;
    eventTurnBatching;
    noSync;
    overlappingSync;
    maxFreeSpaceToLoad;
    maxFreeSpaceToRetain;
    pageSize;
    noReadAhead;
    constructor(path, readOnly = false) {
        this.path = path;
        this.mapSize = MAP_SIZE;
        this.maxDbs = MAX_DBS;
        this.maxReaders = MAX_READERS;
        this.sharedStructuresKey = Symbol.for('structures');
        this.readOnly = readOnly;
        this.trackMetrics = true;
        this.eventTurnBatching = false; // event turn batching is not needed in Harper
        this.noSync =
            envMngr.get(terms.CONFIG_PARAMS.STORAGE_WRITEASYNC) === true ||
                envMngr.get(terms.CONFIG_PARAMS.STORAGE_WRITEASYNC) === 'true' ||
                envMngr.get(terms.CONFIG_PARAMS.STORAGE_WRITEASYNC) === 'TRUE';
        //this.noFSAccess = true; // we might re-enable this if we want secure JS environments
        // otherwise overlappingSync uses lmdb-js default, which is enabled on linux/mac, disabled on windows
        if (envMngr.get(terms.CONFIG_PARAMS.STORAGE_OVERLAPPINGSYNC) !== undefined)
            this.overlappingSync = envMngr.get(terms.CONFIG_PARAMS.STORAGE_OVERLAPPINGSYNC);
        if (envMngr.get(terms.CONFIG_PARAMS.STORAGE_MAXFREESPACETOLOAD))
            this.maxFreeSpaceToLoad = envMngr.get(terms.CONFIG_PARAMS.STORAGE_MAXFREESPACETOLOAD);
        if (envMngr.get(terms.CONFIG_PARAMS.STORAGE_MAXFREESPACETORETAIN))
            this.maxFreeSpaceToRetain = envMngr.get(terms.CONFIG_PARAMS.STORAGE_MAXFREESPACETORETAIN);
        if (envMngr.get(terms.CONFIG_PARAMS.STORAGE_PAGESIZE))
            this.pageSize = envMngr.get(terms.CONFIG_PARAMS.STORAGE_PAGESIZE);
        this.noReadAhead = envMngr.get(terms.CONFIG_PARAMS.STORAGE_NOREADAHEAD);
    }
}
exports.default = OpenEnvironmentObject;
//# sourceMappingURL=OpenEnvironmentObject.js.map