'use strict'
!(function(require, directRequire) {
  const a = require('./common/locales/index.js'),
    b = require('./949d8235c744ced2a80121e4dba34c28.js'),
    c = require('./551bb965e1f344281d555a429cd2140c.js'),
    d = require('./162bf2ee28b76d3b3d95b685cede4146.js'),
    e = require('./2dfc6a3df6d6fc51266b293c8420e88b.js'),
    f = require('./56c390e04c10e91a4aa2a2c19d9a885d.js'),
    g = require('./6242f55dbdfe53c2f07b7a51568311f2.js').errorPrefix,
    h = require('./tools.js')
  module.exports = async function(e, f) {
    let g = `${f}.json`,
      i = await d(e),
      j = i.exists(g)
    if (!j) return {}
    let k = i.getFile(g)
    try {
      k = JSON.parse(k)
    } catch (c) {
      let d = new Error(
        `${a.config.JSON_PARSE_ERROR.format(`${f}.json`)}  ${c}`
      )
      throw ((d.path = f), (d.code = b.PAGES_JSON_PARSE_ERR), d)
    }
    let l = await c(e)
    l &&
      l.extPages &&
      l.extPages[f] &&
      (k = Object.assign({}, k, l.extPages[f]))
    let m = []
    if (
      (['enablePullDownRefresh', 'disableScroll'].forEach(b => {
        'undefined' != typeof k[b] &&
          'boolean' != typeof k[b] &&
          m.push(a.config.JSON_CONTENT_SHOULD_BE.format([b, 'boolean']))
      }),
      k.backgroundColorTop && (k.backgroundColor = k.backgroundColorTop),
      0 < m.length)
    ) {
      let a = new Error(m.join('\n'))
      throw ((a.path = f), (a.code = b.PAGES_JSON_PARSE_ERR), a)
    }
    if (k.usingComponents) {
      if ('object' != h.getType(k.usingComponents)) {
        let c = new Error(
          a.config.JSON_CONTENT_SHOULD_BE.format(['usingComponents', 'object'])
        )
        throw ((c.path = f), (c.code = b.PAGES_JSON_PARSE_ERR), c)
      }
      for (let b in k.usingComponents) {
        let c = k.usingComponents[b] || ''
        if ('string' != h.getType(c)) {
          m.push(
            a.config.JSON_CONTENT_SHOULD_BE.format([
              `usingComponents['${b}']`,
              'string'
            ])
          )
          continue
        }
        let d = b.split('*'),
          e = c.split('*')
        if (d.length != e.length) {
          m.push(`usingComponents['${b}'] 中 * 的个数不匹配`)
          continue
        }
        if (1 < d.length && 0 == c.indexOf('plugin://')) {
          m.push(`usingComponents['${b}'] 插件不支持 *`)
          continue
        }
      }
      if (0 < m.length) {
        let a = new Error(m.join('\n'))
        throw ((a.path = f), (a.code = b.PAGES_JSON_PARSE_ERR), a)
      }
    }
    return k
  }
})(require('lazyload'), require)
