import { create } from 'zustand';
import { persist } from 'zustand/middleware';
import { createGlobalMMKVStorage } from './storage';
import { createResettableStore } from './registry';



// 用户首次进入应用的协议同意状态
const createConsentStore = () =>
  create()(
    persist(
      (set, get) => ({
        accepted: false,
        setAccepted: (v) => set({ accepted: !!v }),
        isAccepted: () => !!get().accepted,
        reset: () => set({ accepted: false }),
      }),
      {
        name: 'user-consent',
        storage: createGlobalMMKVStorage('user-consent'),
      }
    )
  );

const resettableConsent = createResettableStore('consentStore', createConsentStore);
export const useConsentStore = resettableConsent.useStore;