import * as EffectConfig from "effect/Config";
import * as Context from "effect/Context";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import { ConfigError } from "@distilled.cloud/core/errors";
/**
 * Default PostHog API host (US Cloud).
 *
 * Override per-region by setting `POSTHOG_HOST` (e.g. `https://eu.posthog.com`
 * for EU Cloud, or your self-hosted instance URL). Operation paths in the spec
 * already include the `/api/...` prefix, so the host should NOT include it.
 */
export const DEFAULT_API_BASE_URL = "https://us.posthog.com";
export class Credentials extends Context.Service()("PosthogCredentials") {
}
const envConfig = EffectConfig.all({
    apiKey: EffectConfig.string("POSTHOG_API_KEY"),
    apiBaseUrl: EffectConfig.string("POSTHOG_HOST").pipe(EffectConfig.withDefault(DEFAULT_API_BASE_URL)),
});
export const CredentialsFromEnv = Layer.effect(Credentials, envConfig.asEffect().pipe(Effect.mapError(() => new ConfigError({
    message: "POSTHOG_API_KEY environment variable is required",
}))));
//# sourceMappingURL=credentials.js.map