// AUTO-GENERATED by mizan — do not edit

import { readable, type Readable } from 'svelte/store'
import { registerContext, type ContextState } from '@mizan/base'

import { fetchUserContext, type UserContextData, type UserContextParams, callUpdateProfile, callEcho, callFindUser, callRenameUser, callWhoami } from '../index'

export function createUserContext(params: UserContextParams) {
    const store = readable<ContextState<UserContextData>>(
        { data: null, status: 'idle', error: null },
        (set) => {
            const handle = registerContext('user', params, () => fetchUserContext(params))
            const unsub = handle.subscribe(() => set(handle.getState()))
            handle.refetch()
            return () => { unsub(); handle.unregister() }
        },
    )

    return store
}

export { callUpdateProfile } from '../index'
export { callEcho } from '../index'
export { callFindUser } from '../index'
export { callRenameUser } from '../index'
export { callWhoami } from '../index'

export type { ContextState } from '@mizan/base'
export { configure, initSession, MizanError } from '@mizan/base'
