export function createStore(initialState) {
    let state = initialState;
    const listeners = new Set();
    return {
        getState() {
            return state;
        },
        setState(update) {
            state = typeof update === "function" ? update(state) : update;
            for (const listener of listeners)
                listener(state);
            return state;
        },
        subscribe(listener) {
            listeners.add(listener);
            return () => listeners.delete(listener);
        },
    };
}
