// hook to initialize the environment and auth session
// the main app must call this hook before rendering the page.
export class VertesiaEnvironment {
    _props;
    constructor(_props) {
        this._props = _props;
    }
    init(props) {
        this._props = props;
        return this;
    }
    prop(name) {
        if (!this._props) {
            throw new Error("VertesiaEnvironment was not initialized");
        }
        return this._props[name];
    }
    get version() {
        return this.prop("version");
    }
    get name() {
        return this.prop("name");
    }
    get type() {
        return this.prop("type");
    }
    get isProd() {
        return this.type === "production";
    }
    get isStable() {
        return this.type === "production" || this.type === "preview" || this.type === "dr";
    }
    get isDev() {
        return !this.isStable;
    }
    get isPreview() {
        return this.type === "preview";
    }
    get isLocalDev() {
        return this.prop("isLocalDev");
    }
    get isDocker() {
        return this.prop("isDocker");
    }
    get endpoints() {
        return this.prop("endpoints");
    }
    get firebase() {
        return this.prop("firebase");
    }
    get datadog() {
        return this._props?.datadog ?? false;
    }
    get logger() {
        return this._props?.logger ?? console;
    }
    /**
     * Callback to notify the host app when the user logs in.
     */
    onLogin(token) {
        this._props?.onLogin?.(token);
    }
    /**
     * Callback to notify the host app when the user logs out
     */
    onLogout() {
        this._props?.onLogout?.();
    }
}
const Env = new VertesiaEnvironment();
export { Env };
//# sourceMappingURL=index.js.map