import { createPinia, getActivePinia, type Pinia } from 'pinia';
import { createPersistedState } from 'pinia-plugin-persistedstate';


const persistedState = createPersistedState({
  key: (storeKey) => `${ import.meta.env.SIX_APP_NAME ?? '@six/unknown' }:${ storeKey }`,
  auto: true,
  debug: import.meta.env.DEV,
});

const pinia = createPinia();
pinia.use(persistedState);

export default pinia;
export { usePlatformStore }     from './platform.store';
export { useAccountStore }      from './account.store';
export { useFlowStore }         from './flow.store';
export { useVisitor }     from './visitor.store';

export function getPinia() {
  return getActivePinia() ?? pinia;
}