'use strict'
!(function(require, directRequire) {
  function a(a, e = {}) {
    let { srcFilePath: f, fileBuffer: g, destFilePath: l } = e,
      m = c.extname(f)
    if (k[m]) {
      let a = i(g)
      if (void 0 === a) {
        let a = new Error(h.config.FILE_NOT_UTF8.format(f))
        throw ((a.code = j), a)
      }
    }
    let n = c.dirname(l)
    d.sync(n), b.writeFileSync(l, g)
  }
  const b = require('fs'),
    c = require('path'),
    d = require('mkdir-p'),
    e = require('./162bf2ee28b76d3b3d95b685cede4146.js'),
    f = require('./a63026ab5a5a3c59a61a9749a18aa2ca.js'),
    g = require('./9fdd4ac31a05c27355910f0d74accd4c.js'),
    h = require('./common/locales/index.js'),
    { bufToUTF8: i } = require('./efc820e1b92d6e4063535296d4a24213.js'),
    { FILE_NOT_UTF8: j } = require('./949d8235c744ced2a80121e4dba34c28.js'),
    k = { '.json': !0, '.wxml': !0, '.wxs': !0 },
    {
      whiteFileExtName: l,
      gameWhiteFileExtName: m
    } = require('./6242f55dbdfe53c2f07b7a51568311f2.js'),
    n = { '.js': !0, '.wxss': !0 }
  module.exports = async function(d, h = {}) {
    let i = d.compileType,
      { distPath: j } = h,
      k = await e(d),
      o = k.getAllFile(),
      p = l
    d.attr && d.attr.gameApp && (p = m)
    let q = i == g.plugin ? d.miniprogramRoot : ''
    for (let b = 0, e = o.length; b < e; b++) {
      let e = o[b],
        f = c.extname(e)
      if (!n[f] && p[f]) {
        if (
          (!d.attr ||
            !d.attr.platform ||
            !d.attr.extInfo ||
            !d.attr.extInfo.appid) &&
          'ext.json' === e
        )
          continue
        let b = k.getFile(e, null)
        a(d, {
          fileBuffer: b,
          srcFilePath: c.join(q, e),
          destFilePath: c.join(j, q, e)
        })
      }
    }
    if (i == g.plugin) {
      ;(k = await f(d)),
        (o = k.getAllFile()),
        (p = l),
        (q = d.pluginRoot),
        d.attr && d.attr.gameApp && (p = m)
      for (let b = 0, e = o.length; b < e; b++) {
        let e = o[b],
          f = c.extname(e)
        if (!n[f] && p[f]) {
          let b = k.getFile(e, null)
          a(d, {
            fileBuffer: b,
            srcFilePath: c.join(q, e),
            destFilePath: c.join(j, q, e)
          })
        }
      }
      b.writeFileSync(
        c.join(j, 'project.config.json'),
        JSON.stringify({
          miniprogramRoot: d.miniprogramRoot,
          pluginRoot: d.pluginRoot
        })
      )
    }
  }
})(require('lazyload'), require)
