import React, { useMemo, useRef } from 'react';
import { SubCellClickContext } from './subCellContext';
/**
 * Stable owner (mounted by EditableCell around the cell content, kept mounted
 * across the edit↔view swap) for the datetime cell's sub-cell click tracking.
 *
 * The View writes the most-recently-clicked sub-cell to a ref via the
 * context; the Edit consumes it on mount to pick the initial sub-edit. This
 * survives the View→Edit transition without resorting to module-global state
 * or a document-level listener.
 */
export function DateTimeEditWrapper({ children }) {
    const lastClickedRef = useRef(null);
    const tracker = useMemo(() => ({
        consume: () => {
            const value = lastClickedRef.current;
            lastClickedRef.current = null;
            return value;
        },
        record: (sub) => {
            lastClickedRef.current = sub;
        },
    }), []);
    return (React.createElement(SubCellClickContext.Provider, { value: tracker }, children));
}
//# sourceMappingURL=DateTimeEditWrapper.js.map