import { atom } from 'jotai';
import { atomFamily } from 'jotai/utils';
import merge from 'deepmerge';
export function getDefaultOperationStore(pointer, requestValues = {}, activeExampleName) {
    return {
        activeExampleName,
        activeOneOf: {
            [pointer]: 0,
        },
        requestValues: requestValues,
        request: {
            expandedAll: undefined,
        },
        response: {
            expandedAll: undefined,
        },
    };
}
export const allOperations = atom({});
export const operationStore = atomFamily((pointer) => atom((get) => get(allOperations)?.[pointer] || getDefaultOperationStore(pointer), (get, set, update) => {
    const prevStore = get(allOperations);
    const prevValue = prevStore[pointer] || getDefaultOperationStore(pointer);
    set(allOperations, {
        ...prevStore,
        [pointer]: merge(prevValue, update),
    });
}));
//# sourceMappingURL=operation.js.map