let _env; try { // @ts-expect-error const { env } = await import("cloudflare:workers"); _env = env; } catch { if (typeof process !== "undefined") { _env = process.env; } else { _env = import.meta.env; } } export interface Env { [key: string]: string | undefined; } export const env: Env = _env; export const toEnvKey = ( id: ID, suffix: Suffix, ) => `${replace(toUpper(id))}_${replace(toUpper(suffix))}` as const; export const toUpper = (str: S) => str.toUpperCase() as string extends S ? S : Uppercase; const replace = (str: S) => str.replace(/-/g, "_") as Replace; type Replace = string extends S ? S : S extends "" ? Accum : S extends `${infer S}${infer Rest}` ? S extends "-" ? Replace : Replace : Accum;