'use strict'
!(function(require, directRequire) {
  function a(a, b) {
    return function() {
      return b(a.apply(void 0, arguments))
    }
  }
  const b = require('path'),
    c = require('url'),
    d = require('querystring'),
    e = require('./df6d0ff021a69fb541c733de4dbba0fe.js'),
    f = require('./common/locales/index.js'),
    g = require('redux'),
    h = require('./6242f55dbdfe53c2f07b7a51568311f2.js'),
    i = require('./9fdd4ac31a05c27355910f0d74accd4c.js')
  module.exports = {
    parseCgiErrorCode: function(a, b) {
      let c = f.config
      switch (a) {
        case e.NOT_LOGIN:
        case e.INVALID_LOGIN:
        case e.INVALID_TOKEN:
        case e.DEV_INVALID_SIGNATURE:
        case e.DEV_NEED_RELOGIN:
          return c.CGI_ERR_NEED_RELOGIN
        case e.NOT_LIMITS_CARD:
          return c.CGI_ERR_NO_PERMISSION
        case e.DEV_APP_NOT_BAND:
          return c.CGI_ERR_NOT_BAND
        case e.DEV_NEED_ADMIN:
          return c.CGI_ERR_NEED_ADMIN
        case e.DEV_NEED_UPDATE:
          return c.CGI_ERR_NEED_UPDATE
        case e.DEV_NEED_SCAN_CODE:
          return c.CGI_ERR_NEED_SCAN_CODE
        case e.DEV_COMPILE_EMPTY_SOURCE:
          return c.CGI_ERR_EMPTY_SOURCE
        case e.DEV_COMPILE_SOURCE_MAX_LIMIT:
          return c.CGI_ERR_SOURCE_MAX_LIMIT
        case e.DEV_COMPILE_WXPKG_MAX_LIMIT:
          return c.CGI_ERR_WXPKG_MAX_LIMIT
        case e.DEV_COMPILE_INVALID_WXPKG:
          return c.CGI_ERR_INVALID_WXPKG
        case e.DEV_COMPILE_WXML_FAIL:
          return c.CGI_ERR_WXML_FAIL.format(b)
        case e.DEV_COMPILE_WXSS_FAIL:
          return c.CGI_ERR_WXSS_FAIL.format(b)
        case e.DEV_COMPILE_INVALID_FILE:
          return c.CGI_ERR_INVALID_FILE.format(b)
        case e.DEV_COMPILE_INVALID_JSON_FILE:
          return c.CGI_ERR_INVALID_JSON.format(b)
        case e.DEV_COMPILE_LACK_OF_FILE:
          return c.CGI_ERR_LACK_OF_FILE.format(b)
        case e.DEV_BIND_NOT_24H:
          return c.CGI_ERR_BIND_NOT_24H
        case e.DEV_PLATFORM_NOT_BAND_DEV:
          return c.CGI_ERR_PLATFORM_NOT_BAND
        case e.DEV_PLATFORM_INVALID_EXT_APPID:
          return c.CGI_ERR_PLATFORM_INVALID_EXT_APPID
        case e.DEV_PLATFORM_EXT_APPID_NOT_AUTH:
          return c.CGI_ERR_PLATFORM_EXT_APPID_NOT_AUTH
        case e.NOT_LIMITS:
          return c.CGI_ERR_NOT_LIMITS
        case e.NOT_LIMITS_QY:
          return c.CGI_ERR_NOT_LIMITS_QY
        case e.DEV_INVALID_APPID:
          return c.CGI_ERR_DEV_INVALID_APPID
        case e.DEV_CLOUD_NO_PERMISSION:
          return c.CGI_ERR_DEV_CLOUD_NO_PERMISSION
        case e.DEV_CLOUD_NO_PRODUCT_ENV:
          return c.CGI_ERR_DEV_CLOUD_NO_PRODUCT_ENV
        case e.DEV_CLOUD_INVALID_RESP_DATA:
          return c.CGI_ERR_DEV_CLOUD_INVALID_RESP_DATA
        case e.DEV_CLOUD_SYNC_CALLBACK_ERR:
        case e.DEV_CLOUD_ASYNC_CALLBACK_ERR:
          return c.CGI_ERR_DEV_CLOUD_CALLBACK_ERR.format(a)
        case e.DEV_CLOUD_NO_CLOUD_ACCOUNT:
          return c.CGI_ERR_DEV_CLOUD_NO_CLOUD_ACCOUNT
        case e.DEV_CLOUD_EVENT_EXPIRED:
          return c.CGI_ERR_DEV_CLOUD_EVENT_EXPIRED
        case e.DEV_CLOUD_INVALID_ACTION:
          return c.CGI_ERR_DEV_CLOUD_INVALID_ACTION
        case e.CGI_ERR_USER_CAN_NOT_ACCESS_APP:
          return c.CGI_ERR_USER_CAN_NOT_ACCESS_APP
        case e.CGI_ERR_APP_NOT_EXIST:
          return c.CGI_ERR_APP_NOT_EXIST
        case e.CGI_ERR_APP_VERSION_NOT_EXIST:
          return c.CGI_ERR_APP_VERSION_NOT_EXIST
        case e.DEV_CLOUD_NO_DEVELOP_ENV:
          return (
            c.CGI_ERR_DEV_CLOUD_NO_DEVELOP_ENV ||
            '\u672A\u5F00\u901A\u6D4B\u8BD5\u73AF\u5883'
          )
        case e.DEV_CLOUD_NO_AUTH: {
          try {
            nw.Shell.openExternal(
              'https://cloud.tencent.com/developer/ask/24861/answer/27432'
            )
          } catch (a) {}
          return (
            c.CGI_ERR_DEV_CLOUD_NO_AUTH ||
            '\u672A\u6388\u6743\u817E\u8BAF\u4E91'
          )
        }
        case e.DEV_LIMIT:
          return c.CGI_ERR_NOT_DEV_LIMIT || b
        case e.DEV_INVALID_PLUGIN_VERSION:
          return c.CGI_ERR_DEV_INVALID_PLUGIN_VERSION + ',' + b
        case e.DEV_PLUGIN_NOT_FOUND:
          return c.CGI_ERR_DEV_PLUGIN_NOT_FOUND + ',' + b
        case e.DEV_DEVPLUGIN_NOT_DEFINED:
          return c.CGI_ERR_DEV_DEVPLUGIN_NOT_DEFINED
        case e.DEV_PLUGIN_ROOT_NOT_DEFINED:
          return c.CGI_ERR_DEV_PLUGIN_ROOT_NOT_DEFINED
        case e.DEV_TWO_SAME_PLUGIN_FOUND:
          return c.CGI_ERR_DEV_TWO_SAME_PLUGIN_FOUND + ',' + b
        case e.DEV_COMPILE_SOURCE_MAX_LIMIT_SUBPKG:
          return c.CGI_ERR_DEV_COMPILE_SOURCE_MAX_LIMIT_SUBPKG + ',' + b
        case e.DEV_PLUGIN_NOT_INITTED:
          return c.CGI_ERR_DEV_PLUGIN_NOT_INITTED + ',' + b
        default:
          return b || c.CGI_ERR_SYSTEM_ERROR.format(a)
      }
    },
    parseUrl: function(a) {
      let b = c.parse(a)
      return {
        pathName: b.pathname.replace(/\.html$/, ''),
        query: d.parse(b.query)
      }
    },
    getProjectHashFromURL: function(a) {
      let b = a.replace(/https?:\/\//, '').split('.')
      return b[0]
    },
    bindActionCreators: function(b, c) {
      if ('[object Function]' == Object.prototype.toString.call(b))
        return a(b, c)
      for (var d = Object.keys(b), e = {}, f = 0; f < d.length; f++) {
        var g = d[f],
          h = b[g]
        '[object Function]' == Object.prototype.toString.call(h) &&
          (e[g] = a(h, c))
      }
      return e
    },
    getWidgetOffset: function(a, b) {
      if (a == i.search)
        return {
          width: b.screenWidth - 30,
          height: (b.screenWidth - 30) * h.default_search_widget_radio
        }
      if (a == i.conversation) {
        let a = 0.6 * b.screenWidth
        return (
          ('iPhone 6' == b.title || 'iPhone 6 Plus' == b.title) &&
            (a = 0.56 * b.screenWidth),
          { height: a * h.default_conversation_widget_radio, width: a }
        )
      }
    },
    getWidgetDirectory: function(a, b) {
      try {
        for (let c, d = 0, e = b.widgets.length; d < e; d++)
          if (((c = b.widgets[d]), c.type == a)) return c.path
      } catch (a) {}
      return ''
    },
    strToHash: function(a) {
      let b,
        c,
        d,
        e = 0
      if (0 === a.length) return e
      for (b = 0, d = a.length; b < d; b++)
        (c = a.charCodeAt(b)), (e = (e << 5) - e + c), (e |= 0)
      return 0 < e ? e : 0 - e
    },
    checkIsInSubPackage: function(a, c) {
      c = b.posix.normalize(c)
      let d
      if (a.subPackages)
        for (let e = 0, f = a.subPackages.length; e < f; e++) {
          let f = a.subPackages[e],
            g = b.posix.normalize(f.root + '/')
          if (0 == c.indexOf(g)) {
            d = f
            break
          }
        }
      return d
    },
    checkInGameSubPackage: function(a, c) {
      ;(c = b.posix.normalize(c)), 0 != c.indexOf('/') && (c = '/' + c)
      let d
      if (a.subPackages)
        for (let e, f = 0, g = a.subPackages.length; f < g; f++)
          if (((e = a.subPackages[f]), !/\.js$/.test(e.root))) {
            let a = b.posix.normalize(e.root + '/')
            if (0 == c.indexOf(a)) {
              d = e
              break
            }
          } else if (c == e.root) {
            d = e
            break
          }
      return d
    }
  }
})(require('lazyload'), require)
