import { n as CodemationTsyringeParamInfoReader, t as CodemationTsyringeTypeInfoRegistrar } from "./CodemationTsyringeTypeInfoRegistrar-Bj6FJYFz.js";

//#region src/presentation/server/DevelopmentRuntimeRouteGuard.ts
var DevelopmentRuntimeRouteGuard = class DevelopmentRuntimeRouteGuard {
	static isAuthorized(request) {
		if (this.isLoopbackRequest(request)) return true;
		const expectedToken = process.env.CODEMATION_DEV_SERVER_TOKEN;
		if (!expectedToken) return true;
		return request.headers.get("x-codemation-dev-token") === expectedToken;
	}
	static isLoopbackRequest(request) {
		const requestUrl = new URL(request.url);
		return requestUrl.hostname === "127.0.0.1" || requestUrl.hostname === "localhost" || requestUrl.hostname === "::1";
	}
	static async parseSignal(request) {
		const payload = await request.json();
		return DevelopmentRuntimeRouteGuard.parseSignalFromPayload(payload);
	}
	static parseSignalFromPayload(payload) {
		if (payload.kind === "buildStarted") return {
			kind: payload.kind,
			buildVersion: typeof payload.buildVersion === "string" ? payload.buildVersion : void 0
		};
		if (payload.kind === "buildCompleted") return {
			kind: payload.kind,
			buildVersion: typeof payload.buildVersion === "string" ? payload.buildVersion : void 0
		};
		if (payload.kind === "buildFailed" && typeof payload.message === "string" && payload.message.length > 0) return {
			kind: payload.kind,
			message: payload.message
		};
		throw new Error("Unsupported development runtime signal.");
	}
};

//#endregion
export { CodemationTsyringeParamInfoReader, CodemationTsyringeTypeInfoRegistrar, DevelopmentRuntimeRouteGuard };
//# sourceMappingURL=devServerSidecar.js.map