import { PanelState , EmbeddableInput } from '../../../embeddable_plugin' ; import { DEFAULT_PANEL_HEIGHT , DEFAULT_PANEL_WIDTH } from '../dashboard_constants' ; import { DashboardPanelState } from '../types' ; import { IPanelPlacementArgs , findTopLeftMostOpenSpace , PanelPlacementMethod , } from './dashboard_panel_placement' ; /**
 * Creates and initializes a basic panel state.
 */ export function createPanelState < TEmbeddableInput extends EmbeddableInput , TPlacementMethodArgs extends IPanelPlacementArgs = IPanelPlacementArgs > ( panelState , currentPanels , placementMethod ? , placementArgs ? ) { const defaultPlacementArgs = { width : DEFAULT_PANEL_WIDTH , height : DEFAULT_PANEL_HEIGHT , currentPanels , } ; const finalPlacementArgs = placementArgs ? { ... defaultPlacementArgs , ... placementArgs , } : defaultPlacementArgs ; const gridDataLocation = placementMethod ? placementMethod ( finalPlacementArgs as TPlacementMethodArgs ) : findTopLeftMostOpenSpace ( defaultPlacementArgs ) ; return { gridData : { ... gridDataLocation , i : panelState . explicitInput . id , } , ... panelState , } ; }