license import { styles } from './overlay.template.js' ; function getOverlay ( { id = 'pt.overlay' , small = false , createIfNecessary = true } = { } ) { const existingOverlay = document . getElementById ( id ) ; if ( existingOverlay ) { return existingOverlay ; } if ( ! createIfNecessary ) { return ; } const overlay = document . createElement ( 'div' ) ; overlay . id = id ; const root = overlay . attachShadow ( { mode : 'open' } ) ; root . innerHTML = `<style>${ styles }</style><span class="content"><slot></slot></span>` ; if ( small ) { overlay . classList . add ( 'small' ) ; } return overlay ; } hidden export function showOverlay ( message , { target = document . body , id = 'pt.overlay' , small = false } = { } ) { const overlay = getOverlay ( { id , small } ) ; if ( ! overlay ) { return ; } overlay . textContent = message ; target . appendChild ( overlay ) ; return overlay ; } hidden export function hideOverlay ( { id = 'pt.overlay' } = { } ) { const overlay = getOverlay ( { id , createIfNecessary : false } ) ; if ( ! overlay ) { return ; } overlay . remove ( ) ; }