function e(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}

function i(e, i, t) {
    return i in e ? Object.defineProperty(e, i, {
        value: t,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[i] = t, e;
}

function t(e) {
    console.log(e);
}

function a(e) {
    var i = e.target.dataset.from, t = e.target.dataset.idx;
    void 0 !== i && 0 < i.length && r(e, t, this, i);
}

function r(e, t, a, r) {
    var h, o = a.data[r];
    if (o && 0 != o.images.length) {
        var g, l = o.images;
        g = l[t].width ? d(e.detail.width, e.detail.height, a, r, l[t]) : n(e.detail.width, e.detail.height, a, r), 
        console.log(g);
        var s = l[t].index, m = "" + r, v = !0, u = !1, f = void 0;
        try {
            for (var c, w = s.split(".")[Symbol.iterator](); !(v = (c = w.next()).done); v = !0) m += ".nodes[" + c.value + "]";
        } catch (e) {
            u = !0, f = e;
        } finally {
            try {
                !v && w.return && w.return();
            } finally {
                if (u) throw f;
            }
        }
        var x = m + ".width", P = m + ".height";
        a.setData((i(h = {}, x, g.imageWidth), i(h, P, g.imageheight), h));
    }
}

function n(e, i, t, a) {
    var r, n = 0, d = 0, h = {}, o = t.data[a].view.imagePadding;
    return (r = g - 2 * o) < e ? (d = (n = r) * i / e, h.imageWidth = n, h.imageheight = d) : (h.imageWidth = e, 
    h.imageheight = i), h;
}

function d(e, i, t, a, r) {
    console.log(r);
    var n = r.attr.style, d = n.indexOf("width:"), h = "";
    -1 != d && (h = n[d + 1]);
    var o = h.search("%;"), l = h.search("px;"), s = "", m = "", v = "";
    if (0 < o && h.length == o + 2 && (s = h.slice(0, -2)), 0 < l && h.length == l + 3) {
        m = h.slice(0, -3);
        var u = n.indexOf("height:"), f = "";
        -1 != u && (f = n[u + 1]);
        var c = f.search("px;");
        0 < c && f.length == c + 3 && (v = f.slice(0, -3));
    }
    var w, x = 0, P = 0, y = {}, j = t.data[a].view.imagePadding;
    return w = g - 2 * j, s ? (P = (x = w * s / 100) * i / e, y.imageWidth = x, y.imageheight = P) : m && v && m <= w ? (y.imageWidth = m, 
    y.imageheight = v) : w < e ? (P = (x = w) * i / e, y.imageWidth = x, y.imageheight = P) : (y.imageWidth = e, 
    y.imageheight = i), y;
}

var h = e(require("./showdown.js")), o = e(require("./html2json.js")), g = 0, l = 0;

wx.getSystemInfo({
    success: function(e) {
        g = e.windowWidth, l = e.windowHeight;
    }
}), module.exports = {
    wxParse: function() {
        var e = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : "wxParseData", i = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : "html", r = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : '<div class="color:red;">数据不能为空</div>', n = arguments[3], d = arguments[4], g = n, l = {};
        if ("html" == i) l = o.default.html2json(r, e); else if ("md" == i || "markdown" == i) {
            var s = new h.default.Converter().makeHtml(r);
            l = o.default.html2json(s, e);
        }
        l.view = {}, void (l.view.imagePadding = 0) !== d && (l.view.imagePadding = d);
        var m = {};
        m[e] = l, g.setData(m), g.wxParseImgTap = t, g.wxParseImgLoad = a;
    },
    wxParseTemArray: function(e, i, t, a) {
        for (var r = [], n = a.data, d = null, h = 0; h < t; h++) {
            var o = n[i + h].nodes;
            r.push(o);
        }
        e = e || "wxParseTemArray", (d = JSON.parse('{"' + e + '":""}'))[e] = r, a.setData(d);
    },
    emojisInit: function() {
        var e = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : "", i = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : "/wxParse/emojis/", t = arguments[2];
        o.default.emojisInit(e, i, t);
    }
};