import { writable } from 'svelte/store';

const compositeStores = new Map();

// Create or retrieve a composite store
export function createCompositeStore(compositeId: string, initialState = {}) {
    if (!compositeStores.has(compositeId)) {
        compositeStores.set(compositeId, writable(initialState));
    }
    return compositeStores.get(compositeId);
}

// Get composite store or create a default empty one if not exists
export function getCompositeStore(compositeId: string) {
    return compositeStores.get(compositeId) || createCompositeStore(compositeId);
}
