import { objectEntries } from "@vueuse/core";
import { replaceVariables } from "@scalar/helpers/regex/replace-variables";
//#region src/v2/blocks/operation-block/helpers/get-environment-variables.ts
/**
* Flattens the environment variables array into a key-value object.
* If a variable value is a string, use it directly; otherwise, use its default value.
*
* @returns An object mapping variable names to their resolved values.
*/
var getEnvironmentVariables = (environment) => {
	return environment.variables.reduce((acc, curr) => {
		acc[curr.name] = typeof curr.value === "string" ? curr.value : curr.value.default;
		return acc;
	}, {});
};
//#endregion
//#region src/v2/blocks/operation-block/helpers/get-server-url.ts
var getServerUrl = (server, environmentVariables) => {
	/** Extract the server variables default values*/
	const serverVariables = objectEntries(server?.variables ?? {}).reduce((acc, [name, variable]) => {
		if (variable.default) acc[name] = variable.default;
		return acc;
	}, {});
	return replaceVariables(server?.url ?? "", {
		...environmentVariables,
		...serverVariables
	});
};
//#endregion
export { getEnvironmentVariables as n, getServerUrl as t };

//# sourceMappingURL=get-server-url-o3On8CEr.js.map