import { atom } from 'jotai'; import type { Map, StyleSpecification, LayerSpecification } from 'maplibre-gl'; const mapState = atom(null); const isMapLoadedState = atom(false); const styleURLState = atom(''); const spriteState = atom(undefined); const styleObjState = atom(null); const selectedLayerIDState = atom(undefined); const layerState = atom((get) => { const openLayerID = get(selectedLayerIDState); const styleObj = get(styleObjState); return styleObj?.layers?.find( (l) => l.id === openLayerID ) as LayerSpecification; }); export { mapState, isMapLoadedState, styleURLState, spriteState, styleObjState, selectedLayerIDState, layerState, };