'use strict'
!(function(require, directRequire) {
  function a() {
    if (k) {
      k.removeAllListeners(),
        k.kill('SIGTERM'),
        (k = null),
        (l = null),
        (i = void 0),
        clearTimeout(j),
        (j = void 0)
      for (const a of m) a[1](l)
      m = []
    }
  }
  function b(b) {
    return !k || k.killed
      ? void 0
      : b
        ? void a()
        : void (
            void 0 != j ||
            (j = setTimeout(() => {
              a()
            }, 5e3))
          )
  }
  function c(a) {
    ;(l = a), (i = !0)
    for (const b of m) b[0](l)
    m = []
  }
  function d() {
    let b = e.join(e.dirname(process.execPath), 'node')
    'darwin' !== process.platform && (b += '.exe'),
      (k = f.spawn(b, ['--expose-gc', g], {
        stdio: ['ipc'],
        env: { START_SERVER: 'yes' }
      })),
      k.stdout.setEncoding('utf8'),
      k.stdout.on('data', a => {
        console.log('stdout: ' + a)
      }),
      k.stderr.on('data', a => {
        console.log('stderr: ' + a)
      })
    const d = k,
      h = () => {
        k === d && a()
      }
    k.on('disconnect', h),
      k.on('close', h),
      k.on('exit', () => {
        h()
      }),
      k.on('error', () => {
        try {
          h()
        } catch (a) {}
      }),
      k.on('message', a => {
        console.log('child process message', a),
          'object' == typeof a && a.httpReady && !i && c(a.port)
      })
  }
  const e = require('path'),
    f = require('child_process'),
    {
      fileName: g,
      dirName: h
    } = require('./4c80b71f4868859dd3ff3e4df5161315.js')
  let i,
    j,
    k = null,
    l = null
  let m = []
  module.exports = {
    start: async function() {
      return k && !k.killed && (clearTimeout(j), (j = void 0), l)
        ? l
        : new Promise((a, c) => {
            if (!k || k.killed)
              try {
                d()
              } catch (a) {
                c(a)
              }
            m.push([a, c]),
              setTimeout(() => {
                k &&
                  !i &&
                  (console.warn('server init fail within 10 sec'),
                  b(),
                  c(new Error('server init fail. Please retry.')))
              }, 1e4)
          })
    },
    stop: b
  }
})(require('lazyload'), require)
