var e, n, r; (e = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (e) { return typeof e; } : function (e) { return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e; }), (n = (function () { function e(e, n) { for (var r = 0; r < n.length; r++) { var t = n[r]; (t.enumerable = t.enumerable || !1), (t.configurable = !0), "value" in t && (t.writable = !0), Object.defineProperty(e, t.key, t); } } return function (n, r, t) { return r && e(n.prototype, r), t && e(n, t), n; }; })()), (r = (function () { function r(e) { !(function (e, n) { if (!(e instanceof n)) throw new TypeError("Cannot call a class as a function"); })(this, r); var n = this; for (var t in (e = e || {})) n.config[t] = e[t]; n.m = {}; var i = { html: !0, xhtmlOut: !0, typographer: !0, highlight: function (e, r, t) { return n.m.highlight.highlightAuto(e).value; }, }; global ? ((n.m.html2json = require("./lib/html2json")), (n.m.highlight = require("./plugins/hljs/index")), (n.m.md = require("./lib/markdown-it")(i)), (n.m.md_sub = require("./plugins/markdown-it-sub")), (n.m.md_sup = require("./plugins/markdown-it-sup")), (n.m.md_ins = require("./plugins/markdown-it-ins")), (n.m.md_mark = require("./plugins/markdown-it-mark"))) : window && ((n.m.html2json = window.html2json), (n.m.highlight = window.hljs), (n.m.md = new window.markdownit(i)), (n.m.md_sub = window.markdownitSub), (n.m.md_sup = window.markdownitSup), (n.m.md_ins = window.markdownitIns), (n.m.md_mark = window.markdownitMark)), n.m.md.use(n.m.md_sub), n.m.md.use(n.m.md_sup), n.m.md.use(n.m.md_ins), n.m.md.use(n.m.md_mark), (n.wxmlTag = [ "view", "video", "swiper", "block", "swiper-item", "button", "slider", "scroll-view", "movable-area", "movable-view", "text", "progress", "checkbox-group", "label", "checkbox", "form", "switch", "input", "radio-group", "radio", "picker", "picker-view", "switch", "textarea", "navigator", "audio", "image", "map", "canvas", "contact-button", ]); } return ( n(r, [ { key: "md2html", value: function (e) { return this.m.md.render(e); }, }, { key: "html2wxml", value: function (e) { var n = this; return e.replace(/<[^<]*>/gi, function (e) { if (""; } else { var t = e.substr(1, e.length - 2).split(" "), i = t[0].toLowerCase(), o = "h2w__" + i; if (n.isConversion(i)) { t.splice(0, 1); var a = t.length; (function () { if (a) for (var e = 0; e < a; e++) { var n = t[e], r = /class="/gi; if (r.test(n)) return ( (t[e] = n.replace(r, function (e) { return e + o + " "; })), !0 ); } return !1; })() || t.unshift('class="' + o + '"'); var s = (function () { var e = ""; return ( t.forEach(function (n, r) { e += n + " "; }), (e = e.substr(0, e.length - 1)) ); })(); return "img" === i ? "" : "<" + n.newLabel(i) + " " + s + ">" + n.needClose(i); } } return e; }); }, }, { key: "md2wxml", value: function (e) { var n = this.md2html(e); return (function (e) { var n = ""; return 0 === e.length ? n : (n = (n = (n = (n = (n = (n = e.replace( /&/gi, "&" )).replace(/</gi, "<")).replace(/>/gi, ">")).replace( / /g, " " )).replace(/'/g, "'")).replace(/"/g, '"')); })(this.html2wxml(n)); }, }, { key: "isConversion", value: function (e) { return !this.wxmlTag.some(function (n, r) { return e === n; }); }, }, { key: "needClose", value: function (e) { var n = ""; return ( ["hr", "br"].some(function (n, r) { return e === n; }) && (n = ""), n ); }, }, { key: "newLabel", value: function (e) { var n = "view"; switch (e) { case "a": n = "navigator"; break; case "span": case "b": case "strong": case "i": case "em": case "code": case "sub": case "sup": case "g-emoji": case "mark": case "ins": n = "text"; } return n; }, }, { key: "toJson", value: function (n, r) { var t = this, i = "", o = void 0; return ( "markdown" === (r = r || "html") ? (i = t.m.html2json(t.md2wxml(n))) : "html" === r && (i = t.m.html2json(t.html2wxml(n))), (o = function (n) { for (var r in n) "child" === r && "object" === e(n[r]) && n[r].length && n[r].forEach(function (e, n) { o(e); }), "attr" === r && ("string" == typeof n[r].class ? (n[r].className = n[r].class) : "object" === e(n[r].class) && n[r].class.length && (n[r].className = n[r].class .toString() .replace(/,/g, " "))); })(i), (i.theme = "light"), i ); }, }, ]), r ); })()), (module.exports = r);