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

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

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

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

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

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

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

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