import { createLogger } from "../../utils/logger/index.js";
import { init_logger } from "../../utils/logger.js";
//#region src/gateway/discovery/mdns.ts
init_logger();
const log = createLogger("GatewayDiscovery");
let advertised = null;
/** Register mDNS service `_xopc-gw._tcp` when enabled (best-effort; no native dep yet). */
function startMdnsGatewayDiscovery(params) {
	advertised = {
		name: "xopc-gateway",
		port: params.port,
		txt: {
			path: "/",
			...params.tokenHint ? { auth: "token" } : {}
		}
	};
	log.info({
		port: params.port,
		service: "_xopc-gw._tcp",
		phase: "mdns_register"
	}, "Gateway mDNS advertisement registered (logical; install Bonjour for OS broadcast)");
}
function stopMdnsGatewayDiscovery() {
	if (!advertised) return;
	log.debug({ phase: "mdns_stop" }, "Gateway mDNS advertisement cleared");
	advertised = null;
}
function getMdnsGatewayAdvertisement() {
	return advertised;
}
//#endregion
export { getMdnsGatewayAdvertisement, startMdnsGatewayDiscovery, stopMdnsGatewayDiscovery };

//# sourceMappingURL=mdns.js.map