'use strict'
!(function(require, directRequire) {
  async function a(a) {
    let c, h, q
    a.tempProject
      ? ((c = a.tempProject.attr), (h = a.tempProject))
      : ((c = p.getCurrentConfig()), (h = p.getCurrent()))
    try {
      const a = await n(h)
      q = a.subPackages
        ? c.setting.MaxSubpackageFullCodeSize || c.setting.MaxCodeSize
        : c.setting.MaxCodeSize
    } catch (a) {
      try {
        q = c.setting.MaxCodeSize
      } catch (a) {
        q = 2
      }
    }
    let v = 1024 * q
    const y = a.onProgressUpdate || w,
      z = a.onFilesMissing || w
    y('buildstart', '\u6B63\u5728\u7F16\u8BD1\u4EE3\u7801')
    let A = await k(h, {
      noCompile: !0,
      onProgressUpdate: y,
      onFilesIgnored: a.onFilesIgnored
    })
    y('globfiles', '\u6B63\u5728\u5BF9\u6BD4\u6587\u4EF6\u5217\u8868')
    const B = [
      'node_modules/**/*',
      '**/node_modules/**',
      '**/.git/**',
      '.git/**/*',
      '**/.svn/**',
      '.svn/**/*',
      '.DS_Store',
      '**/.DS_Store'
    ]
    let C = await x('**', {
      nodir: !0,
      ignore: B,
      nosort: !0,
      strict: !1,
      silent: !0,
      cwd: A,
      absolute: !1,
      mark: !0,
      dot: !0
    })
    const D = (h.packOptions || {}).ignore || [],
      E = []
    for (const c of C)
      u.isFileIgnored(c, D) ? b.unlinkSync(d.join(A, c)) : E.push(c)
    C = E
    let F = h.projectpath
    'plugin' === h.compileType
      ? (F = h.projectpath)
      : h.miniprogramRoot &&
        (F = d.posix.join(h.projectpath, h.miniprogramRoot))
    const G = await x('**', {
        nodir: !0,
        ignore: B,
        nosort: !0,
        strict: !1,
        silent: !0,
        cwd: F,
        absolute: !1,
        mark: !0,
        dot: !0
      }),
      H =
        G.filter(a => {
          return 0 > C.findIndex(b => b === a)
        }) || [],
      I =
        (await x('**/node_modules/', {
          nosort: !0,
          strict: !1,
          silent: !0,
          cwd: F,
          absolute: !1,
          mark: !0,
          dot: !0
        })) || []
    H.push(...I),
      z(H),
      y('buildend', '\u7F16\u8BD1\u4EE3\u7801\u5B8C\u6210'),
      y('packstart', '\u6B63\u5728\u6253\u5305')
    let J = d.join(r, `${+new Date()}.wx`),
      K = await l(A, J)
    b.unlink(J, () => {}),
      y('packend', '\u6253\u5305\u5B8C\u6210'),
      y('uploadstart', '\u6B63\u5728\u4E0A\u4F20')
    let L = K.data,
      M = K.pDestPath
    f(A, () => {})
    let N = parseInt(K.totalSize / 1024)
    if (N > v) {
      let a = new Error(o.config.CODE_SIZE_EXCEED.format([N, v]))
      throw ((a.code = j.CODE_SIZE_EXCEED), a)
    }
    let O,
      P = global.appConfig.isBeta
    if (a.test) {
      if (
        ((m[`last-up-test-${h.projectid}`] = N),
        (O = P
          ? `${i.testSourceNewFeatureURL}?gzip=1`
          : `${i.testSourceURL}?gzip=1`),
        a.remoteDebug)
      ) {
        let b = 1
        'ios' === a.remoteDebugLocal
          ? (b = 2)
          : 'android' === a.remoteDebugLocal && (b = 3)
        const c = a.remoteProxyPort || 0,
          d = a.disableUrlCheck ? 1 : 0
        O = `${
          i.testSourceURL
        }?gzip=1&open_remote=yes&remote_network_type=${b}&remote_proxy_port=${c}&disable_url_check=${d}&remote_support_compress_algo=1`
      }
      a.liveReload && (O += '&hot_update=yes')
      let { page: b, query: c, searchQuery: d, boxQI: e } = a
      if (b) {
        let a = encodeURIComponent(`${b}?${c}`)
        O = `${O}&path=${a}`
      }
      if (h.attr.gameApp && c) {
        let a = encodeURIComponent(`?${c}`)
        O = `${O}&path=${a}`
      }
      if ((d && (O = `${O}&search_query=${encodeURIComponent(d)}`), e)) {
        O = `${O}&search_extInfo=${encodeURIComponent(
          JSON.stringify({ box_qi: e })
        )}`
      }
    } else {
      m[`last-up-load-${h.projectid}`] = N
      let b = encodeURIComponent(a.desc),
        c = encodeURIComponent(a.version),
        d = encodeURIComponent(a.uuid)
      O = P
        ? `${
            i.commitSourceNewFeatureURL
          }?user-version=${c}&user-desc=${b}&uuid=${d}&gzip=1`
        : `${
            i.commitSourceURL
          }?user-version=${c}&user-desc=${b}&uuid=${d}&gzip=1`
    }
    let Q = e.gzipSync(L)
    const R = 1 * new Date(),
      S = a.tempProject
        ? {
            url: `${O}&appid=${a.tempProject.appid}&devplugin=${
              h.compileType == t.plugin ? 1 : 0
            }`,
            method: 'post',
            body: Q,
            needToken: 1
          }
        : {
            url: `${O}&devplugin=${h.compileType == t.plugin ? 1 : 0}`,
            method: 'post',
            body: Q,
            needToken: 1,
            needAppID: 1
          }
    a.tempProject &&
      a.tempProject.attr &&
      (a.tempProject.attr.platform && (S.url += '&platform=1'),
      a.tempProject.attr.platform &&
        a.tempProject.attr.extInfo &&
        (S.url += `&ext_appid=${a.tempProject.attr.extInfo.appid || ''}`))
    let { body: T } = await g(S)
    const U = 1 * new Date()
    return (
      s(
        a.test ? 'client_test_source_time' : 'client_commit_source_time',
        h.appid,
        `${U - R}`
      ),
      y('uploadend', '\u4E0A\u4F20\u5B8C\u6210'),
      T
    )
  }
  const b = require('fs'),
    c = require('glob'),
    d = require('path'),
    e = require('zlib'),
    f = require('rmdir'),
    g = require('./15ba1827c7f6564a45df6bd44da3a977.js'),
    h = require('./92320c1386e6db6a6f2556736a9bc280.js'),
    i = require('./f171257bbcaef547a3cf27266ccb0db2.js'),
    j = require('./949d8235c744ced2a80121e4dba34c28.js'),
    k = require('./911222a6723da8db7ca8a8e3689591e1.js'),
    l = require('./e5fa35c3c8e81bc6466b4b8eb436113b.js'),
    m = require('./84858de8a097c9cf84ff2c2e3d86e2a9.js'),
    n = require('./1dea83a77e99a7c94f6b6f01f5c175b0.js'),
    o = require('./common/locales/index.js'),
    p = require('./3bfffbe88b3d923921f851c0697974fe.js'),
    q = require('./logger.js'),
    r = h.Weappdest,
    s = require('./da7c31daaf542cf1796023d8e344b98a.js'),
    t = require('./9fdd4ac31a05c27355910f0d74accd4c.js'),
    u = require('./1c8a8c710417d102ab574145dc51b4b0.js'),
    v = require('./a932aac82ac84fc9c6c92194bd88204e.js'),
    w = () => {},
    x = function(a, b) {
      return new Promise(d => {
        c(a, b, (a, b) => {
          a ? d([]) : d(b)
        })
      })
    }
  module.exports = async function(b) {
    return v.enqueueBuildTask(a.bind(null, b), v.buildType.upload)
  }
})(require('lazyload'), require)
