//#region src/domains/run/services/blob-storage/storage-keys.ts
const STORAGE_KEY_VERSION = "v1";
function buildStorageKey(input) {
	switch (input.category) {
		case "media": return [
			STORAGE_KEY_VERSION,
			`t_${input.tenantId}`,
			input.category,
			`p_${input.projectId}`,
			"conv",
			`c_${input.conversationId}`,
			`m_${input.messageId}`,
			`sha256-${input.contentHash}.${input.ext}`
		].join("/");
	}
}
function parseMediaStorageKey(key) {
	const parts = key.split("/");
	if (parts.length < 7) return null;
	const [version, tenantSlug, category, projectSlug, conv, conversationSlug, ...tailParts] = parts;
	if (version !== STORAGE_KEY_VERSION || category !== "media" || conv !== "conv" || !tenantSlug.startsWith("t_") || !projectSlug.startsWith("p_") || !conversationSlug.startsWith("c_")) return null;
	return {
		tenantId: tenantSlug.slice(2),
		projectId: projectSlug.slice(2),
		conversationId: conversationSlug.slice(2),
		tail: tailParts.join("/")
	};
}
function buildMediaStorageKeyPrefix(input) {
	return [
		STORAGE_KEY_VERSION,
		`t_${input.tenantId}`,
		"media",
		`p_${input.projectId}`,
		"conv",
		`c_${input.conversationId}`
	].join("/");
}

//#endregion
export { buildMediaStorageKeyPrefix, buildStorageKey, parseMediaStorageKey };