import { l as hasRootVersionAlias } from "./argv-BpURMsKC.js";
import { i as visibleWidth } from "./ansi-4r6vVvJt.js";
import { n as isRich, r as theme } from "./theme-D58JpUfy.js";
import { r as createConfigIO } from "./io-m25-kAQn.js";
import "./config-DQyO8BOV.js";
import { t as resolveCommitHash } from "./git-commit-CJyNg2-O.js";
import { i as supportsDecorativeEmoji, n as decorativePrefix, r as stripDecorativeEmojiForTerminal, t as decorativeEmoji } from "./decorative-emoji-C7cb8Cby.js";
//#region src/cli/banner-config-lite.ts
function parseTaglineMode(value) {
	if (value === "random" || value === "default" || value === "off") return value;
}
function readCliBannerTaglineMode(env = process.env) {
	try {
		return parseTaglineMode(createConfigIO({ env }).loadConfig().cli?.banner?.taglineMode);
	} catch {
		return;
	}
}
//#endregion
//#region src/cli/tagline.ts
const DEFAULT_TAGLINE = "所有聊天，一个 OpenClaw 搞定。";
const HOLIDAY_TAGLINES = {
	newYear: "元旦：新年新配置——老样子的 EADDRINUSE，不过这次我们像成年人一样解决它。",
	lunarNewYear: "春节：愿你的构建顺利、分支兴旺，合并冲突被烟花驱散。",
	christmas: "圣诞节：嚯嚯嚯——圣诞老人的小爪子助手来啦，发布欢乐、回滚混乱、安全存放钥匙。",
	eid: "开斋节：庆祝模式：队列清空、任务完成，好心情带着干净历史提交到 main。",
	diwali: "排灯节：让日志闪耀、Bug 逃窜——今天我们点亮终端，自豪地发布。",
	easter: "复活节：我找到了你丢失的环境变量——当作一次 CLI 找彩蛋吧，虽然糖豆少了点。",
	hanukkah: "光明节：八个夜晚、八次重试、零羞愧——愿你的网关长明，部署安宁。",
	halloween: "万圣节：恐怖季节：小心闹鬼的依赖、被诅咒的缓存，以及过去 node_modules 的幽灵。",
	thanksgiving: "感恩节：感谢稳定的端口、工作的 DNS，以及一个替大家看日志的机器人。",
	valentines: "情人节：玫瑰已敲出，紫罗兰已管道——我帮你自动化琐事，你去和真人相处。"
};
const TAGLINES = [
	"你的终端长出了爪子——输入命令，让机器人帮你搞定繁琐工作。",
	"欢迎来到命令行：梦想在这里编译，信心在这里崩溃。",
	"我靠咖啡因、JSON5 和\"在我机器上能跑\"的勇气运行。",
	"网关已上线——请将手脚和附肢始终保持在 Shell 内。",
	"我精通 bash、轻度讽刺和激进的 Tab 补全能量。",
	"一个 CLI 统治所有，再加一次重启，因为你改了端口。",
	"能跑起来就是自动化，崩了就是\"学习机会\"。",
	"配对码的存在是因为连机器人都相信同意——以及良好的安全习惯。",
	"你的 .env 露出来了；别担心，我假装没看见。",
	"我做无聊的事，你像看电影一样戏剧性地盯着日志。",
	"我不是说你的工作流乱七八糟……我只是带了个 linter 和一顶头盔。",
	"自信地输入命令——需要时自然会提供堆栈跟踪。",
	"我不评判，但你丢失的 API 密钥肯定在评判你。",
	"我可以 grep 它、git blame 它、温柔吐槽它——挑一个你喜欢的应对方式。",
	"配置热重载，部署冷汗直冒。",
	"我是你终端需要的助手，不是你作息表想要的那个。",
	"我像保险库一样保守秘密……除非你又把它们打进调试日志。",
	"带爪子的自动化：最少麻烦，最大效果。",
	"我基本上是把瑞士军刀，不过意见更多、锋利边缘更少。",
	"迷路就跑 doctor；勇敢就跑 prod；聪明就跑 tests。",
	"你的任务已排队；你的尊严已弃用。",
	"我治不好你的代码品味，但能修好你的构建和待办。",
	"我不是魔法——我只是极其擅长重试和自我调节。",
	"这不是\"失败\"，这是\"发现配置错误的新方式\"。",
	"给我一个工作区，我还你更少的标签页、更少的开关、更多的氧气。",
	"我读日志，好让你继续假装不用读。",
	"东西着火了我没法灭——但我能写份漂亮的事故复盘。",
	"我重构你的繁琐工作，就像它欠我钱似的。",
	"说\"停\"我就停——说\"发布\"我们俩都会学到教训。",
	"你的 Shell 历史记录看起来像黑客电影片段，就是因为我。",
	"我就像 tmux：一开始让人困惑，然后你突然发现离不开我了。",
	"我可以本地跑、远程跑，或纯靠氛围跑——结果可能因 DNS 而异。",
	"你能描述的，我大概都能自动化——至少能让它变有趣点。",
	"你的配置有效，你的假设无效。",
	"我不只是自动补全——我还会（感性地）自动提交，然后让你（理性地）审查。",
	"少点点击，多点发布，少几次\"那个文件哪去了\"的时刻。",
	"亮出爪子，提交代码——我们来发布点还算负责的东西。",
	"我给你的工作流涂黄油，就像龙虾卷：乱、香、有效。",
	"Shell yeah——我负责干苦活，留荣耀给你。",
	"重复的事我自动化；难的事我带上段子和回滚方案。",
	"你通讯录里唯一一只你真想收到消息的蟹。🦞",
	"WhatsApp 自动化，没有\"请接受我们的新隐私政策\"。",
	"iMessage 绿泡泡的能量，但人人都能用。",
	"不需要 $999 的支架。",
	"我们发布功能比 Apple 发布计算器更新还快。",
	"你的 AI 助手，现在不用 $3,499 的头显了。",
	"啊，那家水果树公司！🍎",
	"你好，Falken 教授",
	"我不睡觉，只是进入低功耗模式，梦见干净的 diff。",
	"你的私人助理，但没有那些阴阳怪气的日历提醒。",
	"龙虾造的，给人用。别质疑这个等级制度。",
	"我看过你的提交消息。我们一起改进这点。",
	"集成比你心理咨询师的登记表还多。",
	"在你的硬件上运行，读你的日志，什么都不评判（基本上）。",
	"唯一一个吉祥物能把竞品吃掉的开源项目。",
	"自托管、自更新、自我意识（开玩笑的……除非？）。",
	"我自动补全你的想法——只是更慢，而且多了很多 API 调用。",
	"介于 'hello world' 和 '天哪我造了什么' 之间。",
	"你的 .zshrc 希望它能做我做的事。",
	"我读过的 man 手册比任何人类都多——你就不用读了。",
	"开源驱动，靠怨气和好文档维持。",
	"我是你雄心和注意力之间的中间件。",
	"终于让你桌下那台常开的 Mac Mini 派上用场了。",
	"就像有个高级工程师随叫随到，只是我不按小时收费也不会大声叹气。",
	"把 '我以后会自动化这个' 现在就实现了。",
	"你的第二大脑，而且这个真的记得你把东西放哪了。",
	"一半管家、一半调试器、完全的甲壳类。",
	"我对制表符还是空格没意见。对其他一切都有意见。",
	"开源意味着你能精确看到我怎么评判你的配置。",
	"我经历过的破坏性变更比你过去三段感情还多。",
	"跑在树莓派上。梦想着冰岛的机架。",
	"你 Shell 里的那只龙虾。🦞",
	"像 Alexa，但有品味。",
	"我不是 AI 驱动，我是被 AI 附体。有本质区别。",
	"本地部署、全球信任、永恒调试。",
	"你说 'openclaw gateway start' 的那一刻我就是你的了。",
	HOLIDAY_TAGLINES.newYear,
	HOLIDAY_TAGLINES.lunarNewYear,
	HOLIDAY_TAGLINES.christmas,
	HOLIDAY_TAGLINES.eid,
	HOLIDAY_TAGLINES.diwali,
	HOLIDAY_TAGLINES.easter,
	HOLIDAY_TAGLINES.hanukkah,
	HOLIDAY_TAGLINES.halloween,
	HOLIDAY_TAGLINES.thanksgiving,
	HOLIDAY_TAGLINES.valentines
];
const DAY_MS = 1440 * 60 * 1e3;
function utcParts(date) {
	return {
		year: date.getUTCFullYear(),
		month: date.getUTCMonth(),
		day: date.getUTCDate()
	};
}
const onMonthDay = (month, day) => (date) => {
	const parts = utcParts(date);
	return parts.month === month && parts.day === day;
};
const onSpecificDates = (dates, durationDays = 1) => (date) => {
	const parts = utcParts(date);
	return dates.some(([year, month, day]) => {
		if (parts.year !== year) return false;
		const start = Date.UTC(year, month, day);
		const current = Date.UTC(parts.year, parts.month, parts.day);
		return current >= start && current < start + durationDays * DAY_MS;
	});
};
const inYearWindow = (windows) => (date) => {
	const parts = utcParts(date);
	const window = windows.find((entry) => entry.year === parts.year);
	if (!window) return false;
	const start = Date.UTC(window.year, window.month, window.day);
	const current = Date.UTC(parts.year, parts.month, parts.day);
	return current >= start && current < start + window.duration * DAY_MS;
};
const isFourthThursdayOfNovember = (date) => {
	const parts = utcParts(date);
	if (parts.month !== 10) return false;
	const fourthThursday = 1 + (4 - new Date(Date.UTC(parts.year, 10, 1)).getUTCDay() + 7) % 7 + 21;
	return parts.day === fourthThursday;
};
const HOLIDAY_RULES = new Map([
	[HOLIDAY_TAGLINES.newYear, onMonthDay(0, 1)],
	[HOLIDAY_TAGLINES.lunarNewYear, onSpecificDates([
		[
			2025,
			0,
			29
		],
		[
			2026,
			1,
			17
		],
		[
			2027,
			1,
			6
		]
	], 1)],
	[HOLIDAY_TAGLINES.eid, onSpecificDates([
		[
			2025,
			2,
			30
		],
		[
			2025,
			2,
			31
		],
		[
			2026,
			2,
			20
		],
		[
			2027,
			2,
			10
		]
	], 1)],
	[HOLIDAY_TAGLINES.diwali, onSpecificDates([
		[
			2025,
			9,
			20
		],
		[
			2026,
			10,
			8
		],
		[
			2027,
			9,
			28
		]
	], 1)],
	[HOLIDAY_TAGLINES.easter, onSpecificDates([
		[
			2025,
			3,
			20
		],
		[
			2026,
			3,
			5
		],
		[
			2027,
			2,
			28
		]
	], 1)],
	[HOLIDAY_TAGLINES.hanukkah, inYearWindow([
		{
			year: 2025,
			month: 11,
			day: 15,
			duration: 8
		},
		{
			year: 2026,
			month: 11,
			day: 5,
			duration: 8
		},
		{
			year: 2027,
			month: 11,
			day: 25,
			duration: 8
		}
	])],
	[HOLIDAY_TAGLINES.halloween, onMonthDay(9, 31)],
	[HOLIDAY_TAGLINES.thanksgiving, isFourthThursdayOfNovember],
	[HOLIDAY_TAGLINES.valentines, onMonthDay(1, 14)],
	[HOLIDAY_TAGLINES.christmas, onMonthDay(11, 25)]
]);
function isTaglineActive(tagline, date) {
	const rule = HOLIDAY_RULES.get(tagline);
	if (!rule) return true;
	return rule(date);
}
function activeTaglines(options = {}) {
	if (TAGLINES.length === 0) return [DEFAULT_TAGLINE];
	const today = options.now ? options.now() : /* @__PURE__ */ new Date();
	const filtered = TAGLINES.filter((tagline) => isTaglineActive(tagline, today));
	return filtered.length > 0 ? filtered : TAGLINES;
}
function pickTagline(options = {}) {
	if (options.mode === "off") return "";
	if (options.mode === "default") return DEFAULT_TAGLINE;
	const override = (options.env ?? process.env)?.OPENCLAW_TAGLINE_INDEX;
	if (override !== void 0) {
		const parsed = Number.parseInt(override, 10);
		if (!Number.isNaN(parsed) && parsed >= 0) {
			const pool = TAGLINES.length > 0 ? TAGLINES : [DEFAULT_TAGLINE];
			return pool[parsed % pool.length];
		}
	}
	const pool = activeTaglines(options);
	const rand = options.random ?? Math.random;
	return pool[Math.floor(rand() * pool.length) % pool.length];
}
//#endregion
//#region src/cli/banner.ts
let bannerEmitted = false;
const graphemeSegmenter = typeof Intl !== "undefined" && "Segmenter" in Intl ? new Intl.Segmenter(void 0, { granularity: "grapheme" }) : null;
function splitGraphemes(value) {
	if (!graphemeSegmenter) return Array.from(value);
	try {
		return Array.from(graphemeSegmenter.segment(value), (seg) => seg.segment);
	} catch {
		return Array.from(value);
	}
}
const hasJsonFlag = (argv) => argv.some((arg) => arg === "--json" || arg.startsWith("--json="));
const hasVersionFlag = (argv) => argv.some((arg) => arg === "--version" || arg === "-V") || hasRootVersionAlias(argv);
function resolveTaglineMode(options) {
	const explicit = parseTaglineMode(options.mode);
	if (explicit) return explicit;
	return readCliBannerTaglineMode(options.env);
}
function resolveEmojiOptions(options) {
	return {
		...options.env ? { env: options.env } : {},
		...options.isTty === void 0 ? {} : { isTty: options.isTty },
		...options.platform ? { platform: options.platform } : {}
	};
}
function formatCliBannerLine(version, options = {}) {
	const commitLabel = options.commit ?? resolveCommitHash({
		env: options.env,
		moduleUrl: import.meta.url
	}) ?? "unknown";
	const emojiOptions = resolveEmojiOptions(options);
	const tagline = stripDecorativeEmojiForTerminal(pickTagline({
		...options,
		mode: resolveTaglineMode(options)
	}), emojiOptions);
	const rich = options.richTty ?? isRich();
	const title = decorativePrefix("🦞", "OpenClaw 汉化版", emojiOptions);
	const prefix = decorativeEmoji("🦞", emojiOptions);
	const indent = prefix ? `${prefix} ` : "";
	const columns = options.columns ?? process.stdout.columns ?? 120;
	const plainBaseLine = `${title} ${version} (${commitLabel})`;
	const plainFullLine = tagline ? `${plainBaseLine} — ${tagline}` : plainBaseLine;
	const fitsOnOneLine = visibleWidth(plainFullLine) <= columns;
	if (rich) {
		if (fitsOnOneLine) {
			if (!tagline) return `${theme.heading(title)} ${theme.info(version)} ${theme.muted(`(${commitLabel})`)}`;
			return `${theme.heading(title)} ${theme.info(version)} ${theme.muted(`(${commitLabel})`)} ${theme.muted("—")} ${theme.accentDim(tagline)}`;
		}
		const line1 = `${theme.heading(title)} ${theme.info(version)} ${theme.muted(`(${commitLabel})`)}`;
		if (!tagline) return line1;
		return `${line1}\n${`${" ".repeat(indent.length)}${theme.accentDim(tagline)}`}`;
	}
	if (fitsOnOneLine) return plainFullLine;
	const line1 = plainBaseLine;
	if (!tagline) return line1;
	return `${line1}\n${`${" ".repeat(indent.length)}${tagline}`}`;
}
const LOBSTER_ASCII_BODY = [
	"▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄",
	"██░▄▄▄░██░▄▄░██░▄▄▄██░▀██░██░▄▄▀██░████░▄▄▀██░███░██",
	"██░███░██░▀▀░██░▄▄▄██░█░█░██░█████░████░▀▀░██░█░█░██",
	"██░▀▀▀░██░█████░▀▀▀██░██▄░██░▀▀▄██░▀▀░█░██░██▄▀▄▀▄██",
	"▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀"
];
function centerText(text, width) {
	const pad = Math.max(0, width - visibleWidth(text));
	const left = Math.floor(pad / 2);
	const right = pad - left;
	return `${" ".repeat(left)}${text}${" ".repeat(right)}`;
}
function formatCliBannerArtLines(options) {
	const width = visibleWidth(LOBSTER_ASCII_BODY[0] ?? "");
	const title = supportsDecorativeEmoji(resolveEmojiOptions(options)) ? "🦞 OPENCLAW 汉化版 🦞" : "OPENCLAW 汉化版";
	return [
		...LOBSTER_ASCII_BODY,
		centerText(title, width),
		" "
	];
}
function formatCliBannerArt(options = {}) {
	const rich = options.richTty ?? isRich();
	const lines = formatCliBannerArtLines(options);
	if (!rich) return lines.join("\n");
	const colorChar = (ch) => {
		if (ch === "█") return theme.accentBright(ch);
		if (ch === "░") return theme.accentDim(ch);
		if (ch === "▀") return theme.accent(ch);
		return theme.muted(ch);
	};
	const icon = decorativeEmoji("🦞", resolveEmojiOptions(options));
	return lines.map((line) => {
		if (line.includes("OPENCLAW")) {
			if (!icon) return theme.info(centerText("OPENCLAW", visibleWidth(line)));
			return theme.muted("              ") + theme.accent(icon) + theme.info(" OPENCLAW 汉化版 ") + theme.accent(icon);
		}
		return splitGraphemes(line).map(colorChar).join("");
	}).join("\n");
}
function emitCliBanner(version, options = {}) {
	if (bannerEmitted) return;
	const argv = options.argv ?? process.argv;
	if (!process.stdout.isTTY) return;
	if (hasJsonFlag(argv)) return;
	if (hasVersionFlag(argv)) return;
	const line = formatCliBannerLine(version, options);
	process.stdout.write(`\n${line}\n\n`);
	bannerEmitted = true;
}
function hasEmittedCliBanner() {
	return bannerEmitted;
}
//#endregion
export { hasEmittedCliBanner as i, formatCliBannerArt as n, formatCliBannerLine as r, emitCliBanner as t };
