import { MOBILE_SQLITE_DATABASE_NAME } from './mobile-sqlite-schema.rules';

const ANONYMOUS_DATABASE_SCOPE = 'anonymous';

/** Mirrors IndexedDB per-user database scoping for Capacitor SQLite files. */
export function resolveMobileSqliteDatabaseName(userId: string | null): string {
  const scopedUserId = userId?.trim() || ANONYMOUS_DATABASE_SCOPE;

  return `${MOBILE_SQLITE_DATABASE_NAME}__${encodeURIComponent(scopedUserId)}`;
}
