/**
 * ANNOTATED COPY — every line explained
 * Source: src/store/locale.ts
 * NOT used by the app — read this to learn how the real file works
 */
// Zustand — simple global state store (cart, auth, locale)
import { create } from 'zustand';
// Zustand — simple global state store (cart, auth, locale)
import { persist } from 'zustand/middleware';
// Import project module (@/ alias = src/ folder in tsconfig)
import { DEFAULT_LOCALE, Locale } from '@/i18n/types';
// (blank line — separates logical blocks for readability)
// TypeScript interface — contract for object properties and methods
interface LocaleState {
  // Line 6: locale: Locale;
  locale: Locale;
  // Line 7: setLocale: (locale: Locale) => void;
  setLocale: (locale: Locale) => void;
// Closing brace — end of block (function, if, object, JSX)
}
// (blank line — separates logical blocks for readability)
// Named export constant — shared config/data imported elsewhere
export const useLocaleStore = create<LocaleState>()(
  // Zustand persist — save store to localStorage between visits
  persist(
    // Line 12: (set) => ({
    (set) => ({
      // Property or array item — trailing comma allowed in TypeScript
      locale: DEFAULT_LOCALE,
      // Property or array item — trailing comma allowed in TypeScript
      setLocale: (locale) => set({ locale }),
    // Closing brace — end of block (function, if, object, JSX)
    }),
    // Line 16: { name: 'kott-gard-locale' }
    { name: 'kott-gard-locale' }
  // Line 17: )
  )
// Line 18: );
);
