/**
 * Generates a unique storage key by combining a base key with metadata key-value pairs.
 *
 * @param {string} storageKey - The base storage key.
 * @param {Record<string, unknown>} metadata - Object containing additional distinguishing metadata.
 * @returns {string} The combined storage key.
 *
 * @example
 * getStorageKey('surveyFoo', { foo: 123, bar: 'baz' })
 * // Returns: '@px:surveyFoo__foo:123__bar:baz'
 */
export const getStorageKey = (
  prefix: string,
  storageKey: string,
  metadata: Record<string, unknown>,
) =>
  `${prefix}:${storageKey}__${Object.entries(metadata)
    .map(([key, value]) => `${key}:${value}`)
    .join('__')}`;
