Is there a way to check which panel is currently open (Search, File-Explorer or Bookmarks)?

Hello, Is there a way to check which panel is currently open: file navigator, search, or bookmarks?

I have a hacky way of determining that using the script below but maybe somebody knows something better?

const workspace = this.app.workspace;


let currentlyOpenPanel = "unknown";
workspace.iterateAllLeaves((openLeaf: any) => {
    if (openLeaf.height == 0) return;
    const viewState = openLeaf.getViewState();
    const viewType = viewState.type;
    currentlyOpenPanel = viewType;
});

Are you looking for which panel is visible in the UI or which panel is currently focused by the user? If it’s the former I love your hacky method!! If it’s the latter, maybe check for the mod-active class in the leaf’s containerEl? I think the JS API also has a thing that lets you see if an element is focused, not sure though.