import { Deck , DeckOperations , ExcalidrawElement } from "@excalideck/deck" ; import PrintableAreaUtils from "./PrintableAreaUtils" ; const ExcalidrawElementUtils = { getIds ( excalidrawElements ) { return excalidrawElements . map ( ( excalidrawElement ) => excalidrawElement . id ) ; } , removeByIds ( excalidrawElements , ids ) { const idSet = new Set ( ids ) ; return excalidrawElements . filter ( ( excalidrawElement ) => ! idSet . has ( excalidrawElement . id ) ) ; } , getCommonExcalidrawElementsForExcalidrawInput ( deck ) { return [ ... deck . commonExcalidrawElements , PrintableAreaUtils . getExcalidrawElement ( deck . printableArea ) , ] ; } , extractCommonExcalidrawElements ( /** These include common excalidraw elements and the printable area */ excalidrawInputExcalidrawElements ) { return ExcalidrawElementUtils . removeByIds ( excalidrawInputExcalidrawElements , [ PrintableAreaUtils . getExcalidrawElementId ( ) ] ) ; } , getSlideExcalidrawElementsForExcalidrawInput ( deck , slideId ) { const slide = DeckOperations . getSlide ( deck , slideId ) ; return [ ... slide . excalidrawElements , ... ( slide . shouldRenderWithCommonExcalidrawElements ? deck . commonExcalidrawElements : [ ] ) , PrintableAreaUtils . getExcalidrawElement ( deck . printableArea ) , ] ; } , extractSlideExcalidrawElements ( /**
     * These include common excalidraw elements (possibly) and the printable
     * area
     */ excalidrawInputExcalidrawElements , commonExcalidrawElements ) { return ExcalidrawElementUtils . removeByIds ( excalidrawInputExcalidrawElements , [ ... ExcalidrawElementUtils . getIds ( commonExcalidrawElements ) , PrintableAreaUtils . getExcalidrawElementId ( ) , ] ) ; } , } ; export default ExcalidrawElementUtils ;