'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); const DEFAULT_THROW_IF_EMPTY = false; const DEFAULT_KEY = "NODE_ENV"; const DEFAULT_SOURCE = globalThis.process.env; class EnvModeException extends Error { } var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); class EnvMode { static configure(opts) { const { throwIfEmpty, key, source } = opts; if (throwIfEmpty) this.throwIfEmpty = throwIfEmpty; if (key) this.key = key; if (source) this.source = source; } static get() { return this.getGuardedMode(); } static getOrThrow() { return this._getOrThrow(); } static is(mode) { return mode === this.get(); } static isNot(mode) { return !this.is(mode); } static in(modes) { return modes.includes(this.get()); } static notIn(modes) { return !this.in(modes); } static select(selector) { const value = selector[this.get()]; return value === void 0 ? selector.default : value; } /** @internal */ static getGuardedMode() { return this.throwIfEmpty ? this._getOrThrow() : this._get(); } /** @internal */ static _getOrThrow() { const mode = this._get(); this.guard(mode); return mode; } /** @internal */ static _get() { return this.source[this.key]; } /** @internal */ static guard(mode) { if (this.isEmpty(mode)) throw new EnvModeException(`"${this.key}" is not defined in "${this.source.toString()}".`); return true; } /** @internal */ static isEmpty(mode) { return mode === void 0 || mode === ""; } } /** @internal */ __publicField(EnvMode, "throwIfEmpty", DEFAULT_THROW_IF_EMPTY); /** @internal */ __publicField(EnvMode, "key", DEFAULT_KEY); /** @internal */ __publicField(EnvMode, "source", DEFAULT_SOURCE); exports.default = EnvMode; module.exports = Object.assign(exports.default, exports); //# sourceMappingURL=index.cjs.map