import { create } from "zustand";
import type { AppState } from "./types";
import { createAuthSlice }      from "./slices/auth";
import { createDevicesSlice }   from "./slices/devices";
import { createTransferSlice }  from "./slices/transfer";
import { createMessagesSlice }  from "./slices/messages";
import { createClipboardSlice } from "./slices/clipboard";
import { createUiSlice }        from "./slices/ui";
import { createThemeSlice }     from "./slices/theme";
import { createLocaleSlice }    from "./slices/locale";
import { createPushSlice }      from "./slices/push";

export const useAppStore = create<AppState>()((...a) =>
({
    ...createAuthSlice(...a),
    ...createDevicesSlice(...a),
    ...createTransferSlice(...a),
    ...createMessagesSlice(...a),
    ...createClipboardSlice(...a),
    ...createUiSlice(...a),
    ...createThemeSlice(...a),
    ...createLocaleSlice(...a),
    ...createPushSlice(...a),
}));

// 重新导出所有 type 与 helper，保证现有 `from "./store"` import 仍可解析。
export type {
    AppState,
    AuthMode,
    SessionScope,
    ThemeMode,
    User,
    DeviceInfo,
    TransferPhase,
    CandidateBreakdown,
    IceStats,
    TransferRecord,
    MessageRecord,
    ClipboardState,
} from "./types";
