import { localStorageNamespace } from "../constants"; function hashScope(scope: string): string { let hash = 2166136261; for (let index = 0; index < scope.length; index += 1) { hash ^= scope.charCodeAt(index); hash = Math.imul(hash, 16777619); } return (hash >>> 0).toString(36); } export function normalizeHistoryScope(scope?: string | null): string | null { const trimmed = scope?.trim(); if (!trimmed) { return null; } return hashScope(trimmed); } export function getHistoryActiveSessionKey(scope: string): string { return `${localStorageNamespace}/history/${scope}/activeSessionId`; } export function getHistoryConversationsKey(scope: string): string { return `${localStorageNamespace}/history/${scope}/conversations`; }