'use client';
import { jsx as _jsx } from "react/jsx-runtime";
import { createContext, useContext, useState, useMemo } from 'react';
// ---------------------------------------------------------------------------
// Pure mapping: FeatureNodeState (6-state) → FeatureStatus (5-state) | null
// ---------------------------------------------------------------------------
const stateMapping = {
    'action-required': 'action-needed',
    running: 'in-progress',
    done: 'done',
    blocked: 'blocked',
    pending: 'pending',
    error: 'error',
    creating: null,
    deleting: null,
    archived: null,
};
/**
 * Maps a canvas FeatureNodeState to the sidebar's 5-state FeatureStatus.
 * Returns `null` for `creating` (optimistic UI) — these should be excluded from the sidebar.
 */
export function mapNodeStateToSidebarStatus(state) {
    return stateMapping[state];
}
const SidebarFeaturesContext = createContext(null);
export function SidebarFeaturesProvider({ children }) {
    const [features, setFeatures] = useState([]);
    const [hasRepositories, setHasRepositories] = useState(false);
    const value = useMemo(() => ({ features, setFeatures, hasRepositories, setHasRepositories }), [features, hasRepositories]);
    return (_jsx(SidebarFeaturesContext.Provider, { value: value, children: children }));
}
export function useSidebarFeaturesContext() {
    const ctx = useContext(SidebarFeaturesContext);
    if (!ctx) {
        throw new Error('useSidebarFeaturesContext must be used within a <SidebarFeaturesProvider>');
    }
    return ctx;
}
