'use strict'
!(function(require, directRequire) {
  'use strict'
  Object.defineProperty(exports, '__esModule', { value: !0 })
  const a = require('./46d7303eb986fa402d60bf5e929aa077.js'),
    b = require('./a148d3a11fd5268109e21fb40c9d527b.js'),
    c = require('fs'),
    d = require('path'),
    e = require('mkdir-p'),
    f = 20,
    g = () => {}
  class h {
    constructor(b) {
      ;(this.counters = {
        log: a.dateStamp(),
        warn: a.dateStamp(),
        error: a.dateStamp(),
        assertion: a.dateStamp()
      }),
        (this.timers = {}),
        (this.caches = {}),
        (this.warnCounter = 0),
        (this.errorCounter = 0),
        (this.assertionCounter = 0),
        (this.logFolder = b.logFolder),
        (this.logFileForWarnings = b.logFileForWarnings),
        (this.logFileForErrors = b.logFileForErrors),
        (this.logFileForAssertions = b.logFileForAssertions),
        e.sync(this.logFolder),
        this.init.call(this)
    }
    init() {
      const b = this.getProperty('logFolder'),
        e = c.readdirSync(b),
        g = { log: [], warn: [], error: [], assertion: [] }
      for (const a of e) {
        const e = d.join(b, a),
          f = c.statSync(e)
        a.startsWith('log.')
          ? g.log.push({
              filePath: e,
              createTime: parseInt(f.birthtime.getTime() / 1e3 + '')
            })
          : a.startsWith('warn.')
            ? g.warn.push({
                filePath: e,
                createTime: parseInt(f.birthtime.getTime() / 1e3 + '')
              })
            : a.startsWith('error.')
              ? g.error.push({
                  filePath: e,
                  createTime: parseInt(f.birthtime.getTime() / 1e3 + '')
                })
              : a.startsWith('assertion.') &&
                g.assertion.push({
                  filePath: e,
                  createTime: parseInt(f.birthtime.getTime() / 1e3 + '')
                })
      }
      const h = this.getProperty('counters')
      for (const b in g) {
        if (!g.hasOwnProperty(b)) continue
        const d = g[b]
        if (
          (d.sort((c, a) => {
            return c.createTime < a.createTime ? 1 : -1
          }),
          d.length >= f)
        )
          for (let a = f; a < d.length; a++) {
            const b = d[a]
            try {
              c.unlinkSync(b.filePath)
            } catch (a) {}
          }
        h[b] = a.dateStamp(new Date(), !0)
      }
    }
    get i() {
      return a.isDev
        ? console.log.bind(console, a.timeStamp(), this.identifier)
        : g
    }
    get i_() {
      return console.log.bind(console, a.timeStamp(), this.identifier)
    }
    get w() {
      return this.logFileForWarnings
        ? (...b) => {
            this.logWarn.call(this, ...b),
              console.warn(a.timeStamp(), this.identifier, ...b)
          }
        : console.warn.bind(console, a.timeStamp(), this.identifier)
    }
    get w_() {
      return console.warn.bind(console, a.timeStamp(), this.identifier)
    }
    get e_() {
      return console.error.bind(console, a.timeStamp(), this.identifier)
    }
    get e() {
      return this.logFileForErrors
        ? (...b) => {
            this.logError.call(this, ...b),
              console.error(a.timeStamp(), this.identifier, ...b)
          }
        : console.error.bind(console, a.timeStamp(), this.identifier)
    }
    get assert() {
      return this.logFileForAssertions
        ? (...b) => {
            this.logAssertion.call(this, ...b),
              console.error(a.timeStamp(), this.identifier, ...b)
          }
        : console.error.bind(
            console,
            a.timeStamp(),
            this.identifier,
            '[ASSERTION]'
          )
    }
    get assert_() {
      return console.error.bind(
        console,
        a.timeStamp(),
        this.identifier,
        '[ASSERTION]'
      )
    }
    get f() {
      return this.logLog.bind(this)
    }
    get f_() {
      return g
    }
    logLog(...b) {
      this.logToFile.call(
        this,
        'log',
        `${this.identifier} ${a.timeStamp()} :: ${b.join(' ')}`
      )
    }
    logWarn(...b) {
      this.logToFile.call(
        this,
        'warn',
        `${this.identifier} ${a.timeStamp()} :: ${b.join(' ')}`
      )
    }
    logError(...b) {
      this.logToFile.call(
        this,
        'error',
        `${this.identifier} ${a.timeStamp()} :: ${b.join(' ')}`
      )
    }
    logAssertion(...b) {
      this.logToFile.call(
        this,
        'assertion',
        `${this.identifier} ${a.timeStamp()} :: ${b.join(' ')}`
      )
    }
    logToFile(a, b) {
      const e = this.getProperty('caches')
      e[a] = (e[a] || '') + '\n' + b
      const f = this.getProperty('timers')
      f[a] ||
        (f[a] = setTimeout(() => {
          f[a] = void 0
          const b = this.getProperty('counters'),
            g = this.getProperty('logFolder'),
            h = d.join(g, `${a}.${b[a] || 0}.txt`)
          let i = ''
          try {
            i = c.readFileSync(h, 'utf-8')
          } catch (a) {
            i = ''
          }
          ;(i += e[a]), (e[a] = '')
          try {
            c.writeFileSync(h, i, 'utf-8'), i.length > 512000 && (b[a] += '.1')
          } catch (a) {}
        }, 5e3))
    }
    setProperty(a, b) {
      this[a] = b
    }
    getProperty(a) {
      return this[a]
    }
  }
  const i = new h({
      identifier: '[not provided]',
      logFolder: b.RemoteLogDir,
      logFileForWarnings: !0,
      logFileForErrors: !0,
      logFileForAssertions: !0
    }),
    j = i.getProperty.bind(i),
    k = i.setProperty.bind(i)
  exports.default = function(a) {
    const b = { identifier: a, setProperty: k, getProperty: j }
    return Object.setPrototypeOf(b, i), b
  }
})(require('lazyload'), require)
