//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// TypeScript helpers (universal micro-lib.) | Author: Sergei Y.Kitaev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Helpers for interaction with HTML document tree (static class):
class HDoc
{
   static Body(): any {
      return document.body
   }

   static ClearSelection(): boolean {
      var sel: any = window.getSelection ? window.getSelection() : DOC.selection
      if (!sel)
         return false
      if (sel.removeAllRanges) {
         sel.removeAllRanges()
         return true
      }
      else if (sel.empty) {
         sel.empty()
         return true
      }
      return false
   }

   static FocusedElement(): HTMLElement|null {
      let activeElement = document.activeElement
      return activeElement instanceof HTMLElement ? activeElement as HTMLElement : null
   }
} // HDoc
