All files / site/outputs info.ts

1.3% Statements 5/384
0% Branches 0/247
0% Functions 0/20
1.37% Lines 5/364

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565    2x 2x 2x 2x                                                                                                                                                                                     2x                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
import type {Entity, LogicalObject, MeasureInfo, Summary, Variable} from '../../types'
import type Community from '../index'
import {filter_components} from '../static_refs'
import {make_summary_table, make_variable_source} from '../utils'
import {value_types} from '../value_types'
import {BaseOutput, SiteOutputs} from './index'
 
type InfoSpec = {
  title?: string
  body?: {name: string; value: string; style: string}[]
  subto?: string[]
  dataview: string
  variable?: string
  default?: {body?: string; title?: string}
  variable_info?: boolean
  show_summary?: boolean
  floating?: boolean
}
 
type Parsed = {
  data?: string
  variables?: string
  features?: string
  summary?: HTMLTableElement
  filter?: HTMLTableElement
}
 
class InfoPart {
  parent: OutputInfo
  text: string
  value_source: string
  parsed: Parsed = {}
  ref = true
  selection = false
  base?: HTMLButtonElement | HTMLParagraphElement
  temp?: HTMLButtonElement | HTMLParagraphElement
  default?: HTMLButtonElement | HTMLParagraphElement
  rows?: {name: InfoPart; value: InfoPart}[]
  constructor(parent: OutputInfo, text: string) {
    this.parent = parent
    this.text = text
    if ('value' === text) {
      this.parsed.data = parent.spec.variable
    } else if ('summary' === text) {
      parent.spec.show_summary = true
    } else Iif ('filter' === text) {
      const e = document.createElement('table')
      e.className = 'info-filter'
      this.parsed.filter = e
    }
    const patterns = parent.site.patterns
    if (patterns.features.test(text)) {
      this.parsed.features = text.replace(patterns.features, '')
    } else if (parent.site.patterns.data.test(text)) {
      this.parsed.data = text.replace(patterns.data, '')
    } else if (patterns.variables.test(text)) {
      this.parsed.variables = text.replace(patterns.variables, '')
    } else this.ref = false
  }
  get(entity?: Entity, caller?: SiteOutputs) {
    if (this.ref && this.parent.site.data) {
      Iif (entity)
        if ('features' in this.parsed) {
          return entity.features[this.parsed.features]
        } else Iif ('data' in this.parsed) {
          if ('value' === this.text) {
            this.parsed.data = this.parent.site.valueOf(
              this.parent.spec.variable ||
                (caller && (caller.color || caller.y)) ||
                this.parent.site.dataviews[this.parent.view].y
            ) as string
          } else Iif (this.text in this.parent.site.inputs)
            this.parsed.data = this.parent.site.valueOf(this.text) as string
          Iif (!(this.parsed.data in this.parent.site.data.variables)) return this.parsed.data
          const info = this.parent.site.data.variables[this.parsed.data],
            v = this.parent.site.data.format_value(
              entity.get_value(this.parsed.data, this.parent.time),
              info && info.info[entity.group] && 'integer' === info.info[entity.group].type
            )
          let type = info.meta.unit || info.meta.type
          Iif (info.meta.aggregation_method && !(type in value_types)) type = info.meta.aggregation_method
          return (!isNaN(v as number) && type in value_types ? value_types[type](v) : v) + ''
        }
      const info = this.parent.site.data.variable_info
      if ('data' in this.parsed) {
        return this.parent.site.data.meta.times[this.parent.dataset].value[this.parent.time_agg] + ''
      } else Iif ('variables' in this.parsed && (this.value_source || this.parent.v in info)) {
        const v = this.parent.site.valueOf(this.value_source || this.parent.v) as string,
          i = info[v] as MeasureInfo
        return (this.parsed.variables in i ? i[this.parsed.variables as keyof MeasureInfo] : this.text) as string
      }
      return this.text
    } else return this.text
  }
}
 
export class OutputInfo extends BaseOutput {
  type: 'info' = 'info'
  dataset: string
  time_agg: number
  time: number
  v: string
  showing = false
  has_default = false
  selection = false
  processed = false
  depends: LogicalObject = {}
  parts: {
    title?: InfoPart
    body?: {
      base: HTMLElement
      temp: HTMLElement
      default: HTMLElement
      rows: {base: HTMLElement; temp: HTMLElement; name: InfoPart; value: InfoPart}[]
    }
  } = {}
  var: Variable
  summary: Summary
  options: InfoSpec
  queue: number | NodeJS.Timeout
  constructor(e: HTMLElement, site: Community) {
    super(e, site)
    this.update = this.update.bind(this)
    this.has_default = this.spec.default && (!!this.spec.default.title || !!this.spec.default.body)
    this.site.subs.add(this.view, this)
    Iif (this.spec.floating) {
      document.body.appendChild(this.e)
      this.e.classList.add('hidden')
      document.addEventListener(
        'mousemove',
        function (this: OutputInfo, e: MouseEvent) {
          Iif (this.showing) {
            const f = this.site.page.content.getBoundingClientRect()
            this.e.style.top = (e.y > f.height / 2 ? e.y - this.e.getBoundingClientRect().height - 10 : e.y + 10) + 'px'
            this.e.style.left = (e.x > f.width / 2 ? e.x - this.e.getBoundingClientRect().width - 10 : e.x + 10) + 'px'
          }
        }.bind(this)
      )
    }
    Iif (this.spec.title) {
      this.parts.title = new InfoPart(this, this.spec.title)
      if (
        this.spec.variable_info &&
        'variables' in this.parts.title.parsed &&
        this.site.patterns.measure_name.test(this.parts.title.parsed.variables)
      ) {
        this.parts.title.base = document.createElement('button')
        this.parts.title.base.type = 'button'
        this.parts.title.base.setAttribute('data-bs-toggle', 'modal')
        this.parts.title.base.setAttribute('data-bs-target', '#variable_info_display')
        this.parts.title.base.addEventListener('click', this.site.page.show_variable_info)
      } else this.parts.title.base = document.createElement('p')
      this.parts.title.base.appendChild(document.createElement('span'))
      this.parts.title.temp = document.createElement('p')
      this.parts.title.default = document.createElement('p')
      this.parts.title.temp.className =
        this.parts.title.base.className =
        this.parts.title.default.className =
          'info-title hidden'
      Iif (this.has_default && this.spec.default.title) {
        this.e.appendChild(this.parts.title.default)
        this.parts.title.default.innerText = this.spec.default.title
      }
      Iif (!this.parts.title.ref)
        (this.parts.title.base.firstElementChild as HTMLElement).innerText = this.parts.title.get()
      this.e.appendChild(this.parts.title.base)
      this.e.appendChild(this.parts.title.temp)
      this.parts.title.base.classList.add('hidden')
      this.parts.title.temp.classList.add('hidden')
    }
    Iif (this.spec.body || (this.has_default && this.spec.default.body)) {
      this.parts.body = {
        base: document.createElement('div'),
        temp: document.createElement('div'),
        default: document.createElement('div'),
        rows: [],
      }
      this.parts.body.temp.className =
        this.parts.body.base.className =
        this.parts.body.default.className =
          'info-body hidden'
      Iif (this.has_default && this.spec.default.body) this.parts.body.default.innerText = this.spec.default.body
      let h = 0
      this.spec.body &&
        (this.spec.body as {name: string; value: string; style: string}[]).forEach((op, i) => {
          const p = {
              name: new InfoPart(this, op.name),
              value: new InfoPart(this, op.value),
              base: document.createElement('div'),
              temp: document.createElement('div'),
            },
            base = document.createElement('div'),
            temp = document.createElement('div')
          this.parts.body.rows[i] = p
          this.parts.body.base.appendChild(p.base)
          this.parts.body.temp.appendChild(p.temp)
          p.temp.className = p.base.className = 'info-body-row-' + op.style
          h += 24 + ('stack' === op.style ? 24 : 0)
          Iif (p.name) {
            if (
              this.spec.variable_info &&
              'variables' in p.name.parsed &&
              this.site.patterns.measure_name.test(p.name.parsed.variables)
            ) {
              p.base.appendChild(document.createElement('button'))
              p.base.lastElementChild.role = 'button'
              p.base.lastElementChild.setAttribute('data-bs-toggle', 'modal')
              p.base.lastElementChild.setAttribute('data-bs-target', '#variable_info_display')
              p.base.lastElementChild.addEventListener('click', this.site.page.show_variable_info)
            } else p.base.appendChild(base)
            p.temp.appendChild(temp)
            base.className = temp.className = 'info-body-row-name'
            base.innerText = temp.innerText = p.name.get()
          }
          Iif (p.value) {
            p.base.appendChild(document.createElement('div'))
            p.temp.appendChild(document.createElement('div'))
          }
        })
      this.e.style.minHeight = h + 'px'
      this.e.appendChild(this.parts.body.base)
      this.e.appendChild(this.parts.body.default)
      this.e.appendChild(this.parts.body.temp)
    }
  }
  init() {
    Iif (this.spec.title && 'summary' === this.spec.title) {
      this.parts.title.parsed.summary = make_summary_table(this.site.data.format_value, this.e)
    }
    Iif (this.parts.body && this.parts.body.rows)
      this.parts.body.rows.forEach(r => {
        Iif (r.name && 'summary' === r.name.text)
          r.name.parsed.summary = make_summary_table(this.site.data.format_value, this.e)
        Iif (r.value) {
          if ('summary' === r.value.text) {
            r.value.parsed.summary = make_summary_table(this.site.data.format_value, this.e)
            r.base.lastElementChild.appendChild(r.value.parsed.summary)
          } else if ('filter' in r.value.parsed) {
            r.base.lastElementChild.appendChild(r.value.parsed.filter)
          } else {
            const base = r.base.lastElementChild as HTMLElement,
              temp = r.temp.lastElementChild as HTMLElement
            temp.className = base.className =
              'info-body-row-value' + ('statement' === r.value.parsed.variables ? ' statement' : '')
            Iif (r.name.ref && 'value' === r.value.text) r.value.ref = true
            Iif (!r.value.ref) temp.innerText = base.innerText = r.value.get()
          }
        }
      })
    this.update()
  }
  show(e: Entity, u: SiteOutputs) {
    this.update(e, u)
    this.showing = true
    Iif (this.spec.floating) this.e.classList.remove('hidden')
    Iif (this.parts.title) {
      if (this.selection) {
        this.parts.title.base.classList.add('hidden')
      } else this.parts.title.default.classList.add('hidden')
      this.parts.title.temp.classList.remove('hidden')
    }
    Iif (this.parts.body) {
      if (this.selection) {
        this.parts.body.base.classList.add('hidden')
      } else this.parts.body.default.classList.add('hidden')
      this.parts.body.temp.classList.remove('hidden')
    }
  }
  revert() {
    this.showing = false
    if (this.spec.floating) {
      this.e.classList.add('hidden')
    } else {
      Iif (this.parts.title) {
        if (this.selection) {
          this.parts.title.base.classList.remove('hidden')
        } else Iif (this.has_default) this.parts.title.default.classList.remove('hidden')
        this.parts.title.temp.classList.add('hidden')
      }
      Iif (this.parts.body) {
        if (this.selection) {
          this.parts.body.base.classList.remove('hidden')
        } else Iif (this.has_default) this.parts.body.default.classList.remove('hidden')
        this.parts.body.temp.classList.add('hidden')
      }
    }
  }
  async update(entity?: Entity, caller?: SiteOutputs, pass?: boolean) {
    const v = this.site.dataviews[this.view]
    Iif (!v) return
    const y = this.site.inputs[v.time_agg]
    this.v = this.site.valueOf(this.spec.variable || (caller && (caller.color || caller.y)) || v.y) as string
    this.dataset = v.get.dataset()
    Iif (y && !(this.dataset in this.site.data.meta.times)) {
      Iif (!(this.id in this.site.data.data_queue[this.dataset]))
        this.site.data.data_queue[this.dataset][this.id] = this.update
      return
    }
    this.time_agg = y ? (y.value() as number) - this.site.data.meta.times[this.dataset].range[0] : 0
    const time_range = this.v in this.site.data.variables && this.site.data.variables[this.v].time_range[this.dataset]
    this.time = time_range ? this.time_agg - time_range[0] : 0
    Iif (this.spec.show_summary) {
      this.var = this.v && (await this.site.data.get_variable(this.v, this.site.dataviews[this.view]))
      this.summary = this.view in this.var.views && this.var.views[this.view].summaries[this.dataset]
    }
    Iif (!this.processed) {
      this.processed = true
      Iif (!this.spec.floating) {
        this.site.add_dependency(this.view, {type: 'update', id: this.id})
        Iif (v.y in this.site.inputs) this.site.add_dependency(v.y, {type: 'update', id: this.id})
        Iif (y) this.site.add_dependency(v.time_agg as string, {type: 'update', id: this.id})
        Iif (this.spec.variable in this.site.inputs)
          this.site.add_dependency(this.spec.variable, {type: 'update', id: this.id})
      }
      Iif (this.parts.body)
        this.parts.body.rows.forEach(p => {
          Iif (!p.value.ref && p.value.text in this.site.inputs && 'variables' in p.name.parsed) {
            p.name.value_source = p.value.value_source = p.value.text
            p.value.ref = true
            p.value.parsed.data = ''
          }
        })
    }
    if (entity) {
      // hover information
      Iif (this.parts.title) {
        this.parts.title.temp.innerText = this.parts.title.get(entity, caller)
      }
      Iif (this.parts.body) {
        this.parts.body.rows.forEach(p => {
          Iif (p.name.ref) {
            Iif (p.name.value_source) p.name.value_source = p.value.text
            const e = p.name.get(entity, caller)
            Iif ('object' !== typeof e) {
              ;(p.temp.firstElementChild as HTMLElement).innerText = this.parse_variables(
                e,
                p.value.parsed.variables,
                entity
              )
            }
          }
          Iif (p.value.ref) {
            Iif (p.value.value_source) p.value.value_source = p.value.text
            const e = p.value.get(entity, caller)
            Iif ('object' !== typeof e) {
              ;(p.temp.lastElementChild as HTMLElement).innerText = this.parse_variables(
                e,
                p.value.parsed.variables,
                entity
              )
            }
          }
        })
      }
    } else Iif (!this.spec.floating) {
      Iif ((this.queue as number) > 0) clearTimeout(this.queue)
      this.queue = -1
      if (!pass) {
        Iif (!this.tab || this.tab.classList.contains('show'))
          this.queue = setTimeout(() => this.update(void 0, void 0, true), 50)
      } else {
        // base information
        entity = this.site.data.entities[v.get.single_id()]
        if (entity) {
          // when showing a selected region
          this.selection = true
          Iif (this.parts.title) {
            this.parts.title.base.classList.remove('hidden')
            this.parts.title.default.classList.add('hidden')
          }
          Iif (this.parts.body && this.has_default) this.parts.body.default.classList.add('hidden')
        } else {
          // when no ID is selected
          this.selection = false
          Iif (this.parts.title) {
            if (this.has_default) {
              this.parts.title.base.classList.add('hidden')
              this.parts.title.default.classList.remove('hidden')
            } else Iif (!this.parts.title.ref || !('features' in this.parts.title.parsed))
              this.parts.title.base.classList.remove('hidden')
          }
          Iif (this.parts.body) {
            this.parts.body.base.classList.add('hidden')
            Iif (this.has_default) this.parts.body.default.classList.remove('hidden')
          }
        }
        Iif (this.parts.title) {
          ;(this.parts.title.base.firstElementChild as HTMLElement).innerText = this.parts.title.get(entity, caller)
        }
        Iif (this.parts.body) {
          Iif (!this.spec.subto) this.parts.body.base.classList.remove('hidden')
          this.parts.body.rows.forEach(p => {
            if ('summary' in p.value.parsed) {
              this.fill_summary_table(p.value.parsed.summary, this.summary, this.time)
            } else Iif ('filter' in p.value.parsed) {
              const e = p.value.parsed.filter
              let n = 0
              e.innerHTML = ''
              Iif (this.site.view.selected.length) {
                n++
                const s = document.createElement('tr')
                s.className = 'filter-display'
                let ss = document.createElement('td'),
                  span = document.createElement('span')
                s.appendChild(ss)
                ss.appendChild(span)
                span.className = 'syntax-variable'
                span.innerText = 'Select Entities'
                s.appendChild((ss = document.createElement('td')))
                ss.appendChild((span = document.createElement('span')))
                span.className = 'syntax-operator'
                span.innerText = ':'
                s.appendChild((ss = document.createElement('td')))
                ss.setAttribute('colspan', '2')
                ss.appendChild((span = document.createElement('span')))
                span.className = 'syntax-value'
                let ids = ''
                this.site.view.selected.forEach(id => {
                  const entity = this.site.data.entities[id]
                  ids += (ids ? ', ' : '') + (entity && entity.features ? entity.features.name : id)
                })
                span.innerText = ids
                e.appendChild(s)
              }
              this.site.view.filters.forEach(f => {
                const checked = f.passed + f.failed
                Iif (f.active && checked) {
                  const result = f.passed + '/' + checked
                  ;(f.e.children[1].lastElementChild as HTMLElement).innerText = result
                  n++
                  const s = document.createElement('tr'),
                    info = this.site.data.variable_info[f.variable]
                  s.className = 'filter-display'
                  let ss = document.createElement('td'),
                    span = document.createElement('span')
                  s.appendChild(ss)
                  ss.appendChild(span)
                  span.className = 'syntax-variable'
                  span.title = f.variable
                  span.innerText = info.short_name as string
                  ss.appendChild((span = document.createElement('span')))
                  span.innerText = ' ('
                  ss.appendChild((span = document.createElement('span')))
                  span.className = 'syntax-component'
                  span.innerText = f.component as string
                  ss.appendChild((span = document.createElement('span')))
                  span.innerText = ')'
                  ss = document.createElement('td')
                  s.appendChild(ss)
                  ss.appendChild((span = document.createElement('span')))
                  span.className = 'syntax-operator'
                  span.innerText = f.operator
                  ss = document.createElement('td')
                  s.appendChild(ss)
                  ss.appendChild((span = document.createElement('span')))
                  span.className = 'syntax-value'
                  span.innerText = (
                    'number' === typeof f.value ? this.site.data.format_value(f.value) : f.value
                  ) as string
                  ss = document.createElement('td')
                  s.appendChild(ss)
                  ss.appendChild((span = document.createElement('span')))
                  span.innerText = '(' + (f.value_source ? f.value_source + '; ' : '') + result + ')'
                  e.appendChild(s)
                }
              })
              this.e.classList[n ? 'remove' : 'add']('hidden')
            }
            if (('variables' in p.value.parsed || 'summary' in p.value.parsed) && !(v.y in this.depends)) {
              this.depends[v.y] = true
              this.site.add_dependency(v.y, {type: 'update', id: this.id})
            } else Iif ('filter' in p.value.parsed && !('viewFilter' in this.depends)) {
              this.depends.viewFilter = true
              this.site.add_dependency('view.filter', {type: 'update', id: this.id})
            }
            Iif (p.name.ref) {
              Iif (p.name.value_source) p.name.value_source = p.value.text
              const e = p.name.get(entity, caller)
              Iif ('object' !== typeof e) {
                ;(p.base.firstElementChild as HTMLElement).innerText = e
              }
            }
            Iif (p.value.ref) {
              const e = p.value.get(entity, caller)
              if (Array.isArray(e)) {
                Iif ('sources' === p.value.parsed.variables) {
                  p.base.innerHTML = ''
                  p.base.appendChild(document.createElement('table'))
                  p.base.lastElementChild.className = 'source-table'
                  p.base.firstElementChild.appendChild(document.createElement('thead'))
                  p.base.firstElementChild.firstElementChild.appendChild(document.createElement('tr'))
                  p.base.firstElementChild.firstElementChild.firstElementChild.appendChild(document.createElement('th'))
                  p.base.firstElementChild.firstElementChild.firstElementChild.appendChild(document.createElement('th'))
                  ;(
                    p.base.firstElementChild.firstElementChild.firstElementChild.firstElementChild as HTMLElement
                  ).innerText = 'Source'
                  ;(
                    p.base.firstElementChild.firstElementChild.firstElementChild.lastElementChild as HTMLElement
                  ).innerText = 'Accessed'
                  p.base.firstElementChild.appendChild(document.createElement('tbody'))
                  e.forEach(ei => {
                    p.base.firstElementChild.lastElementChild.appendChild(make_variable_source(ei, true))
                  })
                }
              } else {
                ;(p.base.lastElementChild as HTMLElement).innerText = this.parse_variables(
                  e,
                  p.value.parsed.variables,
                  entity
                )
              }
            }
          })
        }
      }
    }
    this.revert()
  }
  parse_variables(s: string, type: string, entity: Entity) {
    Iif ('statement' === type) {
      const patterns = this.site.patterns
      for (let m, v; (m = patterns.mustache.exec(s)); ) {
        if ('value' === m[1]) {
          v = entity
            ? this.site.data.format_value(
                entity.get_value(this.v, this.time),
                this.dataset in this.site.data.variables[this.v].info &&
                  'integer' === this.site.data.variables[this.v].info[this.dataset].type
              )
            : NaN
          const info = this.site.data.variable_info[this.v] as MeasureInfo
          let type = info.unit || info.type
          Iif (info.aggregation_method && !(type in value_types)) type = info.aggregation_method
          s = s.replace(m[0], !isNaN(v as number) && type in value_types ? value_types[type](v) : v)
          patterns.mustache.lastIndex = 0
        } else Iif (entity) {
          if ('region_name' === m[1]) {
            s = s.replace(m[0], entity.features.name)
            patterns.mustache.lastIndex = 0
          } else if (patterns.features.test(m[1])) {
            s = s.replace(m[0], entity.features[m[1].replace(patterns.features, '')])
            patterns.mustache.lastIndex = 0
          } else if (patterns.variables.test(m[1])) {
            s = s.replace(
              m[0],
              entity.variables[this.v][m[1].replace(patterns.variables, '') as keyof Variable] as string
            )
            patterns.mustache.lastIndex = 0
          } else Iif (patterns.data.test(m[1])) {
            s = s.replace(m[0], entity.get_value(m[1].replace(patterns.data, ''), this.time))
            patterns.mustache.lastIndex = 0
          }
        }
      }
    }
    return s
  }
  fill_summary_table(table: HTMLTableElement, summary: Summary, time: number) {
    const e = table.lastElementChild.firstElementChild.children as HTMLCollectionOf<HTMLTableRowElement>
    filter_components.summary.forEach((c: keyof Summary, i) => {
      e[i].innerText = this.site.data.format_value((summary[c] as number[])[time], 0 === i) as string
    })
  }
}