/*! * @toast-ui/editor * @version 2.5.2 | Fri Apr 16 2021 * @author NHN FE Development Lab * @license MIT */ ! function (e, t) { "object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define([], t) : "object" == typeof exports ? exports.Editor = t() : (e.toastui = e.toastui || {}, e.toastui.Editor = t()) }(window, (function () { return function (e) { var t = {}; function n(r) { if (t[r]) return t[r].exports; var i = t[r] = { i: r, l: !1, exports: {} }; return e[r].call(i.exports, i, i.exports, n), i.l = !0, i.exports } return n.m = e, n.c = t, n.d = function (e, t, r) { n.o(e, t) || Object.defineProperty(e, t, { enumerable: !0, get: r }) }, n.r = function (e) { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e, "__esModule", { value: !0 }) }, n.t = function (e, t) { if (1 & t && (e = n(e)), 8 & t) return e; if (4 & t && "object" == typeof e && e && e.__esModule) return e; var r = Object.create(null); if (n.r(r), Object.defineProperty(r, "default", { enumerable: !0, value: e }), 2 & t && "string" != typeof e) for (var i in e) n.d(r, i, function (t) { return e[t] }.bind(null, i)); return r }, n.n = function (e) { var t = e && e.__esModule ? function () { return e.default } : function () { return e }; return n.d(t, "a", t), t }, n.o = function (e, t) { return Object.prototype.hasOwnProperty.call(e, t) }, n.p = "", n(n.s = 43) }([function (e, t, n) { "use strict"; var r = n(11), i = n(20); e.exports = function (e, t, n) { var o = e.style; r(t) ? o[t] = n : i(t, (function (e, t) { o[t] = e })) } }, function (e, t, n) { "use strict"; var r = n(16); e.exports = function (e) { var t; try { t = Array.prototype.slice.call(e) } catch (n) { t = [], r(e, (function (e) { t.push(e) })) } return t } }, function (e, t, n) { "use strict"; var r = n(20), i = n(12), o = n(24), a = n(28); e.exports = function (e) { var t, n = Array.prototype.slice.call(arguments, 1), s = e.classList, l = []; s ? r(n, (function (t) { e.classList.add(t) })) : ((t = o(e)) && (n = [].concat(t.split(/\s+/), n)), r(n, (function (e) { i(e, l) < 0 && l.push(e) })), a(e, l)) } }, function (e, t, n) { "use strict"; var r = n(16), i = n(12), o = n(24), a = n(28); e.exports = function (e) { var t, n, s = Array.prototype.slice.call(arguments, 1), l = e.classList; l ? r(s, (function (e) { l.remove(e) })) : (t = o(e).split(/\s+/), n = [], r(t, (function (e) { i(e, s) < 0 && n.push(e) })), a(e, n)) } }, function (e, t, n) { "use strict"; e.exports = function (e, t) { var n, r, i, o, a = Object.prototype.hasOwnProperty; for (i = 1, o = arguments.length; i < o; i += 1) for (r in n = arguments[i]) a.call(n, r) && (e[r] = n[r]); return e } }, function (e, t, n) { "use strict"; var r, i, o, a, s, l, c, u, d, h, f = { chrome: !1, firefox: !1, safari: !1, msie: !1, edge: !1, others: !1, version: 0 }; "undefined" != typeof window && window.navigator && (o = window.navigator, a = o.appName.replace(/\s/g, "_"), s = o.userAgent, l = /MSIE\s([0-9]+[.0-9]*)/, c = /Trident.*rv:11\./, u = /Edge\/(\d+)\./, d = { firefox: /Firefox\/(\d+)\./, chrome: /Chrome\/(\d+)\./, safari: /Version\/([\d.]+).*Safari\/(\d+)/ }, (h = { Microsoft_Internet_Explorer: function () { var e = s.match(l); e ? (f.msie = !0, f.version = parseFloat(e[1])) : f.others = !0 }, Netscape: function () { var e = !1; if (c.exec(s)) f.msie = !0, f.version = 11, e = !0; else if (u.exec(s)) f.edge = !0, f.version = s.match(u)[1], e = !0; else for (r in d) if (d.hasOwnProperty(r) && (i = s.match(d[r])) && i.length > 1) { f[r] = e = !0, f.version = parseFloat(i[1] || 0); break } e || (f.others = !0) } })[a] && h[a]()), e.exports = f }, function (e, t, n) { e.exports = function () { "use strict"; var e = navigator.userAgent, t = navigator.platform, n = /gecko\/\d/i.test(e), r = /MSIE \d/.test(e), i = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(e), o = /Edge\/(\d+)/.exec(e), a = r || i || o, s = a && (r ? document.documentMode || 6 : +(o || i)[1]), l = !o && /WebKit\//.test(e), c = l && /Qt\/\d+\.\d+/.test(e), u = !o && /Chrome\//.test(e), d = /Opera\//.test(e), h = /Apple Computer/.test(navigator.vendor), f = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(e), p = /PhantomJS/.test(e), g = !o && /AppleWebKit/.test(e) && /Mobile\/\w+/.test(e), m = /Android/.test(e), v = g || m || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(e), y = g || /Mac/.test(t), b = /\bCrOS\b/.test(e), C = /win/i.test(t), w = d && e.match(/Version\/(\d*\.\d*)/); w && (w = Number(w[1])), w && w >= 15 && (d = !1, l = !0); var _ = y && (c || d && (null == w || w < 12.11)), T = n || a && s >= 9; function E(e) { return new RegExp("(^|\\s)" + e + "(?:$|\\s)\\s*") } var x, S = function (e, t) { var n = e.className, r = E(t).exec(n); if (r) { var i = n.slice(r.index + r[0].length); e.className = n.slice(0, r.index) + (i ? r[1] + i : "") } }; function N(e) { for (var t = e.childNodes.length; t > 0; --t) e.removeChild(e.firstChild); return e } function k(e, t) { return N(e).appendChild(t) } function L(e, t, n, r) { var i = document.createElement(e); if (n && (i.className = n), r && (i.style.cssText = r), "string" == typeof t) i.appendChild(document.createTextNode(t)); else if (t) for (var o = 0; o < t.length; ++o) i.appendChild(t[o]); return i } function M(e, t, n, r) { var i = L(e, t, n, r); return i.setAttribute("role", "presentation"), i } function A(e, t) { if (3 == t.nodeType && (t = t.parentNode), e.contains) return e.contains(t); do { if (11 == t.nodeType && (t = t.host), t == e) return !0 } while (t = t.parentNode) } function B() { var e; try { e = document.activeElement } catch (t) { e = document.body || null } for (; e && e.shadowRoot && e.shadowRoot.activeElement;) e = e.shadowRoot.activeElement; return e } function O(e, t) { var n = e.className; E(t).test(n) || (e.className += (n ? " " : "") + t) } function D(e, t) { for (var n = e.split(" "), r = 0; r < n.length; r++) n[r] && !E(n[r]).test(t) && (t += " " + n[r]); return t } x = document.createRange ? function (e, t, n, r) { var i = document.createRange(); return i.setEnd(r || e, n), i.setStart(e, t), i } : function (e, t, n) { var r = document.body.createTextRange(); try { r.moveToElementText(e.parentNode) } catch (e) { return r } return r.collapse(!0), r.moveEnd("character", n), r.moveStart("character", t), r }; var I = function (e) { e.select() }; function R(e) { var t = Array.prototype.slice.call(arguments, 1); return function () { return e.apply(null, t) } } function P(e, t, n) { for (var r in t || (t = {}), e) !e.hasOwnProperty(r) || !1 === n && t.hasOwnProperty(r) || (t[r] = e[r]); return t } function H(e, t, n, r, i) { null == t && -1 == (t = e.search(/[^\s\u00a0]/)) && (t = e.length); for (var o = r || 0, a = i || 0;;) { var s = e.indexOf("\t", o); if (s < 0 || s >= t) return a + (t - o); a += s - o, a += n - a % n, o = s + 1 } } g ? I = function (e) { e.selectionStart = 0, e.selectionEnd = e.value.length } : a && (I = function (e) { try { e.select() } catch (e) {} }); var F = function () { this.id = null, this.f = null, this.time = 0, this.handler = R(this.onTimeout, this) }; function U(e, t) { for (var n = 0; n < e.length; ++n) if (e[n] == t) return n; return -1 } F.prototype.onTimeout = function (e) { e.id = 0, e.time <= +new Date ? e.f() : setTimeout(e.handler, e.time - +new Date) }, F.prototype.set = function (e, t) { this.f = t; var n = +new Date + e; (!this.id || n < this.time) && (clearTimeout(this.id), this.id = setTimeout(this.handler, e), this.time = n) }; var W = { toString: function () { return "CodeMirror.Pass" } }, q = { scroll: !1 }, z = { origin: "*mouse" }, j = { origin: "+move" }; function V(e, t, n) { for (var r = 0, i = 0;;) { var o = e.indexOf("\t", r); - 1 == o && (o = e.length); var a = o - r; if (o == e.length || i + a >= t) return r + Math.min(a, t - i); if (i += o - r, r = o + 1, (i += n - i % n) >= t) return r } } var K = [""]; function G(e) { for (; K.length <= e;) K.push($(K) + " "); return K[e] } function $(e) { return e[e.length - 1] } function Y(e, t) { for (var n = [], r = 0; r < e.length; r++) n[r] = t(e[r], r); return n } function X() {} function Z(e, t) { var n; return Object.create ? n = Object.create(e) : (X.prototype = e, n = new X), t && P(t, n), n } var Q = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/; function J(e) { return /\w/.test(e) || e > "€" && (e.toUpperCase() != e.toLowerCase() || Q.test(e)) } function ee(e, t) { return t ? !!(t.source.indexOf("\\w") > -1 && J(e)) || t.test(e) : J(e) } function te(e) { for (var t in e) if (e.hasOwnProperty(t) && e[t]) return !1; return !0 } var ne = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/; function re(e) { return e.charCodeAt(0) >= 768 && ne.test(e) } function ie(e, t, n) { for (; (n < 0 ? t > 0 : t < e.length) && re(e.charAt(t));) t += n; return t } function oe(e, t, n) { for (var r = t > n ? -1 : 1;;) { if (t == n) return t; var i = (t + n) / 2, o = r < 0 ? Math.ceil(i) : Math.floor(i); if (o == t) return e(o) ? t : n; e(o) ? n = o : t = o + r } } var ae = null; function se(e, t, n) { var r; ae = null; for (var i = 0; i < e.length; ++i) { var o = e[i]; if (o.from < t && o.to > t) return i; o.to == t && (o.from != o.to && "before" == n ? r = i : ae = i), o.from == t && (o.from != o.to && "before" != n ? r = i : ae = i) } return null != r ? r : ae } var le = function () { var e = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/, t = /[stwN]/, n = /[LRr]/, r = /[Lb1n]/, i = /[1n]/; function o(e, t, n) { this.level = e, this.from = t, this.to = n } return function (a, s) { var l = "ltr" == s ? "L" : "R"; if (0 == a.length || "ltr" == s && !e.test(a)) return !1; for (var c, u = a.length, d = [], h = 0; h < u; ++h) d.push((c = a.charCodeAt(h)) <= 247 ? "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN".charAt(c) : 1424 <= c && c <= 1524 ? "R" : 1536 <= c && c <= 1785 ? "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111".charAt(c - 1536) : 1774 <= c && c <= 2220 ? "r" : 8192 <= c && c <= 8203 ? "w" : 8204 == c ? "b" : "L"); for (var f = 0, p = l; f < u; ++f) { var g = d[f]; "m" == g ? d[f] = p : p = g } for (var m = 0, v = l; m < u; ++m) { var y = d[m]; "1" == y && "r" == v ? d[m] = "n" : n.test(y) && (v = y, "r" == y && (d[m] = "R")) } for (var b = 1, C = d[0]; b < u - 1; ++b) { var w = d[b]; "+" == w && "1" == C && "1" == d[b + 1] ? d[b] = "1" : "," != w || C != d[b + 1] || "1" != C && "n" != C || (d[b] = C), C = w } for (var _ = 0; _ < u; ++_) { var T = d[_]; if ("," == T) d[_] = "N"; else if ("%" == T) { var E = void 0; for (E = _ + 1; E < u && "%" == d[E]; ++E); for (var x = _ && "!" == d[_ - 1] || E < u && "1" == d[E] ? "1" : "N", S = _; S < E; ++S) d[S] = x; _ = E - 1 } } for (var N = 0, k = l; N < u; ++N) { var L = d[N]; "L" == k && "1" == L ? d[N] = "L" : n.test(L) && (k = L) } for (var M = 0; M < u; ++M) if (t.test(d[M])) { var A = void 0; for (A = M + 1; A < u && t.test(d[A]); ++A); for (var B = "L" == (M ? d[M - 1] : l), O = B == ("L" == (A < u ? d[A] : l)) ? B ? "L" : "R" : l, D = M; D < A; ++D) d[D] = O; M = A - 1 } for (var I, R = [], P = 0; P < u;) if (r.test(d[P])) { var H = P; for (++P; P < u && r.test(d[P]); ++P); R.push(new o(0, H, P)) } else { var F = P, U = R.length, W = "rtl" == s ? 1 : 0; for (++P; P < u && "L" != d[P]; ++P); for (var q = F; q < P;) if (i.test(d[q])) { F < q && (R.splice(U, 0, new o(1, F, q)), U += W); var z = q; for (++q; q < P && i.test(d[q]); ++q); R.splice(U, 0, new o(2, z, q)), U += W, F = q } else ++q; F < P && R.splice(U, 0, new o(1, F, P)) } return "ltr" == s && (1 == R[0].level && (I = a.match(/^\s+/)) && (R[0].from = I[0].length, R.unshift(new o(0, 0, I[0].length))), 1 == $(R).level && (I = a.match(/\s+$/)) && ($(R).to -= I[0].length, R.push(new o(0, u - I[0].length, u)))), "rtl" == s ? R.reverse() : R } }(); function ce(e, t) { var n = e.order; return null == n && (n = e.order = le(e.text, t)), n } var ue = [], de = function (e, t, n) { if (e.addEventListener) e.addEventListener(t, n, !1); else if (e.attachEvent) e.attachEvent("on" + t, n); else { var r = e._handlers || (e._handlers = {}); r[t] = (r[t] || ue).concat(n) } }; function he(e, t) { return e._handlers && e._handlers[t] || ue } function fe(e, t, n) { if (e.removeEventListener) e.removeEventListener(t, n, !1); else if (e.detachEvent) e.detachEvent("on" + t, n); else { var r = e._handlers, i = r && r[t]; if (i) { var o = U(i, n); o > -1 && (r[t] = i.slice(0, o).concat(i.slice(o + 1))) } } } function pe(e, t) { var n = he(e, t); if (n.length) for (var r = Array.prototype.slice.call(arguments, 2), i = 0; i < n.length; ++i) n[i].apply(null, r) } function ge(e, t, n) { return "string" == typeof t && (t = { type: t, preventDefault: function () { this.defaultPrevented = !0 } }), pe(e, n || t.type, e, t), we(t) || t.codemirrorIgnore } function me(e) { var t = e._handlers && e._handlers.cursorActivity; if (t) for (var n = e.curOp.cursorActivityHandlers || (e.curOp.cursorActivityHandlers = []), r = 0; r < t.length; ++r) - 1 == U(n, t[r]) && n.push(t[r]) } function ve(e, t) { return he(e, t).length > 0 } function ye(e) { e.prototype.on = function (e, t) { de(this, e, t) }, e.prototype.off = function (e, t) { fe(this, e, t) } } function be(e) { e.preventDefault ? e.preventDefault() : e.returnValue = !1 } function Ce(e) { e.stopPropagation ? e.stopPropagation() : e.cancelBubble = !0 } function we(e) { return null != e.defaultPrevented ? e.defaultPrevented : 0 == e.returnValue } function _e(e) { be(e), Ce(e) } function Te(e) { return e.target || e.srcElement } function Ee(e) { var t = e.which; return null == t && (1 & e.button ? t = 1 : 2 & e.button ? t = 3 : 4 & e.button && (t = 2)), y && e.ctrlKey && 1 == t && (t = 3), t } var xe, Se, Ne = function () { if (a && s < 9) return !1; var e = L("div"); return "draggable" in e || "dragDrop" in e }(); function ke(e) { if (null == xe) { var t = L("span", "​"); k(e, L("span", [t, document.createTextNode("x")])), 0 != e.firstChild.offsetHeight && (xe = t.offsetWidth <= 1 && t.offsetHeight > 2 && !(a && s < 8)) } var n = xe ? L("span", "​") : L("span", " ", null, "display: inline-block; width: 1px; margin-right: -1px"); return n.setAttribute("cm-text", ""), n } function Le(e) { if (null != Se) return Se; var t = k(e, document.createTextNode("AخA")), n = x(t, 0, 1).getBoundingClientRect(), r = x(t, 1, 2).getBoundingClientRect(); return N(e), !(!n || n.left == n.right) && (Se = r.right - n.right < 3) } var Me, Ae = 3 != "\n\nb".split(/\n/).length ? function (e) { for (var t = 0, n = [], r = e.length; t <= r;) { var i = e.indexOf("\n", t); - 1 == i && (i = e.length); var o = e.slice(t, "\r" == e.charAt(i - 1) ? i - 1 : i), a = o.indexOf("\r"); - 1 != a ? (n.push(o.slice(0, a)), t += a + 1) : (n.push(o), t = i + 1) } return n } : function (e) { return e.split(/\r\n?|\n/) }, Be = window.getSelection ? function (e) { try { return e.selectionStart != e.selectionEnd } catch (e) { return !1 } } : function (e) { var t; try { t = e.ownerDocument.selection.createRange() } catch (e) {} return !(!t || t.parentElement() != e) && 0 != t.compareEndPoints("StartToEnd", t) }, Oe = "oncopy" in (Me = L("div")) || (Me.setAttribute("oncopy", "return;"), "function" == typeof Me.oncopy), De = null, Ie = {}, Re = {}; function Pe(e, t) { arguments.length > 2 && (t.dependencies = Array.prototype.slice.call(arguments, 2)), Ie[e] = t } function He(e) { if ("string" == typeof e && Re.hasOwnProperty(e)) e = Re[e]; else if (e && "string" == typeof e.name && Re.hasOwnProperty(e.name)) { var t = Re[e.name]; "string" == typeof t && (t = { name: t }), (e = Z(t, e)).name = t.name } else { if ("string" == typeof e && /^[\w\-]+\/[\w\-]+\+xml$/.test(e)) return He("application/xml"); if ("string" == typeof e && /^[\w\-]+\/[\w\-]+\+json$/.test(e)) return He("application/json") } return "string" == typeof e ? { name: e } : e || { name: "null" } } function Fe(e, t) { t = He(t); var n = Ie[t.name]; if (!n) return Fe(e, "text/plain"); var r = n(e, t); if (Ue.hasOwnProperty(t.name)) { var i = Ue[t.name]; for (var o in i) i.hasOwnProperty(o) && (r.hasOwnProperty(o) && (r["_" + o] = r[o]), r[o] = i[o]) } if (r.name = t.name, t.helperType && (r.helperType = t.helperType), t.modeProps) for (var a in t.modeProps) r[a] = t.modeProps[a]; return r } var Ue = {}; function We(e, t) { P(t, Ue.hasOwnProperty(e) ? Ue[e] : Ue[e] = {}) } function qe(e, t) { if (!0 === t) return t; if (e.copyState) return e.copyState(t); var n = {}; for (var r in t) { var i = t[r]; i instanceof Array && (i = i.concat([])), n[r] = i } return n } function ze(e, t) { for (var n; e.innerMode && (n = e.innerMode(t)) && n.mode != e;) t = n.state, e = n.mode; return n || { mode: e, state: t } } function je(e, t, n) { return !e.startState || e.startState(t, n) } var Ve = function (e, t, n) { this.pos = this.start = 0, this.string = e, this.tabSize = t || 8, this.lastColumnPos = this.lastColumnValue = 0, this.lineStart = 0, this.lineOracle = n }; function Ke(e, t) { if ((t -= e.first) < 0 || t >= e.size) throw new Error("There is no line " + (t + e.first) + " in the document."); for (var n = e; !n.lines;) for (var r = 0;; ++r) { var i = n.children[r], o = i.chunkSize(); if (t < o) { n = i; break } t -= o } return n.lines[t] } function Ge(e, t, n) { var r = [], i = t.line; return e.iter(t.line, n.line + 1, (function (e) { var o = e.text; i == n.line && (o = o.slice(0, n.ch)), i == t.line && (o = o.slice(t.ch)), r.push(o), ++i })), r } function $e(e, t, n) { var r = []; return e.iter(t, n, (function (e) { r.push(e.text) })), r } function Ye(e, t) { var n = t - e.height; if (n) for (var r = e; r; r = r.parent) r.height += n } function Xe(e) { if (null == e.parent) return null; for (var t = e.parent, n = U(t.lines, e), r = t.parent; r; t = r, r = r.parent) for (var i = 0; r.children[i] != t; ++i) n += r.children[i].chunkSize(); return n + t.first } function Ze(e, t) { var n = e.first; e: do { for (var r = 0; r < e.children.length; ++r) { var i = e.children[r], o = i.height; if (t < o) { e = i; continue e } t -= o, n += i.chunkSize() } return n } while (!e.lines); for (var a = 0; a < e.lines.length; ++a) { var s = e.lines[a].height; if (t < s) break; t -= s } return n + a } function Qe(e, t) { return t >= e.first && t < e.first + e.size } function Je(e, t) { return String(e.lineNumberFormatter(t + e.firstLineNumber)) } function et(e, t, n) { if (void 0 === n && (n = null), !(this instanceof et)) return new et(e, t, n); this.line = e, this.ch = t, this.sticky = n } function tt(e, t) { return e.line - t.line || e.ch - t.ch } function nt(e, t) { return e.sticky == t.sticky && 0 == tt(e, t) } function rt(e) { return et(e.line, e.ch) } function it(e, t) { return tt(e, t) < 0 ? t : e } function ot(e, t) { return tt(e, t) < 0 ? e : t } function at(e, t) { return Math.max(e.first, Math.min(t, e.first + e.size - 1)) } function st(e, t) { if (t.line < e.first) return et(e.first, 0); var n = e.first + e.size - 1; return t.line > n ? et(n, Ke(e, n).text.length) : function (e, t) { var n = e.ch; return null == n || n > t ? et(e.line, t) : n < 0 ? et(e.line, 0) : e }(t, Ke(e, t.line).text.length) } function lt(e, t) { for (var n = [], r = 0; r < t.length; r++) n[r] = st(e, t[r]); return n } Ve.prototype.eol = function () { return this.pos >= this.string.length }, Ve.prototype.sol = function () { return this.pos == this.lineStart }, Ve.prototype.peek = function () { return this.string.charAt(this.pos) || void 0 }, Ve.prototype.next = function () { if (this.pos < this.string.length) return this.string.charAt(this.pos++) }, Ve.prototype.eat = function (e) { var t = this.string.charAt(this.pos); if ("string" == typeof e ? t == e : t && (e.test ? e.test(t) : e(t))) return ++this.pos, t }, Ve.prototype.eatWhile = function (e) { for (var t = this.pos; this.eat(e);); return this.pos > t }, Ve.prototype.eatSpace = function () { for (var e = this.pos; /[\s\u00a0]/.test(this.string.charAt(this.pos));) ++this.pos; return this.pos > e }, Ve.prototype.skipToEnd = function () { this.pos = this.string.length }, Ve.prototype.skipTo = function (e) { var t = this.string.indexOf(e, this.pos); if (t > -1) return this.pos = t, !0 }, Ve.prototype.backUp = function (e) { this.pos -= e }, Ve.prototype.column = function () { return this.lastColumnPos < this.start && (this.lastColumnValue = H(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue), this.lastColumnPos = this.start), this.lastColumnValue - (this.lineStart ? H(this.string, this.lineStart, this.tabSize) : 0) }, Ve.prototype.indentation = function () { return H(this.string, null, this.tabSize) - (this.lineStart ? H(this.string, this.lineStart, this.tabSize) : 0) }, Ve.prototype.match = function (e, t, n) { if ("string" != typeof e) { var r = this.string.slice(this.pos).match(e); return r && r.index > 0 ? null : (r && !1 !== t && (this.pos += r[0].length), r) } var i = function (e) { return n ? e.toLowerCase() : e }; if (i(this.string.substr(this.pos, e.length)) == i(e)) return !1 !== t && (this.pos += e.length), !0 }, Ve.prototype.current = function () { return this.string.slice(this.start, this.pos) }, Ve.prototype.hideFirstChars = function (e, t) { this.lineStart += e; try { return t() } finally { this.lineStart -= e } }, Ve.prototype.lookAhead = function (e) { var t = this.lineOracle; return t && t.lookAhead(e) }, Ve.prototype.baseToken = function () { var e = this.lineOracle; return e && e.baseToken(this.pos) }; var ct = function (e, t) { this.state = e, this.lookAhead = t }, ut = function (e, t, n, r) { this.state = t, this.doc = e, this.line = n, this.maxLookAhead = r || 0, this.baseTokens = null, this.baseTokenPos = 1 }; function dt(e, t, n, r) { var i = [e.state.modeGen], o = {}; Ct(e, t.text, e.doc.mode, n, (function (e, t) { return i.push(e, t) }), o, r); for (var a = n.state, s = function (r) { n.baseTokens = i; var s = e.state.overlays[r], l = 1, c = 0; n.state = !0, Ct(e, t.text, s.mode, n, (function (e, t) { for (var n = l; c < e;) { var r = i[l]; r > e && i.splice(l, 1, e, i[l + 1], r), l += 2, c = Math.min(e, r) } if (t) if (s.opaque) i.splice(n, l - n, e, "overlay " + t), l = n + 2; else for (; n < l; n += 2) { var o = i[n + 1]; i[n + 1] = (o ? o + " " : "") + "overlay " + t } }), o), n.state = a, n.baseTokens = null, n.baseTokenPos = 1 }, l = 0; l < e.state.overlays.length; ++l) s(l); return { styles: i, classes: o.bgClass || o.textClass ? o : null } } function ht(e, t, n) { if (!t.styles || t.styles[0] != e.state.modeGen) { var r = ft(e, Xe(t)), i = t.text.length > e.options.maxHighlightLength && qe(e.doc.mode, r.state), o = dt(e, t, r); i && (r.state = i), t.stateAfter = r.save(!i), t.styles = o.styles, o.classes ? t.styleClasses = o.classes : t.styleClasses && (t.styleClasses = null), n === e.doc.highlightFrontier && (e.doc.modeFrontier = Math.max(e.doc.modeFrontier, ++e.doc.highlightFrontier)) } return t.styles } function ft(e, t, n) { var r = e.doc, i = e.display; if (!r.mode.startState) return new ut(r, !0, t); var o = function (e, t, n) { for (var r, i, o = e.doc, a = n ? -1 : t - (e.doc.mode.innerMode ? 1e3 : 100), s = t; s > a; --s) { if (s <= o.first) return o.first; var l = Ke(o, s - 1), c = l.stateAfter; if (c && (!n || s + (c instanceof ct ? c.lookAhead : 0) <= o.modeFrontier)) return s; var u = H(l.text, null, e.options.tabSize); (null == i || r > u) && (i = s - 1, r = u) } return i }(e, t, n), a = o > r.first && Ke(r, o - 1).stateAfter, s = a ? ut.fromSaved(r, a, o) : new ut(r, je(r.mode), o); return r.iter(o, t, (function (n) { pt(e, n.text, s); var r = s.line; n.stateAfter = r == t - 1 || r % 5 == 0 || r >= i.viewFrom && r < i.viewTo ? s.save() : null, s.nextLine() })), n && (r.modeFrontier = s.line), s } function pt(e, t, n, r) { var i = e.doc.mode, o = new Ve(t, e.options.tabSize, n); for (o.start = o.pos = r || 0, "" == t && gt(i, n.state); !o.eol();) mt(i, o, n.state), o.start = o.pos } function gt(e, t) { if (e.blankLine) return e.blankLine(t); if (e.innerMode) { var n = ze(e, t); return n.mode.blankLine ? n.mode.blankLine(n.state) : void 0 } } function mt(e, t, n, r) { for (var i = 0; i < 10; i++) { r && (r[0] = ze(e, n).mode); var o = e.token(t, n); if (t.pos > t.start) return o } throw new Error("Mode " + e.name + " failed to advance stream.") } ut.prototype.lookAhead = function (e) { var t = this.doc.getLine(this.line + e); return null != t && e > this.maxLookAhead && (this.maxLookAhead = e), t }, ut.prototype.baseToken = function (e) { if (!this.baseTokens) return null; for (; this.baseTokens[this.baseTokenPos] <= e;) this.baseTokenPos += 2; var t = this.baseTokens[this.baseTokenPos + 1]; return { type: t && t.replace(/( |^)overlay .*/, ""), size: this.baseTokens[this.baseTokenPos] - e } }, ut.prototype.nextLine = function () { this.line++, this.maxLookAhead > 0 && this.maxLookAhead-- }, ut.fromSaved = function (e, t, n) { return t instanceof ct ? new ut(e, qe(e.mode, t.state), n, t.lookAhead) : new ut(e, qe(e.mode, t), n) }, ut.prototype.save = function (e) { var t = !1 !== e ? qe(this.doc.mode, this.state) : this.state; return this.maxLookAhead > 0 ? new ct(t, this.maxLookAhead) : t }; var vt = function (e, t, n) { this.start = e.start, this.end = e.pos, this.string = e.current(), this.type = t || null, this.state = n }; function yt(e, t, n, r) { var i, o, a = e.doc, s = a.mode, l = Ke(a, (t = st(a, t)).line), c = ft(e, t.line, n), u = new Ve(l.text, e.options.tabSize, c); for (r && (o = []); (r || u.pos < t.ch) && !u.eol();) u.start = u.pos, i = mt(s, u, c.state), r && o.push(new vt(u, i, qe(a.mode, c.state))); return r ? o : new vt(u, i, c.state) } function bt(e, t) { if (e) for (;;) { var n = e.match(/(?:^|\s+)line-(background-)?(\S+)/); if (!n) break; e = e.slice(0, n.index) + e.slice(n.index + n[0].length); var r = n[1] ? "bgClass" : "textClass"; null == t[r] ? t[r] = n[2] : new RegExp("(?:^|\\s)" + n[2] + "(?:$|\\s)").test(t[r]) || (t[r] += " " + n[2]) } return e } function Ct(e, t, n, r, i, o, a) { var s = n.flattenSpans; null == s && (s = e.options.flattenSpans); var l, c = 0, u = null, d = new Ve(t, e.options.tabSize, r), h = e.options.addModeClass && [null]; for ("" == t && bt(gt(n, r.state), o); !d.eol();) { if (d.pos > e.options.maxHighlightLength ? (s = !1, a && pt(e, t, r, d.pos), d.pos = t.length, l = null) : l = bt(mt(n, d, r.state, h), o), h) { var f = h[0].name; f && (l = "m-" + (l ? f + " " + l : f)) } if (!s || u != l) { for (; c < d.start;) i(c = Math.min(d.start, c + 5e3), u); u = l } d.start = d.pos } for (; c < d.pos;) { var p = Math.min(d.pos, c + 5e3); i(p, u), c = p } } var wt = !1, _t = !1; function Tt(e, t, n) { this.marker = e, this.from = t, this.to = n } function Et(e, t) { if (e) for (var n = 0; n < e.length; ++n) { var r = e[n]; if (r.marker == t) return r } } function xt(e, t) { for (var n, r = 0; r < e.length; ++r) e[r] != t && (n || (n = [])).push(e[r]); return n } function St(e, t) { if (t.full) return null; var n = Qe(e, t.from.line) && Ke(e, t.from.line).markedSpans, r = Qe(e, t.to.line) && Ke(e, t.to.line).markedSpans; if (!n && !r) return null; var i = t.from.ch, o = t.to.ch, a = 0 == tt(t.from, t.to), s = function (e, t, n) { var r; if (e) for (var i = 0; i < e.length; ++i) { var o = e[i], a = o.marker; if (null == o.from || (a.inclusiveLeft ? o.from <= t : o.from < t) || o.from == t && "bookmark" == a.type && (!n || !o.marker.insertLeft)) { var s = null == o.to || (a.inclusiveRight ? o.to >= t : o.to > t); (r || (r = [])).push(new Tt(a, o.from, s ? null : o.to)) } } return r }(n, i, a), l = function (e, t, n) { var r; if (e) for (var i = 0; i < e.length; ++i) { var o = e[i], a = o.marker; if (null == o.to || (a.inclusiveRight ? o.to >= t : o.to > t) || o.from == t && "bookmark" == a.type && (!n || o.marker.insertLeft)) { var s = null == o.from || (a.inclusiveLeft ? o.from <= t : o.from < t); (r || (r = [])).push(new Tt(a, s ? null : o.from - t, null == o.to ? null : o.to - t)) } } return r }(r, o, a), c = 1 == t.text.length, u = $(t.text).length + (c ? i : 0); if (s) for (var d = 0; d < s.length; ++d) { var h = s[d]; if (null == h.to) { var f = Et(l, h.marker); f ? c && (h.to = null == f.to ? null : f.to + u) : h.to = i } } if (l) for (var p = 0; p < l.length; ++p) { var g = l[p]; null != g.to && (g.to += u), null == g.from ? Et(s, g.marker) || (g.from = u, c && (s || (s = [])).push(g)) : (g.from += u, c && (s || (s = [])).push(g)) } s && (s = Nt(s)), l && l != s && (l = Nt(l)); var m = [s]; if (!c) { var v, y = t.text.length - 2; if (y > 0 && s) for (var b = 0; b < s.length; ++b) null == s[b].to && (v || (v = [])).push(new Tt(s[b].marker, null, null)); for (var C = 0; C < y; ++C) m.push(v); m.push(l) } return m } function Nt(e) { for (var t = 0; t < e.length; ++t) { var n = e[t]; null != n.from && n.from == n.to && !1 !== n.marker.clearWhenEmpty && e.splice(t--, 1) } return e.length ? e : null } function kt(e) { var t = e.markedSpans; if (t) { for (var n = 0; n < t.length; ++n) t[n].marker.detachLine(e); e.markedSpans = null } } function Lt(e, t) { if (t) { for (var n = 0; n < t.length; ++n) t[n].marker.attachLine(e); e.markedSpans = t } } function Mt(e) { return e.inclusiveLeft ? -1 : 0 } function At(e) { return e.inclusiveRight ? 1 : 0 } function Bt(e, t) { var n = e.lines.length - t.lines.length; if (0 != n) return n; var r = e.find(), i = t.find(), o = tt(r.from, i.from) || Mt(e) - Mt(t); if (o) return -o; var a = tt(r.to, i.to) || At(e) - At(t); return a || t.id - e.id } function Ot(e, t) { var n, r = _t && e.markedSpans; if (r) for (var i = void 0, o = 0; o < r.length; ++o)(i = r[o]).marker.collapsed && null == (t ? i.from : i.to) && (!n || Bt(n, i.marker) < 0) && (n = i.marker); return n } function Dt(e) { return Ot(e, !0) } function It(e) { return Ot(e, !1) } function Rt(e, t) { var n, r = _t && e.markedSpans; if (r) for (var i = 0; i < r.length; ++i) { var o = r[i]; o.marker.collapsed && (null == o.from || o.from < t) && (null == o.to || o.to > t) && (!n || Bt(n, o.marker) < 0) && (n = o.marker) } return n } function Pt(e, t, n, r, i) { var o = Ke(e, t), a = _t && o.markedSpans; if (a) for (var s = 0; s < a.length; ++s) { var l = a[s]; if (l.marker.collapsed) { var c = l.marker.find(0), u = tt(c.from, n) || Mt(l.marker) - Mt(i), d = tt(c.to, r) || At(l.marker) - At(i); if (!(u >= 0 && d <= 0 || u <= 0 && d >= 0) && (u <= 0 && (l.marker.inclusiveRight && i.inclusiveLeft ? tt(c.to, n) >= 0 : tt(c.to, n) > 0) || u >= 0 && (l.marker.inclusiveRight && i.inclusiveLeft ? tt(c.from, r) <= 0 : tt(c.from, r) < 0))) return !0 } } } function Ht(e) { for (var t; t = Dt(e);) e = t.find(-1, !0).line; return e } function Ft(e, t) { var n = Ke(e, t), r = Ht(n); return n == r ? t : Xe(r) } function Ut(e, t) { if (t > e.lastLine()) return t; var n, r = Ke(e, t); if (!Wt(e, r)) return t; for (; n = It(r);) r = n.find(1, !0).line; return Xe(r) + 1 } function Wt(e, t) { var n = _t && t.markedSpans; if (n) for (var r = void 0, i = 0; i < n.length; ++i) if ((r = n[i]).marker.collapsed) { if (null == r.from) return !0; if (!r.marker.widgetNode && 0 == r.from && r.marker.inclusiveLeft && qt(e, t, r)) return !0 } } function qt(e, t, n) { if (null == n.to) { var r = n.marker.find(1, !0); return qt(e, r.line, Et(r.line.markedSpans, n.marker)) } if (n.marker.inclusiveRight && n.to == t.text.length) return !0; for (var i = void 0, o = 0; o < t.markedSpans.length; ++o) if ((i = t.markedSpans[o]).marker.collapsed && !i.marker.widgetNode && i.from == n.to && (null == i.to || i.to != n.from) && (i.marker.inclusiveLeft || n.marker.inclusiveRight) && qt(e, t, i)) return !0 } function zt(e) { for (var t = 0, n = (e = Ht(e)).parent, r = 0; r < n.lines.length; ++r) { var i = n.lines[r]; if (i == e) break; t += i.height } for (var o = n.parent; o; o = (n = o).parent) for (var a = 0; a < o.children.length; ++a) { var s = o.children[a]; if (s == n) break; t += s.height } return t } function jt(e) { if (0 == e.height) return 0; for (var t, n = e.text.length, r = e; t = Dt(r);) { var i = t.find(0, !0); r = i.from.line, n += i.from.ch - i.to.ch } for (r = e; t = It(r);) { var o = t.find(0, !0); n -= r.text.length - o.from.ch, n += (r = o.to.line).text.length - o.to.ch } return n } function Vt(e) { var t = e.display, n = e.doc; t.maxLine = Ke(n, n.first), t.maxLineLength = jt(t.maxLine), t.maxLineChanged = !0, n.iter((function (e) { var n = jt(e); n > t.maxLineLength && (t.maxLineLength = n, t.maxLine = e) })) } var Kt = function (e, t, n) { this.text = e, Lt(this, t), this.height = n ? n(this) : 1 }; function Gt(e) { e.parent = null, kt(e) } Kt.prototype.lineNo = function () { return Xe(this) }, ye(Kt); var $t = {}, Yt = {}; function Xt(e, t) { if (!e || /^\s*$/.test(e)) return null; var n = t.addModeClass ? Yt : $t; return n[e] || (n[e] = e.replace(/\S+/g, "cm-$&")) } function Zt(e, t) { var n = M("span", null, null, l ? "padding-right: .1px" : null), r = { pre: M("pre", [n], "CodeMirror-line"), content: n, col: 0, pos: 0, cm: e, trailingSpace: !1, splitSpaces: e.getOption("lineWrapping") }; t.measure = {}; for (var i = 0; i <= (t.rest ? t.rest.length : 0); i++) { var o = i ? t.rest[i - 1] : t.line, a = void 0; r.pos = 0, r.addToken = Jt, Le(e.display.measure) && (a = ce(o, e.doc.direction)) && (r.addToken = en(r.addToken, a)), r.map = [], nn(o, r, ht(e, o, t != e.display.externalMeasured && Xe(o))), o.styleClasses && (o.styleClasses.bgClass && (r.bgClass = D(o.styleClasses.bgClass, r.bgClass || "")), o.styleClasses.textClass && (r.textClass = D(o.styleClasses.textClass, r.textClass || ""))), 0 == r.map.length && r.map.push(0, 0, r.content.appendChild(ke(e.display.measure))), 0 == i ? (t.measure.map = r.map, t.measure.cache = {}) : ((t.measure.maps || (t.measure.maps = [])).push(r.map), (t.measure.caches || (t.measure.caches = [])).push({})) } if (l) { var s = r.content.lastChild; (/\bcm-tab\b/.test(s.className) || s.querySelector && s.querySelector(".cm-tab")) && (r.content.className = "cm-tab-wrap-hack") } return pe(e, "renderLine", e, t.line, r.pre), r.pre.className && (r.textClass = D(r.pre.className, r.textClass || "")), r } function Qt(e) { var t = L("span", "•", "cm-invalidchar"); return t.title = "\\u" + e.charCodeAt(0).toString(16), t.setAttribute("aria-label", t.title), t } function Jt(e, t, n, r, i, o, l) { if (t) { var c, u = e.splitSpaces ? function (e, t) { if (e.length > 1 && !/ /.test(e)) return e; for (var n = t, r = "", i = 0; i < e.length; i++) { var o = e.charAt(i); " " != o || !n || i != e.length - 1 && 32 != e.charCodeAt(i + 1) || (o = " "), r += o, n = " " == o } return r }(t, e.trailingSpace) : t, d = e.cm.state.specialChars, h = !1; if (d.test(t)) { c = document.createDocumentFragment(); for (var f = 0;;) { d.lastIndex = f; var p = d.exec(t), g = p ? p.index - f : t.length - f; if (g) { var m = document.createTextNode(u.slice(f, f + g)); a && s < 9 ? c.appendChild(L("span", [m])) : c.appendChild(m), e.map.push(e.pos, e.pos + g, m), e.col += g, e.pos += g } if (!p) break; f += g + 1; var v = void 0; if ("\t" == p[0]) { var y = e.cm.options.tabSize, b = y - e.col % y; (v = c.appendChild(L("span", G(b), "cm-tab"))).setAttribute("role", "presentation"), v.setAttribute("cm-text", "\t"), e.col += b } else "\r" == p[0] || "\n" == p[0] ? ((v = c.appendChild(L("span", "\r" == p[0] ? "␍" : "␤", "cm-invalidchar"))).setAttribute("cm-text", p[0]), e.col += 1) : ((v = e.cm.options.specialCharPlaceholder(p[0])).setAttribute("cm-text", p[0]), a && s < 9 ? c.appendChild(L("span", [v])) : c.appendChild(v), e.col += 1); e.map.push(e.pos, e.pos + 1, v), e.pos++ } } else e.col += t.length, c = document.createTextNode(u), e.map.push(e.pos, e.pos + t.length, c), a && s < 9 && (h = !0), e.pos += t.length; if (e.trailingSpace = 32 == u.charCodeAt(t.length - 1), n || r || i || h || o || l) { var C = n || ""; r && (C += r), i && (C += i); var w = L("span", [c], C, o); if (l) for (var _ in l) l.hasOwnProperty(_) && "style" != _ && "class" != _ && w.setAttribute(_, l[_]); return e.content.appendChild(w) } e.content.appendChild(c) } } function en(e, t) { return function (n, r, i, o, a, s, l) { i = i ? i + " cm-force-border" : "cm-force-border"; for (var c = n.pos, u = c + r.length;;) { for (var d = void 0, h = 0; h < t.length && !((d = t[h]).to > c && d.from <= c); h++); if (d.to >= u) return e(n, r, i, o, a, s, l); e(n, r.slice(0, d.to - c), i, o, null, s, l), o = null, r = r.slice(d.to - c), c = d.to } } } function tn(e, t, n, r) { var i = !r && n.widgetNode; i && e.map.push(e.pos, e.pos + t, i), !r && e.cm.display.input.needsContentAttribute && (i || (i = e.content.appendChild(document.createElement("span"))), i.setAttribute("cm-marker", n.id)), i && (e.cm.display.input.setUneditable(i), e.content.appendChild(i)), e.pos += t, e.trailingSpace = !1 } function nn(e, t, n) { var r = e.markedSpans, i = e.text, o = 0; if (r) for (var a, s, l, c, u, d, h, f = i.length, p = 0, g = 1, m = "", v = 0;;) { if (v == p) { l = c = u = s = "", h = null, d = null, v = 1 / 0; for (var y = [], b = void 0, C = 0; C < r.length; ++C) { var w = r[C], _ = w.marker; if ("bookmark" == _.type && w.from == p && _.widgetNode) y.push(_); else if (w.from <= p && (null == w.to || w.to > p || _.collapsed && w.to == p && w.from == p)) { if (null != w.to && w.to != p && v > w.to && (v = w.to, c = ""), _.className && (l += " " + _.className), _.css && (s = (s ? s + ";" : "") + _.css), _.startStyle && w.from == p && (u += " " + _.startStyle), _.endStyle && w.to == v && (b || (b = [])).push(_.endStyle, w.to), _.title && ((h || (h = {})).title = _.title), _.attributes) for (var T in _.attributes)(h || (h = {}))[T] = _.attributes[T]; _.collapsed && (!d || Bt(d.marker, _) < 0) && (d = w) } else w.from > p && v > w.from && (v = w.from) } if (b) for (var E = 0; E < b.length; E += 2) b[E + 1] == v && (c += " " + b[E]); if (!d || d.from == p) for (var x = 0; x < y.length; ++x) tn(t, 0, y[x]); if (d && (d.from || 0) == p) { if (tn(t, (null == d.to ? f + 1 : d.to) - p, d.marker, null == d.from), null == d.to) return; d.to == p && (d = !1) } } if (p >= f) break; for (var S = Math.min(f, v);;) { if (m) { var N = p + m.length; if (!d) { var k = N > S ? m.slice(0, S - p) : m; t.addToken(t, k, a ? a + l : l, u, p + k.length == v ? c : "", s, h) } if (N >= S) { m = m.slice(S - p), p = S; break } p = N, u = "" } m = i.slice(o, o = n[g++]), a = Xt(n[g++], t.cm.options) } } else for (var L = 1; L < n.length; L += 2) t.addToken(t, i.slice(o, o = n[L]), Xt(n[L + 1], t.cm.options)) } function rn(e, t, n) { this.line = t, this.rest = function (e) { for (var t, n; t = It(e);) e = t.find(1, !0).line, (n || (n = [])).push(e); return n }(t), this.size = this.rest ? Xe($(this.rest)) - n + 1 : 1, this.node = this.text = null, this.hidden = Wt(e, t) } function on(e, t, n) { for (var r, i = [], o = t; o < n; o = r) { var a = new rn(e.doc, Ke(e.doc, o), o); r = o + a.size, i.push(a) } return i } var an = null, sn = null; function ln(e, t) { var n = he(e, t); if (n.length) { var r, i = Array.prototype.slice.call(arguments, 2); an ? r = an.delayedCallbacks : sn ? r = sn : (r = sn = [], setTimeout(cn, 0)); for (var o = function (e) { r.push((function () { return n[e].apply(null, i) })) }, a = 0; a < n.length; ++a) o(a) } } function cn() { var e = sn; sn = null; for (var t = 0; t < e.length; ++t) e[t]() } function un(e, t, n, r) { for (var i = 0; i < t.changes.length; i++) { var o = t.changes[i]; "text" == o ? fn(e, t) : "gutter" == o ? gn(e, t, n, r) : "class" == o ? pn(e, t) : "widget" == o && mn(e, t, r) } t.changes = null } function dn(e) { return e.node == e.text && (e.node = L("div", null, null, "position: relative"), e.text.parentNode && e.text.parentNode.replaceChild(e.node, e.text), e.node.appendChild(e.text), a && s < 8 && (e.node.style.zIndex = 2)), e.node } function hn(e, t) { var n = e.display.externalMeasured; return n && n.line == t.line ? (e.display.externalMeasured = null, t.measure = n.measure, n.built) : Zt(e, t) } function fn(e, t) { var n = t.text.className, r = hn(e, t); t.text == t.node && (t.node = r.pre), t.text.parentNode.replaceChild(r.pre, t.text), t.text = r.pre, r.bgClass != t.bgClass || r.textClass != t.textClass ? (t.bgClass = r.bgClass, t.textClass = r.textClass, pn(e, t)) : n && (t.text.className = n) } function pn(e, t) { ! function (e, t) { var n = t.bgClass ? t.bgClass + " " + (t.line.bgClass || "") : t.line.bgClass; if (n && (n += " CodeMirror-linebackground"), t.background) n ? t.background.className = n : (t.background.parentNode.removeChild(t.background), t.background = null); else if (n) { var r = dn(t); t.background = r.insertBefore(L("div", null, n), r.firstChild), e.display.input.setUneditable(t.background) } }(e, t), t.line.wrapClass ? dn(t).className = t.line.wrapClass : t.node != t.text && (t.node.className = ""); var n = t.textClass ? t.textClass + " " + (t.line.textClass || "") : t.line.textClass; t.text.className = n || "" } function gn(e, t, n, r) { if (t.gutter && (t.node.removeChild(t.gutter), t.gutter = null), t.gutterBackground && (t.node.removeChild(t.gutterBackground), t.gutterBackground = null), t.line.gutterClass) { var i = dn(t); t.gutterBackground = L("div", null, "CodeMirror-gutter-background " + t.line.gutterClass, "left: " + (e.options.fixedGutter ? r.fixedPos : -r.gutterTotalWidth) + "px; width: " + r.gutterTotalWidth + "px"), e.display.input.setUneditable(t.gutterBackground), i.insertBefore(t.gutterBackground, t.text) } var o = t.line.gutterMarkers; if (e.options.lineNumbers || o) { var a = dn(t), s = t.gutter = L("div", null, "CodeMirror-gutter-wrapper", "left: " + (e.options.fixedGutter ? r.fixedPos : -r.gutterTotalWidth) + "px"); if (e.display.input.setUneditable(s), a.insertBefore(s, t.text), t.line.gutterClass && (s.className += " " + t.line.gutterClass), !e.options.lineNumbers || o && o["CodeMirror-linenumbers"] || (t.lineNumber = s.appendChild(L("div", Je(e.options, n), "CodeMirror-linenumber CodeMirror-gutter-elt", "left: " + r.gutterLeft["CodeMirror-linenumbers"] + "px; width: " + e.display.lineNumInnerWidth + "px"))), o) for (var l = 0; l < e.display.gutterSpecs.length; ++l) { var c = e.display.gutterSpecs[l].className, u = o.hasOwnProperty(c) && o[c]; u && s.appendChild(L("div", [u], "CodeMirror-gutter-elt", "left: " + r.gutterLeft[c] + "px; width: " + r.gutterWidth[c] + "px")) } } } function mn(e, t, n) { t.alignable && (t.alignable = null); for (var r = E("CodeMirror-linewidget"), i = t.node.firstChild, o = void 0; i; i = o) o = i.nextSibling, r.test(i.className) && t.node.removeChild(i); yn(e, t, n) } function vn(e, t, n, r) { var i = hn(e, t); return t.text = t.node = i.pre, i.bgClass && (t.bgClass = i.bgClass), i.textClass && (t.textClass = i.textClass), pn(e, t), gn(e, t, n, r), yn(e, t, r), t.node } function yn(e, t, n) { if (bn(e, t.line, t, n, !0), t.rest) for (var r = 0; r < t.rest.length; r++) bn(e, t.rest[r], t, n, !1) } function bn(e, t, n, r, i) { if (t.widgets) for (var o = dn(n), a = 0, s = t.widgets; a < s.length; ++a) { var l = s[a], c = L("div", [l.node], "CodeMirror-linewidget" + (l.className ? " " + l.className : "")); l.handleMouseEvents || c.setAttribute("cm-ignore-events", "true"), Cn(l, c, n, r), e.display.input.setUneditable(c), i && l.above ? o.insertBefore(c, n.gutter || n.text) : o.appendChild(c), ln(l, "redraw") } } function Cn(e, t, n, r) { if (e.noHScroll) { (n.alignable || (n.alignable = [])).push(t); var i = r.wrapperWidth; t.style.left = r.fixedPos + "px", e.coverGutter || (i -= r.gutterTotalWidth, t.style.paddingLeft = r.gutterTotalWidth + "px"), t.style.width = i + "px" } e.coverGutter && (t.style.zIndex = 5, t.style.position = "relative", e.noHScroll || (t.style.marginLeft = -r.gutterTotalWidth + "px")) } function wn(e) { if (null != e.height) return e.height; var t = e.doc.cm; if (!t) return 0; if (!A(document.body, e.node)) { var n = "position: relative;"; e.coverGutter && (n += "margin-left: -" + t.display.gutters.offsetWidth + "px;"), e.noHScroll && (n += "width: " + t.display.wrapper.clientWidth + "px;"), k(t.display.measure, L("div", [e.node], null, n)) } return e.height = e.node.parentNode.offsetHeight } function _n(e, t) { for (var n = Te(t); n != e.wrapper; n = n.parentNode) if (!n || 1 == n.nodeType && "true" == n.getAttribute("cm-ignore-events") || n.parentNode == e.sizer && n != e.mover) return !0 } function Tn(e) { return e.lineSpace.offsetTop } function En(e) { return e.mover.offsetHeight - e.lineSpace.offsetHeight } function xn(e) { if (e.cachedPaddingH) return e.cachedPaddingH; var t = k(e.measure, L("pre", "x", "CodeMirror-line-like")), n = window.getComputedStyle ? window.getComputedStyle(t) : t.currentStyle, r = { left: parseInt(n.paddingLeft), right: parseInt(n.paddingRight) }; return isNaN(r.left) || isNaN(r.right) || (e.cachedPaddingH = r), r } function Sn(e) { return 50 - e.display.nativeBarWidth } function Nn(e) { return e.display.scroller.clientWidth - Sn(e) - e.display.barWidth } function kn(e) { return e.display.scroller.clientHeight - Sn(e) - e.display.barHeight } function Ln(e, t, n) { if (e.line == t) return { map: e.measure.map, cache: e.measure.cache }; for (var r = 0; r < e.rest.length; r++) if (e.rest[r] == t) return { map: e.measure.maps[r], cache: e.measure.caches[r] }; for (var i = 0; i < e.rest.length; i++) if (Xe(e.rest[i]) > n) return { map: e.measure.maps[i], cache: e.measure.caches[i], before: !0 } } function Mn(e, t, n, r) { return On(e, Bn(e, t), n, r) } function An(e, t) { if (t >= e.display.viewFrom && t < e.display.viewTo) return e.display.view[ur(e, t)]; var n = e.display.externalMeasured; return n && t >= n.lineN && t < n.lineN + n.size ? n : void 0 } function Bn(e, t) { var n = Xe(t), r = An(e, n); r && !r.text ? r = null : r && r.changes && (un(e, r, n, or(e)), e.curOp.forceUpdate = !0), r || (r = function (e, t) { var n = Xe(t = Ht(t)), r = e.display.externalMeasured = new rn(e.doc, t, n); r.lineN = n; var i = r.built = Zt(e, r); return r.text = i.pre, k(e.display.lineMeasure, i.pre), r }(e, t)); var i = Ln(r, t, n); return { line: t, view: r, rect: null, map: i.map, cache: i.cache, before: i.before, hasHeights: !1 } } function On(e, t, n, r, i) { t.before && (n = -1); var o, l = n + (r || ""); return t.cache.hasOwnProperty(l) ? o = t.cache[l] : (t.rect || (t.rect = t.view.text.getBoundingClientRect()), t.hasHeights || (function (e, t, n) { var r = e.options.lineWrapping, i = r && Nn(e); if (!t.measure.heights || r && t.measure.width != i) { var o = t.measure.heights = []; if (r) { t.measure.width = i; for (var a = t.text.firstChild.getClientRects(), s = 0; s < a.length - 1; s++) { var l = a[s], c = a[s + 1]; Math.abs(l.bottom - c.bottom) > 2 && o.push((l.bottom + c.top) / 2 - n.top) } } o.push(n.bottom - n.top) } }(e, t.view, t.rect), t.hasHeights = !0), (o = function (e, t, n, r) { var i, o = Rn(t.map, n, r), l = o.node, c = o.start, u = o.end, d = o.collapse; if (3 == l.nodeType) { for (var h = 0; h < 4; h++) { for (; c && re(t.line.text.charAt(o.coverStart + c));) --c; for (; o.coverStart + u < o.coverEnd && re(t.line.text.charAt(o.coverStart + u));) ++u; if ((i = a && s < 9 && 0 == c && u == o.coverEnd - o.coverStart ? l.parentNode.getBoundingClientRect() : Pn(x(l, c, u).getClientRects(), r)).left || i.right || 0 == c) break; u = c, c -= 1, d = "right" } a && s < 11 && (i = function (e, t) { if (!window.screen || null == screen.logicalXDPI || screen.logicalXDPI == screen.deviceXDPI || ! function (e) { if (null != De) return De; var t = k(e, L("span", "x")), n = t.getBoundingClientRect(), r = x(t, 0, 1).getBoundingClientRect(); return De = Math.abs(n.left - r.left) > 1 }(e)) return t; var n = screen.logicalXDPI / screen.deviceXDPI, r = screen.logicalYDPI / screen.deviceYDPI; return { left: t.left * n, right: t.right * n, top: t.top * r, bottom: t.bottom * r } }(e.display.measure, i)) } else { var f; c > 0 && (d = r = "right"), i = e.options.lineWrapping && (f = l.getClientRects()).length > 1 ? f["right" == r ? f.length - 1 : 0] : l.getBoundingClientRect() } if (a && s < 9 && !c && (!i || !i.left && !i.right)) { var p = l.parentNode.getClientRects()[0]; i = p ? { left: p.left, right: p.left + ir(e.display), top: p.top, bottom: p.bottom } : In } for (var g = i.top - t.rect.top, m = i.bottom - t.rect.top, v = (g + m) / 2, y = t.view.measure.heights, b = 0; b < y.length - 1 && !(v < y[b]); b++); var C = b ? y[b - 1] : 0, w = y[b], _ = { left: ("right" == d ? i.right : i.left) - t.rect.left, right: ("left" == d ? i.left : i.right) - t.rect.left, top: C, bottom: w }; return i.left || i.right || (_.bogus = !0), e.options.singleCursorHeightPerLine || (_.rtop = g, _.rbottom = m), _ }(e, t, n, r)).bogus || (t.cache[l] = o)), { left: o.left, right: o.right, top: i ? o.rtop : o.top, bottom: i ? o.rbottom : o.bottom } } var Dn, In = { left: 0, right: 0, top: 0, bottom: 0 }; function Rn(e, t, n) { for (var r, i, o, a, s, l, c = 0; c < e.length; c += 3) if (s = e[c], l = e[c + 1], t < s ? (i = 0, o = 1, a = "left") : t < l ? o = 1 + (i = t - s) : (c == e.length - 3 || t == l && e[c + 3] > t) && (i = (o = l - s) - 1, t >= l && (a = "right")), null != i) { if (r = e[c + 2], s == l && n == (r.insertLeft ? "left" : "right") && (a = n), "left" == n && 0 == i) for (; c && e[c - 2] == e[c - 3] && e[c - 1].insertLeft;) r = e[2 + (c -= 3)], a = "left"; if ("right" == n && i == l - s) for (; c < e.length - 3 && e[c + 3] == e[c + 4] && !e[c + 5].insertLeft;) r = e[(c += 3) + 2], a = "right"; break } return { node: r, start: i, end: o, collapse: a, coverStart: s, coverEnd: l } } function Pn(e, t) { var n = In; if ("left" == t) for (var r = 0; r < e.length && (n = e[r]).left == n.right; r++); else for (var i = e.length - 1; i >= 0 && (n = e[i]).left == n.right; i--); return n } function Hn(e) { if (e.measure && (e.measure.cache = {}, e.measure.heights = null, e.rest)) for (var t = 0; t < e.rest.length; t++) e.measure.caches[t] = {} } function Fn(e) { e.display.externalMeasure = null, N(e.display.lineMeasure); for (var t = 0; t < e.display.view.length; t++) Hn(e.display.view[t]) } function Un(e) { Fn(e), e.display.cachedCharWidth = e.display.cachedTextHeight = e.display.cachedPaddingH = null, e.options.lineWrapping || (e.display.maxLineChanged = !0), e.display.lineNumChars = null } function Wn() { return u && m ? -(document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft)) : window.pageXOffset || (document.documentElement || document.body).scrollLeft } function qn() { return u && m ? -(document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop)) : window.pageYOffset || (document.documentElement || document.body).scrollTop } function zn(e) { var t = 0; if (e.widgets) for (var n = 0; n < e.widgets.length; ++n) e.widgets[n].above && (t += wn(e.widgets[n])); return t } function jn(e, t, n, r, i) { if (!i) { var o = zn(t); n.top += o, n.bottom += o } if ("line" == r) return n; r || (r = "local"); var a = zt(t); if ("local" == r ? a += Tn(e.display) : a -= e.display.viewOffset, "page" == r || "window" == r) { var s = e.display.lineSpace.getBoundingClientRect(); a += s.top + ("window" == r ? 0 : qn()); var l = s.left + ("window" == r ? 0 : Wn()); n.left += l, n.right += l } return n.top += a, n.bottom += a, n } function Vn(e, t, n) { if ("div" == n) return t; var r = t.left, i = t.top; if ("page" == n) r -= Wn(), i -= qn(); else if ("local" == n || !n) { var o = e.display.sizer.getBoundingClientRect(); r += o.left, i += o.top } var a = e.display.lineSpace.getBoundingClientRect(); return { left: r - a.left, top: i - a.top } } function Kn(e, t, n, r, i) { return r || (r = Ke(e.doc, t.line)), jn(e, r, Mn(e, r, t.ch, i), n) } function Gn(e, t, n, r, i, o) { function a(t, a) { var s = On(e, i, t, a ? "right" : "left", o); return a ? s.left = s.right : s.right = s.left, jn(e, r, s, n) } r = r || Ke(e.doc, t.line), i || (i = Bn(e, r)); var s = ce(r, e.doc.direction), l = t.ch, c = t.sticky; if (l >= r.text.length ? (l = r.text.length, c = "before") : l <= 0 && (l = 0, c = "after"), !s) return a("before" == c ? l - 1 : l, "before" == c); function u(e, t, n) { return a(n ? e - 1 : e, 1 == s[t].level != n) } var d = se(s, l, c), h = ae, f = u(l, d, "before" == c); return null != h && (f.other = u(l, h, "before" != c)), f } function $n(e, t) { var n = 0; t = st(e.doc, t), e.options.lineWrapping || (n = ir(e.display) * t.ch); var r = Ke(e.doc, t.line), i = zt(r) + Tn(e.display); return { left: n, right: n, top: i, bottom: i + r.height } } function Yn(e, t, n, r, i) { var o = et(e, t, n); return o.xRel = i, r && (o.outside = r), o } function Xn(e, t, n) { var r = e.doc; if ((n += e.display.viewOffset) < 0) return Yn(r.first, 0, null, -1, -1); var i = Ze(r, n), o = r.first + r.size - 1; if (i > o) return Yn(r.first + r.size - 1, Ke(r, o).text.length, null, 1, 1); t < 0 && (t = 0); for (var a = Ke(r, i);;) { var s = er(e, a, i, t, n), l = Rt(a, s.ch + (s.xRel > 0 || s.outside > 0 ? 1 : 0)); if (!l) return s; var c = l.find(1); if (c.line == i) return c; a = Ke(r, i = c.line) } } function Zn(e, t, n, r) { r -= zn(t); var i = t.text.length, o = oe((function (t) { return On(e, n, t - 1).bottom <= r }), i, 0); return { begin: o, end: i = oe((function (t) { return On(e, n, t).top > r }), o, i) } } function Qn(e, t, n, r) { return n || (n = Bn(e, t)), Zn(e, t, n, jn(e, t, On(e, n, r), "line").top) } function Jn(e, t, n, r) { return !(e.bottom <= n) && (e.top > n || (r ? e.left : e.right) > t) } function er(e, t, n, r, i) { i -= zt(t); var o = Bn(e, t), a = zn(t), s = 0, l = t.text.length, c = !0, u = ce(t, e.doc.direction); if (u) { var d = (e.options.lineWrapping ? nr : tr)(e, t, n, o, u, r, i); s = (c = 1 != d.level) ? d.from : d.to - 1, l = c ? d.to : d.from - 1 } var h, f, p = null, g = null, m = oe((function (t) { var n = On(e, o, t); return n.top += a, n.bottom += a, !!Jn(n, r, i, !1) && (n.top <= i && n.left <= r && (p = t, g = n), !0) }), s, l), v = !1; if (g) { var y = r - g.left < g.right - r, b = y == c; m = p + (b ? 0 : 1), f = b ? "after" : "before", h = y ? g.left : g.right } else { c || m != l && m != s || m++, f = 0 == m ? "after" : m == t.text.length ? "before" : On(e, o, m - (c ? 1 : 0)).bottom + a <= i == c ? "after" : "before"; var C = Gn(e, et(n, m, f), "line", t, o); h = C.left, v = i < C.top ? -1 : i >= C.bottom ? 1 : 0 } return Yn(n, m = ie(t.text, m, 1), f, v, r - h) } function tr(e, t, n, r, i, o, a) { var s = oe((function (s) { var l = i[s], c = 1 != l.level; return Jn(Gn(e, et(n, c ? l.to : l.from, c ? "before" : "after"), "line", t, r), o, a, !0) }), 0, i.length - 1), l = i[s]; if (s > 0) { var c = 1 != l.level, u = Gn(e, et(n, c ? l.from : l.to, c ? "after" : "before"), "line", t, r); Jn(u, o, a, !0) && u.top > a && (l = i[s - 1]) } return l } function nr(e, t, n, r, i, o, a) { var s = Zn(e, t, r, a), l = s.begin, c = s.end; /\s/.test(t.text.charAt(c - 1)) && c--; for (var u = null, d = null, h = 0; h < i.length; h++) { var f = i[h]; if (!(f.from >= c || f.to <= l)) { var p = On(e, r, 1 != f.level ? Math.min(c, f.to) - 1 : Math.max(l, f.from)).right, g = p < o ? o - p + 1e9 : p - o; (!u || d > g) && (u = f, d = g) } } return u || (u = i[i.length - 1]), u.from < l && (u = { from: l, to: u.to, level: u.level }), u.to > c && (u = { from: u.from, to: c, level: u.level }), u } function rr(e) { if (null != e.cachedTextHeight) return e.cachedTextHeight; if (null == Dn) { Dn = L("pre", null, "CodeMirror-line-like"); for (var t = 0; t < 49; ++t) Dn.appendChild(document.createTextNode("x")), Dn.appendChild(L("br")); Dn.appendChild(document.createTextNode("x")) } k(e.measure, Dn); var n = Dn.offsetHeight / 50; return n > 3 && (e.cachedTextHeight = n), N(e.measure), n || 1 } function ir(e) { if (null != e.cachedCharWidth) return e.cachedCharWidth; var t = L("span", "xxxxxxxxxx"), n = L("pre", [t], "CodeMirror-line-like"); k(e.measure, n); var r = t.getBoundingClientRect(), i = (r.right - r.left) / 10; return i > 2 && (e.cachedCharWidth = i), i || 10 } function or(e) { for (var t = e.display, n = {}, r = {}, i = t.gutters.clientLeft, o = t.gutters.firstChild, a = 0; o; o = o.nextSibling, ++a) { var s = e.display.gutterSpecs[a].className; n[s] = o.offsetLeft + o.clientLeft + i, r[s] = o.clientWidth } return { fixedPos: ar(t), gutterTotalWidth: t.gutters.offsetWidth, gutterLeft: n, gutterWidth: r, wrapperWidth: t.wrapper.clientWidth } } function ar(e) { return e.scroller.getBoundingClientRect().left - e.sizer.getBoundingClientRect().left } function sr(e) { var t = rr(e.display), n = e.options.lineWrapping, r = n && Math.max(5, e.display.scroller.clientWidth / ir(e.display) - 3); return function (i) { if (Wt(e.doc, i)) return 0; var o = 0; if (i.widgets) for (var a = 0; a < i.widgets.length; a++) i.widgets[a].height && (o += i.widgets[a].height); return n ? o + (Math.ceil(i.text.length / r) || 1) * t : o + t } } function lr(e) { var t = e.doc, n = sr(e); t.iter((function (e) { var t = n(e); t != e.height && Ye(e, t) })) } function cr(e, t, n, r) { var i = e.display; if (!n && "true" == Te(t).getAttribute("cm-not-content")) return null; var o, a, s = i.lineSpace.getBoundingClientRect(); try { o = t.clientX - s.left, a = t.clientY - s.top } catch (e) { return null } var l, c = Xn(e, o, a); if (r && c.xRel > 0 && (l = Ke(e.doc, c.line).text).length == c.ch) { var u = H(l, l.length, e.options.tabSize) - l.length; c = et(c.line, Math.max(0, Math.round((o - xn(e.display).left) / ir(e.display)) - u)) } return c } function ur(e, t) { if (t >= e.display.viewTo) return null; if ((t -= e.display.viewFrom) < 0) return null; for (var n = e.display.view, r = 0; r < n.length; r++) if ((t -= n[r].size) < 0) return r } function dr(e, t, n, r) { null == t && (t = e.doc.first), null == n && (n = e.doc.first + e.doc.size), r || (r = 0); var i = e.display; if (r && n < i.viewTo && (null == i.updateLineNumbers || i.updateLineNumbers > t) && (i.updateLineNumbers = t), e.curOp.viewChanged = !0, t >= i.viewTo) _t && Ft(e.doc, t) < i.viewTo && fr(e); else if (n <= i.viewFrom) _t && Ut(e.doc, n + r) > i.viewFrom ? fr(e) : (i.viewFrom += r, i.viewTo += r); else if (t <= i.viewFrom && n >= i.viewTo) fr(e); else if (t <= i.viewFrom) { var o = pr(e, n, n + r, 1); o ? (i.view = i.view.slice(o.index), i.viewFrom = o.lineN, i.viewTo += r) : fr(e) } else if (n >= i.viewTo) { var a = pr(e, t, t, -1); a ? (i.view = i.view.slice(0, a.index), i.viewTo = a.lineN) : fr(e) } else { var s = pr(e, t, t, -1), l = pr(e, n, n + r, 1); s && l ? (i.view = i.view.slice(0, s.index).concat(on(e, s.lineN, l.lineN)).concat(i.view.slice(l.index)), i.viewTo += r) : fr(e) } var c = i.externalMeasured; c && (n < c.lineN ? c.lineN += r : t < c.lineN + c.size && (i.externalMeasured = null)) } function hr(e, t, n) { e.curOp.viewChanged = !0; var r = e.display, i = e.display.externalMeasured; if (i && t >= i.lineN && t < i.lineN + i.size && (r.externalMeasured = null), !(t < r.viewFrom || t >= r.viewTo)) { var o = r.view[ur(e, t)]; if (null != o.node) { var a = o.changes || (o.changes = []); - 1 == U(a, n) && a.push(n) } } } function fr(e) { e.display.viewFrom = e.display.viewTo = e.doc.first, e.display.view = [], e.display.viewOffset = 0 } function pr(e, t, n, r) { var i, o = ur(e, t), a = e.display.view; if (!_t || n == e.doc.first + e.doc.size) return { index: o, lineN: n }; for (var s = e.display.viewFrom, l = 0; l < o; l++) s += a[l].size; if (s != t) { if (r > 0) { if (o == a.length - 1) return null; i = s + a[o].size - t, o++ } else i = s - t; t += i, n += i } for (; Ft(e.doc, n) != n;) { if (o == (r < 0 ? 0 : a.length - 1)) return null; n += r * a[o - (r < 0 ? 1 : 0)].size, o += r } return { index: o, lineN: n } } function gr(e) { for (var t = e.display.view, n = 0, r = 0; r < t.length; r++) { var i = t[r]; i.hidden || i.node && !i.changes || ++n } return n } function mr(e) { e.display.input.showSelection(e.display.input.prepareSelection()) } function vr(e, t) { void 0 === t && (t = !0); for (var n = e.doc, r = {}, i = r.cursors = document.createDocumentFragment(), o = r.selection = document.createDocumentFragment(), a = 0; a < n.sel.ranges.length; a++) if (t || a != n.sel.primIndex) { var s = n.sel.ranges[a]; if (!(s.from().line >= e.display.viewTo || s.to().line < e.display.viewFrom)) { var l = s.empty(); (l || e.options.showCursorWhenSelecting) && yr(e, s.head, i), l || Cr(e, s, o) } } return r } function yr(e, t, n) { var r = Gn(e, t, "div", null, null, !e.options.singleCursorHeightPerLine), i = n.appendChild(L("div", " ", "CodeMirror-cursor")); if (i.style.left = r.left + "px", i.style.top = r.top + "px", i.style.height = Math.max(0, r.bottom - r.top) * e.options.cursorHeight + "px", r.other) { var o = n.appendChild(L("div", " ", "CodeMirror-cursor CodeMirror-secondarycursor")); o.style.display = "", o.style.left = r.other.left + "px", o.style.top = r.other.top + "px", o.style.height = .85 * (r.other.bottom - r.other.top) + "px" } } function br(e, t) { return e.top - t.top || e.left - t.left } function Cr(e, t, n) { var r = e.display, i = e.doc, o = document.createDocumentFragment(), a = xn(e.display), s = a.left, l = Math.max(r.sizerWidth, Nn(e) - r.sizer.offsetLeft) - a.right, c = "ltr" == i.direction; function u(e, t, n, r) { t < 0 && (t = 0), t = Math.round(t), r = Math.round(r), o.appendChild(L("div", null, "CodeMirror-selected", "position: absolute; left: " + e + "px;\n top: " + t + "px; width: " + (null == n ? l - e : n) + "px;\n height: " + (r - t) + "px")) } function d(t, n, r) { var o, a, d = Ke(i, t), h = d.text.length; function f(n, r) { return Kn(e, et(t, n), "div", d, r) } function p(t, n, r) { var i = Qn(e, d, null, t), o = "ltr" == n == ("after" == r) ? "left" : "right"; return f("after" == r ? i.begin : i.end - (/\s/.test(d.text.charAt(i.end - 1)) ? 2 : 1), o)[o] } var g = ce(d, i.direction); return function (e, t, n, r) { if (!e) return r(t, n, "ltr", 0); for (var i = !1, o = 0; o < e.length; ++o) { var a = e[o]; (a.from < n && a.to > t || t == n && a.to == t) && (r(Math.max(a.from, t), Math.min(a.to, n), 1 == a.level ? "rtl" : "ltr", o), i = !0) } i || r(t, n, "ltr") }(g, n || 0, null == r ? h : r, (function (e, t, i, d) { var m = "ltr" == i, v = f(e, m ? "left" : "right"), y = f(t - 1, m ? "right" : "left"), b = null == n && 0 == e, C = null == r && t == h, w = 0 == d, _ = !g || d == g.length - 1; if (y.top - v.top <= 3) { var T = (c ? C : b) && _, E = (c ? b : C) && w ? s : (m ? v : y).left, x = T ? l : (m ? y : v).right; u(E, v.top, x - E, v.bottom) } else { var S, N, k, L; m ? (S = c && b && w ? s : v.left, N = c ? l : p(e, i, "before"), k = c ? s : p(t, i, "after"), L = c && C && _ ? l : y.right) : (S = c ? p(e, i, "before") : s, N = !c && b && w ? l : v.right, k = !c && C && _ ? s : y.left, L = c ? p(t, i, "after") : l), u(S, v.top, N - S, v.bottom), v.bottom < y.top && u(s, v.bottom, null, y.top), u(k, y.top, L - k, y.bottom) }(!o || br(v, o) < 0) && (o = v), br(y, o) < 0 && (o = y), (!a || br(v, a) < 0) && (a = v), br(y, a) < 0 && (a = y) })), { start: o, end: a } } var h = t.from(), f = t.to(); if (h.line == f.line) d(h.line, h.ch, f.ch); else { var p = Ke(i, h.line), g = Ke(i, f.line), m = Ht(p) == Ht(g), v = d(h.line, h.ch, m ? p.text.length + 1 : null).end, y = d(f.line, m ? 0 : null, f.ch).start; m && (v.top < y.top - 2 ? (u(v.right, v.top, null, v.bottom), u(s, y.top, y.left, y.bottom)) : u(v.right, v.top, y.left - v.right, v.bottom)), v.bottom < y.top && u(s, v.bottom, null, y.top) } n.appendChild(o) } function wr(e) { if (e.state.focused) { var t = e.display; clearInterval(t.blinker); var n = !0; t.cursorDiv.style.visibility = "", e.options.cursorBlinkRate > 0 ? t.blinker = setInterval((function () { e.hasFocus() || xr(e), t.cursorDiv.style.visibility = (n = !n) ? "" : "hidden" }), e.options.cursorBlinkRate) : e.options.cursorBlinkRate < 0 && (t.cursorDiv.style.visibility = "hidden") } } function _r(e) { e.hasFocus() || (e.display.input.focus(), e.state.focused || Er(e)) } function Tr(e) { e.state.delayingBlurEvent = !0, setTimeout((function () { e.state.delayingBlurEvent && (e.state.delayingBlurEvent = !1, e.state.focused && xr(e)) }), 100) } function Er(e, t) { e.state.delayingBlurEvent && !e.state.draggingText && (e.state.delayingBlurEvent = !1), "nocursor" != e.options.readOnly && (e.state.focused || (pe(e, "focus", e, t), e.state.focused = !0, O(e.display.wrapper, "CodeMirror-focused"), e.curOp || e.display.selForContextMenu == e.doc.sel || (e.display.input.reset(), l && setTimeout((function () { return e.display.input.reset(!0) }), 20)), e.display.input.receivedFocus()), wr(e)) } function xr(e, t) { e.state.delayingBlurEvent || (e.state.focused && (pe(e, "blur", e, t), e.state.focused = !1, S(e.display.wrapper, "CodeMirror-focused")), clearInterval(e.display.blinker), setTimeout((function () { e.state.focused || (e.display.shift = !1) }), 150)) } function Sr(e) { for (var t = e.display, n = t.lineDiv.offsetTop, r = 0; r < t.view.length; r++) { var i = t.view[r], o = e.options.lineWrapping, l = void 0, c = 0; if (!i.hidden) { if (a && s < 8) { var u = i.node.offsetTop + i.node.offsetHeight; l = u - n, n = u } else { var d = i.node.getBoundingClientRect(); l = d.bottom - d.top, !o && i.text.firstChild && (c = i.text.firstChild.getBoundingClientRect().right - d.left - 1) } var h = i.line.height - l; if ((h > .005 || h < -.005) && (Ye(i.line, l), Nr(i.line), i.rest)) for (var f = 0; f < i.rest.length; f++) Nr(i.rest[f]); if (c > e.display.sizerWidth) { var p = Math.ceil(c / ir(e.display)); p > e.display.maxLineLength && (e.display.maxLineLength = p, e.display.maxLine = i.line, e.display.maxLineChanged = !0) } } } } function Nr(e) { if (e.widgets) for (var t = 0; t < e.widgets.length; ++t) { var n = e.widgets[t], r = n.node.parentNode; r && (n.height = r.offsetHeight) } } function kr(e, t, n) { var r = n && null != n.top ? Math.max(0, n.top) : e.scroller.scrollTop; r = Math.floor(r - Tn(e)); var i = n && null != n.bottom ? n.bottom : r + e.wrapper.clientHeight, o = Ze(t, r), a = Ze(t, i); if (n && n.ensure) { var s = n.ensure.from.line, l = n.ensure.to.line; s < o ? (o = s, a = Ze(t, zt(Ke(t, s)) + e.wrapper.clientHeight)) : Math.min(l, t.lastLine()) >= a && (o = Ze(t, zt(Ke(t, l)) - e.wrapper.clientHeight), a = l) } return { from: o, to: Math.max(a, o + 1) } } function Lr(e, t) { var n = e.display, r = rr(e.display); t.top < 0 && (t.top = 0); var i = e.curOp && null != e.curOp.scrollTop ? e.curOp.scrollTop : n.scroller.scrollTop, o = kn(e), a = {}; t.bottom - t.top > o && (t.bottom = t.top + o); var s = e.doc.height + En(n), l = t.top < r, c = t.bottom > s - r; if (t.top < i) a.scrollTop = l ? 0 : t.top; else if (t.bottom > i + o) { var u = Math.min(t.top, (c ? s : t.bottom) - o); u != i && (a.scrollTop = u) } var d = e.options.fixedGutter ? 0 : n.gutters.offsetWidth, h = e.curOp && null != e.curOp.scrollLeft ? e.curOp.scrollLeft : n.scroller.scrollLeft - d, f = Nn(e) - n.gutters.offsetWidth, p = t.right - t.left > f; return p && (t.right = t.left + f), t.left < 10 ? a.scrollLeft = 0 : t.left < h ? a.scrollLeft = Math.max(0, t.left + d - (p ? 0 : 10)) : t.right > f + h - 3 && (a.scrollLeft = t.right + (p ? 0 : 10) - f), a } function Mr(e, t) { null != t && (Or(e), e.curOp.scrollTop = (null == e.curOp.scrollTop ? e.doc.scrollTop : e.curOp.scrollTop) + t) } function Ar(e) { Or(e); var t = e.getCursor(); e.curOp.scrollToPos = { from: t, to: t, margin: e.options.cursorScrollMargin } } function Br(e, t, n) { null == t && null == n || Or(e), null != t && (e.curOp.scrollLeft = t), null != n && (e.curOp.scrollTop = n) } function Or(e) { var t = e.curOp.scrollToPos; t && (e.curOp.scrollToPos = null, Dr(e, $n(e, t.from), $n(e, t.to), t.margin)) } function Dr(e, t, n, r) { var i = Lr(e, { left: Math.min(t.left, n.left), top: Math.min(t.top, n.top) - r, right: Math.max(t.right, n.right), bottom: Math.max(t.bottom, n.bottom) + r }); Br(e, i.scrollLeft, i.scrollTop) } function Ir(e, t) { Math.abs(e.doc.scrollTop - t) < 2 || (n || li(e, { top: t }), Rr(e, t, !0), n && li(e), ri(e, 100)) } function Rr(e, t, n) { t = Math.max(0, Math.min(e.display.scroller.scrollHeight - e.display.scroller.clientHeight, t)), (e.display.scroller.scrollTop != t || n) && (e.doc.scrollTop = t, e.display.scrollbars.setScrollTop(t), e.display.scroller.scrollTop != t && (e.display.scroller.scrollTop = t)) } function Pr(e, t, n, r) { t = Math.max(0, Math.min(t, e.display.scroller.scrollWidth - e.display.scroller.clientWidth)), (n ? t == e.doc.scrollLeft : Math.abs(e.doc.scrollLeft - t) < 2) && !r || (e.doc.scrollLeft = t, di(e), e.display.scroller.scrollLeft != t && (e.display.scroller.scrollLeft = t), e.display.scrollbars.setScrollLeft(t)) } function Hr(e) { var t = e.display, n = t.gutters.offsetWidth, r = Math.round(e.doc.height + En(e.display)); return { clientHeight: t.scroller.clientHeight, viewHeight: t.wrapper.clientHeight, scrollWidth: t.scroller.scrollWidth, clientWidth: t.scroller.clientWidth, viewWidth: t.wrapper.clientWidth, barLeft: e.options.fixedGutter ? n : 0, docHeight: r, scrollHeight: r + Sn(e) + t.barHeight, nativeBarWidth: t.nativeBarWidth, gutterWidth: n } } var Fr = function (e, t, n) { this.cm = n; var r = this.vert = L("div", [L("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar"), i = this.horiz = L("div", [L("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar"); r.tabIndex = i.tabIndex = -1, e(r), e(i), de(r, "scroll", (function () { r.clientHeight && t(r.scrollTop, "vertical") })), de(i, "scroll", (function () { i.clientWidth && t(i.scrollLeft, "horizontal") })), this.checkedZeroWidth = !1, a && s < 8 && (this.horiz.style.minHeight = this.vert.style.minWidth = "18px") }; Fr.prototype.update = function (e) { var t = e.scrollWidth > e.clientWidth + 1, n = e.scrollHeight > e.clientHeight + 1, r = e.nativeBarWidth; if (n) { this.vert.style.display = "block", this.vert.style.bottom = t ? r + "px" : "0"; var i = e.viewHeight - (t ? r : 0); this.vert.firstChild.style.height = Math.max(0, e.scrollHeight - e.clientHeight + i) + "px" } else this.vert.style.display = "", this.vert.firstChild.style.height = "0"; if (t) { this.horiz.style.display = "block", this.horiz.style.right = n ? r + "px" : "0", this.horiz.style.left = e.barLeft + "px"; var o = e.viewWidth - e.barLeft - (n ? r : 0); this.horiz.firstChild.style.width = Math.max(0, e.scrollWidth - e.clientWidth + o) + "px" } else this.horiz.style.display = "", this.horiz.firstChild.style.width = "0"; return !this.checkedZeroWidth && e.clientHeight > 0 && (0 == r && this.zeroWidthHack(), this.checkedZeroWidth = !0), { right: n ? r : 0, bottom: t ? r : 0 } }, Fr.prototype.setScrollLeft = function (e) { this.horiz.scrollLeft != e && (this.horiz.scrollLeft = e), this.disableHoriz && this.enableZeroWidthBar(this.horiz, this.disableHoriz, "horiz") }, Fr.prototype.setScrollTop = function (e) { this.vert.scrollTop != e && (this.vert.scrollTop = e), this.disableVert && this.enableZeroWidthBar(this.vert, this.disableVert, "vert") }, Fr.prototype.zeroWidthHack = function () { var e = y && !f ? "12px" : "18px"; this.horiz.style.height = this.vert.style.width = e, this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none", this.disableHoriz = new F, this.disableVert = new F }, Fr.prototype.enableZeroWidthBar = function (e, t, n) { e.style.pointerEvents = "auto", t.set(1e3, (function r() { var i = e.getBoundingClientRect(); ("vert" == n ? document.elementFromPoint(i.right - 1, (i.top + i.bottom) / 2) : document.elementFromPoint((i.right + i.left) / 2, i.bottom - 1)) != e ? e.style.pointerEvents = "none" : t.set(1e3, r) })) }, Fr.prototype.clear = function () { var e = this.horiz.parentNode; e.removeChild(this.horiz), e.removeChild(this.vert) }; var Ur = function () {}; function Wr(e, t) { t || (t = Hr(e)); var n = e.display.barWidth, r = e.display.barHeight; qr(e, t); for (var i = 0; i < 4 && n != e.display.barWidth || r != e.display.barHeight; i++) n != e.display.barWidth && e.options.lineWrapping && Sr(e), qr(e, Hr(e)), n = e.display.barWidth, r = e.display.barHeight } function qr(e, t) { var n = e.display, r = n.scrollbars.update(t); n.sizer.style.paddingRight = (n.barWidth = r.right) + "px", n.sizer.style.paddingBottom = (n.barHeight = r.bottom) + "px", n.heightForcer.style.borderBottom = r.bottom + "px solid transparent", r.right && r.bottom ? (n.scrollbarFiller.style.display = "block", n.scrollbarFiller.style.height = r.bottom + "px", n.scrollbarFiller.style.width = r.right + "px") : n.scrollbarFiller.style.display = "", r.bottom && e.options.coverGutterNextToScrollbar && e.options.fixedGutter ? (n.gutterFiller.style.display = "block", n.gutterFiller.style.height = r.bottom + "px", n.gutterFiller.style.width = t.gutterWidth + "px") : n.gutterFiller.style.display = "" } Ur.prototype.update = function () { return { bottom: 0, right: 0 } }, Ur.prototype.setScrollLeft = function () {}, Ur.prototype.setScrollTop = function () {}, Ur.prototype.clear = function () {}; var zr = { native: Fr, null: Ur }; function jr(e) { e.display.scrollbars && (e.display.scrollbars.clear(), e.display.scrollbars.addClass && S(e.display.wrapper, e.display.scrollbars.addClass)), e.display.scrollbars = new zr[e.options.scrollbarStyle]((function (t) { e.display.wrapper.insertBefore(t, e.display.scrollbarFiller), de(t, "mousedown", (function () { e.state.focused && setTimeout((function () { return e.display.input.focus() }), 0) })), t.setAttribute("cm-not-content", "true") }), (function (t, n) { "horizontal" == n ? Pr(e, t) : Ir(e, t) }), e), e.display.scrollbars.addClass && O(e.display.wrapper, e.display.scrollbars.addClass) } var Vr = 0; function Kr(e) { var t; e.curOp = { cm: e, viewChanged: !1, startHeight: e.doc.height, forceUpdate: !1, updateInput: 0, typing: !1, changeObjs: null, cursorActivityHandlers: null, cursorActivityCalled: 0, selectionChanged: !1, updateMaxLine: !1, scrollLeft: null, scrollTop: null, scrollToPos: null, focus: !1, id: ++Vr }, t = e.curOp, an ? an.ops.push(t) : t.ownsGroup = an = { ops: [t], delayedCallbacks: [] } } function Gr(e) { var t = e.curOp; t && function (e, t) { var n = e.ownsGroup; if (n) try { ! function (e) { var t = e.delayedCallbacks, n = 0; do { for (; n < t.length; n++) t[n].call(null); for (var r = 0; r < e.ops.length; r++) { var i = e.ops[r]; if (i.cursorActivityHandlers) for (; i.cursorActivityCalled < i.cursorActivityHandlers.length;) i.cursorActivityHandlers[i.cursorActivityCalled++].call(null, i.cm) } } while (n < t.length) }(n) } finally { an = null, t(n) } }(t, (function (e) { for (var t = 0; t < e.ops.length; t++) e.ops[t].cm.curOp = null; ! function (e) { for (var t = e.ops, n = 0; n < t.length; n++) $r(t[n]); for (var r = 0; r < t.length; r++) Yr(t[r]); for (var i = 0; i < t.length; i++) Xr(t[i]); for (var o = 0; o < t.length; o++) Zr(t[o]); for (var a = 0; a < t.length; a++) Qr(t[a]) }(e) })) } function $r(e) { var t = e.cm, n = t.display; ! function (e) { var t = e.display; !t.scrollbarsClipped && t.scroller.offsetWidth && (t.nativeBarWidth = t.scroller.offsetWidth - t.scroller.clientWidth, t.heightForcer.style.height = Sn(e) + "px", t.sizer.style.marginBottom = -t.nativeBarWidth + "px", t.sizer.style.borderRightWidth = Sn(e) + "px", t.scrollbarsClipped = !0) }(t), e.updateMaxLine && Vt(t), e.mustUpdate = e.viewChanged || e.forceUpdate || null != e.scrollTop || e.scrollToPos && (e.scrollToPos.from.line < n.viewFrom || e.scrollToPos.to.line >= n.viewTo) || n.maxLineChanged && t.options.lineWrapping, e.update = e.mustUpdate && new oi(t, e.mustUpdate && { top: e.scrollTop, ensure: e.scrollToPos }, e.forceUpdate) } function Yr(e) { e.updatedDisplay = e.mustUpdate && ai(e.cm, e.update) } function Xr(e) { var t = e.cm, n = t.display; e.updatedDisplay && Sr(t), e.barMeasure = Hr(t), n.maxLineChanged && !t.options.lineWrapping && (e.adjustWidthTo = Mn(t, n.maxLine, n.maxLine.text.length).left + 3, t.display.sizerWidth = e.adjustWidthTo, e.barMeasure.scrollWidth = Math.max(n.scroller.clientWidth, n.sizer.offsetLeft + e.adjustWidthTo + Sn(t) + t.display.barWidth), e.maxScrollLeft = Math.max(0, n.sizer.offsetLeft + e.adjustWidthTo - Nn(t))), (e.updatedDisplay || e.selectionChanged) && (e.preparedSelection = n.input.prepareSelection()) } function Zr(e) { var t = e.cm; null != e.adjustWidthTo && (t.display.sizer.style.minWidth = e.adjustWidthTo + "px", e.maxScrollLeft < t.doc.scrollLeft && Pr(t, Math.min(t.display.scroller.scrollLeft, e.maxScrollLeft), !0), t.display.maxLineChanged = !1); var n = e.focus && e.focus == B(); e.preparedSelection && t.display.input.showSelection(e.preparedSelection, n), (e.updatedDisplay || e.startHeight != t.doc.height) && Wr(t, e.barMeasure), e.updatedDisplay && ui(t, e.barMeasure), e.selectionChanged && wr(t), t.state.focused && e.updateInput && t.display.input.reset(e.typing), n && _r(e.cm) } function Qr(e) { var t = e.cm, n = t.display, r = t.doc; e.updatedDisplay && si(t, e.update), null == n.wheelStartX || null == e.scrollTop && null == e.scrollLeft && !e.scrollToPos || (n.wheelStartX = n.wheelStartY = null), null != e.scrollTop && Rr(t, e.scrollTop, e.forceScroll), null != e.scrollLeft && Pr(t, e.scrollLeft, !0, !0), e.scrollToPos && function (e, t) { if (!ge(e, "scrollCursorIntoView")) { var n = e.display, r = n.sizer.getBoundingClientRect(), i = null; if (t.top + r.top < 0 ? i = !0 : t.bottom + r.top > (window.innerHeight || document.documentElement.clientHeight) && (i = !1), null != i && !p) { var o = L("div", "​", null, "position: absolute;\n top: " + (t.top - n.viewOffset - Tn(e.display)) + "px;\n height: " + (t.bottom - t.top + Sn(e) + n.barHeight) + "px;\n left: " + t.left + "px; width: " + Math.max(2, t.right - t.left) + "px;"); e.display.lineSpace.appendChild(o), o.scrollIntoView(i), e.display.lineSpace.removeChild(o) } } }(t, function (e, t, n, r) { var i; null == r && (r = 0), e.options.lineWrapping || t != n || (n = "before" == (t = t.ch ? et(t.line, "before" == t.sticky ? t.ch - 1 : t.ch, "after") : t).sticky ? et(t.line, t.ch + 1, "before") : t); for (var o = 0; o < 5; o++) { var a = !1, s = Gn(e, t), l = n && n != t ? Gn(e, n) : s, c = Lr(e, i = { left: Math.min(s.left, l.left), top: Math.min(s.top, l.top) - r, right: Math.max(s.left, l.left), bottom: Math.max(s.bottom, l.bottom) + r }), u = e.doc.scrollTop, d = e.doc.scrollLeft; if (null != c.scrollTop && (Ir(e, c.scrollTop), Math.abs(e.doc.scrollTop - u) > 1 && (a = !0)), null != c.scrollLeft && (Pr(e, c.scrollLeft), Math.abs(e.doc.scrollLeft - d) > 1 && (a = !0)), !a) break } return i }(t, st(r, e.scrollToPos.from), st(r, e.scrollToPos.to), e.scrollToPos.margin)); var i = e.maybeHiddenMarkers, o = e.maybeUnhiddenMarkers; if (i) for (var a = 0; a < i.length; ++a) i[a].lines.length || pe(i[a], "hide"); if (o) for (var s = 0; s < o.length; ++s) o[s].lines.length && pe(o[s], "unhide"); n.wrapper.offsetHeight && (r.scrollTop = t.display.scroller.scrollTop), e.changeObjs && pe(t, "changes", t, e.changeObjs), e.update && e.update.finish() } function Jr(e, t) { if (e.curOp) return t(); Kr(e); try { return t() } finally { Gr(e) } } function ei(e, t) { return function () { if (e.curOp) return t.apply(e, arguments); Kr(e); try { return t.apply(e, arguments) } finally { Gr(e) } } } function ti(e) { return function () { if (this.curOp) return e.apply(this, arguments); Kr(this); try { return e.apply(this, arguments) } finally { Gr(this) } } } function ni(e) { return function () { var t = this.cm; if (!t || t.curOp) return e.apply(this, arguments); Kr(t); try { return e.apply(this, arguments) } finally { Gr(t) } } } function ri(e, t) { e.doc.highlightFrontier < e.display.viewTo && e.state.highlight.set(t, R(ii, e)) } function ii(e) { var t = e.doc; if (!(t.highlightFrontier >= e.display.viewTo)) { var n = +new Date + e.options.workTime, r = ft(e, t.highlightFrontier), i = []; t.iter(r.line, Math.min(t.first + t.size, e.display.viewTo + 500), (function (o) { if (r.line >= e.display.viewFrom) { var a = o.styles, s = o.text.length > e.options.maxHighlightLength ? qe(t.mode, r.state) : null, l = dt(e, o, r, !0); s && (r.state = s), o.styles = l.styles; var c = o.styleClasses, u = l.classes; u ? o.styleClasses = u : c && (o.styleClasses = null); for (var d = !a || a.length != o.styles.length || c != u && (!c || !u || c.bgClass != u.bgClass || c.textClass != u.textClass), h = 0; !d && h < a.length; ++h) d = a[h] != o.styles[h]; d && i.push(r.line), o.stateAfter = r.save(), r.nextLine() } else o.text.length <= e.options.maxHighlightLength && pt(e, o.text, r), o.stateAfter = r.line % 5 == 0 ? r.save() : null, r.nextLine(); if (+new Date > n) return ri(e, e.options.workDelay), !0 })), t.highlightFrontier = r.line, t.modeFrontier = Math.max(t.modeFrontier, r.line), i.length && Jr(e, (function () { for (var t = 0; t < i.length; t++) hr(e, i[t], "text") })) } } var oi = function (e, t, n) { var r = e.display; this.viewport = t, this.visible = kr(r, e.doc, t), this.editorIsHidden = !r.wrapper.offsetWidth, this.wrapperHeight = r.wrapper.clientHeight, this.wrapperWidth = r.wrapper.clientWidth, this.oldDisplayWidth = Nn(e), this.force = n, this.dims = or(e), this.events = [] }; function ai(e, t) { var n = e.display, r = e.doc; if (t.editorIsHidden) return fr(e), !1; if (!t.force && t.visible.from >= n.viewFrom && t.visible.to <= n.viewTo && (null == n.updateLineNumbers || n.updateLineNumbers >= n.viewTo) && n.renderedView == n.view && 0 == gr(e)) return !1; hi(e) && (fr(e), t.dims = or(e)); var i = r.first + r.size, o = Math.max(t.visible.from - e.options.viewportMargin, r.first), a = Math.min(i, t.visible.to + e.options.viewportMargin); n.viewFrom < o && o - n.viewFrom < 20 && (o = Math.max(r.first, n.viewFrom)), n.viewTo > a && n.viewTo - a < 20 && (a = Math.min(i, n.viewTo)), _t && (o = Ft(e.doc, o), a = Ut(e.doc, a)); var s = o != n.viewFrom || a != n.viewTo || n.lastWrapHeight != t.wrapperHeight || n.lastWrapWidth != t.wrapperWidth; ! function (e, t, n) { var r = e.display; 0 == r.view.length || t >= r.viewTo || n <= r.viewFrom ? (r.view = on(e, t, n), r.viewFrom = t) : (r.viewFrom > t ? r.view = on(e, t, r.viewFrom).concat(r.view) : r.viewFrom < t && (r.view = r.view.slice(ur(e, t))), r.viewFrom = t, r.viewTo < n ? r.view = r.view.concat(on(e, r.viewTo, n)) : r.viewTo > n && (r.view = r.view.slice(0, ur(e, n)))), r.viewTo = n }(e, o, a), n.viewOffset = zt(Ke(e.doc, n.viewFrom)), e.display.mover.style.top = n.viewOffset + "px"; var c = gr(e); if (!s && 0 == c && !t.force && n.renderedView == n.view && (null == n.updateLineNumbers || n.updateLineNumbers >= n.viewTo)) return !1; var u = function (e) { if (e.hasFocus()) return null; var t = B(); if (!t || !A(e.display.lineDiv, t)) return null; var n = { activeElt: t }; if (window.getSelection) { var r = window.getSelection(); r.anchorNode && r.extend && A(e.display.lineDiv, r.anchorNode) && (n.anchorNode = r.anchorNode, n.anchorOffset = r.anchorOffset, n.focusNode = r.focusNode, n.focusOffset = r.focusOffset) } return n }(e); return c > 4 && (n.lineDiv.style.display = "none"), function (e, t, n) { var r = e.display, i = e.options.lineNumbers, o = r.lineDiv, a = o.firstChild; function s(t) { var n = t.nextSibling; return l && y && e.display.currentWheelTarget == t ? t.style.display = "none" : t.parentNode.removeChild(t), n } for (var c = r.view, u = r.viewFrom, d = 0; d < c.length; d++) { var h = c[d]; if (h.hidden); else if (h.node && h.node.parentNode == o) { for (; a != h.node;) a = s(a); var f = i && null != t && t <= u && h.lineNumber; h.changes && (U(h.changes, "gutter") > -1 && (f = !1), un(e, h, u, n)), f && (N(h.lineNumber), h.lineNumber.appendChild(document.createTextNode(Je(e.options, u)))), a = h.node.nextSibling } else { var p = vn(e, h, u, n); o.insertBefore(p, a) } u += h.size } for (; a;) a = s(a) }(e, n.updateLineNumbers, t.dims), c > 4 && (n.lineDiv.style.display = ""), n.renderedView = n.view, function (e) { if (e && e.activeElt && e.activeElt != B() && (e.activeElt.focus(), !/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName) && e.anchorNode && A(document.body, e.anchorNode) && A(document.body, e.focusNode))) { var t = window.getSelection(), n = document.createRange(); n.setEnd(e.anchorNode, e.anchorOffset), n.collapse(!1), t.removeAllRanges(), t.addRange(n), t.extend(e.focusNode, e.focusOffset) } }(u), N(n.cursorDiv), N(n.selectionDiv), n.gutters.style.height = n.sizer.style.minHeight = 0, s && (n.lastWrapHeight = t.wrapperHeight, n.lastWrapWidth = t.wrapperWidth, ri(e, 400)), n.updateLineNumbers = null, !0 } function si(e, t) { for (var n = t.viewport, r = !0;; r = !1) { if (r && e.options.lineWrapping && t.oldDisplayWidth != Nn(e)) r && (t.visible = kr(e.display, e.doc, n)); else if (n && null != n.top && (n = { top: Math.min(e.doc.height + En(e.display) - kn(e), n.top) }), t.visible = kr(e.display, e.doc, n), t.visible.from >= e.display.viewFrom && t.visible.to <= e.display.viewTo) break; if (!ai(e, t)) break; Sr(e); var i = Hr(e); mr(e), Wr(e, i), ui(e, i), t.force = !1 } t.signal(e, "update", e), e.display.viewFrom == e.display.reportedViewFrom && e.display.viewTo == e.display.reportedViewTo || (t.signal(e, "viewportChange", e, e.display.viewFrom, e.display.viewTo), e.display.reportedViewFrom = e.display.viewFrom, e.display.reportedViewTo = e.display.viewTo) } function li(e, t) { var n = new oi(e, t); if (ai(e, n)) { Sr(e), si(e, n); var r = Hr(e); mr(e), Wr(e, r), ui(e, r), n.finish() } } function ci(e) { var t = e.gutters.offsetWidth; e.sizer.style.marginLeft = t + "px" } function ui(e, t) { e.display.sizer.style.minHeight = t.docHeight + "px", e.display.heightForcer.style.top = t.docHeight + "px", e.display.gutters.style.height = t.docHeight + e.display.barHeight + Sn(e) + "px" } function di(e) { var t = e.display, n = t.view; if (t.alignWidgets || t.gutters.firstChild && e.options.fixedGutter) { for (var r = ar(t) - t.scroller.scrollLeft + e.doc.scrollLeft, i = t.gutters.offsetWidth, o = r + "px", a = 0; a < n.length; a++) if (!n[a].hidden) { e.options.fixedGutter && (n[a].gutter && (n[a].gutter.style.left = o), n[a].gutterBackground && (n[a].gutterBackground.style.left = o)); var s = n[a].alignable; if (s) for (var l = 0; l < s.length; l++) s[l].style.left = o } e.options.fixedGutter && (t.gutters.style.left = r + i + "px") } } function hi(e) { if (!e.options.lineNumbers) return !1; var t = e.doc, n = Je(e.options, t.first + t.size - 1), r = e.display; if (n.length != r.lineNumChars) { var i = r.measure.appendChild(L("div", [L("div", n)], "CodeMirror-linenumber CodeMirror-gutter-elt")), o = i.firstChild.offsetWidth, a = i.offsetWidth - o; return r.lineGutter.style.width = "", r.lineNumInnerWidth = Math.max(o, r.lineGutter.offsetWidth - a) + 1, r.lineNumWidth = r.lineNumInnerWidth + a, r.lineNumChars = r.lineNumInnerWidth ? n.length : -1, r.lineGutter.style.width = r.lineNumWidth + "px", ci(e.display), !0 } return !1 } function fi(e, t) { for (var n = [], r = !1, i = 0; i < e.length; i++) { var o = e[i], a = null; if ("string" != typeof o && (a = o.style, o = o.className), "CodeMirror-linenumbers" == o) { if (!t) continue; r = !0 } n.push({ className: o, style: a }) } return t && !r && n.push({ className: "CodeMirror-linenumbers", style: null }), n } function pi(e) { var t = e.gutters, n = e.gutterSpecs; N(t), e.lineGutter = null; for (var r = 0; r < n.length; ++r) { var i = n[r], o = i.className, a = i.style, s = t.appendChild(L("div", null, "CodeMirror-gutter " + o)); a && (s.style.cssText = a), "CodeMirror-linenumbers" == o && (e.lineGutter = s, s.style.width = (e.lineNumWidth || 1) + "px") } t.style.display = n.length ? "" : "none", ci(e) } function gi(e) { pi(e.display), dr(e), di(e) } function mi(e, t, r, i) { var o = this; this.input = r, o.scrollbarFiller = L("div", null, "CodeMirror-scrollbar-filler"), o.scrollbarFiller.setAttribute("cm-not-content", "true"), o.gutterFiller = L("div", null, "CodeMirror-gutter-filler"), o.gutterFiller.setAttribute("cm-not-content", "true"), o.lineDiv = M("div", null, "CodeMirror-code"), o.selectionDiv = L("div", null, null, "position: relative; z-index: 1"), o.cursorDiv = L("div", null, "CodeMirror-cursors"), o.measure = L("div", null, "CodeMirror-measure"), o.lineMeasure = L("div", null, "CodeMirror-measure"), o.lineSpace = M("div", [o.measure, o.lineMeasure, o.selectionDiv, o.cursorDiv, o.lineDiv], null, "position: relative; outline: none"); var c = M("div", [o.lineSpace], "CodeMirror-lines"); o.mover = L("div", [c], null, "position: relative"), o.sizer = L("div", [o.mover], "CodeMirror-sizer"), o.sizerWidth = null, o.heightForcer = L("div", null, null, "position: absolute; height: 50px; width: 1px;"), o.gutters = L("div", null, "CodeMirror-gutters"), o.lineGutter = null, o.scroller = L("div", [o.sizer, o.heightForcer, o.gutters], "CodeMirror-scroll"), o.scroller.setAttribute("tabIndex", "-1"), o.wrapper = L("div", [o.scrollbarFiller, o.gutterFiller, o.scroller], "CodeMirror"), a && s < 8 && (o.gutters.style.zIndex = -1, o.scroller.style.paddingRight = 0), l || n && v || (o.scroller.draggable = !0), e && (e.appendChild ? e.appendChild(o.wrapper) : e(o.wrapper)), o.viewFrom = o.viewTo = t.first, o.reportedViewFrom = o.reportedViewTo = t.first, o.view = [], o.renderedView = null, o.externalMeasured = null, o.viewOffset = 0, o.lastWrapHeight = o.lastWrapWidth = 0, o.updateLineNumbers = null, o.nativeBarWidth = o.barHeight = o.barWidth = 0, o.scrollbarsClipped = !1, o.lineNumWidth = o.lineNumInnerWidth = o.lineNumChars = null, o.alignWidgets = !1, o.cachedCharWidth = o.cachedTextHeight = o.cachedPaddingH = null, o.maxLine = null, o.maxLineLength = 0, o.maxLineChanged = !1, o.wheelDX = o.wheelDY = o.wheelStartX = o.wheelStartY = null, o.shift = !1, o.selForContextMenu = null, o.activeTouch = null, o.gutterSpecs = fi(i.gutters, i.lineNumbers), pi(o), r.init(o) } oi.prototype.signal = function (e, t) { ve(e, t) && this.events.push(arguments) }, oi.prototype.finish = function () { for (var e = 0; e < this.events.length; e++) pe.apply(null, this.events[e]) }; var vi = 0, yi = null; function bi(e) { var t = e.wheelDeltaX, n = e.wheelDeltaY; return null == t && e.detail && e.axis == e.HORIZONTAL_AXIS && (t = e.detail), null == n && e.detail && e.axis == e.VERTICAL_AXIS ? n = e.detail : null == n && (n = e.wheelDelta), { x: t, y: n } } function Ci(e) { var t = bi(e); return t.x *= yi, t.y *= yi, t } function wi(e, t) { var r = bi(t), i = r.x, o = r.y, a = e.display, s = a.scroller, c = s.scrollWidth > s.clientWidth, u = s.scrollHeight > s.clientHeight; if (i && c || o && u) { if (o && y && l) e: for (var h = t.target, f = a.view; h != s; h = h.parentNode) for (var p = 0; p < f.length; p++) if (f[p].node == h) { e.display.currentWheelTarget = h; break e } if (i && !n && !d && null != yi) return o && u && Ir(e, Math.max(0, s.scrollTop + o * yi)), Pr(e, Math.max(0, s.scrollLeft + i * yi)), (!o || o && u) && be(t), void(a.wheelStartX = null); if (o && null != yi) { var g = o * yi, m = e.doc.scrollTop, v = m + a.wrapper.clientHeight; g < 0 ? m = Math.max(0, m + g - 50) : v = Math.min(e.doc.height, v + g + 50), li(e, { top: m, bottom: v }) } vi < 20 && (null == a.wheelStartX ? (a.wheelStartX = s.scrollLeft, a.wheelStartY = s.scrollTop, a.wheelDX = i, a.wheelDY = o, setTimeout((function () { if (null != a.wheelStartX) { var e = s.scrollLeft - a.wheelStartX, t = s.scrollTop - a.wheelStartY, n = t && a.wheelDY && t / a.wheelDY || e && a.wheelDX && e / a.wheelDX; a.wheelStartX = a.wheelStartY = null, n && (yi = (yi * vi + n) / (vi + 1), ++vi) } }), 200)) : (a.wheelDX += i, a.wheelDY += o)) } } a ? yi = -.53 : n ? yi = 15 : u ? yi = -.7 : h && (yi = -1 / 3); var _i = function (e, t) { this.ranges = e, this.primIndex = t }; _i.prototype.primary = function () { return this.ranges[this.primIndex] }, _i.prototype.equals = function (e) { if (e == this) return !0; if (e.primIndex != this.primIndex || e.ranges.length != this.ranges.length) return !1; for (var t = 0; t < this.ranges.length; t++) { var n = this.ranges[t], r = e.ranges[t]; if (!nt(n.anchor, r.anchor) || !nt(n.head, r.head)) return !1 } return !0 }, _i.prototype.deepCopy = function () { for (var e = [], t = 0; t < this.ranges.length; t++) e[t] = new Ti(rt(this.ranges[t].anchor), rt(this.ranges[t].head)); return new _i(e, this.primIndex) }, _i.prototype.somethingSelected = function () { for (var e = 0; e < this.ranges.length; e++) if (!this.ranges[e].empty()) return !0; return !1 }, _i.prototype.contains = function (e, t) { t || (t = e); for (var n = 0; n < this.ranges.length; n++) { var r = this.ranges[n]; if (tt(t, r.from()) >= 0 && tt(e, r.to()) <= 0) return n } return -1 }; var Ti = function (e, t) { this.anchor = e, this.head = t }; function Ei(e, t, n) { var r = e && e.options.selectionsMayTouch, i = t[n]; t.sort((function (e, t) { return tt(e.from(), t.from()) })), n = U(t, i); for (var o = 1; o < t.length; o++) { var a = t[o], s = t[o - 1], l = tt(s.to(), a.from()); if (r && !a.empty() ? l > 0 : l >= 0) { var c = ot(s.from(), a.from()), u = it(s.to(), a.to()), d = s.empty() ? a.from() == a.head : s.from() == s.head; o <= n && --n, t.splice(--o, 2, new Ti(d ? u : c, d ? c : u)) } } return new _i(t, n) } function xi(e, t) { return new _i([new Ti(e, t || e)], 0) } function Si(e) { return e.text ? et(e.from.line + e.text.length - 1, $(e.text).length + (1 == e.text.length ? e.from.ch : 0)) : e.to } function Ni(e, t) { if (tt(e, t.from) < 0) return e; if (tt(e, t.to) <= 0) return Si(t); var n = e.line + t.text.length - (t.to.line - t.from.line) - 1, r = e.ch; return e.line == t.to.line && (r += Si(t).ch - t.to.ch), et(n, r) } function ki(e, t) { for (var n = [], r = 0; r < e.sel.ranges.length; r++) { var i = e.sel.ranges[r]; n.push(new Ti(Ni(i.anchor, t), Ni(i.head, t))) } return Ei(e.cm, n, e.sel.primIndex) } function Li(e, t, n) { return e.line == t.line ? et(n.line, e.ch - t.ch + n.ch) : et(n.line + (e.line - t.line), e.ch) } function Mi(e) { e.doc.mode = Fe(e.options, e.doc.modeOption), Ai(e) } function Ai(e) { e.doc.iter((function (e) { e.stateAfter && (e.stateAfter = null), e.styles && (e.styles = null) })), e.doc.modeFrontier = e.doc.highlightFrontier = e.doc.first, ri(e, 100), e.state.modeGen++, e.curOp && dr(e) } function Bi(e, t) { return 0 == t.from.ch && 0 == t.to.ch && "" == $(t.text) && (!e.cm || e.cm.options.wholeLineUpdateBefore) } function Oi(e, t, n, r) { function i(e) { return n ? n[e] : null } function o(e, n, i) { ! function (e, t, n, r) { e.text = t, e.stateAfter && (e.stateAfter = null), e.styles && (e.styles = null), null != e.order && (e.order = null), kt(e), Lt(e, n); var i = r ? r(e) : 1; i != e.height && Ye(e, i) }(e, n, i, r), ln(e, "change", e, t) } function a(e, t) { for (var n = [], o = e; o < t; ++o) n.push(new Kt(c[o], i(o), r)); return n } var s = t.from, l = t.to, c = t.text, u = Ke(e, s.line), d = Ke(e, l.line), h = $(c), f = i(c.length - 1), p = l.line - s.line; if (t.full) e.insert(0, a(0, c.length)), e.remove(c.length, e.size - c.length); else if (Bi(e, t)) { var g = a(0, c.length - 1); o(d, d.text, f), p && e.remove(s.line, p), g.length && e.insert(s.line, g) } else if (u == d) if (1 == c.length) o(u, u.text.slice(0, s.ch) + h + u.text.slice(l.ch), f); else { var m = a(1, c.length - 1); m.push(new Kt(h + u.text.slice(l.ch), f, r)), o(u, u.text.slice(0, s.ch) + c[0], i(0)), e.insert(s.line + 1, m) } else if (1 == c.length) o(u, u.text.slice(0, s.ch) + c[0] + d.text.slice(l.ch), i(0)), e.remove(s.line + 1, p); else { o(u, u.text.slice(0, s.ch) + c[0], i(0)), o(d, h + d.text.slice(l.ch), f); var v = a(1, c.length - 1); p > 1 && e.remove(s.line + 1, p - 1), e.insert(s.line + 1, v) } ln(e, "change", e, t) } function Di(e, t, n) { ! function e(r, i, o) { if (r.linked) for (var a = 0; a < r.linked.length; ++a) { var s = r.linked[a]; if (s.doc != i) { var l = o && s.sharedHist; n && !l || (t(s.doc, l), e(s.doc, r, l)) } } }(e, null, !0) } function Ii(e, t) { if (t.cm) throw new Error("This document is already in use."); e.doc = t, t.cm = e, lr(e), Mi(e), Ri(e), e.options.lineWrapping || Vt(e), e.options.mode = t.modeOption, dr(e) } function Ri(e) { ("rtl" == e.doc.direction ? O : S)(e.display.lineDiv, "CodeMirror-rtl") } function Pi(e) { this.done = [], this.undone = [], this.undoDepth = 1 / 0, this.lastModTime = this.lastSelTime = 0, this.lastOp = this.lastSelOp = null, this.lastOrigin = this.lastSelOrigin = null, this.generation = this.maxGeneration = e || 1 } function Hi(e, t) { var n = { from: rt(t.from), to: Si(t), text: Ge(e, t.from, t.to) }; return zi(e, n, t.from.line, t.to.line + 1), Di(e, (function (e) { return zi(e, n, t.from.line, t.to.line + 1) }), !0), n } function Fi(e) { for (; e.length && $(e).ranges;) e.pop() } function Ui(e, t, n, r) { var i = e.history; i.undone.length = 0; var o, a, s = +new Date; if ((i.lastOp == r || i.lastOrigin == t.origin && t.origin && ("+" == t.origin.charAt(0) && i.lastModTime > s - (e.cm ? e.cm.options.historyEventDelay : 500) || "*" == t.origin.charAt(0))) && (o = function (e, t) { return t ? (Fi(e.done), $(e.done)) : e.done.length && !$(e.done).ranges ? $(e.done) : e.done.length > 1 && !e.done[e.done.length - 2].ranges ? (e.done.pop(), $(e.done)) : void 0 }(i, i.lastOp == r))) a = $(o.changes), 0 == tt(t.from, t.to) && 0 == tt(t.from, a.to) ? a.to = Si(t) : o.changes.push(Hi(e, t)); else { var l = $(i.done); for (l && l.ranges || qi(e.sel, i.done), o = { changes: [Hi(e, t)], generation: i.generation }, i.done.push(o); i.done.length > i.undoDepth;) i.done.shift(), i.done[0].ranges || i.done.shift() } i.done.push(n), i.generation = ++i.maxGeneration, i.lastModTime = i.lastSelTime = s, i.lastOp = i.lastSelOp = r, i.lastOrigin = i.lastSelOrigin = t.origin, a || pe(e, "historyAdded") } function Wi(e, t, n, r) { var i = e.history, o = r && r.origin; n == i.lastSelOp || o && i.lastSelOrigin == o && (i.lastModTime == i.lastSelTime && i.lastOrigin == o || function (e, t, n, r) { var i = t.charAt(0); return "*" == i || "+" == i && n.ranges.length == r.ranges.length && n.somethingSelected() == r.somethingSelected() && new Date - e.history.lastSelTime <= (e.cm ? e.cm.options.historyEventDelay : 500) }(e, o, $(i.done), t)) ? i.done[i.done.length - 1] = t : qi(t, i.done), i.lastSelTime = +new Date, i.lastSelOrigin = o, i.lastSelOp = n, r && !1 !== r.clearRedo && Fi(i.undone) } function qi(e, t) { var n = $(t); n && n.ranges && n.equals(e) || t.push(e) } function zi(e, t, n, r) { var i = t["spans_" + e.id], o = 0; e.iter(Math.max(e.first, n), Math.min(e.first + e.size, r), (function (n) { n.markedSpans && ((i || (i = t["spans_" + e.id] = {}))[o] = n.markedSpans), ++o })) } function ji(e) { if (!e) return null; for (var t, n = 0; n < e.length; ++n) e[n].marker.explicitlyCleared ? t || (t = e.slice(0, n)) : t && t.push(e[n]); return t ? t.length ? t : null : e } function Vi(e, t) { var n = function (e, t) { var n = t["spans_" + e.id]; if (!n) return null; for (var r = [], i = 0; i < t.text.length; ++i) r.push(ji(n[i])); return r }(e, t), r = St(e, t); if (!n) return r; if (!r) return n; for (var i = 0; i < n.length; ++i) { var o = n[i], a = r[i]; if (o && a) e: for (var s = 0; s < a.length; ++s) { for (var l = a[s], c = 0; c < o.length; ++c) if (o[c].marker == l.marker) continue e; o.push(l) } else a && (n[i] = a) } return n } function Ki(e, t, n) { for (var r = [], i = 0; i < e.length; ++i) { var o = e[i]; if (o.ranges) r.push(n ? _i.prototype.deepCopy.call(o) : o); else { var a = o.changes, s = []; r.push({ changes: s }); for (var l = 0; l < a.length; ++l) { var c = a[l], u = void 0; if (s.push({ from: c.from, to: c.to, text: c.text }), t) for (var d in c)(u = d.match(/^spans_(\d+)$/)) && U(t, Number(u[1])) > -1 && ($(s)[d] = c[d], delete c[d]) } } } return r } function Gi(e, t, n, r) { if (r) { var i = e.anchor; if (n) { var o = tt(t, i) < 0; o != tt(n, i) < 0 ? (i = t, t = n) : o != tt(t, n) < 0 && (t = n) } return new Ti(i, t) } return new Ti(n || t, t) } function $i(e, t, n, r, i) { null == i && (i = e.cm && (e.cm.display.shift || e.extend)), Ji(e, new _i([Gi(e.sel.primary(), t, n, i)], 0), r) } function Yi(e, t, n) { for (var r = [], i = e.cm && (e.cm.display.shift || e.extend), o = 0; o < e.sel.ranges.length; o++) r[o] = Gi(e.sel.ranges[o], t[o], null, i); Ji(e, Ei(e.cm, r, e.sel.primIndex), n) } function Xi(e, t, n, r) { var i = e.sel.ranges.slice(0); i[t] = n, Ji(e, Ei(e.cm, i, e.sel.primIndex), r) } function Zi(e, t, n, r) { Ji(e, xi(t, n), r) } function Qi(e, t, n) { var r = e.history.done, i = $(r); i && i.ranges ? (r[r.length - 1] = t, eo(e, t, n)) : Ji(e, t, n) } function Ji(e, t, n) { eo(e, t, n), Wi(e, e.sel, e.cm ? e.cm.curOp.id : NaN, n) } function eo(e, t, n) { (ve(e, "beforeSelectionChange") || e.cm && ve(e.cm, "beforeSelectionChange")) && (t = function (e, t, n) { var r = { ranges: t.ranges, update: function (t) { this.ranges = []; for (var n = 0; n < t.length; n++) this.ranges[n] = new Ti(st(e, t[n].anchor), st(e, t[n].head)) }, origin: n && n.origin }; return pe(e, "beforeSelectionChange", e, r), e.cm && pe(e.cm, "beforeSelectionChange", e.cm, r), r.ranges != t.ranges ? Ei(e.cm, r.ranges, r.ranges.length - 1) : t }(e, t, n)); var r = n && n.bias || (tt(t.primary().head, e.sel.primary().head) < 0 ? -1 : 1); to(e, ro(e, t, r, !0)), n && !1 === n.scroll || !e.cm || Ar(e.cm) } function to(e, t) { t.equals(e.sel) || (e.sel = t, e.cm && (e.cm.curOp.updateInput = 1, e.cm.curOp.selectionChanged = !0, me(e.cm)), ln(e, "cursorActivity", e)) } function no(e) { to(e, ro(e, e.sel, null, !1)) } function ro(e, t, n, r) { for (var i, o = 0; o < t.ranges.length; o++) { var a = t.ranges[o], s = t.ranges.length == e.sel.ranges.length && e.sel.ranges[o], l = oo(e, a.anchor, s && s.anchor, n, r), c = oo(e, a.head, s && s.head, n, r); (i || l != a.anchor || c != a.head) && (i || (i = t.ranges.slice(0, o)), i[o] = new Ti(l, c)) } return i ? Ei(e.cm, i, t.primIndex) : t } function io(e, t, n, r, i) { var o = Ke(e, t.line); if (o.markedSpans) for (var a = 0; a < o.markedSpans.length; ++a) { var s = o.markedSpans[a], l = s.marker, c = "selectLeft" in l ? !l.selectLeft : l.inclusiveLeft, u = "selectRight" in l ? !l.selectRight : l.inclusiveRight; if ((null == s.from || (c ? s.from <= t.ch : s.from < t.ch)) && (null == s.to || (u ? s.to >= t.ch : s.to > t.ch))) { if (i && (pe(l, "beforeCursorEnter"), l.explicitlyCleared)) { if (o.markedSpans) { --a; continue } break } if (!l.atomic) continue; if (n) { var d = l.find(r < 0 ? 1 : -1), h = void 0; if ((r < 0 ? u : c) && (d = ao(e, d, -r, d && d.line == t.line ? o : null)), d && d.line == t.line && (h = tt(d, n)) && (r < 0 ? h < 0 : h > 0)) return io(e, d, t, r, i) } var f = l.find(r < 0 ? -1 : 1); return (r < 0 ? c : u) && (f = ao(e, f, r, f.line == t.line ? o : null)), f ? io(e, f, t, r, i) : null } } return t } function oo(e, t, n, r, i) { var o = r || 1, a = io(e, t, n, o, i) || !i && io(e, t, n, o, !0) || io(e, t, n, -o, i) || !i && io(e, t, n, -o, !0); return a || (e.cantEdit = !0, et(e.first, 0)) } function ao(e, t, n, r) { return n < 0 && 0 == t.ch ? t.line > e.first ? st(e, et(t.line - 1)) : null : n > 0 && t.ch == (r || Ke(e, t.line)).text.length ? t.line < e.first + e.size - 1 ? et(t.line + 1, 0) : null : new et(t.line, t.ch + n) } function so(e) { e.setSelection(et(e.firstLine(), 0), et(e.lastLine()), q) } function lo(e, t, n) { var r = { canceled: !1, from: t.from, to: t.to, text: t.text, origin: t.origin, cancel: function () { return r.canceled = !0 } }; return n && (r.update = function (t, n, i, o) { t && (r.from = st(e, t)), n && (r.to = st(e, n)), i && (r.text = i), void 0 !== o && (r.origin = o) }), pe(e, "beforeChange", e, r), e.cm && pe(e.cm, "beforeChange", e.cm, r), r.canceled ? (e.cm && (e.cm.curOp.updateInput = 2), null) : { from: r.from, to: r.to, text: r.text, origin: r.origin } } function co(e, t, n) { if (e.cm) { if (!e.cm.curOp) return ei(e.cm, co)(e, t, n); if (e.cm.state.suppressEdits) return } if (!(ve(e, "beforeChange") || e.cm && ve(e.cm, "beforeChange")) || (t = lo(e, t, !0))) { var r = wt && !n && function (e, t, n) { var r = null; if (e.iter(t.line, n.line + 1, (function (e) { if (e.markedSpans) for (var t = 0; t < e.markedSpans.length; ++t) { var n = e.markedSpans[t].marker; !n.readOnly || r && -1 != U(r, n) || (r || (r = [])).push(n) } })), !r) return null; for (var i = [{ from: t, to: n }], o = 0; o < r.length; ++o) for (var a = r[o], s = a.find(0), l = 0; l < i.length; ++l) { var c = i[l]; if (!(tt(c.to, s.from) < 0 || tt(c.from, s.to) > 0)) { var u = [l, 1], d = tt(c.from, s.from), h = tt(c.to, s.to); (d < 0 || !a.inclusiveLeft && !d) && u.push({ from: c.from, to: s.from }), (h > 0 || !a.inclusiveRight && !h) && u.push({ from: s.to, to: c.to }), i.splice.apply(i, u), l += u.length - 3 } } return i }(e, t.from, t.to); if (r) for (var i = r.length - 1; i >= 0; --i) uo(e, { from: r[i].from, to: r[i].to, text: i ? [""] : t.text, origin: t.origin }); else uo(e, t) } } function uo(e, t) { if (1 != t.text.length || "" != t.text[0] || 0 != tt(t.from, t.to)) { var n = ki(e, t); Ui(e, t, n, e.cm ? e.cm.curOp.id : NaN), po(e, t, n, St(e, t)); var r = []; Di(e, (function (e, n) { n || -1 != U(r, e.history) || (yo(e.history, t), r.push(e.history)), po(e, t, null, St(e, t)) })) } } function ho(e, t, n) { var r = e.cm && e.cm.state.suppressEdits; if (!r || n) { for (var i, o = e.history, a = e.sel, s = "undo" == t ? o.done : o.undone, l = "undo" == t ? o.undone : o.done, c = 0; c < s.length && (i = s[c], n ? !i.ranges || i.equals(e.sel) : i.ranges); c++); if (c != s.length) { for (o.lastOrigin = o.lastSelOrigin = null;;) { if (!(i = s.pop()).ranges) { if (r) return void s.push(i); break } if (qi(i, l), n && !i.equals(e.sel)) return void Ji(e, i, { clearRedo: !1 }); a = i } var u = []; qi(a, l), l.push({ changes: u, generation: o.generation }), o.generation = i.generation || ++o.maxGeneration; for (var d = ve(e, "beforeChange") || e.cm && ve(e.cm, "beforeChange"), h = function (n) { var r = i.changes[n]; if (r.origin = t, d && !lo(e, r, !1)) return s.length = 0, {}; u.push(Hi(e, r)); var o = n ? ki(e, r) : $(s); po(e, r, o, Vi(e, r)), !n && e.cm && e.cm.scrollIntoView({ from: r.from, to: Si(r) }); var a = []; Di(e, (function (e, t) { t || -1 != U(a, e.history) || (yo(e.history, r), a.push(e.history)), po(e, r, null, Vi(e, r)) })) }, f = i.changes.length - 1; f >= 0; --f) { var p = h(f); if (p) return p.v } } } } function fo(e, t) { if (0 != t && (e.first += t, e.sel = new _i(Y(e.sel.ranges, (function (e) { return new Ti(et(e.anchor.line + t, e.anchor.ch), et(e.head.line + t, e.head.ch)) })), e.sel.primIndex), e.cm)) { dr(e.cm, e.first, e.first - t, t); for (var n = e.cm.display, r = n.viewFrom; r < n.viewTo; r++) hr(e.cm, r, "gutter") } } function po(e, t, n, r) { if (e.cm && !e.cm.curOp) return ei(e.cm, po)(e, t, n, r); if (t.to.line < e.first) fo(e, t.text.length - 1 - (t.to.line - t.from.line)); else if (!(t.from.line > e.lastLine())) { if (t.from.line < e.first) { var i = t.text.length - 1 - (e.first - t.from.line); fo(e, i), t = { from: et(e.first, 0), to: et(t.to.line + i, t.to.ch), text: [$(t.text)], origin: t.origin } } var o = e.lastLine(); t.to.line > o && (t = { from: t.from, to: et(o, Ke(e, o).text.length), text: [t.text[0]], origin: t.origin }), t.removed = Ge(e, t.from, t.to), n || (n = ki(e, t)), e.cm ? function (e, t, n) { var r = e.doc, i = e.display, o = t.from, a = t.to, s = !1, l = o.line; e.options.lineWrapping || (l = Xe(Ht(Ke(r, o.line))), r.iter(l, a.line + 1, (function (e) { if (e == i.maxLine) return s = !0, !0 }))), r.sel.contains(t.from, t.to) > -1 && me(e), Oi(r, t, n, sr(e)), e.options.lineWrapping || (r.iter(l, o.line + t.text.length, (function (e) { var t = jt(e); t > i.maxLineLength && (i.maxLine = e, i.maxLineLength = t, i.maxLineChanged = !0, s = !1) })), s && (e.curOp.updateMaxLine = !0)), function (e, t) { if (e.modeFrontier = Math.min(e.modeFrontier, t), !(e.highlightFrontier < t - 10)) { for (var n = e.first, r = t - 1; r > n; r--) { var i = Ke(e, r).stateAfter; if (i && (!(i instanceof ct) || r + i.lookAhead < t)) { n = r + 1; break } } e.highlightFrontier = Math.min(e.highlightFrontier, n) } }(r, o.line), ri(e, 400); var c = t.text.length - (a.line - o.line) - 1; t.full ? dr(e) : o.line != a.line || 1 != t.text.length || Bi(e.doc, t) ? dr(e, o.line, a.line + 1, c) : hr(e, o.line, "text"); var u = ve(e, "changes"), d = ve(e, "change"); if (d || u) { var h = { from: o, to: a, text: t.text, removed: t.removed, origin: t.origin }; d && ln(e, "change", e, h), u && (e.curOp.changeObjs || (e.curOp.changeObjs = [])).push(h) } e.display.selForContextMenu = null }(e.cm, t, r) : Oi(e, t, r), eo(e, n, q), e.cantEdit && oo(e, et(e.firstLine(), 0)) && (e.cantEdit = !1) } } function go(e, t, n, r, i) { var o; r || (r = n), tt(r, n) < 0 && (n = (o = [r, n])[0], r = o[1]), "string" == typeof t && (t = e.splitLines(t)), co(e, { from: n, to: r, text: t, origin: i }) } function mo(e, t, n, r) { n < e.line ? e.line += r : t < e.line && (e.line = t, e.ch = 0) } function vo(e, t, n, r) { for (var i = 0; i < e.length; ++i) { var o = e[i], a = !0; if (o.ranges) { o.copied || ((o = e[i] = o.deepCopy()).copied = !0); for (var s = 0; s < o.ranges.length; s++) mo(o.ranges[s].anchor, t, n, r), mo(o.ranges[s].head, t, n, r) } else { for (var l = 0; l < o.changes.length; ++l) { var c = o.changes[l]; if (n < c.from.line) c.from = et(c.from.line + r, c.from.ch), c.to = et(c.to.line + r, c.to.ch); else if (t <= c.to.line) { a = !1; break } } a || (e.splice(0, i + 1), i = 0) } } } function yo(e, t) { var n = t.from.line, r = t.to.line, i = t.text.length - (r - n) - 1; vo(e.done, n, r, i), vo(e.undone, n, r, i) } function bo(e, t, n, r) { var i = t, o = t; return "number" == typeof t ? o = Ke(e, at(e, t)) : i = Xe(t), null == i ? null : (r(o, i) && e.cm && hr(e.cm, i, n), o) } function Co(e) { this.lines = e, this.parent = null; for (var t = 0, n = 0; n < e.length; ++n) e[n].parent = this, t += e[n].height; this.height = t } function wo(e) { this.children = e; for (var t = 0, n = 0, r = 0; r < e.length; ++r) { var i = e[r]; t += i.chunkSize(), n += i.height, i.parent = this } this.size = t, this.height = n, this.parent = null } Ti.prototype.from = function () { return ot(this.anchor, this.head) }, Ti.prototype.to = function () { return it(this.anchor, this.head) }, Ti.prototype.empty = function () { return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch }, Co.prototype = { chunkSize: function () { return this.lines.length }, removeInner: function (e, t) { for (var n = e, r = e + t; n < r; ++n) { var i = this.lines[n]; this.height -= i.height, Gt(i), ln(i, "delete") } this.lines.splice(e, t) }, collapse: function (e) { e.push.apply(e, this.lines) }, insertInner: function (e, t, n) { this.height += n, this.lines = this.lines.slice(0, e).concat(t).concat(this.lines.slice(e)); for (var r = 0; r < t.length; ++r) t[r].parent = this }, iterN: function (e, t, n) { for (var r = e + t; e < r; ++e) if (n(this.lines[e])) return !0 } }, wo.prototype = { chunkSize: function () { return this.size }, removeInner: function (e, t) { this.size -= t; for (var n = 0; n < this.children.length; ++n) { var r = this.children[n], i = r.chunkSize(); if (e < i) { var o = Math.min(t, i - e), a = r.height; if (r.removeInner(e, o), this.height -= a - r.height, i == o && (this.children.splice(n--, 1), r.parent = null), 0 == (t -= o)) break; e = 0 } else e -= i } if (this.size - t < 25 && (this.children.length > 1 || !(this.children[0] instanceof Co))) { var s = []; this.collapse(s), this.children = [new Co(s)], this.children[0].parent = this } }, collapse: function (e) { for (var t = 0; t < this.children.length; ++t) this.children[t].collapse(e) }, insertInner: function (e, t, n) { this.size += t.length, this.height += n; for (var r = 0; r < this.children.length; ++r) { var i = this.children[r], o = i.chunkSize(); if (e <= o) { if (i.insertInner(e, t, n), i.lines && i.lines.length > 50) { for (var a = i.lines.length % 25 + 25, s = a; s < i.lines.length;) { var l = new Co(i.lines.slice(s, s += 25)); i.height -= l.height, this.children.splice(++r, 0, l), l.parent = this } i.lines = i.lines.slice(0, a), this.maybeSpill() } break } e -= o } }, maybeSpill: function () { if (!(this.children.length <= 10)) { var e = this; do { var t = new wo(e.children.splice(e.children.length - 5, 5)); if (e.parent) { e.size -= t.size, e.height -= t.height; var n = U(e.parent.children, e); e.parent.children.splice(n + 1, 0, t) } else { var r = new wo(e.children); r.parent = e, e.children = [r, t], e = r } t.parent = e.parent } while (e.children.length > 10); e.parent.maybeSpill() } }, iterN: function (e, t, n) { for (var r = 0; r < this.children.length; ++r) { var i = this.children[r], o = i.chunkSize(); if (e < o) { var a = Math.min(t, o - e); if (i.iterN(e, a, n)) return !0; if (0 == (t -= a)) break; e = 0 } else e -= o } } }; var _o = function (e, t, n) { if (n) for (var r in n) n.hasOwnProperty(r) && (this[r] = n[r]); this.doc = e, this.node = t }; function To(e, t, n) { zt(t) < (e.curOp && e.curOp.scrollTop || e.doc.scrollTop) && Mr(e, n) } _o.prototype.clear = function () { var e = this.doc.cm, t = this.line.widgets, n = this.line, r = Xe(n); if (null != r && t) { for (var i = 0; i < t.length; ++i) t[i] == this && t.splice(i--, 1); t.length || (n.widgets = null); var o = wn(this); Ye(n, Math.max(0, n.height - o)), e && (Jr(e, (function () { To(e, n, -o), hr(e, r, "widget") })), ln(e, "lineWidgetCleared", e, this, r)) } }, _o.prototype.changed = function () { var e = this, t = this.height, n = this.doc.cm, r = this.line; this.height = null; var i = wn(this) - t; i && (Wt(this.doc, r) || Ye(r, r.height + i), n && Jr(n, (function () { n.curOp.forceUpdate = !0, To(n, r, i), ln(n, "lineWidgetChanged", n, e, Xe(r)) }))) }, ye(_o); var Eo = 0, xo = function (e, t) { this.lines = [], this.type = t, this.doc = e, this.id = ++Eo }; function So(e, t, n, r, i) { if (r && r.shared) return function (e, t, n, r, i) { (r = P(r)).shared = !1; var o = [So(e, t, n, r, i)], a = o[0], s = r.widgetNode; return Di(e, (function (e) { s && (r.widgetNode = s.cloneNode(!0)), o.push(So(e, st(e, t), st(e, n), r, i)); for (var l = 0; l < e.linked.length; ++l) if (e.linked[l].isParent) return; a = $(o) })), new No(o, a) }(e, t, n, r, i); if (e.cm && !e.cm.curOp) return ei(e.cm, So)(e, t, n, r, i); var o = new xo(e, i), a = tt(t, n); if (r && P(r, o, !1), a > 0 || 0 == a && !1 !== o.clearWhenEmpty) return o; if (o.replacedWith && (o.collapsed = !0, o.widgetNode = M("span", [o.replacedWith], "CodeMirror-widget"), r.handleMouseEvents || o.widgetNode.setAttribute("cm-ignore-events", "true"), r.insertLeft && (o.widgetNode.insertLeft = !0)), o.collapsed) { if (Pt(e, t.line, t, n, o) || t.line != n.line && Pt(e, n.line, t, n, o)) throw new Error("Inserting collapsed marker partially overlapping an existing one"); _t = !0 } o.addToHistory && Ui(e, { from: t, to: n, origin: "markText" }, e.sel, NaN); var s, l = t.line, c = e.cm; if (e.iter(l, n.line + 1, (function (e) { c && o.collapsed && !c.options.lineWrapping && Ht(e) == c.display.maxLine && (s = !0), o.collapsed && l != t.line && Ye(e, 0), function (e, t) { e.markedSpans = e.markedSpans ? e.markedSpans.concat([t]) : [t], t.marker.attachLine(e) }(e, new Tt(o, l == t.line ? t.ch : null, l == n.line ? n.ch : null)), ++l })), o.collapsed && e.iter(t.line, n.line + 1, (function (t) { Wt(e, t) && Ye(t, 0) })), o.clearOnEnter && de(o, "beforeCursorEnter", (function () { return o.clear() })), o.readOnly && (wt = !0, (e.history.done.length || e.history.undone.length) && e.clearHistory()), o.collapsed && (o.id = ++Eo, o.atomic = !0), c) { if (s && (c.curOp.updateMaxLine = !0), o.collapsed) dr(c, t.line, n.line + 1); else if (o.className || o.startStyle || o.endStyle || o.css || o.attributes || o.title) for (var u = t.line; u <= n.line; u++) hr(c, u, "text"); o.atomic && no(c.doc), ln(c, "markerAdded", c, o) } return o } xo.prototype.clear = function () { if (!this.explicitlyCleared) { var e = this.doc.cm, t = e && !e.curOp; if (t && Kr(e), ve(this, "clear")) { var n = this.find(); n && ln(this, "clear", n.from, n.to) } for (var r = null, i = null, o = 0; o < this.lines.length; ++o) { var a = this.lines[o], s = Et(a.markedSpans, this); e && !this.collapsed ? hr(e, Xe(a), "text") : e && (null != s.to && (i = Xe(a)), null != s.from && (r = Xe(a))), a.markedSpans = xt(a.markedSpans, s), null == s.from && this.collapsed && !Wt(this.doc, a) && e && Ye(a, rr(e.display)) } if (e && this.collapsed && !e.options.lineWrapping) for (var l = 0; l < this.lines.length; ++l) { var c = Ht(this.lines[l]), u = jt(c); u > e.display.maxLineLength && (e.display.maxLine = c, e.display.maxLineLength = u, e.display.maxLineChanged = !0) } null != r && e && this.collapsed && dr(e, r, i + 1), this.lines.length = 0, this.explicitlyCleared = !0, this.atomic && this.doc.cantEdit && (this.doc.cantEdit = !1, e && no(e.doc)), e && ln(e, "markerCleared", e, this, r, i), t && Gr(e), this.parent && this.parent.clear() } }, xo.prototype.find = function (e, t) { var n, r; null == e && "bookmark" == this.type && (e = 1); for (var i = 0; i < this.lines.length; ++i) { var o = this.lines[i], a = Et(o.markedSpans, this); if (null != a.from && (n = et(t ? o : Xe(o), a.from), -1 == e)) return n; if (null != a.to && (r = et(t ? o : Xe(o), a.to), 1 == e)) return r } return n && { from: n, to: r } }, xo.prototype.changed = function () { var e = this, t = this.find(-1, !0), n = this, r = this.doc.cm; t && r && Jr(r, (function () { var i = t.line, o = Xe(t.line), a = An(r, o); if (a && (Hn(a), r.curOp.selectionChanged = r.curOp.forceUpdate = !0), r.curOp.updateMaxLine = !0, !Wt(n.doc, i) && null != n.height) { var s = n.height; n.height = null; var l = wn(n) - s; l && Ye(i, i.height + l) } ln(r, "markerChanged", r, e) })) }, xo.prototype.attachLine = function (e) { if (!this.lines.length && this.doc.cm) { var t = this.doc.cm.curOp; t.maybeHiddenMarkers && -1 != U(t.maybeHiddenMarkers, this) || (t.maybeUnhiddenMarkers || (t.maybeUnhiddenMarkers = [])).push(this) } this.lines.push(e) }, xo.prototype.detachLine = function (e) { if (this.lines.splice(U(this.lines, e), 1), !this.lines.length && this.doc.cm) { var t = this.doc.cm.curOp; (t.maybeHiddenMarkers || (t.maybeHiddenMarkers = [])).push(this) } }, ye(xo); var No = function (e, t) { this.markers = e, this.primary = t; for (var n = 0; n < e.length; ++n) e[n].parent = this }; function ko(e) { return e.findMarks(et(e.first, 0), e.clipPos(et(e.lastLine())), (function (e) { return e.parent })) } function Lo(e) { for (var t = function (t) { var n = e[t], r = [n.primary.doc]; Di(n.primary.doc, (function (e) { return r.push(e) })); for (var i = 0; i < n.markers.length; i++) { var o = n.markers[i]; - 1 == U(r, o.doc) && (o.parent = null, n.markers.splice(i--, 1)) } }, n = 0; n < e.length; n++) t(n) } No.prototype.clear = function () { if (!this.explicitlyCleared) { this.explicitlyCleared = !0; for (var e = 0; e < this.markers.length; ++e) this.markers[e].clear(); ln(this, "clear") } }, No.prototype.find = function (e, t) { return this.primary.find(e, t) }, ye(No); var Mo = 0, Ao = function (e, t, n, r, i) { if (!(this instanceof Ao)) return new Ao(e, t, n, r, i); null == n && (n = 0), wo.call(this, [new Co([new Kt("", null)])]), this.first = n, this.scrollTop = this.scrollLeft = 0, this.cantEdit = !1, this.cleanGeneration = 1, this.modeFrontier = this.highlightFrontier = n; var o = et(n, 0); this.sel = xi(o), this.history = new Pi(null), this.id = ++Mo, this.modeOption = t, this.lineSep = r, this.direction = "rtl" == i ? "rtl" : "ltr", this.extend = !1, "string" == typeof e && (e = this.splitLines(e)), Oi(this, { from: o, to: o, text: e }), Ji(this, xi(o), q) }; Ao.prototype = Z(wo.prototype, { constructor: Ao, iter: function (e, t, n) { n ? this.iterN(e - this.first, t - e, n) : this.iterN(this.first, this.first + this.size, e) }, insert: function (e, t) { for (var n = 0, r = 0; r < t.length; ++r) n += t[r].height; this.insertInner(e - this.first, t, n) }, remove: function (e, t) { this.removeInner(e - this.first, t) }, getValue: function (e) { var t = $e(this, this.first, this.first + this.size); return !1 === e ? t : t.join(e || this.lineSeparator()) }, setValue: ni((function (e) { var t = et(this.first, 0), n = this.first + this.size - 1; co(this, { from: t, to: et(n, Ke(this, n).text.length), text: this.splitLines(e), origin: "setValue", full: !0 }, !0), this.cm && Br(this.cm, 0, 0), Ji(this, xi(t), q) })), replaceRange: function (e, t, n, r) { go(this, e, t = st(this, t), n = n ? st(this, n) : t, r) }, getRange: function (e, t, n) { var r = Ge(this, st(this, e), st(this, t)); return !1 === n ? r : r.join(n || this.lineSeparator()) }, getLine: function (e) { var t = this.getLineHandle(e); return t && t.text }, getLineHandle: function (e) { if (Qe(this, e)) return Ke(this, e) }, getLineNumber: function (e) { return Xe(e) }, getLineHandleVisualStart: function (e) { return "number" == typeof e && (e = Ke(this, e)), Ht(e) }, lineCount: function () { return this.size }, firstLine: function () { return this.first }, lastLine: function () { return this.first + this.size - 1 }, clipPos: function (e) { return st(this, e) }, getCursor: function (e) { var t = this.sel.primary(); return null == e || "head" == e ? t.head : "anchor" == e ? t.anchor : "end" == e || "to" == e || !1 === e ? t.to() : t.from() }, listSelections: function () { return this.sel.ranges }, somethingSelected: function () { return this.sel.somethingSelected() }, setCursor: ni((function (e, t, n) { Zi(this, st(this, "number" == typeof e ? et(e, t || 0) : e), null, n) })), setSelection: ni((function (e, t, n) { Zi(this, st(this, e), st(this, t || e), n) })), extendSelection: ni((function (e, t, n) { $i(this, st(this, e), t && st(this, t), n) })), extendSelections: ni((function (e, t) { Yi(this, lt(this, e), t) })), extendSelectionsBy: ni((function (e, t) { Yi(this, lt(this, Y(this.sel.ranges, e)), t) })), setSelections: ni((function (e, t, n) { if (e.length) { for (var r = [], i = 0; i < e.length; i++) r[i] = new Ti(st(this, e[i].anchor), st(this, e[i].head)); null == t && (t = Math.min(e.length - 1, this.sel.primIndex)), Ji(this, Ei(this.cm, r, t), n) } })), addSelection: ni((function (e, t, n) { var r = this.sel.ranges.slice(0); r.push(new Ti(st(this, e), st(this, t || e))), Ji(this, Ei(this.cm, r, r.length - 1), n) })), getSelection: function (e) { for (var t, n = this.sel.ranges, r = 0; r < n.length; r++) { var i = Ge(this, n[r].from(), n[r].to()); t = t ? t.concat(i) : i } return !1 === e ? t : t.join(e || this.lineSeparator()) }, getSelections: function (e) { for (var t = [], n = this.sel.ranges, r = 0; r < n.length; r++) { var i = Ge(this, n[r].from(), n[r].to()); !1 !== e && (i = i.join(e || this.lineSeparator())), t[r] = i } return t }, replaceSelection: function (e, t, n) { for (var r = [], i = 0; i < this.sel.ranges.length; i++) r[i] = e; this.replaceSelections(r, t, n || "+input") }, replaceSelections: ni((function (e, t, n) { for (var r = [], i = this.sel, o = 0; o < i.ranges.length; o++) { var a = i.ranges[o]; r[o] = { from: a.from(), to: a.to(), text: this.splitLines(e[o]), origin: n } } for (var s = t && "end" != t && function (e, t, n) { for (var r = [], i = et(e.first, 0), o = i, a = 0; a < t.length; a++) { var s = t[a], l = Li(s.from, i, o), c = Li(Si(s), i, o); if (i = s.to, o = c, "around" == n) { var u = e.sel.ranges[a], d = tt(u.head, u.anchor) < 0; r[a] = new Ti(d ? c : l, d ? l : c) } else r[a] = new Ti(l, l) } return new _i(r, e.sel.primIndex) }(this, r, t), l = r.length - 1; l >= 0; l--) co(this, r[l]); s ? Qi(this, s) : this.cm && Ar(this.cm) })), undo: ni((function () { ho(this, "undo") })), redo: ni((function () { ho(this, "redo") })), undoSelection: ni((function () { ho(this, "undo", !0) })), redoSelection: ni((function () { ho(this, "redo", !0) })), setExtending: function (e) { this.extend = e }, getExtending: function () { return this.extend }, historySize: function () { for (var e = this.history, t = 0, n = 0, r = 0; r < e.done.length; r++) e.done[r].ranges || ++t; for (var i = 0; i < e.undone.length; i++) e.undone[i].ranges || ++n; return { undo: t, redo: n } }, clearHistory: function () { var e = this; this.history = new Pi(this.history.maxGeneration), Di(this, (function (t) { return t.history = e.history }), !0) }, markClean: function () { this.cleanGeneration = this.changeGeneration(!0) }, changeGeneration: function (e) { return e && (this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null), this.history.generation }, isClean: function (e) { return this.history.generation == (e || this.cleanGeneration) }, getHistory: function () { return { done: Ki(this.history.done), undone: Ki(this.history.undone) } }, setHistory: function (e) { var t = this.history = new Pi(this.history.maxGeneration); t.done = Ki(e.done.slice(0), null, !0), t.undone = Ki(e.undone.slice(0), null, !0) }, setGutterMarker: ni((function (e, t, n) { return bo(this, e, "gutter", (function (e) { var r = e.gutterMarkers || (e.gutterMarkers = {}); return r[t] = n, !n && te(r) && (e.gutterMarkers = null), !0 })) })), clearGutter: ni((function (e) { var t = this; this.iter((function (n) { n.gutterMarkers && n.gutterMarkers[e] && bo(t, n, "gutter", (function () { return n.gutterMarkers[e] = null, te(n.gutterMarkers) && (n.gutterMarkers = null), !0 })) })) })), lineInfo: function (e) { var t; if ("number" == typeof e) { if (!Qe(this, e)) return null; if (t = e, !(e = Ke(this, e))) return null } else if (null == (t = Xe(e))) return null; return { line: t, handle: e, text: e.text, gutterMarkers: e.gutterMarkers, textClass: e.textClass, bgClass: e.bgClass, wrapClass: e.wrapClass, widgets: e.widgets } }, addLineClass: ni((function (e, t, n) { return bo(this, e, "gutter" == t ? "gutter" : "class", (function (e) { var r = "text" == t ? "textClass" : "background" == t ? "bgClass" : "gutter" == t ? "gutterClass" : "wrapClass"; if (e[r]) { if (E(n).test(e[r])) return !1; e[r] += " " + n } else e[r] = n; return !0 })) })), removeLineClass: ni((function (e, t, n) { return bo(this, e, "gutter" == t ? "gutter" : "class", (function (e) { var r = "text" == t ? "textClass" : "background" == t ? "bgClass" : "gutter" == t ? "gutterClass" : "wrapClass", i = e[r]; if (!i) return !1; if (null == n) e[r] = null; else { var o = i.match(E(n)); if (!o) return !1; var a = o.index + o[0].length; e[r] = i.slice(0, o.index) + (o.index && a != i.length ? " " : "") + i.slice(a) || null } return !0 })) })), addLineWidget: ni((function (e, t, n) { return function (e, t, n, r) { var i = new _o(e, n, r), o = e.cm; return o && i.noHScroll && (o.display.alignWidgets = !0), bo(e, t, "widget", (function (t) { var n = t.widgets || (t.widgets = []); if (null == i.insertAt ? n.push(i) : n.splice(Math.min(n.length, Math.max(0, i.insertAt)), 0, i), i.line = t, o && !Wt(e, t)) { var r = zt(t) < e.scrollTop; Ye(t, t.height + wn(i)), r && Mr(o, i.height), o.curOp.forceUpdate = !0 } return !0 })), o && ln(o, "lineWidgetAdded", o, i, "number" == typeof t ? t : Xe(t)), i }(this, e, t, n) })), removeLineWidget: function (e) { e.clear() }, markText: function (e, t, n) { return So(this, st(this, e), st(this, t), n, n && n.type || "range") }, setBookmark: function (e, t) { var n = { replacedWith: t && (null == t.nodeType ? t.widget : t), insertLeft: t && t.insertLeft, clearWhenEmpty: !1, shared: t && t.shared, handleMouseEvents: t && t.handleMouseEvents }; return So(this, e = st(this, e), e, n, "bookmark") }, findMarksAt: function (e) { var t = [], n = Ke(this, (e = st(this, e)).line).markedSpans; if (n) for (var r = 0; r < n.length; ++r) { var i = n[r]; (null == i.from || i.from <= e.ch) && (null == i.to || i.to >= e.ch) && t.push(i.marker.parent || i.marker) } return t }, findMarks: function (e, t, n) { e = st(this, e), t = st(this, t); var r = [], i = e.line; return this.iter(e.line, t.line + 1, (function (o) { var a = o.markedSpans; if (a) for (var s = 0; s < a.length; s++) { var l = a[s]; null != l.to && i == e.line && e.ch >= l.to || null == l.from && i != e.line || null != l.from && i == t.line && l.from >= t.ch || n && !n(l.marker) || r.push(l.marker.parent || l.marker) }++i })), r }, getAllMarks: function () { var e = []; return this.iter((function (t) { var n = t.markedSpans; if (n) for (var r = 0; r < n.length; ++r) null != n[r].from && e.push(n[r].marker) })), e }, posFromIndex: function (e) { var t, n = this.first, r = this.lineSeparator().length; return this.iter((function (i) { var o = i.text.length + r; if (o > e) return t = e, !0; e -= o, ++n })), st(this, et(n, t)) }, indexFromPos: function (e) { var t = (e = st(this, e)).ch; if (e.line < this.first || e.ch < 0) return 0; var n = this.lineSeparator().length; return this.iter(this.first, e.line, (function (e) { t += e.text.length + n })), t }, copy: function (e) { var t = new Ao($e(this, this.first, this.first + this.size), this.modeOption, this.first, this.lineSep, this.direction); return t.scrollTop = this.scrollTop, t.scrollLeft = this.scrollLeft, t.sel = this.sel, t.extend = !1, e && (t.history.undoDepth = this.history.undoDepth, t.setHistory(this.getHistory())), t }, linkedDoc: function (e) { e || (e = {}); var t = this.first, n = this.first + this.size; null != e.from && e.from > t && (t = e.from), null != e.to && e.to < n && (n = e.to); var r = new Ao($e(this, t, n), e.mode || this.modeOption, t, this.lineSep, this.direction); return e.sharedHist && (r.history = this.history), (this.linked || (this.linked = [])).push({ doc: r, sharedHist: e.sharedHist }), r.linked = [{ doc: this, isParent: !0, sharedHist: e.sharedHist }], function (e, t) { for (var n = 0; n < t.length; n++) { var r = t[n], i = r.find(), o = e.clipPos(i.from), a = e.clipPos(i.to); if (tt(o, a)) { var s = So(e, o, a, r.primary, r.primary.type); r.markers.push(s), s.parent = r } } }(r, ko(this)), r }, unlinkDoc: function (e) { if (e instanceof Na && (e = e.doc), this.linked) for (var t = 0; t < this.linked.length; ++t) if (this.linked[t].doc == e) { this.linked.splice(t, 1), e.unlinkDoc(this), Lo(ko(this)); break } if (e.history == this.history) { var n = [e.id]; Di(e, (function (e) { return n.push(e.id) }), !0), e.history = new Pi(null), e.history.done = Ki(this.history.done, n), e.history.undone = Ki(this.history.undone, n) } }, iterLinkedDocs: function (e) { Di(this, e) }, getMode: function () { return this.mode }, getEditor: function () { return this.cm }, splitLines: function (e) { return this.lineSep ? e.split(this.lineSep) : Ae(e) }, lineSeparator: function () { return this.lineSep || "\n" }, setDirection: ni((function (e) { var t; "rtl" != e && (e = "ltr"), e != this.direction && (this.direction = e, this.iter((function (e) { return e.order = null })), this.cm && Jr(t = this.cm, (function () { Ri(t), dr(t) }))) })) }), Ao.prototype.eachLine = Ao.prototype.iter; var Bo = 0; function Oo(e) { var t = this; if (Do(t), !ge(t, e) && !_n(t.display, e)) { be(e), a && (Bo = +new Date); var n = cr(t, e, !0), r = e.dataTransfer.files; if (n && !t.isReadOnly()) if (r && r.length && window.FileReader && window.File) for (var i = r.length, o = Array(i), s = 0, l = function () { ++s == i && ei(t, (function () { var e = { from: n = st(t.doc, n), to: n, text: t.doc.splitLines(o.filter((function (e) { return null != e })).join(t.doc.lineSeparator())), origin: "paste" }; co(t.doc, e), Qi(t.doc, xi(st(t.doc, n), st(t.doc, Si(e)))) }))() }, c = function (e, n) { if (t.options.allowDropFileTypes && -1 == U(t.options.allowDropFileTypes, e.type)) l(); else { var r = new FileReader; r.onerror = function () { return l() }, r.onload = function () { var e = r.result; /[\x00-\x08\x0e-\x1f]{2}/.test(e) || (o[n] = e), l() }, r.readAsText(e) } }, u = 0; u < r.length; u++) c(r[u], u); else { if (t.state.draggingText && t.doc.sel.contains(n) > -1) return t.state.draggingText(e), void setTimeout((function () { return t.display.input.focus() }), 20); try { var d = e.dataTransfer.getData("Text"); if (d) { var h; if (t.state.draggingText && !t.state.draggingText.copy && (h = t.listSelections()), eo(t.doc, xi(n, n)), h) for (var f = 0; f < h.length; ++f) go(t.doc, "", h[f].anchor, h[f].head, "drag"); t.replaceSelection(d, "around", "paste"), t.display.input.focus() } } catch (e) {} } } } function Do(e) { e.display.dragCursor && (e.display.lineSpace.removeChild(e.display.dragCursor), e.display.dragCursor = null) } function Io(e) { if (document.getElementsByClassName) { for (var t = document.getElementsByClassName("CodeMirror"), n = [], r = 0; r < t.length; r++) { var i = t[r].CodeMirror; i && n.push(i) } n.length && n[0].operation((function () { for (var t = 0; t < n.length; t++) e(n[t]) })) } } var Ro = !1; function Po() { var e; Ro || (de(window, "resize", (function () { null == e && (e = setTimeout((function () { e = null, Io(Ho) }), 100)) })), de(window, "blur", (function () { return Io(xr) })), Ro = !0) } function Ho(e) { var t = e.display; t.cachedCharWidth = t.cachedTextHeight = t.cachedPaddingH = null, t.scrollbarsClipped = !1, e.setSize() } for (var Fo = { 3: "Pause", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt", 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert", 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 145: "ScrollLock", 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", 221: "]", 222: "'", 224: "Mod", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete", 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert" }, Uo = 0; Uo < 10; Uo++) Fo[Uo + 48] = Fo[Uo + 96] = String(Uo); for (var Wo = 65; Wo <= 90; Wo++) Fo[Wo] = String.fromCharCode(Wo); for (var qo = 1; qo <= 12; qo++) Fo[qo + 111] = Fo[qo + 63235] = "F" + qo; var zo = {}; function jo(e) { var t, n, r, i, o = e.split(/-(?!$)/); e = o[o.length - 1]; for (var a = 0; a < o.length - 1; a++) { var s = o[a]; if (/^(cmd|meta|m)$/i.test(s)) i = !0; else if (/^a(lt)?$/i.test(s)) t = !0; else if (/^(c|ctrl|control)$/i.test(s)) n = !0; else { if (!/^s(hift)?$/i.test(s)) throw new Error("Unrecognized modifier name: " + s); r = !0 } } return t && (e = "Alt-" + e), n && (e = "Ctrl-" + e), i && (e = "Cmd-" + e), r && (e = "Shift-" + e), e } function Vo(e) { var t = {}; for (var n in e) if (e.hasOwnProperty(n)) { var r = e[n]; if (/^(name|fallthrough|(de|at)tach)$/.test(n)) continue; if ("..." == r) { delete e[n]; continue } for (var i = Y(n.split(" "), jo), o = 0; o < i.length; o++) { var a = void 0, s = void 0; o == i.length - 1 ? (s = i.join(" "), a = r) : (s = i.slice(0, o + 1).join(" "), a = "..."); var l = t[s]; if (l) { if (l != a) throw new Error("Inconsistent bindings for " + s) } else t[s] = a } delete e[n] } for (var c in t) e[c] = t[c]; return e } function Ko(e, t, n, r) { var i = (t = Xo(t)).call ? t.call(e, r) : t[e]; if (!1 === i) return "nothing"; if ("..." === i) return "multi"; if (null != i && n(i)) return "handled"; if (t.fallthrough) { if ("[object Array]" != Object.prototype.toString.call(t.fallthrough)) return Ko(e, t.fallthrough, n, r); for (var o = 0; o < t.fallthrough.length; o++) { var a = Ko(e, t.fallthrough[o], n, r); if (a) return a } } } function Go(e) { var t = "string" == typeof e ? e : Fo[e.keyCode]; return "Ctrl" == t || "Alt" == t || "Shift" == t || "Mod" == t } function $o(e, t, n) { var r = e; return t.altKey && "Alt" != r && (e = "Alt-" + e), (_ ? t.metaKey : t.ctrlKey) && "Ctrl" != r && (e = "Ctrl-" + e), (_ ? t.ctrlKey : t.metaKey) && "Mod" != r && (e = "Cmd-" + e), !n && t.shiftKey && "Shift" != r && (e = "Shift-" + e), e } function Yo(e, t) { if (d && 34 == e.keyCode && e.char) return !1; var n = Fo[e.keyCode]; return null != n && !e.altGraphKey && (3 == e.keyCode && e.code && (n = e.code), $o(n, e, t)) } function Xo(e) { return "string" == typeof e ? zo[e] : e } function Zo(e, t) { for (var n = e.doc.sel.ranges, r = [], i = 0; i < n.length; i++) { for (var o = t(n[i]); r.length && tt(o.from, $(r).to) <= 0;) { var a = r.pop(); if (tt(a.from, o.from) < 0) { o.from = a.from; break } } r.push(o) } Jr(e, (function () { for (var t = r.length - 1; t >= 0; t--) go(e.doc, "", r[t].from, r[t].to, "+delete"); Ar(e) })) } function Qo(e, t, n) { var r = ie(e.text, t + n, n); return r < 0 || r > e.text.length ? null : r } function Jo(e, t, n) { var r = Qo(e, t.ch, n); return null == r ? null : new et(t.line, r, n < 0 ? "after" : "before") } function ea(e, t, n, r, i) { if (e) { "rtl" == t.doc.direction && (i = -i); var o = ce(n, t.doc.direction); if (o) { var a, s = i < 0 ? $(o) : o[0], l = i < 0 == (1 == s.level) ? "after" : "before"; if (s.level > 0 || "rtl" == t.doc.direction) { var c = Bn(t, n); a = i < 0 ? n.text.length - 1 : 0; var u = On(t, c, a).top; a = oe((function (e) { return On(t, c, e).top == u }), i < 0 == (1 == s.level) ? s.from : s.to - 1, a), "before" == l && (a = Qo(n, a, 1)) } else a = i < 0 ? s.to : s.from; return new et(r, a, l) } } return new et(r, i < 0 ? n.text.length : 0, i < 0 ? "before" : "after") } zo.basic = { Left: "goCharLeft", Right: "goCharRight", Up: "goLineUp", Down: "goLineDown", End: "goLineEnd", Home: "goLineStartSmart", PageUp: "goPageUp", PageDown: "goPageDown", Delete: "delCharAfter", Backspace: "delCharBefore", "Shift-Backspace": "delCharBefore", Tab: "defaultTab", "Shift-Tab": "indentAuto", Enter: "newlineAndIndent", Insert: "toggleOverwrite", Esc: "singleSelection" }, zo.pcDefault = { "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo", "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown", "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd", "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find", "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll", "Ctrl-[": "indentLess", "Ctrl-]": "indentMore", "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection", fallthrough: "basic" }, zo.emacsy = { "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown", "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd", "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore", "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars", "Ctrl-O": "openLine" }, zo.macDefault = { "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo", "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft", "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore", "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find", "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll", "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight", "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd", fallthrough: ["basic", "emacsy"] }, zo.default = y ? zo.macDefault : zo.pcDefault; var ta = { selectAll: so, singleSelection: function (e) { return e.setSelection(e.getCursor("anchor"), e.getCursor("head"), q) }, killLine: function (e) { return Zo(e, (function (t) { if (t.empty()) { var n = Ke(e.doc, t.head.line).text.length; return t.head.ch == n && t.head.line < e.lastLine() ? { from: t.head, to: et(t.head.line + 1, 0) } : { from: t.head, to: et(t.head.line, n) } } return { from: t.from(), to: t.to() } })) }, deleteLine: function (e) { return Zo(e, (function (t) { return { from: et(t.from().line, 0), to: st(e.doc, et(t.to().line + 1, 0)) } })) }, delLineLeft: function (e) { return Zo(e, (function (e) { return { from: et(e.from().line, 0), to: e.from() } })) }, delWrappedLineLeft: function (e) { return Zo(e, (function (t) { var n = e.charCoords(t.head, "div").top + 5; return { from: e.coordsChar({ left: 0, top: n }, "div"), to: t.from() } })) }, delWrappedLineRight: function (e) { return Zo(e, (function (t) { var n = e.charCoords(t.head, "div").top + 5, r = e.coordsChar({ left: e.display.lineDiv.offsetWidth + 100, top: n }, "div"); return { from: t.from(), to: r } })) }, undo: function (e) { return e.undo() }, redo: function (e) { return e.redo() }, undoSelection: function (e) { return e.undoSelection() }, redoSelection: function (e) { return e.redoSelection() }, goDocStart: function (e) { return e.extendSelection(et(e.firstLine(), 0)) }, goDocEnd: function (e) { return e.extendSelection(et(e.lastLine())) }, goLineStart: function (e) { return e.extendSelectionsBy((function (t) { return na(e, t.head.line) }), { origin: "+move", bias: 1 }) }, goLineStartSmart: function (e) { return e.extendSelectionsBy((function (t) { return ra(e, t.head) }), { origin: "+move", bias: 1 }) }, goLineEnd: function (e) { return e.extendSelectionsBy((function (t) { return function (e, t) { var n = Ke(e.doc, t), r = function (e) { for (var t; t = It(e);) e = t.find(1, !0).line; return e }(n); return r != n && (t = Xe(r)), ea(!0, e, n, t, -1) }(e, t.head.line) }), { origin: "+move", bias: -1 }) }, goLineRight: function (e) { return e.extendSelectionsBy((function (t) { var n = e.cursorCoords(t.head, "div").top + 5; return e.coordsChar({ left: e.display.lineDiv.offsetWidth + 100, top: n }, "div") }), j) }, goLineLeft: function (e) { return e.extendSelectionsBy((function (t) { var n = e.cursorCoords(t.head, "div").top + 5; return e.coordsChar({ left: 0, top: n }, "div") }), j) }, goLineLeftSmart: function (e) { return e.extendSelectionsBy((function (t) { var n = e.cursorCoords(t.head, "div").top + 5, r = e.coordsChar({ left: 0, top: n }, "div"); return r.ch < e.getLine(r.line).search(/\S/) ? ra(e, t.head) : r }), j) }, goLineUp: function (e) { return e.moveV(-1, "line") }, goLineDown: function (e) { return e.moveV(1, "line") }, goPageUp: function (e) { return e.moveV(-1, "page") }, goPageDown: function (e) { return e.moveV(1, "page") }, goCharLeft: function (e) { return e.moveH(-1, "char") }, goCharRight: function (e) { return e.moveH(1, "char") }, goColumnLeft: function (e) { return e.moveH(-1, "column") }, goColumnRight: function (e) { return e.moveH(1, "column") }, goWordLeft: function (e) { return e.moveH(-1, "word") }, goGroupRight: function (e) { return e.moveH(1, "group") }, goGroupLeft: function (e) { return e.moveH(-1, "group") }, goWordRight: function (e) { return e.moveH(1, "word") }, delCharBefore: function (e) { return e.deleteH(-1, "codepoint") }, delCharAfter: function (e) { return e.deleteH(1, "char") }, delWordBefore: function (e) { return e.deleteH(-1, "word") }, delWordAfter: function (e) { return e.deleteH(1, "word") }, delGroupBefore: function (e) { return e.deleteH(-1, "group") }, delGroupAfter: function (e) { return e.deleteH(1, "group") }, indentAuto: function (e) { return e.indentSelection("smart") }, indentMore: function (e) { return e.indentSelection("add") }, indentLess: function (e) { return e.indentSelection("subtract") }, insertTab: function (e) { return e.replaceSelection("\t") }, insertSoftTab: function (e) { for (var t = [], n = e.listSelections(), r = e.options.tabSize, i = 0; i < n.length; i++) { var o = n[i].from(), a = H(e.getLine(o.line), o.ch, r); t.push(G(r - a % r)) } e.replaceSelections(t) }, defaultTab: function (e) { e.somethingSelected() ? e.indentSelection("add") : e.execCommand("insertTab") }, transposeChars: function (e) { return Jr(e, (function () { for (var t = e.listSelections(), n = [], r = 0; r < t.length; r++) if (t[r].empty()) { var i = t[r].head, o = Ke(e.doc, i.line).text; if (o) if (i.ch == o.length && (i = new et(i.line, i.ch - 1)), i.ch > 0) i = new et(i.line, i.ch + 1), e.replaceRange(o.charAt(i.ch - 1) + o.charAt(i.ch - 2), et(i.line, i.ch - 2), i, "+transpose"); else if (i.line > e.doc.first) { var a = Ke(e.doc, i.line - 1).text; a && (i = new et(i.line, 1), e.replaceRange(o.charAt(0) + e.doc.lineSeparator() + a.charAt(a.length - 1), et(i.line - 1, a.length - 1), i, "+transpose")) } n.push(new Ti(i, i)) } e.setSelections(n) })) }, newlineAndIndent: function (e) { return Jr(e, (function () { for (var t = e.listSelections(), n = t.length - 1; n >= 0; n--) e.replaceRange(e.doc.lineSeparator(), t[n].anchor, t[n].head, "+input"); t = e.listSelections(); for (var r = 0; r < t.length; r++) e.indentLine(t[r].from().line, null, !0); Ar(e) })) }, openLine: function (e) { return e.replaceSelection("\n", "start") }, toggleOverwrite: function (e) { return e.toggleOverwrite() } }; function na(e, t) { var n = Ke(e.doc, t), r = Ht(n); return r != n && (t = Xe(r)), ea(!0, e, r, t, 1) } function ra(e, t) { var n = na(e, t.line), r = Ke(e.doc, n.line), i = ce(r, e.doc.direction); if (!i || 0 == i[0].level) { var o = Math.max(n.ch, r.text.search(/\S/)), a = t.line == n.line && t.ch <= o && t.ch; return et(n.line, a ? 0 : o, n.sticky) } return n } function ia(e, t, n) { if ("string" == typeof t && !(t = ta[t])) return !1; e.display.input.ensurePolled(); var r = e.display.shift, i = !1; try { e.isReadOnly() && (e.state.suppressEdits = !0), n && (e.display.shift = !1), i = t(e) != W } finally { e.display.shift = r, e.state.suppressEdits = !1 } return i } var oa = new F; function aa(e, t, n, r) { var i = e.state.keySeq; if (i) { if (Go(t)) return "handled"; if (/\'$/.test(t) ? e.state.keySeq = null : oa.set(50, (function () { e.state.keySeq == i && (e.state.keySeq = null, e.display.input.reset()) })), sa(e, i + " " + t, n, r)) return !0 } return sa(e, t, n, r) } function sa(e, t, n, r) { var i = function (e, t, n) { for (var r = 0; r < e.state.keyMaps.length; r++) { var i = Ko(t, e.state.keyMaps[r], n, e); if (i) return i } return e.options.extraKeys && Ko(t, e.options.extraKeys, n, e) || Ko(t, e.options.keyMap, n, e) }(e, t, r); return "multi" == i && (e.state.keySeq = t), "handled" == i && ln(e, "keyHandled", e, t, n), "handled" != i && "multi" != i || (be(n), wr(e)), !!i } function la(e, t) { var n = Yo(t, !0); return !!n && (t.shiftKey && !e.state.keySeq ? aa(e, "Shift-" + n, t, (function (t) { return ia(e, t, !0) })) || aa(e, n, t, (function (t) { if ("string" == typeof t ? /^go[A-Z]/.test(t) : t.motion) return ia(e, t) })) : aa(e, n, t, (function (t) { return ia(e, t) }))) } var ca = null; function ua(e) { var t = this; if (!(e.target && e.target != t.display.input.getField() || (t.curOp.focus = B(), ge(t, e)))) { a && s < 11 && 27 == e.keyCode && (e.returnValue = !1); var r = e.keyCode; t.display.shift = 16 == r || e.shiftKey; var i = la(t, e); d && (ca = i ? r : null, i || 88 != r || Oe || !(y ? e.metaKey : e.ctrlKey) || t.replaceSelection("", null, "cut")), n && !y && !i && 46 == r && e.shiftKey && !e.ctrlKey && document.execCommand && document.execCommand("cut"), 18 != r || /\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className) || function (e) { var t = e.display.lineDiv; function n(e) { 18 != e.keyCode && e.altKey || (S(t, "CodeMirror-crosshair"), fe(document, "keyup", n), fe(document, "mouseover", n)) } O(t, "CodeMirror-crosshair"), de(document, "keyup", n), de(document, "mouseover", n) }(t) } } function da(e) { 16 == e.keyCode && (this.doc.sel.shift = !1), ge(this, e) } function ha(e) { var t = this; if (!(e.target && e.target != t.display.input.getField() || _n(t.display, e) || ge(t, e) || e.ctrlKey && !e.altKey || y && e.metaKey)) { var n = e.keyCode, r = e.charCode; if (d && n == ca) return ca = null, void be(e); if (!d || e.which && !(e.which < 10) || !la(t, e)) { var i = String.fromCharCode(null == r ? n : r); "\b" != i && (function (e, t, n) { return aa(e, "'" + n + "'", t, (function (t) { return ia(e, t, !0) })) }(t, e, i) || t.display.input.onKeyPress(e)) } } } var fa, pa, ga = function (e, t, n) { this.time = e, this.pos = t, this.button = n }; function ma(e) { var t = this, n = t.display; if (!(ge(t, e) || n.activeTouch && n.input.supportsTouch())) if (n.input.ensurePolled(), n.shift = e.shiftKey, _n(n, e)) l || (n.scroller.draggable = !1, setTimeout((function () { return n.scroller.draggable = !0 }), 100)); else if (!ba(t, e)) { var r = cr(t, e), i = Ee(e), o = r ? function (e, t) { var n = +new Date; return pa && pa.compare(n, e, t) ? (fa = pa = null, "triple") : fa && fa.compare(n, e, t) ? (pa = new ga(n, e, t), fa = null, "double") : (fa = new ga(n, e, t), pa = null, "single") }(r, i) : "single"; window.focus(), 1 == i && t.state.selectingText && t.state.selectingText(e), r && function (e, t, n, r, i) { var o = "Click"; return "double" == r ? o = "Double" + o : "triple" == r && (o = "Triple" + o), aa(e, $o(o = (1 == t ? "Left" : 2 == t ? "Middle" : "Right") + o, i), i, (function (t) { if ("string" == typeof t && (t = ta[t]), !t) return !1; var r = !1; try { e.isReadOnly() && (e.state.suppressEdits = !0), r = t(e, n) != W } finally { e.state.suppressEdits = !1 } return r })) }(t, i, r, o, e) || (1 == i ? r ? function (e, t, n, r) { a ? setTimeout(R(_r, e), 0) : e.curOp.focus = B(); var i, o = function (e, t, n) { var r = e.getOption("configureMouse"), i = r ? r(e, t, n) : {}; if (null == i.unit) { var o = b ? n.shiftKey && n.metaKey : n.altKey; i.unit = o ? "rectangle" : "single" == t ? "char" : "double" == t ? "word" : "line" } return (null == i.extend || e.doc.extend) && (i.extend = e.doc.extend || n.shiftKey), null == i.addNew && (i.addNew = y ? n.metaKey : n.ctrlKey), null == i.moveOnDrag && (i.moveOnDrag = !(y ? n.altKey : n.ctrlKey)), i }(e, n, r), c = e.doc.sel; e.options.dragDrop && Ne && !e.isReadOnly() && "single" == n && (i = c.contains(t)) > -1 && (tt((i = c.ranges[i]).from(), t) < 0 || t.xRel > 0) && (tt(i.to(), t) > 0 || t.xRel < 0) ? function (e, t, n, r) { var i = e.display, o = !1, c = ei(e, (function (t) { l && (i.scroller.draggable = !1), e.state.draggingText = !1, e.state.delayingBlurEvent && (e.hasFocus() ? e.state.delayingBlurEvent = !1 : Tr(e)), fe(i.wrapper.ownerDocument, "mouseup", c), fe(i.wrapper.ownerDocument, "mousemove", u), fe(i.scroller, "dragstart", d), fe(i.scroller, "drop", c), o || (be(t), r.addNew || $i(e.doc, n, null, null, r.extend), l && !h || a && 9 == s ? setTimeout((function () { i.wrapper.ownerDocument.body.focus({ preventScroll: !0 }), i.input.focus() }), 20) : i.input.focus()) })), u = function (e) { o = o || Math.abs(t.clientX - e.clientX) + Math.abs(t.clientY - e.clientY) >= 10 }, d = function () { return o = !0 }; l && (i.scroller.draggable = !0), e.state.draggingText = c, c.copy = !r.moveOnDrag, de(i.wrapper.ownerDocument, "mouseup", c), de(i.wrapper.ownerDocument, "mousemove", u), de(i.scroller, "dragstart", d), de(i.scroller, "drop", c), e.state.delayingBlurEvent = !0, setTimeout((function () { return i.input.focus() }), 20), i.scroller.dragDrop && i.scroller.dragDrop() }(e, r, t, o) : function (e, t, n, r) { a && Tr(e); var i = e.display, o = e.doc; be(t); var s, l, c = o.sel, u = c.ranges; if (r.addNew && !r.extend ? (l = o.sel.contains(n), s = l > -1 ? u[l] : new Ti(n, n)) : (s = o.sel.primary(), l = o.sel.primIndex), "rectangle" == r.unit) r.addNew || (s = new Ti(n, n)), n = cr(e, t, !0, !0), l = -1; else { var d = va(e, n, r.unit); s = r.extend ? Gi(s, d.anchor, d.head, r.extend) : d } r.addNew ? -1 == l ? (l = u.length, Ji(o, Ei(e, u.concat([s]), l), { scroll: !1, origin: "*mouse" })) : u.length > 1 && u[l].empty() && "char" == r.unit && !r.extend ? (Ji(o, Ei(e, u.slice(0, l).concat(u.slice(l + 1)), 0), { scroll: !1, origin: "*mouse" }), c = o.sel) : Xi(o, l, s, z) : (l = 0, Ji(o, new _i([s], 0), z), c = o.sel); var h = n; function f(t) { if (0 != tt(h, t)) if (h = t, "rectangle" == r.unit) { for (var i = [], a = e.options.tabSize, u = H(Ke(o, n.line).text, n.ch, a), d = H(Ke(o, t.line).text, t.ch, a), f = Math.min(u, d), p = Math.max(u, d), g = Math.min(n.line, t.line), m = Math.min(e.lastLine(), Math.max(n.line, t.line)); g <= m; g++) { var v = Ke(o, g).text, y = V(v, f, a); f == p ? i.push(new Ti(et(g, y), et(g, y))) : v.length > y && i.push(new Ti(et(g, y), et(g, V(v, p, a)))) } i.length || i.push(new Ti(n, n)), Ji(o, Ei(e, c.ranges.slice(0, l).concat(i), l), { origin: "*mouse", scroll: !1 }), e.scrollIntoView(t) } else { var b, C = s, w = va(e, t, r.unit), _ = C.anchor; tt(w.anchor, _) > 0 ? (b = w.head, _ = ot(C.from(), w.anchor)) : (b = w.anchor, _ = it(C.to(), w.head)); var T = c.ranges.slice(0); T[l] = function (e, t) { var n = t.anchor, r = t.head, i = Ke(e.doc, n.line); if (0 == tt(n, r) && n.sticky == r.sticky) return t; var o = ce(i); if (!o) return t; var a = se(o, n.ch, n.sticky), s = o[a]; if (s.from != n.ch && s.to != n.ch) return t; var l, c = a + (s.from == n.ch == (1 != s.level) ? 0 : 1); if (0 == c || c == o.length) return t; if (r.line != n.line) l = (r.line - n.line) * ("ltr" == e.doc.direction ? 1 : -1) > 0; else { var u = se(o, r.ch, r.sticky), d = u - a || (r.ch - n.ch) * (1 == s.level ? -1 : 1); l = u == c - 1 || u == c ? d < 0 : d > 0 } var h = o[c + (l ? -1 : 0)], f = l == (1 == h.level), p = f ? h.from : h.to, g = f ? "after" : "before"; return n.ch == p && n.sticky == g ? t : new Ti(new et(n.line, p, g), r) }(e, new Ti(st(o, _), b)), Ji(o, Ei(e, T, l), z) } } var p = i.wrapper.getBoundingClientRect(), g = 0; function m(t) { e.state.selectingText = !1, g = 1 / 0, t && (be(t), i.input.focus()), fe(i.wrapper.ownerDocument, "mousemove", v), fe(i.wrapper.ownerDocument, "mouseup", y), o.history.lastSelOrigin = null } var v = ei(e, (function (t) { 0 !== t.buttons && Ee(t) ? function t(n) { var a = ++g, s = cr(e, n, !0, "rectangle" == r.unit); if (s) if (0 != tt(s, h)) { e.curOp.focus = B(), f(s); var l = kr(i, o); (s.line >= l.to || s.line < l.from) && setTimeout(ei(e, (function () { g == a && t(n) })), 150) } else { var c = n.clientY < p.top ? -20 : n.clientY > p.bottom ? 20 : 0; c && setTimeout(ei(e, (function () { g == a && (i.scroller.scrollTop += c, t(n)) })), 50) } }(t) : m(t) })), y = ei(e, m); e.state.selectingText = y, de(i.wrapper.ownerDocument, "mousemove", v), de(i.wrapper.ownerDocument, "mouseup", y) }(e, r, t, o) }(t, r, o, e) : Te(e) == n.scroller && be(e) : 2 == i ? (r && $i(t.doc, r), setTimeout((function () { return n.input.focus() }), 20)) : 3 == i && (T ? t.display.input.onContextMenu(e) : Tr(t))) } } function va(e, t, n) { if ("char" == n) return new Ti(t, t); if ("word" == n) return e.findWordAt(t); if ("line" == n) return new Ti(et(t.line, 0), st(e.doc, et(t.line + 1, 0))); var r = n(e, t); return new Ti(r.from, r.to) } function ya(e, t, n, r) { var i, o; if (t.touches) i = t.touches[0].clientX, o = t.touches[0].clientY; else try { i = t.clientX, o = t.clientY } catch (e) { return !1 } if (i >= Math.floor(e.display.gutters.getBoundingClientRect().right)) return !1; r && be(t); var a = e.display, s = a.lineDiv.getBoundingClientRect(); if (o > s.bottom || !ve(e, n)) return we(t); o -= s.top - a.viewOffset; for (var l = 0; l < e.display.gutterSpecs.length; ++l) { var c = a.gutters.childNodes[l]; if (c && c.getBoundingClientRect().right >= i) return pe(e, n, e, Ze(e.doc, o), e.display.gutterSpecs[l].className, t), we(t) } } function ba(e, t) { return ya(e, t, "gutterClick", !0) } function Ca(e, t) { _n(e.display, t) || function (e, t) { return !!ve(e, "gutterContextMenu") && ya(e, t, "gutterContextMenu", !1) }(e, t) || ge(e, t, "contextmenu") || T || e.display.input.onContextMenu(t) } function wa(e) { e.display.wrapper.className = e.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") + e.options.theme.replace(/(^|\s)\s*/g, " cm-s-"), Un(e) } ga.prototype.compare = function (e, t, n) { return this.time + 400 > e && 0 == tt(t, this.pos) && n == this.button }; var _a = { toString: function () { return "CodeMirror.Init" } }, Ta = {}, Ea = {}; function xa(e, t, n) { if (!t != !(n && n != _a)) { var r = e.display.dragFunctions, i = t ? de : fe; i(e.display.scroller, "dragstart", r.start), i(e.display.scroller, "dragenter", r.enter), i(e.display.scroller, "dragover", r.over), i(e.display.scroller, "dragleave", r.leave), i(e.display.scroller, "drop", r.drop) } } function Sa(e) { e.options.lineWrapping ? (O(e.display.wrapper, "CodeMirror-wrap"), e.display.sizer.style.minWidth = "", e.display.sizerWidth = null) : (S(e.display.wrapper, "CodeMirror-wrap"), Vt(e)), lr(e), dr(e), Un(e), setTimeout((function () { return Wr(e) }), 100) } function Na(e, t) { var n = this; if (!(this instanceof Na)) return new Na(e, t); this.options = t = t ? P(t) : {}, P(Ta, t, !1); var r = t.value; "string" == typeof r ? r = new Ao(r, t.mode, null, t.lineSeparator, t.direction) : t.mode && (r.modeOption = t.mode), this.doc = r; var i = new Na.inputStyles[t.inputStyle](this), o = this.display = new mi(e, r, i, t); for (var c in o.wrapper.CodeMirror = this, wa(this), t.lineWrapping && (this.display.wrapper.className += " CodeMirror-wrap"), jr(this), this.state = { keyMaps: [], overlays: [], modeGen: 0, overwrite: !1, delayingBlurEvent: !1, focused: !1, suppressEdits: !1, pasteIncoming: -1, cutIncoming: -1, selectingText: !1, draggingText: !1, highlight: new F, keySeq: null, specialChars: null }, t.autofocus && !v && o.input.focus(), a && s < 11 && setTimeout((function () { return n.display.input.reset(!0) }), 20), function (e) { var t = e.display; de(t.scroller, "mousedown", ei(e, ma)), de(t.scroller, "dblclick", a && s < 11 ? ei(e, (function (t) { if (!ge(e, t)) { var n = cr(e, t); if (n && !ba(e, t) && !_n(e.display, t)) { be(t); var r = e.findWordAt(n); $i(e.doc, r.anchor, r.head) } } })) : function (t) { return ge(e, t) || be(t) }), de(t.scroller, "contextmenu", (function (t) { return Ca(e, t) })), de(t.input.getField(), "contextmenu", (function (n) { t.scroller.contains(n.target) || Ca(e, n) })); var n, r = { end: 0 }; function i() { t.activeTouch && (n = setTimeout((function () { return t.activeTouch = null }), 1e3), (r = t.activeTouch).end = +new Date) } function o(e, t) { if (null == t.left) return !0; var n = t.left - e.left, r = t.top - e.top; return n * n + r * r > 400 } de(t.scroller, "touchstart", (function (i) { if (!ge(e, i) && ! function (e) { if (1 != e.touches.length) return !1; var t = e.touches[0]; return t.radiusX <= 1 && t.radiusY <= 1 }(i) && !ba(e, i)) { t.input.ensurePolled(), clearTimeout(n); var o = +new Date; t.activeTouch = { start: o, moved: !1, prev: o - r.end <= 300 ? r : null }, 1 == i.touches.length && (t.activeTouch.left = i.touches[0].pageX, t.activeTouch.top = i.touches[0].pageY) } })), de(t.scroller, "touchmove", (function () { t.activeTouch && (t.activeTouch.moved = !0) })), de(t.scroller, "touchend", (function (n) { var r = t.activeTouch; if (r && !_n(t, n) && null != r.left && !r.moved && new Date - r.start < 300) { var a, s = e.coordsChar(t.activeTouch, "page"); a = !r.prev || o(r, r.prev) ? new Ti(s, s) : !r.prev.prev || o(r, r.prev.prev) ? e.findWordAt(s) : new Ti(et(s.line, 0), st(e.doc, et(s.line + 1, 0))), e.setSelection(a.anchor, a.head), e.focus(), be(n) } i() })), de(t.scroller, "touchcancel", i), de(t.scroller, "scroll", (function () { t.scroller.clientHeight && (Ir(e, t.scroller.scrollTop), Pr(e, t.scroller.scrollLeft, !0), pe(e, "scroll", e)) })), de(t.scroller, "mousewheel", (function (t) { return wi(e, t) })), de(t.scroller, "DOMMouseScroll", (function (t) { return wi(e, t) })), de(t.wrapper, "scroll", (function () { return t.wrapper.scrollTop = t.wrapper.scrollLeft = 0 })), t.dragFunctions = { enter: function (t) { ge(e, t) || _e(t) }, over: function (t) { ge(e, t) || (function (e, t) { var n = cr(e, t); if (n) { var r = document.createDocumentFragment(); yr(e, n, r), e.display.dragCursor || (e.display.dragCursor = L("div", null, "CodeMirror-cursors CodeMirror-dragcursors"), e.display.lineSpace.insertBefore(e.display.dragCursor, e.display.cursorDiv)), k(e.display.dragCursor, r) } }(e, t), _e(t)) }, start: function (t) { return function (e, t) { if (a && (!e.state.draggingText || +new Date - Bo < 100)) _e(t); else if (!ge(e, t) && !_n(e.display, t) && (t.dataTransfer.setData("Text", e.getSelection()), t.dataTransfer.effectAllowed = "copyMove", t.dataTransfer.setDragImage && !h)) { var n = L("img", null, null, "position: fixed; left: 0; top: 0;"); n.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", d && (n.width = n.height = 1, e.display.wrapper.appendChild(n), n._top = n.offsetTop), t.dataTransfer.setDragImage(n, 0, 0), d && n.parentNode.removeChild(n) } }(e, t) }, drop: ei(e, Oo), leave: function (t) { ge(e, t) || Do(e) } }; var l = t.input.getField(); de(l, "keyup", (function (t) { return da.call(e, t) })), de(l, "keydown", ei(e, ua)), de(l, "keypress", ei(e, ha)), de(l, "focus", (function (t) { return Er(e, t) })), de(l, "blur", (function (t) { return xr(e, t) })) }(this), Po(), Kr(this), this.curOp.forceUpdate = !0, Ii(this, r), t.autofocus && !v || this.hasFocus() ? setTimeout((function () { n.hasFocus() && !n.state.focused && Er(n) }), 20) : xr(this), Ea) Ea.hasOwnProperty(c) && Ea[c](this, t[c], _a); hi(this), t.finishInit && t.finishInit(this); for (var u = 0; u < ka.length; ++u) ka[u](this); Gr(this), l && t.lineWrapping && "optimizelegibility" == getComputedStyle(o.lineDiv).textRendering && (o.lineDiv.style.textRendering = "auto") } Na.defaults = Ta, Na.optionHandlers = Ea; var ka = []; function La(e, t, n, r) { var i, o = e.doc; null == n && (n = "add"), "smart" == n && (o.mode.indent ? i = ft(e, t).state : n = "prev"); var a = e.options.tabSize, s = Ke(o, t), l = H(s.text, null, a); s.stateAfter && (s.stateAfter = null); var c, u = s.text.match(/^\s*/)[0]; if (r || /\S/.test(s.text)) { if ("smart" == n && ((c = o.mode.indent(i, s.text.slice(u.length), s.text)) == W || c > 150)) { if (!r) return; n = "prev" } } else c = 0, n = "not"; "prev" == n ? c = t > o.first ? H(Ke(o, t - 1).text, null, a) : 0 : "add" == n ? c = l + e.options.indentUnit : "subtract" == n ? c = l - e.options.indentUnit : "number" == typeof n && (c = l + n), c = Math.max(0, c); var d = "", h = 0; if (e.options.indentWithTabs) for (var f = Math.floor(c / a); f; --f) h += a, d += "\t"; if (h < c && (d += G(c - h)), d != u) return go(o, d, et(t, 0), et(t, u.length), "+input"), s.stateAfter = null, !0; for (var p = 0; p < o.sel.ranges.length; p++) { var g = o.sel.ranges[p]; if (g.head.line == t && g.head.ch < u.length) { var m = et(t, u.length); Xi(o, p, new Ti(m, m)); break } } } Na.defineInitHook = function (e) { return ka.push(e) }; var Ma = null; function Aa(e) { Ma = e } function Ba(e, t, n, r, i) { var o = e.doc; e.display.shift = !1, r || (r = o.sel); var a = +new Date - 200, s = "paste" == i || e.state.pasteIncoming > a, l = Ae(t), c = null; if (s && r.ranges.length > 1) if (Ma && Ma.text.join("\n") == t) { if (r.ranges.length % Ma.text.length == 0) { c = []; for (var u = 0; u < Ma.text.length; u++) c.push(o.splitLines(Ma.text[u])) } } else l.length == r.ranges.length && e.options.pasteLinesPerSelection && (c = Y(l, (function (e) { return [e] }))); for (var d = e.curOp.updateInput, h = r.ranges.length - 1; h >= 0; h--) { var f = r.ranges[h], p = f.from(), g = f.to(); f.empty() && (n && n > 0 ? p = et(p.line, p.ch - n) : e.state.overwrite && !s ? g = et(g.line, Math.min(Ke(o, g.line).text.length, g.ch + $(l).length)) : s && Ma && Ma.lineWise && Ma.text.join("\n") == l.join("\n") && (p = g = et(p.line, 0))); var m = { from: p, to: g, text: c ? c[h % c.length] : l, origin: i || (s ? "paste" : e.state.cutIncoming > a ? "cut" : "+input") }; co(e.doc, m), ln(e, "inputRead", e, m) } t && !s && Da(e, t), Ar(e), e.curOp.updateInput < 2 && (e.curOp.updateInput = d), e.curOp.typing = !0, e.state.pasteIncoming = e.state.cutIncoming = -1 } function Oa(e, t) { var n = e.clipboardData && e.clipboardData.getData("Text"); if (n) return e.preventDefault(), t.isReadOnly() || t.options.disableInput || Jr(t, (function () { return Ba(t, n, 0, null, "paste") })), !0 } function Da(e, t) { if (e.options.electricChars && e.options.smartIndent) for (var n = e.doc.sel, r = n.ranges.length - 1; r >= 0; r--) { var i = n.ranges[r]; if (!(i.head.ch > 100 || r && n.ranges[r - 1].head.line == i.head.line)) { var o = e.getModeAt(i.head), a = !1; if (o.electricChars) { for (var s = 0; s < o.electricChars.length; s++) if (t.indexOf(o.electricChars.charAt(s)) > -1) { a = La(e, i.head.line, "smart"); break } } else o.electricInput && o.electricInput.test(Ke(e.doc, i.head.line).text.slice(0, i.head.ch)) && (a = La(e, i.head.line, "smart")); a && ln(e, "electricInput", e, i.head.line) } } } function Ia(e) { for (var t = [], n = [], r = 0; r < e.doc.sel.ranges.length; r++) { var i = e.doc.sel.ranges[r].head.line, o = { anchor: et(i, 0), head: et(i + 1, 0) }; n.push(o), t.push(e.getRange(o.anchor, o.head)) } return { text: t, ranges: n } } function Ra(e, t, n, r) { e.setAttribute("autocorrect", n ? "" : "off"), e.setAttribute("autocapitalize", r ? "" : "off"), e.setAttribute("spellcheck", !!t) } function Pa() { var e = L("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"), t = L("div", [e], null, "overflow: hidden; position: relative; width: 3px; height: 0px;"); return l ? e.style.width = "1000px" : e.setAttribute("wrap", "off"), g && (e.style.border = "1px solid black"), Ra(e), t } function Ha(e, t, n, r, i) { var o = t, a = n, s = Ke(e, t.line), l = i && "rtl" == e.direction ? -n : n; function c(o) { var a, c; if ("codepoint" == r) { var u = s.text.charCodeAt(t.ch + (r > 0 ? 0 : -1)); a = isNaN(u) ? null : new et(t.line, Math.max(0, Math.min(s.text.length, t.ch + n * (u >= 55296 && u < 56320 ? 2 : 1))), -n) } else a = i ? function (e, t, n, r) { var i = ce(t, e.doc.direction); if (!i) return Jo(t, n, r); n.ch >= t.text.length ? (n.ch = t.text.length, n.sticky = "before") : n.ch <= 0 && (n.ch = 0, n.sticky = "after"); var o = se(i, n.ch, n.sticky), a = i[o]; if ("ltr" == e.doc.direction && a.level % 2 == 0 && (r > 0 ? a.to > n.ch : a.from < n.ch)) return Jo(t, n, r); var s, l = function (e, n) { return Qo(t, e instanceof et ? e.ch : e, n) }, c = function (n) { return e.options.lineWrapping ? (s = s || Bn(e, t), Qn(e, t, s, n)) : { begin: 0, end: t.text.length } }, u = c("before" == n.sticky ? l(n, -1) : n.ch); if ("rtl" == e.doc.direction || 1 == a.level) { var d = 1 == a.level == r < 0, h = l(n, d ? 1 : -1); if (null != h && (d ? h <= a.to && h <= u.end : h >= a.from && h >= u.begin)) { var f = d ? "before" : "after"; return new et(n.line, h, f) } } var p = function (e, t, r) { for (var o = function (e, t) { return t ? new et(n.line, l(e, 1), "before") : new et(n.line, e, "after") }; e >= 0 && e < i.length; e += t) { var a = i[e], s = t > 0 == (1 != a.level), c = s ? r.begin : l(r.end, -1); if (a.from <= c && c < a.to) return o(c, s); if (c = s ? a.from : l(a.to, -1), r.begin <= c && c < r.end) return o(c, s) } }, g = p(o + r, r, u); if (g) return g; var m = r > 0 ? u.end : l(u.begin, -1); return null == m || r > 0 && m == t.text.length || !(g = p(r > 0 ? 0 : i.length - 1, r, c(m))) ? null : g }(e.cm, s, t, n) : Jo(s, t, n); if (null == a) { if (o || (c = t.line + l) < e.first || c >= e.first + e.size || (t = new et(c, t.ch, t.sticky), !(s = Ke(e, c)))) return !1; t = ea(i, e.cm, s, t.line, l) } else t = a; return !0 } if ("char" == r || "codepoint" == r) c(); else if ("column" == r) c(!0); else if ("word" == r || "group" == r) for (var u = null, d = "group" == r, h = e.cm && e.cm.getHelper(t, "wordChars"), f = !0; !(n < 0) || c(!f); f = !1) { var p = s.text.charAt(t.ch) || "\n", g = ee(p, h) ? "w" : d && "\n" == p ? "n" : !d || /\s/.test(p) ? null : "p"; if (!d || f || g || (g = "s"), u && u != g) { n < 0 && (n = 1, c(), t.sticky = "after"); break } if (g && (u = g), n > 0 && !c(!f)) break } var m = oo(e, t, o, a, !0); return nt(o, m) && (m.hitSide = !0), m } function Fa(e, t, n, r) { var i, o, a = e.doc, s = t.left; if ("page" == r) { var l = Math.min(e.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight), c = Math.max(l - .5 * rr(e.display), 3); i = (n > 0 ? t.bottom : t.top) + n * c } else "line" == r && (i = n > 0 ? t.bottom + 3 : t.top - 3); for (; (o = Xn(e, s, i)).outside;) { if (n < 0 ? i <= 0 : i >= a.height) { o.hitSide = !0; break } i += 5 * n } return o } var Ua = function (e) { this.cm = e, this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null, this.polling = new F, this.composing = null, this.gracePeriod = !1, this.readDOMTimeout = null }; function Wa(e, t) { var n = An(e, t.line); if (!n || n.hidden) return null; var r = Ke(e.doc, t.line), i = Ln(n, r, t.line), o = ce(r, e.doc.direction), a = "left"; o && (a = se(o, t.ch) % 2 ? "right" : "left"); var s = Rn(i.map, t.ch, a); return s.offset = "right" == s.collapse ? s.end : s.start, s } function qa(e, t) { return t && (e.bad = !0), e } function za(e, t, n) { var r; if (t == e.display.lineDiv) { if (!(r = e.display.lineDiv.childNodes[n])) return qa(e.clipPos(et(e.display.viewTo - 1)), !0); t = null, n = 0 } else for (r = t;; r = r.parentNode) { if (!r || r == e.display.lineDiv) return null; if (r.parentNode && r.parentNode == e.display.lineDiv) break } for (var i = 0; i < e.display.view.length; i++) { var o = e.display.view[i]; if (o.node == r) return ja(o, t, n) } } function ja(e, t, n) { var r = e.text.firstChild, i = !1; if (!t || !A(r, t)) return qa(et(Xe(e.line), 0), !0); if (t == r && (i = !0, t = r.childNodes[n], n = 0, !t)) { var o = e.rest ? $(e.rest) : e.line; return qa(et(Xe(o), o.text.length), i) } var a = 3 == t.nodeType ? t : null, s = t; for (a || 1 != t.childNodes.length || 3 != t.firstChild.nodeType || (a = t.firstChild, n && (n = a.nodeValue.length)); s.parentNode != r;) s = s.parentNode; var l = e.measure, c = l.maps; function u(t, n, r) { for (var i = -1; i < (c ? c.length : 0); i++) for (var o = i < 0 ? l.map : c[i], a = 0; a < o.length; a += 3) { var s = o[a + 2]; if (s == t || s == n) { var u = Xe(i < 0 ? e.line : e.rest[i]), d = o[a] + r; return (r < 0 || s != t) && (d = o[a + (r ? 1 : 0)]), et(u, d) } } } var d = u(a, s, n); if (d) return qa(d, i); for (var h = s.nextSibling, f = a ? a.nodeValue.length - n : 0; h; h = h.nextSibling) { if (d = u(h, h.firstChild, 0)) return qa(et(d.line, d.ch - f), i); f += h.textContent.length } for (var p = s.previousSibling, g = n; p; p = p.previousSibling) { if (d = u(p, p.firstChild, -1)) return qa(et(d.line, d.ch + g), i); g += p.textContent.length } } Ua.prototype.init = function (e) { var t = this, n = this, r = n.cm, i = n.div = e.lineDiv; function o(e) { for (var t = e.target; t; t = t.parentNode) { if (t == i) return !0; if (/\bCodeMirror-(?:line)?widget\b/.test(t.className)) break } return !1 } function a(e) { if (o(e) && !ge(r, e)) { if (r.somethingSelected()) Aa({ lineWise: !1, text: r.getSelections() }), "cut" == e.type && r.replaceSelection("", null, "cut"); else { if (!r.options.lineWiseCopyCut) return; var t = Ia(r); Aa({ lineWise: !0, text: t.text }), "cut" == e.type && r.operation((function () { r.setSelections(t.ranges, 0, q), r.replaceSelection("", null, "cut") })) } if (e.clipboardData) { e.clipboardData.clearData(); var a = Ma.text.join("\n"); if (e.clipboardData.setData("Text", a), e.clipboardData.getData("Text") == a) return void e.preventDefault() } var s = Pa(), l = s.firstChild; r.display.lineSpace.insertBefore(s, r.display.lineSpace.firstChild), l.value = Ma.text.join("\n"); var c = document.activeElement; I(l), setTimeout((function () { r.display.lineSpace.removeChild(s), c.focus(), c == i && n.showPrimarySelection() }), 50) } } Ra(i, r.options.spellcheck, r.options.autocorrect, r.options.autocapitalize), de(i, "paste", (function (e) { !o(e) || ge(r, e) || Oa(e, r) || s <= 11 && setTimeout(ei(r, (function () { return t.updateFromDOM() })), 20) })), de(i, "compositionstart", (function (e) { t.composing = { data: e.data, done: !1 } })), de(i, "compositionupdate", (function (e) { t.composing || (t.composing = { data: e.data, done: !1 }) })), de(i, "compositionend", (function (e) { t.composing && (e.data != t.composing.data && t.readFromDOMSoon(), t.composing.done = !0) })), de(i, "touchstart", (function () { return n.forceCompositionEnd() })), de(i, "input", (function () { t.composing || t.readFromDOMSoon() })), de(i, "copy", a), de(i, "cut", a) }, Ua.prototype.screenReaderLabelChanged = function (e) { e ? this.div.setAttribute("aria-label", e) : this.div.removeAttribute("aria-label") }, Ua.prototype.prepareSelection = function () { var e = vr(this.cm, !1); return e.focus = document.activeElement == this.div, e }, Ua.prototype.showSelection = function (e, t) { e && this.cm.display.view.length && ((e.focus || t) && this.showPrimarySelection(), this.showMultipleSelections(e)) }, Ua.prototype.getSelection = function () { return this.cm.display.wrapper.ownerDocument.getSelection() }, Ua.prototype.showPrimarySelection = function () { var e = this.getSelection(), t = this.cm, r = t.doc.sel.primary(), i = r.from(), o = r.to(); if (t.display.viewTo == t.display.viewFrom || i.line >= t.display.viewTo || o.line < t.display.viewFrom) e.removeAllRanges(); else { var a = za(t, e.anchorNode, e.anchorOffset), s = za(t, e.focusNode, e.focusOffset); if (!a || a.bad || !s || s.bad || 0 != tt(ot(a, s), i) || 0 != tt(it(a, s), o)) { var l = t.display.view, c = i.line >= t.display.viewFrom && Wa(t, i) || { node: l[0].measure.map[2], offset: 0 }, u = o.line < t.display.viewTo && Wa(t, o); if (!u) { var d = l[l.length - 1].measure, h = d.maps ? d.maps[d.maps.length - 1] : d.map; u = { node: h[h.length - 1], offset: h[h.length - 2] - h[h.length - 3] } } if (c && u) { var f, p = e.rangeCount && e.getRangeAt(0); try { f = x(c.node, c.offset, u.offset, u.node) } catch (e) {} f && (!n && t.state.focused ? (e.collapse(c.node, c.offset), f.collapsed || (e.removeAllRanges(), e.addRange(f))) : (e.removeAllRanges(), e.addRange(f)), p && null == e.anchorNode ? e.addRange(p) : n && this.startGracePeriod()), this.rememberSelection() } else e.removeAllRanges() } } }, Ua.prototype.startGracePeriod = function () { var e = this; clearTimeout(this.gracePeriod), this.gracePeriod = setTimeout((function () { e.gracePeriod = !1, e.selectionChanged() && e.cm.operation((function () { return e.cm.curOp.selectionChanged = !0 })) }), 20) }, Ua.prototype.showMultipleSelections = function (e) { k(this.cm.display.cursorDiv, e.cursors), k(this.cm.display.selectionDiv, e.selection) }, Ua.prototype.rememberSelection = function () { var e = this.getSelection(); this.lastAnchorNode = e.anchorNode, this.lastAnchorOffset = e.anchorOffset, this.lastFocusNode = e.focusNode, this.lastFocusOffset = e.focusOffset }, Ua.prototype.selectionInEditor = function () { var e = this.getSelection(); if (!e.rangeCount) return !1; var t = e.getRangeAt(0).commonAncestorContainer; return A(this.div, t) }, Ua.prototype.focus = function () { "nocursor" != this.cm.options.readOnly && (this.selectionInEditor() && document.activeElement == this.div || this.showSelection(this.prepareSelection(), !0), this.div.focus()) }, Ua.prototype.blur = function () { this.div.blur() }, Ua.prototype.getField = function () { return this.div }, Ua.prototype.supportsTouch = function () { return !0 }, Ua.prototype.receivedFocus = function () { var e = this; this.selectionInEditor() ? this.pollSelection() : Jr(this.cm, (function () { return e.cm.curOp.selectionChanged = !0 })), this.polling.set(this.cm.options.pollInterval, (function t() { e.cm.state.focused && (e.pollSelection(), e.polling.set(e.cm.options.pollInterval, t)) })) }, Ua.prototype.selectionChanged = function () { var e = this.getSelection(); return e.anchorNode != this.lastAnchorNode || e.anchorOffset != this.lastAnchorOffset || e.focusNode != this.lastFocusNode || e.focusOffset != this.lastFocusOffset }, Ua.prototype.pollSelection = function () { if (null == this.readDOMTimeout && !this.gracePeriod && this.selectionChanged()) { var e = this.getSelection(), t = this.cm; if (m && u && this.cm.display.gutterSpecs.length && function (e) { for (var t = e; t; t = t.parentNode) if (/CodeMirror-gutter-wrapper/.test(t.className)) return !0; return !1 }(e.anchorNode)) return this.cm.triggerOnKeyDown({ type: "keydown", keyCode: 8, preventDefault: Math.abs }), this.blur(), void this.focus(); if (!this.composing) { this.rememberSelection(); var n = za(t, e.anchorNode, e.anchorOffset), r = za(t, e.focusNode, e.focusOffset); n && r && Jr(t, (function () { Ji(t.doc, xi(n, r), q), (n.bad || r.bad) && (t.curOp.selectionChanged = !0) })) } } }, Ua.prototype.pollContent = function () { null != this.readDOMTimeout && (clearTimeout(this.readDOMTimeout), this.readDOMTimeout = null); var e, t, n, r = this.cm, i = r.display, o = r.doc.sel.primary(), a = o.from(), s = o.to(); if (0 == a.ch && a.line > r.firstLine() && (a = et(a.line - 1, Ke(r.doc, a.line - 1).length)), s.ch == Ke(r.doc, s.line).text.length && s.line < r.lastLine() && (s = et(s.line + 1, 0)), a.line < i.viewFrom || s.line > i.viewTo - 1) return !1; a.line == i.viewFrom || 0 == (e = ur(r, a.line)) ? (t = Xe(i.view[0].line), n = i.view[0].node) : (t = Xe(i.view[e].line), n = i.view[e - 1].node.nextSibling); var l, c, u = ur(r, s.line); if (u == i.view.length - 1 ? (l = i.viewTo - 1, c = i.lineDiv.lastChild) : (l = Xe(i.view[u + 1].line) - 1, c = i.view[u + 1].node.previousSibling), !n) return !1; for (var d = r.doc.splitLines(function (e, t, n, r, i) { var o = "", a = !1, s = e.doc.lineSeparator(), l = !1; function c() { a && (o += s, l && (o += s), a = l = !1) } function u(e) { e && (c(), o += e) } function d(t) { if (1 == t.nodeType) { var n = t.getAttribute("cm-text"); if (n) return void u(n); var o, h = t.getAttribute("cm-marker"); if (h) { var f = e.findMarks(et(r, 0), et(i + 1, 0), (m = +h, function (e) { return e.id == m })); return void(f.length && (o = f[0].find(0)) && u(Ge(e.doc, o.from, o.to).join(s))) } if ("false" == t.getAttribute("contenteditable")) return; var p = /^(pre|div|p|li|table|br)$/i.test(t.nodeName); if (!/^br$/i.test(t.nodeName) && 0 == t.textContent.length) return; p && c(); for (var g = 0; g < t.childNodes.length; g++) d(t.childNodes[g]); /^(pre|p)$/i.test(t.nodeName) && (l = !0), p && (a = !0) } else 3 == t.nodeType && u(t.nodeValue.replace(/\u200b/g, "").replace(/\u00a0/g, " ")); var m } for (; d(t), t != n;) t = t.nextSibling, l = !1; return o }(r, n, c, t, l)), h = Ge(r.doc, et(t, 0), et(l, Ke(r.doc, l).text.length)); d.length > 1 && h.length > 1;) if ($(d) == $(h)) d.pop(), h.pop(), l--; else { if (d[0] != h[0]) break; d.shift(), h.shift(), t++ } for (var f = 0, p = 0, g = d[0], m = h[0], v = Math.min(g.length, m.length); f < v && g.charCodeAt(f) == m.charCodeAt(f);) ++f; for (var y = $(d), b = $(h), C = Math.min(y.length - (1 == d.length ? f : 0), b.length - (1 == h.length ? f : 0)); p < C && y.charCodeAt(y.length - p - 1) == b.charCodeAt(b.length - p - 1);) ++p; if (1 == d.length && 1 == h.length && t == a.line) for (; f && f > a.ch && y.charCodeAt(y.length - p - 1) == b.charCodeAt(b.length - p - 1);) f--, p++; d[d.length - 1] = y.slice(0, y.length - p).replace(/^\u200b+/, ""), d[0] = d[0].slice(f).replace(/\u200b+$/, ""); var w = et(t, f), _ = et(l, h.length ? $(h).length - p : 0); return d.length > 1 || d[0] || tt(w, _) ? (go(r.doc, d, w, _, "+input"), !0) : void 0 }, Ua.prototype.ensurePolled = function () { this.forceCompositionEnd() }, Ua.prototype.reset = function () { this.forceCompositionEnd() }, Ua.prototype.forceCompositionEnd = function () { this.composing && (clearTimeout(this.readDOMTimeout), this.composing = null, this.updateFromDOM(), this.div.blur(), this.div.focus()) }, Ua.prototype.readFromDOMSoon = function () { var e = this; null == this.readDOMTimeout && (this.readDOMTimeout = setTimeout((function () { if (e.readDOMTimeout = null, e.composing) { if (!e.composing.done) return; e.composing = null } e.updateFromDOM() }), 80)) }, Ua.prototype.updateFromDOM = function () { var e = this; !this.cm.isReadOnly() && this.pollContent() || Jr(this.cm, (function () { return dr(e.cm) })) }, Ua.prototype.setUneditable = function (e) { e.contentEditable = "false" }, Ua.prototype.onKeyPress = function (e) { 0 == e.charCode || this.composing || (e.preventDefault(), this.cm.isReadOnly() || ei(this.cm, Ba)(this.cm, String.fromCharCode(null == e.charCode ? e.keyCode : e.charCode), 0)) }, Ua.prototype.readOnlyChanged = function (e) { this.div.contentEditable = String("nocursor" != e) }, Ua.prototype.onContextMenu = function () {}, Ua.prototype.resetPosition = function () {}, Ua.prototype.needsContentAttribute = !0; var Va = function (e) { this.cm = e, this.prevInput = "", this.pollingFast = !1, this.polling = new F, this.hasSelection = !1, this.composing = null }; Va.prototype.init = function (e) { var t = this, n = this, r = this.cm; this.createField(e); var i = this.textarea; function o(e) { if (!ge(r, e)) { if (r.somethingSelected()) Aa({ lineWise: !1, text: r.getSelections() }); else { if (!r.options.lineWiseCopyCut) return; var t = Ia(r); Aa({ lineWise: !0, text: t.text }), "cut" == e.type ? r.setSelections(t.ranges, null, q) : (n.prevInput = "", i.value = t.text.join("\n"), I(i)) } "cut" == e.type && (r.state.cutIncoming = +new Date) } } e.wrapper.insertBefore(this.wrapper, e.wrapper.firstChild), g && (i.style.width = "0px"), de(i, "input", (function () { a && s >= 9 && t.hasSelection && (t.hasSelection = null), n.poll() })), de(i, "paste", (function (e) { ge(r, e) || Oa(e, r) || (r.state.pasteIncoming = +new Date, n.fastPoll()) })), de(i, "cut", o), de(i, "copy", o), de(e.scroller, "paste", (function (t) { if (!_n(e, t) && !ge(r, t)) { if (!i.dispatchEvent) return r.state.pasteIncoming = +new Date, void n.focus(); var o = new Event("paste"); o.clipboardData = t.clipboardData, i.dispatchEvent(o) } })), de(e.lineSpace, "selectstart", (function (t) { _n(e, t) || be(t) })), de(i, "compositionstart", (function () { var e = r.getCursor("from"); n.composing && n.composing.range.clear(), n.composing = { start: e, range: r.markText(e, r.getCursor("to"), { className: "CodeMirror-composing" }) } })), de(i, "compositionend", (function () { n.composing && (n.poll(), n.composing.range.clear(), n.composing = null) })) }, Va.prototype.createField = function (e) { this.wrapper = Pa(), this.textarea = this.wrapper.firstChild }, Va.prototype.screenReaderLabelChanged = function (e) { e ? this.textarea.setAttribute("aria-label", e) : this.textarea.removeAttribute("aria-label") }, Va.prototype.prepareSelection = function () { var e = this.cm, t = e.display, n = e.doc, r = vr(e); if (e.options.moveInputWithCursor) { var i = Gn(e, n.sel.primary().head, "div"), o = t.wrapper.getBoundingClientRect(), a = t.lineDiv.getBoundingClientRect(); r.teTop = Math.max(0, Math.min(t.wrapper.clientHeight - 10, i.top + a.top - o.top)), r.teLeft = Math.max(0, Math.min(t.wrapper.clientWidth - 10, i.left + a.left - o.left)) } return r }, Va.prototype.showSelection = function (e) { var t = this.cm.display; k(t.cursorDiv, e.cursors), k(t.selectionDiv, e.selection), null != e.teTop && (this.wrapper.style.top = e.teTop + "px", this.wrapper.style.left = e.teLeft + "px") }, Va.prototype.reset = function (e) { if (!this.contextMenuPending && !this.composing) { var t = this.cm; if (t.somethingSelected()) { this.prevInput = ""; var n = t.getSelection(); this.textarea.value = n, t.state.focused && I(this.textarea), a && s >= 9 && (this.hasSelection = n) } else e || (this.prevInput = this.textarea.value = "", a && s >= 9 && (this.hasSelection = null)) } }, Va.prototype.getField = function () { return this.textarea }, Va.prototype.supportsTouch = function () { return !1 }, Va.prototype.focus = function () { if ("nocursor" != this.cm.options.readOnly && (!v || B() != this.textarea)) try { this.textarea.focus() } catch (e) {} }, Va.prototype.blur = function () { this.textarea.blur() }, Va.prototype.resetPosition = function () { this.wrapper.style.top = this.wrapper.style.left = 0 }, Va.prototype.receivedFocus = function () { this.slowPoll() }, Va.prototype.slowPoll = function () { var e = this; this.pollingFast || this.polling.set(this.cm.options.pollInterval, (function () { e.poll(), e.cm.state.focused && e.slowPoll() })) }, Va.prototype.fastPoll = function () { var e = !1, t = this; t.pollingFast = !0, t.polling.set(20, (function n() { t.poll() || e ? (t.pollingFast = !1, t.slowPoll()) : (e = !0, t.polling.set(60, n)) })) }, Va.prototype.poll = function () { var e = this, t = this.cm, n = this.textarea, r = this.prevInput; if (this.contextMenuPending || !t.state.focused || Be(n) && !r && !this.composing || t.isReadOnly() || t.options.disableInput || t.state.keySeq) return !1; var i = n.value; if (i == r && !t.somethingSelected()) return !1; if (a && s >= 9 && this.hasSelection === i || y && /[\uf700-\uf7ff]/.test(i)) return t.display.input.reset(), !1; if (t.doc.sel == t.display.selForContextMenu) { var o = i.charCodeAt(0); if (8203 != o || r || (r = "​"), 8666 == o) return this.reset(), this.cm.execCommand("undo") } for (var l = 0, c = Math.min(r.length, i.length); l < c && r.charCodeAt(l) == i.charCodeAt(l);) ++l; return Jr(t, (function () { Ba(t, i.slice(l), r.length - l, null, e.composing ? "*compose" : null), i.length > 1e3 || i.indexOf("\n") > -1 ? n.value = e.prevInput = "" : e.prevInput = i, e.composing && (e.composing.range.clear(), e.composing.range = t.markText(e.composing.start, t.getCursor("to"), { className: "CodeMirror-composing" })) })), !0 }, Va.prototype.ensurePolled = function () { this.pollingFast && this.poll() && (this.pollingFast = !1) }, Va.prototype.onKeyPress = function () { a && s >= 9 && (this.hasSelection = null), this.fastPoll() }, Va.prototype.onContextMenu = function (e) { var t = this, n = t.cm, r = n.display, i = t.textarea; t.contextMenuPending && t.contextMenuPending(); var o = cr(n, e), c = r.scroller.scrollTop; if (o && !d) { n.options.resetSelectionOnContextMenu && -1 == n.doc.sel.contains(o) && ei(n, Ji)(n.doc, xi(o), q); var u, h = i.style.cssText, f = t.wrapper.style.cssText, p = t.wrapper.offsetParent.getBoundingClientRect(); if (t.wrapper.style.cssText = "position: static", i.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - p.top - 5) + "px; left: " + (e.clientX - p.left - 5) + "px;\n z-index: 1000; background: " + (a ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);", l && (u = window.scrollY), r.input.focus(), l && window.scrollTo(null, u), r.input.reset(), n.somethingSelected() || (i.value = t.prevInput = " "), t.contextMenuPending = v, r.selForContextMenu = n.doc.sel, clearTimeout(r.detectingSelectAll), a && s >= 9 && m(), T) { _e(e); var g = function () { fe(window, "mouseup", g), setTimeout(v, 20) }; de(window, "mouseup", g) } else setTimeout(v, 50) } function m() { if (null != i.selectionStart) { var e = n.somethingSelected(), o = "​" + (e ? i.value : ""); i.value = "⇚", i.value = o, t.prevInput = e ? "" : "​", i.selectionStart = 1, i.selectionEnd = o.length, r.selForContextMenu = n.doc.sel } } function v() { if (t.contextMenuPending == v && (t.contextMenuPending = !1, t.wrapper.style.cssText = f, i.style.cssText = h, a && s < 9 && r.scrollbars.setScrollTop(r.scroller.scrollTop = c), null != i.selectionStart)) { (!a || a && s < 9) && m(); var e = 0, o = function () { r.selForContextMenu == n.doc.sel && 0 == i.selectionStart && i.selectionEnd > 0 && "​" == t.prevInput ? ei(n, so)(n) : e++ < 10 ? r.detectingSelectAll = setTimeout(o, 500) : (r.selForContextMenu = null, r.input.reset()) }; r.detectingSelectAll = setTimeout(o, 200) } } }, Va.prototype.readOnlyChanged = function (e) { e || this.reset(), this.textarea.disabled = "nocursor" == e, this.textarea.readOnly = !!e }, Va.prototype.setUneditable = function () {}, Va.prototype.needsContentAttribute = !1, function (e) { var t = e.optionHandlers; function n(n, r, i, o) { e.defaults[n] = r, i && (t[n] = o ? function (e, t, n) { n != _a && i(e, t, n) } : i) } e.defineOption = n, e.Init = _a, n("value", "", (function (e, t) { return e.setValue(t) }), !0), n("mode", null, (function (e, t) { e.doc.modeOption = t, Mi(e) }), !0), n("indentUnit", 2, Mi, !0), n("indentWithTabs", !1), n("smartIndent", !0), n("tabSize", 4, (function (e) { Ai(e), Un(e), dr(e) }), !0), n("lineSeparator", null, (function (e, t) { if (e.doc.lineSep = t, t) { var n = [], r = e.doc.first; e.doc.iter((function (e) { for (var i = 0;;) { var o = e.text.indexOf(t, i); if (-1 == o) break; i = o + t.length, n.push(et(r, o)) } r++ })); for (var i = n.length - 1; i >= 0; i--) go(e.doc, t, n[i], et(n[i].line, n[i].ch + t.length)) } })), n("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, (function (e, t, n) { e.state.specialChars = new RegExp(t.source + (t.test("\t") ? "" : "|\t"), "g"), n != _a && e.refresh() })), n("specialCharPlaceholder", Qt, (function (e) { return e.refresh() }), !0), n("electricChars", !0), n("inputStyle", v ? "contenteditable" : "textarea", (function () { throw new Error("inputStyle can not (yet) be changed in a running editor") }), !0), n("spellcheck", !1, (function (e, t) { return e.getInputField().spellcheck = t }), !0), n("autocorrect", !1, (function (e, t) { return e.getInputField().autocorrect = t }), !0), n("autocapitalize", !1, (function (e, t) { return e.getInputField().autocapitalize = t }), !0), n("rtlMoveVisually", !C), n("wholeLineUpdateBefore", !0), n("theme", "default", (function (e) { wa(e), gi(e) }), !0), n("keyMap", "default", (function (e, t, n) { var r = Xo(t), i = n != _a && Xo(n); i && i.detach && i.detach(e, r), r.attach && r.attach(e, i || null) })), n("extraKeys", null), n("configureMouse", null), n("lineWrapping", !1, Sa, !0), n("gutters", [], (function (e, t) { e.display.gutterSpecs = fi(t, e.options.lineNumbers), gi(e) }), !0), n("fixedGutter", !0, (function (e, t) { e.display.gutters.style.left = t ? ar(e.display) + "px" : "0", e.refresh() }), !0), n("coverGutterNextToScrollbar", !1, (function (e) { return Wr(e) }), !0), n("scrollbarStyle", "native", (function (e) { jr(e), Wr(e), e.display.scrollbars.setScrollTop(e.doc.scrollTop), e.display.scrollbars.setScrollLeft(e.doc.scrollLeft) }), !0), n("lineNumbers", !1, (function (e, t) { e.display.gutterSpecs = fi(e.options.gutters, t), gi(e) }), !0), n("firstLineNumber", 1, gi, !0), n("lineNumberFormatter", (function (e) { return e }), gi, !0), n("showCursorWhenSelecting", !1, mr, !0), n("resetSelectionOnContextMenu", !0), n("lineWiseCopyCut", !0), n("pasteLinesPerSelection", !0), n("selectionsMayTouch", !1), n("readOnly", !1, (function (e, t) { "nocursor" == t && (xr(e), e.display.input.blur()), e.display.input.readOnlyChanged(t) })), n("screenReaderLabel", null, (function (e, t) { t = "" === t ? null : t, e.display.input.screenReaderLabelChanged(t) })), n("disableInput", !1, (function (e, t) { t || e.display.input.reset() }), !0), n("dragDrop", !0, xa), n("allowDropFileTypes", null), n("cursorBlinkRate", 530), n("cursorScrollMargin", 0), n("cursorHeight", 1, mr, !0), n("singleCursorHeightPerLine", !0, mr, !0), n("workTime", 100), n("workDelay", 100), n("flattenSpans", !0, Ai, !0), n("addModeClass", !1, Ai, !0), n("pollInterval", 100), n("undoDepth", 200, (function (e, t) { return e.doc.history.undoDepth = t })), n("historyEventDelay", 1250), n("viewportMargin", 10, (function (e) { return e.refresh() }), !0), n("maxHighlightLength", 1e4, Ai, !0), n("moveInputWithCursor", !0, (function (e, t) { t || e.display.input.resetPosition() })), n("tabindex", null, (function (e, t) { return e.display.input.getField().tabIndex = t || "" })), n("autofocus", null), n("direction", "ltr", (function (e, t) { return e.doc.setDirection(t) }), !0), n("phrases", null) }(Na), function (e) { var t = e.optionHandlers, n = e.helpers = {}; e.prototype = { constructor: e, focus: function () { window.focus(), this.display.input.focus() }, setOption: function (e, n) { var r = this.options, i = r[e]; r[e] == n && "mode" != e || (r[e] = n, t.hasOwnProperty(e) && ei(this, t[e])(this, n, i), pe(this, "optionChange", this, e)) }, getOption: function (e) { return this.options[e] }, getDoc: function () { return this.doc }, addKeyMap: function (e, t) { this.state.keyMaps[t ? "push" : "unshift"](Xo(e)) }, removeKeyMap: function (e) { for (var t = this.state.keyMaps, n = 0; n < t.length; ++n) if (t[n] == e || t[n].name == e) return t.splice(n, 1), !0 }, addOverlay: ti((function (t, n) { var r = t.token ? t : e.getMode(this.options, t); if (r.startState) throw new Error("Overlays may not be stateful."); ! function (e, t, n) { for (var r = 0, i = n(t); r < e.length && n(e[r]) <= i;) r++; e.splice(r, 0, t) }(this.state.overlays, { mode: r, modeSpec: t, opaque: n && n.opaque, priority: n && n.priority || 0 }, (function (e) { return e.priority })), this.state.modeGen++, dr(this) })), removeOverlay: ti((function (e) { for (var t = this.state.overlays, n = 0; n < t.length; ++n) { var r = t[n].modeSpec; if (r == e || "string" == typeof e && r.name == e) return t.splice(n, 1), this.state.modeGen++, void dr(this) } })), indentLine: ti((function (e, t, n) { "string" != typeof t && "number" != typeof t && (t = null == t ? this.options.smartIndent ? "smart" : "prev" : t ? "add" : "subtract"), Qe(this.doc, e) && La(this, e, t, n) })), indentSelection: ti((function (e) { for (var t = this.doc.sel.ranges, n = -1, r = 0; r < t.length; r++) { var i = t[r]; if (i.empty()) i.head.line > n && (La(this, i.head.line, e, !0), n = i.head.line, r == this.doc.sel.primIndex && Ar(this)); else { var o = i.from(), a = i.to(), s = Math.max(n, o.line); n = Math.min(this.lastLine(), a.line - (a.ch ? 0 : 1)) + 1; for (var l = s; l < n; ++l) La(this, l, e); var c = this.doc.sel.ranges; 0 == o.ch && t.length == c.length && c[r].from().ch > 0 && Xi(this.doc, r, new Ti(o, c[r].to()), q) } } })), getTokenAt: function (e, t) { return yt(this, e, t) }, getLineTokens: function (e, t) { return yt(this, et(e), t, !0) }, getTokenTypeAt: function (e) { e = st(this.doc, e); var t, n = ht(this, Ke(this.doc, e.line)), r = 0, i = (n.length - 1) / 2, o = e.ch; if (0 == o) t = n[2]; else for (;;) { var a = r + i >> 1; if ((a ? n[2 * a - 1] : 0) >= o) i = a; else { if (!(n[2 * a + 1] < o)) { t = n[2 * a + 2]; break } r = a + 1 } } var s = t ? t.indexOf("overlay ") : -1; return s < 0 ? t : 0 == s ? null : t.slice(0, s - 1) }, getModeAt: function (t) { var n = this.doc.mode; return n.innerMode ? e.innerMode(n, this.getTokenAt(t).state).mode : n }, getHelper: function (e, t) { return this.getHelpers(e, t)[0] }, getHelpers: function (e, t) { var r = []; if (!n.hasOwnProperty(t)) return r; var i = n[t], o = this.getModeAt(e); if ("string" == typeof o[t]) i[o[t]] && r.push(i[o[t]]); else if (o[t]) for (var a = 0; a < o[t].length; a++) { var s = i[o[t][a]]; s && r.push(s) } else o.helperType && i[o.helperType] ? r.push(i[o.helperType]) : i[o.name] && r.push(i[o.name]); for (var l = 0; l < i._global.length; l++) { var c = i._global[l]; c.pred(o, this) && -1 == U(r, c.val) && r.push(c.val) } return r }, getStateAfter: function (e, t) { var n = this.doc; return ft(this, (e = at(n, null == e ? n.first + n.size - 1 : e)) + 1, t).state }, cursorCoords: function (e, t) { var n = this.doc.sel.primary(); return Gn(this, null == e ? n.head : "object" == typeof e ? st(this.doc, e) : e ? n.from() : n.to(), t || "page") }, charCoords: function (e, t) { return Kn(this, st(this.doc, e), t || "page") }, coordsChar: function (e, t) { return Xn(this, (e = Vn(this, e, t || "page")).left, e.top) }, lineAtHeight: function (e, t) { return e = Vn(this, { top: e, left: 0 }, t || "page").top, Ze(this.doc, e + this.display.viewOffset) }, heightAtLine: function (e, t, n) { var r, i = !1; if ("number" == typeof e) { var o = this.doc.first + this.doc.size - 1; e < this.doc.first ? e = this.doc.first : e > o && (e = o, i = !0), r = Ke(this.doc, e) } else r = e; return jn(this, r, { top: 0, left: 0 }, t || "page", n || i).top + (i ? this.doc.height - zt(r) : 0) }, defaultTextHeight: function () { return rr(this.display) }, defaultCharWidth: function () { return ir(this.display) }, getViewport: function () { return { from: this.display.viewFrom, to: this.display.viewTo } }, addWidget: function (e, t, n, r, i) { var o, a, s, l = this.display, c = (e = Gn(this, st(this.doc, e))).bottom, u = e.left; if (t.style.position = "absolute", t.setAttribute("cm-ignore-events", "true"), this.display.input.setUneditable(t), l.sizer.appendChild(t), "over" == r) c = e.top; else if ("above" == r || "near" == r) { var d = Math.max(l.wrapper.clientHeight, this.doc.height), h = Math.max(l.sizer.clientWidth, l.lineSpace.clientWidth); ("above" == r || e.bottom + t.offsetHeight > d) && e.top > t.offsetHeight ? c = e.top - t.offsetHeight : e.bottom + t.offsetHeight <= d && (c = e.bottom), u + t.offsetWidth > h && (u = h - t.offsetWidth) } t.style.top = c + "px", t.style.left = t.style.right = "", "right" == i ? (u = l.sizer.clientWidth - t.offsetWidth, t.style.right = "0px") : ("left" == i ? u = 0 : "middle" == i && (u = (l.sizer.clientWidth - t.offsetWidth) / 2), t.style.left = u + "px"), n && (o = this, a = { left: u, top: c, right: u + t.offsetWidth, bottom: c + t.offsetHeight }, null != (s = Lr(o, a)).scrollTop && Ir(o, s.scrollTop), null != s.scrollLeft && Pr(o, s.scrollLeft)) }, triggerOnKeyDown: ti(ua), triggerOnKeyPress: ti(ha), triggerOnKeyUp: da, triggerOnMouseDown: ti(ma), execCommand: function (e) { if (ta.hasOwnProperty(e)) return ta[e].call(null, this) }, triggerElectric: ti((function (e) { Da(this, e) })), findPosH: function (e, t, n, r) { var i = 1; t < 0 && (i = -1, t = -t); for (var o = st(this.doc, e), a = 0; a < t && !(o = Ha(this.doc, o, i, n, r)).hitSide; ++a); return o }, moveH: ti((function (e, t) { var n = this; this.extendSelectionsBy((function (r) { return n.display.shift || n.doc.extend || r.empty() ? Ha(n.doc, r.head, e, t, n.options.rtlMoveVisually) : e < 0 ? r.from() : r.to() }), j) })), deleteH: ti((function (e, t) { var n = this.doc.sel, r = this.doc; n.somethingSelected() ? r.replaceSelection("", null, "+delete") : Zo(this, (function (n) { var i = Ha(r, n.head, e, t, !1); return e < 0 ? { from: i, to: n.head } : { from: n.head, to: i } })) })), findPosV: function (e, t, n, r) { var i = 1, o = r; t < 0 && (i = -1, t = -t); for (var a = st(this.doc, e), s = 0; s < t; ++s) { var l = Gn(this, a, "div"); if (null == o ? o = l.left : l.left = o, (a = Fa(this, l, i, n)).hitSide) break } return a }, moveV: ti((function (e, t) { var n = this, r = this.doc, i = [], o = !this.display.shift && !r.extend && r.sel.somethingSelected(); if (r.extendSelectionsBy((function (a) { if (o) return e < 0 ? a.from() : a.to(); var s = Gn(n, a.head, "div"); null != a.goalColumn && (s.left = a.goalColumn), i.push(s.left); var l = Fa(n, s, e, t); return "page" == t && a == r.sel.primary() && Mr(n, Kn(n, l, "div").top - s.top), l }), j), i.length) for (var a = 0; a < r.sel.ranges.length; a++) r.sel.ranges[a].goalColumn = i[a] })), findWordAt: function (e) { var t = Ke(this.doc, e.line).text, n = e.ch, r = e.ch; if (t) { var i = this.getHelper(e, "wordChars"); "before" != e.sticky && r != t.length || !n ? ++r : --n; for (var o = t.charAt(n), a = ee(o, i) ? function (e) { return ee(e, i) } : /\s/.test(o) ? function (e) { return /\s/.test(e) } : function (e) { return !/\s/.test(e) && !ee(e) }; n > 0 && a(t.charAt(n - 1));) --n; for (; r < t.length && a(t.charAt(r));) ++r } return new Ti(et(e.line, n), et(e.line, r)) }, toggleOverwrite: function (e) { null != e && e == this.state.overwrite || ((this.state.overwrite = !this.state.overwrite) ? O(this.display.cursorDiv, "CodeMirror-overwrite") : S(this.display.cursorDiv, "CodeMirror-overwrite"), pe(this, "overwriteToggle", this, this.state.overwrite)) }, hasFocus: function () { return this.display.input.getField() == B() }, isReadOnly: function () { return !(!this.options.readOnly && !this.doc.cantEdit) }, scrollTo: ti((function (e, t) { Br(this, e, t) })), getScrollInfo: function () { var e = this.display.scroller; return { left: e.scrollLeft, top: e.scrollTop, height: e.scrollHeight - Sn(this) - this.display.barHeight, width: e.scrollWidth - Sn(this) - this.display.barWidth, clientHeight: kn(this), clientWidth: Nn(this) } }, scrollIntoView: ti((function (e, t) { null == e ? (e = { from: this.doc.sel.primary().head, to: null }, null == t && (t = this.options.cursorScrollMargin)) : "number" == typeof e ? e = { from: et(e, 0), to: null } : null == e.from && (e = { from: e, to: null }), e.to || (e.to = e.from), e.margin = t || 0, null != e.from.line ? function (e, t) { Or(e), e.curOp.scrollToPos = t }(this, e) : Dr(this, e.from, e.to, e.margin) })), setSize: ti((function (e, t) { var n = this, r = function (e) { return "number" == typeof e || /^\d+$/.test(String(e)) ? e + "px" : e }; null != e && (this.display.wrapper.style.width = r(e)), null != t && (this.display.wrapper.style.height = r(t)), this.options.lineWrapping && Fn(this); var i = this.display.viewFrom; this.doc.iter(i, this.display.viewTo, (function (e) { if (e.widgets) for (var t = 0; t < e.widgets.length; t++) if (e.widgets[t].noHScroll) { hr(n, i, "widget"); break }++ i })), this.curOp.forceUpdate = !0, pe(this, "refresh", this) })), operation: function (e) { return Jr(this, e) }, startOperation: function () { return Kr(this) }, endOperation: function () { return Gr(this) }, refresh: ti((function () { var e = this.display.cachedTextHeight; dr(this), this.curOp.forceUpdate = !0, Un(this), Br(this, this.doc.scrollLeft, this.doc.scrollTop), ci(this.display), (null == e || Math.abs(e - rr(this.display)) > .5 || this.options.lineWrapping) && lr(this), pe(this, "refresh", this) })), swapDoc: ti((function (e) { var t = this.doc; return t.cm = null, this.state.selectingText && this.state.selectingText(), Ii(this, e), Un(this), this.display.input.reset(), Br(this, e.scrollLeft, e.scrollTop), this.curOp.forceScroll = !0, ln(this, "swapDoc", this, t), t })), phrase: function (e) { var t = this.options.phrases; return t && Object.prototype.hasOwnProperty.call(t, e) ? t[e] : e }, getInputField: function () { return this.display.input.getField() }, getWrapperElement: function () { return this.display.wrapper }, getScrollerElement: function () { return this.display.scroller }, getGutterElement: function () { return this.display.gutters } }, ye(e), e.registerHelper = function (t, r, i) { n.hasOwnProperty(t) || (n[t] = e[t] = { _global: [] }), n[t][r] = i }, e.registerGlobalHelper = function (t, r, i, o) { e.registerHelper(t, r, o), n[t]._global.push({ pred: i, val: o }) } }(Na); var Ka = "iter insert remove copy getEditor constructor".split(" "); for (var Ga in Ao.prototype) Ao.prototype.hasOwnProperty(Ga) && U(Ka, Ga) < 0 && (Na.prototype[Ga] = function (e) { return function () { return e.apply(this.doc, arguments) } }(Ao.prototype[Ga])); return ye(Ao), Na.inputStyles = { textarea: Va, contenteditable: Ua }, Na.defineMode = function (e) { Na.defaults.mode || "null" == e || (Na.defaults.mode = e), Pe.apply(this, arguments) }, Na.defineMIME = function (e, t) { Re[e] = t }, Na.defineMode("null", (function () { return { token: function (e) { return e.skipToEnd() } } })), Na.defineMIME("text/plain", "null"), Na.defineExtension = function (e, t) { Na.prototype[e] = t }, Na.defineDocExtension = function (e, t) { Ao.prototype[e] = t }, Na.fromTextArea = function (e, t) { if ((t = t ? P(t) : {}).value = e.value, !t.tabindex && e.tabIndex && (t.tabindex = e.tabIndex), !t.placeholder && e.placeholder && (t.placeholder = e.placeholder), null == t.autofocus) { var n = B(); t.autofocus = n == e || null != e.getAttribute("autofocus") && n == document.body } function r() { e.value = s.getValue() } var i; if (e.form && (de(e.form, "submit", r), !t.leaveSubmitMethodAlone)) { var o = e.form; i = o.submit; try { var a = o.submit = function () { r(), o.submit = i, o.submit(), o.submit = a } } catch (e) {} } t.finishInit = function (n) { n.save = r, n.getTextArea = function () { return e }, n.toTextArea = function () { n.toTextArea = isNaN, r(), e.parentNode.removeChild(n.getWrapperElement()), e.style.display = "", e.form && (fe(e.form, "submit", r), t.leaveSubmitMethodAlone || "function" != typeof e.form.submit || (e.form.submit = i)) } }, e.style.display = "none"; var s = Na((function (t) { return e.parentNode.insertBefore(t, e.nextSibling) }), t); return s }, function (e) { e.off = fe, e.on = de, e.wheelEventPixels = Ci, e.Doc = Ao, e.splitLines = Ae, e.countColumn = H, e.findColumn = V, e.isWordChar = J, e.Pass = W, e.signal = pe, e.Line = Kt, e.changeEnd = Si, e.scrollbarModel = zr, e.Pos = et, e.cmpPos = tt, e.modes = Ie, e.mimeModes = Re, e.resolveMode = He, e.getMode = Fe, e.modeExtensions = Ue, e.extendMode = We, e.copyState = qe, e.startState = je, e.innerMode = ze, e.commands = ta, e.keyMap = zo, e.keyName = Yo, e.isModifierKey = Go, e.lookupKey = Ko, e.normalizeKeyMap = Vo, e.StringStream = Ve, e.SharedTextMarker = No, e.TextMarker = xo, e.LineWidget = _o, e.e_preventDefault = be, e.e_stopPropagation = Ce, e.e_stop = _e, e.addClass = O, e.contains = A, e.rmClass = S, e.keyNames = Fo }(Na), Na.version = "5.58.3", Na }() }, function (e, t, n) { "use strict"; e.exports = function (e, t, n) { var r; for (r in n = n || null, e) if (e.hasOwnProperty(r) && !1 === t.call(n, e[r], r, e)) break } }, function (e, t, n) { "use strict"; var r = n(12), i = n(1), o = Element.prototype, a = o.matches || o.webkitMatchesSelector || o.mozMatchesSelector || o.msMatchesSelector || function (e) { var t = this.document || this.ownerDocument; return r(this, i(t.querySelectorAll(e))) > -1 }; e.exports = function (e, t) { return a.call(e, t) } }, function (e, t, n) { "use strict"; e.exports = function (e) { return void 0 === e } }, function (e, t, n) { "use strict"; var r = n(12), i = n(24); e.exports = function (e, t) { var n; return e.classList ? e.classList.contains(t) : (n = i(e).split(/\s+/), r(t, n) > -1) } }, function (e, t, n) { "use strict"; e.exports = function (e) { return "string" == typeof e || e instanceof String } }, function (e, t, n) { "use strict"; var r = n(15); e.exports = function (e, t, n) { var i, o; if (n = n || 0, !r(t)) return -1; if (Array.prototype.indexOf) return Array.prototype.indexOf.call(t, e, n); for (o = t.length, i = n; n >= 0 && i < o; i += 1) if (t[i] === e) return i; return -1 } }, function (e, t, n) { "use strict"; var r = n(11), i = n(20), o = n(29); function a(e, t, n, r) { function a(t) { n.call(r || e, t || window.event) } "addEventListener" in e ? e.addEventListener(t, a) : "attachEvent" in e && e.attachEvent("on" + t, a), function (e, t, n, r) { var a = o(e, t), s = !1; i(a, (function (e) { return e.handler !== n || (s = !0, !1) })), s || a.push({ handler: n, wrappedHandler: r }) }(e, t, n, a) } e.exports = function (e, t, n, o) { r(t) ? i(t.split(/\s+/g), (function (t) { a(e, t, n, o) })) : i(t, (function (t, r) { a(e, r, t, n) })) } }, function (e, t, n) { "use strict"; var r = n(11), i = n(20), o = n(29); function a(e, t, n) { var r, a = o(e, t); n ? (i(a, (function (i, o) { return n !== i.handler || (s(e, t, i.wrappedHandler), r = o, !1) })), a.splice(r, 1)) : (i(a, (function (n) { s(e, t, n.wrappedHandler) })), a.splice(0, a.length)) } function s(e, t, n) { "removeEventListener" in e ? e.removeEventListener(t, n) : "detachEvent" in e && e.detachEvent("on" + t, n) } e.exports = function (e, t, n) { r(t) ? i(t.split(/\s+/g), (function (t) { a(e, t, n) })) : i(t, (function (t, n) { a(e, n, t) })) } }, function (e, t, n) { "use strict"; e.exports = function (e) { return e instanceof Array } }, function (e, t, n) { "use strict"; e.exports = function (e, t, n) { var r = 0, i = e.length; for (n = n || null; r < i && !1 !== t.call(n, e[r], r, e); r += 1); } }, function (e, t) { ! function (e, t) { for (var n in t) e[n] = t[n] }(t, function (e) { var t = {}; function n(r) { if (t[r]) return t[r].exports; var i = t[r] = { i: r, l: !1, exports: {} }; return e[r].call(i.exports, i, i.exports, n), i.l = !0, i.exports } return n.m = e, n.c = t, n.d = function (e, t, r) { n.o(e, t) || Object.defineProperty(e, t, { enumerable: !0, get: r }) }, n.r = function (e) { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e, "__esModule", { value: !0 }) }, n.t = function (e, t) { if (1 & t && (e = n(e)), 8 & t) return e; if (4 & t && "object" == typeof e && e && e.__esModule) return e; var r = Object.create(null); if (n.r(r), Object.defineProperty(r, "default", { enumerable: !0, value: e }), 2 & t && "string" != typeof e) for (var i in e) n.d(r, i, function (t) { return e[t] }.bind(null, i)); return r }, n.n = function (e) { var t = e && e.__esModule ? function () { return e.default } : function () { return e }; return n.d(t, "a", t), t }, n.o = function (e, t) { return Object.prototype.hasOwnProperty.call(e, t) }, n.p = "/dist", n(n.s = 11) }([function (e, t, n) { "use strict"; n.r(t), n.d(t, "__extends", (function () { return i })), n.d(t, "__assign", (function () { return o })), n.d(t, "__rest", (function () { return a })), n.d(t, "__decorate", (function () { return s })), n.d(t, "__param", (function () { return l })), n.d(t, "__metadata", (function () { return c })), n.d(t, "__awaiter", (function () { return u })), n.d(t, "__generator", (function () { return d })), n.d(t, "__createBinding", (function () { return h })), n.d(t, "__exportStar", (function () { return f })), n.d(t, "__values", (function () { return p })), n.d(t, "__read", (function () { return g })), n.d(t, "__spread", (function () { return m })), n.d(t, "__spreadArrays", (function () { return v })), n.d(t, "__await", (function () { return y })), n.d(t, "__asyncGenerator", (function () { return b })), n.d(t, "__asyncDelegator", (function () { return C })), n.d(t, "__asyncValues", (function () { return w })), n.d(t, "__makeTemplateObject", (function () { return _ })), n.d(t, "__importStar", (function () { return T })), n.d(t, "__importDefault", (function () { return E })), n.d(t, "__classPrivateFieldGet", (function () { return x })), n.d(t, "__classPrivateFieldSet", (function () { return S })); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ var r = function (e, t) { return (r = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (e, t) { e.__proto__ = t } || function (e, t) { for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]) })(e, t) }; function i(e, t) { function n() { this.constructor = e } r(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, new n) } var o = function () { return (o = Object.assign || function (e) { for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]); return e }).apply(this, arguments) }; function a(e, t) { var n = {}; for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]); if (null != e && "function" == typeof Object.getOwnPropertySymbols) { var i = 0; for (r = Object.getOwnPropertySymbols(e); i < r.length; i++) t.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[i]) && (n[r[i]] = e[r[i]]) } return n } function s(e, t, n, r) { var i, o = arguments.length, a = o < 3 ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, n) : r; if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) a = Reflect.decorate(e, t, n, r); else for (var s = e.length - 1; s >= 0; s--)(i = e[s]) && (a = (o < 3 ? i(a) : o > 3 ? i(t, n, a) : i(t, n)) || a); return o > 3 && a && Object.defineProperty(t, n, a), a } function l(e, t) { return function (n, r) { t(n, r, e) } } function c(e, t) { if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(e, t) } function u(e, t, n, r) { return new(n || (n = Promise))((function (i, o) { function a(e) { try { l(r.next(e)) } catch (e) { o(e) } } function s(e) { try { l(r.throw(e)) } catch (e) { o(e) } } function l(e) { var t; e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n((function (e) { e(t) }))).then(a, s) } l((r = r.apply(e, t || [])).next()) })) } function d(e, t) { var n, r, i, o, a = { label: 0, sent: function () { if (1 & i[0]) throw i[1]; return i[1] }, trys: [], ops: [] }; return o = { next: s(0), throw: s(1), return: s(2) }, "function" == typeof Symbol && (o[Symbol.iterator] = function () { return this }), o; function s(o) { return function (s) { return function (o) { if (n) throw new TypeError("Generator is already executing."); for (; a;) try { if (n = 1, r && (i = 2 & o[0] ? r.return : o[0] ? r.throw || ((i = r.return) && i.call(r), 0) : r.next) && !(i = i.call(r, o[1])).done) return i; switch (r = 0, i && (o = [2 & o[0], i.value]), o[0]) { case 0: case 1: i = o; break; case 4: return a.label++, { value: o[1], done: !1 }; case 5: a.label++, r = o[1], o = [0]; continue; case 7: o = a.ops.pop(), a.trys.pop(); continue; default: if (!((i = (i = a.trys).length > 0 && i[i.length - 1]) || 6 !== o[0] && 2 !== o[0])) { a = 0; continue } if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) { a.label = o[1]; break } if (6 === o[0] && a.label < i[1]) { a.label = i[1], i = o; break } if (i && a.label < i[2]) { a.label = i[2], a.ops.push(o); break } i[2] && a.ops.pop(), a.trys.pop(); continue } o = t.call(e, a) } catch (e) { o = [6, e], r = 0 } finally { n = i = 0 } if (5 & o[0]) throw o[1]; return { value: o[0] ? o[1] : void 0, done: !0 } }([o, s]) } } } function h(e, t, n, r) { void 0 === r && (r = n), e[r] = t[n] } function f(e, t) { for (var n in e) "default" === n || t.hasOwnProperty(n) || (t[n] = e[n]) } function p(e) { var t = "function" == typeof Symbol && Symbol.iterator, n = t && e[t], r = 0; if (n) return n.call(e); if (e && "number" == typeof e.length) return { next: function () { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e } } }; throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.") } function g(e, t) { var n = "function" == typeof Symbol && e[Symbol.iterator]; if (!n) return e; var r, i, o = n.call(e), a = []; try { for (; (void 0 === t || t-- > 0) && !(r = o.next()).done;) a.push(r.value) } catch (e) { i = { error: e } } finally { try { r && !r.done && (n = o.return) && n.call(o) } finally { if (i) throw i.error } } return a } function m() { for (var e = [], t = 0; t < arguments.length; t++) e = e.concat(g(arguments[t])); return e } function v() { for (var e = 0, t = 0, n = arguments.length; t < n; t++) e += arguments[t].length; var r = Array(e), i = 0; for (t = 0; t < n; t++) for (var o = arguments[t], a = 0, s = o.length; a < s; a++, i++) r[i] = o[a]; return r } function y(e) { return this instanceof y ? (this.v = e, this) : new y(e) } function b(e, t, n) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var r, i = n.apply(e, t || []), o = []; return r = {}, a("next"), a("throw"), a("return"), r[Symbol.asyncIterator] = function () { return this }, r; function a(e) { i[e] && (r[e] = function (t) { return new Promise((function (n, r) { o.push([e, t, n, r]) > 1 || s(e, t) })) }) } function s(e, t) { try { (n = i[e](t)).value instanceof y ? Promise.resolve(n.value.v).then(l, c) : u(o[0][2], n) } catch (e) { u(o[0][3], e) } var n } function l(e) { s("next", e) } function c(e) { s("throw", e) } function u(e, t) { e(t), o.shift(), o.length && s(o[0][0], o[0][1]) } } function C(e) { var t, n; return t = {}, r("next"), r("throw", (function (e) { throw e })), r("return"), t[Symbol.iterator] = function () { return this }, t; function r(r, i) { t[r] = e[r] ? function (t) { return (n = !n) ? { value: y(e[r](t)), done: "return" === r } : i ? i(t) : t } : i } } function w(e) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var t, n = e[Symbol.asyncIterator]; return n ? n.call(e) : (e = p(e), t = {}, r("next"), r("throw"), r("return"), t[Symbol.asyncIterator] = function () { return this }, t); function r(n) { t[n] = e[n] && function (t) { return new Promise((function (r, i) { ! function (e, t, n, r) { Promise.resolve(r).then((function (t) { e({ value: t, done: n }) }), t) }(r, i, (t = e[n](t)).done, t.value) })) } } } function _(e, t) { return Object.defineProperty ? Object.defineProperty(e, "raw", { value: t }) : e.raw = t, e } function T(e) { if (e && e.__esModule) return e; var t = {}; if (null != e) for (var n in e) Object.hasOwnProperty.call(e, n) && (t[n] = e[n]); return t.default = e, t } function E(e) { return e && e.__esModule ? e : { default: e } } function x(e, t) { if (!t.has(e)) throw new TypeError("attempted to get private field on non-instance"); return t.get(e) } function S(e, t, n) { if (!t.has(e)) throw new TypeError("attempted to set private field on non-instance"); return t.set(e, n), n } }, function (e, t, n) { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.text = t.isRefDef = t.isTable = t.isList = t.isHeading = t.isHtmlBlock = t.isCodeBlock = t.createNode = t.RefDefNode = t.TableCellNode = t.TableNode = t.CodeNode = t.HtmlBlockNode = t.CodeBlockNode = t.LinkNode = t.HeadingNode = t.ListNode = t.BlockNode = t.Node = t.removeAllNode = t.removeNodeById = t.getNodeById = t.isContainer = void 0; var r = n(0), i = r.__importDefault(n(18)); function o(e) { switch (e.type) { case "document": case "blockQuote": case "list": case "item": case "paragraph": case "heading": case "emph": case "strong": case "strike": case "link": case "image": case "table": case "tableHead": case "tableBody": case "tableRow": case "tableCell": case "tableDelimRow": return !0; default: return !1 } } t.isContainer = o; var a = 1, s = {}; t.getNodeById = function (e) { return s[e] }, t.removeNodeById = function (e) { delete s[e] }, t.removeAllNode = function () { s = {} }; var l = function () { function e(e, t) { this.parent = null, this.prev = null, this.next = null, this.firstChild = null, this.lastChild = null, this.literal = null, this.id = "document" === e ? -1 : a++, this.type = e, this.sourcepos = t, s[this.id] = this } return e.prototype.isContainer = function () { return o(this) }, e.prototype.unlink = function () { this.prev ? this.prev.next = this.next : this.parent && (this.parent.firstChild = this.next), this.next ? this.next.prev = this.prev : this.parent && (this.parent.lastChild = this.prev), this.parent = null, this.next = null, this.prev = null }, e.prototype.replaceWith = function (e) { this.insertBefore(e), this.unlink() }, e.prototype.insertAfter = function (e) { e.unlink(), e.next = this.next, e.next && (e.next.prev = e), e.prev = this, this.next = e, this.parent && (e.parent = this.parent, e.next || (e.parent.lastChild = e)) }, e.prototype.insertBefore = function (e) { e.unlink(), e.prev = this.prev, e.prev && (e.prev.next = e), e.next = this, this.prev = e, e.parent = this.parent, e.prev || (e.parent.firstChild = e) }, e.prototype.appendChild = function (e) { e.unlink(), e.parent = this, this.lastChild ? (this.lastChild.next = e, e.prev = this.lastChild, this.lastChild = e) : (this.firstChild = e, this.lastChild = e) }, e.prototype.prependChild = function (e) { e.unlink(), e.parent = this, this.firstChild ? (this.firstChild.prev = e, e.next = this.firstChild, this.firstChild = e) : (this.firstChild = e, this.lastChild = e) }, e.prototype.walker = function () { return new i.default(this) }, e }(); t.Node = l; var c = function (e) { function t(t, n) { var r = e.call(this, t, n) || this; return r.open = !0, r.lineOffsets = null, r.stringContent = null, r.lastLineBlank = !1, r.lastLineChecked = !1, r.customType = null, r.type = t, r } return r.__extends(t, e), t }(l); t.BlockNode = c; var u = function (e) { function t() { var t = null !== e && e.apply(this, arguments) || this; return t.listData = null, t } return r.__extends(t, e), t }(c); t.ListNode = u; var d = function (e) { function t() { var t = null !== e && e.apply(this, arguments) || this; return t.level = 0, t.headingType = "atx", t } return r.__extends(t, e), t }(c); t.HeadingNode = d; var h = function (e) { function t() { var t = null !== e && e.apply(this, arguments) || this; return t.destination = null, t.title = null, t.extendedAutolink = !1, t } return r.__extends(t, e), t }(l); t.LinkNode = h; var f = function (e) { function t() { var t = null !== e && e.apply(this, arguments) || this; return t.isFenced = !1, t.fenceChar = null, t.fenceLength = 0, t.fenceOffset = -1, t.info = null, t.infoPadding = 0, t } return r.__extends(t, e), t }(c); t.CodeBlockNode = f; var p = function (e) { function t() { var t = null !== e && e.apply(this, arguments) || this; return t.htmlBlockType = -1, t } return r.__extends(t, e), t }(c); t.HtmlBlockNode = p; var g = function (e) { function t() { var t = null !== e && e.apply(this, arguments) || this; return t.tickCount = 0, t } return r.__extends(t, e), t }(l); t.CodeNode = g; var m = function (e) { function t() { var t = null !== e && e.apply(this, arguments) || this; return t.columns = [], t } return r.__extends(t, e), t }(c); t.TableNode = m; var v = function (e) { function t() { var t = null !== e && e.apply(this, arguments) || this; return t.startIdx = 0, t.endIdx = 0, t.paddingLeft = 0, t.paddingRight = 0, t.ignored = !1, t } return r.__extends(t, e), t }(c); t.TableCellNode = v; var y = function (e) { function t() { var t = null !== e && e.apply(this, arguments) || this; return t.title = "", t.dest = "", t.label = "", t } return r.__extends(t, e), t }(c); function b(e, t) { switch (e) { case "heading": return new d(e, t); case "list": case "item": return new u(e, t); case "link": case "image": return new h(e, t); case "codeBlock": return new f(e, t); case "htmlBlock": return new p(e, t); case "table": return new m(e, t); case "tableCell": return new v(e, t); case "document": case "paragraph": case "blockQuote": case "thematicBreak": case "tableRow": case "tableBody": case "tableHead": return new c(e, t); case "code": return new g(e, t); case "refDef": return new y(e, t); default: return new l(e, t) } } t.RefDefNode = y, t.createNode = b, t.isCodeBlock = function (e) { return "codeBlock" === e.type }, t.isHtmlBlock = function (e) { return "htmlBlock" === e.type }, t.isHeading = function (e) { return "heading" === e.type }, t.isList = function (e) { return "list" === e.type }, t.isTable = function (e) { return "table" === e.type }, t.isRefDef = function (e) { return "refDef" === e.type }, t.text = function (e, t) { var n = b("text", t); return n.literal = e, n } }, function (e, t, n) { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.isEmpty = t.last = t.repeat = t.escapeXml = t.normalizeURI = t.unescapeString = t.ESCAPABLE = t.ENTITY = void 0; var r = n(0).__importDefault(n(12)), i = n(8); t.ENTITY = "&(?:#x[a-f0-9]{1,6}|#[0-9]{1,7}|[a-z][a-z0-9]{1,31});"; var o = /[\\&]/; t.ESCAPABLE = "[!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]"; var a = new RegExp("\\\\" + t.ESCAPABLE + "|" + t.ENTITY, "gi"), s = new RegExp('[&<>"]', "g"), l = function (e) { return 92 === e.charCodeAt(0) ? e.charAt(1) : i.decodeHTML(e) }; function c(e) { switch (e) { case "&": return "&"; case "<": return "<"; case ">": return ">"; case '"': return """; default: return e } } t.unescapeString = function (e) { return o.test(e) ? e.replace(a, l) : e }, t.normalizeURI = function (e) { try { return r.default(e) } catch (t) { return e } }, t.escapeXml = function (e) { return s.test(e) ? e.replace(s, c) : e }, t.repeat = function (e, t) { for (var n = [], r = 0; r < t; r++) n.push(e); return n.join("") }, t.last = function (e) { return e.length ? e[e.length - 1] : null }, t.isEmpty = function (e) { return !e || !/[^ \t]+/.test(e) } }, function (e, t, n) { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.clearObj = t.isEmptyObj = t.omit = t.iterateObject = t.normalizeReference = t.last = void 0; var r = n(0); t.last = function (e) { return e[e.length - 1] }, t.normalizeReference = function (e) { return e.slice(1, e.length - 1).trim().replace(/[ \t\r\n]+/, " ").toLowerCase().toUpperCase() }, t.iterateObject = function (e, t) { Object.keys(e).forEach((function (n) { t(n, e[n]) })) }, t.omit = function (e) { for (var t = [], n = 1; n < arguments.length; n++) t[n - 1] = arguments[n]; var i = r.__assign({}, e); return t.forEach((function (e) { delete i[e] })), i }, t.isEmptyObj = function (e) { return !Object.keys(e).length }, t.clearObj = function (e) { Object.keys(e).forEach((function (t) { delete e[t] })) } }, function (e, t, n) { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.isSpaceOrTab = t.isBlank = t.peek = t.endsWithBlankLine = t.reClosingCodeFence = t.reNonSpace = t.C_OPEN_BRACKET = t.C_SPACE = t.C_LESSTHAN = t.C_GREATERTHAN = t.C_NEWLINE = t.C_TAB = t.CODE_INDENT = void 0, t.CODE_INDENT = 4, t.C_TAB = 9, t.C_NEWLINE = 10, t.C_GREATERTHAN = 62, t.C_LESSTHAN = 60, t.C_SPACE = 32, t.C_OPEN_BRACKET = 91, t.reNonSpace = /[^ \t\f\v\r\n]/, t.reClosingCodeFence = /^(?:`{3,}|~{3,})(?= *$)/, t.endsWithBlankLine = function (e) { for (var t = e; t;) { if (t.lastLineBlank) return !0; var n = t.type; if (t.lastLineChecked || "list" !== n && "item" !== n) { t.lastLineChecked = !0; break } t.lastLineChecked = !0, t = t.lastChild } return !1 }, t.peek = function (e, t) { return t < e.length ? e.charCodeAt(t) : -1 }, t.isBlank = function (e) { return !t.reNonSpace.test(e) }, t.isSpaceOrTab = function (e) { return e === t.C_SPACE || e === t.C_TAB } }, function (e, t, n) { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.ToastMark = t.createRefDefState = t.reLineEnding = void 0; var r = n(0), i = n(7), o = n(1), a = n(27), s = n(10), l = n(3), c = n(4), u = n(6); function d(e) { return { id: e.id, title: e.title, sourcepos: e.sourcepos, unlinked: !1, destination: e.dest } } t.reLineEnding = /\r\n|\n|\r/, t.createRefDefState = d; var h = function () { function e(e, n) { this.refMap = {}, this.refLinkCandidateMap = {}, this.refDefCandidateMap = {}, this.referenceDefinition = !!(null == n ? void 0 : n.referenceDefinition), this.frontMatter = !!(null == n ? void 0 : n.frontMatter), this.parser = new i.Parser(n), this.parser.setRefMaps(this.refMap, this.refLinkCandidateMap, this.refDefCandidateMap), this.eventHandlerMap = { change: [] }, e = e || "", this.lineTexts = e.split(t.reLineEnding), this.root = this.parser.parse(e) } return e.prototype.updateLineTexts = function (e, n, i) { var o, a = e[0], s = e[1], l = n[0], c = n[1], u = i.split(t.reLineEnding), d = u.length, h = this.lineTexts[a - 1], f = this.lineTexts[l - 1]; u[0] = h.slice(0, s - 1) + u[0], u[d - 1] = u[d - 1] + f.slice(c - 1); var p = l - a + 1; return (o = this.lineTexts).splice.apply(o, r.__spreadArrays([a - 1, p], u)), d - p }, e.prototype.updateRootNodeState = function () { if (1 === this.lineTexts.length && "" === this.lineTexts[0]) return this.root.lastLineBlank = !0, void(this.root.sourcepos = [ [1, 1], [1, 0] ]); this.root.lastChild && (this.root.lastLineBlank = this.root.lastChild.lastLineBlank); for (var e = this.lineTexts, t = e.length - 1; "" === e[t];) t -= 1; e.length - 2 > t && (t += 1), this.root.sourcepos[1] = [t + 1, e[t].length] }, e.prototype.replaceRangeNodes = function (e, t, n) { e ? (a.insertNodesBefore(e, n), a.removeNextUntil(e, t), [e.id, t.id].forEach((function (e) { return o.removeNodeById(e) })), e.unlink()) : t ? (a.insertNodesBefore(t, n), o.removeNodeById(t.id), t.unlink()) : a.prependChildNodes(this.root, n) }, e.prototype.getNodeRange = function (e, t) { var n = a.findChildNodeAtLine(this.root, e[0]), r = a.findChildNodeAtLine(this.root, t[0]); return r && r.next && t[0] + 1 === r.next.sourcepos[0][0] && (r = r.next), a.getRangeForCustomType(n, r) }, e.prototype.trigger = function (e, t) { this.eventHandlerMap[e].forEach((function (e) { e(t) })) }, e.prototype.extendEndLine = function (e) { for (; "" === this.lineTexts[e];) e += 1; return e }, e.prototype.parseRange = function (e, t, n, r) { var i; e && e.prev && (o.isList(e.prev) && function (e) { var t = e.match(/^[ \t]+/); if (t && (t[0].length >= 2 || /\t/.test(t[0]))) return !0; var n = t ? e.slice(t.length) : e; return s.reBulletListMarker.test(n) || s.reOrderedListMarker.test(n) }(this.lineTexts[n - 1]) || o.isTable(e.prev) && (i = this.lineTexts[n - 1], !c.isBlank(i) && -1 !== i.indexOf("|"))) && (n = (e = e.prev).sourcepos[0][0]); for (var l = this.lineTexts.slice(n - 1, r), u = this.parser.partialParseStart(n, l), d = t ? t.next : this.root.firstChild, h = u.lastChild, f = h && o.isCodeBlock(h), p = h && o.isList(h); f && d || p && d && ("list" === d.type || d.sourcepos[0][1] >= 2);) { var g = this.extendEndLine(d.sourcepos[1][0]); this.parser.partialParseExtends(this.lineTexts.slice(r, g)), e || (e = t), t = d, r = g, d = d.next } return this.parser.partialParseFinish(), { newNodes: a.getChildNodes(u), extStartNode: e, extEndNode: t } }, e.prototype.getRemovedNodeRange = function (e, t) { return !e || e && o.isRefDef(e) || t && o.isRefDef(t) ? null : { id: [e.id, t.id], line: [e.sourcepos[0][0] - 1, t.sourcepos[1][0] - 1] } }, e.prototype.markDeletedRefMap = function (e, t) { var n = this; if (!l.isEmptyObj(this.refMap)) { var r = function (e) { if (o.isRefDef(e)) { var t = n.refMap[e.label]; t && e.id === t.id && (t.unlinked = !0) } }; e && a.invokeNextUntil(r, e.parent, t), t && a.invokeNextUntil(r, t) } }, e.prototype.replaceWithNewRefDefState = function (e) { var t = this; if (!l.isEmptyObj(this.refMap)) { var n = function (e) { if (o.isRefDef(e)) { var n = e.label, r = t.refMap[n]; r && !r.unlinked || (t.refMap[n] = d(e)) } }; e.forEach((function (e) { a.invokeNextUntil(n, e) })) } }, e.prototype.replaceWithRefDefCandidate = function () { var e = this; l.isEmptyObj(this.refDefCandidateMap) || l.iterateObject(this.refDefCandidateMap, (function (t, n) { var r = n.label, i = n.sourcepos, o = e.refMap[r]; (!o || o.unlinked || o.sourcepos[0][0] > i[0][0]) && (e.refMap[r] = d(n)) })) }, e.prototype.getRangeWithRefDef = function (e, t, n, r, i) { if (this.referenceDefinition && !l.isEmptyObj(this.refMap)) { var s = a.findChildNodeAtLine(this.root, e - 1), c = a.findChildNodeAtLine(this.root, t + 1); s && o.isRefDef(s) && s !== n && s !== r && (e = (n = s).sourcepos[0][0]), c && o.isRefDef(c) && c !== n && c !== r && (r = c, t = this.extendEndLine(r.sourcepos[1][0] + i)) } return [n, r, e, t] }, e.prototype.parseWithFrontMatter = function (e, t, n) { void 0 === n && (n = 0); var i = r.__spreadArrays(this.lineTexts), o = u.getFrontMatterPos(this.lineTexts), a = o[0], s = o[1]; a > -1 && s > -1 && (this.lineTexts[a] = u.frontMatterOpen, this.lineTexts[s] = u.frontMatterClose, a >= t[0] - 1 && (t[0] = s + 1), a <= e[0] - 1 && s >= t[0] - 1 && (e[0] = a + 1, t[0] = s + 1)); var l = this.parse(e, t, n); return this.lineTexts = i, l }, e.prototype.parse = function (e, t, n) { void 0 === n && (n = 0); var r = this.getNodeRange(e, t), i = r[0], o = r[1], a = i ? Math.min(i.sourcepos[0][0], e[0]) : e[0], s = this.extendEndLine((o ? Math.max(o.sourcepos[1][0], t[0]) : t[0]) + n), l = this.parseRange.apply(this, this.getRangeWithRefDef(a, s, i, o, n)), c = l.newNodes, u = l.extStartNode, d = l.extEndNode, h = this.getRemovedNodeRange(u, d), f = d ? d.next : this.root.firstChild; return this.referenceDefinition ? (this.markDeletedRefMap(u, d), this.replaceRangeNodes(u, d, c), this.replaceWithNewRefDefState(c)) : this.replaceRangeNodes(u, d, c), { nodes: c, removedNodeRange: h, nextNode: f } }, e.prototype.parseRefLink = function () { var e = this, t = []; return l.isEmptyObj(this.refMap) || l.iterateObject(this.refMap, (function (n, r) { r.unlinked && delete e.refMap[n], l.iterateObject(e.refLinkCandidateMap, (function (r, i) { var o = i.node; i.refLabel === n && t.push(e.parse(o.sourcepos[0], o.sourcepos[1])) })) })), t }, e.prototype.removeUnlinkedCandidate = function () { l.isEmptyObj(this.refDefCandidateMap) || [this.refLinkCandidateMap, this.refDefCandidateMap].forEach((function (e) { l.iterateObject(e, (function (t) { a.isUnlinked(t) && delete e[t] })) })) }, e.prototype.editMarkdown = function (e, t, n) { var r = this.updateLineTexts(e, t, n), i = this.frontMatter ? this.parseWithFrontMatter(e, t, r) : this.parse(e, t, r), o = l.omit(i, "nextNode"); a.updateNextLineNumbers(i.nextNode, r), this.updateRootNodeState(); var s = [o]; return this.referenceDefinition && (this.removeUnlinkedCandidate(), this.replaceWithRefDefCandidate(), s = s.concat(this.parseRefLink())), this.trigger("change", s), s }, e.prototype.getLineTexts = function () { return this.lineTexts }, e.prototype.getRootNode = function () { return this.root }, e.prototype.findNodeAtPosition = function (e) { var t = a.findNodeAtPosition(this.root, e); return t && t !== this.root ? t : null }, e.prototype.findFirstNodeAtLine = function (e) { return a.findFirstNodeAtLine(this.root, e) }, e.prototype.on = function (e, t) { this.eventHandlerMap[e].push(t) }, e.prototype.off = function (e, t) { var n = this.eventHandlerMap[e], r = n.indexOf(t); n.splice(r, 1) }, e.prototype.findNodeById = function (e) { return a.findNodeById(e) }, e.prototype.removeAllNode = function () { o.removeAllNode() }, e }(); t.ToastMark = h }, function (e, t, n) { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.getFrontMatterPos = t.replaceFrontMatter = t.frontMatterClose = t.frontMatterOpen = void 0, t.frontMatterOpen = "{:f", t.frontMatterClose = "f:}"; var r = /^---$/, i = /^---$([\s\S]*)^---$/m; t.replaceFrontMatter = function (e) { var n = e.trim(); return /^---/.test(n) && function (e) { return i.test(e) }(n) ? e.replace(i, t.frontMatterOpen + "$1" + t.frontMatterClose) : e }, t.getFrontMatterPos = function (e) { for (var t = -1, n = -1, i = 0; i < e.length; i += 1) { var o = e[i].trim(); if (t < 0 && o && !r.test(o) || n > 0) break; r.test(o) && (t < 0 ? t = i : n = i) } return [t, n] } }, function (e, t, n) { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.Parser = void 0; var r = n(0), i = n(2), o = n(1), a = n(19), s = n(22), l = n(4), c = n(10), u = n(3), d = n(6), h = n(26), f = [/./, /<\/(?:script|pre|style)>/i, /-->/, /\?>/, />/, /\]\]>/], p = /^[#`~*+_=<>0-9-]/, g = /\r\n|\n|\r/; function m() { return o.createNode("document", [ [1, 1], [0, 0] ]) } var v = { smart: !1, tagFilter: !1, extendedAutolinks: !1, disallowedHtmlBlockTags: [], referenceDefinition: !1, disallowDeepHeading: !1, customParser: null, frontMatter: !1 }, y = function () { function e(e) { this.options = r.__assign(r.__assign({}, v), e), this.doc = m(), this.tip = this.doc, this.oldtip = this.doc, this.lineNumber = 0, this.offset = 0, this.column = 0, this.nextNonspace = 0, this.nextNonspaceColumn = 0, this.indent = 0, this.currentLine = "", this.indented = !1, this.blank = !1, this.partiallyConsumedTab = !1, this.allClosed = !0, this.lastMatchedContainer = this.doc, this.refMap = {}, this.refLinkCandidateMap = {}, this.refDefCandidateMap = {}, this.lastLineLength = 0, this.options.frontMatter && (this.options.customParser = r.__assign(r.__assign({}, h.frontMatterParser), this.options.customParser)), this.inlineParser = new a.InlineParser(this.options) } return e.prototype.advanceOffset = function (e, t) { void 0 === t && (t = !1); for (var n, r, i, o = this.currentLine; e > 0 && (i = o[this.offset]);) "\t" === i ? (n = 4 - this.column % 4, t ? (this.partiallyConsumedTab = n > e, r = n > e ? e : n, this.column += r, this.offset += this.partiallyConsumedTab ? 0 : 1, e -= r) : (this.partiallyConsumedTab = !1, this.column += n, this.offset += 1, e -= 1)) : (this.partiallyConsumedTab = !1, this.offset += 1, this.column += 1, e -= 1) }, e.prototype.advanceNextNonspace = function () { this.offset = this.nextNonspace, this.column = this.nextNonspaceColumn, this.partiallyConsumedTab = !1 }, e.prototype.findNextNonspace = function () { for (var e, t = this.currentLine, n = this.offset, r = this.column; "" !== (e = t.charAt(n));) if (" " === e) n++, r++; else { if ("\t" !== e) break; n++, r += 4 - r % 4 } this.blank = "\n" === e || "\r" === e || "" === e, this.nextNonspace = n, this.nextNonspaceColumn = r, this.indent = this.nextNonspaceColumn - this.column, this.indented = this.indent >= l.CODE_INDENT }, e.prototype.addLine = function () { if (this.partiallyConsumedTab) { this.offset += 1; var e = 4 - this.column % 4; this.tip.stringContent += i.repeat(" ", e) } this.tip.lineOffsets ? this.tip.lineOffsets.push(this.offset) : this.tip.lineOffsets = [this.offset], this.tip.stringContent += this.currentLine.slice(this.offset) + "\n" }, e.prototype.addChild = function (e, t) { for (; !s.blockHandlers[this.tip.type].canContain(e);) this.finalize(this.tip, this.lineNumber - 1); var n = t + 1, r = o.createNode(e, [ [this.lineNumber, n], [0, 0] ]); return r.stringContent = "", this.tip.appendChild(r), this.tip = r, r }, e.prototype.closeUnmatchedBlocks = function () { if (!this.allClosed) { for (; this.oldtip !== this.lastMatchedContainer;) { var e = this.oldtip.parent; this.finalize(this.oldtip, this.lineNumber - 1), this.oldtip = e } this.allClosed = !0 } }, e.prototype.finalize = function (e, t) { var n = e.parent; e.open = !1, e.sourcepos[1] = [t, this.lastLineLength], s.blockHandlers[e.type].finalize(this, e), this.tip = n }, e.prototype.processInlines = function (e) { var t, n = this.options.customParser, r = e.walker(); for (this.inlineParser.refMap = this.refMap, this.inlineParser.refLinkCandidateMap = this.refLinkCandidateMap, this.inlineParser.refDefCandidateMap = this.refDefCandidateMap, this.inlineParser.options = this.options; t = r.next();) { var i = t.node, o = t.entering, a = i.type; n && n[a] && n[a](i, { entering: o, options: this.options }), o || "paragraph" !== a && "heading" !== a && ("tableCell" !== a || i.ignored) || this.inlineParser.parse(i) } }, e.prototype.incorporateLine = function (e) { var t = this.doc; this.oldtip = this.tip, this.offset = 0, this.column = 0, this.blank = !1, this.partiallyConsumedTab = !1, this.lineNumber += 1, -1 !== e.indexOf("\0") && (e = e.replace(/\0/g, "�")), this.currentLine = e; for (var n, r = !0; (n = t.lastChild) && n.open;) { switch (t = n, this.findNextNonspace(), s.blockHandlers[t.type].continue(this, t)) { case 0: break; case 1: r = !1; break; case 2: return void(this.lastLineLength = e.length); default: throw new Error("continue returned illegal value, must be 0, 1, or 2") } if (!r) { t = t.parent; break } } this.allClosed = t === this.oldtip, this.lastMatchedContainer = t; for (var i = "paragraph" !== t.type && s.blockHandlers[t.type].acceptsLines, a = c.blockStarts.length; !i;) { if (this.findNextNonspace(), "table" !== t.type && "tableBody" !== t.type && "paragraph" !== t.type && !this.indented && !p.test(e.slice(this.nextNonspace))) { this.advanceNextNonspace(); break } for (var l = 0; l < a;) { var u = c.blockStarts[l](this, t); if (1 === u) { t = this.tip; break } if (2 === u) { t = this.tip, i = !0; break } l++ } if (l === a) { this.advanceNextNonspace(); break } } if (this.allClosed || this.blank || "paragraph" !== this.tip.type) { this.closeUnmatchedBlocks(), this.blank && t.lastChild && (t.lastChild.lastLineBlank = !0); for (var d = t.type, h = this.blank && !("blockQuote" === d || o.isCodeBlock(t) && t.isFenced || "item" === d && !t.firstChild && t.sourcepos[0][0] === this.lineNumber), g = t; g;) g.lastLineBlank = h, g = g.parent; s.blockHandlers[d].acceptsLines ? (this.addLine(), o.isHtmlBlock(t) && t.htmlBlockType >= 1 && t.htmlBlockType <= 5 && f[t.htmlBlockType].test(this.currentLine.slice(this.offset)) && (this.lastLineLength = e.length, this.finalize(t, this.lineNumber))) : this.offset < e.length && !this.blank && (t = this.addChild("paragraph", this.offset), this.advanceNextNonspace(), this.addLine()) } else this.addLine(); this.lastLineLength = e.length }, e.prototype.parse = function (e) { this.options.frontMatter && (e = d.replaceFrontMatter(e)), this.doc = m(), this.tip = this.doc, this.lineNumber = 0, this.lastLineLength = 0, this.offset = 0, this.column = 0, this.lastMatchedContainer = this.doc, this.currentLine = ""; var t = e.split(g), n = t.length; this.options.referenceDefinition && this.clearRefMaps(), e.charCodeAt(e.length - 1) === a.C_NEWLINE && (n -= 1); for (var r = 0; r < n; r++) this.incorporateLine(t[r]); for (; this.tip;) this.finalize(this.tip, n); return this.processInlines(this.doc), this.doc }, e.prototype.partialParseStart = function (e, t) { this.doc = m(), this.tip = this.doc, this.lineNumber = e - 1, this.lastLineLength = 0, this.offset = 0, this.column = 0, this.lastMatchedContainer = this.doc, this.currentLine = ""; for (var n = t.length, r = 0; r < n; r++) this.incorporateLine(t[r]); return this.doc }, e.prototype.partialParseExtends = function (e) { for (var t = 0; t < e.length; t++) this.incorporateLine(e[t]) }, e.prototype.partialParseFinish = function () { for (; this.tip;) this.finalize(this.tip, this.lineNumber); this.processInlines(this.doc) }, e.prototype.setRefMaps = function (e, t, n) { this.refMap = e, this.refLinkCandidateMap = t, this.refDefCandidateMap = n }, e.prototype.clearRefMaps = function () { [this.refMap, this.refLinkCandidateMap, this.refDefCandidateMap].forEach((function (e) { u.clearObj(e) })) }, e }(); t.Parser = y }, function (e, t, n) { "use strict"; var r = this && this.__importDefault || function (e) { return e && e.__esModule ? e : { default: e } }; Object.defineProperty(t, "__esModule", { value: !0 }), t.decodeHTML = t.decodeHTMLStrict = t.decodeXML = void 0; var i = r(n(13)), o = r(n(14)), a = r(n(15)), s = r(n(16)); function l(e) { var t = Object.keys(e).join("|"), n = u(e), r = new RegExp("&(?:" + (t += "|#[xX][\\da-fA-F]+|#\\d+") + ");", "g"); return function (e) { return String(e).replace(r, n) } } t.decodeXML = l(a.default), t.decodeHTMLStrict = l(i.default); var c = function (e, t) { return e < t ? 1 : -1 }; function u(e) { return function (t) { if ("#" === t.charAt(1)) { var n = t.charAt(2); return "X" === n || "x" === n ? s.default(parseInt(t.substr(3), 16)) : s.default(parseInt(t.substr(2), 10)) } return e[t.slice(1, -1)] } } t.decodeHTML = function () { for (var e = Object.keys(o.default).sort(c), t = Object.keys(i.default).sort(c), n = 0, r = 0; n < t.length; n++) e[r] === t[n] ? (t[n] += ";?", r++) : t[n] += ";"; var a = new RegExp("&(?:" + t.join("|") + "|#[xX][\\da-fA-F]+;?|#\\d+;?)", "g"), s = u(i.default); function l(e) { return ";" !== e.substr(-1) && (e += ";"), s(e) } return function (e) { return String(e).replace(a, l) } }() }, function (e, t, n) { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.reHtmlTag = t.CLOSETAG = t.OPENTAG = void 0, t.OPENTAG = "<[A-Za-z][A-Za-z0-9-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^\"'=<>`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)*\\s*/?>", t.CLOSETAG = "]"; var r = "(?:" + t.OPENTAG + "|" + t.CLOSETAG + "|\x3c!----\x3e|\x3c!--(?:-?[^>-])(?:-?[^-])*--\x3e|[<][?].*?[?][>]|]*>|)"; t.reHtmlTag = new RegExp("^" + r, "i") }, function (e, t, n) { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.blockStarts = t.reOrderedListMarker = t.reBulletListMarker = void 0; var r = n(1), i = n(9), o = n(4), a = n(25), s = /^`{3,}(?!.*`)|^~{3,}/, l = [/./, /^<(?:script|pre|style)(?:\s|>|$)/i, /^|<([a-zA-Z_][a-zA-Z0-9\-.:/]*)>/), f(E, "markdownTextToEscapeBackSlashRx", /\\[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~\\]/), f(E, "markdownTextToEscapePairedCharsRx", /[*_~`]/); var x = /\n$/g, S = /[ \xA0]+\n\n/g, N = /([ \xA0]+\n){2,}/g, k = /href="(.*?)"/, L = /^/gm, M = E.factory({ TEXT_NODE: function (e) { var t = this.trim(this.getSpaceCollapsedText(e.nodeValue)); return this._isNeedEscapeBackSlash(t) && (t = this.escapeTextBackSlash(t)), t = this.escapePairedCharacters(t), this._isNeedEscapeHtml(t) && (t = this.escapeTextHtml(t)), this._isNeedEscape(t) && (t = this.escapeText(t)), this.getSpaceControlled(t, e) }, "CODE TEXT_NODE": function (e) { return e.nodeValue }, "EM, I": function (e, t) { var n = ""; return this.isEmptyText(t) || (n = "*" + t + "*"), n }, "STRONG, B": function (e, t) { var n = ""; return this.isEmptyText(t) || (n = "**" + t + "**"), n }, A: function (e, t) { var n, r = t, i = "", o = k.exec(e.outerHTML); return o && (n = o[1].replace(/&/g, "&")), e.title && (i = ' "' + e.title + '"'), !this.isEmptyText(t) && n && (r = "[" + this.escapeTextForLink(t) + "](" + n + i + ")"), r }, IMG: function (e) { var t = e.getAttribute("src"), n = e.alt; return t ? "![" + this.escapeTextForLink(n) + "](" + t + ")" : "" }, BR: function () { return " \n" }, CODE: function (e, t) { var n, r, i = ""; return this.isEmptyText(t) || (r = parseInt(e.getAttribute("data-backticks"), 10), i = (n = isNaN(r) ? "`" : Array(r + 1).join("`")) + t + n), i }, P: function (e, t) { var n = ""; return t = t.replace(N, " \n"), this.isEmptyText(t) || (n = "\n\n" + t + "\n\n"), n }, "BLOCKQUOTE P": function (e, t) { return t }, "LI P": function (e, t) { var n = ""; return this.isEmptyText(t) || (n = t), n }, "H1, H2, H3, H4, H5, H6": function (e, t) { for (var n = "", r = parseInt(e.tagName.charAt(1), 10); r;) n += "#", r -= 1; return n += " ", "\n\n" + (n += t) + "\n\n" }, "LI H1, LI H2, LI H3, LI H4, LI H5, LI H6": function (e, t) { var n = parseInt(e.tagName.charAt(1), 10); return Array(n + 1).join("#") + " " + t }, "UL, OL": function (e, t) { return "\n\n" + t + "\n\n" }, "LI OL, LI UL": function (e, t) { return "\n" + t.replace(S, "\n").replace(x, "").replace(L, " ") }, "UL LI": function (e, t) { var n = ""; return t = t.replace(N, " \n"), e.firstChild && "P" === e.firstChild.tagName && (n += "\n"), n += "* " + t + "\n" }, "OL LI": function (e, t) { for (var n = "", r = parseInt(e.parentNode.getAttribute("start") || 1, 10); e.previousSibling;) 1 === (e = e.previousSibling).nodeType && "LI" === e.tagName && (r += 1); return t = t.replace(N, " \n"), e.firstChild && "P" === e.firstChild.tagName && (n += "\n"), n += r + ". " + t + "\n" }, HR: function () { return "\n\n- - -\n\n" }, BLOCKQUOTE: function (e, t) { return t = t.replace(N, "\n\n"), "\n\n" + this.trim(t).replace(L, "> ") + "\n\n" }, "PRE CODE": function (e, t) { return "\n\n" + t.replace(x, "").replace(L, " ") + "\n\n" } }), A = E.factory(M, { "DEL, S": function (e, t) { return "~~" + t + "~~" }, "PRE CODE": function (e, t) { var n = "", r = e.getAttribute("data-backticks"); e.getAttribute("data-language") && (n = " " + e.getAttribute("data-language")), r = parseInt(r, 10); var i = isNaN(r) ? "```" : Array(r + 1).join("`"); return "\n\n" + i + n + "\n" + (t = t.replace(/(\r\n)|(\r)|(\n)/g, this.lineFeedReplacement)) + "\n" + i + "\n\n" }, PRE: function (e, t) { return t }, "UL LI": function (e, t) { return M.convert(e, B(e, t)) }, "OL LI": function (e, t) { return M.convert(e, B(e, t)) }, TABLE: function (e, t) { return "\n\n" + t + "\n\n" }, "TBODY, TFOOT": function (e, t) { return t }, "TR TD, TR TH": function (e, t) { return " " + (t = t.replace(/(\r\n)|(\r)|(\n)/g, "")) + " |" }, "TD BR, TH BR": function () { return "
" }, TR: function (e, t) { return "|" + t + "\n" }, THEAD: function (e, t) { for (var n = "", r = D(D(e, "TR")[0], "TH"), i = 0, o = r.length; i < o; i += 1) n += " " + O(r[i]) + " |"; return t ? t + "|" + n + "\n" : "" } }); function B(e, t) { return -1 !== e.className.indexOf("task-list-item") && (t = "[" + (-1 !== e.className.indexOf("checked") ? "x" : " ") + "] " + t), t } function O(e) { var t, n, r, i = e.align; return r = e.textContent ? e.textContent.length : e.innerText.length, t = "", n = "", i && ("left" === i ? (t = ":", r -= 1) : "right" === i ? (n = ":", r -= 1) : "center" === i && (n = ":", t = ":", r -= 2)), t + function (e, t) { var n = e; for (t = Math.max(t, 3); t > 1;) n += e, t -= 1; return n }("-", r) + n } function D(e, t) { for (var n = e.childNodes, r = [], i = 0, o = n.length; i < o; i += 1) n[i].tagName && n[i].tagName === t && r.push(n[i]); return r } var I = /[ \xA0]+(\n\n)/g, R = /^[\n]+|[\s\n]+$/g, P = /([ \xA0]+\n){2,}/g, H = /([ \xA0]){2,}\n/g, F = /[ \xA0\n]+/g; function U(e, t) { var n, r = !0; return e ? (n = A, t && (!1 === (r = t.gfm) && (n = M), n = t.renderer || n), function (e, t, n) { return e = (e = (e = (e = (e = e.replace(I, "\n")).replace(P, "\n\n")).replace(F, (function (e) { return (e.match(/\n/g) || []).length >= 3 ? "\n\n" : e >= 1 ? "\n" : e }))).replace(R, "")).replace(new RegExp(n, "g"), "\n"), t && (e = e.replace(H, "\n")), e }(function (e, t) { for (var n = ""; e.next();) n += W(e, t); return n }(new s(d(e)), n), r, n.lineFeedReplacement)) : "" } function W(e, t) { for (var n = "", r = e.getNode(), i = 0, o = r.childNodes.length; i < o; i += 1) e.next(), n += W(e, t); return t.convert(r, n) } U.Renderer = E, U.basicRenderer = M, U.gfmRenderer = A, t.default = U }]).default }, e.exports = r() }, function (e, t, n) { "use strict"; e.exports = function (e, t) { var n, r; return t = t || 0, function () { r = Array.prototype.slice.call(arguments), window.clearTimeout(n), n = window.setTimeout((function () { e.apply(null, r) }), t) } } }, function (e, t, n) { "use strict"; var r = n(9); e.exports = function (e) { return e && e.className ? r(e.className.baseVal) ? e.className : e.className.baseVal : "" } }, function (e, t, n) { "use strict"; var r = n(18); e.exports = function (e) { return r(e) && !1 !== e } }, function (e, t, n) { "use strict"; e.exports = function (e) { return e === Object(e) } }, function (e, t, n) { ! function (t, n) { "use strict"; function r(e, t, n) { this.root = this.currentNode = e, this.nodeType = t, this.filter = n || le } function i(e) { return e.nodeType === I && !!ue[e.nodeName] } function o(e) { switch (e.nodeType) { case R: return he; case I: case H: if (ie && ge.has(e)) return ge.get(e); break; default: return de } var t; return t = function (e, t) { for (var n = e.length; n--;) if (!t(e[n])) return !1; return !0 }(e.childNodes, a) ? ce.test(e.nodeName) ? he : fe : pe, ie && ge.set(e, t), t } function a(e) { return o(e) === he } function s(e) { return o(e) === fe } function l(e) { return o(e) === pe } function c(e, t) { var n = new r(t, F, s); return n.currentNode = e, n } function u(e, t) { return (e = c(e, t).previousNode()) !== t ? e : null } function d(e, t) { return (e = c(e, t).nextNode()) !== t ? e : null } function h(e, t) { return !i(e) && e.nodeType === t.nodeType && e.nodeName === t.nodeName && "A" !== e.nodeName && e.className === t.className && (!e.style && !t.style || e.style.cssText === t.style.cssText) } function f(e, t, n) { if (e.nodeName !== t) return !1; for (var r in n) if (e.getAttribute(r) !== n[r]) return !1; return !0 } function p(e, t, n, r) { for (; e && e !== t;) { if (f(e, n, r)) return e; e = e.parentNode } return null } function g(e, t) { for (; t;) { if (t === e) return !0; t = t.parentNode } return !1 } function m(e) { var t = e.nodeType; return t === I || t === H ? e.childNodes.length : e.length || 0 } function v(e) { var t = e.parentNode; return t && t.removeChild(e), e } function y(e, t) { var n = e.parentNode; n && n.replaceChild(t, e) } function b(e) { for (var t = e.ownerDocument.createDocumentFragment(), n = e.childNodes, r = n ? n.length : 0; r--;) t.appendChild(e.firstChild); return t } function C(e, t, r, i) { var o, a, s, l = e.createElement(t); if (r instanceof Array && (i = r, r = null), r) for (o in r) r[o] !== n && l.setAttribute(o, r[o]); if (i) for (a = 0, s = i.length; a < s; a += 1) l.appendChild(i[a]); return l } function w(e, t) { var n, r, o = t.__squire__, s = e.ownerDocument, l = e; if (e === t && ((r = e.firstChild) && "BR" !== r.nodeName || (n = o.createDefaultBlock(), r ? e.replaceChild(n, r) : e.appendChild(n), e = n, n = null)), e.nodeType === R) return l; if (a(e)) { for (r = e.firstChild; te && r && r.nodeType === R && !r.data;) e.removeChild(r), r = e.firstChild; r || (te ? (n = s.createTextNode(U), o._didAddZWS()) : n = s.createTextNode("")) } else if (ee) { for (; e.nodeType !== R && !i(e);) { if (!(r = e.firstChild)) { n = s.createTextNode(""); break } e = r } e.nodeType === R ? /^ +$/.test(e.data) && (e.data = "") : i(e) && e.parentNode.insertBefore(s.createTextNode(""), e) } else if ("HR" !== e.nodeName && !e.querySelector("BR")) for (n = C(s, "BR"); (r = e.lastElementChild) && !a(r);) e = r; if (n) try { e.appendChild(n) } catch (t) { o.didError({ name: "Squire: fixCursor – " + t, message: "Parent: " + e.nodeName + "/" + e.innerHTML + " appendChild: " + n.nodeName }) } return l } function _(e, t) { var n, r, i, o, s = e.childNodes, c = e.ownerDocument, u = null, d = t.__squire__._config; for (n = 0, r = s.length; n < r; n += 1) !(o = "BR" === (i = s[n]).nodeName) && a(i) ? (u || (u = C(c, d.blockTag, d.blockAttributes)), u.appendChild(i), n -= 1, r -= 1) : (o || u) && (u || (u = C(c, d.blockTag, d.blockAttributes)), w(u, t), o ? e.replaceChild(u, i) : (e.insertBefore(u, i), n += 1, r += 1), u = null), l(i) && _(i, t); return u && e.appendChild(w(u, t)), e } function T(e, t, n, r) { var i, o, a, s = e.nodeType; if (s === R && e !== n) return T(e.parentNode, e.splitText(t), n, r); if (s === I) { if ("number" == typeof t && (t = t < e.childNodes.length ? e.childNodes[t] : null), e === n) return t; for (i = e.parentNode, o = e.cloneNode(!1); t;) a = t.nextSibling, o.appendChild(t), t = a; return "OL" === e.nodeName && p(e, r, "BLOCKQUOTE") && (o.start = (+e.start || 1) + e.childNodes.length - 1), w(e, r), w(o, r), (a = e.nextSibling) ? i.insertBefore(o, a) : i.appendChild(o), T(i, o, n, r) } return t } function E(e, t) { if (e.nodeType === R && (e = e.parentNode), e.nodeType === I) { var n = { startContainer: t.startContainer, startOffset: t.startOffset, endContainer: t.endContainer, endOffset: t.endOffset }; (function e(t, n) { for (var r, i, o, s = t.childNodes, l = s.length, c = []; l--;) if (r = s[l], i = l && s[l - 1], l && a(r) && h(r, i) && !ue[r.nodeName]) n.startContainer === r && (n.startContainer = i, n.startOffset += m(i)), n.endContainer === r && (n.endContainer = i, n.endOffset += m(i)), n.startContainer === t && (n.startOffset > l ? n.startOffset -= 1 : n.startOffset === l && (n.startContainer = i, n.startOffset = m(i))), n.endContainer === t && (n.endOffset > l ? n.endOffset -= 1 : n.endOffset === l && (n.endContainer = i, n.endOffset = m(i))), v(r), r.nodeType === R ? i.appendData(r.data) : c.push(b(r)); else if (r.nodeType === I) { for (o = c.length; o--;) r.appendChild(c.pop()); e(r, n) } })(e, n), t.setStart(n.startContainer, n.startOffset), t.setEnd(n.endContainer, n.endOffset) } } function x(e) { var t = e.nodeName; return "TD" === t || "TH" === t || "TR" === t || "TBODY" === t || "THEAD" === t } function S(e, t, n, r) { var i, o, a, s = t; if (!x(e) || !x(t)) { for (; (i = s.parentNode) && i !== r && i.nodeType === I && 1 === i.childNodes.length;) s = i; v(s), a = e.childNodes.length, (o = e.lastChild) && "BR" === o.nodeName && (e.removeChild(o), a -= 1), e.appendChild(b(t)), n.setStart(e, a), n.collapse(!0), E(e, n), Y && (o = e.lastChild) && "BR" === o.nodeName && e.removeChild(o) } } function N(e, t) { var n, r, i = e.previousSibling, o = e.firstChild, a = e.ownerDocument, s = "LI" === e.nodeName; if ((!s || o && /^[OU]L$/.test(o.nodeName)) && !x(e)) if (i && h(i, e) && i.isContentEditable && e.isContentEditable) { if (!l(i)) { if (!s) return; (r = C(a, "DIV")).appendChild(b(i)), i.appendChild(r) } v(e), n = !l(e), i.appendChild(b(e)), n && _(i, t), o && N(o, t) } else s && (i = C(a, "DIV"), e.insertBefore(i, o), w(i, t)) } function k(e) { this.isShiftDown = e.shiftKey } function L(e, t, n) { var r, i; if (e || (e = {}), t) for (r in t) !n && r in e || (i = t[r], e[r] = i && i.constructor === Object ? L(e[r], i, n) : i); return e } function M(e, t) { e.nodeType === P && (e = e.body); var n, r = e.ownerDocument, i = r.defaultView; this._win = i, this._doc = r, this._root = e, this._events = {}, this._isFocused = !1, this._lastSelection = null, ne && this.addEventListener("beforedeactivate", this.getSelection), this._hasZWS = !1, this._lastAnchorNode = null, this._lastFocusNode = null, this._path = "", this._willUpdatePath = !1, "onselectionchange" in r ? this.addEventListener("selectionchange", this._updatePathOnEvent) : (this.addEventListener("keyup", this._updatePathOnEvent), this.addEventListener("mouseup", this._updatePathOnEvent)), this._undoIndex = -1, this._undoStack = [], this._undoStackLength = 0, this._isInUndoState = !1, this._ignoreChange = !1, this._ignoreAllChanges = !1, re ? ((n = new MutationObserver(this._docWasChanged.bind(this))).observe(e, { childList: !0, attributes: !0, characterData: !0, subtree: !0 }), this._mutation = n) : this.addEventListener("keyup", this._keyUpDetectChange), this._restoreSelection = !1, this.addEventListener("blur", A), this.addEventListener("mousedown", B), this.addEventListener("touchstart", B), this.addEventListener("focus", O), this._awaitingPaste = !1, this.addEventListener($ ? "beforecut" : "cut", Qe), this.addEventListener("copy", Je), this.addEventListener("keydown", k), this.addEventListener("keyup", k), this.addEventListener($ ? "beforepaste" : "paste", et), this.addEventListener("drop", tt), this.addEventListener(Y ? "keypress" : "keydown", Be), this._keyHandlers = Object.create(Re), this.setConfig(t), $ && (i.Text.prototype.splitText = function (e) { var t = this.ownerDocument.createTextNode(this.data.slice(e)), n = this.nextSibling, r = this.parentNode, i = this.length - e; return n ? r.insertBefore(t, n) : r.appendChild(t), i && this.deleteData(e, i), t }), e.setAttribute("contenteditable", "true"); try { r.execCommand("enableObjectResizing", !1, "false"), r.execCommand("enableInlineTableEditing", !1, "false") } catch (e) {} e.__squire__ = this, this.setHTML("") } function A() { this._restoreSelection = !0 } function B() { this._restoreSelection = !1 } function O() { this._restoreSelection && this.setSelection(this._lastSelection) } function D(e, t, n) { var r, i; for (r = t.firstChild; r; r = i) { if (i = r.nextSibling, a(r)) { if (r.nodeType === R || "BR" === r.nodeName || "IMG" === r.nodeName) { n.appendChild(r); continue } } else if (s(r)) { n.appendChild(e.createDefaultBlock([D(e, r, e._doc.createDocumentFragment())])); continue } D(e, r, n) } return n } var I = 1, R = 3, P = 9, H = 11, F = 1, U = "​", W = t.defaultView, q = navigator.userAgent, z = /Android/.test(q), j = /iP(?:ad|hone|od)/.test(q), V = /Mac OS X/.test(q), K = /Windows NT/.test(q), G = /Gecko\//.test(q), $ = /Trident\/[456]\./.test(q), Y = !!W.opera, X = /Edge\//.test(q), Z = !X && /WebKit\//.test(q), Q = /Trident\/[4567]\./.test(q), J = V ? "meta-" : "ctrl-", ee = $ || Y, te = $ || Z, ne = $, re = "undefined" != typeof MutationObserver, ie = "undefined" != typeof WeakMap, oe = /[^ \t\r\n]/, ae = Array.prototype.indexOf; Object.create || (Object.create = function (e) { var t = function () {}; return t.prototype = e, new t }); var se = { 1: 1, 2: 2, 3: 4, 8: 128, 9: 256, 11: 1024 }, le = function () { return !0 }; r.prototype.nextNode = function () { for (var e, t = this.currentNode, n = this.root, r = this.nodeType, i = this.filter;;) { for (e = t.firstChild; !e && t && t !== n;)(e = t.nextSibling) || (t = t.parentNode); if (!e) return null; if (se[e.nodeType] & r && i(e)) return this.currentNode = e, e; t = e } }, r.prototype.previousNode = function () { for (var e, t = this.currentNode, n = this.root, r = this.nodeType, i = this.filter;;) { if (t === n) return null; if (e = t.previousSibling) for (; t = e.lastChild;) e = t; else e = t.parentNode; if (!e) return null; if (se[e.nodeType] & r && i(e)) return this.currentNode = e, e; t = e } }, r.prototype.previousPONode = function () { for (var e, t = this.currentNode, n = this.root, r = this.nodeType, i = this.filter;;) { for (e = t.lastChild; !e && t && t !== n;)(e = t.previousSibling) || (t = t.parentNode); if (!e) return null; if (se[e.nodeType] & r && i(e)) return this.currentNode = e, e; t = e } }; var ce = /^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|I(?:FRAME|MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|TIME|U|VAR|WBR)$/, ue = { BR: 1, HR: 1, IFRAME: 1, IMG: 1, INPUT: 1 }, de = 0, he = 1, fe = 2, pe = 3, ge = ie ? new WeakMap : null, me = function (e, t) { for (var n = e.childNodes; t && e.nodeType === I;) t = (n = (e = n[t - 1]).childNodes).length; return e }, ve = function (e, t) { if (e.nodeType === I) { var n = e.childNodes; if (t < n.length) e = n[t]; else { for (; e && !e.nextSibling;) e = e.parentNode; e && (e = e.nextSibling) } } return e }, ye = function (e, t) { var n, r, i, o, a = e.startContainer, s = e.startOffset, l = e.endContainer, c = e.endOffset; a.nodeType === R ? (r = (n = a.parentNode).childNodes, s === a.length ? (s = ae.call(r, a) + 1, e.collapsed && (l = n, c = s)) : (s && (o = a.splitText(s), l === a ? (c -= s, l = o) : l === n && (c += 1), a = o), s = ae.call(r, a)), a = n) : r = a.childNodes, s === (i = r.length) ? a.appendChild(t) : a.insertBefore(t, r[s]), a === l && (c += r.length - i), e.setStart(a, s), e.setEnd(l, c) }, be = function (e, t, n) { var r = e.startContainer, i = e.startOffset, o = e.endContainer, a = e.endOffset; t || (t = e.commonAncestorContainer), t.nodeType === R && (t = t.parentNode); for (var s, l, c, u, d, h = T(o, a, t, n), f = T(r, i, t, n), p = t.ownerDocument.createDocumentFragment(); f !== h;) s = f.nextSibling, p.appendChild(f), f = s; return r = t, i = h ? ae.call(t.childNodes, h) : t.childNodes.length, (l = (c = t.childNodes[i]) && c.previousSibling) && l.nodeType === R && c.nodeType === R && (r = l, i = l.length, u = l.data, d = c.data, " " === u.charAt(u.length - 1) && " " === d.charAt(0) && (d = " " + d.slice(1)), l.appendData(d), v(c)), e.setStart(r, i), e.collapse(!0), w(t, n), p }, Ce = function (e, t) { var n, r, i = xe(e, t), o = Se(e, t), a = i !== o; return Te(e), Ee(e, i, o, t), n = be(e, null, t), Te(e), a && (o = Se(e, t), i && o && i !== o && S(i, o, e, t)), i && w(i, t), (r = t.firstChild) && "BR" !== r.nodeName ? e.collapse(!0) : (w(t, t), e.selectNodeContents(t.firstChild)), n }, we = function (e, t, n) { var r, i, o, s, c, h, f, g, v, y; for (_(t, n), r = t; r = d(r, n);) w(r, n); if (e.collapsed || Ce(e, n), Te(e), e.collapse(!1), s = p(e.endContainer, n, "BLOCKQUOTE") || n, i = xe(e, n), f = d(t, t), i && f && ! function (e, t, n) { for (; e && e !== t;) { if (n.test(e.nodeName)) return e; e = e.parentNode } return null }(f, t, /PRE|TABLE|H[1-6]|OL|UL|BLOCKQUOTE/)) { if (Ee(e, i, i, n), e.collapse(!0), c = e.endContainer, h = e.endOffset, Xe(i, n, !1), a(c) && (c = (g = T(c, h, u(c, n), n)).parentNode, h = ae.call(c.childNodes, g)), h !== m(c)) for (o = n.ownerDocument.createDocumentFragment(); r = c.childNodes[h];) o.appendChild(r); S(c, f, e, n), h = ae.call(c.parentNode.childNodes, c) + 1, c = c.parentNode, e.setEnd(c, h) } m(t) && (Ee(e, s, s, n), v = (g = T(e.endContainer, e.endOffset, s, n)) ? g.previousSibling : s.lastChild, s.insertBefore(t, g), g ? e.setEndBefore(g) : e.setEnd(s, m(s)), i = Se(e, n), Te(e), c = e.endContainer, h = e.endOffset, g && l(g) && N(g, n), (g = v && v.nextSibling) && l(g) && N(g, n), e.setEnd(c, h)), o && (S(i, o, y = e.cloneRange(), n), e.setEnd(y.endContainer, y.endOffset)), Te(e) }, _e = function (e, t, n) { var r = t.ownerDocument.createRange(); if (r.selectNode(t), n) { var i = e.compareBoundaryPoints(3, r) > -1, o = e.compareBoundaryPoints(1, r) < 1; return !i && !o } var a = e.compareBoundaryPoints(0, r) < 1, s = e.compareBoundaryPoints(2, r) > -1; return a && s }, Te = function (e) { for (var t, n = e.startContainer, r = e.startOffset, o = e.endContainer, a = e.endOffset, s = !0; n.nodeType !== R && (t = n.childNodes[r]) && !i(t);) n = t, r = 0; if (a) for (; o.nodeType !== R;) { if (!(t = o.childNodes[a - 1]) || i(t)) { if (s && t && "BR" === t.nodeName) { a -= 1, s = !1; continue } break } a = m(o = t) } else for (; o.nodeType !== R && (t = o.firstChild) && !i(t);) o = t; e.collapsed ? (e.setStart(o, a), e.setEnd(n, r)) : (e.setStart(n, r), e.setEnd(o, a)) }, Ee = function (e, t, n, r) { var i, o = e.startContainer, a = e.startOffset, s = e.endContainer, l = e.endOffset, c = !0; for (t || (t = e.commonAncestorContainer), n || (n = t); !a && o !== t && o !== r;) i = o.parentNode, a = ae.call(i.childNodes, o), o = i; for (; c && s.nodeType !== R && s.childNodes[l] && "BR" === s.childNodes[l].nodeName && (l += 1, c = !1), s !== n && s !== r && l === m(s);) i = s.parentNode, l = ae.call(i.childNodes, s) + 1, s = i; e.setStart(o, a), e.setEnd(s, l) }, xe = function (e, t) { var n, r = e.startContainer; return a(r) ? n = u(r, t) : r !== t && s(r) ? n = r : n = d(n = me(r, e.startOffset), t), n && _e(e, n, !0) ? n : null }, Se = function (e, t) { var n, r, i = e.endContainer; if (a(i)) n = u(i, t); else if (i !== t && s(i)) n = i; else { if (!(n = ve(i, e.endOffset)) || !g(t, n)) for (n = t; r = n.lastChild;) n = r; n = u(n, t) } return n && _e(e, n, !0) ? n : null }, Ne = new r(null, 4 | F, (function (e) { return e.nodeType === R ? oe.test(e.data) : "IMG" === e.nodeName })), ke = function (e, t) { var n, r = e.startContainer, i = e.startOffset; if (Ne.root = null, r.nodeType === R) { if (i) return !1; n = r } else if ((n = ve(r, i)) && !g(t, n) && (n = null), !n && ((n = me(r, i)).nodeType === R && n.length)) return !1; return Ne.currentNode = n, Ne.root = xe(e, t), !Ne.previousNode() }, Le = function (e, t) { var n, r = e.endContainer, i = e.endOffset; if (Ne.root = null, r.nodeType === R) { if ((n = r.data.length) && i < n) return !1; Ne.currentNode = r } else Ne.currentNode = me(r, i); return Ne.root = Se(e, t), !Ne.nextNode() }, Me = function (e, t) { var n, r = xe(e, t), i = Se(e, t); r && i && (n = r.parentNode, e.setStart(n, ae.call(n.childNodes, r)), n = i.parentNode, e.setEnd(n, ae.call(n.childNodes, i) + 1)) }, Ae = { 8: "backspace", 9: "tab", 13: "enter", 32: "space", 33: "pageup", 34: "pagedown", 37: "left", 39: "right", 46: "delete", 219: "[", 221: "]" }, Be = function (e) { var t = e.keyCode, n = Ae[t], r = "", i = this.getSelection(); e.defaultPrevented || (n || (n = String.fromCharCode(t).toLowerCase(), /^[A-Za-z0-9]$/.test(n) || (n = "")), Y && 46 === e.which && (n = "."), 111 < t && t < 124 && (n = "f" + (t - 111)), "backspace" !== n && "delete" !== n && (e.altKey && (r += "alt-"), e.ctrlKey && (r += "ctrl-"), e.metaKey && (r += "meta-")), e.shiftKey && (r += "shift-"), n = r + n, this._keyHandlers[n] ? this._keyHandlers[n](this, e, i) : i.collapsed || e.isComposing || e.ctrlKey || e.metaKey || 1 !== (Q ? n : e.key || n).length || (this.saveUndoState(i), Ce(i, this._root), this._ensureBottomLine(), this.setSelection(i), this._updatePath(i, !0))) }, Oe = function (e) { return function (t, n) { n.preventDefault(), t[e]() } }, De = function (e, t) { return t = t || null, function (n, r) { r.preventDefault(); var i = n.getSelection(); n.hasFormat(e, null, i) ? n.changeFormat(null, { tag: e }, i) : n.changeFormat({ tag: e }, t, i) } }, Ie = function (e, t) { try { t || (t = e.getSelection()); var n, r = t.startContainer; for (r.nodeType === R && (r = r.parentNode), n = r; a(n) && (!n.textContent || n.textContent === U);) n = (r = n).parentNode; r !== n && (t.setStart(n, ae.call(n.childNodes, r)), t.collapse(!0), n.removeChild(r), s(n) || (n = u(n, e._root)), w(n, e._root), Te(t)), r === e._root && (r = r.firstChild) && "BR" === r.nodeName && v(r), e._ensureBottomLine(), e.setSelection(t), e._updatePath(t, !0) } catch (t) { e.didError(t) } }, Re = { enter: function (e, t, n) { var r, i, o, a, s, l = e._root; if (t.preventDefault(), e._recordUndoState(n), p(n.startContainer, l, "PRE", { "data-te-codeblock": "" }) || pt(n.startContainer, l, e), e._removeZWS(), e._getRangeAndRemoveBookmark(n), n.collapsed || Ce(n, l), (r = xe(n, l)) && (i = p(r, l, "PRE"))) return Te(n), o = n.startContainer, a = n.startOffset, o.nodeType !== R && (o = e._doc.createTextNode(""), i.insertBefore(o, i.firstChild)), t.shiftKey || "\n" !== o.data.charAt(a - 1) && !ke(n, l) || "\n" !== o.data.charAt(a) && !Le(n, l) ? (o.insertData(a, "\n"), w(i, l), o.length === a + 1 ? n.setStartAfter(o) : n.setStart(o, a + 1)) : (o.deleteData(a && a - 1, a ? 2 : 1), (o = (s = T(o, a && a - 1, l, l)).previousSibling).textContent || v(o), o = e.createDefaultBlock(), s.parentNode.insertBefore(o, s), s.textContent || v(s), n.setStart(o, 0)), n.collapse(!0), e.setSelection(n), e._updatePath(n, !0), void e._docWasChanged(); if (!r || t.shiftKey || /^T[HD]$/.test(r.nodeName)) return (i = p(n.endContainer, l, "A")) && (i = i.parentNode, Ee(n, i, i, l), n.collapse(!1)), ye(n, e.createElement("BR")), n.collapse(!1), e.setSelection(n), void e._updatePath(n, !0); if ((i = p(r, l, "LI")) && (r = i), function (e) { return !e.textContent && !e.querySelector("IMG") }(r)) { if (p(r, l, "UL") || p(r, l, "OL")) return e.decreaseListLevel(n); if (p(r, l, "BLOCKQUOTE")) return e.modifyBlocks(dt, n) } for (s = ct(e, r, n.startContainer, n.startOffset), at(r), Ge(r), w(r, l); s.nodeType === I;) { var c, u = s.firstChild; if ("A" === s.nodeName && (!s.textContent || s.textContent === U)) { y(s, u = e._doc.createTextNode("")), s = u; break } for (; u && u.nodeType === R && !u.data && (c = u.nextSibling) && "BR" !== c.nodeName;) v(u), u = c; if (!u || "BR" === u.nodeName || u.nodeType === R && !Y) break; s = u } n = e.createRange(s, 0), e.setSelection(n), e._updatePath(n, !0) }, "shift-enter": function (e, t, n) { return e._keyHandlers.enter(e, t, n) }, backspace: function (e, t, n) { var r = e._root; if (e._removeZWS(), e.saveUndoState(n), n.collapsed) if (ke(n, r)) { t.preventDefault(); var i, o = xe(n, r); if (!o) return; if (_(o.parentNode, r), i = u(o, r)) { if (!i.isContentEditable) { for (; !i.parentNode.isContentEditable;) i = i.parentNode; return void v(i) } for (S(i, o, n, r), o = i.parentNode; o !== r && !o.nextSibling;) o = o.parentNode; o !== r && (o = o.nextSibling) && N(o, r), e.setSelection(n) } else if (o) { if (p(o, r, "UL") || p(o, r, "OL")) return e.decreaseListLevel(n); if (p(o, r, "BLOCKQUOTE")) return e.modifyBlocks(ut, n); e.setSelection(n), e._updatePath(n, !0) } } else e.setSelection(n), setTimeout((function () { Ie(e) }), 0); else t.preventDefault(), Ce(n, r), Ie(e, n) }, delete: function (e, t, n) { var r, i, o, a, s, l, c = e._root; if (e._removeZWS(), e.saveUndoState(n), n.collapsed) if (Le(n, c)) { if (t.preventDefault(), !(r = xe(n, c))) return; if (_(r.parentNode, c), i = d(r, c)) { if (!i.isContentEditable) { for (; !i.parentNode.isContentEditable;) i = i.parentNode; return void v(i) } for (S(r, i, n, c), i = r.parentNode; i !== c && !i.nextSibling;) i = i.parentNode; i !== c && (i = i.nextSibling) && N(i, c), e.setSelection(n), e._updatePath(n, !0) } } else { if (o = n.cloneRange(), Ee(n, c, c, c), a = n.endContainer, s = n.endOffset, a.nodeType === I && (l = a.childNodes[s]) && "IMG" === l.nodeName) return t.preventDefault(), v(l), Te(n), void Ie(e, n); e.setSelection(o), setTimeout((function () { Ie(e) }), 0) } else t.preventDefault(), Ce(n, c), Ie(e, n) }, tab: function (e, t, n) { var r, i, o = e._root; if (e._removeZWS(), n.collapsed && ke(n, o)) for (r = xe(n, o); i = r.parentNode;) { if ("UL" === i.nodeName || "OL" === i.nodeName) { t.preventDefault(), e.increaseListLevel(n); break } r = i } }, "shift-tab": function (e, t, n) { var r, i = e._root; e._removeZWS(), n.collapsed && ke(n, i) && ((p(r = n.startContainer, i, "UL") || p(r, i, "OL")) && (t.preventDefault(), e.decreaseListLevel(n))) }, space: function (e, t, n) { var r, i = e._root; if (e._recordUndoState(n), pt(n.startContainer, i, e), e._getRangeAndRemoveBookmark(n), r = n.endContainer, n.collapsed && n.endOffset === m(r)) do { if ("A" === r.nodeName) { n.setStartAfter(r); break } } while (!r.nextSibling && (r = r.parentNode) && r !== i); n.collapsed || (Ce(n, i), e._ensureBottomLine(), e.setSelection(n), e._updatePath(n, !0)), e.setSelection(n) }, left: function (e) { e._removeZWS() }, right: function (e) { e._removeZWS() } }; V && G && (Re["meta-left"] = function (e, t) { t.preventDefault(); var n = ot(e); n && n.modify && n.modify("move", "backward", "lineboundary") }, Re["meta-right"] = function (e, t) { t.preventDefault(); var n = ot(e); n && n.modify && n.modify("move", "forward", "lineboundary") }), V || (Re.pageup = function (e) { e.moveCursorToStart() }, Re.pagedown = function (e) { e.moveCursorToEnd() }), Re[J + "b"] = De("B"), Re[J + "i"] = De("I"), Re[J + "u"] = De("U"), Re[J + "shift-7"] = De("S"), Re[J + "shift-5"] = De("SUB", { tag: "SUP" }), Re[J + "shift-6"] = De("SUP", { tag: "SUB" }), Re[J + "shift-8"] = Oe("makeUnorderedList"), Re[J + "shift-9"] = Oe("makeOrderedList"), Re[J + "["] = Oe("decreaseQuoteLevel"), Re[J + "]"] = Oe("increaseQuoteLevel"), Re[J + "d"] = Oe("toggleCode"), Re[J + "y"] = Oe("redo"), Re[J + "z"] = Oe("undo"), Re[J + "shift-z"] = Oe("redo"); var Pe = { 1: 10, 2: 13, 3: 16, 4: 18, 5: 24, 6: 32, 7: 48 }, He = { backgroundColor: { regexp: oe, replace: function (e, t, n) { return C(e, "SPAN", { class: t.highlight, style: "background-color:" + n }) } }, color: { regexp: oe, replace: function (e, t, n) { return C(e, "SPAN", { class: t.colour, style: "color:" + n }) } }, fontWeight: { regexp: /^bold|^700/i, replace: function (e) { return C(e, "B") } }, fontStyle: { regexp: /^italic/i, replace: function (e) { return C(e, "I") } }, fontFamily: { regexp: oe, replace: function (e, t, n) { return C(e, "SPAN", { class: t.fontFamily, style: "font-family:" + n }) } }, fontSize: { regexp: oe, replace: function (e, t, n) { return C(e, "SPAN", { class: t.fontSize, style: "font-size:" + n }) } }, textDecoration: { regexp: /^underline/i, replace: function (e) { return C(e, "U") } } }, Fe = function (e) { return function (t, n) { var r = C(t.ownerDocument, e); return n.replaceChild(r, t), r.appendChild(b(t)), r } }, Ue = function (e, t, n) { var r, i, o, a, s, l, c = e.style, u = e.ownerDocument; for (r in He) i = He[r], (o = c[r]) && i.regexp.test(o) && (l = i.replace(u, n.classNames, o), s || (s = l), a && a.appendChild(l), a = l, e.style[r] = ""); return s && (a.appendChild(b(e)), "SPAN" === e.nodeName ? t.replaceChild(s, e) : e.appendChild(s)), a || e }, We = { P: Ue, SPAN: Ue, STRONG: Fe("B"), EM: Fe("I"), INS: Fe("U"), STRIKE: Fe("S"), FONT: function (e, t, n) { var r, i, o, a, s, l = e.face, c = e.size, u = e.color, d = e.ownerDocument, h = n.classNames; return l && (s = r = C(d, "SPAN", { class: h.fontFamily, style: "font-family:" + l }), a = r), c && (i = C(d, "SPAN", { class: h.fontSize, style: "font-size:" + Pe[c] + "px" }), s || (s = i), a && a.appendChild(i), a = i), u && /^#?([\dA-F]{3}){1,2}$/i.test(u) && ("#" !== u.charAt(0) && (u = "#" + u), o = C(d, "SPAN", { class: h.colour, style: "color:" + u }), s || (s = o), a && a.appendChild(o), a = o), s || (s = a = C(d, "SPAN")), t.replaceChild(s, e), a.appendChild(b(e)), a }, TT: function (e, t, n) { var r = C(e.ownerDocument, "SPAN", { class: n.classNames.fontFamily, style: 'font-family:menlo,consolas,"courier new",monospace' }); return t.replaceChild(r, e), r.appendChild(b(e)), r } }, qe = /^(?:A(?:DDRESS|RTICLE|SIDE|UDIO)|BLOCKQUOTE|CAPTION|D(?:[DLT]|IV)|F(?:IGURE|IGCAPTION|OOTER)|H[1-6]|HEADER|HR|L(?:ABEL|EGEND|I)|O(?:L|UTPUT)|P(?:RE)?|SECTION|T(?:ABLE|BODY|D|FOOT|H|HEAD|R)|COL(?:GROUP)?|UL)$/, ze = /^(?:HEAD|META|STYLE)/, je = new r(null, 4 | F), Ve = function (e, t) { var n, r = t.allowedBlocks, i = !1, o = r.length; if (o) { for (n = 0; n < o; n += 1) r[n] = r[n].toUpperCase(); i = new RegExp(r.join("|")).test(e) } return qe.test(e) || i }, Ke = function e(t, n, r) { var i, o, s, l, c, u, d, h, f, p, g, m, v = t.childNodes; for (i = t; a(i);) i = i.parentNode; for (je.root = i, o = 0, s = v.length; o < s; o += 1) if (c = (l = v[o]).nodeName, u = l.nodeType, d = We[c], u === I) { if (h = l.childNodes.length, d) l = d(l, t, n); else { if (ze.test(c)) { t.removeChild(l), o -= 1, s -= 1; continue } if (!Ve(c, n) && !a(l)) { o -= 1, s += h - 1, t.replaceChild(b(l), l); continue } } h && e(l, n, r || "PRE" === c) } else { if (u === R) { if (g = l.data, f = !oe.test(g.charAt(0)), p = !oe.test(g.charAt(g.length - 1)), r || !f && !p) continue; if (f) { for (je.currentNode = l; (m = je.previousPONode()) && !("IMG" === (c = m.nodeName) || "#text" === c && oe.test(m.data));) if (!a(m)) { m = null; break } g = g.replace(/^[ \t\r\n]+/g, m ? " " : "") } if (p) { for (je.currentNode = l; (m = je.nextNode()) && !("IMG" === c || "#text" === c && oe.test(m.data));) if (!a(m)) { m = null; break } g = g.replace(/[ \t\r\n]+$/g, m ? " " : "") } if (g) { l.data = g; continue } } t.removeChild(l), o -= 1, s -= 1 } return t }, Ge = function e(t) { for (var n, r = t.childNodes, o = r.length; o--;) if ((n = r[o]).nodeType !== I || i(n)) n.nodeType !== R || n.data || t.removeChild(n); else { e(n); var s = "FIGURE" === n.tagName; !a(n) && !s || n.firstChild || t.removeChild(n) } }, $e = function (e) { return e.nodeType === I ? "BR" === e.nodeName || "IMG" === e.nodeName : oe.test(e.data) }, Ye = function (e, t) { for (var n, i = e.parentNode; a(i);) i = i.parentNode; return (n = new r(i, 4 | F, $e)).currentNode = e, !!n.nextNode() || t && !n.previousNode() }, Xe = function (e, t, n) { var r, i, o, s = e.querySelectorAll("BR"), l = [], c = s.length; for (r = 0; r < c; r += 1) l[r] = Ye(s[r], n); for (; c--;)(o = (i = s[c]).parentNode) && (l[c] ? a(o) || _(o, t) : v(i)) }, Ze = function (e, t, n, r) { var i, o, a = t.ownerDocument.body, s = r.willCutCopy; Xe(t, n, !0), t.setAttribute("style", "position:fixed;overflow:hidden;bottom:100%;right:100%;"), a.appendChild(t), i = t.innerHTML, o = t.innerText || t.textContent, s && (i = s(i)), K && (o = o.replace(/\r?\n/g, "\r\n")), e.setData("text/html", i), e.setData("text/plain", o), a.removeChild(t) }, Qe = function (e) { var t, n, r, i, o, a, s = e.clipboardData, l = this.getSelection(), c = this._root, u = this; if (l.collapsed) e.preventDefault(); else { if (this.saveUndoState(l), X || j || !s) setTimeout((function () { try { u._ensureBottomLine() } catch (e) { u.didError(e) } }), 0); else { for (n = (t = xe(l, c)) === Se(l, c) && t || c, r = Ce(l, c), (i = l.commonAncestorContainer).nodeType === R && (i = i.parentNode); i && i !== n;)(o = i.cloneNode(!1)).appendChild(r), r = o, i = i.parentNode; (a = this.createElement("div")).appendChild(r), Ze(s, a, c, this._config), e.preventDefault() } this.setSelection(l) } }, Je = function (e) { var t, n, r, i, o, a, s = e.clipboardData, l = this.getSelection(), c = this._root; if (!X && !j && s) { for (n = (t = xe(l, c)) === Se(l, c) && t || c, l = l.cloneRange(), Te(l), Ee(l, n, n, c), r = l.cloneContents(), (i = l.commonAncestorContainer).nodeType === R && (i = i.parentNode); i && i !== n;)(o = i.cloneNode(!1)).appendChild(r), r = o, i = i.parentNode; (a = this.createElement("div")).appendChild(r), Ze(s, a, c, this._config), e.preventDefault() } }, et = function (e) { var t, n, r, i, o, a = e.clipboardData, s = a && a.items, l = this.isShiftDown, c = !1, u = !1, d = null, h = this; if (s) { for (e.preventDefault(), t = s.length; t--;) { if (r = (n = s[t]).type, !l && "text/html" === r) return void n.getAsString((function (e) { h.insertHTML(e, !0) })); "text/plain" === r && (d = n), !l && /^image\/.*/.test(r) && (u = !0) } u ? (this.fireEvent("dragover", { dataTransfer: a, preventDefault: function () { c = !0 } }), c && this.fireEvent("drop", { dataTransfer: a })) : d && d.getAsString((function (e) { h.insertPlainText(e, !0) })) } else { if (i = a && a.types, !X && i && (ae.call(i, "text/html") > -1 || !G && ae.call(i, "text/plain") > -1 && ae.call(i, "text/rtf") < 0)) return e.preventDefault(), void(!l && (o = a.getData("text/html")) ? this.insertHTML(o, !0) : ((o = a.getData("text/plain")) || (o = a.getData("text/uri-list"))) && this.insertPlainText(o, !0)); this._awaitingPaste = !0; var f = this._doc.body, p = this.getSelection(), g = p.startContainer, m = p.startOffset, y = p.endContainer, b = p.endOffset, C = this.createElement("DIV", { contenteditable: "true", style: "position:fixed; overflow:hidden; top:0; right:100%; width:1px; height:1px;" }); f.appendChild(C), p.selectNodeContents(C), this.setSelection(p), setTimeout((function () { try { h._awaitingPaste = !1; for (var e, t, n = "", r = C; C = r;) r = C.nextSibling, v(C), (e = C.firstChild) && e === C.lastChild && "DIV" === e.nodeName && (C = e), n += C.innerHTML; t = h.createRange(g, m, y, b), h.setSelection(t), n && h.insertHTML(n, !0) } catch (e) { h.didError(e) } }), 0) } }, tt = function (e) { for (var t = e.dataTransfer.types, n = t.length, r = !1, i = !1; n--;) switch (t[n]) { case "text/plain": r = !0; break; case "text/html": i = !0; break; default: return }(i || r) && this.saveUndoState() }, nt = M.prototype, rt = function (e, t, n) { var r = n._doc, i = e ? DOMPurify.sanitize(e, { ALLOW_UNKNOWN_PROTOCOLS: !0, WHOLE_DOCUMENT: !1, RETURN_DOM: !0, RETURN_DOM_FRAGMENT: !0 }) : null; return i ? r.importNode(i, !0) : r.createDocumentFragment() }; nt.setConfig = function (e) { return (e = L({ blockTag: "DIV", blockAttributes: null, tagAttributes: { blockquote: null, ul: null, ol: null, li: null, a: null }, classNames: { colour: "colour", fontFamily: "font", fontSize: "size", highlight: "highlight" }, leafNodeNames: ue, undo: { documentSizeThreshold: -1, undoLimit: -1 }, isInsertedHTMLSanitized: !0, isSetHTMLSanitized: !0, sanitizeToDOMFragment: "undefined" != typeof DOMPurify && DOMPurify.isSupported ? rt : null, willCutCopy: null, allowedBlocks: [] }, e, !0)).blockTag = e.blockTag.toUpperCase(), this._config = e, this }, nt.createElement = function (e, t, n) { return C(this._doc, e, t, n) }, nt.createDefaultBlock = function (e) { var t = this._config; return w(this.createElement(t.blockTag, t.blockAttributes, e), this._root) }, nt.didError = function (e) { console.log(e) }, nt.getDocument = function () { return this._doc }, nt.getRoot = function () { return this._root }, nt.modifyDocument = function (e) { var t = this._mutation; t && (t.takeRecords().length && this._docWasChanged(), t.disconnect()), this._ignoreAllChanges = !0, e(), this._ignoreAllChanges = !1, t && (t.observe(this._root, { childList: !0, attributes: !0, characterData: !0, subtree: !0 }), this._ignoreChange = !1) }; var it = { pathChange: 1, select: 1, input: 1, undoStateChange: 1 }; nt.fireEvent = function (e, t) { var n, r, i, o = this._events[e]; if (/^(?:focus|blur)/.test(e)) if (n = this._root === this._doc.activeElement, "focus" === e) { if (!n || this._isFocused) return this; this._isFocused = !0 } else { if (n || !this._isFocused) return this; this._isFocused = !1 } if (o) for (t || (t = {}), t.type !== e && (t.type = e), r = (o = o.slice()).length; r--;) { i = o[r]; try { i.handleEvent ? i.handleEvent(t) : i.call(this, t) } catch (t) { t.details = "Squire: fireEvent error. Event type: " + e, this.didError(t) } } return this }, nt.destroy = function () { var e, t = this._events; for (e in t) this.removeEventListener(e); this._mutation && this._mutation.disconnect(), delete this._root.__squire__, this._undoIndex = -1, this._undoStack = [], this._undoStackLength = 0 }, nt.handleEvent = function (e) { this.fireEvent(e.type, e) }, nt.addEventListener = function (e, t) { var n = this._events[e], r = this._root; return t ? (n || (n = this._events[e] = [], it[e] || ("selectionchange" === e && (r = this._doc), r.addEventListener(e, this, !0))), n.push(t), this) : (this.didError({ name: "Squire: addEventListener with null or undefined fn", message: "Event type: " + e }), this) }, nt.removeEventListener = function (e, t) { var n, r = this._events[e], i = this._root; if (r) { if (t) for (n = r.length; n--;) r[n] === t && r.splice(n, 1); else r.length = 0; r.length || (delete this._events[e], it[e] || ("selectionchange" === e && (i = this._doc), i.removeEventListener(e, this, !0))) } return this }, nt.createRange = function (e, t, n, r) { if (e instanceof this._win.Range) return e.cloneRange(); var i = this._doc.createRange(); return i.setStart(e, t), n ? i.setEnd(n, r) : i.setEnd(e, t), i }, nt.getCursorPosition = function (e) { if (!e && !(e = this.getSelection()) || !e.getBoundingClientRect) return null; var t, n, r = e.getBoundingClientRect(); return r && !r.top && (this._ignoreChange = !0, (t = this._doc.createElement("SPAN")).textContent = U, ye(e, t), r = t.getBoundingClientRect(), (n = t.parentNode).removeChild(t), E(n, e), this._ignoreChange = !1), r }, nt._moveCursorTo = function (e) { var t = this._root, n = this.createRange(t, e ? 0 : t.childNodes.length); return Te(n), this.setSelection(n), this }, nt.moveCursorToStart = function () { return this._moveCursorTo(!0) }, nt.moveCursorToEnd = function () { return this._moveCursorTo(!1) }; var ot = function (e) { return e._win.getSelection() || null }; nt.setSelection = function (e) { if (e) if (this._lastSelection = e, this._isFocused) if (z && !this._restoreSelection) A.call(this), this.blur(), this.focus(); else { j && this._win.focus(); var t = ot(this); t && (t.removeAllRanges(), t.addRange(e)) } else A.call(this); return this }, nt.getSelection = function () { var e, t, n, r, o = ot(this), a = this._root; return this._isFocused && o && o.rangeCount && (t = (e = o.getRangeAt(0).cloneRange()).startContainer, n = e.endContainer, t && i(t) && e.setStartBefore(t), n && i(n) && e.setEndBefore(n)), e && g(a, e.commonAncestorContainer) ? this._lastSelection = e : g((r = (e = this._lastSelection).commonAncestorContainer).ownerDocument, r) || (e = null), e || (e = this.createRange(a.firstChild, 0)), e }, nt.getSelectedText = function () { var e = this.getSelection(); if (!e || e.collapsed) return ""; var t, n = new r(e.commonAncestorContainer, 4 | F, (function (t) { return _e(e, t, !0) })), i = e.startContainer, o = e.endContainer, s = n.currentNode = i, l = "", c = !1; for (n.filter(s) || (s = n.nextNode()); s;) s.nodeType === R ? (t = s.data) && /\S/.test(t) && (s === o && (t = t.slice(0, e.endOffset)), s === i && (t = t.slice(e.startOffset)), l += t, c = !0) : ("BR" === s.nodeName || c && !a(s)) && (l += "\n", c = !1), s = n.nextNode(); return l }, nt.getPath = function () { return this._path }; var at = function (e, t) { for (var n, i, o, s = new r(e, 4); i = s.nextNode();) for (; (o = i.data.indexOf(U)) > -1 && (!t || i.parentNode !== t);) { if (1 === i.length) { do { (n = i.parentNode).removeChild(i), i = n, s.currentNode = n } while (a(i) && !m(i)); break } i.deleteData(o, 1) } }; nt._didAddZWS = function () { this._hasZWS = !0 }, nt._removeZWS = function () { this._hasZWS && (at(this._root), this._hasZWS = !1) }, nt._updatePath = function (e, t) { if (e) { var n, r = e.startContainer, i = e.endContainer; (t || r !== this._lastAnchorNode || i !== this._lastFocusNode) && (this._lastAnchorNode = r, this._lastFocusNode = i, n = r && i ? r === i ? function e(t, n, r) { var i, o, a, s, l, c = ""; return t && t !== n && (c = e(t.parentNode, n, r), t.nodeType === I && (c += (c ? ">" : "") + t.nodeName, (i = t.id) && (c += "#" + i), (o = t.className.trim()) && ((a = o.split(/\s\s*/)).sort(), c += ".", c += a.join(".")), (s = t.dir) && (c += "[dir=" + s + "]"), a && (l = r.classNames, ae.call(a, l.highlight) > -1 && (c += "[backgroundColor=" + t.style.backgroundColor.replace(/ /g, "") + "]"), ae.call(a, l.colour) > -1 && (c += "[color=" + t.style.color.replace(/ /g, "") + "]"), ae.call(a, l.fontFamily) > -1 && (c += "[fontFamily=" + t.style.fontFamily.replace(/ /g, "") + "]"), ae.call(a, l.fontSize) > -1 && (c += "[fontSize=" + t.style.fontSize + "]")))), c }(i, this._root, this._config) : "(selection)" : "", this._path !== n && (this._path = n, this.fireEvent("pathChange", { path: n }))), this.fireEvent(e.collapsed ? "cursor" : "select", { range: e }) } }, nt._updatePathOnEvent = function (e) { var t = this; t._isFocused && !t._willUpdatePath && (t._willUpdatePath = !0, setTimeout((function () { t._willUpdatePath = !1, t._updatePath(t.getSelection()) }), 0)) }, nt.focus = function () { if (Q) { try { this._root.setActive() } catch (e) {} this.fireEvent("focus") } else this._root.focus(); return this }, nt.blur = function () { return this._root.blur(), Q && this.fireEvent("blur"), this }; var st = "squire-selection-end"; nt._saveRangeToBookmark = function (e) { var t, n = this.createElement("INPUT", { id: "squire-selection-start", type: "hidden" }), r = this.createElement("INPUT", { id: st, type: "hidden" }); ye(e, n), e.collapse(!1), ye(e, r), 2 & n.compareDocumentPosition(r) && (n.id = st, r.id = "squire-selection-start", t = n, n = r, r = t), e.setStartAfter(n), e.setEndBefore(r) }, nt._getRangeAndRemoveBookmark = function (e) { var t = this._root, n = t.querySelector("#squire-selection-start"), r = t.querySelector("#" + st); if (n && r) { var i = n.parentNode, o = r.parentNode, a = ae.call(i.childNodes, n), s = ae.call(o.childNodes, r); i === o && (s -= 1), v(n), v(r), e || (e = this._doc.createRange()), e.setStart(i, a), e.setEnd(o, s), E(i, e), i !== o && E(o, e), e.collapsed && ((i = e.startContainer).nodeType === R && ((o = i.childNodes[e.startOffset]) && o.nodeType === R || (o = i.childNodes[e.startOffset - 1]), o && o.nodeType === R && (e.setStart(o, 0), e.collapse(!0)))) } return e || null }, nt._keyUpDetectChange = function (e) { var t = e.keyCode; e.ctrlKey || e.metaKey || e.altKey || !(t < 16 || t > 20) || !(t < 33 || t > 45) || this._docWasChanged() }, nt._docWasChanged = function () { if (ie && (ge = new WeakMap), !this._ignoreAllChanges) { if (re && this._ignoreChange) return void(this._ignoreChange = !1); this._isInUndoState && (this._isInUndoState = !1, this.fireEvent("undoStateChange", { canUndo: !0, canRedo: !1 })), this.fireEvent("input") } }, nt._recordUndoState = function (e, t) { if (!this._isInUndoState || t) { var n, r = this._undoIndex, i = this._undoStack, o = this._config.undo, a = o.documentSizeThreshold, s = o.undoLimit; t || (r += 1), r < this._undoStackLength && (i.length = this._undoStackLength = r), e && this._saveRangeToBookmark(e), n = this._getHTML(), a > -1 && 2 * n.length > a && s > -1 && r > s && (i.splice(0, r - s), r = s, this._undoStackLength = s), i[r] = n, this._undoIndex = r, this._undoStackLength += 1, this._isInUndoState = !0 } }, nt.saveUndoState = function (e) { return e === n && (e = this.getSelection()), this._recordUndoState(e, this._isInUndoState), this._getRangeAndRemoveBookmark(e), this }, nt.undo = function () { if (0 !== this._undoIndex || !this._isInUndoState) { this._recordUndoState(this.getSelection(), !1), this._undoIndex -= 1, this._setHTML(this._undoStack[this._undoIndex]); var e = this._getRangeAndRemoveBookmark(); e && this.setSelection(e), this._isInUndoState = !0, this.fireEvent("undoStateChange", { canUndo: 0 !== this._undoIndex, canRedo: !0 }), this.fireEvent("input") } return this }, nt.redo = function () { var e = this._undoIndex, t = this._undoStackLength; if (e + 1 < t && this._isInUndoState) { this._undoIndex += 1, this._setHTML(this._undoStack[this._undoIndex]); var n = this._getRangeAndRemoveBookmark(); n && this.setSelection(n), this.fireEvent("undoStateChange", { canUndo: !0, canRedo: e + 2 < t }), this.fireEvent("input") } return this }, nt.hasFormat = function (e, t, n) { if (e = e.toUpperCase(), t || (t = {}), !n && !(n = this.getSelection())) return !1; !n.collapsed && n.startContainer.nodeType === R && n.startOffset === n.startContainer.length && n.startContainer.nextSibling && n.setStartBefore(n.startContainer.nextSibling), !n.collapsed && n.endContainer.nodeType === R && 0 === n.endOffset && n.endContainer.previousSibling && n.setEndAfter(n.endContainer.previousSibling); var i, o, a = this._root, s = n.commonAncestorContainer; if (p(s, a, e, t)) return !0; if (s.nodeType === R) return !1; i = new r(s, 4, (function (e) { return _e(n, e, !0) })); for (var l = !1; o = i.nextNode();) { if (!p(o, a, e, t)) return !1; l = !0 } return l }, nt.getFontInfo = function (e) { var t, r, i, o = { color: n, backgroundColor: n, family: n, size: n }, a = 0; if (!e && !(e = this.getSelection())) return o; if (t = e.commonAncestorContainer, e.collapsed || t.nodeType === R) for (t.nodeType === R && (t = t.parentNode); a < 4 && t;)(r = t.style) && (!o.color && (i = r.color) && (o.color = i, a += 1), !o.backgroundColor && (i = r.backgroundColor) && (o.backgroundColor = i, a += 1), !o.family && (i = r.fontFamily) && (o.family = i, a += 1), !o.size && (i = r.fontSize) && (o.size = i, a += 1)), t = t.parentNode; return o }, nt._addFormat = function (e, t, n) { var i, o, s, l, c, u, d, h, f = this._root; if (n.collapsed) { for (i = w(this.createElement(e, t), f), ye(n, i), n.setStart(i.firstChild, i.firstChild.length), n.collapse(!0), h = i; a(h);) h = h.parentNode; at(h, i) } else { if (o = new r(n.commonAncestorContainer, 4 | F, (function (e) { return (e.nodeType === R || "BR" === e.nodeName || "IMG" === e.nodeName) && _e(n, e, !0) })), s = n.startContainer, c = n.startOffset, l = n.endContainer, u = n.endOffset, o.currentNode = s, o.filter(s) || (s = o.nextNode(), c = 0), !s) return n; do { !p(d = o.currentNode, f, e, t) && (d === l && d.length > u && d.splitText(u), d === s && c && (d = d.splitText(c), l === s && (l = d, u -= c), s = d, c = 0), y(d, i = this.createElement(e, t)), i.appendChild(d)) } while (o.nextNode()); l.nodeType !== R && (d.nodeType === R ? (l = d, u = d.length) : (l = d.parentNode, u = 1)), n = this.createRange(s, c, l, u) } return n }, nt._removeFormat = function (e, t, n, r) { this._saveRangeToBookmark(n); var i, o = this._doc; n.collapsed && (te ? (i = o.createTextNode(U), this._didAddZWS()) : i = o.createTextNode(""), ye(n, i)); for (var s = n.commonAncestorContainer; a(s);) s = s.parentNode; var l = n.startContainer, c = n.startOffset, u = n.endContainer, d = n.endOffset, h = [], p = function (e, t) { if (!_e(n, e, !1)) { var r, i, o = e.nodeType === R; if (!_e(n, e, !0)) return void("INPUT" === e.nodeName || o && !e.data || h.push([t, e])); if (o) e === u && d !== e.length && h.push([t, e.splitText(d)]), e === l && c && (e.splitText(c), h.push([t, e])); else for (r = e.firstChild; r; r = i) i = r.nextSibling, p(r, t) } }, g = Array.prototype.filter.call(s.getElementsByTagName(e), (function (r) { return _e(n, r, !0) && f(r, e, t) })); return r || g.forEach((function (e) { p(e, e) })), h.forEach((function (e) { var t = e[0].cloneNode(!1), n = e[1]; y(n, t), t.appendChild(n) })), g.forEach((function (e) { y(e, b(e)) })), this._getRangeAndRemoveBookmark(n), i && n.collapse(!1), E(s, n), n }, nt.changeFormat = function (e, t, n, r) { return n || (n = this.getSelection()) ? (this.saveUndoState(n), t && (n = this._removeFormat(t.tag.toUpperCase(), t.attributes || {}, n, r)), e && (n = this._addFormat(e.tag.toUpperCase(), e.attributes || {}, n)), this.setSelection(n), this._updatePath(n, !0), re || this._docWasChanged(), this) : this }; var lt = { DT: "DD", DD: "DT", LI: "LI", PRE: "PRE" }, ct = function (e, t, n, r) { var i = lt[t.nodeName], o = null, a = T(n, r, t.parentNode, e._root), s = e._config; return i || (i = s.blockTag, o = s.blockAttributes), f(a, i, o) || (t = C(a.ownerDocument, i, o), a.dir && (t.dir = a.dir), y(a, t), t.appendChild(b(a)), a = t), a }; nt.forEachBlock = function (e, t, n) { if (!n && !(n = this.getSelection())) return this; t && this.saveUndoState(n); var r = this._root, i = xe(n, r), o = Se(n, r); if (i && o) do { if (e(i) || i === o) break } while (i = d(i, r)); return t && (this.setSelection(n), this._updatePath(n, !0), re || this._docWasChanged()), this }, nt.modifyBlocks = function (e, t) { if (!t && !(t = this.getSelection())) return this; this._recordUndoState(t, this._isInUndoState); var n, r = this._root; return Me(t, r), Ee(t, r, r, r), n = be(t, r, r), ye(t, e.call(this, n)), t.endOffset < t.endContainer.childNodes.length && N(t.endContainer.childNodes[t.endOffset], r), N(t.startContainer.childNodes[t.startOffset], r), this._getRangeAndRemoveBookmark(t), this.setSelection(t), this._updatePath(t, !0), re || this._docWasChanged(), this }; var ut = function (e) { var t = this._root, n = e.querySelectorAll("blockquote"); return Array.prototype.filter.call(n, (function (e) { return !p(e.parentNode, t, "BLOCKQUOTE") })).forEach((function (e) { y(e, b(e)) })), e }, dt = function () { return this.createDefaultBlock([this.createElement("INPUT", { id: "squire-selection-start", type: "hidden" }), this.createElement("INPUT", { id: st, type: "hidden" })]) }, ht = function (e, t, n) { for (var r, i, o, a, s = c(t, e._root), l = e._config.tagAttributes, u = l[n.toLowerCase()], d = l.li; r = s.nextNode();) "LI" === r.parentNode.nodeName && (r = r.parentNode, s.currentNode = r.lastChild), "LI" !== r.nodeName ? (a = e.createElement("LI", d), r.dir && (a.dir = r.dir), (o = r.previousSibling) && o.nodeName === n ? (o.appendChild(a), v(r)) : y(r, e.createElement(n, u, [a])), a.appendChild(b(r)), s.currentNode = a) : (i = (r = r.parentNode).nodeName) !== n && /^[OU]L$/.test(i) && y(r, e.createElement(n, u, [b(r)])) }, ft = function (e, t) { for (var n = e.commonAncestorContainer, r = e.startContainer, i = e.endContainer; n && n !== t && !/^[OU]L$/.test(n.nodeName);) n = n.parentNode; if (!n || n === t) return null; for (r === n && (r = r.childNodes[e.startOffset]), i === n && (i = i.childNodes[e.endOffset]); r && r.parentNode !== n;) r = r.parentNode; for (; i && i.parentNode !== n;) i = i.parentNode; return [n, r, i] }; nt.increaseListLevel = function (e) { if (!e && !(e = this.getSelection())) return this.focus(); var t = this._root, n = ft(e, t); if (!n) return this.focus(); var r = n[0], i = n[1], o = n[2]; if (!i || i === r.firstChild) return this.focus(); this._recordUndoState(e, this._isInUndoState); var a, s, l = r.nodeName, c = i.previousSibling; c.nodeName !== l && (a = this._config.tagAttributes[l.toLowerCase()], c = this.createElement(l, a), r.insertBefore(c, i)); do { s = i === o ? null : i.nextSibling, c.appendChild(i) } while (i = s); return (s = c.nextSibling) && N(s, t), this._getRangeAndRemoveBookmark(e), this.setSelection(e), this._updatePath(e, !0), re || this._docWasChanged(), this.focus() }, nt.decreaseListLevel = function (e) { if (!e && !(e = this.getSelection())) return this.focus(); var t = this._root, n = ft(e, t); if (!n) return this.focus(); var r = n[0], i = n[1], o = n[2]; i || (i = r.firstChild), o || (o = r.lastChild), this._recordUndoState(e, this._isInUndoState); var a, s = r.parentNode, l = o.nextSibling ? T(r, o.nextSibling, s, t) : r.nextSibling; if (s !== t && "LI" === s.nodeName) { for (s = s.parentNode; l;) a = l.nextSibling, o.appendChild(l), l = a; l = r.parentNode.nextSibling } var c = !/^[OU]L$/.test(s.nodeName); do { a = i === o ? null : i.nextSibling, r.removeChild(i), c && "LI" === i.nodeName && (i = this.createDefaultBlock([b(i)])), s.insertBefore(i, l) } while (i = a); return r.firstChild || v(r), l && N(l, t), this._getRangeAndRemoveBookmark(e), this.setSelection(e), this._updatePath(e, !0), re || this._docWasChanged(), this.focus() }, nt._ensureBottomLine = function () { var e = this._root, t = e.lastElementChild; t && t.nodeName === this._config.blockTag && s(t) || e.appendChild(this.createDefaultBlock()) }, nt.setKeyHandler = function (e, t) { return this._keyHandlers[e] = t, this }, nt._getHTML = function () { return this._root.innerHTML }, nt._setHTML = function (e) { var t = this._root, n = t; n.innerHTML = e; do { w(n, t) } while (n = d(n, t)); this._ignoreChange = !0 }, nt.getHTML = function (e) { var t, n, r, i, o, a, s = []; if (e && (a = this.getSelection()) && this._saveRangeToBookmark(a), ee) for (n = t = this._root; n = d(n, t);) n.textContent || n.querySelector("BR") || (r = this.createElement("BR"), n.appendChild(r), s.push(r)); if (i = this._getHTML().replace(/\u200B/g, ""), ee) for (o = s.length; o--;) v(s[o]); return a && this._getRangeAndRemoveBookmark(a), i }, nt.setHTML = function (e) { var t, n, r, i = this._config, o = i.isSetHTMLSanitized ? i.sanitizeToDOMFragment : null, a = this._root; "function" == typeof o ? n = o(e, !1, this) : ((t = this.createElement("DIV")).innerHTML = e, (n = this._doc.createDocumentFragment()).appendChild(b(t))), Ke(n, i), Xe(n, a, !1), _(n, a); for (var s = n; s = d(s, a);) w(s, a); for (this._ignoreChange = !0; r = a.lastChild;) a.removeChild(r); a.appendChild(n), w(a, a), this._undoIndex = -1, this._undoStack.length = 0, this._undoStackLength = 0, this._isInUndoState = !1; var l = this._getRangeAndRemoveBookmark() || this.createRange(a.firstChild, 0); return this.saveUndoState(l), this._lastSelection = l, A.call(this), this._updatePath(l, !0), this }, nt.insertElement = function (e, t) { if (t || (t = this.getSelection()), t.collapse(!0), a(e)) ye(t, e), t.setStartAfter(e); else { for (var n, r = this._root, i = xe(t, r) || r; i !== r && !i.nextSibling;) i = i.parentNode; i !== r && (n = T(i.parentNode, i.nextSibling, r, r)), n ? r.insertBefore(e, n) : (r.appendChild(e), n = this.createDefaultBlock(), r.appendChild(n)), t.setStart(n, 0), t.setEnd(n, 0), Te(t) } return this.focus(), this.setSelection(t), this._updatePath(t), re || this._docWasChanged(), this }, nt.insertImage = function (e, t) { var n = this.createElement("IMG", L({ src: e }, t, !0)); return this.insertElement(n), n }, nt.linkRegExp = /\b((?:(?:ht|f)tps?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,}\/)(?:[^\s()<>]+|\([^\s()<>]+\))+(?:\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))|([\w\-.%+]+@(?:[\w\-]+\.)+[A-Z]{2,}\b)(?:\?[^&?\s]+=[^&?\s]+(?:&[^&?\s]+=[^&?\s]+)*)?/i; var pt = function (e, t, n) { var i, o, a, s, l, c, u, d = e.ownerDocument, h = new r(e, 4, (function (e) { return !p(e, t, "A") })), f = n.linkRegExp, g = n._config.tagAttributes.a; if (f) for (; i = h.nextNode();) for (o = i.data, a = i.parentNode; s = f.exec(o);) c = (l = s.index) + s[0].length, l && (u = d.createTextNode(o.slice(0, l)), a.insertBefore(u, i)), (u = n.createElement("A", L({ href: s[1] ? /^(?:ht|f)tps?:/i.test(s[1]) ? s[1] : "http://" + s[1] : "mailto:" + s[0] }, g, !1))).textContent = o.slice(l, c), a.insertBefore(u, i), i.data = o = o.slice(c) }; nt.insertHTML = function (e, t) { var n, r, i, o, a, s, l, c = this._config, u = c.isInsertedHTMLSanitized ? c.sanitizeToDOMFragment : null, h = this.getSelection(), f = this._doc; "function" == typeof u ? o = u(e, t, this) : (t && (n = e.indexOf("\x3c!--StartFragment--\x3e"), r = e.lastIndexOf("\x3c!--EndFragment--\x3e"), n > -1 && r > -1 && (e = e.slice(n + 20, r))), /<\/td>((?!<\/tr>)[\s\S])*$/i.test(e) && (e = "" + e + ""), /<\/tr>((?!<\/table>)[\s\S])*$/i.test(e) && (e = "" + e + "
"), (i = this.createElement("DIV")).innerHTML = e, (o = f.createDocumentFragment()).appendChild(b(i))), this.saveUndoState(h); try { for (a = this._root, s = o, l = { fragment: o, preventDefault: function () { this.defaultPrevented = !0 }, defaultPrevented: !1 }, pt(o, o, this), Ke(o, c), Xe(o, a, !1), Ge(o), o.normalize(); s = d(s, o);) w(s, a); t && this.fireEvent("willPaste", l), l.defaultPrevented || (we(h, l.fragment, a), re || this._docWasChanged(), h.collapse(!1), this._ensureBottomLine()), this.setSelection(h), this._updatePath(h, !0), t && this.focus() } catch (e) { this.didError(e) } return this }; var gt = function (e) { return e.split("&").join("&").split("<").join("<").split(">").join(">").split('"').join(""") }; nt.insertPlainText = function (e, t) { var n = this.getSelection(); if (n.collapsed && p(n.startContainer, this._root, "PRE")) { var r, i, o = n.startContainer, a = n.startOffset; return o && o.nodeType === R || (r = this._doc.createTextNode(""), o.insertBefore(r, o.childNodes[a]), o = r, a = 0), i = { text: e, preventDefault: function () { this.defaultPrevented = !0 }, defaultPrevented: !1 }, t && this.fireEvent("willPaste", i), i.defaultPrevented || (e = i.text, o.insertData(a, e), n.setStart(o, a + e.length), n.collapse(!0)), this.setSelection(n), this } var s, l, c, u, d = e.split("\n"), h = this._config, f = h.blockTag, g = h.blockAttributes, m = "", v = "<" + f; for (s in g) v += " " + s + '="' + gt(g[s]) + '"'; for (v += ">", l = 0, c = d.length; l < c; l += 1) u = d[l], u = gt(u).replace(/ (?= )/g, " "), d[l] = v + (u || "
") + m; return this.insertHTML(d.join(""), t) }; var mt = function (e, t, n) { return function () { return this[e](t, n), this.focus() } }; nt.addStyles = function (e) { if (e) { var t = this._doc.documentElement.firstChild, n = this.createElement("STYLE", { type: "text/css" }); n.appendChild(this._doc.createTextNode(e)), t.appendChild(n) } return this }, nt.bold = mt("changeFormat", { tag: "B" }), nt.italic = mt("changeFormat", { tag: "I" }), nt.underline = mt("changeFormat", { tag: "U" }), nt.strikethrough = mt("changeFormat", { tag: "S" }), nt.subscript = mt("changeFormat", { tag: "SUB" }, { tag: "SUP" }), nt.superscript = mt("changeFormat", { tag: "SUP" }, { tag: "SUB" }), nt.removeBold = mt("changeFormat", null, { tag: "B" }), nt.removeItalic = mt("changeFormat", null, { tag: "I" }), nt.removeUnderline = mt("changeFormat", null, { tag: "U" }), nt.removeStrikethrough = mt("changeFormat", null, { tag: "S" }), nt.removeSubscript = mt("changeFormat", null, { tag: "SUB" }), nt.removeSuperscript = mt("changeFormat", null, { tag: "SUP" }), nt.makeLink = function (e, t) { var n = this.getSelection(); if (n.collapsed) { var r = e.indexOf(":") + 1; if (r) for (; "/" === e[r];) r += 1; ye(n, this._doc.createTextNode(e.slice(r))) } return t = L(L({ href: e }, t, !0), this._config.tagAttributes.a, !1), this.changeFormat({ tag: "A", attributes: t }, { tag: "A" }, n), this.focus() }, nt.removeLink = function () { return this.changeFormat(null, { tag: "A" }, this.getSelection(), !0), this.focus() }, nt.setFontFace = function (e) { var t = this._config.classNames.fontFamily; return this.changeFormat(e ? { tag: "SPAN", attributes: { class: t, style: "font-family: " + e + ", sans-serif;" } } : null, { tag: "SPAN", attributes: { class: t } }), this.focus() }, nt.setFontSize = function (e) { var t = this._config.classNames.fontSize; return this.changeFormat(e ? { tag: "SPAN", attributes: { class: t, style: "font-size: " + ("number" == typeof e ? e + "px" : e) } } : null, { tag: "SPAN", attributes: { class: t } }), this.focus() }, nt.setTextColour = function (e) { var t = this._config.classNames.colour; return this.changeFormat(e ? { tag: "SPAN", attributes: { class: t, style: "color:" + e } } : null, { tag: "SPAN", attributes: { class: t } }), this.focus() }, nt.setHighlightColour = function (e) { var t = this._config.classNames.highlight; return this.changeFormat(e ? { tag: "SPAN", attributes: { class: t, style: "background-color:" + e } } : e, { tag: "SPAN", attributes: { class: t } }), this.focus() }, nt.setTextAlignment = function (e) { return this.forEachBlock((function (t) { var n = t.className.split(/\s+/).filter((function (e) { return !!e && !/^align/.test(e) })).join(" "); e ? (t.className = n + " align-" + e, t.style.textAlign = e) : (t.className = n, t.style.textAlign = "") }), !0), this.focus() }, nt.setTextDirection = function (e) { return this.forEachBlock((function (t) { e ? t.dir = e : t.removeAttribute("dir") }), !0), this.focus() }; var vt = function (e) { for (var t, n = this._root, i = this._doc, o = i.createDocumentFragment(), a = c(e, n); t = a.nextNode();) { var s, l, u = t.querySelectorAll("BR"), d = [], h = u.length; for (s = 0; s < h; s += 1) d[s] = Ye(u[s], !1); for (; h--;) l = u[h], d[h] ? y(l, i.createTextNode("\n")) : v(l); for (h = (u = t.querySelectorAll("CODE")).length; h--;) v(u[h]); o.childNodes.length && o.appendChild(i.createTextNode("\n")), o.appendChild(b(t)) } for (a = new r(o, 4); t = a.nextNode();) t.data = t.data.replace(/ /g, " "); return o.normalize(), w(this.createElement("PRE", this._config.tagAttributes.pre, [o]), n) }, yt = function (e) { for (var t, n, i, o, a, s, l = this._doc, c = this._root, u = e.querySelectorAll("PRE"), d = u.length; d--;) { for (n = new r(t = u[d], 4); i = n.nextNode();) { for (o = (o = i.data).replace(/ (?= )/g, " "), a = l.createDocumentFragment(); (s = o.indexOf("\n")) > -1;) a.appendChild(l.createTextNode(o.slice(0, s))), a.appendChild(l.createElement("BR")), o = o.slice(s + 1); i.parentNode.insertBefore(a, i), i.data = o } _(t, c), y(t, b(t)) } return e }; nt.code = function () { var e = this.getSelection(); return e.collapsed || l(e.commonAncestorContainer) ? this.modifyBlocks(vt, e) : this.changeFormat({ tag: "CODE", attributes: this._config.tagAttributes.code }, null, e), this.focus() }, nt.removeCode = function () { var e = this.getSelection(); return p(e.commonAncestorContainer, this._root, "PRE") ? this.modifyBlocks(yt, e) : this.changeFormat(null, { tag: "CODE" }, e), this.focus() }, nt.toggleCode = function () { return this.hasFormat("PRE") || this.hasFormat("CODE") ? this.removeCode() : this.code(), this }, nt.removeAllFormatting = function (e) { if (!e && !(e = this.getSelection()) || e.collapsed) return this; for (var t = this._root, n = e.commonAncestorContainer; n && !s(n);) n = n.parentNode; if (n || (Me(e, t), n = t), n.nodeType === R) return this; this.saveUndoState(e), Ee(e, n, n, t); for (var r, i, o = n.ownerDocument, a = e.startContainer, l = e.startOffset, c = e.endContainer, u = e.endOffset, d = o.createDocumentFragment(), h = o.createDocumentFragment(), f = T(c, u, n, t), p = T(a, l, n, t); p !== f;) r = p.nextSibling, d.appendChild(p), p = r; return D(this, d, h), h.normalize(), p = h.firstChild, r = h.lastChild, i = n.childNodes, p ? (n.insertBefore(h, f), l = ae.call(i, p), u = ae.call(i, r) + 1) : u = l = ae.call(i, f), e.setStart(n, l), e.setEnd(n, u), E(n, e), Te(e), this.setSelection(e), this._updatePath(e, !0), this.focus() }, nt.increaseQuoteLevel = mt("modifyBlocks", (function (e) { return this.createElement("BLOCKQUOTE", this._config.tagAttributes.blockquote, [e]) })), nt.decreaseQuoteLevel = mt("modifyBlocks", ut), nt.makeUnorderedList = mt("modifyBlocks", (function (e) { return ht(this, e, "UL"), e })), nt.makeOrderedList = mt("modifyBlocks", (function (e) { return ht(this, e, "OL"), e })), nt.removeList = mt("modifyBlocks", (function (e) { var t, n, r, i, o, a = e.querySelectorAll("UL, OL"), l = e.querySelectorAll("LI"), c = this._root; for (t = 0, n = a.length; t < n; t += 1) _(i = b(r = a[t]), c), y(r, i); for (t = 0, n = l.length; t < n; t += 1) s(o = l[t]) ? y(o, this.createDefaultBlock([b(o)])) : (_(o, c), y(o, b(o))); return e })), M.isInline = a, M.isBlock = s, M.isContainer = l, M.getBlockWalker = c, M.getPreviousBlock = u, M.getNextBlock = d, M.areAlike = h, M.hasTagAttributes = f, M.getNearest = p, M.isOrContains = g, M.detach = v, M.replaceWith = y, M.empty = b, M.getNodeBefore = me, M.getNodeAfter = ve, M.insertNodeInRange = ye, M.extractContentsOfRange = be, M.deleteContentsOfRange = Ce, M.insertTreeFragmentIntoRange = we, M.isNodeContainedInRange = _e, M.moveRangeBoundariesDownTree = Te, M.moveRangeBoundariesUpTree = Ee, M.getStartBlockOfRange = xe, M.getEndBlockOfRange = Se, M.contentWalker = Ne, M.rangeDoesStartAtBlockBoundary = ke, M.rangeDoesEndAtBlockBoundary = Le, M.expandRangeToBlockBoundaries = Me, M.onPaste = et, M.addLinks = pt, M.splitBlock = ct, M.startSelectionId = "squire-selection-start", M.endSelectionId = st, e.exports = M }(document) }, function (e, t, n) { "use strict"; var r = n(15), i = n(9); e.exports = function (e, t) { t = (t = r(t) ? t.join(" ") : t).replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""), i(e.className.baseVal) ? e.className = t : e.className.baseVal = t } }, function (e, t, n) { "use strict"; e.exports = function (e, t) { var n, r = e._feEventKey; return r || (r = e._feEventKey = {}), (n = r[t]) || (n = r[t] = []), n } }, function (e, t, n) { "use strict"; var r = n(9), i = n(37); e.exports = function (e, t) { var n = location.hostname, o = "TOAST UI " + e + " for " + n + ": Statistics", a = window.localStorage.getItem(o); (r(window.tui) || !1 !== window.tui.usageStatistics) && (a && ! function (e) { return (new Date).getTime() - e > 6048e5 }(a) || (window.localStorage.setItem(o, (new Date).getTime()), setTimeout((function () { "interactive" !== document.readyState && "complete" !== document.readyState || i("https://www.google-analytics.com/collect", { v: 1, t: "event", tid: t, cid: n, dp: n, dh: e, el: e, ec: "use" }) }), 1e3))) } }, function (e, t, n) { "use strict"; e.exports = function (e) { return "boolean" == typeof e || e instanceof Boolean } }, function (e, t, n) { "use strict"; var r = n(25); e.exports = function (e) { return !r(e) } }, function (e, t, n) { "use strict"; var r = n(21), i = n(15), o = n(1), a = n(20), s = function () { try { return Object.defineProperty({}, "x", {}), !0 } catch (e) { return !1 } }(), l = 0; function c(e) { e && this.set.apply(this, arguments) } c.prototype.set = function (e) { var t = this; i(e) || (e = o(arguments)), a(e, (function (e) { t._addItem(e) })) }, c.prototype.getName = function (e) { var t, n = this; return a(this, (function (r, i) { if (n._isEnumItem(i) && e === r) return t = i, !1 })), t }, c.prototype._addItem = function (e) { var t; this.hasOwnProperty(e) || (t = this._makeEnumValue(), s ? Object.defineProperty(this, e, { enumerable: !0, configurable: !1, writable: !1, value: t }) : this[e] = t) }, c.prototype._makeEnumValue = function () { var e; return e = l, l += 1, e }, c.prototype._isEnumItem = function (e) { return r(this[e]) }, e.exports = c }, function (e, t, n) { "use strict"; (function (e) { var n = function () { if ("undefined" != typeof Map) return Map; function e(e, t) { var n = -1; return e.some((function (e, r) { return e[0] === t && (n = r, !0) })), n } return function () { function t() { this.__entries__ = [] } return Object.defineProperty(t.prototype, "size", { get: function () { return this.__entries__.length }, enumerable: !0, configurable: !0 }), t.prototype.get = function (t) { var n = e(this.__entries__, t), r = this.__entries__[n]; return r && r[1] }, t.prototype.set = function (t, n) { var r = e(this.__entries__, t); ~r ? this.__entries__[r][1] = n : this.__entries__.push([t, n]) }, t.prototype.delete = function (t) { var n = this.__entries__, r = e(n, t); ~r && n.splice(r, 1) }, t.prototype.has = function (t) { return !!~e(this.__entries__, t) }, t.prototype.clear = function () { this.__entries__.splice(0) }, t.prototype.forEach = function (e, t) { void 0 === t && (t = null); for (var n = 0, r = this.__entries__; n < r.length; n++) { var i = r[n]; e.call(t, i[1], i[0]) } }, t }() }(), r = "undefined" != typeof window && "undefined" != typeof document && window.document === document, i = void 0 !== e && e.Math === Math ? e : "undefined" != typeof self && self.Math === Math ? self : "undefined" != typeof window && window.Math === Math ? window : Function("return this")(), o = "function" == typeof requestAnimationFrame ? requestAnimationFrame.bind(i) : function (e) { return setTimeout((function () { return e(Date.now()) }), 1e3 / 60) }; var a = ["top", "right", "bottom", "left", "width", "height", "size", "weight"], s = "undefined" != typeof MutationObserver, l = function () { function e() { this.connected_ = !1, this.mutationEventsAdded_ = !1, this.mutationsObserver_ = null, this.observers_ = [], this.onTransitionEnd_ = this.onTransitionEnd_.bind(this), this.refresh = function (e, t) { var n = !1, r = !1, i = 0; function a() { n && (n = !1, e()), r && l() } function s() { o(a) } function l() { var e = Date.now(); if (n) { if (e - i < 2) return; r = !0 } else n = !0, r = !1, setTimeout(s, t); i = e } return l }(this.refresh.bind(this), 20) } return e.prototype.addObserver = function (e) { ~this.observers_.indexOf(e) || this.observers_.push(e), this.connected_ || this.connect_() }, e.prototype.removeObserver = function (e) { var t = this.observers_, n = t.indexOf(e); ~n && t.splice(n, 1), !t.length && this.connected_ && this.disconnect_() }, e.prototype.refresh = function () { this.updateObservers_() && this.refresh() }, e.prototype.updateObservers_ = function () { var e = this.observers_.filter((function (e) { return e.gatherActive(), e.hasActive() })); return e.forEach((function (e) { return e.broadcastActive() })), e.length > 0 }, e.prototype.connect_ = function () { r && !this.connected_ && (document.addEventListener("transitionend", this.onTransitionEnd_), window.addEventListener("resize", this.refresh), s ? (this.mutationsObserver_ = new MutationObserver(this.refresh), this.mutationsObserver_.observe(document, { attributes: !0, childList: !0, characterData: !0, subtree: !0 })) : (document.addEventListener("DOMSubtreeModified", this.refresh), this.mutationEventsAdded_ = !0), this.connected_ = !0) }, e.prototype.disconnect_ = function () { r && this.connected_ && (document.removeEventListener("transitionend", this.onTransitionEnd_), window.removeEventListener("resize", this.refresh), this.mutationsObserver_ && this.mutationsObserver_.disconnect(), this.mutationEventsAdded_ && document.removeEventListener("DOMSubtreeModified", this.refresh), this.mutationsObserver_ = null, this.mutationEventsAdded_ = !1, this.connected_ = !1) }, e.prototype.onTransitionEnd_ = function (e) { var t = e.propertyName, n = void 0 === t ? "" : t; a.some((function (e) { return !!~n.indexOf(e) })) && this.refresh() }, e.getInstance = function () { return this.instance_ || (this.instance_ = new e), this.instance_ }, e.instance_ = null, e }(), c = function (e, t) { for (var n = 0, r = Object.keys(t); n < r.length; n++) { var i = r[n]; Object.defineProperty(e, i, { value: t[i], enumerable: !1, writable: !1, configurable: !0 }) } return e }, u = function (e) { return e && e.ownerDocument && e.ownerDocument.defaultView || i }, d = v(0, 0, 0, 0); function h(e) { return parseFloat(e) || 0 } function f(e) { for (var t = [], n = 1; n < arguments.length; n++) t[n - 1] = arguments[n]; return t.reduce((function (t, n) { return t + h(e["border-" + n + "-width"]) }), 0) } function p(e) { var t = e.clientWidth, n = e.clientHeight; if (!t && !n) return d; var r = u(e).getComputedStyle(e), i = function (e) { for (var t = {}, n = 0, r = ["top", "right", "bottom", "left"]; n < r.length; n++) { var i = r[n], o = e["padding-" + i]; t[i] = h(o) } return t }(r), o = i.left + i.right, a = i.top + i.bottom, s = h(r.width), l = h(r.height); if ("border-box" === r.boxSizing && (Math.round(s + o) !== t && (s -= f(r, "left", "right") + o), Math.round(l + a) !== n && (l -= f(r, "top", "bottom") + a)), ! function (e) { return e === u(e).document.documentElement }(e)) { var c = Math.round(s + o) - t, p = Math.round(l + a) - n; 1 !== Math.abs(c) && (s -= c), 1 !== Math.abs(p) && (l -= p) } return v(i.left, i.top, s, l) } var g = "undefined" != typeof SVGGraphicsElement ? function (e) { return e instanceof u(e).SVGGraphicsElement } : function (e) { return e instanceof u(e).SVGElement && "function" == typeof e.getBBox }; function m(e) { return r ? g(e) ? function (e) { var t = e.getBBox(); return v(0, 0, t.width, t.height) }(e) : p(e) : d } function v(e, t, n, r) { return { x: e, y: t, width: n, height: r } } var y = function () { function e(e) { this.broadcastWidth = 0, this.broadcastHeight = 0, this.contentRect_ = v(0, 0, 0, 0), this.target = e } return e.prototype.isActive = function () { var e = m(this.target); return this.contentRect_ = e, e.width !== this.broadcastWidth || e.height !== this.broadcastHeight }, e.prototype.broadcastRect = function () { var e = this.contentRect_; return this.broadcastWidth = e.width, this.broadcastHeight = e.height, e }, e }(), b = function (e, t) { var n, r, i, o, a, s, l, u = (r = (n = t).x, i = n.y, o = n.width, a = n.height, s = "undefined" != typeof DOMRectReadOnly ? DOMRectReadOnly : Object, l = Object.create(s.prototype), c(l, { x: r, y: i, width: o, height: a, top: i, right: r + o, bottom: a + i, left: r }), l); c(this, { target: e, contentRect: u }) }, C = function () { function e(e, t, r) { if (this.activeObservations_ = [], this.observations_ = new n, "function" != typeof e) throw new TypeError("The callback provided as parameter 1 is not a function."); this.callback_ = e, this.controller_ = t, this.callbackCtx_ = r } return e.prototype.observe = function (e) { if (!arguments.length) throw new TypeError("1 argument required, but only 0 present."); if ("undefined" != typeof Element && Element instanceof Object) { if (!(e instanceof u(e).Element)) throw new TypeError('parameter 1 is not of type "Element".'); var t = this.observations_; t.has(e) || (t.set(e, new y(e)), this.controller_.addObserver(this), this.controller_.refresh()) } }, e.prototype.unobserve = function (e) { if (!arguments.length) throw new TypeError("1 argument required, but only 0 present."); if ("undefined" != typeof Element && Element instanceof Object) { if (!(e instanceof u(e).Element)) throw new TypeError('parameter 1 is not of type "Element".'); var t = this.observations_; t.has(e) && (t.delete(e), t.size || this.controller_.removeObserver(this)) } }, e.prototype.disconnect = function () { this.clearActive(), this.observations_.clear(), this.controller_.removeObserver(this) }, e.prototype.gatherActive = function () { var e = this; this.clearActive(), this.observations_.forEach((function (t) { t.isActive() && e.activeObservations_.push(t) })) }, e.prototype.broadcastActive = function () { if (this.hasActive()) { var e = this.callbackCtx_, t = this.activeObservations_.map((function (e) { return new b(e.target, e.broadcastRect()) })); this.callback_.call(e, t, e), this.clearActive() } }, e.prototype.clearActive = function () { this.activeObservations_.splice(0) }, e.prototype.hasActive = function () { return this.activeObservations_.length > 0 }, e }(), w = "undefined" != typeof WeakMap ? new WeakMap : new n, _ = function e(t) { if (!(this instanceof e)) throw new TypeError("Cannot call a class as a function."); if (!arguments.length) throw new TypeError("1 argument required, but only 0 present."); var n = l.getInstance(), r = new C(t, n, this); w.set(this, r) }; ["observe", "unobserve", "disconnect"].forEach((function (e) { _.prototype[e] = function () { var t; return (t = w.get(this))[e].apply(t, arguments) } })); var T = void 0 !== i.ResizeObserver ? i.ResizeObserver : _; t.a = T }).call(this, n(38)) }, function (e, t, n) { "use strict"; var r = n(4), i = n(18), o = n(11), a = n(26), s = n(15), l = n(19), c = n(20), u = /\s+/g; function d() { this.events = null, this.contexts = null } d.mixin = function (e) { r(e.prototype, d.prototype) }, d.prototype._getHandlerItem = function (e, t) { var n = { handler: e }; return t && (n.context = t), n }, d.prototype._safeEvent = function (e) { var t, n = this.events; return n || (n = this.events = {}), e && ((t = n[e]) || (t = [], n[e] = t), n = t), n }, d.prototype._safeContext = function () { var e = this.contexts; return e || (e = this.contexts = []), e }, d.prototype._indexOfContext = function (e) { for (var t = this._safeContext(), n = 0; t[n];) { if (e === t[n][0]) return n; n += 1 } return -1 }, d.prototype._memorizeContext = function (e) { var t, n; i(e) && (t = this._safeContext(), (n = this._indexOfContext(e)) > -1 ? t[n][1] += 1 : t.push([e, 1])) }, d.prototype._forgetContext = function (e) { var t, n; i(e) && (t = this._safeContext(), (n = this._indexOfContext(e)) > -1 && (t[n][1] -= 1, t[n][1] <= 0 && t.splice(n, 1))) }, d.prototype._bindEvent = function (e, t, n) { var r = this._safeEvent(e); this._memorizeContext(n), r.push(this._getHandlerItem(t, n)) }, d.prototype.on = function (e, t, n) { var r = this; o(e) ? (e = e.split(u), c(e, (function (e) { r._bindEvent(e, t, n) }))) : a(e) && (n = t, c(e, (function (e, t) { r.on(t, e, n) }))) }, d.prototype.once = function (e, t, n) { var r = this; if (a(e)) return n = t, void c(e, (function (e, t) { r.once(t, e, n) })); this.on(e, (function i() { t.apply(n, arguments), r.off(e, i, n) }), n) }, d.prototype._spliceMatches = function (e, t) { var n, r = 0; if (s(e)) for (n = e.length; r < n; r += 1) !0 === t(e[r]) && (e.splice(r, 1), n -= 1, r -= 1) }, d.prototype._matchHandler = function (e) { var t = this; return function (n) { var r = e === n.handler; return r && t._forgetContext(n.context), r } }, d.prototype._matchContext = function (e) { var t = this; return function (n) { var r = e === n.context; return r && t._forgetContext(n.context), r } }, d.prototype._matchHandlerAndContext = function (e, t) { var n = this; return function (r) { var i = e === r.handler, o = t === r.context, a = i && o; return a && n._forgetContext(r.context), a } }, d.prototype._offByEventName = function (e, t) { var n = this, r = l(t), i = n._matchHandler(t); e = e.split(u), c(e, (function (e) { var t = n._safeEvent(e); r ? n._spliceMatches(t, i) : (c(t, (function (e) { n._forgetContext(e.context) })), n.events[e] = []) })) }, d.prototype._offByHandler = function (e) { var t = this, n = this._matchHandler(e); c(this._safeEvent(), (function (e) { t._spliceMatches(e, n) })) }, d.prototype._offByObject = function (e, t) { var n, r = this; this._indexOfContext(e) < 0 ? c(e, (function (e, t) { r.off(t, e) })) : o(t) ? (n = this._matchContext(e), r._spliceMatches(this._safeEvent(t), n)) : l(t) ? (n = this._matchHandlerAndContext(t, e), c(this._safeEvent(), (function (e) { r._spliceMatches(e, n) }))) : (n = this._matchContext(e), c(this._safeEvent(), (function (e) { r._spliceMatches(e, n) }))) }, d.prototype.off = function (e, t) { o(e) ? this._offByEventName(e, t) : arguments.length ? l(e) ? this._offByHandler(e) : a(e) && this._offByObject(e, t) : (this.events = {}, this.contexts = []) }, d.prototype.fire = function (e) { this.invoke.apply(this, arguments) }, d.prototype.invoke = function (e) { var t, n, r, i; if (!this.hasListener(e)) return !0; for (t = this._safeEvent(e), n = Array.prototype.slice.call(arguments, 1), r = 0; t[r];) { if (!1 === (i = t[r]).handler.apply(i.context, n)) return !1; r += 1 } return !0 }, d.prototype.hasListener = function (e) { return this.getListenerLength(e) > 0 }, d.prototype.getListenerLength = function (e) { return this._safeEvent(e).length }, e.exports = d }, function (e, t, n) { "use strict"; e.exports = function (e) { return null === e } }, function (e, t, n) { "use strict"; var r = n(7); e.exports = function (e, t) { var n = document.createElement("img"), i = ""; return r(t, (function (e, t) { i += "&" + t + "=" + e })), i = i.substring(1), n.src = e + "?" + i, n.style.display = "none", document.body.appendChild(n), document.body.removeChild(n), n } }, function (e, t) { var n; n = function () { return this }(); try { n = n || new Function("return this")() } catch (e) { "object" == typeof window && (n = window) } e.exports = n }, function (e, t, n) {}, function (e, t, n) {}, function (e, t, n) {}, function (e, t, n) {}, function (e, t, n) { "use strict"; n.r(t); var r = n(7), i = n.n(r), o = n(18), a = n.n(o), s = n(21), l = n.n(s), c = n(4), u = n.n(c), d = n(0), h = n.n(d), f = n(2), p = n.n(f), g = n(3), m = n.n(g), v = n(17); function y() { return (y = Object.assign || function (e) { for (var t = 1; t < arguments.length; t++) { var n = arguments[t]; for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]) } return e }).apply(this, arguments) } var b = { paragraph: function (e, t) { var n = t.entering, r = t.origin, i = t.options, o = i.nodeId, a = i.customProp, s = (void 0 === a ? {} : a).showFrontMatter && e.customType; return o && !e.customType || s ? { type: n ? "openTag" : "closeTag", outerNewLine: !0, tagName: "p" } : r() }, softbreak: function (e) { return { type: "html", content: e.prev && "htmlInline" === e.prev.type && /
/.test(e.prev.literal) ? "\n" : "
\n" } }, item: function (e, t) { if (t.entering) { var n = {}, r = []; return e.listData.task && (n["data-te-task"] = "", r.push("task-list-item"), e.listData.checked && r.push("checked")), { type: "openTag", tagName: "li", classNames: r, attributes: n, outerNewLine: !0 } } return { type: "closeTag", tagName: "li", outerNewLine: !0 } }, code: function (e) { return [{ type: "openTag", tagName: "code", attributes: { "data-backticks": e.tickCount } }, { type: "text", content: e.literal }, { type: "closeTag", tagName: "code" }] }, codeBlock: function (e) { var t = e.info ? e.info.split(/\s+/) : [], n = [], r = {}; if (e.fenceLength > 3 && (r["data-backticks"] = e.fenceLength), t.length > 0 && t[0].length > 0) { var i = t[0]; n.push("lang-" + i), r["data-language"] = i } return [{ type: "openTag", tagName: "pre", classNames: n }, { type: "openTag", tagName: "code", attributes: r }, { type: "text", content: e.literal }, { type: "closeTag", tagName: "code" }, { type: "closeTag", tagName: "pre" }] } }; function C(e, t) { var n = y({}, b); return e && (n.link = function (t, n) { var r = n.entering, i = (0, n.origin)(); return r && (i.attributes = y({}, i.attributes, e)), i }), t && Object.keys(t).forEach((function (e) { var r = n[e], i = t[e]; n[e] = r ? function (e, t) { var n = y({}, t); return n.origin = function () { return r(e, t) }, i(e, n) } : i })), n } var w = n(9), _ = n.n(w), T = n(30), E = n.n(T), x = /Mac/.test(navigator.platform); function S(e, t) { return -1 !== e.indexOf(t) } var N = ["rel", "target", "contenteditable", "hreflang", "type"]; function k(e) { if (!e) return null; var t = {}; return N.forEach((function (n) { _()(e[n]) || (t[n] = e[n]) })), t } var L = n(31), M = n.n(L), A = n(6), B = n.n(A), O = /^(\s*)((\d+)([.)]\s(?:\[(?:x|\s)\]\s)?))(.*)/; function D(e, t, n, r) { var i, o, a, s, l = n, c = r.getLine(e); do { var u = O.exec(c); if (i = u[1], o = u[4], a = u[5], (s = i.length) === t) r.replaceRange("" + i + l + o + a, { line: e, ch: 0 }, { line: e, ch: c.length }), l += 1, e += 1; else { if (!(s > t)) return e; e = D(e, s, 1, r) } c = r.getLine(e) } while (O.test(c)); return e } function I(e, t) { for (var n = e, r = t.getLine(e); O.test(r);) n -= 1, r = t.getLine(n); return e === n ? n = -1 : n += 1, n } B.a.commands.indentLessOrderedList = function (e) { return e.getOption("disableInput") ? B.a.Pass : (e.execCommand("indentLess"), e.execCommand("fixOrderedListNumber"), null) }, B.a.commands.fixOrderedListNumber = function (e) { if (e.getOption("disableInput") || e.state.isCursorInCodeBlock) return B.a.Pass; for (var t = e.listSelections(), n = 0; n < t.length; n += 1) { var r = I(t[n].head.line, e); if (r >= 0) { var i = e.getLine(r), o = O.exec(i), a = o[1], s = o[3]; D(r, a.length, parseInt(s, 10), e) } } return null }, B.a.overlayMode = function (e, t, n) { return { startState: function () { return { base: B.a.startState(e), overlay: B.a.startState(t), basePos: 0, baseCur: null, overlayPos: 0, overlayCur: null, streamSeen: null } }, copyState: function (n) { return { base: B.a.copyState(e, n.base), overlay: B.a.copyState(t, n.overlay), basePos: n.basePos, baseCur: null, overlayPos: n.overlayPos, overlayCur: null } }, token: function (r, i) { return (r != i.streamSeen || Math.min(i.basePos, i.overlayPos) < r.start) && (i.streamSeen = r, i.basePos = i.overlayPos = r.start), r.start == i.basePos && (i.baseCur = e.token(r, i.base), i.basePos = r.pos), r.start == i.overlayPos && (r.pos = r.start, i.overlayCur = t.token(r, i.overlay), i.overlayPos = r.pos), r.pos = Math.min(i.basePos, i.overlayPos), null == i.overlayCur ? i.baseCur : null != i.baseCur && i.overlay.combineTokens || n && null == i.overlay.combineTokens ? i.baseCur + " " + i.overlayCur : i.overlayCur }, indent: e.indent && function (t, n) { return e.indent(t.base, n) }, electricChars: e.electricChars, innerMode: function (t) { return { state: t.base, mode: e } }, blankLine: function (n) { e.blankLine && e.blankLine(n.base), t.blankLine && t.blankLine(n.overlay) } } }; var R = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]\s))(\s*)/, P = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/, H = /[*+-]\s/; function F(e, t) { var n = t.line, r = 0, i = 0, o = R.exec(e.getLine(n)), a = o[1]; do { var s = n + (r += 1), l = e.getLine(s), c = R.exec(l); if (c) { var u = c[1], d = parseInt(o[3], 10) + r - i, h = parseInt(c[3], 10), f = h; if (a !== u || isNaN(h)) { if (a.length > u.length) return; if (a.length < u.length && 1 === r) return; i += 1 } else d === h && (f = h + 1), d > h && (f = d + 1), e.replaceRange(l.replace(R, u + f + c[4] + c[5]), { line: s, ch: 0 }, { line: s, ch: l.length }) } } while (c) } function U(e) { return W(e) && e.anchor.ch === e.head.ch } function W(e) { return e.anchor.line === e.head.line } function q(e, t, n, r) { var i = e.getLine(n.line), o = e.getLine(n.line + r), a = { anchor: t, head: n }; e.replaceRange(o, { line: n.line, ch: 0 }, { line: n.line, ch: i.length }, "+input"), e.replaceRange(i, { line: n.line + r, ch: 0 }, { line: n.line + r, ch: o.length }, "+input"), U(a) ? e.setCursor({ line: n.line + r, ch: n.ch }) : e.setSelection({ line: t.line + r, ch: t.ch }, { line: n.line + r, ch: n.ch }) } function z(e, t, n, r) { var i, o = e.getRange({ line: t.line, ch: 0 }, { line: n.line, ch: e.getLine(n.line).length }), a = r > 0 ? n : t, s = e.getLine(a.line + r); i = r > 0 ? t : n, e.replaceRange(s, { line: i.line, ch: 0 }, { line: i.line, ch: e.getLine(i.line).length }, "+input"), e.replaceRange(o, { line: t.line + r, ch: 0 }, { line: n.line + r, ch: e.getLine(n.line + r).length }, "+input"), e.setSelection({ line: t.line + r, ch: t.ch }, { line: n.line + r, ch: n.ch }) } function j(e) { e.state.placeholder && (e.state.placeholder.parentNode.removeChild(e.state.placeholder), e.state.placeholder = null) } function V(e) { j(e); var t = e.state.placeholder = document.createElement("pre"); t.style.cssText = "height: 0; overflow: visible", t.className = "CodeMirror-placeholder"; var n = e.getOption("placeholder"); "string" == typeof n && (n = document.createTextNode(n)), t.appendChild(n), e.display.lineSpace.insertBefore(t, e.display.lineSpace.firstChild) } function K(e) { $(e) && V(e) } function G(e) { var t = e.getWrapperElement(), n = $(e); t.className = t.className.replace(" CodeMirror-empty", "") + (n ? " CodeMirror-empty" : ""), n ? V(e) : j(e) } function $(e) { return 1 === e.lineCount() && "" === e.getLine(0) } function Y() { return (Y = Object.assign || function (e) { for (var t = 1; t < arguments.length; t++) { var n = arguments[t]; for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]) } return e }).apply(this, arguments) } B.a.commands.indentOrderedList = function (e) { if (e.getOption("disableInput")) return B.a.Pass; for (var t = e.listSelections(), n = 0; n < t.length; n++) { var r = t[n].head, i = e.getLine(r.line).substr(0, r.ch); R.test(i) || e.somethingSelected() ? e.indentSelection("add") : e.execCommand("insertSoftTab") } e.execCommand("fixOrderedListNumber") }, B.a.commands.newlineAndIndentContinueMarkdownList = function (e) { if (e.getOption("disableInput") || e.state.isCursorInCodeBlock) e.execCommand("newlineAndIndent"); else { for (var t = e.listSelections(), n = [], r = 0; r < t.length; r++) { var i = t[r].head, o = e.getLine(i.line), a = R.exec(o), s = /^\s*$/.test(o.slice(0, i.ch)); if (!t[r].empty() || !a || s) return void e.execCommand("newlineAndIndent"); if (P.test(o)) />\s*$/.test(o) || e.replaceRange("", { line: i.line, ch: 0 }, { line: i.line, ch: i.ch + 1 }), n[r] = "\n"; else { var l = a[1], c = a[5], u = !(H.test(a[2]) || a[2].indexOf(">") >= 0), d = u ? parseInt(a[3], 10) + 1 + a[4] : a[2].replace("x", " "); n[r] = "\n" + l + d + c, u && F(e, i) } } e.replaceSelections(n) } }, B.a.commands.replaceLineTextToUpper = function (e) { if (e.getOption("disableInput")) return B.a.Pass; for (var t = e.listSelections(), n = 0; n < t.length; n++) { var r = t[n], i = r.anchor, o = r.head; if (W(r) && o.line > 0) q(e, i, o, -1); else if (!U(r)) { var a = i.line < o.line ? i.line : o.line; if (a > 0) z(e, i.line === a ? i : o, i.line === a ? o : i, -1) } } }, B.a.commands.replaceLineTextToLower = function (e) { if (e.getOption("disableInput")) return B.a.Pass; for (var t = e.listSelections(), n = 0; n < t.length; n++) { var r = t[n], i = r.anchor, o = r.head, a = o.line === e.lastLine(); if (W(r) && !a) q(e, i, o, 1); else if (!U(r)) { var s = i.line < o.line ? i.line : o.line, l = i.line === s ? i : o, c = i.line === s ? o : i; c.line < e.lastLine() && z(e, l, c, 1) } } }, B.a.defineOption("placeholder", "", (function (e, t, n) { var r = n && n != B.a.Init; if (t && !r) e.on("blur", K), e.on("change", G), e.on("swapDoc", G), G(e); else if (!t && r) { e.off("blur", K), e.off("change", G), e.off("swapDoc", G), j(e); var i = e.getWrapperElement(); i.className = i.className.replace(" CodeMirror-empty", "") } t && !e.hasFocus() && K(e) })); var X, Z = function () { function e(e, t) { void 0 === t && (t = {}), this.editorContainerEl = e, this.cm = null, this._init(t) } var t = e.prototype; return t._init = function (e) { var t = document.createElement("textarea"); this.editorContainerEl.appendChild(t), e = Y({}, e, { lineWrapping: !0, theme: "default", extraKeys: Y({ "Shift-Tab": "indentLess", "Alt-Up": "replaceLineTextToUpper", "Alt-Down": "replaceLineTextToLower" }, e.extraKeys), indentUnit: 4, cursorScrollMargin: 12, specialCharPlaceholder: function () { return document.createElement("span") } }), this.cm = B.a.fromTextArea(t, e) }, t.getCurrentRange = function () { var e = this.cm.getCursor("from"), t = this.cm.getCursor("to"); return { from: e, to: t, collapsed: e.line === t.line && e.ch === t.ch } }, t.focus = function () { this.cm.focus() }, t.blur = function () { this.cm.getInputField().blur() }, t.remove = function () { this.cm.toTextArea() }, t.setValue = function (e, t) { void 0 === t && (t = !0), this.cm.setValue(e), t && this.moveCursorToEnd(), this.cm.doc.clearHistory(), this.cm.refresh() }, t.getValue = function () { return this.cm.getValue("\n") }, t.getEditor = function () { return this.cm }, t.reset = function () { this.setValue("") }, t.getCaretPosition = function () { return this.cm.cursorCoords() }, t.addWidget = function (e, t, n, r) { r && (e.ch += r), this.cm.addWidget(e.end, t, !0, n) }, t.replaceSelection = function (e, t) { t && this.cm.setSelection(t.from, t.to), this.cm.replaceSelection(e), this.focus() }, t.replaceRelativeOffset = function (e, t, n) { var r = this.cm.getCursor(), i = { from: { line: r.line, ch: r.ch + t }, to: { line: r.line, ch: r.ch + t + n } }; this.replaceSelection(e, i) }, t.setHeight = function (e) { var t = this.getWrapperElement(); h()(t, { height: e + "px" }) }, t.setMinHeight = function (e) { var t = this.getWrapperElement(); h()(t, { minHeight: e + "px" }) }, t.setPlaceholder = function (e) { e && this.cm.setOption("placeholder", e) }, t.getWrapperElement = function () { return this.cm.getWrapperElement() }, t.getCursor = function (e) { return this.cm.getCursor(e) }, t.moveCursorToEnd = function () { var e = this.getEditor().getDoc(), t = e.lastLine(); e.setCursor(t, e.getLine(t).length) }, t.moveCursorToStart = function () { var e = this.getEditor().getDoc(), t = e.firstLine(); e.setCursor(t, 0) }, t.scrollTop = function (e) { return e && this.cm.scrollTo(0, e), this.cm.getScrollInfo().top }, t.getRange = function () { var e = this.cm.getCursor("from"), t = this.cm.getCursor("to"); return { start: { line: e.line, ch: e.ch }, end: { line: t.line, ch: t.ch } } }, t.on = function (e, t) { this.cm.on(e, t) }, t.off = function (e, t) { this.cm.off(e, t) }, e }(), Q = ["", "", "", "CANCEL", "", "", "HELP", "", "BACK_SPACE", "TAB", "", "", "CLEAR", "ENTER", "ENTER_SPECIAL", "", "", "", "", "PAUSE", "CAPS_LOCK", "KANA", "EISU", "JUNJA", "FINAL", "HANJA", "", "ESCAPE", "CONVERT", "NONCONVERT", "ACCEPT", "MODECHANGE", "SPACE", "PAGE_UP", "PAGE_DOWN", "END", "HOME", "LEFT", "UP", "RIGHT", "DOWN", "SELECT", "PRINT", "EXECUTE", "PRINTSCREEN", "INSERT", "DELETE", "", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?", "AT", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "", "", "CONTEXT_MENU", "", "SLEEP", "NUMPAD0", "NUMPAD1", "NUMPAD2", "NUMPAD3", "NUMPAD4", "NUMPAD5", "NUMPAD6", "NUMPAD7", "NUMPAD8", "NUMPAD9", "MULTIPLY", "ADD", "SEPARATOR", "SUBTRACT", "DECIMAL", "DIVIDE", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24", "", "", "", "", "", "", "", "", "NUM_LOCK", "SCROLL_LOCK", "WIN_OEM_FJ_JISHO", "WIN_OEM_FJ_MASSHOU", "WIN_OEM_FJ_TOUROKU", "WIN_OEM_FJ_LOYA", "WIN_OEM_FJ_ROYA", "", "", "", "", "", "", "", "", "", "@", "!", '"', "#", "$", "%", "&", "_", "(", ")", "*", "+", "|", "-", "{", "}", "~", "", "", "", "", "VOLUME_MUTE", "VOLUME_DOWN", "VOLUME_UP", "", "", ";", "=", ",", "-", ".", "/", "`", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "[", "\\", "]", "'", "", "META", "ALTGR", "", "WIN_ICO_HELP", "WIN_ICO_00", "", "WIN_ICO_CLEAR", "", "", "WIN_OEM_RESET", "WIN_OEM_JUMP", "WIN_OEM_PA1", "WIN_OEM_PA2", "WIN_OEM_PA3", "WIN_OEM_WSCTRL", "WIN_OEM_CUSEL", "WIN_OEM_ATTN", "WIN_OEM_FINISH", "WIN_OEM_COPY", "WIN_OEM_AUTO", "WIN_OEM_ENLW", "WIN_OEM_BACKTAB", "ATTN", "CRSEL", "EXSEL", "EREOF", "PLAY", "ZOOM", "", "PA1", "WIN_OEM_CLEAR", ""], J = function () { function e(e) { this._setSplitter(e) } var t = e.prototype; return t._setSplitter = function (e) { var t = e ? e.splitter : "+"; this._splitter = t }, t.convert = function (e) { var t = []; e.shiftKey && t.push("SHIFT"), e.ctrlKey && t.push("CTRL"), e.metaKey && t.push("META"), e.altKey && t.push("ALT"); var n = this._getKeyCodeChar(e.keyCode); return n && t.push(n), t.join(this._splitter) }, t._getKeyCodeChar = function (e) { return Q[e] }, e.getSharedInstance = function () { return X || (X = new e), X }, e.keyCode = function (e) { return Q.indexOf(e) }, e }(), ee = /^[ \t]*([-*]|[\d]+\.)( \[[ xX]])? /, te = /^[ \t]*([*-] |[\d]+\. )(\[[ xX]] )/, ne = /^[ \t]*[-*] .*/, re = /^[ \t]*[\d]+\. \[[ xX]] .*/, ie = /([*-] |[\d]+\. )/, oe = /([-*] |[\d]+\. )(\[[ xX]] )/, ae = /([-*]|[\d]+\.)( \[[ xX]])? /, se = /([-*])( \[[ xX]]) /, le = /([\d])+\.( \[[ xX]])? /, ce = /^\|([-\s\w\d\t<>?!@#$%^&*()_=+\\/'";: \r[\]]*\|+)+/i, ue = /^#+\s/, de = /^ {0,3}(```|\||>)/, he = function () { function e(e) { this.cm = e.getEditor(), this.doc = this.cm.getDoc(), this.toastMark = e.getToastMark(), this.name = "list" } var t = e.prototype; return t._createSortedLineRange = function (e) { var t = e.from.line > e.to.line, n = { line: t ? e.to.line : e.from.line, ch: 0 }, r = { line: t ? e.from.line : e.to.line, ch: 0 }; return { start: n.line, end: r.line } }, t._calculateOrdinalNumber = function (e) { for (var t = 1, n = e - 1; n >= 0; n -= 1) { var r = this._getListDepth(n); if (1 === r && le.exec(this.doc.getLine(n))) { t = parseInt(RegExp.$1, 10) + 1; break } if (0 === r) break } return t }, t._isListLine = function (e) { return !!ee.exec(this.doc.getLine(e)) }, t._isCanBeList = function (e) { var t = this.doc.getLine(e); return !de.test(t) && !ce.test(t) && !ue.test(t) }, t._getChangeFn = function (e) { var t, n = this; switch (e) { case "ol": case "ul": t = function (t) { return n._changeToList(t, e) }; break; case "task": t = function (e) { return n._changeToTask(e) } } return t }, t.changeSyntax = function (e, t) { for (var n = [], r = this._createSortedLineRange(e), i = r.start, o = r.end, a = this._getChangeFn(t), s = i; s <= o && this._isCanBeList(s); s += 1) this._isListLine(s) || n.push(s), a(s); this._insertBlankLineForNewList(n), this.cm.focus() }, t._replaceLineText = function (e, t) { this.doc.replaceRange(e, { line: t, ch: 0 }) }, t._changeToList = function (e, t) { var n = this; this._isListLine(e) ? this._changeSameDepthList(e, "ol" === t ? function (e, t) { n._replaceListTypeToOL(e, t) } : function (e) { n._replaceListTypeToUL(e) }) : this._replaceLineText("ol" === t ? this._calculateOrdinalNumber(e) + ". " : "* ", e) }, t._changeToTask = function (e) { te.exec(this.doc.getLine(e)) ? this._replaceLineTextByRegexp(e, oe, "$1") : this._isListLine(e) ? this._replaceLineTextByRegexp(e, ie, "$1[ ] ") : this._replaceLineText("* [ ] ", e) }, t._getListDepth = function (e) { var t = 0; if (this.doc.getLine(e)) for (var n = this.toastMark.findFirstNodeAtLine(e + 1); n && "document" !== n.type;) "list" === n.type && (t += 1), n = n.parent; return t }, t._findSameDepthList = function (e, t, n) { for (var r, i = this.doc.lineCount(), o = [], a = e; n ? a < i - 1 : a > 0;) if (a = n ? a + 1 : a - 1, (r = this._getListDepth(a)) === t) o.push(a); else if (r < t) break; return o }, t._changeSameDepthList = function (e, t) { var n = this._getListDepth(e), r = this._findSameDepthList(e, n, !1).reverse(), i = this._findSameDepthList(e, n, !0); r.concat([e]).concat(i).forEach((function (e, n) { t(e, n + 1) })) }, t._replaceLineTextByRegexp = function (e, t, n) { var r = this.doc.getLine(e), i = { line: e, ch: 0 }, o = { line: e, ch: r.length }; r = r.replace(t, n), this.doc.replaceRange(r, i, o) }, t._replaceListTypeToUL = function (e) { var t = this.doc.getLine(e); se.exec(t) ? this._replaceLineTextByRegexp(e, se, "$1 ") : le.exec(t) && this._replaceLineTextByRegexp(e, le, "* ") }, t._replaceListTypeToOL = function (e, t) { var n = this.doc.getLine(e); ne.exec(n) || re.exec(n) ? this._replaceLineTextByRegexp(e, ae, t + ". ") : le.exec(n) && parseInt(RegExp.$1, 10) !== t && this._replaceLineTextByRegexp(e, le, t + ". ") }, t._insertBlankLineForNewList = function (e) { var t = e.length; if (t) { var n = e[0], r = e[t - 1]; this._isNotBlankNotListLine(r + 1) && this.doc.replaceRange("\n", { line: r, ch: this.doc.getLine(r).length }), n > 0 && this._isNotBlankNotListLine(n - 1) && this.doc.replaceRange("\n", { line: n, ch: 0 }) } }, t._isNotBlankNotListLine = function (e) { return !!this.doc.getLine(e) && !this._isListLine(e) }, e }(), fe = function () { function e(e) { this._managers = {}, this._editor = e } var t = e.prototype; return t.addManager = function (e, t) { t || (t = e, e = null); var n = new t(this._editor); this._managers[e || n.name] = n }, t.getManager = function (e) { return this._managers[e] }, t.removeManager = function (e) { var t = this.getManager(e); t && (t.destroy && t.destroy(), delete this._managers[e]) }, e }(), pe = function () { function e(e, t) { this._mde = e, this.setRange(t || e.getRange()) } var t = e.prototype; return t._setStart = function (e) { this._start = e }, t._setEnd = function (e) { this._end = e }, t.setRange = function (e) { this._setStart(e.start), this._setEnd(e.end) }, t.setEndBeforeRange = function (e) { this._setEnd(e.start) }, t.expandStartOffset = function () { var e = this._start; 0 !== e.ch && (e.ch -= 1) }, t.expandEndOffset = function () { var e = this._end; e.ch < this._mde.getEditor().getDoc().getLine(e.line).length && (e.ch += 1) }, t.getTextContent = function () { return this._mde.getEditor().getRange(this._start, this._end) }, t.replaceContent = function (e) { this._mde.getEditor().replaceRange(e, this._start, this._end, "+input") }, t.deleteContent = function () { this._mde.getEditor().replaceRange("", this._start, this._end, "+delete") }, t.peekStartBeforeOffset = function (e) { var t = { line: this._start.line, ch: Math.max(this._start.ch - e, 0) }; return this._mde.getEditor().getRange(t, this._start) }, e }(); function ge(e) { return e.sourcepos[0][0] } function me(e) { return e.sourcepos[1][0] } function ve(e) { return e.sourcepos[0][1] } function ye(e) { return e.sourcepos[1][1] } function be(e) { var t = e.type; return "strike" === t || "strong" === t || "emph" === t } function Ce(e) { var t = e.type; return "tableCell" === t || "tableDelimCell" === t } function we(e, t, n) { for (void 0 === n && (n = !0), e = n ? e : e.parent; e && "document" !== e.type;) { if (t(e)) return e; e = e.parent } return null } function _e(e, t) { return { line: e.line, ch: e.ch + t } } function Te(e, t) { return { line: e.line, ch: t } } var Ee = n(19), xe = n.n(Ee); function Se() { return (Se = Object.assign || function (e) { for (var t = 1; t < arguments.length; t++) { var n = arguments[t]; for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]) } return e }).apply(this, arguments) } var Ne, ke = (Ne = { DELIM: "delimiter", META: "meta", TEXT: "marked-text", THEMATIC_BREAK: "thematic-break", CODE_BLOCK: "code-block", TABLE: "table", HTML: "html" }, i()(Ne, (function (e, t) { Ne[t] = Me(e) })), Ne), Le = { strong: 2, emph: 1, strike: 2 }; function Me() { for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++) t[n] = arguments[n]; return t.map((function (e) { return "tui-md-" + e })).join(" ") } function Ae(e, t, n) { return { start: e, end: t, className: n } } function Be(e, t, n) { var r = e.type; return { marks: [Ae(t, n, Me("" + r)), Ae(t, _e(t, Le[r]), ke.DELIM), Ae(_e(n, -Le[r]), n, ke.DELIM)] } } function Oe(e, t, n, r) { return [Ae(e, t, Me("link")), Ae(n, Te(t, r), Me("link-desc")), Ae(Te(e, n.ch + 1), Te(t, r - 1), ke.TEXT), Ae(Te(t, r), t, Me("link-url")), Ae(Te(t, r + 1), _e(t, -1), ke.TEXT)] } function De(e, t) { for (var n = []; e;) { var r = e.type; "paragraph" !== r && "codeBlock" !== r || n.push(Ae({ line: ge(e) - 1, ch: ve(e) - 1 }, { line: me(e) - 1, ch: ye(e) }, t)), e = e.next } return n } var Ie = { heading: function (e, t, n) { var r = e.level, i = e.headingType, o = [Ae(t, n, Me("heading", "heading" + r))]; return "atx" === i ? o.push(Ae(t, _e(t, r), ke.DELIM)) : o.push(Ae(Te(n, 0), n, ke.DELIM + " setext")), { marks: o } }, strong: Be, emph: Be, strike: Be, link: function (e, t, n) { var r = e.lastChild, i = e.extendedAutolink, o = r ? ye(r) + 1 : 2; return { marks: i ? [Ae(t, n, Me("link", "link-desc") + " " + ke.TEXT)] : Oe(t, n, t, o) } }, image: function (e, t, n) { var r = e.lastChild, i = r ? ye(r) + 1 : 3, o = _e(t, 1); return { marks: [Ae(t, o, ke.META)].concat(Oe(t, n, o, i)) } }, code: function (e, t, n) { var r = e.tickCount, i = _e(t, r), o = _e(n, -r); return { marks: [Ae(t, n, Me("code")), Ae(t, i, ke.DELIM + " start"), Ae(i, o, ke.TEXT), Ae(o, n, ke.DELIM + " end")] } }, codeBlock: function (e, t, n, r) { var i = e.fenceOffset, o = e.fenceLength, a = e.fenceChar, s = e.info, l = e.infoPadding, c = e.parent, u = i + o, d = [Ae(Te(t, 0), n, ke.CODE_BLOCK)]; return a && d.push(Ae(t, _e(t, u), ke.DELIM)), s && d.push(Ae(Te(t, u), Te(t, u + l + s.length), ke.META)), new RegExp("^(\\s{0,3})(" + a + "{" + o + ",})").test(r) && d.push(Ae(Te(n, 0), n, ke.DELIM)), { marks: d, lineBackground: Se({}, "item" !== c.type && "blockQuote" !== c.type ? { start: t.line, end: n.line, className: ke.CODE_BLOCK } : null) } }, blockQuote: function (e, t, n) { var r = e.parent && "blockQuote" !== e.parent.type ? [Ae(t, n, Me("block-quote"))] : []; if (e.firstChild) { var i = []; "paragraph" === e.firstChild.type ? i = function (e) { for (var t = []; e;) t.push(Ae({ line: ge(e) - 1, ch: ve(e) - 1 }, { line: me(e) - 1, ch: ye(e) }, ke.TEXT)), e = e.next; return t }(e.firstChild.firstChild, ke.TEXT) : "list" === e.firstChild.type && (i = De(e.firstChild, ke.TEXT)), r = [].concat(r, i) } return { marks: r } }, item: function (e, t) { var n = function (e) { for (var t = 0; e.parent.parent && "item" === e.parent.parent.type;) e = e.parent.parent, t += 1; var n = ["fisrt", "second", "third"][t % 3]; return Me("list-item", "" + ["list-item-odd", "list-item-even"][t % 2]) + " " + n }(e), r = e.listData, i = r.padding, o = r.task; return { marks: [Ae(t, _e(t, i), n + " " + Me("list-item-bullet"))].concat(o ? [Ae(_e(t, i), _e(t, i + 3), n + " " + ke.DELIM), Ae(_e(t, i + 1), _e(t, i + 2), ke.META)] : [], De(e.firstChild, n + " " + ke.TEXT)) } } }, Re = { thematicBreak: ke.THEMATIC_BREAK, table: ke.TABLE, tableCell: ke.TEXT, htmlInline: ke.HTML }; function Pe(e, t) { var n; if ("undefined" == typeof Symbol || null == e[Symbol.iterator]) { if (Array.isArray(e) || (n = function (e, t) { if (!e) return; if ("string" == typeof e) return He(e, t); var n = Object.prototype.toString.call(e).slice(8, -1); "Object" === n && e.constructor && (n = e.constructor.name); if ("Map" === n || "Set" === n) return Array.from(e); if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return He(e, t) }(e)) || t && e && "number" == typeof e.length) { n && (e = n); var r = 0; return function () { return r >= e.length ? { done: !0 } : { done: !1, value: e[r++] } } } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.") } return (n = e[Symbol.iterator]()).next.bind(n) } function He(e, t) { (null == t || t > e.length) && (t = e.length); for (var n = 0, r = new Array(t); n < t; n++) r[n] = e[n]; return r } function Fe() { return (Fe = Object.assign || function (e) { for (var t = 1; t < arguments.length; t++) { var n = arguments[t]; for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]) } return e }).apply(this, arguments) } var Ue = J.getSharedInstance(), We = { strong: !1, emph: !1, strike: !1, thematicBreak: !1, blockQuote: !1, code: !1, codeBlock: !1, list: !1, taskList: !1, orderedList: !1, heading: !1, table: !1 }; var qe = /x|backspace/i, ze = function (e) { var t, n; function r(t, n, r, i) { var o; return (o = e.call(this, t, { dragDrop: !0, allowDropFileTypes: ["image"], extraKeys: { Enter: function () { return o.eventManager.emit("command", "AddLine") }, Tab: function () { return o.eventManager.emit("command", "MoveNextCursorOrIndent") }, "Shift-Tab": function () { return o.eventManager.emit("command", "MovePrevCursorOrOutdent") }, "Shift-Ctrl-X": function () { return o.eventManager.emit("command", "ToggleTaskMarker") } }, viewportMargin: i && "auto" === i.height ? 1 / 0 : 10 }) || this).eventManager = n, o.componentManager = new fe(function (e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e }(o)), o.toastMark = r, o.componentManager.addManager(he), o._latestState = null, o._markedLines = {}, o._initEvent(), o } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i._initEvent = function () { var e = this; this.cm.getWrapperElement().addEventListener("click", (function () { e.eventManager.emit("click", { source: "markdown" }) })), this.cm.on("beforeChange", (function (t, n) { "paste" === n.origin && e.eventManager.emit("pasteBefore", { source: "markdown", data: n }) })), this.cm.on("change", (function (t, n) { e._refreshCodeMirrorMarks(n), e._emitMarkdownEditorChangeEvent(n) })), this.cm.on("focus", (function () { e.eventManager.emit("focus", { source: "markdown" }) })), this.cm.on("blur", (function () { e.eventManager.emit("blur", { source: "markdown" }) })), this.cm.on("scroll", (function (t, n) { e.eventManager.emit("scroll", { source: "markdown", data: n }) })), this.cm.on("keydown", (function (t, n) { e.eventManager.emit("keydown", { source: "markdown", data: n }), e.eventManager.emit("keyMap", { source: "markdown", keyMap: Ue.convert(n), data: n }) })), this.cm.on("keyup", (function (t, n) { e.eventManager.emit("keyup", { source: "markdown", data: n }); var r = n.key; qe.test(r) && e.eventManager.emit("command", "ChangeTaskMarker") })), this.cm.on("copy", (function (t, n) { e.eventManager.emit("copy", { source: "markdown", data: n }) })), this.cm.on("cut", (function (t, n) { e.eventManager.emit("cut", { source: "markdown", data: n }) })), this.cm.on("paste", (function (t, n) { e.eventManager.emit("paste", { source: "markdown", data: n }) })), this.cm.on("drop", (function (t, n) { n.preventDefault(), e.eventManager.emit("drop", { source: "markdown", data: n }) })), this.cm.on("cursorActivity", (function () { return e._onChangeCursorActivity() })) }, i.setValue = function (t, n) { e.prototype.setValue.call(this, t, n) }, i.getTextObject = function (e) { return new pe(this, e) }, i._emitMarkdownEditorContentChangedEvent = function (e) { this.eventManager.emit("contentChangedFromMarkdown", e) }, i._emitMarkdownEditorChangeEvent = function (e) { if ("setValue" !== e.origin) { var t = { source: "markdown" }; this.eventManager.emit("changeFromMarkdown", t), this.eventManager.emit("change", t) } }, i._refreshCodeMirrorMarks = function (e) { var t = this, n = e.from, r = e.to, i = e.text, o = this.toastMark.editMarkdown([n.line + 1, n.ch + 1], [r.line + 1, r.ch + 1], i.join("\n")); this._emitMarkdownEditorContentChangedEvent(o), o.length && o.forEach((function (e) { return t._markNodes(e) })) }, i._markNodes = function (e) { var t = e.nodes, n = e.removedNodeRange; if (n && this._removeBackgroundOfLines(n), t.length) { for (var r, i = t[0].sourcepos[0], o = t[t.length - 1].sourcepos[1], a = { line: i[0] - 1, ch: i[1] - 1 }, s = { line: o[0] - 1, ch: o[1] }, l = Pe(this.cm.findMarks(a, s)); !(r = l()).done;) { var c = r.value; c.attributes && "data-tui-mark" in c.attributes && c.clear() } for (var u, d = Pe(t); !(u = d()).done;) for (var h = u.value.walker(), f = h.next(); f;) { var p = f, g = p.node; p.entering && this._markNode(g), f = h.next() } } }, i._removeBackgroundOfLines = function (e) { for (var t = e.line, n = t[0], r = t[1], i = n; i <= r; i += 1) this._markedLines[i] && (this.cm.removeLineClass(i, "background"), this._markedLines[i] = !1) }, i._markCodeBlockBackground = function (e) { for (var t = e.start, n = e.end, r = e.className, i = t; i <= n; i += 1) { var o = r; i === t ? o += " start" : i === n && (o += " end"), this.cm.addLineClass(i, "background", o), this._markedLines[i] = !0 } }, i._markNode = function (e) { var t = this, n = { line: ge(e) - 1, ch: ve(e) - 1 }, r = { line: me(e) - 1, ch: ye(e) }, i = function (e, t, n, r) { var i = e.type; return xe()(Ie[i]) ? Ie[i](e, t, n, r) : Re[i] ? { marks: [Ae(t, n, Re[i])] } : null }(e, n, r, this.cm.getLine(r.line)); if (i) { var o = i.marks, a = void 0 === o ? [] : o, s = i.lineBackground, l = void 0 === s ? {} : s; a.forEach((function (e) { var n, r = e.start, i = e.end, o = e.className, a = ((n = {})["data-tui-mark"] = "", n); t.cm.markText(r, i, { className: o, attributes: a }) })), this._markCodeBlockBackground(l) } }, i._setToolbarState = function (e) { if (n = this._latestState, r = e, (n || r) && (!n && r || n && !r || Object.keys(r).some((function (e) { return n[e] !== r[e] })))) { var t = Fe({ source: "markdown" }, e || We); this.eventManager.emit("stateChange", t) } var n, r; this._latestState = e }, i._onChangeCursorActivity = function () { var e = this.cm.getCursor(), t = e.line, n = e.ch, r = t + 1, i = this.cm.getLine(t).length === n ? n : n + 1, o = this.toastMark.findNodeAtPosition([r, i]), a = null; this.cm.state.isCursorInCodeBlock = o && "codeBlock" === o.type, this.eventManager.emit("cursorActivity", { source: "markdown", cursor: { line: t, ch: n }, markdownNode: o }), o && (a = function (e, t, n, r) { var i = Fe({}, We), o = !1; return function (e, t, n) { for (void 0 === n && (n = !0), e = n ? e : e.parent; e && "document" !== e.type;) t(e), e = e.parent }(e, (function (e) { var t = function (e) { var t = e.type, n = e.listData; return "list" === t || "item" === t ? n.task ? "taskList" : "ordered" === n.type ? "orderedList" : "list" : -1 !== t.indexOf("table") ? "table" : t }(e); M()(i[t]) && ("list" === t || "orderedList" === t ? o || (i[t] = !0, o = !0) : i[t] = !0) })), be(e) && (r === t && me(e) === n || r === ye(e) + 1 && n === me(e) || r === ve(e) && n === ge(e)) && (i[e.type] = !1), i }(o = "text" === o.type ? o.parent : o, n, r, i)), this._setToolbarState(a) }, i.resetState = function () { this._latestState = null }, i.getToastMark = function () { return this.toastMark }, r.factory = function (e, t, n, i) { return new r(e, t, n, i) }, r }(Z), je = n(13), Ve = n.n(je), Ke = n(14), Ge = n.n(Ke), $e = n(11), Ye = n.n($e), Xe = function () { function e() { this.globalTOID = null, this.lazyRunFunctions = {} } var t = e.prototype; return t.run = function (e, t, n, r) { var i; return Ye()(e) ? i = this._runRegisteredRun(e, t, n, r) : (i = this._runSingleRun(e, t, n, r, this.globalTOID), this.globalTOID = i), i }, t.registerLazyRunFunction = function (e, t, n, r) { r = r || this, this.lazyRunFunctions[e] = { fn: t, delay: n, context: r, TOID: null } }, t._runSingleRun = function (e, t, n, r, i) { return this._clearTOIDIfNeed(i), i = setTimeout((function () { e.call(n, t) }), r) }, t._runRegisteredRun = function (e, t, n, r) { var i = this.lazyRunFunctions[e], o = i.fn, a = i.TOID; return r = r || i.delay, n = n || i.context, a = this._runSingleRun(o, t, n, r, a), i.TOID = a, a }, t._clearTOIDIfNeed = function (e) { e && clearTimeout(e) }, e }(), Ze = n(1), Qe = n.n(Ze), Je = n(10), et = n.n(Je), tt = n(8), nt = n.n(tt), rt = /\u200B/g, it = window.getComputedStyle, ot = function (e) { return e && e.nodeType === Node.TEXT_NODE }, at = function (e) { return e && e.nodeType === Node.ELEMENT_NODE }, st = function (e) { return at(e) ? e.tagName : "TEXT" }, lt = function (e) { var t; return at(e) ? t = e.textContent.replace(rt, "").length : ot(e) && (t = e.nodeValue.replace(rt, "").length), t }, ct = function (e) { var t, n, r, i = e.parentNode.childNodes; for (t = 0, n = i.length; t < n; t += 1) if (i[t] === e) { r = t; break } return r }, ut = function (e, t) { var n; return ot(e) ? n = e : e.childNodes.length && t >= 0 && (n = e.childNodes[t]), n }, dt = function (e, t, n) { for (var r, i, o = e + "Sibling"; t && !t[o] && (r = st(t.parentNode)) !== n && "BODY" !== r;) t = t.parentNode; return t[o] && (i = t[o]), i }, ht = function (e, t, n) { for (; e.parentNode && !t(e.parentNode) && (e = e.parentNode, !n || !n(e));); return t(e.parentNode) ? e : null }, ft = function (e, t) { return Ye()(t) ? ht(e, (function (e) { return t === st(e) })) : ht(e, (function (e) { return t === e })) }, pt = function (e, t, n) { var r, i = e + "Sibling"; return (t = ft(t, n)) && t[i] && (r = t[i]), r }, gt = function (e) { var t = {}; t.tagName = e.nodeName, e.id && (t.id = e.id); var n = e.className.trim(); return n && (t.className = n), t }, mt = function (e, t, n) { var r = t; if (r && e === r.parentNode) for (; r !== n;) { var i = r.nextSibling; e.removeChild(r), r = i } }, vt = function (e) { return !!e && ("UL" === e.nodeName || "OL" === e.nodeName) }, yt = function (e, t) { e.hasChildNodes() && (Qe()(e.childNodes).forEach((function () { t.appendChild(e.firstChild) })), t.normalize()), e.parentNode && e.parentNode.removeChild(e) }, bt = function (e, t) { if ("SPAN" !== e.nodeName) for (var n = e.parentNode, r = e; r.childNodes && 1 === r.childNodes.length && !ot(r.firstChild) && "SPAN" !== (r = r.firstChild).nodeName;) if (r.nodeName === t) { var i = document.createElement(t); return yt(r, r.parentNode), n.replaceChild(i, e), i.appendChild(e), i } return e }, Ct = function (e, t, n) { var r = bt(e, n); if (r.nodeName === n) for (var i = bt(t, n), o = r, a = r.nextSibling; a;) { var s = a.nextSibling; if ((a = bt(a, n)).nodeName === n ? o ? yt(a, o) : o = a : o = null, a === i) break; a = s } }; function wt(e, t) { var n = Qe()(e.querySelectorAll(t)); return n.length ? n : [] } function _t(e, t, n) { var r; for (n = n || document, r = Ye()(t) ? function (e) { return nt()(e, t) } : function (e) { return e === t }; e && e !== n;) { if (at(e) && r(e)) return e; e = e.parentNode } return null } function Tt(e, t) { for (var n = []; e && e !== document;)(e = _t(e.parentNode, t)) && n.push(e); return n } function Et(e, t) { var n; return n = e.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? e.childNodes : e.children, Qe()(n).filter((function (e) { return nt()(e, t) })) } function xt(e) { e.parentNode && e.parentNode.removeChild(e) } var St = { getNodeName: st, isTextNode: ot, isElemNode: at, isBlockNode: function (e) { return /^(ADDRESS|ARTICLE|ASIDE|BLOCKQUOTE|DETAILS|DIALOG|DD|DIV|DL|DT|FIELDSET|FIGCAPTION|FIGURE|FOOTER|FORM|H[\d]|HEADER|HGROUP|HR|LI|MAIN|NAV|OL|P|PRE|SECTION|UL)$/gi.test(this.getNodeName(e)) }, getTextLength: lt, getOffsetLength: function (e) { var t; return at(e) ? t = e.childNodes.length : ot(e) && (t = e.nodeValue.replace(rt, "").length), t }, getPrevOffsetNodeUntil: function (e, t, n) { return t > 0 ? ut(e, t - 1) : dt("previous", e, n) }, getNodeOffsetOfParent: ct, getChildNodeByOffset: ut, getNodeWithDirectionUntil: dt, containsNode: function (e, t) { for (var n = document.createTreeWalker(e, 4, null, !1), r = e === t; !r && n.nextNode();) r = n.currentNode === t; return r }, getTopPrevNodeUnder: function (e, t) { return pt("previous", e, t) }, getTopNextNodeUnder: function (e, t) { return pt("next", e, t) }, getParentUntilBy: ht, getParentUntil: ft, getTopBlockNode: function (e) { return ft(e, "BODY") }, getPrevTextNode: function (e) { for (e = e.previousSibling || e.parentNode; !ot(e) && "BODY" !== st(e);) if (e.previousSibling) for (e = e.previousSibling; e.lastChild;) e = e.lastChild; else e = e.parentNode; return "BODY" === st(e) && (e = null), e }, findOffsetNode: function (e, t, n) { var r, i = [], o = "", a = 0; if (!t.length) return i; for (var s = t.shift(), l = document.createTreeWalker(e, 4, null, !1); l.nextNode();) { for (o = l.currentNode.nodeValue || "", n && (o = n(o)), r = a + o.length; r >= s;) { if (i.push({ container: l.currentNode, offsetInContainer: s - a, offset: s }), !t.length) return i; s = t.shift() } a = r } do { i.push({ container: l.currentNode, offsetInContainer: o.length, offset: s }), s = t.shift() } while (!_()(s)); return i }, getPath: function (e, t) { for (var n = []; e && e !== t;) at(e) && n.unshift(gt(e)), e = e.parentNode; return n }, getNodeInfo: gt, getTableCellByDirection: function (e, t) { var n = null; return _()(t) || "next" !== t && "previous" !== t || (n = "next" === t ? e.nextElementSibling : e.previousElementSibling), n }, getSiblingRowCellByDirection: function (e, t, n) { var r, i, o, a, s, l = null; return _()(t) || "next" !== t && "previous" !== t || e && ("next" === t ? (i = e.parentNode && e.parentNode.nextSibling, s = (a = (o = Tt(e, "thead"))[0] && o[0].nextSibling) && "TBODY" === st(a), r = 0) : (i = e.parentNode && e.parentNode.previousSibling, s = (a = (o = Tt(e, "tbody"))[0] && o[0].previousSibling) && "THEAD" === st(a), r = e.parentNode.childNodes.length - 1), !_()(n) && n || (r = ct(e)), i ? l = Et(i, "td,th")[r] : o[0] && s && (l = wt(a, "td,th")[r])), l }, isMDSupportInlineNode: function (e) { return /^(A|B|BR|CODE|DEL|EM|I|IMG|S|SPAN|STRONG)$/gi.test(e.nodeName) }, isStyledNode: function (e) { return /^(A|ABBR|ACRONYM|B|BDI|BDO|BIG|CITE|CODE|DEL|DFN|EM|I|INS|KBD|MARK|Q|S|SAMP|SMALL|SPAN|STRONG|SUB|SUP|U|VAR)$/gi.test(e.nodeName) }, removeChildFromStartToEndNode: mt, removeNodesByDirection: function (e, t, n) { for (var r = t; r !== e;) { var i = r.parentNode, o = r, a = o.nextSibling, s = o.previousSibling; !n && a ? mt(i, a, null) : n && s && mt(i, i.childNodes[0], r), r = i } }, getLeafNode: function (e) { for (var t = e; t.childNodes && t.childNodes.length;) { var n = t.firstChild; t = ot(n) && !lt(n) && n.nextSibling || n } return t }, isInsideButtonBox: function (e, t, n) { var r = parseInt(e.left, 10), i = parseInt(e.top, 10), o = parseInt(e.width, 10), a = parseInt(e.height, 10); return t >= r && t <= r + o && n >= i && n <= i + a }, isListNode: vt, isFirstListItem: function (e) { var t = e.nodeName, n = e.parentNode; return "LI" === t && e === n.firstChild }, isFirstLevelListItem: function (e) { var t = e.nodeName, n = e.parentNode.parentNode; return "LI" === t && !vt(n) }, mergeNode: yt, createHorizontalRule: function () { var e = document.createElement("div"), t = document.createElement("hr"); return e.setAttribute("contenteditable", !1), t.setAttribute("contenteditable", !1), e.appendChild(t), e }, createEmptyLine: function () { var e = document.createElement("div"); return e.appendChild(document.createElement("br")), e }, changeTagOrder: bt, mergeSameNodes: Ct, optimizeRange: function (e, t) { var n = e.collapsed, r = e.commonAncestorContainer, i = e.startContainer, o = e.endContainer; if (!n) { var a = null; if (i !== o) { var s = ft(i, r), l = ft(o, r); s && l && Ct(s, l, t), a = r } else ot(i) && (a = i.parentNode); if (a && a.nodeName === t) { var c, u = a.previousSibling; u && (c = bt(u)).nodeName === t && yt(a, c); var d = a.nextSibling; d && (c = bt(d)).nodeName === t && yt(c, a) } } }, getAllTextNode: function (e) { for (var t = document.createTreeWalker(e, 4, null, !1), n = []; t.nextNode();) { var r = t.currentNode; ot(r) && n.push(r) } return n }, isCellNode: function (e) { return !!e && ("TD" === e.nodeName || "TH" === e.nodeName) }, getLastNodeBy: function (e, t) { for (var n = e && e.lastChild; n && t(n);) n = n.lastChild; return n }, getParentNodeBy: function (e, t) { for (; e && t(e.parentNode, e);) e = e.parentNode; return e }, getSiblingNodeBy: function (e, t, n) { for (var r = t + "Sibling"; e && n(e[r], e);) e = e[r]; return e }, createElementWith: function (e, t) { var n = document.createElement("div"); Ye()(e) ? n.innerHTML = e : n.appendChild(e); var r = n.firstChild; return t && t.appendChild(r), r }, findAll: wt, isContain: function (e, t) { return e !== t && e.contains(t) }, closest: _t, parent: function (e, t) { var n = e.parentNode; return t ? n && nt()(n, t) ? n : null : n }, parents: Tt, parentsUntil: function (e, t) { for (var n = []; e.parentNode && !nt()(e.parentNode, t);)(e = e.parentNode) && n.push(e); return n }, children: Et, append: function (e, t) { if (Ye()(t)) e.insertAdjacentHTML("beforeEnd", t); else for (var n = 0, r = (t = t.length ? Qe()(t) : [t]).length; n < r; n += 1) e.appendChild(t[n]) }, prepend: function (e, t) { if (Ye()(t)) e.insertAdjacentHTML("afterBegin", t); else for (var n = (t = t.length ? Qe()(t) : [t]).length - 1; n >= 0; n -= 1) e.insertBefore(t[n], e.firstChild) }, insertBefore: function (e, t) { var n = t.parentNode; n && n.insertBefore(e, t) }, insertAfter: function (e, t) { var n = t.parentNode; n && n.insertBefore(e, t.nextSibling) }, replaceWith: function (e, t) { (e = e.length ? Qe()(e) : [e]).forEach((function (e) { e.insertAdjacentHTML("afterEnd", t), e.parentNode.removeChild(e) })) }, wrap: function (e, t) { (e = e.length ? Qe()(e) : [e]).forEach((function (e) { var n = document.createElement(t); e.parentNode.insertBefore(n, e), n.appendChild(e) })) }, wrapInner: function (e, t) { (e = e.length ? Qe()(e) : [e]).forEach((function (e) { var n = document.createElement(t); for (e.appendChild(n); e.firstChild !== n;) n.appendChild(e.firstChild) })) }, unwrap: function (e) { for (var t = []; e.firstChild;) t.push(e.firstChild), e.parentNode.insertBefore(e.firstChild, e); return xt(e), t }, remove: xt, empty: function (e) { for (; e.firstChild;) e.removeChild(e.firstChild) }, setOffset: function (e, t) { var n = e.parentNode.getBoundingClientRect(), r = n.top, i = n.left; h()(e, { top: t.top - r - document.body.scrollTop + "px" }), h()(e, { left: t.left - i - document.body.scrollLeft + "px" }) }, getOffset: function (e, t) { void 0 === t && (t = "document"); var n = 0, r = 0; do { n += e.offsetTop || 0, r += e.offsetLeft || 0, e = e.offsetParent } while (e && !nt()(e, t)); return { top: n, left: r } }, getOuterWidth: function (e, t) { var n = e.offsetWidth; if (t) { var r = it(e), i = r.marginLeft, o = r.marginRight; n += parseInt(i, 10) + parseInt(o, 10) } return n }, getOuterHeight: function (e, t) { var n = e.offsetHeight; if (t) { var r = it(e), i = r.marginTop, o = r.marginBottom; n += parseInt(i, 10) + parseInt(o, 10) } return n }, toggleClass: function (e, t, n) { _()(n) && (n = !et()(e, t)), (n ? p.a : m.a)(e, t) }, finalizeHtml: function (e, t) { var n; if (t) n = e.innerHTML; else { for (var r = document.createDocumentFragment(), i = Qe()(e.childNodes), o = i.length, a = 0; a < o; a += 1) r.appendChild(i[a]); n = r } return n }, getFragmentReplacedByNewlineToBr: function (e) { var t = document.createDocumentFragment(), n = e.split("\n"); return n.forEach((function (e, r) { var i = document.createTextNode(e); t.appendChild(i), r < n.length - 1 && t.appendChild(document.createElement("br")) })), t } }; var Nt = new(function () { function e() { this._replacers = {} } var t = e.prototype; return t.setReplacer = function (e, t) { e = e.toLowerCase(), this._replacers[e] = t }, t.getReplacer = function (e) { return this._replacers[e] }, t.createCodeBlockHtml = function (e, t) { e = e.toLowerCase(); var n, r = this.getReplacer(e); return r ? r(t, e) : (n = !1, t.replace(n ? /&/g : /&(?!#?\w+;)/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'")) }, e }()), kt = function () { function e(e, t, n, r) { this.eventManager = t, this.convertor = n, this.el = e, this.isViewer = !!r, this.delayCodeBlockTime = 500, this._initContentSection(), this.lazyRunner = new Xe } var t = e.prototype; return t._initContentSection = function () { this._previewContent = St.createElementWith('
'), this.el.appendChild(this._previewContent) }, t.getCodeBlockElements = function (e) { var t = this._previewContent, n = []; return (e ? e.map((function (e) { return t.querySelector('[data-nodeid="' + e + '"]') })).filter(Boolean) : [t]).forEach((function (e) { n.push.apply(n, St.findAll(e, "code[data-language]")) })), n }, t.invokeCodeBlockPlugins = function (e) { e.forEach((function (e) { var t = e.getAttribute("data-language"), n = Nt.createCodeBlockHtml(t, e.textContent); e.innerHTML = n })) }, t.refresh = function (e) { void 0 === e && (e = ""), this.render(this.convertor.toHTMLWithCodeHighlight(e)), this.invokeCodeBlockPlugins(this.getCodeBlockElements()) }, t.getHTML = function () { return this._previewContent.innerHTML }, t.setHTML = function (e) { this._previewContent.innerHTML = e }, t.render = function (e) { var t = this._previewContent; e = this.eventManager.emit("previewBeforeHook", e) || e, St.empty(t), t.innerHTML = e }, t.setHeight = function (e) { h()(this.el, { height: e + "px" }) }, t.setMinHeight = function (e) { h()(this.el, { minHeight: e + "px" }) }, t.isVisible = function () { return "none" !== this.el.style.display }, e }(), Lt = ["list", "blockQuote"], Mt = ["UL", "OL", "BLOCKQUOTE"], At = ["TR", "TH", "TBODY", "TD"]; function Bt(e) { return !S(Lt, e.type) } function Ot(e, t, n, r) { var i = (e - t) / n; return i < 1 ? i * r : r } function Dt(e) { for (var t = document.querySelector('[data-nodeid="' + e.id + '"]'); !t || S(At, e.type) || be(e);) e = e.parent, t = document.querySelector('[data-nodeid="' + e.id + '"]'); return function (e) { var t = e.mdNode, n = e.node; for (; S(Lt, t.type) && t.firstChild;) t = t.firstChild, n = n.firstElementChild; return { mdNode: t, node: n } }(function (e) { var t = e; for (; e && "document" !== e;) { if ("item" === e.type) { t = e; break } e = e.parent } return { mdNode: t, node: document.querySelector('[data-nodeid="' + t.id + '"]') } }(e)) } function It(e, t) { var n = ge(e), r = me(e), i = t.lineInfo(n - 1).handle.height, o = t.heightAtLine(r, "local") - t.heightAtLine(n - 1, "local"); return o <= 0 ? i : o + Rt(t, me(e)) } function Rt(e, t, n) { void 0 === n && (n = Number.MAX_VALUE); var r = e.lineInfo(t); if (!r) return 0; for (var i = r.handle, o = 0; t <= n && !i.text.trim();) o += i.height, t += 1, i = e.lineInfo(t).handle; return o } function Pt(e, t) { for (var n = 0; e && e !== t && (S(Mt, e.tagName) || (n += e.offsetTop), e.offsetParent !== t.offsetParent);) e = e.parentElement; return n } function Ht(e, t) { for (var n = t, r = null; n;) { var i = n.firstElementChild; if (!i) break; r = n, n = Ft(i, e, Pt(n, t)) } var o = n || r; return o === t ? null : o } function Ft(e, t, n) { return e && t > n + e.offsetTop ? Ft(e.nextElementSibling, t, n) || e : null } function Ut(e) { var t = e.latestScrollTop, n = e.scrollTop, r = e.targetScrollTop, i = e.sourceScrollTop; return null === t ? r : t < n ? Math.max(r, i) : Math.min(r, i) } var Wt = {}; function qt(e, t) { Wt[e] = Wt[e] || {}, Wt[e].height = t } function zt(e) { return Wt[e] && Wt[e].height } function jt(e) { e && (delete Wt[e.getAttribute("data-nodeid")], Qe()(e.children).forEach((function (e) { jt(e) }))) } var Vt = function (e) { var t, n; function r(t, n, r, i) { var o; (o = e.call(this, t, n, r, i.isViewer) || this).lazyRunner.registerLazyRunFunction("invokeCodeBlock", o.invokeCodeBlockPlugins, o.delayCodeBlockTime, function (e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e }(o)); var a = i.linkAttribute, s = i.customHTMLRenderer, l = i.highlight, c = void 0 !== l && l; return o.renderHTML = Object(v.createRenderHTML)({ gfm: !0, nodeId: !0, convertors: C(a, s) }), o.cursorNodeId = null, o._initEvent(c), o } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i._initEvent = function (e) { var t = this; this.eventManager.listen("contentChangedFromMarkdown", this.update.bind(this)), e && (this.eventManager.listen("cursorActivity", (function (e) { var n = e.markdownNode, r = e.cursor; t._updateCursorNode(n, r) })), this.eventManager.listen("blur", (function () { t._removeHighlight() }))), Ve()(this.el, "scroll", (function (e) { t.eventManager.emit("scroll", { source: "preview", data: Ht(e.target.scrollTop, t._previewContent) }) })) }, i._removeHighlight = function () { if (this.cursorNodeId) { var e = this._getElementByNodeId(this.cursorNodeId); e && m()(e, "te-preview-highlight") } }, i._updateCursorNode = function (e, t) { e && ("tableRow" === (e = we(e, (function (e) { return ! function (e) { switch (e.type) { case "code": case "text": case "emph": case "strong": case "strike": case "link": case "image": case "htmlInline": case "linebreak": case "softbreak": return !0; default: return !1 } }(e) }))).type ? e = function (e, t) { for (var n = t.ch, r = e.firstChild; r && r.next && !(ve(r.next) > n + 1);) r = r.next; return r }(e, t) : "tableBody" === e.type && (e = null)); var n = e ? e.id : null; if (this.cursorNodeId !== n) { var r = e && "frontMatter" === e.customType, i = this._getElementByNodeId(this.cursorNodeId), o = this._getElementByNodeId(n); i && m()(i, "te-preview-highlight"), o && !r && p()(o, "te-preview-highlight"), this.cursorNodeId = n } }, i._getElementByNodeId = function (e) { return e ? this._previewContent.querySelector('[data-nodeid="' + e + '"]') : null }, i.update = function (e) { var t = this; e.forEach((function (e) { return t.replaceRangeNodes(e) })), this.eventManager.emit("previewRenderAfter", this) }, i.replaceRangeNodes = function (e) { var t = this, n = e.nodes, r = e.removedNodeRange, i = this._previewContent, o = this.eventManager.emitReduce("convertorAfterMarkdownToHtmlConverted", n.map((function (e) { return t.renderHTML(e) })).join("")); if (r) { var a = r.id, s = a[0], l = a[1], c = this._getElementByNodeId(s), u = this._getElementByNodeId(l); if (c) { var d; c.insertAdjacentHTML("beforebegin", o); for (var h = c; h && h !== u;) { var f = h.nextElementSibling; h.parentNode.removeChild(h), jt(h), h = f }(null == (d = h) ? void 0 : d.parentNode) && (St.remove(h), jt(h)) } } else i.insertAdjacentHTML("afterbegin", o); var p = this.getCodeBlockElements(n.map((function (e) { return e.id }))); p.length && this.lazyRunner.run("invokeCodeBlock", p) }, i.render = function (t) { e.prototype.render.call(this, t), this.eventManager.emit("previewRenderAfter", this) }, i.remove = function () { Ge()(this.el, "scroll"), this.el = null }, r }(kt), Kt = n(16), Gt = n.n(Kt), $t = n(15), Yt = n.n($t), Xt = n(5), Zt = n.n(Xt), Qt = n(23), Jt = n.n(Qt), en = /MsoListParagraph/, tn = /style=(.|\n)*mso-/, nn = /mso-list:(.*)/, rn = /O:P/, on = /^(n|u|l)/; function an(e) { return tn.test(e) } function sn(e) { for (var t = [], n = document.createTreeWalker(e, 1, null, !1); n.nextNode();) { var r = n.currentNode; if (St.isElemNode(r)) { var i = r.outerHTML, o = r.textContent, a = tn.test(i), s = nn.test(i); a && !s && o ? t.push([r, !0]) : (rn.test(r.nodeName) || a && !o || s) && t.push([r, !1]) } } return t.forEach((function (e) { var t = e[0]; e[1] ? St.unwrap(t) : St.remove(t) })), e.innerHTML.trim() } function ln(e) { var t = []; return e.forEach((function (e, n) { var r = t[n - 1], i = function (e, t) { var n = e.getAttribute("style").match(nn)[1].trim().split(" ")[1]; return { id: t, level: parseInt(n.replace("level", ""), 10), prev: null, parent: null, children: [], unorderedListItem: on.test(e.textContent), contents: sn(e) } }(e, n); r && function (e, t) { if (t.level < e.level) t.children.push(e), e.parent = t; else { for (; t && t.level !== e.level;) t = t.parent; t && (e.prev = t, e.parent = t.parent, e.parent && e.parent.children.push(e)) } }(i, r), t.push(i) })), t } function cn(e) { return function e(t) { var n = t[0].unorderedListItem ? "ul" : "ol", r = document.createElement(n); return t.forEach((function (t) { var n = t.children, i = t.contents, o = document.createElement("li"); o.innerHTML = i, r.appendChild(o), n.length && r.appendChild(e(n)) })), r }(ln(e).filter((function (e) { return !e.parent }))) } function un(e) { var t = []; return St.findAll(e, "p.MsoListParagraph").forEach((function (n) { var r = function (e) { for (; e && !St.isElemNode(e);) e = e.nextSibling; return !e || !en.test(e.className) }(n.nextSibling); if (t.push(n), r) { var i = cn(t), o = n.nextSibling; o ? St.insertBefore(i, o) : St.append(e, i), t = [] } St.remove(n) })), e } var dn = new RegExp("^(abbr|align|alt|axis|bgcolor|border|cellpadding|cellspacing|class|clear|color|cols|compact|coords|dir|face|headers|height|hreflang|hspace|ismap|lang|language|nohref|nowrap|rel|rev|rows|rules|scope|scrolling|shape|size|span|start|summary|tabindex|target|title|type|valign|value|vspace|width|checked|mathvariant|encoding|id|name|background|cite|href|longdesc|src|usemap|xlink:href|data-+|checked|style)", "g"), hn = new RegExp("^(accent-height|accumulate|additive|alphabetic|arabic-form|ascent|baseProfile|bbox|begin|by|calcMode|cap-height|class|color|color-rendering|content|cx|cy|d|dx|dy|descent|display|dur|end|fill|fill-rule|font-family|font-size|font-stretch|font-style|font-variant|font-weight|from|fx|fy|g1|g2|glyph-name|gradientUnits|hanging|height|horiz-adv-x|horiz-origin-x|ideographic|k|keyPoints|keySplines|keyTimes|lang|marker-end|marker-mid|marker-start|markerHeight|markerUnits|markerWidth|mathematical|max|min|offset|opacity|orient|origin|overline-position|overline-thickness|panose-1|path|pathLength|points|preserveAspectRatio|r|refX|refY|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|rotate|rx|ry|slope|stemh|stemv|stop-color|stop-opacity|strikethrough-position|strikethrough-thickness|stroke|stroke-dasharray|stroke-dashoffset|stroke-linecap|stroke-linejoin|stroke-miterlimit|stroke-opacity|stroke-width|systemLanguage|target|text-anchor|to|transform|type|u1|u2|underline-position|underline-thickness|unicode|unicode-range|units-per-em|values|version|viewBox|visibility|width|widths|x|x-height|x1|x2|xlink:actuate|xlink:arcrole|xlink:role|xlink:show|xlink:title|xlink:type|xml:base|xml:lang|xml:space|xmlns|xmlns:xlink|y|y1|y2|zoomAndPan)", "g"), fn = /href|src|background/gi, pn = /((java|vb|live)script|x):/gi, gn = /^on\S+/; var mn = function (e, t) { var n = document.createElement("div"); return Ye()(e) ? (e = e.replace(//g, ""), n.innerHTML = e) : n.appendChild(e), function (e) { St.findAll(e, "script, iframe, textarea, form, button, select, input, meta, style, link, title, embed, object, details, summary").forEach((function (e) { St.remove(e) })) }(n), function (e) { St.findAll(e, "*").forEach((function (e) { var t = e.attributes; ! function (e, t) { Qe()(t).forEach((function (t) { var n = t.name; gn.test(n) && (e[n] = null), e.getAttribute(n) && e.removeAttribute(n) })) }(e, Qe()(t).filter((function (e) { var t = e.name, n = e.value, r = t.match(dn), i = t.match(hn), o = r && function (e, t) { return e.match(fn) && t.match(pn) }(t, n); return !r && !i || o }))) })) }(n), St.finalizeHtml(n, t) }, vn = function () { function e(e) { this.wwe = e } var t = e.prototype; return t.preparePaste = function (e) { var t, n, r, i = this.wwe.getEditor().getSelection().cloneRange(), o = this.wwe.componentManager.getManager("codeblock"), a = !1, s = document.createElement("div"); this._pasteFirstAid(e); for (var l = Qe()(e.childNodes); l.length;) n = l[0], r = "LI" === (t = St.getNodeName(n)) || "UL" === t || "OL" === t, o.isInCodeBlock(i) ? St.append(s, o.prepareToPasteOnCodeblock(l)) : r ? (St.append(s, this._prepareToPasteList(l, i, a)), a = !0) : St.append(s, l.shift()); e.innerHTML = s.innerHTML }, t._wrapOrphanNodeWithDiv = function (e) { var t, n = document.createElement("div"); return Qe()(e.childNodes).forEach((function (e) { var r = 3 === e.nodeType, i = /^(SPAN|A|CODE|EM|I|STRONG|B|S|U|ABBR|ACRONYM|CITE|DFN|KBD|SAMP|VAR|BDO|Q|SUB|SUP)$/gi.test(e.tagName), o = "BR" === e.nodeName; r || i || o ? (t || (t = document.createElement("div"), n.appendChild(t)), t.appendChild(e), o && (t = null)) : (t && "BR" !== t.lastChild.tagName && t.appendChild(document.createElement("br")), t = null, n.appendChild(e)) })), n.innerHTML }, t._sanitizeHtml = function (e) { var t = this.wwe.getSanitizer(), n = mn(e.innerHTML, !0); t && t !== mn && (n = t(n)), e.innerHTML = n }, t._pasteFirstAid = function (e) { var t = this; this._sanitizeHtml(e), St.findAll(e, "*").forEach((function (e) { t._removeStyles(e) })); var n = "div, section, article, aside, nav, menus, p"; this._unwrapIfNonBlockElementHasBr(e), this._unwrapNestedBlocks(e, n), this._removeUnnecessaryBlocks(e, n), e.innerHTML = this._wrapOrphanNodeWithDiv(e), this._preprocessPreElement(e), this._preprocessListElement(e), this._preprocessTableElement(e), Qe()(e.children).forEach((function (e) { "BR" === St.getNodeName(e) && St.remove(e) })) }, t._preprocessListElement = function (e) { var t = this.wwe.componentManager.getManager("list"); e.innerHTML = t.convertToArbitraryNestingList(e.innerHTML) }, t._preprocessPreElement = function (e) { this.wwe.componentManager.getManager("codeblock").modifyCodeBlockForWysiwyg(e) }, t._unwrapIfNonBlockElementHasBr = function (e) { St.findAll(e, "span, a, b, em, i, s").forEach((function (e) { St.children(e, "br").length && "LI" !== e.nodeName && "UL" !== e.nodeName && St.unwrap(e) })) }, t._unwrapNestedBlocks = function (e, t) { St.findAll(e, "*").filter((function (e) { return !nt()(e, "b,s,i,em,code,span,hr") && !e.firstChild })).forEach((function (n) { for (var r = "BR" === n.nodeName ? n.parentNode : n; St.parents(r, t).length;) { var i = St.parent(r, t); i && i !== e ? St.unwrap(i) : r = r.parentElement } })) }, t._removeUnnecessaryBlocks = function (e, t) { St.findAll(e, t).forEach((function (e) { var n = "DIV" === e.tagName, r = !!St.parent(e, "li"), i = !!St.parent(e, "blockquote"), o = !!St.children(e, t).length; n && (r || i || !o) || (e.lastChild && "BR" !== e.lastChild.nodeName && e.appendChild(document.createElement("br")), St.replaceWith(e, e.innerHTML)) })) }, t._removeStyles = function (e) { var t; "SPAN" !== St.getNodeName(e) ? e.removeAttribute("style") : (e.getAttribute("style") && (t = e.style.color), e.removeAttribute("style"), t && "rgb(34, 34, 34)" !== t ? h()(e, { color: t }) : St.unwrap(e)) }, t._prepareToPasteList = function (e, t, n) { var r = St.getNodeName(e[0]), i = e.shift(), o = this.wwe.getEditor().getDocument().createDocumentFragment(); if ("LI" !== r && e.length && "LI" === e[0].tagName && (r = "LI", i = this._makeNodeAndAppend({ tagName: r }, i)), "OL" === r || "UL" === r) !n && this.wwe.getEditor().hasFormat("LI") ? St.append(o, this._wrapCurrentFormat(i)) : o.appendChild(i); else if ("LI" === r) { var a = this.wwe.getEditor().getDocument().createDocumentFragment(); for (a.appendChild(i); e.length && "LI" === e[0].tagName;) a.appendChild(e.shift()); !n && this.wwe.getEditor().hasFormat("LI") ? St.append(o, this._wrapCurrentFormat(a)) : !t || "UL" !== t.commonAncestorName && "OL" !== t.commonAncestorName ? St.append(o, this._makeNodeAndAppend({ tagName: "UL" }, a)) : St.append(o, this._makeNodeAndAppend({ tagName: t.commonAncestorName }, a)) } return this._getResolvePastedListDepthToCurrentDepth(t.startContainer, i, o) }, t._unwrapFragmentFirstChildForPasteAsInline = function (e) { return St.findAll(e, "br").forEach((function (e) { return St.remove(e) })), e.childNodes }, t._wrapCurrentFormat = function (e) { var t, n = this; return this._eachCurrentPath((function (r) { "DIV" !== r.tagName && (t = St.isElemNode(e) ? e.tagName : e.firstChild.tagName, r.tagName !== t && (e = n._makeNodeAndAppend(r, e))) })), e }, t._eachCurrentPath = function (e) { for (var t = St.getPath(this.wwe.getEditor().getSelection().startContainer, this.wwe.getBody()), n = t.length - 1; n > -1; n -= 1) e(t[n]) }, t._makeNodeAndAppend = function (e, t) { var n = document.createElement("" + e.tagName); return n.appendChild(t), e.id && n.setAttribute("id", e.id), e.className && p()(n, e.className), n }, t._preprocessTableElement = function (e) { this._removeColgroup(e), this._completeTableIfNeed(e), this._updateTableIDClassName(e) }, t._removeColgroup = function (e) { var t = e.querySelector("colgroup"); t && St.remove(t) }, t._completeTableIfNeed = function (e) { var t = this.wwe.componentManager.getManager("table"), n = t.wrapDanglingTableCellsIntoTrIfNeed(e); n && St.append(e, n); var r = t.wrapTrsIntoTbodyIfNeed(e); r && St.append(e, r); var i = t.wrapTheadAndTbodyIntoTableIfNeed(e); i && St.append(e, i) }, t._updateTableIDClassName = function (e) { var t = this.wwe.componentManager.getManager("table"), n = St.findAll(e, "table"); n.forEach((function (e) { var t = e.className.match(/.*\s*(te-content-table-\d+)\s*.*/); t && m()(e, t[0]) })), n.forEach((function (e) { p()(e, t.getTableIDClassName()) })) }, t._getResolvePastedListDepthToCurrentDepth = function (e, t, n) { var r = this._getListDepth(e), i = this._getContinuousDepth(t); for (n = this._getRemovedUnnecessaryListWrapper(n, t); r < i && ("UL" === n.firstChild.tagName || "OL" === n.firstChild.tagName);) { var o = Qe()(n.childNodes); n = n.firstChild, o.filter((function (e) { return e !== n })).forEach((function (e) { n.insertAdjacentElement("beforeend", e) })), i -= 1 } for (; r && r > i;) { var a = n.firstChild.parentElement, s = document.createElement(a.tagName); s.appendChild(a), n = s, i += 1 } return r && !e.textContent && St.remove(e), n }, t._getListDepth = function (e) { for (var t = 0, n = this.wwe.getBody(); e && e !== n;) "UL" !== e.tagName && "OL" !== e.tagName || (t += 1), e = e.parentNode; return t }, t._getContinuousDepth = function (e) { for (var t = 0; e && ("UL" === e.tagName || "OL" === e.tagName) && (t += 1, !(e.childNodes.length > 1));) e = e.firstChild; return t }, t._getRemovedUnnecessaryListWrapper = function (e, t) { for (; e.querySelectorAll("ul,ol").length > t.querySelectorAll("ul,ol").length;) e = e.firstChild; return e }, e }(), yn = function () { function e(e) { this.wwe = e } var t = e.prototype; return t.pasteClipboard = function (e) { var t = e.clipboardData || window.clipboardData, n = t && t.items; n ? (this._pasteClipboardItem(n), e.preventDefault()) : (this._pasteClipboardUsingPasteArea(), e.squirePrevented = !0) }, t._pasteClipboardUsingPasteArea = function () { var e = this, t = this.wwe.getEditor(), n = t.getSelection(), r = n.startContainer, i = n.startOffset, o = n.endContainer, a = n.endOffset, s = document.createElement("div"), l = document.body; s.setAttribute("contenteditable", !0), s.setAttribute("style", "position:fixed; overflow:hidden; top:0; right:100%; width:1px; height:1px;"), l.appendChild(s), n.selectNodeContents(s), t.setSelection(n), setTimeout((function () { var c = l.removeChild(s); n.setStart(r, i), n.setEnd(o, a), t.focus(), t.setSelection(n), e._pasteClipboardHtml(c.innerHTML) })) }, t._pasteClipboardItem = function (e) { var t = this, n = null, r = null; Qe()(e).forEach((function (e) { "text/html" === e.type ? r = e : "text/plain" === e.type && (n = e) })), r ? r.getAsString((function (e) { t._pasteClipboardHtml(e) })) : n && n.getAsString((function (e) { var n = St.getFragmentReplacedByNewlineToBr(e); t._pasteClipboardContainer(n) })) }, t._getSanitizedHtml = function (e) { var t = this.wwe.getSanitizer(); e = mn(e, !0), t && t !== mn && (e = t(e)); var n = document.createElement("div"); return n.innerHTML = e, St.finalizeHtml(n) }, t._convertToMsoList = function (e) { var t = document.createElement("div"); return t.innerHTML = e, un(t), t.innerHTML }, t._pasteClipboardHtml = function (e) { var t = document.createDocumentFragment(), n = e.indexOf("\x3c!--StartFragment--\x3e"), r = e.lastIndexOf("\x3c!--EndFragment--\x3e"); n > -1 && r > -1 && (e = e.slice(n + "\x3c!--StartFragment--\x3e".length, r)), /<\/td>((?!<\/tr>)[\s\S])*$/i.test(e) && (e = "" + e + ""), /<\/tr>((?!<\/table>)[\s\S])*$/i.test(e) && (e = "" + e + "
"), an(e) && (e = this._convertToMsoList(e)), t.appendChild(this._getSanitizedHtml(e)), this._pasteClipboardContainer(t) }, t._pasteClipboardContainer = function (e) { var t = this.wwe.getEditor(), n = e.childNodes; if (1 === n.length && "TABLE" === n[0].nodeName) { this.wwe.componentManager.getManager("table").pasteTableData(e) } else { var r = t.getSelection().cloneRange(), i = this._preparePasteDocumentFragment(e); t.saveUndoState(r), r.collapsed || this._deleteContentsRange(r), St.isTextNode(r.startContainer) ? this._pasteIntoTextNode(r, i) : this._pasteIntoElements(r, i), t.setSelection(r) } }, t._preparePasteDocumentFragment = function (e) { var t = e.childNodes, n = document.createDocumentFragment(); return t.length ? n.appendChild(this._unwrapBlock(e)) : this._isPossibleInsertToTable(e) && n.appendChild(e), n }, t._unwrapBlock = function (e) { for (var t = document.createDocumentFragment(), n = Qe()(e.childNodes); n.length;) { var r = n.shift(); if (this._isPossibleInsertToTable(r)) t.appendChild(r); else { t.appendChild(this._unwrapBlock(r)); var i = t.lastChild; n.length && i && "BR" !== i.nodeName && t.appendChild(document.createElement("br")) } } return t }, t._isPossibleInsertToTable = function (e) { var t = e.nodeName; return !("CODE" === t && e.childNodes.length > 1) && ("UL" === t || "OL" === t || St.isMDSupportInlineNode(e) || St.isTextNode(e)) }, t._pasteIntoElements = function (e, t) { var n = e.startContainer, r = e.startOffset, i = St.getChildNodeByOffset(n, r); if (i) n.insertBefore(t, i), e.setStart(i, 0); else if ("TD" === n.nodeName) n.appendChild(t), e.setStart(n, n.childNodes.length); else { var o = n.parentNode, a = n.nextSibling; o.insertBefore(t, a), a ? e.setStart(a, 0) : e.setStartAfter(o.lastChild) } e.collapse(!0) }, t._pasteIntoTextNode = function (e, t) { var n = e.startContainer, r = e.startOffset, i = n.parentNode, o = n.textContent, a = o.slice(0, r), s = o.slice(r, o.length), l = t.childNodes, c = l[0], u = 1 === l.length && St.isTextNode(c); if (a) if (s) if (u) { var d = c.textContent; n.textContent = "" + a + d + s, e.setStart(n, a.length + d.length) } else { var h = document.createDocumentFragment(); h.appendChild(document.createTextNode(a)), h.appendChild(t), h.appendChild(document.createTextNode(s)), i.replaceChild(h, n); var f = Qe()(i.childNodes), p = 0; f.forEach((function (e, t) { e.textContent === s && (p = t) })), e.setStart(i.childNodes[p], 0) } else { var g = n.nextSibling; i.insertBefore(t, g), e.setStartAfter(g) } else i.insertBefore(t, n), e.setStart(n, 0); e.collapse(!0) }, t._deleteContentsRange = function (e) { var t = e.startContainer, n = e.startOffset, r = e.endContainer, i = e.endOffset; t === r ? (this._deleteContentsByOffset(t, n, i), e.setStart(t, n), e.collapse(!0)) : this._deleteNotCollapsedRangeContents(e) }, t._deleteNotCollapsedRangeContents = function (e) { var t = e.startContainer, n = e.startOffset, r = e.endContainer, i = e.endOffset, o = e.commonAncestorContainer, a = this._getBlock(t, o, n), s = this._getBlock(r, o, i - 1); if (a === s) this._removeInSameBlock(a, t, r, n, i), s = r !== s ? null : s; else { var l = a.nextSibling; "TD" === t.nodeName ? l = this._removeOneLine(a) : (this._deleteContentsByOffset(t, n, St.getOffsetLength(t)), St.removeNodesByDirection(a, t, !1)), "TD" === r.nodeName ? s = this._removeOneLine(s) : (this._deleteContentsByOffset(r, 0, i), St.removeNodesByDirection(s, r, !0)), St.removeChildFromStartToEndNode(o, l, s) } s ? e.setStart(s, 0) : e.setStartAfter(a), e.collapse(!0) }, t._removeInSameBlock = function (e, t, n, r, i) { var o = t === e ? r : 0, a = n === e ? i : St.getOffsetLength(e); this._deleteContentsByOffset(e, o, a) }, t._removeOneLine = function (e) { var t = e.nextSibling, n = e.parentNode, r = t; return n.removeChild(e), t && "BR" === t.nodeName && (r = t.nextSibling, n.removeChild(t)), r }, t._getBlock = function (e, t, n) { return St.getParentUntil(e, t) || St.getChildNodeByOffset(e, n) }, t._deleteContentsByOffset = function (e, t, n) { if (St.isTextNode(e)) { var r = e.textContent, i = r.slice(0, t), o = r.slice(n, r.length); e.textContent = "" + i + o } else { var a = St.getChildNodeByOffset(e, t), s = St.getChildNodeByOffset(e, n); a && St.removeChildFromStartToEndNode(e, a, s || null) } }, e }(), bn = function () { function e(e) { this.wwe = e, this._pch = new vn(this.wwe), this._tablePasteHelper = new yn(this.wwe), this._selectedSellCount = 0, this._clipboardArea = null } var t = e.prototype; return t.init = function () { var e = this; this.wwe.eventManager.listen("willPaste", (function (t) { return e._executeHandler(e._onWillPaste.bind(e), t) })), this.wwe.eventManager.listen("copy", (function (t) { return e._executeHandler(e._onCopyCut.bind(e), t) })), this.wwe.eventManager.listen("copyAfter", (function (t) { return e._executeHandler(e._onCopyAfter.bind(e), t) })), this.wwe.eventManager.listen("cut", (function (t) { return e._executeHandler(e._onCopyCut.bind(e), t) })), this.wwe.eventManager.listen("cutAfter", (function (t) { return e._executeHandler(e._onCutAfter.bind(e), t) })), this.wwe.eventManager.listen("paste", (function (t) { return e._executeHandler(e._onPasteIntoTable.bind(e), t) })) }, t._executeHandler = function (e, t) { "wysiwyg" === t.source && e(t) }, t._onCopyCut = function (e) { var t = this.wwe.componentManager.getManager("tableSelection"); if (t.getSelectedCells().length) if (t.mergedTableSelectionManager) { var n = this.wwe.getEditor(), r = e.data, i = n.getSelection().cloneRange(), o = document.createElement("div"); this._extendRange(i), o.innerHTML = i.cloneContents(), this._updateCopyDataForListTypeIfNeed(i, o), this.wwe.eventManager.emit("copyBefore", { source: "wysiwyg", clipboardContainer: o }), this._setClipboardData(r, o.innerHTML, o.textContent) } else t.createRangeBySelectedCells() }, t._clearClipboardArea = function () { this._clipboardArea && (St.remove(this._clipboardArea), this._clipboardArea = null) }, t._onCopyAfter = function () { this.wwe.getEditor().getBody().focus(), this._clearClipboardArea() }, t._onCutAfter = function () { this.wwe.getEditor().getSelection().deleteContents(), this.wwe.getEditor().focus(), this._clearClipboardArea() }, t._onPasteIntoTable = function (e) { var t = e.data, n = this.wwe.getEditor().getSelection(); this.wwe.isInTable(n) && this._isSingleCellSelected(n) && this._tablePasteHelper.pasteClipboard(t) }, t._isSingleCellSelected = function (e) { var t = e.startContainer, n = e.endContainer; return this._getCell(t) === this._getCell(n) }, t._getCell = function (e) { return "TD" === e.nodeName ? e : St.getParentUntil(e, "TR") }, t._replaceNewLineToBr = function (e) { St.getAllTextNode(e).forEach((function (e) { /\n/.test(e.nodeValue) && (e.parentNode.innerHTML = e.nodeValue.replace(/\n/g, "
")) })) }, t._onWillPaste = function (e) { var t = this, n = e.data, r = document.createElement("div"); r.appendChild(n.fragment.cloneNode(!0)), this._preparePaste(r), this._setTableBookmark(r), n.fragment = document.createDocumentFragment(), Qe()(r.childNodes).forEach((function (e) { "DIV" === St.getNodeName(e) && t._replaceNewLineToBr(e), n.fragment.appendChild(e) })); this.wwe.getEditor().addEventListener("input", (function e() { t.wwe.getEditor().removeEventListener("input", e), t.wwe.eventManager.emit("wysiwygRangeChangeAfter", t), t._focusTableBookmark() })) }, t._setClipboardData = function (e, t, n) { Zt.a.msie ? (e.squirePrevented = !0, this._clipboardArea = this._createClipboardArea(), this._clipboardArea.innerHTML = t, this._clipboardArea.focus(), window.getSelection().selectAllChildren(this._clipboardArea)) : (e.preventDefault(), e.stopPropagation(), e.clipboardData.setData("text/html", t), e.clipboardData.setData("text/plain", n)) }, t._createClipboardArea = function () { var e = document.createElement("div"); return e.setAttribute("contenteditable", !0), h()(e, { position: "fixed", overflow: "hidden", top: 0, right: "100%", width: "1px", height: "1px" }), document.body.appendChild(e), e }, t._updateCopyDataForListTypeIfNeed = function (e, t) { var n = e.commonAncestorContainer.nodeName; if ("UL" === n || "OL" === n) { var r = document.createElement(n); r.appendChild(t), t.innerHTML = "", t.appendChild(r) } }, t._removeEmptyFontElement = function (e) { St.children(e, "font").forEach((function (e) { e.textContent.trim() || St.remove(e) })) }, t._preProcessPtag = function (e) { St.findAll(e, "p").forEach((function (e) { e.lastChild && "BR" !== e.lastChild.nodeName && e.appendChild(document.createElement("br")), e.appendChild(document.createElement("br")) })) }, t._preparePaste = function (e) { an(e.innerHTML) ? un(e) : this._preProcessPtag(e), this._removeEmptyFontElement(e), this._pch.preparePaste(e), this.wwe.eventManager.emit("pasteBefore", { source: "wysiwyg", clipboardContainer: e }) }, t._setTableBookmark = function (e) { var t = e.lastChild; t && "TABLE" === t.nodeName && p()(t, "tui-paste-table-bookmark") }, t._focusTableBookmark = function () { var e = this.wwe.getEditor(), t = e.getSelection().cloneRange(), n = e.getBody().querySelector(".tui-paste-table-bookmark"), r = e.getBody().querySelector(".tui-paste-table-cell-bookmark"); n && (m()(n, "tui-paste-table-bookmark"), t.setEndAfter(n), t.collapse(!1), e.setSelection(t)), r && (m()(r, "tui-paste-table-cell-bookmark"), t.selectNodeContents(r), t.collapse(!1), e.setSelection(t)) }, t._extendRange = function (e) { (!St.isTextNode(e.commonAncestorContainer) || 0 === e.startOffset && e.commonAncestorContainer.textContent.length === e.endOffset || "TD" === e.commonAncestorContainer.nodeName) && (0 === e.startOffset && (e = this._extendStartRange(e)), e.endOffset === St.getOffsetLength(e.endContainer) && (e = this._extendEndRange(e)), this._isWholeCommonAncestorContainerSelected(e) && e.selectNode(e.commonAncestorContainer), this.wwe.getEditor().setSelection(e)) }, t._extendStartRange = function (e) { for (var t = e.startContainer; t.parentNode !== e.commonAncestorContainer && t.parentNode !== this.wwe.getBody() && !t.previousSibling;) t = t.parentNode; return e.setStart(t.parentNode, St.getNodeOffsetOfParent(t)), e }, t._extendEndRange = function (e) { for (var t = e.endContainer, n = t.nextSibling; t.parentNode !== e.commonAncestorContainer && t.parentNode !== this.wwe.getBody() && (!n || "BR" === St.getNodeName(n) && t.parentNode.lastChild === n);) n = (t = t.parentNode).nextSibling; return e.setEnd(t.parentNode, St.getNodeOffsetOfParent(t) + 1), e }, t._isWholeCommonAncestorContainerSelected = function (e) { return e.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && e.commonAncestorContainer !== this.wwe.getBody() && 0 === e.startOffset && e.endOffset === e.commonAncestorContainer.childNodes.length && e.commonAncestorContainer === e.startContainer && e.commonAncestorContainer === e.endContainer }, e }(), Cn = function () { function e(e) { this.wwe = e, this.eventManager = e.eventManager, this.name = "link", this._init() } var t = e.prototype; return t._init = function () { var e = this; this.eventManager.listen("wysiwygSetValueAfter", (function () { e._addClassNameToAllImageLinks() })), this.wwe.getEditor().addEventListener("click", (function (t) { var n = t.target, r = t.offsetX, i = t.offsetY, o = getComputedStyle(n, ":before"); et()(n, "image-link") && St.isInsideButtonBox(o, r, i) && (e._selectImageLink(n.parentNode), e.eventManager.emit("openPopupAddLink", { url: n.getAttribute("href") })) })) }, t._selectImageLink = function (e) { var t = this.wwe.getEditor().getSelection().cloneRange(); t.selectNode(e), this.wwe.getEditor().setSelection(t) }, t._addClassNameToImageLinks = function (e) { e.forEach((function (e) { e.firstChild && "IMG" === e.firstChild.nodeName && p()(e, "image-link") })) }, t._addClassNameToAllImageLinks = function () { var e = St.findAll(this.wwe.getBody(), "a"); this._addClassNameToImageLinks(e) }, t.addClassNameToImageLinksInSelection = function () { var e, t = this.wwe.getEditor().getSelection().commonAncestorContainer; St.isElemNode(t) && (e = "A" === t.nodeName ? [t] : St.findAll(t, "a"), this._addClassNameToImageLinks(e)) }, e }(), wn = /
  • ]*>)(.*?)(<\/(?:th|td)>)/g, Tn = /<(ul|ol|li)([^>]*)>/g, En = function () { function e(e) { this.wwe = e, this.eventManager = e.eventManager, this.name = "list", this._init() } var t = e.prototype; return t._init = function () { this._initEvent(), this._initKeyHandler() }, t._initEvent = function () { var e = this; this.eventManager.listen("wysiwygSetValueBefore", (function (t) { return e.convertToArbitraryNestingList(t) })), this.eventManager.listen("wysiwygRangeChangeAfter", (function () { e._findAndRemoveEmptyList(), e._removeBranchListAll() })), this.eventManager.listen("wysiwygSetValueAfter", (function () { e._removeBranchListAll() })), this.eventManager.listen("wysiwygProcessHTMLText", (function (t) { return t = e._convertFromArbitraryNestingList(t) })), this.eventManager.listen("convertorBeforeHtmlToMarkdownConverted", (function (t) { return e._insertDataToMarkPassForListInTable(t) })) }, t._initKeyHandler = function () { var e = this; this.wwe.addKeyEventHandler(["TAB", "CTRL+]", "META+]"], (function (t) { var n; return e.wwe.getEditor().hasFormat("LI") && (t.preventDefault(), e.eventManager.emit("command", "Indent"), n = !1), n })), this.wwe.addKeyEventHandler(["SHIFT+TAB", "CTRL+[", "META+["], (function (t, n) { var r; if (e.wwe.getEditor().hasFormat("LI")) { t.preventDefault(); var i = St.children(St.closest(n.startContainer, "li"), "OL,UL"); e.eventManager.emit("command", "Outdent"), i.length && !i.previousSibling && e._removeBranchList(i), r = !1 } return r })), this.wwe.addKeyEventHandler("ENTER", (function (t, n) { n.collapsed && e.wwe.getEditor().hasFormat("LI") && e.wwe.defer((function () { var t = e.wwe.getRange(), n = St.parents(t.startContainer, "li")[0]; e._removeBranchListAll(n) })) })), this.wwe.addKeyEventHandler("BACK_SPACE", (function (t, n) { n.collapsed && e.wwe.getEditor().hasFormat("LI") && e.wwe.defer((function () { e._removeBranchListAll() })) })) }, t._findAndRemoveEmptyList = function () { St.findAll(this.wwe.getBody(), "OL,UL").forEach((function (e) { wn.test(e.innerHTML) || St.remove(e) })) }, t._removeBranchListAll = function (e) { var t = this; e = e || this.wwe.getBody(), St.findAll(e, "li > ul, li > ol").forEach((function (e) { e && !e.previousSibling && t._removeBranchList(e) })) }, t._removeBranchList = function (e) { for (var t = e; !t.previousSibling && t.parentElement.tagName.match(/UL|OL|LI/g);) t = t.parentElement; var n = St.children(t, "li")[0], r = St.unwrap(e); St.prepend(t, r), St.remove(n) }, t.convertToArbitraryNestingList = function (e) { for (var t = St.createElementWith("
    " + e + "
    "), n = t.querySelector("li > ul, li > ol"); null !== n;) { var r = n.parentNode; r.parentNode.insertBefore(n, r.nextElementSibling), n = t.querySelector("li > ul, li > ol") } return t.innerHTML }, t._convertFromArbitraryNestingList = function (e) { for (var t = St.createElementWith("
    " + e + "
    "), n = t.querySelector("ol > ol, ol > ul, ul > ol, ul > ul"); null !== n;) { for (var r = n.previousElementSibling; r && "LI" !== r.tagName;) r = r.previousElementSibling; r ? r.appendChild(n) : this._unwrap(n), n = t.querySelector("ol > ol, ol > ul, ul > ol, ul > ul") } return t.innerHTML }, t._unwrap = function (e) { for (var t = document.createDocumentFragment(); e.firstChild;) t.appendChild(e.firstChild); e.parentNode.replaceChild(t, e) }, t._insertDataToMarkPassForListInTable = function (e) { return e.replace(_n, (function (e, t, n, r) { return "" + t + n.replace(Tn, "<$1 data-tomark-pass $2>") + r })) }, t.getLinesOfSelection = function (e, t) { var n, r = [], i = !1, o = !0; St.isTextNode(e) && (e = St.parents(e, "DIV,LI")[0]); St.isTextNode(t) && (t = St.parents(t, "DIV,LI")[0]); for (var a = e; o && nt()(a, "DIV,LI"); a = n) r.push(a), a === t ? i = !0 : n = this._getNextLine(a, t), o = n && !i; return r }, t._getNextLine = function (e, t) { var n = e.nextElementSibling; return n ? nt()(n, "OL,UL") && (n = n.querySelector("li")) : n = e.parentNode.nextElementSibling, nt()(n, "DIV,LI") || n === t ? n : this._getNextLine(n) }, t.mergeList = function (e) { var t = e.parentNode, n = t.previousElementSibling, r = t.nextElementSibling; t.firstElementChild === e && n && nt()(n, "OL,UL") && (this._mergeList(t, n), t = n), t.lastElementChild === e && r && nt()(r, "OL,UL") && this._mergeList(r, t) }, t._mergeList = function (e, t) { var n = e.firstElementChild; if (t && nt()(t, "OL,UL")) { for (; n;) { var r = n.nextElementSibling; t.appendChild(n), n = r } e.parentNode.removeChild(e) } }, t.isAvailableMakeListInTable = function () { var e = this.wwe.componentManager.getManager("tableSelection").getSelectedCells(), t = this.wwe.getEditor(); return e && t.hasFormat("table") && !t.hasFormat("OL") && !t.hasFormat("UL") }, t._getParentNodeBeforeTD = function (e, t) { var n = St.getParentUntil(e, "TD"); if (!n) { var r = e.childNodes, i = r ? r.length : 0, o = t > 0 && t === i ? t - 1 : t; n = St.getChildNodeByOffset(e, o) } return n }, t._findLINodeInsideCell = function (e, t) { var n = null; e && St.isCellNode(e) && (e = e.firstChild); var r = St.getParentUntilBy(e, (function (e) { return e && St.isListNode(e) }), (function (e) { return e && St.isCellNode(e) })); if (r) n = r; else if ("LI" === e.nodeName) n = e; else if (St.isListNode(e)) { var i = e.childNodes.length; n = e.childNodes[t >= i ? i - 1 : t] } return n }, t._getFirstNodeInLineOfTable = function (e, t) { var n = this._findLINodeInsideCell(e, t); if (!n) for (var r = (n = this._getParentNodeBeforeTD(e, t)).previousSibling; r && "BR" !== r.nodeName && !St.isListNode(r);) r = (n = r).previousSibling; return n }, t._getLastNodeInLineOfTable = function (e, t) { var n = this._findLINodeInsideCell(e, t); if (!n) for (n = this._getParentNodeBeforeTD(e, t); n.nextSibling && "BR" !== n.nodeName && !St.isListNode(n);) n = n.nextSibling; return n }, t._isLastNodeInLineOfTable = function (e) { var t = e.nodeName; return "LI" === t || "BR" === t }, t._getNextNodeInLineOfTable = function (e) { var t = e.nextSibling; if ("LI" !== e.nodeName || t) St.isListNode(t) && (t = t.firstChild); else for (var n = e.parentNode; !St.isCellNode(n);) { if (n.nextSibling) { t = n.nextSibling; break } n = n.parentNode } return t }, t._getLinesOfSelectionInTable = function (e) { for (var t = e.startContainer, n = e.endContainer, r = e.startOffset, i = e.endOffset, o = this._getFirstNodeInLineOfTable(t, r), a = this._getLastNodeInLineOfTable(n, i), s = [], l = []; o;) { if (l.push(o), this._isLastNodeInLineOfTable(o) && (s.push(l), l = []), o === a) { l.length && s.push(l); break } o = this._getNextNodeInLineOfTable(o) } return s }, t._createListElement = function (e) { return document.createElement("TASK" === e ? "UL" : e) }, t._createListItemElement = function (e, t) { var n = document.createElement("li"); (e.forEach((function (e) { n.appendChild(e) })), "TASK" === t) && this.wwe.componentManager.getManager("task").formatTask(n); return n }, t._mergeListWithPreviousSibiling = function (e) { var t = e.previousSibling, n = e; return t && e.nodeName === t.nodeName && (this._mergeList(e, t), n = t), n }, t._mergeListWithNextSibiling = function (e) { var t = e.nextSibling; return t && e.nodeName === t.nodeName && this._mergeList(t, e), e }, t.createListInTable = function (e, t) { var n = this, r = this._getLinesOfSelectionInTable(e), i = r[r.length - 1], o = i[i.length - 1], a = o.nextSibling, s = o.parentNode, l = this._createListElement(t), c = l.nodeName, u = []; return r.forEach((function (e) { var r, i = e[0]; if ("LI" === i.nodeName) { var o = i.parentNode; if (r = i, o.nodeName !== c) { var a = o.childNodes; Qe()(a).forEach((function () { l.appendChild(o.firstChild) })), o.parentNode.replaceChild(l, o) } l = r.parentNode } else r = n._createListItemElement(e, t), l.appendChild(r); u.push(r) })), l.parentNode || s.insertBefore(l, a), l = this._mergeListWithPreviousSibiling(l), this._mergeListWithNextSibiling(l), u }, t.adjustRange = function (e, t, n, r, i) { var o = St.containsNode(i[0], e) ? e : i[0], a = St.containsNode(i[i.length - 1], t) ? t : i[i.length - 1], s = "TD" === e.nodeName ? 0 : n, l = "TD" === t.nodeName ? 0 : r; this.wwe.setSelectionByContainerAndOffset(o, s, a, l) }, e }(), xn = function () { function e(e) { this.wwe = e, this.eventManager = e.eventManager, this.name = "task", this._init() } var t = e.prototype; return t._init = function () { this._initKeyHandler(), this._initEvent(), this.wwe.getEditor().addEventListener("mousedown", (function (e) { var t = getComputedStyle(e.target, ":before"); e.target.hasAttribute("data-te-task") && St.isInsideButtonBox(t, e.offsetX, e.offsetY) && (e.preventDefault(), St.toggleClass(e.target, "checked")) })) }, t._initEvent = function () { var e = this; this.eventManager.listen("wysiwygSetValueAfter", (function () { e._removeTaskListClass() })) }, t._initKeyHandler = function () { var e = this; this.wwe.addKeyEventHandler("ENTER", (function (t, n) { e.isInTaskList(n) && e.wwe.defer((function () { var t = e.wwe.getRange(), n = St.closest(t.startContainer, "li"); n && m()(n, "checked") })) })) }, t.isInTaskList = function (e) { var t; (e || (e = this.wwe.getEditor().getSelection().cloneRange()), e.startContainer.nodeType === Node.ELEMENT_NODE && "LI" === e.startContainer.tagName) ? t = e.startContainer: t = St.parents(e.startContainer, "li")[0]; return !!t && et()(t, "task-list-item") }, t.unformatTask = function (e) { var t = St.closest(e, "li"); m()(t, "task-list-item"), m()(t, "checked"), t.removeAttribute("data-te-task"), t.getAttribute("class") || t.removeAttribute("class") }, t.formatTask = function (e) { var t = St.closest(e, "li"); p()(t, "task-list-item"), t.setAttribute("data-te-task", "") }, t._formatTaskIfNeed = function () { var e = this.wwe.getEditor().getSelection().cloneRange(); this.isInTaskList(e) && this.formatTask(e.startContainer) }, t._removeTaskListClass = function () { St.findAll(this.wwe.getBody(), ".task-list").forEach((function (e) { m()(e, "task-list") })) }, e }(), Sn = Zt.a.msie && 10 === Zt.a.version, Nn = Zt.a.msie && (10 === Zt.a.version || 11 === Zt.a.version), kn = Zt.a.msie ? "" : "
    "; function Ln(e, t) { for (var n = "<" + t + ">
    ", r = "", i = 0; i < e; i += 1) r += n; return r } var Mn = function () { function e(e) { this.wwe = e, this.eventManager = e.eventManager, this.name = "table", this._lastCellNode = null, this._init() } var t = e.prototype; return t._init = function () { this._initKeyHandler(), this._initEvent(), this.tableID = 0 }, t._initEvent = function () { var e = this; this.eventManager.listen("wysiwygRangeChangeAfter.table", (function () { var t = e.wwe.getEditor().getSelection(), n = e.wwe.isInTable(t); (e._unwrapBlockInTable(), e._completeTableIfNeed(), n) || e.wwe.componentManager.getManager("tableSelection").removeClassAttrbuteFromAllCellsIfNeed(); e._insertDefaultBlockBetweenTable() })), this.eventManager.listen("wysiwygSetValueAfter.table", (function () { e._unwrapBlockInTable(), e._insertDefaultBlockBetweenTable() })), this.eventManager.listen("wysiwygProcessHTMLText.table", (function (e) { return e.replace(/
    (<\/td>|<\/th>)/g, "$1") })), this.eventManager.listen("cut.table", (function () { var t = e.wwe.componentManager.getManager("tableSelection"), n = t.getSelectedCells(); n.length && n.forEach((function (e) { e.innerHTML = kn })), t.removeClassAttrbuteFromAllCellsIfNeed() })), this.eventManager.listen("copyBefore.table", (function (t) { var n = t.clipboardContainer; return e.updateTableHtmlOfClipboardIfNeed(n) })) }, t.updateTableHtmlOfClipboardIfNeed = function (e) { var t = this, n = this.wwe.componentManager.getManager("tableSelection"); if (n.getSelectedCells().length) { n.createRangeBySelectedCells(); var r = this.wwe.getEditor().getSelection().cloneContents(); Qe()(r.children).forEach((function (e) { if (t.isTableOrSubTableElement(e.nodeName)) if ("TABLE" === e.nodeName && e.querySelector("thead") && e.querySelector("tbody")) St.remove(e); else if (e.previousSibling && "TABLE" === e.previousSibling.nodeName) e.previousSibling.appendChild(e); else if (t._completeIncompleteTable(e), "TABLE" !== e.nodeName && "THEAD" !== e.nodeName) { var n = St.closest(e, "table").querySelector("thead"); St.remove(n) } })), e.appendChild(r), St.findAll(e, ".te-cell-selected").forEach((function (e) { m()(e, "te-cell-selected") })) } }, t.pasteTableData = function (e) { this._expandTableIfNeed(e), this._pasteDataIntoTable(e) }, t._initKeyHandler = function () { var e = this; this.keyEventHandlers = { DEFAULT: function (t, n, r) { var i = e.wwe.isInTable(n); i && !e._isModifierKey(r) ? (e._recordUndoStateIfNeed(n), e._removeContentsAndChangeSelectionIfNeed(n, r, t)) : !i && e._lastCellNode && e._recordUndoStateAndResetCellNode(n), i && !e._isModifierKeyPushed(t) && e.wwe.getEditor().modifyDocument((function () { e.wwe.componentManager.getManager("tableSelection").removeClassAttrbuteFromAllCellsIfNeed() })) }, ENTER: function (t, n) { var r; return e._isAfterTable(n) ? (t.preventDefault(), n.setStart(n.startContainer, n.startOffset - 1), e.wwe.breakToNewDefaultBlock(n), r = !1) : e._isBeforeTable(n) ? (t.preventDefault(), e.wwe.breakToNewDefaultBlock(n, "before"), r = !1) : e.wwe.isInTable(n) && (!e._isInList(n.startContainer) && e._isInStyledText(n) ? e.wwe.defer((function () { e._removeBRinStyleText() })) : e._isEmptyFirstLevelLI(n) && e.wwe.defer((function () { var t = e.wwe.getRange().cloneRange(), n = t.startContainer, r = document.createElement("br"); n.parentNode.replaceChild(r, n), t.setStartBefore(r), t.collapse(!0), e.wwe.getEditor().setSelection(t) })), e._appendBrIfTdOrThNotHaveAsLastChild(n), r = !1), r }, BACK_SPACE: function (t, n, r) { return e._handleBackspaceAndDeleteKeyEvent(t, n, r) }, DELETE: function (t, n, r) { return e._handleBackspaceAndDeleteKeyEvent(t, n, r) }, TAB: function () { return e._moveCursorTo("next", "cell") }, "SHIFT+TAB": function (t) { return e._moveCursorTo("previous", "cell", t) }, UP: function (t) { return e._moveCursorTo("previous", "row", t) }, DOWN: function (t) { return e._moveCursorTo("next", "row", t) } }, i()(this.keyEventHandlers, (function (t, n) { return e.wwe.addKeyEventHandler(n, t) })) }, t._isEmptyListItem = function (e) { var t = e.childNodes; return "LI" === e.nodeName && 1 === t.length && "BR" === t[0].nodeName }, t._isEmptyFirstLevelLI = function (e) { var t = e.collapsed, n = e.startContainer, r = e.startOffset; return t && 0 === r && this._isEmptyListItem(n) && St.isFirstLevelListItem(n) }, t._isInStyledText = function (e) { var t, n = e.startContainer; return t = St.isTextNode(n) ? n.parentNode : n, e.collapsed && St.isStyledNode(t) }, t._removeBRinStyleText = function () { var e, t = this.wwe.getRange(), n = t.startContainer, r = t.startOffset, i = (e = "TD" === n.nodeName ? St.getChildNodeByOffset(n, r - 1) : St.getParentUntil(n, "TD")).querySelector("br"); if (i) { var o = e, a = o.parentNode, s = o.nodeName; if ("CODE" !== s || i.previousSibling) if ("CODE" !== s || i.nextSibling) { var l = this._splitByBR(e, i); t.setStart(l, 0) } else a.insertBefore(i, e.nextSibling), t.setStart(a, St.getNodeOffsetOfParent(i) + 1); else a.insertBefore(i, e), t.setStart(e, 0); t.collapse(!0), this.wwe.getEditor().setSelection(t) } }, t._splitByBR = function (e, t) { var n = e.cloneNode(!0), r = document.createElement("br"), i = e.parentNode; St.removeNodesByDirection(e, t, !1), t.parentNode.removeChild(t); var o = n.querySelector("br"); St.removeNodesByDirection(n, o, !0), o.parentNode.removeChild(o), i.insertBefore(n, e.nextSibling), i.insertBefore(r, n); var a = St.getLeafNode(n); return St.getTextLength(a) || (a.textContent = "​"), a }, t._isBeforeTable = function (e) { return "TABLE" === St.getNodeName(St.getChildNodeByOffset(e.startContainer, e.startOffset)) }, t._isAfterTable = function (e) { var t = St.getPrevOffsetNodeUntil(e.startContainer, e.startOffset); return "TABLE" === St.getNodeName(t) && e.commonAncestorContainer === this.wwe.getBody() }, t._handleBackspaceAndDeleteKeyEvent = function (e, t, n) { var r = "BACK_SPACE" === n, i = this.wwe.componentManager.getManager("tableSelection").getSelectedCells(), o = !0; if (t.collapsed) { if (this.wwe.isInTable(t)) r ? this._tableHandlerOnBackspace(t, e) : this._tableHandlerOnDelete(t, e), this._removeContentsAndChangeSelectionIfNeed(t, n, e), o = !1; else if (!r && this._isBeforeTable(t) || r && this._isAfterTable(t)) { e.preventDefault(); var a = r ? t.startOffset - 1 : t.startOffset; this._removeTable(t, St.getChildNodeByOffset(t.startContainer, a)), o = !1 } } else if (this.wwe.isInTable(t)) { if (i.length > 0) this._removeContentsAndChangeSelectionIfNeed(t, n, e) && (e.preventDefault(), o = !1) } return o }, t._moveListItemToPreviousOfList = function (e, t) { var n = e.parentNode, r = e.firstChild, i = document.createDocumentFragment(); St.mergeNode(e, i), n.parentNode.insertBefore(i, n), t.setStart(r, 0), t.collapse(!0), this.wwe.getEditor().setSelection(t), n.hasChildNodes() || n.parentNode.removeChild(n) }, t._isInList = function (e) { return St.getParentUntilBy(e, (function (e) { return e && (St.isListNode(e) || "LI" === e.nodeName) }), (function (e) { return e && ("TD" === e.nodeName || "TH" === e.nodeName) })) }, t._findListItem = function (e) { return St.getParentUntilBy(e, (function (e) { return e && St.isListNode(e) }), (function (e) { return e && ("TD" === e.nodeName || "TH" === e.nodeName) })) }, t._tableHandlerOnBackspace = function (e, t) { var n = e.startContainer, r = e.startOffset, i = this._findListItem(n); if (i && 0 === r && St.isFirstListItem(i) && St.isFirstLevelListItem(i)) this.wwe.getEditor().saveUndoState(e), this._moveListItemToPreviousOfList(i, e), t.preventDefault(); else { var o = St.getPrevOffsetNodeUntil(n, r, "TR"); "BR" === St.getNodeName(o) && 1 !== o.parentNode.childNodes.length && (t.preventDefault(), St.remove(o)) } }, t._isDeletingBR = function (e) { var t = this._getCurrentNodeInCell(e), n = t && t.nextSibling; return "BR" === St.getNodeName(t) && !!n && "BR" === St.getNodeName(n) }, t._getCurrentNodeInCell = function (e) { var t, n = e.startContainer, r = e.startOffset; return "TD" === St.getNodeName(n) ? t = St.getChildNodeByOffset(n, r) : St.getParentUntil(n, "TD") && (t = n), t }, t._isEndOfList = function (e, t) { var n = t.startContainer, r = t.startOffset, i = !1; if (!e.nextSibling) if (e === n) { var o = St.getOffsetLength(e); "BR" === e.lastChild.nodeName && (o -= 1), i = o === r } else { var a = St.getParentUntil(n, "li") || n, s = St.getOffsetLength(n), l = e.lastChild; "BR" === l.nodeName && (l = l.previousSibling), i = l === a && s === r } return i }, t._getNextLineNode = function (e) { for (var t = document.createDocumentFragment(), n = St.getParentUntil(e, "TD").nextSibling; n;) { var r = n.nextSibling; if (t.appendChild(n), "BR" === n.nodeName) break; n = r } return t }, t._tableHandlerOnDelete = function (e, t) { var n = this._findListItem(e.startContainer); if (n && this._isEndOfList(n, e)) this.wwe.getEditor().saveUndoState(e), "BR" === n.lastChild.nodeName && n.removeChild(n.lastChild), St.mergeNode(this._getNextLineNode(n), n), t.preventDefault(); else if (this._isDeletingBR(e)) { var r = this._getCurrentNodeInCell(e); r.parentNode.removeChild(r.nextSibling), t.preventDefault() } }, t._appendBrIfTdOrThNotHaveAsLastChild = function (e) { var t, n = St.getNodeName(e.startContainer); if ("TD" === n || "TH" === n) t = e.startContainer; else { var r = St.parentsUntil(e.startContainer, "tr"); t = r[r.length - 1] } var i = St.getNodeName(t.lastChild); "BR" === i || "DIV" === i || "UL" === i || "OL" === i || Nn || St.append(t, "
    ") }, t._unwrapBlockInTable = function () { St.findAll(this.wwe.getBody(), "td div,th div,tr>br,td>br,th>br").forEach((function (e) { if ("BR" === St.getNodeName(e)) { var t = St.getNodeName(e.parentNode), n = /TD|TH/.test(t), r = 0 === e.parentNode.textContent.length, i = e.parentNode.lastChild === e; ("TR" === t || n && !r && i) && St.remove(e) } else St.unwrap(e) })) }, t._insertDefaultBlockBetweenTable = function () { St.findAll(this.wwe.getBody(), "table").forEach((function (e) { if (e.nextElementSibling && "TABLE" === e.nextElementSibling.nodeName) { var t = document.createElement("div"); t.appendChild(document.createElement("br")), St.insertAfter(t, e) } })) }, t._removeTable = function (e, t) { "TABLE" === t.tagName && (this.wwe.getEditor().saveUndoState(e), this.wwe.saveSelection(e), St.remove(t), this.wwe.restoreSavedSelection()) }, t._recordUndoStateIfNeed = function (e) { var t = St.getParentUntil(e.startContainer, "TR"); e.collapsed && t && this._lastCellNode !== t && (this.wwe.getEditor().saveUndoState(e), this._lastCellNode = t) }, t._recordUndoStateAndResetCellNode = function (e) { this.wwe.getEditor().saveUndoState(e), this.resetLastCellNode() }, t._pasteDataIntoTable = function (e) { var t, n, r, i, o = this.wwe.getEditor().getSelection().startContainer, a = this._getTableDataFromTable(e), s = "TD" === o.nodeName || "TH" === o.nodeName, l = Sn ? "" : "
    "; for (n = t = (t = s ? o : (t = St.getParentUntilBy(o, (function (e) { return e && ("TD" === e.nodeName || "TH" === e.nodeName) }), (function (e) { return !!St.closest(e, "table") }))) ? t.parentNode : null) || o.querySelector("th,td"); a.length;) { for (r = a.shift(); n && r.length;)(i = r.shift()).length ? n.textContent = i : n.innerHTML = l, n = St.getTableCellByDirection(n, "next"); t = n = St.getSiblingRowCellByDirection(t, "next", !1) } }, t._getTableDataFromTable = function (e) { var t = []; return St.findAll(e, "tr").forEach((function (e) { var n = []; Qe()(e.children).forEach((function (e) { n.push(e.textContent) })), n.length && t.push(n) })), t }, t._removeTableContents = function (e) { this.wwe.getEditor().saveUndoState(), Qe()(e).forEach((function (e) { var t = Sn ? "" : "
    "; e.innerHTML = t })) }, t.wrapDanglingTableCellsIntoTrIfNeed = function (e) { var t, n = St.children(e, "td,th"); if (n.length) { var r = document.createElement("tr"); Qe()(n).forEach((function (e) { St.append(r, e) })), t = r } return t }, t.wrapTrsIntoTbodyIfNeed = function (e) { var t, n = St.children(e, "tr"), r = []; if (Qe()(n).forEach((function (e) { r = r.concat(e.querySelectorAll("th")) })), r.length && Qe()(r).forEach((function (e) { var t = document.createElement("td"); t.innerHTML = e.innerHTML, St.insertBefore(e, t), St.remove(e) })), n.length) { var i = document.createElement("tbody"); Qe()(n).forEach((function (e) { St.append(i, e) })), t = i } return t }, t.wrapTheadAndTbodyIntoTableIfNeed = function (e) { var t, n = St.children(e, "thead"), r = St.children(e, "tbody"), i = document.createElement("table"); return !r.length && n.length ? (St.append(i, n[0]), St.append(i, this._createTheadOrTboday("tbody")), t = i) : r.length && !n.length ? (St.append(i, this._createTheadOrTboday("thead")), St.append(i, r[0]), t = i) : r.length && n.length && (St.append(i, n[0]), St.append(i, r[0]), t = i), t }, t.isTableOrSubTableElement = function (e) { return "TABLE" === e || "TBODY" === e || "THEAD" === e || "TR" === e || "TD" === e }, t._createTheadOrTboday = function (e) { var t = document.createElement(e), n = document.createElement("tr"); return t.appendChild(n), t }, t._stuffTableCellsIntoIncompleteRow = function (e, t) { Qe()(e).forEach((function (e) { for (var n = e.querySelectorAll("th,td"), r = "THEAD" === St.getNodeName(e.parentNode) ? "th" : "td", i = n.length; i < t; i += 1) St.append(e, Ln(1, r)) })) }, t.prepareToTableCellStuffing = function (e) { var t = e[0].querySelectorAll("th,td").length, n = !1; return Qe()(e).forEach((function (e) { var r = e.querySelectorAll("th,td").length; t !== r && (n = !0, t < r && (t = r)) })), { maximumCellLength: t, needTableCellStuffingAid: n } }, t._addTbodyOrTheadIfNeed = function (e) { var t = !e.querySelector("thead"), n = !e.querySelector("tbody"); t ? St.prepend(e, "") : n && St.append(e, "") }, t.tableCellAppendAidForTableElement = function (e) { this._addTbodyOrTheadIfNeed(e), this._addTrIntoContainerIfNeed(e); var t = e.querySelectorAll("tr"), n = this.prepareToTableCellStuffing(t), r = n.maximumCellLength; n.needTableCellStuffingAid && this._stuffTableCellsIntoIncompleteRow(t, r) }, t._generateTheadAndTbodyFromTbody = function (e) { var t = document.createElement("tr"), n = document.createElement("thead"); return St.append(t, Ln(e.querySelector("tr > td").length, "th")), St.append(n, t), { thead: n, tbody: e } }, t._generateTheadAndTbodyFromThead = function (e) { var t = document.createElement("tr"), n = document.createElement("tbody"); return St.append(t, Ln(e.querySelectorAll("th").length, "td")), St.append(n, t), { thead: e, tbody: n } }, t._generateTheadAndTbodyFromTr = function (e) { var t, n, r = document.createElement("thead"), i = document.createElement("tbody"); return "TH" === e.children[0].tagName ? (t = e, n = St.createElementWith("" + Ln(e.querySelectorAll("th").length, "td") + "")) : (t = St.createElementWith("" + Ln(e.querySelectorAll("td").length, "th") + ""), n = e), St.append(r, t), St.append(i, n), { thead: r, tbody: i } }, t._completeIncompleteTable = function (e) { var t, n, r = e.tagName; "TABLE" === r ? t = e : (t = document.createElement("table"), e.parentNode.insertBefore(t, e.nextSibling), "TBODY" === r ? n = this._generateTheadAndTbodyFromTbody(e) : "THEAD" === r ? n = this._generateTheadAndTbodyFromThead(e) : "TR" === r && (n = this._generateTheadAndTbodyFromTr(e)), t.appendChild(n.thead), t.appendChild(n.tbody)), this._removeEmptyRows(t), this.tableCellAppendAidForTableElement(t) }, t._removeEmptyRows = function (e) { St.findAll(e, "tr").forEach((function (e) { e.cells.length || e.parentNode.removeChild(e) })) }, t._completeTableIfNeed = function () { var e = this, t = this.wwe.getEditor().getBody(); Qe()(t.children).forEach((function (t) { e.isTableOrSubTableElement(t.nodeName) && ("TABLE" !== t.nodeName || t.querySelector("tbody") ? e._completeIncompleteTable(t) : St.remove(t)) })) }, t.resetLastCellNode = function () { this._lastCellNode = null }, t.setLastCellNode = function (e) { this._lastCellNode = e }, t._isModifierKey = function (e) { return /((META|SHIFT|ALT|CONTROL)\+?)/g.test(e) }, t._isModifierKeyPushed = function (e) { return e.metaKey || e.ctrlKey || e.altKey || e.shiftKey }, t._addTrIntoContainerIfNeed = function (e) { Qe()(e.children).forEach((function (e) { 0 === e.querySelectorAll("tr").length && St.append(e, "") })) }, t._expandTableIfNeed = function (e) { var t = this.wwe.getEditor().getSelection().cloneRange(), n = St.parents(t.startContainer, "table")[0], r = this._getColumnAndRowDifference(e, t); r.column < 0 && this._appendCellForAllRow(n, r.column), r.row < 0 && this._appendRow(n, r.row) }, t._getColumnAndRowDifference = function (e, t) { var n = this._getTableDataFromTable(e), r = n.length, i = n[0].length, o = St.closest(t.startContainer, "th,td"), a = o.parentNode, s = St.getNodeOffsetOfParent(o), l = St.getNodeOffsetOfParent(o.parentNode), c = St.parents(a, "table")[0], u = c.querySelector("tr").children.length, d = c.querySelectorAll("tr").length; return !!St.parents(a, "tbody").length && (l += 1), { row: d - (l + r), column: u - (s + i) } }, t._appendCellForAllRow = function (e, t) { var n = Sn ? "" : "
    "; St.findAll(e, "tr").forEach((function (e, r) { for (var i, o = t; o < 0; o += 1) i = 0 === r ? "th" : "td", St.append(e, "<" + i + ">" + n + "") })) }, t._appendRow = function (e, t) { var n = e.querySelectorAll("tr"), r = n[n.length - 1].cloneNode(!0), i = Sn ? "" : "
    "; for (St.findAll(r, "td").forEach((function (e) { e.innerHTML = i })); t < 0; t += 1) St.append(e.querySelector("tbody"), r.cloneNode(!0)) }, t._changeSelectionToTargetCell = function (e, t, n, r) { var i, o = "next" === n, a = "row" === r; (a ? i = St.getSiblingRowCellByDirection(e, n, !1) : (i = St.getTableCellByDirection(e, n)) || (i = St.getSiblingRowCellByDirection(e, n, !0)), i) ? (a && !o ? this._moveToCursorEndOfCell(i, t) : t.setStart(i, 0), t.collapse(!0)) : (i = St.parents(e, "table")[0], o ? t.setStart(i.nextElementSibling, 0) : i.previousElementSibling && "TABLE" !== i.previousElementSibling.nodeName ? t.setStart(i.previousElementSibling, 1) : t.setStartBefore(i), t.collapse(!0)) }, t._moveToCursorEndOfCell = function (e, t) { var n; St.isListNode(e.lastChild) && (n = St.getLastNodeBy(e.lastChild, (function (e) { return "LI" !== e.nodeName || null !== e.nextSibling }))); var r = St.getLastNodeBy(n || e, (function (e) { return !St.isTextNode(e) })), i = r || n || e, o = r ? r.length : i.childNodes.length - 1; t.setStart(i, o) }, t._moveCursorTo = function (e, t, n) { var r, i = this.wwe.getEditor(), o = i.getSelection().cloneRange(), a = St.closest(o.startContainer, "td,th"); if (o.collapsed && this.wwe.isInTable(o) && a) { if ("row" === t && !this._isMovedCursorToRow(o, e)) return r; "previous" !== e && "row" !== t || _()(n) || n.preventDefault(), this._changeSelectionToTargetCell(a, o, e, t), i.setSelection(o), r = !1 } return r }, t._isMovedCursorToRow = function (e, t) { var n = e.startContainer; return this._isInList(n) ? this._isMovedCursorFromListToRow(n, t) : this._isMovedCursorFromTextToRow(e, t) }, t._isMovedCursorFromListToRow = function (e, t) { var n = t + "Sibling", r = this._findListItem(e), i = St.getParentNodeBy(r, (function (e, t) { var r = null === t[n] && null === e[n]; return !St.isCellNode(e) && r })), o = St.isListNode(i) && null === i[n]; return St.isCellNode(i.parentNode) && o }, t._isMovedCursorFromTextToRow = function (e, t) { var n = e.startContainer, r = e.startOffset, i = St.isCellNode(n) ? n.childNodes[r] : n, o = St.getParentNodeBy(i, (function (e) { return !St.isCellNode(e) && !St.isTextNode(e) })), a = St.getSiblingNodeBy(o, t, (function (e) { return null !== e && "BR" !== e.nodeName })); return a && null === a[t + "Sibling"] }, t._removeContentsAndChangeSelectionIfNeed = function (e, t, n) { var r = t.length <= 1, i = "BACK_SPACE" === t || "DELETE" === t, o = this.wwe.componentManager.getManager("tableSelection").getSelectedCells(), a = o[0], s = !1; return (r || i) && !this._isModifierKeyPushed(n) && o.length && (i && this._recordUndoStateIfNeed(e), this._removeTableContents(o), this._lastCellNode = a, e.setStart(a, 0), e.collapse(!0), this.wwe.getEditor().setSelection(e), s = !0), s }, t.getTableIDClassName = function () { var e = "te-content-table-" + this.tableID; return this.tableID += 1, e }, t.destroy = function () { var e = this; this.eventManager.removeEventHandler("wysiwygRangeChangeAfter.table"), this.eventManager.removeEventHandler("wysiwygSetValueAfter.table"), this.eventManager.removeEventHandler("wysiwygProcessHTMLText.table"), this.eventManager.removeEventHandler("cut.table"), this.eventManager.removeEventHandler("copyBefore.table"), i()(this.keyEventHandlers, (function (t, n) { return e.wwe.removeKeyEventHandler(n, t) })) }, e }(), An = function () { function e(e) { this.wwe = e, this.eventManager = e.eventManager, this.name = "tableSelection", this._init() } var t = e.prototype; return t._init = function () { this._initEvent(), Zt.a.firefox && (document.execCommand("enableObjectResizing", !1, "false"), document.execCommand("enableInlineTableEditing", !1, "false")) }, t._initEvent = function () { var e, t, n, r = this; this._tableSelectionTimer = null, this._removeSelectionTimer = null, this._isSelectionStarted = !1; var i = function (i) { t = St.closest(i.data.target, "[contenteditable=true] td,th"); var o = r.wwe.getEditor().getSelection(), a = St.parents(t, "[contenteditable=true] table"), s = e === t, l = r._isTextSelect(o, s) && !et()(e, "te-cell-selected"); r._isSelectionStarted && a && !l && (window.getSelection().removeAllRanges(), Zt.a.firefox && !r._removeSelectionTimer && (r._removeSelectionTimer = setInterval((function () { window.getSelection().removeAllRanges() }), 10)), e && t && (r.highlightTableCellsBy(e, t), n = t)) }, o = function () { r._isSelectionStarted && (r._isSelectionStarted = !1, r.eventManager.removeEventHandler("mouseover.tableSelection"), r.eventManager.removeEventHandler("mouseup.tableSelection")) }, a = function (i) { t = St.closest(i.data.target, "[contenteditable=true] td,th"); var a = r.wwe.getEditor().getSelection(), s = e === t, l = r._isTextSelect(a, s) && !et()(e, "te-cell-selected"); r._clearTableSelectionTimerIfNeed(), r._isSelectionStarted && (l || r._isListSelect(a) ? r.removeClassAttrbuteFromAllCellsIfNeed() : (r.wwe.componentManager.getManager("table").resetLastCellNode(), t = t || n, (a = r.wwe.getEditor().getSelection()).setStart(t, 0), Zt.a.msie ? a.setEnd(t, 1) : (a.setEnd(t, 0), a.collapse(!1)), r.wwe.getEditor().setSelection(a)), r.onDragEnd && r.onDragEnd()), o() }; this.eventManager.listen("mousedown.tableSelection", (function (n) { var s = !!(e = St.closest(n.data.target, "[contenteditable=true] td,th")) && et()(e, "te-cell-selected"); t = null, !s || s && 2 !== n.data.button ? (r.removeClassAttrbuteFromAllCellsIfNeed(), e && (r.setTableSelectionTimerIfNeed(e), r.eventManager.listen("mouseover.tableSelection", i), r.eventManager.listen("mouseup.tableSelection", a), r.onDragStart && r.onDragStart(e))) : 2 === n.data.button && o() })), this.eventManager.listen("copyBefore.tableSelection", o), this.eventManager.listen("pasteBefore.tableSelection", o) }, t._isTextSelect = function (e, t) { return /TD|TH|TEXT/i.test(e.commonAncestorContainer.nodeName) && t }, t._isListSelect = function (e) { return /UL|OL|LI/i.test(e.commonAncestorContainer.nodeName) }, t.setTableSelectionTimerIfNeed = function (e) { St.parents(e, "[contenteditable=true] table").length && (this._isSelectionStarted = !0) }, t._clearTableSelectionTimerIfNeed = function () { clearTimeout(this._tableSelectionTimer), Zt.a.firefox && this._removeSelectionTimer && (clearTimeout(this._removeSelectionTimer), this._removeSelectionTimer = null) }, t._reArrangeSelectionIfneed = function (e, t) { var n = St.parents(e, "[contenteditable=true] table").length, r = St.parents(t, "[contenteditable=true] table").length, i = !r && n; if (r && !n) e = St.parents(t, "[contenteditable=true] table")[0].querySelectorAll("th")[0]; else if (i) { var o = St.parents(e, "[contenteditable=true] table")[0].querySelectorAll("td"); t = o[o.length - 1] } return { startContainer: e, endContainer: t } }, t._applySelectionDirection = function (e, t) { var n = St.getNodeOffsetOfParent, r = e.startContainer, i = e.endContainer, o = n(St.closest(r, "[contenteditable=true] tr")) - n(St.closest(i, "[contenteditable=true] tr")), a = n(r) - n(i), s = o < 0; return 0 === o ? a > 0 ? (t.setStart(i, 0), t.setEnd(r, 1)) : (t.setStart(r, 0), t.setEnd(i, 1)) : s ? (t.setStart(r, 0), t.setEnd(i, 1)) : (t.setStart(i, 0), t.setEnd(r, 1)), t }, t.getSelectionRangeFromTable = function (e, t) { var n, r, i = St.getNodeOffsetOfParent, o = i(e.parentNode), a = i(t.parentNode), s = i(e), l = i(t), c = St.getParentUntil(e, "TABLE"), u = St.getParentUntil(t, "TABLE"), d = "TBODY" === St.getNodeName(c) && "THEAD" === St.getNodeName(u), h = c !== u, f = !!St.parents(e, "tbody").length && !!St.parents(t, "tbody").length, p = { row: o, cell: s }, g = { row: a, cell: l }; return d ? p.row += 1 : h ? g.row += 1 : f && (p.row += 1, g.row += 1), o > a || o === a && s > l ? (n = g, r = p) : (n = p, r = g), { from: n, to: r } }, t.highlightTableCellsBy = function (e, t) { var n = St.findAll(St.parents(e, "[contenteditable=true] table")[0], "tr"), r = this.getSelectionRangeFromTable(e, t), i = r.from.row, o = r.from.cell, a = r.to.row, s = r.to.cell; n.forEach((function (e, t) { St.findAll(e, "td,th").forEach((function (e, n) { t === i && n < o || t === a && n > s || t < i || t > a ? m()(e, "te-cell-selected") : p()(e, "te-cell-selected") })) })) }, t.removeClassAttrbuteFromAllCellsIfNeed = function () { St.findAll(this.wwe.getBody(), "td.te-cell-selected,th.te-cell-selected").forEach((function (e) { m()(e, "te-cell-selected"), e.getAttribute("class") || e.removeAttribute("class") })) }, t.getSelectedCells = function () { return this.wwe.getBody().querySelectorAll(".te-cell-selected") }, t.createRangeBySelectedCells = function () { var e = this.wwe.getEditor(), t = e.getSelection().cloneRange(), n = this.getSelectedCells(), r = n[0], i = n[n.length - 1]; n.length && this.wwe.isInTable(t) && (t.setStart(r, 0), t.setEnd(i, i.childNodes.length), e.setSelection(t)) }, t.styleToSelectedCells = function (e, t) { this.createRangeBySelectedCells(), e(this.wwe.getEditor(), t) }, t.destroy = function () { this.eventManager.removeEventHandler("mousedown.tableSelection"), this.eventManager.removeEventHandler("mouseover.tableSelection"), this.eventManager.removeEventHandler("mouseup.tableSelection"), this.eventManager.removeEventHandler("copyBefore.tableSelection"), this.eventManager.removeEventHandler("pasteBefore.tableSelection") }, e }(), Bn = function () { function e(e) { this.wwe = e, this.eventManager = e.eventManager, this.name = "hr", this._init() } var t = e.prototype; return t._init = function () { this._initEvent() }, t._initEvent = function () { var e = this; this.eventManager.listen("wysiwygSetValueAfter", (function () { e._insertEmptyLineIfNeed(), e._changeHRForWysiwyg() })) }, t._insertEmptyLineIfNeed = function () { var e = this.wwe.getBody(), t = e.firstChild, n = e.lastChild; t && "HR" === t.nodeName ? e.insertBefore(St.createEmptyLine(), t) : n && "HR" === n.nodeName && e.appendChild(St.createEmptyLine()) }, t._changeHRForWysiwyg = function () { var e = this.wwe.getBody(); St.findAll(e, "hr").forEach((function (e) { e.parentNode.replaceChild(St.createHorizontalRule(), e) })) }, e }(), On = function () { function e(e) { this.wwe = e, this.eventManager = e.eventManager, this.name = "p", this._initEvent() } var t = e.prototype; return t._initEvent = function () { var e = this; this.eventManager.listen("wysiwygSetValueBefore", (function (t) { return e._splitPtagContentLines(t) })), this.eventManager.listen("wysiwygSetValueAfter", (function () { e._ensurePtagContentWrappedWithDiv(), e._unwrapPtags() })) }, t._splitPtagContentLines = function (e) { if (e) { var t = St.createElementWith("
    " + e + "
    "); St.findAll(t, "p").forEach((function (e) { var t = e.attributes, n = e.nextElementSibling, r = e.innerHTML.split(/
    /gi), i = r.length - 1, o = ""; o = r.map((function (e, n) { if (n > 0 && n < i && (e = e || "
    "), e) { var r = document.createElement("div"); return Object.keys(t).forEach((function (e) { var n = t[e], i = n.name, o = n.value; r.setAttribute(i, o) })), r.innerHTML = e, r.outerHTML } return "" })), (n && "P" === n.nodeName || "false" === e.getAttribute("contenteditable")) && o.push("

    "), St.replaceWith(e, o.join("")) })), e = t.innerHTML } return e }, t._ensurePtagContentWrappedWithDiv = function () { var e = this; St.findAll(this.wwe.getBody(), "p").forEach((function (t) { t.querySelectorAll("div").length || St.wrapInner(t, "div"), e._findNextParagraph(t, "p") && St.append(t, "

    ") })) }, t._unwrapPtags = function () { St.findAll(this.wwe.getBody(), "div").forEach((function (e) { var t = e.parentNode; "P" === t.tagName && St.unwrap(t) })) }, t._findNextParagraph = function (e, t) { var n = e.nextElementSibling; return t ? n && nt()(n, t) ? n : null : n }, e }(), Dn = /h[\d]/i, In = Zt.a.msie && 10 === Zt.a.version, Rn = function () { function e(e) { this.wwe = e, this.eventManager = e.eventManager, this.name = "heading", this._init() } var t = e.prototype; return t._init = function () { this._initEvent(), this._initKeyHandler() }, t._initEvent = function () { var e = this; this.eventManager.listen("wysiwygSetValueAfter", (function () { e._wrapDefaultBlockToHeadingInner() })) }, t._initKeyHandler = function () { var e = this; this.wwe.addKeyEventHandler("ENTER", (function (t, n) { return !e.wwe.hasFormatWithRx(Dn) || (e._onEnter(t, n), !1) })), this.wwe.addKeyEventHandler("BACK_SPACE", (function (t, n) { return !e.wwe.hasFormatWithRx(Dn) || (e._addBrToEmptyBlock(n), e._removePrevTopNodeIfNeed(t, n), !1) })) }, t._wrapDefaultBlockToHeadingInner = function () { St.findAll(this.wwe.getBody(), "h1, h2, h3, h4, h5, h6").forEach((function (e) { !St.children(e, "div, p").length && St.wrapInner(e, "div") })) }, t._unwrapHeading = function () { this.wwe.unwrapBlockTag((function (e) { return Dn.test(e) })) }, t._onEnter = function (e, t) { var n = this; t.startOffset > 0 ? this.wwe.defer((function (e) { n._unwrapHeading(), e.getEditor().removeLastUndoStack() })) : (e.preventDefault(), this._insertEmptyBlockToPrevious(t)) }, t._insertEmptyBlockToPrevious = function (e) { this.wwe.getEditor().saveUndoState(e); var t = St.createElementWith("

    "); St.insertBefore(t, St.getParentUntil(e.startContainer, this.wwe.getBody())) }, t._removePrevTopNodeIfNeed = function (e, t) { var n = !1; if (t.collapsed && 0 === t.startOffset) { var r = t.startContainer, i = St.getTopPrevNodeUnder(r, this.wwe.getBody()), o = i && 0 === i.textContent.length, a = this.wwe.getEditor(); 0 === r.textContent.length ? n = this._removeHedingAndChangeSelection(e, t, i) : o && (e.preventDefault(), a.saveUndoState(t), St.remove(i), n = !0) } return n }, t._getHeadingElement = function (e) { return Dn.test(St.getNodeName(e)) ? e : St.parents(e, "h1,h2,h3,h4,h5,h6")[0] }, t._addBrToEmptyBlock = function (e) { var t = e.collapsed, n = e.startOffset, r = e.startContainer; if (t && 1 === n) { var i = this._getHeadingElement(r), o = St.children(i.firstChild, "br"); if (!In && !o.length) { var a = document.createElement("br"); r.parentNode.appendChild(a) } } }, t._removeHedingAndChangeSelection = function (e, t, n) { var r = t.startContainer, i = this.wwe.getEditor(), o = this.wwe.getBody(), a = this._getHeadingElement(r), s = n, l = 1; (e.defaultPrevented || (e.preventDefault(), i.saveUndoState(t)), St.remove(a), n) || (s = St.children(o, "div")[0], l = 0); return t.setStart(s, l), t.collapse(!0), i.setSelection(t), !0 }, e }(), Pn = n(25), Hn = n.n(Pn), Fn = Zt.a.msie && 10 === Zt.a.version, Un = Fn ? "" : "
    ", Wn = { "&": "&", "<": "<", ">": ">" }, qn = /\u200B/g; function zn(e) { return e ? e.replace(/[<>&]/g, (function (e) { return Wn[e] || e })) : "" } var jn = function () { function e(e) { this.wwe = e, this.eventManager = e.eventManager, this.name = "codeblock", this._init() } var t = e.prototype; return t._init = function () { this._initKeyHandler(), this._initEvent() }, t._initKeyHandler = function () { var e = this; this._keyEventHandlers = { BACK_SPACE: this._onBackspaceKeyEventHandler.bind(this), ENTER: function (t, n) { !e.wwe.isInTable(n) && e.wwe.getEditor().hasFormat("CODE") && e.wwe.defer((function () { var t = e.wwe.getRange().startContainer, n = e._getCodeNode(t); n && !St.getTextLength(n) && n.parentNode.removeChild(n) })) } }, i()(this._keyEventHandlers, (function (t, n) { return e.wwe.addKeyEventHandler(n, t) })) }, t._getCodeNode = function (e) { var t; return "CODE" === e.nodeName ? t = e : "CODE" === e.parentNode.nodeName && (t = e.parentNode), t }, t._initEvent = function () { var e = this; this.eventManager.listen("wysiwygSetValueAfter.codeblock", (function () { e.modifyCodeBlockForWysiwyg() })), this.eventManager.listen("wysiwygProcessHTMLText.codeblock", (function (t) { return e._changePreToPreCode(t) })) }, t.prepareToPasteOnCodeblock = function (e) { var t = this.wwe.getEditor().getDocument().createDocumentFragment(), n = this.convertNodesToText(e); return n = n.replace(/\n$/, ""), t.appendChild(document.createTextNode(n)), t }, t.convertNodesToText = function (e) { for (var t = "", n = e.shift(); Hn()(n);) { n.childNodes && St.isBlockNode(n) ? t += this.convertNodesToText(Qe()(n.childNodes)) : "BR" === n.nodeName ? t += "\n" : t += n.textContent, n = e.shift() } return t }, t._copyCodeblockTypeFromRangeCodeblock = function (e, t) { var n = St.getParentUntil(t.commonAncestorContainer, this.wwe.getBody()); if ("PRE" === St.getNodeName(n)) { var r = n.attributes; i()(r, (function (t) { e.setAttribute(t.name, t.value) })) } return e }, t._changePreToPreCode = function (e) { return e.replace(/((.|\n)*?)<\/pre>/g, (function (e, t, n) { return "
    " + n + "
    " })) }, t.modifyCodeBlockForWysiwyg = function (e) { e || (e = this.wwe.getBody()), St.findAll(e, "pre").forEach((function (e) { var t, n, r = e.querySelector("code"); r && (t = r.getAttribute("data-language"), n = r.getAttribute("data-backticks")), e.children.length > 1 && Qe()(e.children).forEach((function (e) { "DIV" !== e.nodeName && "P" !== e.nodeName || e.querySelectorAll("br").length || (e.innerHTML += e.innerHTML + "\n") })); var i = e.querySelectorAll("br"); i.length && St.replaceWith(i, "\n"); var o = e.textContent.replace(/\s+$/, ""); St.empty(e), e.innerHTML = o ? zn(o) : Un, t && (e.setAttribute("data-language", t), p()(e, "lang-" + t)), n && e.setAttribute("data-backticks", n), e.setAttribute("data-te-codeblock", "") })) }, t._onBackspaceKeyEventHandler = function (e, t) { var n = !0, r = this.wwe.getEditor(), i = t.commonAncestorContainer; if (this._isCodeBlockFirstLine(t) && !this._isFrontCodeblock(t)) this._removeCodeblockFirstLine(i), t.collapse(!0), n = !1; else if (t.collapsed && this._isEmptyLine(i) && this._isBetweenSameCodeblocks(i)) { var o = i.previousSibling, a = i.nextSibling, s = o.textContent.length; r.saveUndoState(t), i.parentNode.removeChild(i), this._mergeCodeblocks(o, a), t.setStart(o.childNodes[0], s), t.collapse(!0), n = !1 } return n || (r.setSelection(t), e.preventDefault()), n }, t._isEmptyLine = function (e) { var t = e.nodeName, n = e.childNodes, r = Fn ? "" === e.textContent : 1 === n.length && "BR" === n[0].nodeName; return "DIV" === t && r }, t._isBetweenSameCodeblocks = function (e) { var t = e.previousSibling, n = e.nextSibling; return "PRE" === St.getNodeName(t) && "PRE" === St.getNodeName(n) && t.getAttribute("data-language") === n.getAttribute("data-language") }, t._mergeCodeblocks = function (e, t) { var n = t.textContent; e.childNodes[0].textContent += "\n" + n, t.parentNode.removeChild(t) }, t._isCodeBlockFirstLine = function (e) { return this.isInCodeBlock(e) && e.collapsed && 0 === e.startOffset }, t._isFrontCodeblock = function (e) { var t = St.getParentUntil(e.startContainer, this.wwe.getEditor().getRoot()).previousSibling; return t && "PRE" === t.nodeName }, t._removeCodeblockFirstLine = function (e) { var t = this.wwe.getEditor(), n = "PRE" === e.nodeName ? e : e.parentNode, r = n.textContent.replace(qn, ""); t.modifyBlocks((function () { var e = t.getDocument().createDocumentFragment(), i = r.split("\n"), o = document.createElement("div"), a = i.shift(); if (o.innerHTML = "" + zn(a) + Un, e.appendChild(o), i.length) { var s = n.cloneNode(); s.textContent = i.join("\n"), e.appendChild(s) } return e })) }, t.isInCodeBlock = function (e) { var t; return t = e.collapsed ? e.startContainer : e.commonAncestorContainer, !!St.closest(t, "pre") }, t.destroy = function () { var e = this; this.eventManager.removeEventHandler("wysiwygSetValueAfter.codeblock"), this.eventManager.removeEventHandler("wysiwygProcessHTMLText.codeblock"), i()(this._keyEventHandlers, (function (t, n) { return e.wwe.removeKeyEventHandler(n, t) })) }, e }(), Vn = n(27), Kn = n.n(Vn); var Gn = /\b(H[\d]|LI|P|BLOCKQUOTE|TD)\b/, $n = /Trident\/[456]\./.test(navigator.userAgent), Yn = function (e) { var t, n; function r() { for (var t, n = arguments.length, r = new Array(n), i = 0; i < n; i++) r[i] = arguments[i]; return (t = e.call.apply(e, [this].concat(r)) || this)._decorateHandlerToCancelable("copy"), t._decorateHandlerToCancelable($n ? "beforecut" : "cut"), t._decorateHandlerToCancelable($n ? "beforepaste" : "paste"), t.getBody = function () { return t.body = t.body || t.getRoot(), t.body }, t } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i._decorateHandlerToCancelable = function (e) { var t = this._events[e]; if (t.length > 1) throw new Error("too many" + e + "handlers in squire"); var n = t[0].bind(this); t[0] = function (e) { e.defaultPrevented || e.squirePrevented || n(e) } }, i.changeBlockFormat = function (e, t) { var n = this; this.modifyBlocks((function (r) { var i, o, a, s, l, c, u; if (r.childNodes.length ? i = r.childNodes.item(0) : (i = n.createDefaultBlock(), r.appendChild(i)), e) { for (; i.firstChild;) i = i.firstChild; for (u = function (e) { s.appendChild(e) }; i !== r;) { if (l = i.tagName, xe()(e) ? e(l) : l === e) { s = i.childNodes.item(0), (!St.isElemNode(s) || i.childNodes.length > 1) && (s = n.createDefaultBlock(), Qe()(i.childNodes).forEach(u), (c = s.lastChild) && "BR" === St.getNodeName(c) && s.removeChild(c)), a = t ? n.createElement(t, [s]) : s, (o = n.getDocument().createDocumentFragment()).appendChild(a), r = o; break } i = i.parentNode } } return o && e || !t || "DIV" !== St.getNodeName(r.childNodes[0]) || (r = n.createElement(t, [r.childNodes[0]])), r })) }, i.changeBlockFormatTo = function (e) { this.changeBlockFormat((function (e) { return Gn.test(e) }), e) }, i.getCaretPosition = function () { return this.getCursorPosition() }, i.replaceSelection = function (e, t) { t && this.setSelection(t), this._ignoreChange = !0, this.insertHTML(e) }, i.replaceRelativeOffset = function (e, t, n) { var r = this.getSelection().cloneRange(); this._replaceRelativeOffsetOfSelection(e, t, n, r) }, i._replaceRelativeOffsetOfSelection = function (e, t, n, r) { var i, o, a, s = r.endContainer, l = r.endOffset; "TEXT" !== St.getNodeName(s) && (s = this._getClosestTextNode(s, l)) && (l = St.isTextNode(s) ? s.nodeValue.length : s.textContent.length), s ? (i = this.getSelectionInfoByOffset(s, l + t), r.setStart(i.element, i.offset), a = l + (t + n), o = this.getSelectionInfoByOffset(s, a), r.setEnd(o.element, o.offset), this.replaceSelection(e, r)) : this.replaceSelection(e) }, i._getClosestTextNode = function (e, t) { var n = St.getChildNodeByOffset(e, t - 1); return "TEXT" !== St.getNodeName(n) && (n = n.previousSibling), n }, i.getSelectionInfoByOffset = function (e, t) { var n, r, i, o, a = t >= 0 ? "next" : "previous", s = Math.abs(t), l = n; for (n = "next" === a ? e : e.previousSibling, i = s, o = 0; n && !(s <= (o += r = St.isTextNode(n) ? n.nodeValue.length : n.textContent.length));) i -= r, St.getTextLength(n) > 0 && (l = n), n = n[a + "Sibling"]; return n || (n = l, i = St.getTextLength(n)), "previous" === a && (i = St.getTextLength(n) - i), { element: n, offset: i } }, i.getSelectionPosition = function (e, t, n) { var r = this.createElement("INPUT"), i = e.cloneRange(), o = this.getSelectionInfoByOffset(e.endContainer, e.endOffset + (n || 0)); i.setStart(i.startContainer, i.startOffset), i.setEnd(o.element, o.offset), this._ignoreChange = !0, this.insertElement(r, i); var a = St.getOffset(r); return "over" !== t && (a.top += r.offsetHeight), r.parentNode.removeChild(r), e.setStart(e.endContainer, e.endOffset), e.collapse(!0), this.setSelection(e), a }, i.removeLastUndoStack = function () { this._undoStack.length && (this._undoStackLength -= 1, this._undoIndex -= 1, this._undoStack.pop(), this._isInUndoState = !1) }, i.replaceParent = function (e, t, n) { var r = St.closest(e, t, this.getBody()); r && (St.wrapInner(r, n), St.unwrap(r)) }, i.preserveLastLine = function () { var e = this.getBody().children, t = e[e.length - 1]; t && "DIV" !== St.getNodeName(t) && (this._ignoreChange = !0, St.insertAfter(this.createDefaultBlock(), t)) }, i.scrollTop = function (e) { return _()(e) || (this.getBody().scrollTop = e), this.getBody().scrollTop }, i.isIgnoreChange = function () { return this._ignoreChange }, i.focus = function () { Kn.a.prototype.focus.call(this) }, i.blockCommandShortcuts = function () { var e = this, t = x ? "meta" : "ctrl"; ["b", "i", "u", "shift-7", "shift-5", "shift-6", "shift-8", "shift-9", "[", "]", "d"].forEach((function (n) { e.setKeyHandler(t + "-" + n, (function (e, t) { t.preventDefault() })) })) }, r }(Kn.a), Xn = Zt.a.msie && 11 === Zt.a.version, Zn = -1 !== navigator.appVersion.indexOf("Win") && Zt.a.chrome, Qn = /Windows (NT )?10/g.test(navigator.appVersion), Jn = Xn || Zn && !Qn, er = function () { function e(e, t) { this._wwe = e, Jn && (this.isComposition = !1, this._initCompositionEvent()), this.setRange(t || this._wwe.getRange()) } var t = e.prototype; return t._initCompositionEvent = function () { var e = this; this._wwe.getEditor().addEventListener("compositionstart", (function () { e.isComposition = !0 })), this._wwe.getEditor().addEventListener("compositionend", (function () { e.isComposition = !1 })) }, t.setRange = function (e) { this._range && this._range.detach(), this._range = e }, t.expandStartOffset = function () { var e = this._range; St.isTextNode(e.startContainer) && e.startOffset > 0 && e.setStart(e.startContainer, e.startOffset - 1) }, t.expandEndOffset = function () { var e = this._range; St.isTextNode(e.endContainer) && e.endOffset < e.endContainer.nodeValue.length && e.setEnd(e.endContainer, e.endOffset + 1) }, t.setEndBeforeRange = function (e) { var t = e.startOffset; this.isComposition && (t += 1), this._range.setEnd(e.startContainer, t) }, t.getTextContent = function () { return this._range.cloneContents().textContent }, t.replaceContent = function (e) { this._wwe.getEditor().setSelection(this._range), this._wwe.getEditor().insertHTML(e), this._wwe.isInTable(this._range) && this._wwe.eventManager.emit("wysiwygRangeChangeAfter", this._wwe), this._range = this._wwe.getRange() }, t.deleteContent = function () { this._wwe.getEditor().setSelection(this._range), this._wwe.getEditor().insertHTML(""), this._range = this._wwe.getRange() }, t.peekStartBeforeOffset = function (e) { var t = this._range.cloneRange(); return t.setStart(t.startContainer, Math.max(t.startOffset - e, 0)), t.setEnd(this._range.startContainer, this._range.startOffset), t.cloneContents().textContent }, e }(); var tr = function (e) { var t, n; function r(t) { var n, r = t.eventManager, i = t.container, o = t.wysiwygEditor; return (n = e.call(this, { eventManager: r, container: i, attachedSelector: "pre" }) || this)._wysiwygEditor = o, n._popupCodeBlockLanguages = null, n._initDOM(), n._initDOMEvent(), n } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i._initDOM = function () { var e = this; p()(this.el, "code-block-header"), this._languageLabel = St.createElementWith("text"), St.append(this.el, this._languageLabel), this._buttonOpenModalEditor = St.createElementWith(''), St.append(this.el, this._buttonOpenModalEditor), this._eventManager.emit("removeEditor", (function () { Ge()(e._buttonOpenModalEditor, "click"), e._buttonOpenModalEditor = null })) }, i._initDOMEvent = function () { var e = this; Ve()(this._buttonOpenModalEditor, "click", (function () { return e._openPopupCodeBlockEditor() })) }, i._openPopupCodeBlockEditor = function () { this._eventManager.emit("openPopupCodeBlockEditor", this.getAttachedElement()) }, i._updateLanguage = function () { var e = this.getAttachedElement(), t = e ? e.getAttribute("data-language") : null; this._languageLabel.textContent = t || "text" }, i.syncLayout = function () { var e = this.getAttachedElement(), t = St.getOffset(e, ".te-editor").top; h()(this.el, { top: t + "px", right: "26px", width: "250px", height: "30px" }) }, i.onShow = function () { var t = this; e.prototype.onShow.call(this), this._onAttachedElementChange = function () { return t._updateLanguage() }, this._eventManager.listen("changeLanguage", this._onAttachedElementChange), this._updateLanguage() }, i.onHide = function () { this._eventManager.removeEventHandler("changeLanguage", this._onAttachedElementChange), e.prototype.onHide.call(this) }, r }(function () { function e(e) { var t = e.eventManager, n = e.container, r = e.attachedSelector; this._eventManager = t, this._attachedSelector = "[contenteditable=true] " + r, this._container = n, this._attachedElement = null, this.active = !1, this._createElement(), this._initEvent() } var t = e.prototype; return t._createElement = function () { this.el = St.createElementWith('
    '), h()(this.el, { position: "absolute", display: "none", zIndex: 1 }), St.append(this._container, this.el) }, t._initEvent = function () { var e = this; this._eventManager.listen("change", this._onChange.bind(this)), this._eventManager.listen("mouseover", this._onMouseOver.bind(this)), this._eventManager.listen("focus", (function () { e.setVisibility(!1) })), this._eventManager.listen("mousedown", (function () { e.setVisibility(!1) })) }, t._onChange = function () { this._attachedElement && St.isContain(document.body, this._attachedElement) ? this.syncLayout() : this.setVisibility(!1) }, t._onMouseOver = function (e) { var t = e.data.target, n = St.closest(t, this._attachedSelector); n ? (this._attachedElement = n, this.setVisibility(!0)) : St.closest(t, this.el) ? this.setVisibility(!0) : this.active || this.setVisibility(!1) }, t.syncLayout = function () { var e = St.getOffset(this._attachedElement), t = St.getOuterWidth(this._attachedElement), n = St.getOuterHeight(this._attachedElement); St.setOffset(this.el, e), h()(this.el, { width: t + "px" }), h()(this.el, { height: n + "px" }) }, t.getAttachedElement = function () { return this._attachedElement || null }, t.getVisibility = function () { return "block" === this.el.style.display }, t.setVisibility = function (e) { e && this._attachedElement ? this.getVisibility() || (h()(this.el, { display: "block" }), this.syncLayout(), this.onShow()) : e || this.getVisibility() && (h()(this.el, { display: "none" }), this.onHide()) }, t.onShow = function () {}, t.onHide = function () { this.active = !1, this._attachedElement = null }, e }()), nr = J.getSharedInstance(), rr = /<([a-z]+|h\d)>(
    |
    )<\/\1>/gi, ir = /(?:
    |
    )<\/(.+?)>/gi, or = /\b(H[\d]|LI|P|BLOCKQUOTE|TD|PRE)\b/, ar = /]*)>[\u0020]/g, sr = /[\u0020]<\/span>/g, lr = /^(TABLE|H[1-6])$/, cr = "undefined" != typeof MutationObserver, ur = function () { function e(e, t, n) { var r = this; void 0 === n && (n = {}), this.componentManager = new fe(this), this.eventManager = t, this.editorContainerEl = e, this._height = 0, this._silentChange = !1, this._keyEventHandlers = {}, this._managers = {}, this._linkAttribute = n.linkAttribute || {}, this._sanitizer = n.sanitizer, this._initEvent(), this._initDefaultKeyEventHandler(), this.debouncedPostProcessForChange = Jt()((function () { return r.postProcessForChange() }), 0) } var t = e.prototype; return t.init = function () { var e = document.createElement("div"); this.editorContainerEl.appendChild(e), this.editor = new Yn(e, { blockTag: "DIV", leafNodeNames: { HR: !1 }, allowedBlocks: this._sanitizer && this._sanitizer === mn ? [] : ["details", "summary"] }), this.editor.blockCommandShortcuts(), this._clipboardManager = new bn(this), this._initSquireEvent(), this._clipboardManager.init(), p()(this.getBody(), "tui-editor-contents"), h()(this.editorContainerEl, "position", "relative"), this._togglePlaceholder(), this.codeBlockGadget = new tr({ eventManager: this.eventManager, container: this.editorContainerEl, wysiwygEditor: this }) }, t._initEvent = function () { var e = this; this.eventManager.listen("wysiwygKeyEvent", (function (t) { return e._runKeyEventHandlers(t.data, t.keyMap) })), this.eventManager.listen("wysiwygRangeChangeAfter", (function () { return e.scrollIntoCursor() })), this.eventManager.listen("contentChangedFromWysiwyg", (function () { e._togglePlaceholder() })) }, t.addKeyEventHandler = function (e, t) { var n = this; t || (t = e, e = "DEFAULT"), Yt()(e) || (e = [e]), e.forEach((function (e) { n._keyEventHandlers[e] || (n._keyEventHandlers[e] = []), n._keyEventHandlers[e].push(t) })) }, t.removeKeyEventHandler = function (e, t) { t || (t = e, e = "DEFAULT"); var n = this._keyEventHandlers[e]; n && (this._keyEventHandlers[e] = n.filter((function (e) { return e !== t }))) }, t._runKeyEventHandlers = function (e, t) { var n, r, i = this.getRange(); (n = this._keyEventHandlers.DEFAULT) && Gt()(n, (function (n) { return r = n(e, i, t) })), (n = this._keyEventHandlers[t]) && !1 !== r && Gt()(n, (function (n) { return n(e, i, t) })) }, t._initSquireEvent = function () { var e = this, t = this.getEditor(), n = !1; t.addEventListener("copy", (function (t) { e.eventManager.emit("copy", { source: "wysiwyg", data: t }), Jt()((function () { e.isEditorValid() && e.eventManager.emit("copyAfter", { source: "wysiwyg", data: t }) }))() })), t.addEventListener(Zt.a.msie ? "beforecut" : "cut", (function (t) { e.eventManager.emit("cut", { source: "wysiwyg", data: t }), Jt()((function () { e.isEditorValid() && e.eventManager.emit("cutAfter", { source: "wysiwyg", data: t }) }))() })), t.addEventListener(Zt.a.msie ? "beforepaste" : "paste", (function (t) { e.eventManager.emit("paste", { source: "wysiwyg", data: t }) })), t.addEventListener("dragover", (function (e) { return e.preventDefault(), !1 })), t.addEventListener("drop", (function (t) { return t.preventDefault(), e.eventManager.emit("drop", { source: "wysiwyg", data: t }), !1 })), t.addEventListener("input", Jt()((function () { if (e.isEditorValid()) { if (e._silentChange) e._silentChange = !1; else { var t = { source: "wysiwyg" }; e.eventManager.emit("changeFromWysiwyg", t), e.eventManager.emit("change", t), e.eventManager.emit("contentChangedFromWysiwyg", e) } e.getEditor().preserveLastLine() } }), 0)), t.addEventListener("keydown", (function (t) { e.getEditor().getSelection().collapsed || (n = !0), e.eventManager.emit("keydown", { source: "wysiwyg", data: t }), e._onKeyDown(t) })), Zt.a.firefox && (t.addEventListener("keypress", (function (t) { var r = t.keyCode; 13 !== r && 9 !== r || (e.getEditor().getSelection().collapsed || (n = !0), e.eventManager.emit("keydown", { source: "wysiwyg", data: t }), e._onKeyDown(t)) })), t.addEventListener("keyup", (function () { var t = e.getRange(); if (St.isTextNode(t.commonAncestorContainer) && St.isTextNode(t.commonAncestorContainer.previousSibling)) { var n = t.commonAncestorContainer.previousSibling.length, r = t.commonAncestorContainer; t.commonAncestorContainer.previousSibling.appendData(t.commonAncestorContainer.data), t.setStart(t.commonAncestorContainer.previousSibling, n + t.startOffset), t.collapse(!0), St.remove(r), e.setRange(t), t.detach() } }))), t.addEventListener("keyup", (function (t) { n && (e.debouncedPostProcessForChange(), n = !1), e.eventManager.emit("keyup", { source: "wysiwyg", data: t }) })), Ve()(this.editorContainerEl, "scroll", (function (t) { e.eventManager.emit("scroll", { source: "wysiwyg", data: t }) })), t.addEventListener("click", (function (t) { e.eventManager.emit("click", { source: "wysiwyg", data: t }) })), t.addEventListener("mousedown", (function (t) { e.eventManager.emit("mousedown", { source: "wysiwyg", data: t }) })), t.addEventListener("mouseover", (function (t) { e.eventManager.emit("mouseover", { source: "wysiwyg", data: t }) })), t.addEventListener("mouseout", (function (t) { e.eventManager.emit("mouseout", { source: "wysiwyg", data: t }) })), t.addEventListener("mouseup", (function (t) { e.eventManager.emit("mouseup", { source: "wysiwyg", data: t }) })), t.addEventListener("contextmenu", (function (t) { e.eventManager.emit("contextmenu", { source: "wysiwyg", data: t }) })), t.addEventListener("focus", (function () { e.eventManager.emit("focus", { source: "wysiwyg" }) })), t.addEventListener("blur", (function () { e.fixIMERange(), e.eventManager.emit("blur", { source: "wysiwyg" }) })), t.addEventListener("pathChange", (function (t) { var n = { strong: /(^B>|>B$|>B>|^B$|STRONG)/.test(t.path), emph: /(>I|>EM|^I$|^EM$)/.test(t.path), strike: /(^S>|>S$|>S>|^S$|DEL)/.test(t.path), code: /CODE/.test(t.path), codeBlock: /PRE/.test(t.path), blockQuote: /BLOCKQUOTE/.test(t.path), table: /TABLE/.test(t.path), heading: /H[1-6]/.test(t.path), list: /UL>LI(?!.task-list-item)/.test(t.path), orderedList: /OL>LI(?!.task-list-item)/.test(t.path), taskList: /[UL|OL]>LI.task-list-item/.test(t.path), source: "wysiwyg" }; e.eventManager.emit("stateChange", n) })), t.addEventListener("willPaste", (function (t) { t.fragment && e.eventManager.emit("willPaste", { source: "wysiwyg", data: t }) })) }, t._togglePlaceholder = function () { var e = this.getEditor(); e.modifyDocument((function () { var t = e.getRoot(); t.textContent || t.childNodes.length > 1 ? t.classList.remove("tui-editor-contents-placeholder") : t.classList.add("tui-editor-contents-placeholder") })) }, t._onKeyDown = function (e) { var t = nr.convert(e); e.keyCode && (this.eventManager.emit("keyMap", { source: "wysiwyg", keyMap: t, data: e }), e.defaultPrevented || this.eventManager.emit("wysiwygKeyEvent", { keyMap: t, data: e })) }, t._initDefaultKeyEventHandler = function () { var e = this; this.addKeyEventHandler("ENTER", (function (t, n) { e._isInOrphanText(n) && e.defer((function () { e._wrapDefaultBlockToOrphanTexts(), e.breakToNewDefaultBlock(n, "before") })), e.defer((function () { return e.scrollIntoCursor() })) })), this.addKeyEventHandler("TAB", (function (t) { var n = e.getEditor(), r = n.getSelection(), i = r.collapsed && e._isCursorNotInRestrictedAreaOfTabAction(n), o = !r.collapsed && St.isTextNode(r.commonAncestorContainer); return t.preventDefault(), !i && !o || (n.insertPlainText(" "), !1) })), this.addKeyEventHandler("BACK_SPACE", (function (t, n, r) { return e._handleRemoveKeyEvent(t, n, r) })), this.addKeyEventHandler("DELETE", (function (t, n, r) { return e._handleRemoveKeyEvent(t, n, r) })) }, t._handleRemoveKeyEvent = function (e, t, n) { var r = this.getEditor(); if (this._isStartHeadingOrTableAndContainsThem(t)) { var i = "BACK_SPACE" === n ? "backspace" : "delete"; return r.removeAllFormatting(), r._keyHandlers[i](r, e, r.getSelection()), r.removeLastUndoStack(), !1 } return !0 }, t._isStartHeadingOrTableAndContainsThem = function (e) { var t = e.startContainer, n = e.startOffset, r = e.commonAncestorContainer, i = e.collapsed, o = this.getEditor().getRoot(), a = !1; return i || r !== o || (t === o ? a = lr.test(St.getChildNodeByOffset(t, n).nodeName) : 0 === n && (a = lr.test(St.getParentUntil(t, o).nodeName))), a }, t._wrapDefaultBlockToOrphanTexts = function () { var e = Qe()(this.getBody().childNodes).filter((function (e) { return St.isTextNode(e) })); St.getAllTextNode(this.getBody()), e.forEach((function (e) { e.nextSibling && "BR" === e.nextSibling.tagName && St.remove(e.nextSibling), St.wrap(e, document.createElement("div")) })) }, t._isInOrphanText = function (e) { return e.startContainer.nodeType === Node.TEXT_NODE && e.startContainer.parentNode === this.getBody() }, t._wrapDefaultBlockTo = function (e) { this.saveSelection(e), this._joinSplitedTextNodes(), this.restoreSavedSelection(); var t = (e = this.getRange()).startContainer, n = e.startOffset, r = this.getEditor().createDefaultBlock([e.startContainer]), i = St.getChildNodeByOffset(e.startContainer, e.startOffset); i ? e.setStartBefore(i) : e.selectNodeContents(e.startContainer), e.collapse(!0), e.insertNode(r), e.setStart(t, n), e.collapse(!0), this.setRange(e) }, t._joinSplitedTextNodes = function () { var e, t, n = []; Qe()(this.getBody().childNodes).filter((function (e) { return St.isTextNode(e) })).forEach((function (r) { e === r.previousSibling ? (t.nodeValue += r.nodeValue, n.push(r)) : t = r, e = r })), St.remove(n) }, t.saveSelection = function (e) { e || (e = this.getRange()), this.getEditor()._saveRangeToBookmark(e) }, t.setSelectionByContainerAndOffset = function (e, t, n, r) { var i = this.getEditor(), o = i.getSelection(); return o.setStart(e, t), o.setEnd(n, r), i.setSelection(o), o }, t.restoreSavedSelection = function () { this.setRange(this.getEditor()._getRangeAndRemoveBookmark()) }, t.reset = function () { this.setValue("") }, t.changeBlockFormatTo = function (e) { this.getEditor().changeBlockFormatTo(e), this.eventManager.emit("wysiwygRangeChangeAfter", this) }, t.makeEmptyBlockCurrentSelection = function () { var e = this; this.getEditor().modifyBlocks((function (t) { return t.textContent || (t = e.getEditor().createDefaultBlock()), t })) }, t.focus = function () { var e = this.scrollTop(); this.editor.focus(), e !== this.scrollTop() && this.scrollTop(e) }, t.blur = function () { this.editor.blur() }, t.remove = function () { Ge()(this.editorContainerEl, "scroll"), this.getEditor().destroy(), this.editor = null, this.body = null, this.eventManager = null }, t.setHeight = function (e) { this._height = e, h()(this.editorContainerEl, { overflow: "auto", height: "100%" }), h()(this.editorContainerEl.parentNode, { height: l()(e) ? e + "px" : e }); var t = this.editorContainerEl.style, n = this.getBody().style, r = parseInt(t.paddingTop, 10) - parseInt(t.paddingBottom, 10), i = parseInt(n.marginTop, 10) - parseInt(n.marginBottom, 10); h()(this.getBody(), { minHeight: e - i - r + "px" }) }, t.setMinHeight = function (e) { var t = this.getBody(); h()(t, "minHeight", e + "px") }, t.setPlaceholder = function (e) { e && this.getEditor().getRoot().setAttribute("data-placeholder", e) }, t.getLinkAttribute = function () { return this._linkAttribute }, t.setValue = function (e, t) { void 0 === t && (t = !0), e = this.eventManager.emitReduce("wysiwygSetValueBefore", e), this.editor.setHTML(e), this.eventManager.emit("wysiwygSetValueAfter", this), this.eventManager.emit("contentChangedFromWysiwyg", this), t && this.moveCursorToEnd(), this.getEditor().preserveLastLine(), this.getEditor().removeLastUndoStack(), this.getEditor().saveUndoState() }, t.insertText = function (e) { this.editor.insertPlainText(e) }, t.getValue = function () { this._prepareGetHTML(); var e = this.editor.getHTML(); return e = (e = (e = (e = (e = (e = e.replace(rr, (function (e, t) { return "li" === t ? e : "td" === t || "th" === t ? "<" + t + ">" : "
    " }))).replace(ar, " ")).replace(sr, " ")).replace(ir, "")).replace(/]*>/g, "")).replace(/<\/div>/g, "
    "), e = this.eventManager.emitReduce("wysiwygProcessHTMLText", e) }, t._prepareGetHTML = function () { var e = this; this.getEditor().modifyDocument((function () { e._joinSplitedTextNodes(), e.eventManager.emit("wysiwygGetValueBefore", e) })) }, t.postProcessForChange = function () { var e = this; this.isEditorValid() && this.getEditor().modifyDocument((function () { e.eventManager.emit("wysiwygRangeChangeAfter", e) })) }, t.readySilentChange = function () { cr && !this.getEditor().isIgnoreChange() && (this._silentChange = !0) }, t.getEditor = function () { return this.editor }, t.replaceSelection = function (e, t) { this.getEditor().replaceSelection(e, t) }, t.replaceRelativeOffset = function (e, t, n) { this.getEditor().replaceRelativeOffset(e, t, n) }, t.addWidget = function (e, t, n, r) { var i = this.getEditor().getSelectionPosition(e, n, r), o = St.getOffset(this.editorContainerEl); this.editorContainerEl.appendChild(t), h()(t, { position: "absolute", top: i.top - o.top + "px", left: i.left - o.left + "px" }) }, t.getBody = function () { return this.getEditor().getBody() }, t.hasFormatWithRx = function (e) { return this.getEditor().getPath().match(e) }, t.breakToNewDefaultBlock = function (e, t) { var n = this.editor.createDefaultBlock(), r = St.getChildNodeByOffset(e.startContainer, e.startOffset) || St.getChildNodeByOffset(e.startContainer, e.startOffset - 1), i = St.getParentUntil(r, this.getBody()); "before" === t ? St.insertBefore(n, i) : St.insertAfter(n, i), e.setStart(n, 0), e.collapse(!0), this.setRange(e) }, t.replaceContentText = function (e, t, n) { var r = e.innerHTML; e.innerHTML = r.replace(t, n) }, t.unwrapBlockTag = function (e) { e || (e = function (e) { return or.test(e) }), this.getEditor().changeBlockFormat(e), this.eventManager.emit("wysiwygRangeChangeAfter", this) }, t.scrollIntoCursor = function () { var e = this.scrollTop(), t = this.getEditor().getCursorPosition(), n = t.top, r = t.height, i = this.editorContainerEl.getBoundingClientRect(), o = i.top, a = n - o, s = n + r - (o + i.height); a < 0 ? this.scrollTop(e + a) : s > 0 && this.scrollTop(Math.ceil(e + s)) }, t.moveCursorToEnd = function () { this.getEditor().moveCursorToEnd(), this.scrollIntoCursor(), this._correctRangeAfterMoveCursor("end") }, t.moveCursorToStart = function () { this.getEditor().moveCursorToStart(), this.scrollTop(0) }, t.scrollTop = function (e) { return _()(e) || (this.editorContainerEl.scrollTop = e), this.editorContainerEl.scrollTop }, t._correctRangeAfterMoveCursor = function (e) { var t = this.getRange(), n = this.getBody(); if ("start" === e) for (; n.firstChild;) n = n.firstChild; else for (; n.lastChild;) n = n.lastChild; "BR" === n.tagName ? t.setStartBefore(n) : t.setStartAfter(n), t.collapse(!0), this.setRange(t) }, t.getRange = function () { return this.getEditor().getSelection().cloneRange() }, t.getIMERange = function () { var e, t = getSelection(); return t && t.rangeCount && (e = t.getRangeAt(0).cloneRange()), e }, t.fixIMERange = function () { var e = this.getIMERange(); if (e) { var t = St.getParentUntil(e.commonAncestorContainer, this.editorContainerEl); !(!t || !t.parentNode) && this.setRange(e) } }, t.setRange = function (e) { this.getEditor().setSelection(e) }, t.isInTable = function (e) { var t = e.collapsed ? e.startContainer : e.commonAncestorContainer; return !!St.closest(t, "[contenteditable=true] table") }, t.getTextObject = function (e) { return new er(this, e) }, t.defer = function (e, t) { var n = this; setTimeout((function () { n.isEditorValid() && e(n) }), t || 0) }, t.isEditorValid = function () { return this.getEditor() && St.isContain(document.body, this.editorContainerEl) }, t._isCursorNotInRestrictedAreaOfTabAction = function (e) { return !e.hasFormat("li") && !e.hasFormat("blockquote") && !e.hasFormat("table") }, t.getSanitizer = function () { return this._sanitizer }, e.factory = function (t, n, r) { var i = new e(t, n, r); return i.init(), i.componentManager.addManager(Cn), i.componentManager.addManager(En), i.componentManager.addManager(xn), i.componentManager.addManager(An), i.componentManager.addManager(Mn), i.componentManager.addManager(Bn), i.componentManager.addManager(On), i.componentManager.addManager(Rn), i.componentManager.addManager(jn), i }, e }(), dr = ['
    ', '
    ', '
    ', '
    ', '
    ', "
    ", '
    ', '
    ', "
    ", "
    "].join(""), hr = function () { function e(e, t) { this.el = e.el, this.height = e.height, this.type = e.initialEditType, this.eventManager = t, this.init(), this._initEvent() } var t = e.prototype; return t.init = function () { this._renderLayout(), this._initMarkdownAndPreviewSection(), this._initWysiwygSection() }, t._initEvent = function () { this.eventManager.listen("hide", this.hide.bind(this)), this.eventManager.listen("show", this.show.bind(this)) }, t._renderLayout = function () { h()(this.el, { boxSizing: "border-box" }), this.containerEl = St.createElementWith(dr, this.el) }, t.switchToWYSIWYG = function () { m()(this.containerEl, "te-md-mode"), p()(this.containerEl, "te-ww-mode") }, t.switchToMarkdown = function () { m()(this.containerEl, "te-ww-mode"), p()(this.containerEl, "te-md-mode") }, t._initMarkdownAndPreviewSection = function () { this.mdEditorContainerEl = this.containerEl.querySelector(".te-md-container .te-editor"), this.previewEl = this.containerEl.querySelector(".te-md-container .te-preview") }, t._initWysiwygSection = function () { this.wwEditorContainerEl = this.containerEl.querySelector(".te-ww-container .te-editor") }, t._verticalSplitStyle = function () { var e = this.containerEl.querySelector(".te-md-container"); m()(e, "te-preview-style-tab"), p()(e, "te-preview-style-vertical") }, t._tabStyle = function () { var e = this.containerEl.querySelector(".te-md-container"); m()(e, "te-preview-style-vertical"), p()(e, "te-preview-style-tab") }, t.changePreviewStyle = function (e) { "tab" === e ? this._tabStyle() : "vertical" === e && this._verticalSplitStyle() }, t.hide = function () { p()(this.el.querySelector(".tui-editor"), "te-hide") }, t.show = function () { m()(this.el.querySelector(".tui-editor"), "te-hide") }, t.remove = function () { St.remove(this.el.querySelector(".tui-editor")) }, t.getEditorEl = function () { return this.containerEl }, t.getPreviewEl = function () { return this.previewEl }, t.getMdEditorContainerEl = function () { return this.mdEditorContainerEl }, t.getWwEditorContainerEl = function () { return this.wwEditorContainerEl }, e }(), fr = n(32), pr = n.n(fr), gr = n(33), mr = n.n(gr), vr = n(12), yr = n.n(vr), br = function () { function e() { this._keys = [], this._values = [] } var t = e.prototype; return t._getKeyIndex = function (e) { return yr()(e, this._keys) }, t.get = function (e) { return this._values[this._getKeyIndex(e)] }, t.set = function (e, t) { var n = this._getKeyIndex(e); n > -1 ? this._values[n] = t : (this._keys.push(e), this._values.push(t)) }, t.has = function (e) { return this._getKeyIndex(e) > -1 }, t.delete = function (e) { var t = this._getKeyIndex(e); t > -1 && (this._keys.splice(t, 1), this._values.splice(t, 1)) }, t.forEach = function (e, t) { var n = this; void 0 === t && (t = this), Gt()(this._values, (function (r, i) { r && n._keys[i] && e.call(t, r, n._keys[i], n) })) }, e }(), Cr = ["previewBeforeHook", "previewRenderAfter", "previewNeedsRefresh", "addImageBlobHook", "setMarkdownAfter", "contentChangedFromWysiwyg", "changeFromWysiwyg", "contentChangedFromMarkdown", "changeFromMarkdown", "change", "changeModeToWysiwyg", "changeModeToMarkdown", "changeModeBefore", "changeMode", "changePreviewStyle", "changePreviewTabPreview", "changePreviewTabWrite", "openPopupAddLink", "openPopupAddImage", "openPopupAddTable", "openPopupTableUtils", "openHeadingSelect", "openPopupCodeBlockLanguages", "openPopupCodeBlockEditor", "openDropdownToolbar", "closePopupCodeBlockLanguages", "closePopupCodeBlockEditor", "closeAllPopup", "command", "addCommandBefore", "htmlUpdate", "markdownUpdate", "renderedHtmlUpdated", "removeEditor", "convertorAfterMarkdownToHtmlConverted", "convertorBeforeHtmlToMarkdownConverted", "convertorAfterHtmlToMarkdownConverted", "stateChange", "wysiwygSetValueAfter", "wysiwygSetValueBefore", "wysiwygGetValueBefore", "wysiwygProcessHTMLText", "wysiwygRangeChangeAfter", "wysiwygKeyEvent", "scroll", "click", "mousedown", "mouseover", "mouseout", "mouseup", "contextmenu", "keydown", "keyup", "keyMap", "load", "focus", "blur", "paste", "pasteBefore", "willPaste", "copy", "copyBefore", "copyAfter", "cut", "cutAfter", "drop", "show", "hide", "changeLanguage", "cursorActivity", "requireScrollSync", "requireScrollIntoView", "setCodeBlockLanguages"], wr = function () { function e() { this.events = new br, this.TYPE = new mr.a(Cr) } var t = e.prototype; return t.listen = function (e, t) { var n = this._getTypeInfo(e), r = this.events.get(n.type) || []; if (!this._hasEventType(n.type)) throw new Error("There is no event type " + n.type); n.namespace && (t.namespace = n.namespace), r.push(t), this.events.set(n.type, r) }, t.emit = function () { for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++) t[n] = arguments[n]; var r, o = t.shift(), a = this._getTypeInfo(o), s = this.events.get(a.type); return s && i()(s, (function (e) { var n = e.apply(void 0, t); _()(n) || (r = r || []).push(n) })), r }, t.emitReduce = function () { for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++) t[n] = arguments[n]; var r = t.shift(), o = this.events.get(r); return o && i()(o, (function (e) { var n = e.apply(void 0, t); pr()(n) || (t[0] = n) })), t[0] }, t._getTypeInfo = function (e) { var t = e.split("."); return { type: t[0], namespace: t[1] } }, t._hasEventType = function (e) { return !_()(this.TYPE[this._getTypeInfo(e).type]) }, t.addEventType = function (e) { if (this._hasEventType(e)) throw new Error("There is already have event type " + e); this.TYPE.set(e) }, t.removeEventHandler = function (e, t) { var n = this, r = this._getTypeInfo(e), i = r.type, o = r.namespace; i && t ? this._removeEventHandlerWithHandler(i, t) : i && !o ? this.events.delete(i) : !i && o ? this.events.forEach((function (e, t) { n._removeEventHandlerWithTypeInfo(t, o) })) : i && o && this._removeEventHandlerWithTypeInfo(i, o) }, t._removeEventHandlerWithHandler = function (e, t) { var n = this.events.get(e) || [], r = n.indexOf(t); r >= 0 && n.splice(r, 1) }, t._removeEventHandlerWithTypeInfo = function (e, t) { var n = [], r = this.events.get(e); r && (r.map((function (e) { return e.namespace !== t && n.push(e), null })), this.events.set(e, n)) }, e }(), _r = function () { function e(e, t, n) { this.name = e, this.type = t, n && this.setKeyMap(n) } var t = e.prototype; return t.getName = function () { return this.name }, t.getType = function () { return this.type }, t.isMDType = function () { return this.type === e.TYPE.MD }, t.isWWType = function () { return this.type === e.TYPE.WW }, t.isGlobalType = function () { return this.type === e.TYPE.GB }, t.setKeyMap = function (e, t) { this.keyMap = [e, t] }, e }(); _r.factory = function (e, t) { var n; "markdown" === e ? n = _r.TYPE.MD : "wysiwyg" === e ? n = _r.TYPE.WW : "global" === e && (n = _r.TYPE.GB); var r = new _r(t.name, n); return u()(r, t), r }, _r.TYPE = { MD: 0, WW: 1, GB: 2 }; var Tr = _r, Er = x ? 1 : 0, xr = function () { function e(e, t) { void 0 === t && (t = {}), this._command = new br, this._mdCommand = new br, this._wwCommand = new br, this._options = u()({ useCommandShortcut: !0 }, t), this.base = e, this.keyMapCommand = {}, this._initEvent() } var t = e.prototype; return t._addCommandBefore = function (e) { var t = { command: e }; return this.base.eventManager.emit("addCommandBefore", t), t.command || e }, t.addCommand = function (t) { for (var n = arguments.length, r = new Array(n > 1 ? n - 1 : 0), i = 1; i < n; i++) r[i - 1] = arguments[i]; r.length && (t = e.command.apply(e, [t].concat(r))); var o, a = (t = this._addCommandBefore(t)).getName(); return t.isMDType() ? o = this._mdCommand : t.isWWType() ? o = this._wwCommand : t.isGlobalType() && (o = this._command), o.set(a, t), t.keyMap && (this.keyMapCommand[t.keyMap[Er]] = a), t }, t._initEvent = function () { var e = this; this.base.eventManager.listen("command", (function () { e.exec.apply(e, arguments) })), this.base.eventManager.listen("keyMap", (function (t) { if (e._options.useCommandShortcut) { var n = e.keyMapCommand[t.keyMap]; n && (t.data.preventDefault(), e.exec(n)) } })) }, t.exec = function (e) { var t, n, r = this.base; if ((t = this._command.get(e)) || (this.base.isMarkdownMode() ? (t = this._mdCommand.get(e), r = this.base.mdEditor) : (t = this._wwCommand.get(e), r = this.base.wwEditor)), t) { for (var i, o = arguments.length, a = new Array(o > 1 ? o - 1 : 0), s = 1; s < o; s++) a[s - 1] = arguments[s]; a.unshift(r), n = (i = t).exec.apply(i, a) } return n }, e }(); xr.command = function (e, t) { var n = Tr.factory(e, t.name, t.keyMap); return u()(n, t), n }; var Sr = xr, Nr = /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})(\/([^\s]*))?$/g; var kr = function () { function e(e) { this.eventManager = e, this._initEvent(), this._initDefaultImageImporter() } e.decodeURIGraceful = function (e) { var t, n = e.split(" "), r = []; return Gt()(n, (function (e) { try { t = (t = decodeURIComponent(e)).replace(/ /g, "%20") } catch (n) { t = e } return r.push(t) })), r.join(" ") }, e.encodeMarkdownCharacters = function (e) { return e.replace(/\(/g, "%28").replace(/\)/g, "%29").replace(/\[/g, "%5B").replace(/\]/g, "%5D").replace(//g, "%3E") }, e.escapeMarkdownCharacters = function (e) { return e.replace(/\(/g, "\\(").replace(/\)/g, "\\)").replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(//g, "\\>") }; var t = e.prototype; return t._initEvent = function () { var e = this; this.eventManager.listen("drop", (function (t) { var n = t.data.dataTransfer && t.data.dataTransfer.files; e._processBlobItems(n, t.data) })), this.eventManager.listen("willPaste", (function (t) { var n = t.data.fragment.querySelectorAll("*"); if (1 === n.length && "IMG" === n[0].tagName && /^data:image/.test(n[0].src)) { t.data.preventDefault(); var r = function (e) { for (var t = atob(e.split(",")[1]), n = new ArrayBuffer(t.length), r = new Uint8Array(n), i = 0; i < t.length; i += 1) r[i] = t.charCodeAt(i); var o = e.split(",")[0]; return new Blob([n], { type: o.split(":")[1].split(";")[0] }) }(n[0].src); e._emitAddImageBlobHook(r, "paste") } })), this.eventManager.listen("paste", (function (t) { e._processClipboard(t.data) })), this.eventManager.listen("pasteBefore", (function (t) { e._decodeURL(t) })) }, t._initDefaultImageImporter = function () { this.eventManager.listen("addImageBlobHook", (function (e, t) { var n = new FileReader; n.onload = function (e) { t(e.target.result) }, n.readAsDataURL(e) })) }, t._emitAddImageBlobHook = function (e, t) { var n = this; this.eventManager.emit("addImageBlobHook", e, (function (t, r) { n.eventManager.emit("command", "AddImage", { imageUrl: t, altText: r || e.name || "image" }) }), t) }, t._decodeURL = function (t) { var n = e.decodeURIGraceful, r = e.encodeMarkdownCharacters; if ("markdown" === t.source && t.data.text) { var i = t.data.text, o = i[0]; 1 === i.length && o.match(Nr) && (o = r(o = n(o)), t.data.update(null, null, [o])) } else if ("wysiwyg" === t.source) { var a = t.clipboardContainer, s = a.childNodes[0], l = s.innerText; 1 === a.childNodes.length && "A" === s.tagName && l.match(Nr) && (s.innerText = n(l), s.href = r(s.href)) } }, t._processClipboard = function (e) { var t = e.clipboardData || window.clipboardData, n = t && t.items, r = t.types; n && r && 1 === r.length && -1 !== yr()("Files", [].slice.call(r)) && this._processBlobItems(n, e) }, t._processBlobItems = function (e, t) { var n = this; e && Gt()(e, (function (e) { if (-1 !== e.type.indexOf("image")) { t.preventDefault(), t.stopPropagation(), t.codemirrorIgnore = !0; var r = e.name ? e : e.getAsFile(); return n._emitAddImageBlobHook(r, t.type), !1 } return !0 })) }, e }(), Lr = n(22), Mr = n.n(Lr), Ar = new RegExp("(\\\\<|<)([A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^\"'=<>`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)*\\s*)(\\/?>)", "g"), Br = /^\s?\\-\\-\\-([\s\S]+?)\\-\\-\\-/, Or = / /g, Dr = function () { function e(e, t) { void 0 === t && (t = {}); var n = t, r = n.linkAttribute, i = n.customHTMLRenderer, o = n.extendedAutolinks, a = n.referenceDefinition, s = n.customParser, l = n.frontMatter, c = n.customProp; this.options = t, this.mdReader = new v.Parser({ extendedAutolinks: o, disallowedHtmlBlockTags: ["br"], referenceDefinition: a, disallowDeepHeading: !0, customParser: s, frontMatter: l }), this.renderHTML = Object(v.createRenderHTML)({ gfm: !0, convertors: C(r, i), customProp: c }), this.eventManager = e } var t = e.prototype; return t._markdownToHtmlWithCodeHighlight = function (e) { return this.renderHTML(this.mdReader.parse(e)) }, t._markdownToHtml = function (e) { return e = e.replace(Ar, (function (e, t, n, r) { return "\\" !== e[0] ? "" + t + n + " data-tomark-pass " + r : e })), this.renderHTML(this.mdReader.parse(e)) }, t._removeBrToMarkPassAttributeInCode = function (e) { var t = St.createElementWith("
    " + e + "
    "); return St.findAll(t, "code, pre").forEach((function (e) { var t = e; t.innerHTML = t.innerHTML.replace(/\sdata-tomark-pass\s(\/?)>/g, "$1>") })), e = t.innerHTML }, t.toHTMLWithCodeHighlight = function (e) { var t = this._markdownToHtmlWithCodeHighlight(e); return t = this.eventManager.emitReduce("convertorAfterMarkdownToHtmlConverted", t) }, t.toHTML = function (e) { var t = this._markdownToHtml(e); return t = this.eventManager.emitReduce("convertorAfterMarkdownToHtmlConverted", t), t = this._removeBrToMarkPassAttributeInCode(t) }, t.initHtmlSanitizer = function (e) { this.eventManager.listen("convertorAfterMarkdownToHtmlConverted", (function (t) { return e(t, !0) })) }, t.toMarkdown = function (e, t) { var n = []; e = this.eventManager.emitReduce("convertorBeforeHtmlToMarkdownConverted", e), e = this._appendAttributeForLinkIfNeed(e), e = this._appendAttributeForBrIfNeed(e); var r = Mr()(e, t); return this.options.frontMatter && (r = r.replace(Br, "---$1---")), r = this.eventManager.emitReduce("convertorAfterHtmlToMarkdownConverted", r), (r = this._removeNewlinesBeforeAfterAndBlockElement(r)).split("\n").forEach((function (e, t) { /^(
    )+\||\|[^|]*\|/gi.test(e) ? e = e.replace(/^(
    )+\|/gi, (function (e) { return e.replace(/
    /gi, "
    \n") })) : /`[^`]*
    [^`]*`/gi.test(e) || (e = e.replace(/
    /gi, "
    \n")), n[t] = e })), n.join("\n").replace(Or, " ") }, t._removeNewlinesBeforeAfterAndBlockElement = function (e) { return e = (e = e.replace(/
    \n\n(#{1,6} .*|```|\||(\*+|-+|\d+\.) .*| *>[^\n]+.*)/g, "
    $1")).replace(/(#{1,6} .*|```|\|)\n\n
    /g, "$1\n
    ") }, t._appendAttributeForLinkIfNeed = function (e) { return e.replace(/!?\[.*\]\(<\s*a[^>]*>(.*?)<\s*\/\s*a>\)/gi, (function (e) { return e.replace(/]|<\/a>|<\/code>|<\/span>|<\/b>|<\/i>|<\/s>|]*>)/.source + /

    /.source, "g"); return e = (e = (e = (e = (e = (e = (e = e.replace(/
    /gi, "
    ")).replace(/

    /gi, "

    ")).replace(/
    /gi, "
    ")).replace(/

    (.)/gi, "

    $1")).replace(t, "$1

    ")).replace(/(.)

    (|
    ||
      |
        |
        )/g, "$1

        $2")).replace(/(<\/h[1-6]>|<\/pre>|<\/table>|<\/ul>|<\/ol>|<\/blockquote>)
        (.)/g, "$1
        $2") }, e }(); function Ir() { return (Ir = Object.assign || function (e) { for (var t = 1; t < arguments.length; t++) { var n = arguments[t]; for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]) } return e }).apply(this, arguments) } function Rr(e, t) { e.forEach((function (e) { if (xe()(e)) e(t); else if (Yt()(e)) { var n = e[0], r = e[1]; n(t, void 0 === r ? {} : r) } })) } function Pr(e) { return e ? e.reduce((function (e, t) { var n = Yt()(t) ? t[0] : t; if (!xe()(n)) { var r = n.renderer, i = n.parser, o = n.pluginFn; t = Yt()(t) ? [o, t[1]] : o, r && (e.renderer = Ir({}, e.renderer, r)), i && (e.parser = Ir({}, e.parser, i)) } return e.plugins.push(t), e }), { plugins: [], renderer: {}, parser: {} }) : {} } function Hr() { return (Hr = Object.assign || function (e) { for (var t = 1; t < arguments.length; t++) { var n = arguments[t]; for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]) } return e }).apply(this, arguments) } var Fr = function () { function e(e) { var t = this; this.options = u()({ useDefaultHTMLSanitizer: !0, linkAttribute: null, extendedAutolinks: !1, customConvertor: null, customHTMLRenderer: null, referenceDefinition: !1, customHTMLSanitizer: null, frontMatter: !1 }, e), this.codeBlockLanguages = [], this.eventManager = new wr, this.commandManager = new Sr(this); var n = k(this.options.linkAttribute), r = Pr(this.options.plugins), o = r.renderer, a = r.parser, s = r.plugins, l = this.options, c = l.customHTMLRenderer, d = l.customHTMLSanitizer, h = l.extendedAutolinks, f = l.referenceDefinition, p = l.frontMatter, g = { linkAttribute: n, customHTMLRenderer: Hr({}, o, c), extendedAutolinks: h, referenceDefinition: f, customParser: a, frontMatter: p }; this.options.customConvertor ? this.convertor = new this.options.customConvertor(this.eventManager, g) : this.convertor = new Dr(this.eventManager, g); var m = d || (this.options.useDefaultHTMLSanitizer ? mn : null); m && this.convertor.initHtmlSanitizer(m), this.options.hooks && i()(this.options.hooks, (function (e, n) { t.addHook(n, e) })), this.options.events && i()(this.options.events, (function (e, n) { t.on(n, e) })); var v = this.options, y = v.el, b = v.initialValue, C = y.innerHTML; y.innerHTML = "", this.preview = new Vt(y, this.eventManager, this.convertor, Hr({}, g, { isViewer: !0 })), Ve()(this.preview.el, "mousedown", this._toggleTask.bind(this)), s && Rr(s, this), b ? this.setMarkdown(b) : C && this.preview.setHTML(C), this.eventManager.emit("load", this) } var t = e.prototype; return t._toggleTask = function (e) { var t = getComputedStyle(e.target, ":before"); !e.target.hasAttribute("data-te-task-disabled") && e.target.hasAttribute("data-te-task") && St.isInsideButtonBox(t, e.offsetX, e.offsetY) && (St.toggleClass(e.target, "checked"), this.eventManager.emit("change", { source: "viewer", data: e })) }, t.setMarkdown = function (e) { this.markdownValue = e = e || "", this.preview.refresh(this.markdownValue), this.eventManager.emit("setMarkdownAfter", this.markdownValue) }, t.on = function (e, t) { this.eventManager.listen(e, t) }, t.off = function (e) { this.eventManager.removeEventHandler(e) }, t.remove = function () { this.eventManager.emit("removeEditor"), Ge()(this.preview.el, "mousedown", this._toggleTask.bind(this)), this.preview.remove(), this.options = null, this.eventManager = null, this.commandManager = null, this.convertor = null, this.preview = null }, t.addHook = function (e, t) { this.eventManager.removeEventHandler(e), this.eventManager.listen(e, t) }, t.isViewer = function () { return !0 }, t.isMarkdownMode = function () { return !1 }, t.isWysiwygMode = function () { return !1 }, t.setCodeBlockLanguages = function (e) { var t = this; void 0 === e && (e = []), e.forEach((function (e) { t.codeBlockLanguages.indexOf(e) < 0 && t.codeBlockLanguages.push(e) })) }, e }(); Fr.isViewer = !0, Fr.domUtils = St, Fr.codeBlockManager = Nt, Fr.WwCodeBlockManager = null, Fr.WwTableManager = null, Fr.WwTableSelectionManager = null; var Ur = Fr, Wr = new(function () { function e() { this._code = "en-US", this._langs = new br } var t = e.prototype; return t.setCode = function (e) { this._code = e }, t.setLanguage = function (e, t) { var n = this; (e = [].concat(e)).forEach((function (e) { if (n._langs.has(e)) { var r = n._langs.get(e); n._langs.set(e, u()(r, t)) } else n._langs.set(e, t) })) }, t.get = function (e, t) { t || (t = this._code); var n = this._langs.get(t); n || (n = this._langs.get("en-US")); var r = n[e]; if (!r) throw new Error('There is no text key "' + e + '" in ' + t); return r }, e }()), qr = n(34), zr = n(26), jr = n.n(zr), Vr = n(35), Kr = n.n(Vr); function Gr(e, t, n) { return t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e } var $r = ["click", "mousedown", "mousemove", "mouseup", "mouseover", "mouseout", "scroll"], Yr = -1; var Xr = function () { function e(e) { void 0 === e && (e = {}), Gr(this, "tagName", void 0), Gr(this, "className", void 0), Gr(this, "el", void 0), Gr(this, "_id", void 0), e = u()({ tagName: "div" }, e), this.tagName = e.tagName, this.className = e.className, this._id = Yr += 1, this.customEventManager = new Kr.a, this._setRootElement(e.rootElement) } var t = e.prototype; return t.on = function (e, t) { var n = this; jr()(e) ? i()(e, (function (e, t) { n._addEvent(t, e) })) : this._addEvent(e, t) }, t._bindDomEvent = function (e, t, n) { t ? St.findAll(this.el, t).forEach((function (t) { Ve()(t, e, n) })) : Ve()(this.el, e, n) }, t._addEvent = function (e, t) { var n = this._parseEventType(e), r = n.event, i = n.selector; yr()(r, $r) > -1 ? this._bindDomEvent(r, i, t) : this.customEventManager.on(r, t) }, t._unbindDomEvent = function (e, t, n) { t ? St.findAll(this.el, t).forEach((function (t) { Ge()(t, e, n) })) : Ge()(this.el, e, n) }, t.off = function (e, t) { var n = this._parseEventType(e), r = n.event, i = n.selector; yr()(r, $r) > -1 ? this._unbindDomEvent(r, i, t) : this.customEventManager.off(r, t) }, t._parseEventType = function (e) { var t = e.split(" "); return { event: t.shift(), selector: t.join(" ") } }, t._setRootElement = function (e) { if (!e) { var t = this.tagName; (e = document.createElement(t)).className = this.className || "uic" + this._id } this.el = e }, t.trigger = function (e, t) { this.customEventManager.fire(e, t) }, t.remove = function () { this.el && St.remove(this.el) }, t.destroy = function () { var e = this; this.remove(), i()(this, (function (t, n) { e[n] = null })) }, e }(); function Zr(e, t, n) { return t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e } var Qr = function (e) { var t, n; function r(t) { var n; return void 0 === t && (t = { name: r.name }), (n = e.call(this, u()({ className: r.className }, t)) || this)._name = t.name, n } return n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n, r.prototype.getName = function () { return this._name }, r }(Xr); Zr(Qr, "name", "item"), Zr(Qr, "className", "tui-toolbar-item"); var Jr = Qr, ei = new(function () { function e() { this.el = St.createElementWith('
        '), document.body.appendChild(this.el), this.hide() } var t = e.prototype; return t.show = function (e, t) { var n = e.getBoundingClientRect(), r = n.left + window.pageXOffset, i = n.top + window.pageYOffset; h()(this.el, { top: i + e.clientHeight + 7 + "px", left: r + 3 + "px" }), this.el.querySelector(".text").innerHTML = t, h()(this.el, { display: "block" }) }, t.hide = function () { h()(this.el, { display: "none" }) }, t.remove = function () { St.remove(this.el) }, e }()); function ti(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e } function ni(e, t, n) { return t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e } var ri = function (e) { var t, n; function r(t) { var n; return void 0 === t && (t = { tagName: "button", name: r.name }), (n = e.call(this, { name: t.name, tagName: "button", className: t.className + " " + r.className, rootElement: t.el }) || this)._setOptions(t), n._render(), n.on("click", n._onClick.bind(ti(n))), t.tooltip && (n.on("mouseover", n._onOver.bind(ti(n))), n.on("mouseout", n._onOut.bind(ti(n)))), n } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i.setTooltip = function (e) { this._tooltip = e }, i._setOptions = function (e) { this._command = e.command, this._event = e.event, this._text = e.text, this._tooltip = e.tooltip, this._style = e.style, this._state = e.state }, i._render = function () { var e = document.createTextNode(this._text || ""); this.el.appendChild(e), this.el.setAttribute("type", "button"), this._style && this.el.setAttribute("style", this._style) }, i._onClick = function () { this.isEnabled() && (this._command ? this.trigger("command", this._command) : this._event && this.trigger("event", this._event), this.trigger("clicked")) }, i._onOver = function () { this.isEnabled() && ei.show(this.el, this._tooltip) }, i._onOut = function () { ei.hide() }, i.enable = function () { this.el.disabled = !1 }, i.disable = function () { this.el.disabled = !0 }, i.isEnabled = function () { return !this.el.disabled }, r }(Jr); ni(ri, "name", "button"), ni(ri, "className", "tui-toolbar-icons"); var ii = ri; function oi(e, t, n) { return t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e } var ai = function (e) { var t, n; function r() { return e.call(this, { name: r.name, tagName: "div", className: r.className }) || this } return n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n, r }(Jr); oi(ai, "name", "divider"), oi(ai, "className", "tui-toolbar-divider"); var si = ai, li = function () { function e() {} return e.create = function (e, t) { var n; switch (e) { case "heading": n = new ii({ name: "heading", className: "tui-heading", event: "openHeadingSelect", tooltip: Wr.get("Headings"), state: "heading" }); break; case "bold": n = new ii({ name: "bold", className: "tui-bold", command: "Bold", tooltip: Wr.get("Bold"), state: "strong" }); break; case "italic": n = new ii({ name: "italic", className: "tui-italic", command: "Italic", tooltip: Wr.get("Italic"), state: "emph" }); break; case "strike": n = new ii({ name: "strike", className: "tui-strike", command: "Strike", tooltip: Wr.get("Strike"), state: "strike" }); break; case "hr": n = new ii({ name: "hr", className: "tui-hrline", command: "HR", tooltip: Wr.get("Line"), state: "thematicBreak" }); break; case "quote": n = new ii({ name: "quote", className: "tui-quote", command: "Blockquote", tooltip: Wr.get("Blockquote"), state: "blockQuote" }); break; case "ul": n = new ii({ name: "ul", className: "tui-ul", command: "UL", tooltip: Wr.get("Unordered list"), state: "list" }); break; case "ol": n = new ii({ name: "ol", className: "tui-ol", command: "OL", tooltip: Wr.get("Ordered list"), state: "orderedList" }); break; case "task": n = new ii({ name: "task", className: "tui-task", command: "Task", tooltip: Wr.get("Task"), state: "taskList" }); break; case "table": n = new ii({ name: "table", className: "tui-table", event: "openPopupAddTable", tooltip: Wr.get("Insert table"), state: "table" }); break; case "image": n = new ii({ name: "image", className: "tui-image", event: "openPopupAddImage", tooltip: Wr.get("Insert image"), state: "" }); break; case "link": n = new ii({ name: "link", className: "tui-link", event: "openPopupAddLink", tooltip: Wr.get("Insert link") }); break; case "code": n = new ii({ name: "code", className: "tui-code", command: "Code", tooltip: Wr.get("Code"), state: "code" }); break; case "codeblock": n = new ii({ name: "codeblock", className: "tui-codeblock", command: "CodeBlock", tooltip: Wr.get("Insert CodeBlock"), state: "codeBlock" }); break; case "indent": n = new ii({ name: "indent", className: "tui-indent", command: "Indent", tooltip: Wr.get("Indent") }); break; case "outdent": n = new ii({ name: "outdent", className: "tui-outdent", command: "Outdent", tooltip: Wr.get("Outdent") }); break; case "divider": n = new si; break; case "button": n = new ii(t); break; case "item": default: n = new Jr(t) } return n }, e }(); function ci(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e } function ui(e, t, n) { return t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e } var di = function (e) { var t, n; function r(t, n) { var r; return void 0 === n && (n = []), ui(ci(r = e.call(this, { tagName: "div", className: "tui-editor-defaultUI-toolbar" }) || this), "_items", []), ui(ci(r), "_eventManager", void 0), r._eventManager = t, r.setItems(n), r._initEvent(t), r } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i._initEvent = function (e) { var t = this; e.listen("stateChange", (function (e) { t._items.forEach((function (t) { t._state && St.toggleClass(t.el, "active", !!e[t._state]) })) })), e.listen("changePreviewTabPreview", (function () { return t.disableAllButton() })), e.listen("changePreviewTabWrite", (function () { return t.enableAllButton() })), e.listen("changeMode", (function () { return t.enableAllButton() })) }, i.disableAllButton = function () { this._items.forEach((function (e) { e instanceof ii && e.disable() })) }, i.enableAllButton = function () { this._items.forEach((function (e) { e instanceof ii && e.enable() })) }, i.getItems = function () { return this._items.slice(0) }, i.getItem = function (e) { return this._items[e] }, i.setItems = function (e) { this.removeAllItems(), e.forEach(this.addItem.bind(this)) }, i.addItem = function (e) { this.insertItem(this._items.length, e) }, i.insertItem = function (e, t) { var n = this; Ye()(t) ? t = li.create(t) : Ye()(t.type) && (t = li.create(t.type, t.options)); var r = this.el.children; e >= 0 && e < r.length ? (St.insertBefore(t.el, r[e]), this._items.splice(e, 0, t)) : (this.el.appendChild(t.el), this._items.push(t)), t.onCommandHandler = function (e) { return n._eventManager.emit("command", e) }, t.onEventHandler = function (e) { return n._eventManager.emit(e) }, t.on("command", t.onCommandHandler), t.on("event", t.onEventHandler) }, i.indexOfItem = function (e) { var t; if (e instanceof Jr) t = this._items.indexOf(e); else if (Ye()(e)) { var n = e; t = this._items.map((function (e) { return e.getName() })).indexOf(n) } return t }, i.removeItem = function (e, t) { var n, r; return void 0 === t && (t = !0), (n = e instanceof Jr ? this.indexOfItem(e) : e) >= 0 && (r = this._items.splice(n, 1)[0]), r && (t ? r.destroy() : (r.off("command", r.onCommandHandler), r.off("event", r.onEventHandler), St.remove(r.el))), r }, i.removeAllItems = function () { for (; this._items && this._items.length > 0;) this.removeItem(0) }, i.destroy = function () { this.removeAllItems(), e.prototype.destroy.call(this) }, r }(Xr); var hi = function (e) { var t, n; function r(t) { var n; return t = u()({ header: !0, target: document.body, textContent: "" }, t), (n = e.call(this, { tagName: "div", className: t.modal ? "tui-popup-modal-background" : "tui-popup-wrapper", rootElement: t.el }) || this)._clickEventMap = {}, n._onClickCloseButton = n.hide.bind(function (e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e }(n)), n._initInstance(t), n._initDOM(t), n._initDOMEvent(t), n._initEditorEvent(t), n } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i._initInstance = function (e) { this._target = e.target, e.el && (this.el = e.el, this._isExternalHtmlUse = !0), e.content ? this.content = e.content : this.content = e.textContent, this.options = e }, i._initDOM = function () { this._initLayout(), this._isExternalHtmlUse || (a()(this.options.title) && this.setTitle(this.options.title), this.setContent(this.content)); var e = this.options.headerButtons; if (e) { St.findAll(this.el, ".tui-popup-close-button").forEach((function (e) { St.remove(e) })); var t = this.el.querySelector(".tui-popup-header-buttons"); St.empty(t), t.innerHTML = e } this.options.css && h()(this.el, this.options.css) }, i._initDOMEvent = function () { var e = this, t = this.options, n = t.openerCssQuery, r = t.closerCssQuery, i = document.body; n && St.findAll(i, n).forEach((function (t) { var n = "click." + e._id; e._clickEventMap[n] = e.show.bind(e), Ve()(t, "click", e._clickEventMap[n]) })), r && St.findAll(i, r).forEach((function (t) { var n = "click." + e._id; e._clickEventMap[n] = e.hide.bind(e), Ve()(t, "click", e._clickEventMap[n]) })), this.on("click .tui-popup-close-button", this._onClickCloseButton) }, i._initEditorEvent = function () {}, i._initLayout = function () { var e = this.options; if (this._isExternalHtmlUse) this.hide(), this._target.appendChild(this.el); else { var t = e.modal ? '
        \n
        \n \n
        \n \n
        \n
        \n
        \n
        ' : '
        \n \n
        \n \n
        \n
        \n
        '; this.el.innerHTML = t, e.className && p.a.apply(void 0, [this.el].concat(e.className.split(/\s+/g))), this.hide(), this._target.appendChild(this.el), this.body = this.el.querySelector(".tui-popup-body"), e.header || St.remove(this.el.querySelector(".tui-popup-header")) } }, i.setContent = function (e) { St.empty(this.body), Ye()(e) ? this.body.innerHTML = e : this.body.appendChild(e) }, i.setTitle = function (e) { var t = this.el.querySelector(".tui-popup-title"); St.empty(t), t.innerHTML = e }, i.getTitleElement = function () { return this.el.querySelector(".tui-popup-title") }, i.hide = function () { h()(this.el, { display: "none" }), this._isShow = !1, this.trigger("hidden", this) }, i.show = function () { h()(this.el, { display: "block" }), this._isShow = !0, this.trigger("shown", this) }, i.isShow = function () { return this._isShow }, i.remove = function () { var e = this, t = this.options, n = t.openerCssQuery, r = t.closerCssQuery, i = document.body; this.trigger("remove", this), this.off("click .tui-popup-close-button", this._onClickCloseButton), n && St.findAll(i, n).forEach((function (t) { Ge()(t, "click", e._clickEventMap["click." + e._id]), delete e._clickEventMap["click." + e._id] })), r && St.findAll(i, r).forEach((function (t) { Ge()(t, "click", e._clickEventMap["click." + e._id]), delete e._clickEventMap["click." + e._id] })), St.remove(this.el), this.el = null }, i.setFitToWindow = function (e) { St.toggleClass(this.el, "fit-window", e) }, i.isFitToWindow = function () { return et()(this.el, "fit-window") }, i.toggleFitToWindow = function () { var e = !this.isFitToWindow(); return this.setFitToWindow(e), e }, r }(Xr); var fi = function (e) { var t, n; function r(t) { return t = u()({ header: !1, className: "te-dropdown-toolbar" }, t), e.call(this, t) || this } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i.getToolbar = function () { return this._toolbar }, i.getItems = function () { return this.getToolbar().getItems() }, i.getItem = function (e) { return this.getToolbar().getItem(e) }, i.setItems = function (e) { this.getToolbar().setItems(e) }, i.addItem = function (e) { this.getToolbar().addItem(e) }, i.insertItem = function (e, t) { this.getToolbar().insertItem(e, t) }, i.indexOfItem = function (e) { return this.getToolbar().indexOfItem(e) }, i.removeItem = function (e, t) { return this.getToolbar().removeItem(e, t) }, i.removeAllItems = function () { this.getToolbar().removeAllItems() }, i._initInstance = function (t) { e.prototype._initInstance.call(this, t); var n = t.button, r = t.eventManager; this._button = n, this._eventManager = r, this._toolbar = new di(r) }, i._initDOM = function () { e.prototype._initDOM.call(this), this.setContent(this._toolbar.el) }, i._initEditorEvent = function () { var t = this; e.prototype._initEditorEvent.call(this), this._eventManager.listen("focus", (function () { return t.hide() })), this._eventManager.listen("closeAllPopup", (function () { return t.hide() })), this._eventManager.listen(r.OPEN_EVENT, (function () { var e = t.isShow(); t._eventManager.emit("closeAllPopup"), e || t.show(), h()(t.el, { left: "-1000px" }); var n = t._button, r = St.getOuterHeight(n, !0), i = (r - St.getOuterHeight(n)) / 2, o = n.offsetTop + r - i, a = n.offsetLeft + St.getOuterWidth(n, !0) - St.getOuterWidth(t.el, !0); h()(t.el, { top: o + "px", left: a + "px" }) })) }, r }(hi); ! function (e, t, n) { t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n }(fi, "OPEN_EVENT", "openDropdownToolbar"); var pi = fi; function gi(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e } function mi(e, t, n) { return t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e } var vi = function (e) { var t, n; function r(t, n) { var r; return mi(gi(r = e.call(this, t, n) || this), "_moreButton", void 0), mi(gi(r), "_popupDropdownToolbar", void 0), mi(gi(r), "_observer", void 0), r._init(t), r._bindWidthChangedEvent(), r } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i.insertItem = function (t, n) { e.prototype.insertItem.call(this, t, n), this._arrangeMoreButton() }, i._init = function (e) { var t = li.create("button", { name: "more", className: "tui-more", tooltip: Wr.get("More"), event: pi.OPEN_EVENT }); this._moreButton = t, this._popupDropdownToolbar = new pi({ eventManager: e, target: this.el, button: t.el }), this.addItem(t) }, i._bindWidthChangedEvent = function () { var e = this; this._observer = new qr.a((function () { e._popupDropdownToolbar.hide(), e._balanceButtons() })), this._observer.observe(this.el) }, i._balanceButtons = function () { var t = this; this._popupDropdownToolbar.getItems().forEach((function (n) { t._popupDropdownToolbar.removeItem(n, !1); var r = t.getItems().length; e.prototype.insertItem.call(t, r, n) })), this.removeItem(this._moreButton, !1), e.prototype.insertItem.call(this, 0, this._moreButton), this.getItems().filter((function (e) { return e.el.offsetTop > t.el.clientHeight })).forEach((function (e) { t.removeItem(e, !1), t._popupDropdownToolbar.addItem(e) })), this._arrangeMoreButton() }, i._arrangeMoreButton = function () { if (this._popupDropdownToolbar) { this.removeItem(this._moreButton, !1); var t = this._popupDropdownToolbar.getItems().length > 0, n = this.getItems().length; t && e.prototype.insertItem.call(this, n, this._moreButton) } }, i.destroy = function () { this._observer && (this._observer.disconnect(), this._observer = null) }, r }(di); var yi = function (e) { var t, n; function r(t) { var n; return void 0 === t && (t = {}), (n = e.call(this, { tagName: "div", className: "te-tab" }) || this).sections = t.sections, n._activeButton = null, n._render(t), n._initEvent(t), n } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i._initEvent = function (e) { var t = e.onItemClick; t && this.on("itemClick", t), this.on("click button", this._onTabButton.bind(this)) }, i._render = function (e) { for (var t = e.items, n = e.initName, r = [], i = 0, o = t.length; i < o; i += 1) r.push('"); this.el.innerHTML = r.join(""), this.activate(n) }, i._findButtonContained = function (e, t, n) { return St.findAll(e, t).filter((function (e) { return new RegExp(n).test(e.textContent) })) }, i.activate = function (e) { var t = this._findButtonContained(this.el, "button", e)[0]; this._activateTabByButton(t) }, i._onTabButton = function (e) { var t = e.target; this._activateTabByButton(t), this.trigger("itemClick", t.textContent) }, i._activateTabByButton = function (e) { this._isActivatedButton(e) || this._updateClassByButton(e) }, i._updateClassByButton = function (e) { if (this._activeButton) { var t = this._activeButton.getAttribute("data-index"); m()(this._activeButton, "te-tab-active"), this.sections && m()(this.sections[t], "te-tab-active") } p()(e, "te-tab-active"), this._activeButton = e; var n = e.getAttribute("data-index"); this.sections && p()(this.sections[n], "te-tab-active") }, i._isActivatedButton = function (e) { return this._activeButton && this._activeButton.textContent === e.textContent }, r }(Xr); function bi(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e } function Ci(e, t, n) { return t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e } var wi = function (e) { var t, n; function r(t, n, r) { var i; return Ci(bi(i = e.call(this, { tagName: "div", className: "te-mode-switch" }) || this), "_buttons", {}), Ci(bi(i), "_type", void 0), Ci(bi(i), "_rootElement", void 0), i._eventManager = r, i._render(t), i._switchType(a()(n) ? n : "markdown"), i._initEvent(), i } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i.isShown = function () { return "block" === this._rootElement.style.display }, i.show = function () { h()(this._rootElement, { display: "block" }) }, i.hide = function () { h()(this._rootElement, { display: "none" }) }, i._render = function (e) { this._buttons.markdown = St.createElementWith('"), this._buttons.wysiwyg = St.createElementWith('"), this.el.appendChild(this._buttons.markdown), this.el.appendChild(this._buttons.wysiwyg), e && (e.appendChild(this.el), this._rootElement = e), this.on("click .markdown", this._changeMarkdown.bind(this)), this.on("click .wysiwyg", this._changeWysiwyg.bind(this)), this.show() }, i._changeMarkdown = function () { this._switchType("markdown") }, i._changeWysiwyg = function () { this._switchType("wysiwyg") }, i._setActiveButton = function (e) { m()(this._buttons.markdown, "active"), m()(this._buttons.wysiwyg, "active"), p()(this._buttons["" + e], "active") }, i._switchType = function (e) { this._type !== e && (this._type = e, this._setActiveButton(e), this.trigger("modeSwitched", this._type)) }, i._initEvent = function () { var e = this; this._eventManager.listen("changeMode", (function (t) { e._type !== t && (e._type = t, e._setActiveButton(t)) })) }, r }(Xr); Ci(wi, "TYPE", { MARKDOWN: "markdown", WYSIWYG: "wysiwyg" }); var _i = wi; var Ti = /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})(\/([^\s]*))?$/, Ei = function (e) { var t, n; function r(t) { var n, r = '\n \n \n \n \n
        \n \n \n
        \n "; return t = u()({ header: !0, title: Wr.get("Insert link"), className: "te-popup-add-link tui-editor-popup", content: r }, t), (n = e.call(this, t) || this)._disabledLinkText = !1, n } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i._initInstance = function (t) { e.prototype._initInstance.call(this, t), this._editor = t.editor, this._eventManager = t.editor.eventManager }, i._initDOM = function () { e.prototype._initDOM.call(this); var t = this.el; this._inputText = t.querySelector(".te-link-text-input"), this._inputURL = t.querySelector(".te-url-input") }, i._initDOMEvent = function () { var t = this; e.prototype._initDOMEvent.call(this), this.on("click .te-close-button", (function () { return t.hide() })), this.on("click .te-ok-button", (function () { return t._addLink() })), this.on("shown", (function () { t._disabledLinkText = t._editor.isWysiwygMode() && !t._editor.getRange().collapsed, t._disableLinkTextInput(); var e = t._inputText, n = t._inputURL, r = t._editor.getSelectedText().trim(); e.value = r, Ti.exec(r) && (n.value = r), n.focus() })), this.on("hidden", (function () { t._resetInputs() })) }, i._initEditorEvent = function () { var t = this; e.prototype._initEditorEvent.call(this); var n = this._eventManager; n.listen("focus", (function () { return t.hide() })), n.listen("closeAllPopup", (function () { return t.hide() })), n.listen("openPopupAddLink", (function (e) { n.emit("closeAllPopup"), e && (t._inputURL.value = e.url), t.show() })) }, i._disableLinkTextInput = function () { var e = this._inputText; this._disabledLinkText ? (e.setAttribute("disabled", "disabled"), p()(e, "disabled")) : (e.removeAttribute("disabled"), m()(e, "disabled")) }, i._addLink = function () { var e = this._getValue(), t = e.url, n = e.linkText; this._clearValidationStyle(), !this._disabledLinkText && n.length < 1 ? p()(this._inputText, "wrong") : t.length < 1 ? p()(this._inputURL, "wrong") : (this._eventManager.emit("command", "AddLink", { linkText: n, url: t }), this.hide()) }, i._getValue = function () { return { url: this._inputURL.value, linkText: this._inputText.value } }, i._clearValidationStyle = function () { m()(this._inputURL, "wrong", "disabled"), m()(this._inputText, "wrong") }, i._resetInputs = function () { this._inputText.removeAttribute("disabled"), this._inputText.value = "", this._inputURL.value = "", this._clearValidationStyle() }, r }(hi); var xi = function (e) { var t, n; function r(t) { var n = '\n
        \n
        \n \n \n
        \n
        \n \n \n
        \n \n \n
        \n \n \n
        \n "; return t = u()({ header: !0, title: Wr.get("Insert image"), className: "te-popup-add-image tui-editor-popup", content: n }, t), e.call(this, t) || this } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i._initInstance = function (t) { e.prototype._initInstance.call(this, t), this.eventManager = t.eventManager }, i._initDOM = function () { e.prototype._initDOM.call(this); var t = this.el; this._imageUrlInput = t.querySelector(".te-image-url-input"), this._imageFileInput = t.querySelector(".te-image-file-input"), this._altTextInput = t.querySelector(".te-alt-text-input"); var n = t.querySelector(".te-file-type"), r = t.querySelector(".te-url-type"), i = this.body.querySelector(".te-tab-section"); this.tab = new yi({ initName: Wr.get("File"), items: [Wr.get("File"), Wr.get("URL")], sections: [n, r] }), i.appendChild(this.tab.el) }, i._initDOMEvent = function () { var t = this; e.prototype._initDOMEvent.call(this), this.on("shown", (function () { return t._imageUrlInput.focus() })), this.on("hidden", (function () { return t._resetInputs() })), this.on("change .te-image-file-input", (function () { var e = t._imageFileInput.value.split("\\").pop(); t._altTextInput.value = e })), this.on("click .te-close-button", (function () { return t.hide() })), this.on("click .te-ok-button", (function () { var e = t._imageUrlInput.value, n = t._altTextInput.value; if (e) t._applyImage(e, n); else { var r = t._imageFileInput.files; if (r.length) { var i = r.item(0); t.eventManager.emit("addImageBlobHook", i, (function (e, r) { return t._applyImage(e, r || n) }), "ui") } } t.hide() })), this.tab.on("itemClick", (function () { return t._resetInputs() })) }, i._initEditorEvent = function () { var t = this; e.prototype._initEditorEvent.call(this), this.eventManager.listen("focus", (function () { return t.hide() })), this.eventManager.listen("closeAllPopup", (function () { return t.hide() })), this.eventManager.listen("openPopupAddImage", (function () { t.eventManager.emit("closeAllPopup"), t.show() })) }, i._applyImage = function (e, t) { this.eventManager.emit("command", "AddImage", { imageUrl: e, altText: t || "image" }), this.hide() }, i._resetInputs = function () { St.findAll(this.el, "input").forEach((function (e) { e.value = "" })) }, i.remove = function () { this.tab.remove(), e.prototype.remove.call(this) }, r }(hi); var Si = function (e) { var t, n; function r(t) { var n = '\n \n \n \n \n
        \n \n \n \n
        \n \n "; return t = u()({ header: !1, className: "te-popup-table-utils", content: n }, t), e.call(this, t) || this } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i._initInstance = function (t) { e.prototype._initInstance.call(this, t), this.eventManager = t.eventManager }, i._initDOMEvent = function () { var t = this; e.prototype._initDOMEvent.call(this), this.on("click .te-table-add-row", (function () { return t.eventManager.emit("command", "AddRow") })), this.on("click .te-table-add-col", (function () { return t.eventManager.emit("command", "AddCol") })), this.on("click .te-table-col-align-left", (function () { return t.eventManager.emit("command", "AlignCol", "left") })), this.on("click .te-table-col-align-center", (function () { return t.eventManager.emit("command", "AlignCol", "center") })), this.on("click .te-table-col-align-right", (function () { return t.eventManager.emit("command", "AlignCol", "right") })), this.on("click .te-table-remove-col", (function () { return t.eventManager.emit("command", "RemoveCol") })), this.on("click .te-table-remove", (function () { return t.eventManager.emit("command", "RemoveTable") })), this._bindClickEventOnRemoveRowMenu() }, i._initEditorEvent = function () { var t = this; e.prototype._initEditorEvent.call(this), this.eventManager.listen("focus", (function () { return t.hide() })), this.eventManager.listen("mousedown", (function () { return t.hide() })), this.eventManager.listen("closeAllPopup", (function () { return t.hide() })), this.eventManager.listen("openPopupTableUtils", (function (e) { var n = t.el.parentNode.getBoundingClientRect(), r = n.left, i = n.top; t._disableRemoveRowMenu(e.target), h()(t.el, { position: "absolute", top: e.clientY - i + 5 + "px", left: e.clientX - r + 10 + "px" }), t.eventManager.emit("closeAllPopup"), t.show() })) }, i._bindClickEventOnRemoveRowMenu = function () { var e = this; this.on("click .te-table-remove-row", (function (t) { var n = t.target; et()(n, "te-context-menu-disabled") ? t.preventDefault() : e.eventManager.emit("command", "RemoveRow") })) }, i._disableRemoveRowMenu = function (e) { var t = this.el.querySelector(".te-table-remove-row"); St.toggleClass(t, "te-context-menu-disabled", "TH" === e.nodeName) }, r }(hi); var Ni = function (e) { var t, n; function r(t) { return t = u()({ header: !1, className: "te-popup-add-table", content: '\n
        \n
        \n
        \n
        \n
        \n

        \n' }, t), e.call(this, t) || this } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i._initInstance = function (t) { e.prototype._initInstance.call(this, t), this._selectedBound = {}, this._tableBound = {}, this._eventManager = t.eventManager, this._button = t.button, this._eventHandlers = { onMousedown: this._selectTableRange.bind(this), onClick: this._fireCommandEvent.bind(this) } }, i._initDOM = function () { e.prototype._initDOM.call(this), this._cacheElements(), this._setTableSizeByBound(5, 7) }, i._initDOMEvent = function (t) { e.prototype._initDOMEvent.call(this, t), this.on("mousemove .te-table-selection", this._eventHandlers.onMousedown), this.on("click .te-table-selection", this._eventHandlers.onClick) }, i._selectTableRange = function (e) { var t = e.pageX - this._selectionOffset.left, n = e.pageY - this._selectionOffset.top, r = this._getSelectionBoundByOffset(t, n); this._resizeTableBySelectionIfNeed(r.col, r.row), this._setSelectionAreaByBound(r.col, r.row), this._setDisplayText(r.col, r.row), this._setSelectedBound(r.col, r.row) }, i._fireCommandEvent = function () { var e = this._getSelectedTableSize(); this._eventManager.emit("command", "Table", e.col, e.row) }, i._initEditorEvent = function () { var t = this; e.prototype._initEditorEvent.call(this), this._eventManager.listen("focus", (function () { return t.hide() })), this._eventManager.listen("closeAllPopup", (function () { return t.hide() })), this._eventManager.listen("openPopupAddTable", (function () { var e = t._button, n = e.offsetTop, r = e.offsetLeft; h()(t.el, { top: n + St.getOuterHeight(e) + "px", left: r + "px" }), t._eventManager.emit("closeAllPopup"), t.show(); var i = t.el.querySelector(".te-table-selection").getBoundingClientRect(), o = i.left, a = i.top; t._selectionOffset = { left: o + window.pageXOffset, top: a + window.pageYOffset } })) }, i._cacheElements = function () { this.header = this.el.querySelector(".te-table-header"), this.body = this.el.querySelector(".te-table-body"), this.selection = this.el.querySelector(".te-selection-area"), this.desc = this.el.querySelector(".te-description") }, i._resizeTableBySelectionIfNeed = function (e, t) { var n = this._getResizedTableBound(e, t); n && this._setTableSizeByBound(n.col, n.row) }, i._getResizedTableBound = function (e, t) { var n, r, i; return e >= 5 && e < 9 ? n = e + 1 : e < 5 && (n = 5), t >= 7 && t < 14 ? r = t + 1 : t < 7 && (r = 7), this._isNeedResizeTable(n, r) && (i = { row: r || this._tableBound.row, col: n || this._tableBound.col }), i }, i._isNeedResizeTable = function (e, t) { return e && e !== this._tableBound.col || t && t !== this._tableBound.row }, i._getBoundByOffset = function (e, t) { return { row: parseInt(t / 17, 10), col: parseInt(e / 25, 10) } }, i._getOffsetByBound = function (e, t) { return { x: 25 * e + 25, y: 17 * t + 17 } }, i._setTableSizeByBound = function (e, t) { var n = this._getOffsetByBound(e, t - 1); this._setTableSize(n.x, n.y), this._tableBound.row = t, this._tableBound.col = e }, i._getSelectionBoundByOffset = function (e, t) { var n = this._getBoundByOffset(e, t); return n.row < 1 ? n.row = 1 : n.row > this._tableBound.row && (n.row = this._tableBound.row), n.col < 1 ? n.col = 1 : n.col > this._tableBound.col && (n.col = this._tableBound.col), n }, i._setSelectionAreaByBound = function (e, t) { var n = this._getOffsetByBound(e, t); this._setSelectionArea(n.x, n.y) }, i._setSelectedBound = function (e, t) { this._selectedBound.col = e, this._selectedBound.row = t }, i._getSelectedTableSize = function () { return { row: this._selectedBound.row + 1, col: this._selectedBound.col + 1 } }, i._setDisplayText = function (e, t) { this.desc.innerHTML = e + 1 + " x " + (t + 1) }, i._setTableSize = function (e, t) { e += 1, t += 1, h()(this.header, { height: "17px", width: e + "px" }), h()(this.body, { height: t + "px", width: e + "px" }), h()(this.el, { width: e + 30 + "px" }) }, i._setSelectionArea = function (e, t) { e += 1, t += 1, h()(this.selection, { height: t + "px", width: e + "px" }) }, i.remove = function () { this.off("mousemove .te-table-selection", this._eventHandlers.onMousedown), this.off("click .te-table-selection", this._eventHandlers.onClick), e.prototype.remove.call(this) }, r }(hi); Ni.CELL_WIDTH = 25, Ni.CELL_HEIGHT = 17, Ni.MIN_ROW_SELECTION_INDEX = 1, Ni.MIN_COL_SELECTION_INDEX = 1; var ki = Ni; var Li = function (e) { var t, n; function r(t) { var n = '\n
          \n
        • ' + Wr.get("Heading") + ' 1

        • \n
        • ' + Wr.get("Heading") + ' 2

        • \n
        • ' + Wr.get("Heading") + ' 3

        • \n
        • ' + Wr.get("Heading") + ' 4

        • \n
        • ' + Wr.get("Heading") + ' 5
        • \n
        • ' + Wr.get("Heading") + ' 6
        • \n
        • ' + Wr.get("Paragraph") + "
        • \n
        \n "; return t = u()({ header: !1, className: "te-heading-add", content: n }, t), e.call(this, t) || this } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i._initInstance = function (t) { e.prototype._initInstance.call(this, t), this._eventManager = t.eventManager, this._button = t.button }, i._initDOMEvent = function () { var t = this; e.prototype._initDOMEvent.call(this), this.on("click li", (function (e) { var n = St.closest(e.target, "li"); t._eventManager.emit("command", n.getAttribute("data-type"), n.getAttribute("data-value")) })) }, i._initEditorEvent = function () { var t = this; e.prototype._initEditorEvent.call(this), this._eventManager.listen("focus", this.hide.bind(this)), this._eventManager.listen("closeAllPopup", this.hide.bind(this)), this._eventManager.listen("openHeadingSelect", (function () { var e = t._button, n = e.offsetTop, r = e.offsetLeft; h()(t.el, { top: n + St.getOuterHeight(e) + "px", left: r + "px" }), t._eventManager.emit("closeAllPopup"), t.show() })) }, r }(hi); function Mi(e) { return e.map((function (e) { return '" })).join("") } var Ai = function (e) { var t, n; function r(t) { var n = t.languages; return t = u()({ header: !1, className: "te-popup-code-block-languages", content: Mi(n) }, t), e.call(this, t) || this } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i._initInstance = function (t) { var n = this; e.prototype._initInstance.call(this, t), this.eventManager = t.eventManager, this._onSelectedLanguage = null, this._onDismissed = null, this._currentButton = null, this._buttons = null, this._languages = t.languages, this._btnMousedownHandler = function (e) { var t = e.target.getAttribute("data-lang"); n._onSelectedLanguage && n._onSelectedLanguage(t), n.hide() } }, i._initDOM = function (t) { e.prototype._initDOM.call(this, t), h()(this.el, "zIndex", 1e4), this._buttons = St.findAll(this.el, "button"), this._activateButtonByIndex(0) }, i._initDOMEvent = function () { e.prototype._initDOMEvent.call(this), this._addBtnMouseDownHandler() }, i._initEditorEvent = function () { var t = this; e.prototype._initEditorEvent.call(this), this.eventManager.listen("openPopupCodeBlockLanguages", (function (e) { return t.show(e.callback), h()(t.el, { top: e.offset.top + "px" }), h()(t.el, { left: e.offset.left + "px" }), t.setCurrentLanguage(e.language), t })), this.eventManager.listen("focus", (function () { return t.hide() })), this.eventManager.listen("mousedown", (function () { return t.hide() })), this.eventManager.listen("closeAllPopup", (function () { return t.hide() })), this.eventManager.listen("closePopupCodeBlockLanguages", (function () { return t.hide() })), this.eventManager.listen("scroll", (function () { return t.hide() })), this.eventManager.listen("setCodeBlockLanguages", (function (e) { return t._changeLanguageButtons(e) })) }, i._activateButtonByIndex = function (e) { this._currentButton && m()(this._currentButton, "active"), this._buttons.length && (this._currentButton = this._buttons[e], p()(this._currentButton, "active"), this._currentButton.scrollIntoView()) }, i.prev = function () { var e = yr()(this._currentButton, this._buttons) - 1; e < 0 && (e = this._buttons.length - 1), this._activateButtonByIndex(e) }, i.next = function () { var e = yr()(this._currentButton, this._buttons) + 1; e >= this._buttons.length && (e = 0), this._activateButtonByIndex(e) }, i.getCurrentLanguage = function () { return this._currentButton.getAttribute("data-lang") }, i.setCurrentLanguage = function (e) { var t = this._buttons.filter((function (t) { return nt()(t, ".te-popup-code-block-lang-" + e) })); if (t.length > 0) { var n = yr()(t[0], this._buttons); this._activateButtonByIndex(n) } }, i.show = function (t) { this._onSelectedLanguage = t.selected, this._onDismissed = t.dismissed, e.prototype.show.call(this) }, i.hide = function () { this._onDismissed && this._onDismissed(), this._onSelectedLanguage = null, this._onDismissed = null, e.prototype.hide.call(this) }, i._addBtnMouseDownHandler = function () { var e = this; this._languages.forEach((function (t) { e.off("mousedown .te-popup-code-block-lang-" + t, e._btnMousedownHandler), e.on("mousedown .te-popup-code-block-lang-" + t, e._btnMousedownHandler) })) }, i._changeLanguageButtons = function (e) { this._languages = e, e && e.length && (this.content = Mi(e), this.setContent(this.content), this._addBtnMouseDownHandler(), this._buttons = St.findAll(this.el, "button"), this._activateButtonByIndex(0)) }, r }(hi), Bi = { left: "tui-split-content-left", right: "tui-split-content-right" }, Oi = function () { function e(e, t, n, r) { void 0 === r && (r = {}), r = u()({ showScrollSyncButton: !1, scrollSync: !0, splitView: !0 }, r), this._baseElement = e, this._eventManager = r.eventManager, this._contentElements = [], this._initDom(t, n, r), this._initDomEvent() } var t = e.prototype; return t._initDom = function (e, t, n) { var r = document.createElement("div"); r.className = "tui-split-scroll", this._el = r; var i = document.createElement("div"); i.className = "tui-split-scroll-wrapper", this._scrollWrapper = i, this._setScrollSync(n.scrollSync), this.setSplitView(n.splitView); var o = document.createElement("div"); o.className = "tui-split-scroll-content", this._contentWrapper = o; var a = document.createElement("div"); a.className = "tui-splitter", this._baseElement.appendChild(r), r.appendChild(i), i.appendChild(o), i.appendChild(a), this._setLeft(e), this._setRight(t) }, t._initDomEvent = function () { this._contentWrapper.addEventListener("scroll", this.sync.bind(this)) }, t._requireScrollIntoView = function (e) { var t, n = e.getBoundingClientRect(), r = n.top, i = n.bottom; if (this.isScrollSynced()) t = this._contentWrapper; else if (St.parents(e, this._contentElements.left).length) t = this._contentElements.left; else { if (!St.parents(e, this._contentElements.right).length) return; t = this._contentElements.right } var o = t.getBoundingClientRect(), a = o.top, s = o.bottom; r < a ? t.scrollTop = t.scrollTop + r - a : i > s && (t.scrollTop = t.scrollTop + i - s), this.sync() }, t._setContentElement = function (e, t) { var n = this, r = this._contentElements[t]; r && (this._eventManager.removeEventHandler("requireScrollIntoView"), this._contentWrapper.removeChild(r)), p()(e, Bi[t]), this._contentWrapper.appendChild(e), this._eventManager.listen("requireScrollIntoView", (function (e) { return n._requireScrollIntoView(e) })), this._eventManager.listen("requireScrollSync", (function () { return n.sync() })), this._contentElements[t] = e, this.sync() }, t._setLeft = function (e) { this._setContentElement(e, "left") }, t._setRight = function (e) { this._setContentElement(e, "right") }, t._setScrollSync = function (e) { St.toggleClass(this._el, "scroll-sync", e) }, t.toggleScrollSync = function () { St.toggleClass(this._el, "scroll-sync") }, t.setSplitView = function (e) { e ? m()(this._el, "single-content") : p()(this._el, "single-content") }, t.toggleSplitView = function () { St.toggleClass(this._el, "single-content") }, t.isScrollSynced = function () { return et()(this._el, "scroll-sync") }, t.isSplitView = function () { return !et()(this._el, "single-content") }, t.sync = function () { if (this._contentElements.left && this._contentElements.right) { var e = this._contentWrapper.clientHeight, t = this._contentWrapper.scrollTop, n = this._contentElements.left, r = this._contentElements.right, i = n.offsetHeight - e > 0 ? n : r, o = i === n ? r : n, a = i.offsetHeight, s = Math.max(a - e, 0), l = a - Math.max(o.offsetHeight, e); h()(i, { top: 0 }), h()(o, { top: t / s * l + "px" }) } }, t.scrollTop = function (e) { this._contentWrapper.scrollTop = e }, e }(); var Di = function (e) { var t, n; function r(t, n) { var r; return (r = e.call(this, t, { singleCursorHeightPerLine: !1, theme: "none" }) || this)._language = "", r._eventManager = n, r._initEvent(), r } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i._initEvent = function () { var e = this; this.on("cursorActivity", this._onRequireScrollIntoView.bind(this)), this.on("beforeChange", (function (t, n) { "paste" === n.origin && e._eventManager.emit("pasteBefore", { source: "codeblock", data: n }) })) }, i._onRequireScrollIntoView = function () { var e = this, t = this.getCursor(), n = this.getWrapperElement(); setTimeout((function () { var r = n.querySelector("pre:nth-child(" + (t.line + 1) + ")"); r && e._eventManager.emit("requireScrollIntoView", r) }), 0) }, i.load = function (e) { var t = e.cloneNode(!0); this.setLanguage(t.getAttribute("data-language") || ""), this.setEditorCodeText(t.textContent) }, i.save = function (e) { e.innerHTML = "", e.textContent = this.getEditorCodeText(), e.setAttribute("data-language", this._language), this._eventManager.emit("changeLanguage") }, i.clear = function () { this.setLanguage(""), this.setEditorCodeText("") }, i.getLanguage = function () { return this._language }, i.setLanguage = function (e) { void 0 === e && (e = ""), this._language = e }, i.getEditorCodeText = function () { return this.getValue() }, i.setEditorCodeText = function (e) { void 0 === e && (e = ""), this.setValue(e) }, i.refresh = function () { this.cm.refresh() }, r }(Z); var Ii = function (e) { var t, n; function r(t, n, r, i) { var o; return (o = e.call(this, t, n, r, !0) || this)._codeBlockEditor = i, o._initEvent(), o.lazyRunner.registerLazyRunFunction("refresh", o.refresh, o.delayCodeBlockTime, function (e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e }(o)), o } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i._initEvent = function () { var e = this; this._codeBlockEditor.on("update", (function () { return e.lazyRunner.run("refresh") })) }, i.refresh = function () { var t = this._codeBlockEditor.getLanguage(), n = this._codeBlockEditor.getEditorCodeText(); e.prototype.refresh.call(this, "```" + t + "\n" + n + "\n```"), this.eventManager.emit("requireScrollSync") }, i.clear = function () { e.prototype.render.call(this, "") }, r }(kt), Ri = function () { function e(e, t) { this._eventManager = e, this._languages = t, this._initDOM(), this._initDOMEvent(), this._initEvent() } var t = e.prototype; return t._initDOM = function () { this._inputLanguage = St.createElementWith(''), this._wrapper = St.createElementWith(''), this._wrapper.appendChild(this._inputLanguage), this._hide() }, t._initDOMEvent = function () { var e = this; this._inputLanguage.addEventListener("keydown", (function (t) { return e._onKeyEvent(t) })), this._inputLanguage.addEventListener("focus", (function () { return e._showPopupCodeBlockLanguages() })), this._inputLanguage.addEventListener("focusout", (function () { return e._onFocusOut() })), this._wrapper.addEventListener("mousedown", (function (t) { t.target === e._wrapper && (t.preventDefault(), e._toggleFocus()) })) }, t._initEvent = function () { var e = this; this._eventManager.listen("setCodeBlockLanguages", (function (t) { e._languages = t, t && t.length ? e._show() : e._hide() })) }, t._showPopupCodeBlockLanguages = function () { var e = this, t = this._inputLanguage.getBoundingClientRect(); p()(this._wrapper, "active"), this.active = !0, this._popupCodeBlockLanguages = this._eventManager.emitReduce("openPopupCodeBlockLanguages", { language: this._prevStoredLanguage, offset: { left: t.left, top: t.bottom }, callback: { selected: function (t) { return e._onLanguageSelectedFromList(t) }, dismissed: function () { e._popupCodeBlockLanguages = null } } }) }, t._toggleFocus = function () { var e = this._inputLanguage; et()(this._wrapper, "active") ? e.blur() : e.focus() }, t._onFocusOut = function () { m()(this._wrapper, "active"), this._inputLanguage.value = this._prevStoredLanguage, this._hidePopupCodeBlockLanguages() }, t._onKeyEvent = function (e) { if (this._popupCodeBlockLanguages) switch (e.which) { case J.keyCode("UP"): this._popupCodeBlockLanguages.prev(), e.preventDefault(); break; case J.keyCode("DOWN"): this._popupCodeBlockLanguages.next(), e.preventDefault(); break; case J.keyCode("ENTER"): case J.keyCode("TAB"): var t = this._popupCodeBlockLanguages.getCurrentLanguage(); this._inputLanguage.value = t, this._storeInputLanguage(), e.preventDefault(); break; default: this._popupCodeBlockLanguages.hide() } else e.which !== J.keyCode("ENTER") && e.which !== J.keyCode("TAB") || (this._storeInputLanguage(), e.preventDefault()) }, t._onLanguageSelectedFromList = function (e) { this._inputLanguage.value = e, this._storeInputLanguage() }, t.setOnLanguageSelected = function (e) { this._onLanguageSelected = e }, t._hidePopupCodeBlockLanguages = function () { this._eventManager.emit("closePopupCodeBlockLanguages") }, t.setLanguage = function (e) { this._prevStoredLanguage = e, this._inputLanguage.value = e }, t._storeInputLanguage = function () { var e = this._inputLanguage.value; this.setLanguage(e), this._onLanguageSelected && this._onLanguageSelected(e), this._hidePopupCodeBlockLanguages() }, t.getElement = function () { return this._wrapper }, t._show = function () { h()(this._wrapper, { display: "inline-block" }) }, t._hide = function () { h()(this._wrapper, { display: "none" }) }, e }(); var Pi = function (e) { var t, n; function r(t) { var n = '\n \n
        \n \n \n
        \n "; return t = u()({ header: !0, title: "CodeBlock Editor", content: n, className: "tui-popup-code-block-editor", headerButtons: '\n \n \n \n \n', modal: !0 }, t), e.call(this, t) || this } n = e, (t = r).prototype = Object.create(n.prototype), t.prototype.constructor = t, t.__proto__ = n; var i = r.prototype; return i._initInstance = function (t) { e.prototype._initInstance.call(this, t), this.eventManager = t.eventManager, this.convertor = t.convertor, this.languages = t.languages }, i._initDOM = function (t) { e.prototype._initDOM.call(this, t); var n = this.el, r = this.eventManager; this._body = n.querySelector(".popup-editor-body"), this._toggleFitButton = n.querySelector(".popup-editor-toggle-fit"), this._togglePreviewButton = n.querySelector(".popup-editor-toggle-preview"), this._toggleScrollButton = n.querySelector(".popup-editor-toggle-scroll"), this._okButton = n.querySelector(".te-ok-button"), this._closeButton = n.querySelector(".te-close-button"), this._codeMirrorWrapper = this._createCodeBlockEditor(), this._previewWrapper = this._createPreview(), this._scrollSyncSplit = new Oi(this._body, this._codeMirrorWrapper, this._previewWrapper, { eventManager: r }), this._updateFitWindowButton(), this._updatePreviewButton(), this._updateScrollButton(), this._codeBlockLanguagesCombo = this._createCodeBlockLanguagesCombo() }, i._initDOMEvent = function () { var t = this; e.prototype._initDOMEvent.call(this), this.on("scroll", (function (e) { return e.preventDefault() })), this.on("click .popup-editor-toggle-fit", (function () { return t._toggleFitToWindow() })), this.on("click .popup-editor-toggle-preview", (function () { return t._togglePreview() })), this.on("click .popup-editor-toggle-scroll", (function () { return t._toggleScroll() })), this.on("click .te-ok-button", (function () { return t._save() })), this.on("click .te-close-button", (function () { return t.hide() })), this.on("click .popup-editor-close", (function () { return t.hide() })), this.on("click .popup-editor-editor-wrapper", (function (e) { e.target === t._codeMirrorWrapper && t._focusEditor(!0) })) }, i._initEditorEvent = function () { var t = this; e.prototype._initEditorEvent.call(this), this.eventManager.listen("openPopupCodeBlockEditor", (function (e) { return t.eventManager.emit("closeAllPopup"), t.show(e), t })), this.eventManager.listen("closeAllPopup", this.hide.bind(this)), this.eventManager.listen("closePopupCodeBlockEditor", this.hide.bind(this)) }, i._createCodeBlockEditor = function () { var e = document.createElement("div"); return e.className = "popup-editor-editor-wrapper", this._codeBlockEditor = new Di(e, this.eventManager), e }, i._createPreview = function () { var e = document.createElement("div"); return this._codeBlockPreview = new Ii(e, this.eventManager, this.convertor, this._codeBlockEditor), e }, i._createCodeBlockLanguagesCombo = function () { var e = this, t = this.getTitleElement(), n = new Ri(this.eventManager, this.languages); return n.setOnLanguageSelected((function (t) { e._codeBlockEditor.setLanguage(t), e._codeBlockEditor.refresh(), e._focusEditor() })), t.innerHTML = "CodeBlock Editor", t.appendChild(n.getElement()), n }, i._updateFitWindowButton = function () { St.toggleClass(this._toggleFitButton, "active", this.isFitToWindow()) }, i._updatePreviewButton = function () { St.toggleClass(this._togglePreviewButton, "active", this._scrollSyncSplit.isSplitView()) }, i._updateScrollButton = function () { this._scrollSyncSplit.isSplitView() ? h()(this._toggleScrollButton, { display: "inline-block" }) : h()(this._toggleScrollButton, { display: "none" }), St.toggleClass(this._toggleScrollButton, "active", this._scrollSyncSplit.isScrollSynced()) }, i._focusEditor = function (e) { this._codeBlockEditor.focus(), e ? this._codeBlockEditor.moveCursorToEnd() : this._codeBlockEditor.moveCursorToStart() }, i._togglePreview = function () { this._scrollSyncSplit.toggleSplitView(), this._updatePreviewButton(), this._updateScrollButton(), this._codeBlockEditor.refresh() }, i._toggleFitToWindow = function () { this.toggleFitToWindow(), this._updateFitWindowButton(), this._codeBlockEditor.refresh() }, i._toggleScroll = function () { this._scrollSyncSplit.toggleScrollSync(), this._updateScrollButton() }, i._save = function () { this._codeBlockEditor.save(this._codeBlockElement), this.hide() }, i._load = function (e) { this._codeBlockElement = e, this._codeBlockEditor.load(e), this._codeBlockLanguagesCombo.setLanguage(this._codeBlockEditor.getLanguage()), this._focusEditor(), this._codeBlockPreview.refresh() }, i.show = function (t) { if (e.prototype.show.call(this), !t) throw new Error("should be called with codeBlockElement"); this._load(t) }, i.hide = function () { this.setFitToWindow(!1), this._codeBlockEditor && this._codeBlockEditor.clear(), this._codeBlockPreview && this._codeBlockPreview.clear(), this._codeBlockElement = null, e.prototype.hide.call(this) }, r }(hi); function Hi(e, t, n) { return t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e } var Fi = ['
        ', '
        ', '
        ', '
        ', "
        "].join(""), Ui = function () { function e(e) { Hi(this, "name", "default"), Hi(this, "el", void 0), Hi(this, "_toolbar", void 0), Hi(this, "_container", void 0), Hi(this, "_editorSection", void 0), Hi(this, "_initialEditType", void 0), Hi(this, "_editor", void 0), Hi(this, "_markdownTabSection", void 0), Hi(this, "_markdownTab", void 0), Hi(this, "_modeSwitch", void 0), Hi(this, "_popups", []), this._editor = e, this._initialEditType = e.options.initialEditType, this._init(e.options), this._initEvent() } var t = e.prototype; return t._init = function (e) { var t = e.el, n = e.toolbarItems, r = e.hideModeSwitch; this.el = St.createElementWith(Fi, t), this._container = t, this._editorSection = this.el.querySelector(".te-editor-section"), this._editorSection.appendChild(this._editor.layout.getEditorEl()), this._initToolbar(this._editor.eventManager, n), this._initModeSwitch(this._editor.eventManager, r), this._initPopupAddLink(), this._initPopupAddImage(), this._initPopupAddTable(), this._initPopupAddHeading(), this._initPopupTableUtils(), this._initPopupCodeBlockLanguages(), this._initPopupCodeBlockEditor(), this._initMarkdownTab() }, t._initEvent = function () { this._editor.eventManager.listen("hide", this.hide.bind(this)), this._editor.eventManager.listen("show", this.show.bind(this)), this._editor.eventManager.listen("changeMode", this._markdownTabControl.bind(this)), this._editor.eventManager.listen("changePreviewStyle", this._markdownTabControl.bind(this)) }, t._initToolbar = function (e, t) { var n = new vi(e, t); this._toolbar = n, this.el.querySelector(".te-toolbar-section").appendChild(n.el) }, t._initModeSwitch = function (e, t) { var n = this, r = this.el.querySelector(".te-mode-switch-section"), i = "markdown" === this._initialEditType ? _i.TYPE.MARKDOWN : _i.TYPE.WYSIWYG, o = new _i(r, i, e); this._modeSwitch = o, t && o.hide(), o.on("modeSwitched", (function (e) { return n._editor.changeMode(e) })) }, t._initMarkdownTab = function () { var e = this._editor; this._markdownTab = new yi({ initName: Wr.get("Write"), items: [Wr.get("Write"), Wr.get("Preview")], sections: [e.layout.getMdEditorContainerEl(), e.layout.getPreviewEl()] }), this._markdownTabSection = this.el.querySelector(".te-markdown-tab-section"), this._markdownTabSection.appendChild(this._markdownTab.el), this._markdownTab.on("itemClick", (function (t) { t === Wr.get("Preview") ? (e.eventManager.emit("previewNeedsRefresh"), e.eventManager.emit("changePreviewTabPreview"), e.eventManager.emit("closeAllPopup")) : (e.getCodeMirror().focus(), e.eventManager.emit("changePreviewTabWrite")) })) }, t._markdownTabControl = function () { this._editor.isMarkdownMode() && "tab" === this._editor.getCurrentPreviewStyle() ? (h()(this._markdownTabSection, { display: "block" }), this._markdownTab.activate(Wr.get("Write"))) : h()(this._markdownTabSection, { display: "none" }) }, t._initPopupAddLink = function () { this._popups.push(new Ei({ target: this.el, editor: this._editor })) }, t._initPopupAddImage = function () { this._popups.push(new xi({ target: this.el, eventManager: this._editor.eventManager })) }, t._initPopupAddTable = function () { this._popups.push(new ki({ target: this._toolbar.el, eventManager: this._editor.eventManager, button: this.el.querySelector("button.tui-table"), css: { position: "absolute" } })) }, t._initPopupAddHeading = function () { this._popups.push(new Li({ target: this._toolbar.el, eventManager: this._editor.eventManager, button: this.el.querySelector("button.tui-heading"), css: { position: "absolute" } })) }, t._initPopupTableUtils = function () { var e = this; this._editor.eventManager.listen("contextmenu", (function (t) { St.parents(t.data.target, "[contenteditable=true] table").length > 0 && (t.data.preventDefault(), e._editor.eventManager.emit("openPopupTableUtils", t.data)) })), this._popups.push(new Si({ target: this.el, eventManager: this._editor.eventManager })) }, t._initPopupCodeBlockLanguages = function () { var e = this._editor; this._popups.push(new Ai({ target: this.el, eventManager: e.eventManager, languages: e.codeBlockLanguages })) }, t._initPopupCodeBlockEditor = function () { this._popups.push(new Pi({ target: this.el, eventManager: this._editor.eventManager, convertor: this._editor.convertor, languages: this._editor.codeBlockLanguages })) }, t.getToolbar = function () { return this._toolbar }, t.setToolbar = function (e) { this._toolbar.destroy(), this._toolbar = e }, t.getModeSwitch = function () { return this._modeSwitch }, t.getEditorSectionHeight = function () { var e = this._editorSection.getBoundingClientRect(); return e.bottom - e.top }, t.getEditorHeight = function () { var e = this._container.getBoundingClientRect(); return e.bottom - e.top }, t.getPopupTableUtils = function () { var e; return this._popups.forEach((function (t) { t instanceof Si && (e = t) })), e }, t.hide = function () { p()(this.el, "te-hide") }, t.show = function () { m()(this.el, "te-hide") }, t.remove = function () { St.remove(this.el), this._markdownTab.remove(), this._modeSwitch.remove(), this._toolbar.destroy(), this._popups.forEach((function (e) { return e.remove() })), this._popups = [], ei.hide() }, t.createPopup = function (e) { return new hi(e) }, e }(); function Wi(e, t, n) { var r, i = t.match(/^(\s*)((?:.|\n)*\S)(\s*)$/m), o = i[1], a = i[2], s = i[3]; if (function (e) { var t = St.isElemNode, n = St.isTextNode, r = n(e.previousSibling) && t(e.firstChild), i = n(e.nextSibling) && t(e.lastChild); return !r && !i }(e)) r = "" + n + a + n; else { var l = e.nodeName.toLowerCase(); r = "<" + l + ">" + a + "" } return "" + o + r + s } var qi = Mr.a.Renderer.factory(Mr.a.gfmRenderer, { "EM, I": function (e, t) { return this.isEmptyText(t) ? "" : Wi(e, t, "*") }, "STRONG, B": function (e, t) { return this.isEmptyText(t) ? "" : Wi(e, t, "**") }, "DEL, S": function (e, t) { return this.isEmptyText(t) ? "" : Wi(e, t, "~~") } }), zi = function (e, t) { var n = t.length; return e.substr(n, e.length - 2 * n) }, ji = function (e, t) { return "" + t + e + t }, Vi = function (e, t, n, r, i) { var o = function (e, t) { var n, r = e.start, i = e.end; r.ch >= t && (n = { from: { line: r.line, ch: r.ch - t }, to: { line: i.line, ch: i.ch + t } }); return n }(t, n), a = !1; if (o) { var s = o.from, l = o.to, c = e.getRange(s, l); r(c) && (e.setSelection(s, l), e.replaceSelection(i(c), "around"), a = !0) } return a }, Ki = function (e, t, n, r) { var i = !1; return n(t) && (e.replaceSelection(r(t), "around"), i = !0), i }, Gi = function (e, t, n, r, i) { var o = e.getCursor(), a = o.line, s = o.ch, l = e.getSelection(), c = n.length, u = function (e) { return r.test(e) }; if (!Vi(e, t, c, u, (function (e) { return zi(e, n) })) && !Ki(e, l, u, (function (e) { return zi(e, n) }))) { var d = l.replace(i, "$1"); e.replaceSelection(ji(d, n), "around") } var h = e.getSelection(), f = s; l || (u(h) ? f += c : f -= c, e.setCursor(a, f)) }, $i = /^(\*{2}|_{2}).*\1$/, Yi = /[*_]{2,}([^*_]*)[*_]{2,}/g, Xi = Sr.command("markdown", { name: "Bold", keyMap: ["CTRL+B", "META+B"], exec: function (e) { var t = e.getEditor(), n = t.getDoc(), r = e.getRange(); Gi(n, r, "**", $i, Yi), t.focus() } }), Zi = /^(\*{3}|_{3}).*\1$/, Qi = /^(\*{2}|_{2}).*\1$/, Ji = /^(\*|_).*\1$/, eo = /([^*_])[*_]([^*_]+)[*_]([^*_])/g, to = function (e) { return Zi.test(e) }, no = function (e) { return Qi.test(e) }, ro = function (e) { return Ji.test(e) }, io = "*".length, oo = "**".length, ao = "***".length, so = function (e) { return e ? e.replace(eo, "$1$2$3") : "" }, lo = Sr.command("markdown", { name: "Italic", keyMap: ["CTRL+I", "META+I"], exec: function (e) { var t = e.getEditor(), n = t.getDoc(), r = n.getCursor(), i = r.line, o = r.ch, a = e.getRange(), s = n.getSelection(); if (s)(function (e, t, n) { var r = Vi.bind(this, e, n); return r(ao, to, (function (e) { return zi(e, "*") })) || r(oo, no, (function (e) { return ji(so(e), "*") })) || r(io, ro, (function (e) { return zi(e, "*") })) || Ki(e, t, to, (function (e) { return zi(e, "*") })) || Ki(e, t, no, (function (e) { return ji(so(e), "*") })) || Ki(e, t, ro, (function (e) { return zi(e, "*") })) })(n, s, a) || n.replaceSelection(ji(so(s), "*"), "around"); else { ! function (e, t) { Vi(e, t, ao, to, (function (e) { return zi(e, "*") })) || Vi(e, t, oo, no, (function (e) { return ji(e, "*") })) || Vi(e, t, io, ro, (function () { return "" })) || e.replaceSelection("**", "around") }(n, a); var l = n.getSelection(), c = o; to(l) || ro(l) && !no(l) ? c += io : c -= io, n.setCursor(i, c) } t.focus() } }), co = /^~~.*~~$/, uo = /~~([^~]*)~~/g, ho = Sr.command("markdown", { name: "Strike", keyMap: ["CTRL+S", "META+S"], exec: function (e) { var t = e.getEditor(), n = t.getDoc(), r = e.getRange(); Gi(n, r, "~~", co, uo), t.focus() } }), fo = /^> ?/, po = Sr.command("markdown", { name: "Blockquote", keyMap: ["ALT+Q", "ALT+Q"], exec: function (e) { var t, n = e.getEditor(), r = n.getDoc(), i = e.getCurrentRange(), o = { line: i.from.line, ch: 0 }, a = { line: i.to.line, ch: r.getLineHandle(i.to.line).text.length }, s = r.getRange(o, a).split("\n"), l = this._haveBlockquote(s); if (t = l ? this._removeBlockquote(s) : this._addBlockquote(s), r.replaceRange(t.join("\n"), o, a), l) { var c = s.length; this._isBlockquoteWithSpace(s[c - 1]) ? i.to.ch -= 2 : i.to.ch -= 1 } else i.to.ch += 2; r.setCursor(i.to), n.focus() }, _haveBlockquote: function (e) { for (var t = 0; t < e.length; t += 1) if (!fo.test(e[t])) return !1; return !0 }, _addBlockquote: function (e) { return e.map((function (e) { return "> " + e })) }, _removeBlockquote: function (e) { return e.map((function (e) { return e.replace(fo, "") })) }, _isBlockquoteWithSpace: function (e) { return /^> /.test(e) } }), go = /^#+\s/g; var mo = Sr.command("markdown", { name: "Heading", exec: function (e, t) { var n = e.getEditor(), r = n.getDoc(), i = e.getCurrentRange(), o = { line: i.from.line, ch: 0 }, a = { line: i.to.line, ch: r.getLineHandle(i.to.line).text.length }, s = r.getLine(a.line).length, l = r.getRange(o, a).split("\n"); Qe()(l).forEach((function (e, n) { l[n] = function (e, t) { var n = e.match(go), r = ""; do { r += "#", t -= 1 } while (t > 0); if (n) { var i = e.split(n[0]); e = i[1] } return r + " " + e }(e, t) })), r.replaceRange(l.join("\n"), o, a), i.to.ch += r.getLine(a.line).length - s, r.setSelection(o, i.to), n.focus() } }); var vo = Sr.command("markdown", { name: "Paragraph", exec: function (e) { var t = e.getEditor(), n = t.getDoc(), r = e.getCurrentRange(), i = { line: r.from.line, ch: 0 }, o = { line: r.to.line, ch: n.getLineHandle(r.to.line).text.length }, a = n.getLine(o.line).length, s = n.getRange(i, o).split("\n"); Qe()(s).forEach((function (e, t) { s[t] = e.replace(/^(#{1,6}| *((?:\*|-|\d\.)(?: \[[ xX]])?)) /, "") })), n.replaceRange(s.join("\n"), i, o), r.to.ch += n.getLine(o.line).length - a, n.setSelection(i, o), t.focus() } }), yo = Sr.command("markdown", { name: "HR", keyMap: ["CTRL+L", "META+L"], exec: function (e) { var t = e.getEditor(), n = t.getDoc(), r = "", i = e.getCurrentRange(), o = { line: i.from.line, ch: i.from.ch }, a = { line: i.to.line, ch: i.to.ch }; i.collapsed && (r = n.getLine(o.line), o.ch = 0, a.ch = n.getLineHandle(i.to.line).text.length), n.getLine(o.line).length ? r += "\n\n* * *\n\n" : r += "\n* * *\n", n.replaceRange(r, o, a), t.focus() } }), bo = kr.decodeURIGraceful, Co = kr.encodeMarkdownCharacters, wo = /!\[.*\]\(.*\)/g, _o = /\(|\)|\[|\]|<|>/g; var To = Sr.command("markdown", { name: "AddLink", exec: function (e, t) { var n = e.getEditor(), r = n.getDoc(), i = e.getCurrentRange(), o = { line: i.from.line, ch: i.from.ch }, a = { line: i.to.line, ch: i.to.ch }, s = t.linkText, l = t.url, c = "[" + (s = function (e) { for (var t = [], n = wo.exec(e); n;) { var r = n.index; t.push([r, r + n[0].length]), n = wo.exec(e) } return e.replace(_o, (function (e, n) { return t.some((function (e) { return n > e[0] && n < e[1] })) ? e : "\\" + e })) }(s = bo(s))) + "](" + (l = Co(l)) + ")"; r.replaceRange(c, o, a), n.focus() } }), Eo = kr.decodeURIGraceful, xo = kr.encodeMarkdownCharacters, So = kr.escapeMarkdownCharacters, No = Sr.command("markdown", { name: "AddImage", exec: function (e, t) { var n = e.getEditor(), r = n.getDoc(), i = e.getCurrentRange(), o = { line: i.from.line, ch: i.from.ch }, a = { line: i.to.line, ch: i.to.ch }, s = t.altText, l = t.imageUrl; s = Eo(s); var c = "![" + (s = So(s)) + "](" + (l = xo(l)) + ")"; r.replaceRange(c, o, a, "+addImage"), n.focus() } }), ko = Sr.command("markdown", { name: "UL", keyMap: ["CTRL+U", "META+U"], exec: function (e) { var t = e.getCurrentRange(); e.componentManager.getManager("list").changeSyntax(t, "ul") } }), Lo = Sr.command("markdown", { name: "OL", keyMap: ["CTRL+O", "META+O"], exec: function (e) { var t = e.getCurrentRange(); e.componentManager.getManager("list").changeSyntax(t, "ol") } }), Mo = Sr.command("markdown", { name: "Indent", exec: function (e) { e.getEditor().execCommand("indentOrderedList") } }), Ao = Sr.command("markdown", { name: "Outdent", exec: function (e) { e.getEditor().execCommand("indentLessOrderedList") } }); var Bo = Sr.command("markdown", { name: "Table", exec: function (e, t, n, r) { var i = e.getEditor(), o = i.getDoc(), a = "\n"; i.getCursor().ch > 0 && (a += "\n"), a += function (e, t) { var n = "|", r = "|", i = 0; for (; e;) t ? (n += " " + t[i] + " |", i += 1) : n += " |", r += " --- |", e -= 1; return n + "\n" + r + "\n" }(t, r), a += function (e, t, n) { for (var r = "", i = e, o = 0; o < t; o += 1) { r += "|"; for (var a = 0; a < e; a += 1) n ? (r += " " + n[i] + " |", i += 1) : r += " |"; r += "\n" } return r = r.replace(/\n$/g, "") }(t, n - 1, r), o.replaceSelection(a), r || i.setCursor(i.getCursor().line - n, 2), e.focus() } }), Oo = Sr.command("markdown", { name: "Task", keyMap: ["ALT+T", "ALT+T"], exec: function (e) { var t = e.getCurrentRange(); e.componentManager.getManager("list").changeSyntax(t, "task") } }), Do = /^`([^`]+)`$/, Io = /`([^`]+)`/g, Ro = Sr.command("markdown", { name: "Code", keyMap: ["SHIFT+CTRL+C", "SHIFT+META+C"], exec: function (e) { var t, n = e.getEditor(), r = n.getDoc(), i = r.getSelection(), o = n.getCursor(), a = this.hasStrikeSyntax(i); a ? (t = this.remove(i), t = this._removeCodeSyntax(t)) : (t = this._removeCodeSyntax(i), t = this.append(t)), r.replaceSelection(t, "around"), i || a || this.setCursorToCenter(r, o, a), n.focus() }, setCursorToCenter: function (e, t, n) { var r = n ? -1 : 1; e.setCursor(t.line, t.ch + r) }, hasStrikeSyntax: function (e) { return Do.test(e) }, append: function (e) { return "`" + e + "`" }, remove: function (e) { return e.substr(1, e.length - 2) }, _removeCodeSyntax: function (e) { return e ? e.replace(Io, "$1") : "" } }), Po = Sr.command("markdown", { name: "CodeBlock", keyMap: ["SHIFT+CTRL+P", "SHIFT+META+P"], exec: function (e) { var t = e.getEditor(), n = t.getDoc(), r = e.getCurrentRange(), i = ["```", n.getSelection(), "```"], o = 1; 0 !== r.from.ch && (i.unshift(""), o += 1), r.to.ch !== n.getLine(r.to.line).length && i.push(""), n.replaceSelection(i.join("\n")), t.setCursor(r.from.line + o, 0), t.focus() } }), Ho = /^\[(\s*)(x?)(\s*)\](?:\s+)/i, Fo = Sr.command("markdown", { name: "ChangeTaskMarker", exec: function (e) { var t = e.getEditor(), n = t.getCursor(), r = n.line, i = n.ch, o = t.getLine(r).length === i ? i : i + 1, a = we(e.getToastMark().findNodeAtPosition([r + 1, o]), (function (e) { return "paragraph" === e.type && e.parent && "item" === e.parent.type })); if (a && a.firstChild) { var s = a.firstChild, l = s.literal, c = s.sourcepos[0], u = c[0], d = c[1], h = l.match(Ho); if (h) { var f = h[1], p = h[2], g = h[3], m = f.length + g.length, v = { line: u - 1, ch: d }; p ? t.replaceRange(p, v, _e(v, m ? m + 1 : 0)) : m || t.replaceRange(" ", v, v) } } } }), Uo = Sr.command("markdown", { name: "ToggleTaskMarker", exec: function (e) { var t = this, n = e.getEditor(); n.listSelections().forEach((function (r) { for (var i, o = r.anchor, a = r.head, s = Math.min(o.line, a.line), l = Math.max(o.line, a.line); s <= l; s += 1) "list" !== (i = e.getToastMark().findFirstNodeAtLine(s + 1)).type && "item" !== i.type || t._changeTaskState(i, s, n) })) }, _changeTaskState: function (e, t, n) { var r = e.listData, i = e.sourcepos, o = r.task, a = r.checked, s = r.padding; if (o) { var l = a ? " " : "x", c = { line: t, ch: i[0][1] + s }; n.replaceRange(l, c, _e(c, 1)) } } }), Wo = Sr.command("markdown", { name: "MoveNextCursorOrIndent", exec: function (e) { var t = e.getEditor(), n = t.getCursor(), r = n.line, i = n.ch, o = t.getLine(r).length === i ? i : i + 1, a = we(e.getToastMark().findNodeAtPosition([r + 1, o]), (function (e) { return Ce(e) })); a ? this._moveCursorNextCell(a, t) : t.execCommand("indentOrderedList") }, _moveCursorNextCell: function (e, t) { var n = e.next, r = e.parent, i = ge(e), o = ye(e) + 2; if (n) o = ye(n); else { var a = r.next || "tableHead" !== r.parent.type ? r.next : r.parent.next.firstChild; a && (i += 1, o = ye(a.firstChild)) } t.setCursor({ line: i - 1, ch: o - 1 }) } }), qo = Sr.command("markdown", { name: "MovePrevCursorOrOutdent", exec: function (e) { var t = e.getEditor(), n = t.getCursor(), r = n.line, i = n.ch, o = t.getLine(r).length === i ? i : i + 1, a = we(e.getToastMark().findNodeAtPosition([r + 1, o]), (function (e) { return Ce(e) })); a ? this._moveCursorPrevCell(a, t) : t.execCommand("indentLessOrderedList") }, _moveCursorPrevCell: function (e, t) { var n = e.prev, r = e.parent, i = ge(e), o = 1; if (n) o = ye(n); else { var a = r.prev || "tableBody" !== r.parent.type ? r.prev : r.parent.prev.lastChild; a && (i -= 1, o = ye(a.lastChild)) } t.setCursor({ line: i - 1, ch: o - 1 }) } }); var zo = Sr.command("markdown", { name: "AddLine", exec: function (e) { var t = e.getEditor(), n = t.getCursor(), r = n.line, i = n.ch, o = t.getLine(r).length === i ? i : i + 1, a = we(e.getToastMark().findNodeAtPosition([r + 1, o]), (function (e) { return Ce(e) && ("tableDelimRow" === e.parent.type || "tableBody" === e.parent.parent.type) })); a ? this._addTableRowByCell(a, t) : t.execCommand("newlineAndIndentContinueMarkdownList") }, _addTableRowByCell: function (e, t) { var n = ge(e), r = e.parent, i = r.next, o = t.getLine(n - 1), a = function (e) { for (var t = e.parent.parent.columns.length, n = "|", r = 0; r < t; r += 1) n += " |"; return n }(r); i && "tableRow" === i.type || o !== a ? (t.setCursor(n - 1, ye(r)), t.replaceSelection("\n" + a), t.setCursor(n, 2)) : t.execCommand("deleteLine") } }); function jo(e) { e.hasFormat("b") || e.hasFormat("strong") ? e.changeFormat(null, { tag: "b" }) : e.hasFormat("PRE") || (e.hasFormat("code") && e.changeFormat(null, { tag: "code" }), e.bold()) } var Vo = Sr.command("wysiwyg", { name: "Bold", keyMap: ["CTRL+B", "META+B"], exec: function (e) { var t = e.getEditor(), n = e.componentManager.getManager("tableSelection"); if (e.focus(), t.hasFormat("table") && n.getSelectedCells().length) { n.styleToSelectedCells(jo); var r = t.getSelection(); r.collapse(!0), t.setSelection(r) } else jo(t), St.optimizeRange(t.getSelection(), "B") } }); function Ko(e) { e.hasFormat("i") || e.hasFormat("em") ? e.changeFormat(null, { tag: "i" }) : e.hasFormat("PRE") || (e.hasFormat("code") && e.changeFormat(null, { tag: "code" }), e.italic()) } var Go = Sr.command("wysiwyg", { name: "Italic", keyMap: ["CTRL+I", "META+I"], exec: function (e) { var t = e.getEditor(), n = e.componentManager.getManager("tableSelection"); if (e.focus(), t.hasFormat("table") && n.getSelectedCells().length) { n.styleToSelectedCells(Ko); var r = t.getSelection(); r.collapse(!0), t.setSelection(r) } else Ko(t), St.optimizeRange(t.getSelection(), "I") } }); function $o(e) { e.hasFormat("S") ? e.changeFormat(null, { tag: "S" }) : e.hasFormat("PRE") || (e.hasFormat("code") && e.changeFormat(null, { tag: "code" }), e.strikethrough()) } var Yo = Sr.command("wysiwyg", { name: "Strike", keyMap: ["CTRL+S", "META+S"], exec: function (e) { var t = e.getEditor(), n = e.componentManager.getManager("tableSelection"); if (e.focus(), t.hasFormat("table") && n.getSelectedCells().length) { n.styleToSelectedCells($o); var r = t.getSelection(); r.collapse(!0), t.setSelection(r) } else $o(t), St.optimizeRange(t.getSelection(), "S") } }), Xo = Sr.command("wysiwyg", { name: "Blockquote", keyMap: ["ALT+Q", "ALT+Q"], exec: function (e) { var t = e.getEditor(); e.focus(), t.hasFormat("TABLE") || t.hasFormat("PRE") || (t.hasFormat("BLOCKQUOTE") ? t.decreaseQuoteLevel() : t.increaseQuoteLevel()) } }), Zo = kr.decodeURIGraceful, Qo = kr.encodeMarkdownCharacters, Jo = Sr.command("wysiwyg", { name: "AddImage", exec: function (e, t) { var n = e.getEditor(), r = t.altText, i = t.imageUrl; r = Zo(r), i = Qo(i), e.focus(), n.hasFormat("PRE") || n.insertImage(i, { alt: r }) } }), ea = kr.decodeURIGraceful, ta = kr.encodeMarkdownCharacters, na = Sr.command("wysiwyg", { name: "AddLink", exec: function (e, t) { var n = e.getEditor(), r = e.getLinkAttribute(), i = t.url, o = t.linkText, a = e.componentManager.getManager("link"); if (o = ea(o), i = ta(i), e.focus(), !n.hasFormat("PRE")) { n.removeAllFormatting(); var s = n.getSelectedText(), l = this._isSelectedImageOnly(n.getSelection()); if (s || l) n.makeLink(i, r); else { var c = n.createElement("A", u()({ href: i }, r)); c.textContent = o, n.insertElement(c) } a.addClassNameToImageLinksInSelection() } }, _isSelectedImageOnly: function (e) { if (!e.collapsed) { var t = e.startContainer, n = e.endContainer; if (t && t === n) return St.isElemNode(t) && "IMG" === t.firstChild.nodeName } return !1 } }), ra = Sr.command("wysiwyg", { name: "HR", keyMap: ["CTRL+L", "META+L"], exec: function (e) { var t = e.getEditor(), n = t.getSelection(); if (n.collapsed && !t.hasFormat("TABLE") && !t.hasFormat("PRE")) { var r = document.createElement("hr"), i = St.getChildNodeByOffset(n.startContainer, n.startOffset), o = St.getTopNextNodeUnder(i, e.getBody()); if (o && !St.isTextNode(o)) for (; o && "false" === o.getAttribute("contenteditable");) o = o.nextSibling; o || (o = St.createEmptyLine(), St.append(e.getBody(), o)), t.modifyBlocks((function (e) { return e.appendChild(r), e })); var a = r.previousSibling; a && St.isTextNode(a) && 0 === St.getTextLength(a) && r.parentNode.removeChild(a), r.parentNode.replaceChild(St.createHorizontalRule(), r), n.selectNodeContents(o), n.collapse(!0), t.setSelection(n), t.saveUndoState(n) } e.focus() } }), ia = Sr.command("wysiwyg", { name: "Heading", exec: function (e, t) { var n = e.getEditor(); e.focus(), n.hasFormat("TABLE") || n.hasFormat("PRE") || n.modifyBlocks((function (e) { var n = St.children(e, "h1, h2, h3, h4, h5, h6, div"); return Qe()(n).forEach((function (e) { var n = "h" + t; if ("DIV" === St.getNodeName(e)) St.wrap(e, n); else { var r = document.createElement(n); St.insertBefore(r, e), r.innerHTML = e.innerHTML, St.remove(e) } })), e })) } }); function oa(e, t) { Qe()(t).forEach((function (t) { e.appendChild(t.cloneNode(!0)) })) } var aa = Sr.command("wysiwyg", { name: "Paragraph", exec: function (e) { var t = e.getEditor(); e.focus(), t.hasFormat("TABLE") || t.hasFormat("PRE") || t.modifyBlocks((function (e) { var t = document.createDocumentFragment(); return Qe()(e.childNodes).forEach((function (e) { e.nodeName.match(/h\d/i) ? oa(t, e.children) : e.nodeName.match(/ul|ol/i) ? St.findAll(e, "li").forEach((function (e) { oa(t, e.children) })) : t.appendChild(e) })), t })) } }), sa = Sr.command("wysiwyg", { name: "UL", keyMap: ["CTRL+U", "META+U"], exec: function (e) { var t = e.getEditor(), n = t.getSelection(), r = e.componentManager.getManager("list"), i = n.startContainer, o = n.endContainer, a = n.startOffset, s = n.endOffset, l = []; if (e.focus(), t.saveUndoState(n), r.isAvailableMakeListInTable()) l = r.createListInTable(n, "UL"); else for (var c = r.getLinesOfSelection(i, o), u = 0; u < c.length; u += 1) { var d = this._changeFormatToUnorderedListIfNeed(e, c[u]); d && l.push(d) } l.length && r.adjustRange(i, o, a, s, l) }, _changeFormatToUnorderedListIfNeed: function (e, t) { var n, r = e.getEditor(), i = r.getSelection(), o = e.componentManager.getManager("task"); return r.hasFormat("PRE") || (i.setStart(t, 0), i.collapse(!0), r.setSelection(i), r.hasFormat("LI") ? (e.saveSelection(i), o.unformatTask(i.startContainer), r.replaceParent(i.startContainer, "ol", "ul"), e.restoreSavedSelection()) : (e.unwrapBlockTag(), r.makeUnorderedList()), n = r.getSelection().startContainer), n } }), la = Sr.command("wysiwyg", { name: "OL", keyMap: ["CTRL+O", "META+O"], exec: function (e) { var t = e.getEditor(), n = t.getSelection(), r = e.componentManager.getManager("list"), i = n.startContainer, o = n.startOffset, a = n.endContainer, s = n.endOffset, l = []; if (e.focus(), t.saveUndoState(n), r.isAvailableMakeListInTable()) l = r.createListInTable(n, "OL"); else for (var c = r.getLinesOfSelection(i, a), u = 0; u < c.length; u += 1) { var d = this._changeFormatToOrderedListIfNeed(e, c[u]); d && l.push(d) } l.length && r.adjustRange(i, a, o, s, l) }, _changeFormatToOrderedListIfNeed: function (e, t) { var n, r = e.getEditor(), i = r.getSelection(), o = e.componentManager.getManager("task"); return r.hasFormat("PRE") || (i.setStart(t, 0), i.collapse(!0), r.setSelection(i), r.hasFormat("LI") ? (e.saveSelection(i), o.unformatTask(i.startContainer), r.replaceParent(i.startContainer, "ul", "ol"), e.restoreSavedSelection()) : (e.unwrapBlockTag(), r.makeOrderedList()), n = r.getSelection().startContainer), n } }); var ca = Sr.command("wysiwyg", { name: "Table", exec: function (e, t, n, r) { var i, o = e.getEditor(), a = e.componentManager.getManager("table").getTableIDClassName(); !o.getSelection().collapsed || o.hasFormat("TABLE") || o.hasFormat("PRE") ? e.focus() : (i = '
    ', i += function (e, t) { var n = "", r = 0; for (; e;) n += "", e -= 1; return n += "" }(t, r), i += function (e, t, n) { for (var r = "", i = e, o = 0; o < t; o += 1) { r += ""; for (var a = 0; a < e; a += 1) r += ""; r += "" } return r += "" }(t, n - 1, r), i += "
    ", t && (n += t[r], r += 1), n += "
    ", n && (r += n[i], i += 1), r += "
    ", o.insertHTML(i), e.focus(), r || function (e, t) { var n = e.getSelection(); n.selectNodeContents(t.querySelector("th")), n.collapse(!0), e.setSelection(n) }(o, e.getBody().querySelector("." + a))) } }); function ua(e) { var t = e.cloneNode(!0), n = Zt.a.msie ? "" : "
    "; return St.findAll(t, "td").forEach((function (e) { e.innerHTML = n })), t } function da(e, t) { var n = e.getSelection(); n.selectNodeContents(t.querySelector("td")), n.collapse(!0), e.setSelection(n) } var ha = Sr.command("wysiwyg", { name: "AddRow", exec: function (e) { var t, n, r = e.getEditor(), i = r.getSelection().cloneRange(), o = function (e) { var t = e.componentManager.getManager("tableSelection"), n = t.getSelectedCells(), r = 1; if (n.length > 1) { var i = n[0], o = n[n.length - 1], a = t.getSelectionRangeFromTable(i, o); r = a.to.row - a.from.row + 1 } return r }(e); if (e.focus(), r.hasFormat("TD")) { r.saveUndoState(i), t = St.closest(i.startContainer, "tr"); for (var a = 0; a < o; a += 1) n = ua(t), St.insertAfter(n, t); da(r, n) } else if (r.hasFormat("TH")) { r.saveUndoState(i), t = St.closest(i.startContainer, "tr"); var s = St.parents(t, "thead")[0].nextSibling; if (nt()(s, "tbody")) t = St.children(s, "tr")[0]; for (var l = 0; l < o; l += 1) n = ua(t), St.insertBefore(n, t); da(r, n) } } }); var fa = Sr.command("wysiwyg", { name: "AddCol", exec: function (e) { var t, n = e.getEditor(), r = n.getSelection().cloneRange(), i = function (e) { var t = e.componentManager.getManager("tableSelection").getSelectedCells(), n = 1; if (t.length > 0) { var r = t[0].parentNode.querySelectorAll("td, th").length; n = Math.min(r, t.length) } return n }(e); e.focus(), n.hasFormat("TR") && (n.saveUndoState(r), function (e, t) { void 0 === t && (t = 1); var n = St.parents(e, "table")[0]; if (n) { var r, i = yr()(e, Qe()(e.parentNode.childNodes)); St.findAll(n, "tr").forEach((function (e) { for (var n = "TBODY" === St.getNodeName(e.parentNode), o = Zt.a.msie, a = e.children[i], s = 0; s < t; s += 1) r = n ? document.createElement("td") : document.createElement("th"), o || r.appendChild(document.createElement("br")), St.insertAfter(r, a) })) } }(t = function (e) { var t = e.startContainer; "TD" !== St.getNodeName(t) && "TH" !== St.getNodeName(t) && (t = St.closest(t, "td, th")); return t }(r), i), function (e, t) { var n = e.getSelection(); n.selectNodeContents(t.nextSibling), n.collapse(!0), e.setSelection(n) }(n, t)) } }); function pa(e, t, n) { var r = n.querySelectorAll("tbody tr").length, i = St.parents(e, "thead").length, o = t.from.row, a = t.to.row; return i && (o += 1), (1 === o || i) && a === r && (a -= 1), St.findAll(n, "tr").slice(o, a + 1) } var ga = Sr.command("wysiwyg", { name: "RemoveRow", exec: function (e) { var t = e.getEditor(), n = t.getSelection().cloneRange(), r = St.parents(n.startContainer, "table")[0], i = e.componentManager.getManager("tableSelection"), o = e.componentManager.getManager("table"), a = function (e, t, n) { var r, i, o = t.getSelectedCells(); if (o.length) r = t.getSelectionRangeFromTable(o[0], o[o.length - 1]), i = pa(o[0], r, n); else { var a = St.closest(e.startContainer, "td,th"); r = t.getSelectionRangeFromTable(a, a), i = pa(a, r, n) } return i }(n, i, r), s = r.querySelectorAll("tbody tr").length; if (e.focus(), (t.hasFormat("TD") || t.hasFormat("TABLE")) && s > 1) { t.saveUndoState(n); var l = a[0], c = a[a.length - 1], u = c && c.nextSibling ? c.nextSibling : l && l.previousSibling; u && function (e, t, n, r) { var i = n.querySelector("td"); t.setStart(i, 0), t.collapse(!0), r.setLastCellNode(i), e.setSelection(t) }(t, n, u, o), a.forEach((function (e) { return St.remove(e) })) } i.removeClassAttrbuteFromAllCellsIfNeed() } }); function ma(e) { var t = St.parents(e, "table")[0]; if (t) { var n = yr()(e, Qe()(e.parentNode.childNodes)); St.findAll(t, "tr").forEach((function (e) { var t = e.children[n]; St.remove(t) })) } } var va = Sr.command("wysiwyg", { name: "RemoveCol", exec: function (e) { var t = e.getEditor(), n = t.getSelection().cloneRange(), r = St.parents(n.startContainer, "table")[0], i = e.componentManager.getManager("table"), o = e.componentManager.getManager("tableSelection"), a = St.closest(n.startContainer, "table").querySelectorAll("thead tr th").length > 1; if (e.focus(), n.collapse(!0), t.setSelection(n), t.hasFormat("TR", null, n) && a) { var s = r.querySelectorAll("tbody tr"), l = s.length ? s[0].querySelectorAll("td").length : 0, c = o.getSelectedCells(); if (c.length < l) { var u; if (t.saveUndoState(n), c.length > 1) { var d = c[c.length - 1], h = c[0]; u = d.nextSibling ? d.nextSibling : h.previousSibling, function (e) { for (var t = e.length, n = 0; n < t; n += 1) { e[n] && ma(e[n]) } }(c) } else { var f = function (e) { var t = e.startContainer; "TD" !== St.getNodeName(t) && "TH" === !St.getNodeName(t) && (t = St.parentsUntil(t, "tr")); return t }(n); u = f.nextSibling ? f.nextSibling : f.previousSibling, ma(f) }! function (e, t, n) { var r = t; if (t && St.isContain(document.body, t)) { var i = e.getSelection(); i.selectNodeContents(t), i.collapse(!0), e.setSelection(i), n.setLastCellNode(r) } }(t, u, i) } } } }); var ya = Sr.command("wysiwyg", { name: "AlignCol", exec: function (e, t) { var n = e.getEditor(), r = n.getSelection().cloneRange(), i = e.componentManager.getManager("tableSelection"), o = function (e, t) { var n, r, i = t.getSelectedCells(); if (i.length) n = t.getSelectionRangeFromTable(i[0], i[i.length - 1]); else { var o = e.startContainer; r = St.isTextNode(o) ? St.parent(o, "td,th") : o, n = t.getSelectionRangeFromTable(r, r) } return n }(r, i); if (e.focus(), n.hasFormat("TR")) { n.saveUndoState(r); var a = St.parents(r.startContainer, "table")[0], s = function (e, t) { var n, r, i, o = e.querySelectorAll("tr"), a = o.length ? o[0].querySelectorAll("td,th").length : 0, s = t.from, l = t.to; s.row === l.row ? (n = s.cell, r = l.cell) : s.row < l.row && (s.cell <= l.cell ? (n = 0, r = a - 1) : (n = s.cell, r = l.cell, i = !0)); return { startColumnIndex: n, endColumnIndex: r, isDivided: i } }(a, o); ! function (e, t, n) { var r = n.isDivided || !1, i = n.startColumnIndex, o = n.endColumnIndex, a = St.findAll(e, "tr"), s = a.length ? a[0].querySelectorAll("td,th").length : 0; a.forEach((function (e) { Qe()(St.children(e, "td,th")).forEach((function (e, n) { (r && (i <= n && n <= s || n <= o) || i <= n && n <= o) && e.setAttribute("align", t) })) })) }(a, t, s) } i.removeClassAttrbuteFromAllCellsIfNeed() } }), ba = Sr.command("wysiwyg", { name: "RemoveTable", exec: function (e) { var t = e.getEditor(), n = t.getSelection().cloneRange(); t.hasFormat("TABLE") && (t.saveUndoState(n), St.remove(St.closest(n.startContainer, "table"))), e.focus() } }), Ca = Sr.command("wysiwyg", { name: "Indent", exec: function (e) { var t, n, r, i = e.componentManager.getManager("list"), o = e.getEditor().getSelection(), a = St.closest(o.startContainer, "li"), s = a && a.previousSibling; if (s) { var l = a.querySelector("li"); if (e.getEditor().saveUndoState(), n = a.className, t = s.className, a.className = "", s.className = "", l) r = l.className, Qe()(l.children).filter((function (e) { return nt()(e, "div") })).length || (l.className = ""); e.getEditor().increaseListLevel(), i.mergeList(a), a.className = n, s.className = t, l && (l.className = r) } } }); function wa(e) { var t = e.getEditor().getSelection(); return St.closest(t.startContainer, "li") } var _a = Sr.command("wysiwyg", { name: "Outdent", exec: function (e) { var t, n, r = wa(e); if (r && (t = r, "OL" !== (n = St.getNodeName(t.nextSibling)) && "UL" !== n)) { e.getEditor().saveUndoState(); var i = r.className; e.getEditor().decreaseListLevel(), (r = wa(e)) && i && (r.className = i) } } }), Ta = Sr.command("wysiwyg", { name: "Task", keyMap: ["ALT+T", "ALT+T"], exec: function (e) { var t = e.getEditor(), n = t.getSelection(), r = e.componentManager.getManager("list"), i = n.startContainer, o = n.endContainer, a = n.startOffset, s = n.endOffset, l = []; if (e.focus(), t.saveUndoState(n), r.isAvailableMakeListInTable()) l = r.createListInTable(n, "TASK"); else for (var c = r.getLinesOfSelection(i, o), u = 0; u < c.length; u += 1) { var d = this._changeFormatToTaskIfNeed(e, c[u]); d && l.push(d) } l.length && r.adjustRange(i, o, a, s, l) }, _changeFormatToTaskIfNeed: function (e, t) { var n, r = e.getEditor(), i = r.getSelection(), o = e.componentManager.getManager("task"); return r.hasFormat("PRE") || (i.setStart(t, 0), i.collapse(!0), r.setSelection(i), r.hasFormat("li") || (r.makeUnorderedList(), t = r.getSelection().startContainer), et()(t, "task-list-item") ? o.unformatTask(t) : o.formatTask(t), n = r.getSelection().startContainer), n } }); function Ea(e, t) { if (!t.hasFormat("PRE") && t.hasFormat("code")) t.changeFormat(null, { tag: "code" }), function (e) { "CODE" === St.getNodeName(e.startContainer.nextSibling) && 0 === St.getTextLength(e.startContainer.nextSibling) && St.remove(e.startContainer.nextSibling) }(e.getSelection().cloneRange()); else if (!t.hasFormat("a") && !t.hasFormat("PRE")) { t.hasFormat("b") ? t.removeBold() : t.hasFormat("i") && t.removeItalic(), t.changeFormat({ tag: "code" }); var n = t.getSelection().cloneRange(); n.setStart(n.endContainer, n.endOffset), n.collapse(!0), t.setSelection(n) } } var xa = Sr.command("wysiwyg", { name: "Code", keyMap: ["SHIFT+CTRL+C", "SHIFT+META+C"], exec: function (e) { var t = e.getEditor(), n = e.componentManager.getManager("tableSelection"), r = Ea.bind(null, e.getEditor()); if (e.focus(), t.hasFormat("table") && n.getSelectedCells().length) { n.styleToSelectedCells(r); var i = t.getSelection(); i.collapse(!0), t.setSelection(i) } else r(t) } }); var Sa = Sr.command("wysiwyg", { name: "CodeBlock", keyMap: ["SHIFT+CTRL+P", "SHIFT+META+P"], exec: function (e, t) { var n = e.getEditor(), r = n.getSelection().cloneRange(); if (!n.hasFormat("PRE") && !n.hasFormat("TABLE")) { var i = 'data-te-codeblock class = "te-content-codeblock-temp"'; t && (i += ' data-language="' + t + '"'); var o = function (e, t) { var n, r = t.componentManager.getManager("codeblock"); if (e.collapsed) n = "
    "; else { var i = e.extractContents(), o = Qe()(i.childNodes), a = document.createElement("div"); a.appendChild(r.prepareToPasteOnCodeblock(o)), n = a.innerHTML } return n }(r, e); n.insertHTML("
    " + o + "
    "), function (e, t) { var n = t.getEditor().getSelection().cloneRange(); m()(e, "te-content-codeblock-temp"), n.setStartBefore(e.firstChild), n.collapse(!0), t.getEditor().setSelection(n) }(e.getBody().querySelector(".te-content-codeblock-temp"), e) } e.focus() } }), Na = null, ka = null; function La(e, t) { var n = t.syncScrollTop, r = t.releaseEventBlock; clearTimeout(ka), n(e), ka = setTimeout((function () { r() }), 15) } function Ma(e, t, n) { var r = t - e, i = Date.now(); ! function o() { var a, s = (Date.now() - i) / 200; Na && clearTimeout(Na), s < 1 ? (a = e + r * Math.cos((1 - s) * Math.PI / 2), La(Math.ceil(a), n), Na = setTimeout(o, 1)) : (La(t, n), Na = null) }() } var Aa = !1, Ba = null; function Oa(e, t) { var n = zt(t), r = n || e.offsetHeight; return n || qt(t, r), r } function Da(e, t, n) { var r = t._previewContent, i = t.el, o = e.cm, a = e.toastMark, s = o.getScrollInfo(), l = s.left, c = s.top, u = s.height - c <= s.clientHeight, d = i.scrollTop, h = u ? i.scrollHeight : 0; if (c && !u) { var f = (n ? o.coordsChar({ left: l, top: c }, "local") : o.getCursor("from")).line, p = a.findFirstNodeAtLine(f + 1); if (!p || function (e) { var t = e.type; return "htmlBlock" === t || "htmlInline" === t }(p)) return; var g = Dt(p), m = g.node, v = g.mdNode, y = ge(v), b = Oa(i, 0); if (h = Pt(m, r) || m.offsetTop, n) { if (Bt(v)) { var C = Oa(m, v.id); if (h += Ot(c, o.heightAtLine(y - 1, "local"), It(v, o), C), h = Ut({ latestScrollTop: Ba, scrollTop: c, targetScrollTop: h, sourceScrollTop: d }), Ba = c, h === d) return } } else { var w = function (e, t, n, r, i) { var o = ge(n), a = e.lineInfo(t).handle.height, s = Oa(i, 0), l = r.getBoundingClientRect().top - i.getBoundingClientRect().top, c = .5 * -s; if (function (e) { var t = e.type; return "codeBlock" === t || "paragraph" === t }(n)) { var u = (t - o + 1) * a; c = u, l += u } return { top: l, additionalScrollTop: c } }(o, f, v, m, i), _ = w.top, T = w.additionalScrollTop; if (_ > 0 && _ < b) return; h += T, Ba = null } } Aa = !0, Ma(d, h, { syncScrollTop: function (e) { return i.scrollTop = e }, releaseEventBlock: function () { return Aa = !1 } }) } var Ia = !1, Ra = null; function Pa(e, t, n) { var r, i = zt(t), o = Wt[r = t] && Wt[r].offsetTop, a = i || e.offsetHeight, s = o || Pt(e, n) || e.offsetTop; return i || qt(t, a), o || function (e, t) { Wt[e] = Wt[e] || {}, Wt[e].offsetTop = t }(t, s), { offsetHeight: a, offsetTop: s } } var Ha = !0; function Fa() { return Ha } function Ua(e) { if (!e.isViewer() && "default" === e.getUI().name) { var t = e.i18n, n = { ACTIVE: t.get("Auto scroll enabled"), INACTIVE: t.get("Auto scroll disabled") }, r = e.getUI().getToolbar(), i = document.createElement("button"); i.className = "tui-scrollsync active", r.addItem("divider"), r.addItem({ type: "button", options: { command: "scrollSyncToggle", tooltip: n.ACTIVE, el: i } }); var o = r.getItems(), a = o[o.length - 2].el, s = o[o.length - 1]; Wa(e, s, a), function (e, t, n) { e.on("changeMode", (function () { return Wa(e, t, n) })), e.on("changePreviewStyle", (function () { return Wa(e, t, n) })) }(e, s, a), function (e, t, n) { e.addCommand("markdown", { name: "scrollSyncToggle", exec: function () { Ha = !Ha, t._onOut(), Ha ? (t.el.className = "tui-scrollsync active", t.setTooltip(n.ACTIVE)) : (t.el.className = "tui-scrollsync", t.setTooltip(n.INACTIVE)), t._onOver() } }) }(e, s, n) } } function Wa(e, t, n) { "vertical" === e.mdPreviewStyle && "markdown" === e.currentMode ? (h()(t.el, { display: "inline-block" }), h()(n, { display: "inline-block" })) : (h()(t.el, { display: "none" }), h()(n, { display: "none" })) } var qa = !0; function za(e) { var t = e.mdEditor, n = e.preview; Ua(e), function (e, t) { e.eventManager.listen("scroll", (function (n) { var r = n.source, i = n.data; Fa() && qa && t.isVisible() && ("markdown" !== r || Ia ? "preview" !== r || Aa || function (e, t, n) { var r = e.toastMark, i = e.cm, o = t.el, a = o.scrollTop, s = o.clientHeight, l = o.scrollHeight, c = t._previewContent, u = l - a <= s, d = i.getScrollInfo(), h = d.left, f = d.top, p = d.height, g = u ? p : 0; if (a && n && !u) { if (!(n = function (e, t) { for (; !e.getAttribute("data-nodeid") && e.parentElement !== t;) e = e.parentElement; return e }(n, c)).getAttribute("data-nodeid")) return; var m = i.coordsChar({ left: h, top: f }, "local").line, v = Number(n.getAttribute("data-nodeid")), y = Dt(r.findNodeById(v)), b = y.mdNode, C = y.node, w = ge(b); if (g = i.heightAtLine(w - 1, "local"), function (e) { return "item" === e.type }(b) && (g += Rt(i, w, m)), Bt(b)) { var _ = It(b, i), T = Pa(C, v, c), E = T.offsetHeight; if (g += Ot(a, T.offsetTop, E, _), g = Ut({ latestScrollTop: Ra, scrollTop: a, targetScrollTop: g, sourceScrollTop: f }), Ra = a, g === f) return } } Ia = !0, Ma(f, g, { syncScrollTop: function (e) { return i.scrollTo(0, e) }, releaseEventBlock: function () { return Ia = !1 } }) }(e, t, i) : Da(e, t, !0)) })) }(t, n), function (e, t) { e.eventManager.listen("previewRenderAfter", (function () { setTimeout((function () { Fa() && Da(e, t), qa = !0 }), 200) })) }(t, n), t.cm.on("change", (function () { return qa = !1 })) } function ja() { return (ja = Object.assign || function (e) { for (var t = 1; t < arguments.length; t++) { var n = arguments[t]; for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]) } return e }).apply(this, arguments) } var Va = [], Ka = function () { function e(e) { var t = this; this.initialHtml = e.el.innerHTML, e.el.innerHTML = "", this.options = u()({ previewStyle: "tab", previewHighlight: !0, initialEditType: "markdown", height: "300px", minHeight: "200px", language: "en-US", useDefaultHTMLSanitizer: !0, useCommandShortcut: !0, usageStatistics: !0, toolbarItems: ["heading", "bold", "italic", "strike", "divider", "hr", "quote", "divider", "ul", "ol", "task", "indent", "outdent", "divider", "table", "image", "link", "divider", "code", "codeblock"], hideModeSwitch: !1, linkAttribute: null, extendedAutolinks: !1, customConvertor: null, customHTMLRenderer: null, referenceDefinition: !1, customHTMLSanitizer: null, frontMatter: !1 }, e), this.codeBlockLanguages = [], this.eventManager = new wr, this.importManager = new kr(this.eventManager), this.commandManager = new Sr(this, { useCommandShortcut: this.options.useCommandShortcut }); var n = k(this.options.linkAttribute), r = Pr(this.options.plugins), o = r.renderer, a = r.parser, s = r.plugins, l = this.options, c = l.customHTMLRenderer, d = l.customHTMLSanitizer, h = l.extendedAutolinks, f = l.referenceDefinition, p = l.useDefaultHTMLSanitizer, g = l.frontMatter, m = { linkAttribute: n, customHTMLRenderer: ja({}, o, c), extendedAutolinks: h, referenceDefinition: f, customParser: a, frontMatter: g, customProp: { showFrontMatter: g } }; this.options.customConvertor ? this.convertor = new this.options.customConvertor(this.eventManager, m) : this.convertor = new Dr(this.eventManager, m); var y = d || (p ? mn : null); y && this.convertor.initHtmlSanitizer(y), this.options.hooks && i()(this.options.hooks, (function (e, n) { return t.addHook(n, e) })), this.options.events && i()(this.options.events, (function (e, n) { return t.on(n, e) })), this.layout = new hr(e, this.eventManager), this.i18n = Wr, this.i18n.setCode(this.options.language), this.setUI(this.options.UI || new Ui(this)), this.toastMark = new v.ToastMark("", { disallowedHtmlBlockTags: ["br"], extendedAutolinks: h, referenceDefinition: f, disallowDeepHeading: !0, customParser: a, frontMatter: g }), this.mdEditor = ze.factory(this.layout.getMdEditorContainerEl(), this.eventManager, this.toastMark, this.options), this.preview = new Vt(this.layout.getPreviewEl(), this.eventManager, this.convertor, ja({}, m, { isViewer: !1, highlight: this.options.previewHighlight })), this.wwEditor = ur.factory(this.layout.getWwEditorContainerEl(), this.eventManager, { sanitizer: y, linkAttribute: n }), this.toMarkOptions = { gfm: !0, renderer: qi }, s && Rr(s, this), this.changePreviewStyle(this.options.previewStyle), this.changeMode(this.options.initialEditType, !0), this.minHeight(this.options.minHeight), this.height(this.options.height), this.setMarkdown(this.options.initialValue, !1), this.options.placeholder && this.setPlaceholder(this.options.placeholder), this.options.initialValue || this.setHtml(this.initialHtml, !1), this.eventManager.emit("load", this), Va.push(this), this._addDefaultCommands(), this.options.usageStatistics && E()("editor", "UA-129966929-1"), za(this) } var t = e.prototype; return t.changePreviewStyle = function (e) { this.layout.changePreviewStyle(e), this.mdPreviewStyle = e, this.eventManager.emit("changePreviewStyle", e), this.eventManager.emit("previewNeedsRefresh", this.getMarkdown()) }, t.exec = function () { var e; (e = this.commandManager).exec.apply(e, arguments) }, t._addDefaultCommands = function () { this.addCommand(Xi), this.addCommand(lo), this.addCommand(po), this.addCommand(mo), this.addCommand(vo), this.addCommand(yo), this.addCommand(To), this.addCommand(No), this.addCommand(ko), this.addCommand(Lo), this.addCommand(Mo), this.addCommand(Ao), this.addCommand(Bo), this.addCommand(Oo), this.addCommand(Ro), this.addCommand(Po), this.addCommand(ho), this.addCommand(Fo), this.addCommand(Uo), this.addCommand(Wo), this.addCommand(qo), this.addCommand(zo), this.addCommand(Vo), this.addCommand(Go), this.addCommand(Xo), this.addCommand(sa), this.addCommand(la), this.addCommand(Jo), this.addCommand(na), this.addCommand(ra), this.addCommand(ia), this.addCommand(aa), this.addCommand(Ca), this.addCommand(_a), this.addCommand(Ta), this.addCommand(ca), this.addCommand(ha), this.addCommand(fa), this.addCommand(ga), this.addCommand(va), this.addCommand(ya), this.addCommand(ba), this.addCommand(xa), this.addCommand(Sa), this.addCommand(Yo) }, t.addCommand = function (e, t) { t ? this.commandManager.addCommand(Sr.command(e, t)) : this.commandManager.addCommand(e) }, t.afterAddedCommand = function () { this.eventManager.emit("afterAddedCommand", this) }, t.on = function (e, t) { this.eventManager.listen(e, t) }, t.off = function (e) { this.eventManager.removeEventHandler(e) }, t.addHook = function (e, t) { this.eventManager.removeEventHandler(e), this.eventManager.listen(e, t) }, t.removeHook = function (e) { this.eventManager.removeEventHandler(e) }, t.getCodeMirror = function () { return this.mdEditor.getEditor() }, t.getSquire = function () { return this.wwEditor.getEditor() }, t.focus = function () { this.getCurrentModeEditor().focus() }, t.blur = function () { this.getCurrentModeEditor().blur() }, t.moveCursorToEnd = function () { this.getCurrentModeEditor().moveCursorToEnd() }, t.moveCursorToStart = function () { this.getCurrentModeEditor().moveCursorToStart() }, t.setMarkdown = function (e, t) { void 0 === t && (t = !0), e = e || "", this.isMarkdownMode() ? this.mdEditor.setValue(e, t) : this.wwEditor.setValue(this.convertor.toHTML(e), t), this.eventManager.emit("setMarkdownAfter", e) }, t.setHtml = function (e, t) { if (void 0 === t && (t = !0), e = e || "", this.wwEditor.setValue(e, t), this.isMarkdownMode()) { var n = this.convertor.toMarkdown(this.wwEditor.getValue(), this.toMarkOptions); this.mdEditor.setValue(n, t), this.eventManager.emit("setMarkdownAfter", n) } }, t.getMarkdown = function () { return this.isMarkdownMode() ? this.mdEditor.getValue() : this.convertor.toMarkdown(this.wwEditor.getValue(), this.toMarkOptions) }, t.getHtml = function () { return this.isWysiwygMode() && this.mdEditor.setValue(this.convertor.toMarkdown(this.wwEditor.getValue(), this.toMarkOptions)), this.convertor.toHTML(this.mdEditor.getValue()) }, t.insertText = function (e) { this.isMarkdownMode() ? this.mdEditor.replaceSelection(e) : this.wwEditor.insertText(e) }, t.addWidget = function (e, t, n, r) { this.getCurrentModeEditor().addWidget(e, t, n, r) }, t.height = function (e) { if (a()(e)) { var t = this.options.el; "auto" === e ? (p()(t, "auto-height"), this.minHeight(this.minHeight())) : (m()(t, "auto-height"), this.minHeight(e)), l()(e) && (e += "px"), h()(this.options.el, { height: e }), this._height = e } return this._height }, t.minHeight = function (e) { if (a()(e)) { var t = this._ui.getEditorHeight() - this._ui.getEditorSectionHeight(); this._minHeight = e, e = parseInt(e, 10), e = Math.max(e - t, 0), this.wwEditor.setMinHeight(e), this.mdEditor.setMinHeight(e), this.preview.setMinHeight(e) } return this._minHeight }, t.getCurrentModeEditor = function () { return this.isMarkdownMode() ? this.mdEditor : this.wwEditor }, t.isMarkdownMode = function () { return "markdown" === this.currentMode }, t.isWysiwygMode = function () { return "wysiwyg" === this.currentMode }, t.isViewer = function () { return !1 }, t.getCurrentPreviewStyle = function () { return this.mdPreviewStyle }, t.changeMode = function (e, t) { this.currentMode !== e && (this.eventManager.emit("changeModeBefore", this.currentMode), this.currentMode = e, this.isWysiwygMode() ? (this.layout.switchToWYSIWYG(), this.wwEditor.setValue(this.convertor.toHTML(this.mdEditor.getValue()), !t), this.eventManager.emit("changeModeToWysiwyg")) : (this.layout.switchToMarkdown(), this.mdEditor.resetState(), this.mdEditor.setValue(this.convertor.toMarkdown(this.wwEditor.getValue(), this.toMarkOptions), !t), this.getCodeMirror().refresh(), this.eventManager.emit("changeModeToMarkdown")), this.eventManager.emit("changeMode", e), t || this.focus()) }, t.remove = function () { var e = this, t = Va.length - 1; for (this.wwEditor.remove(), this.mdEditor.remove(), this.layout.remove(), this.preview.remove(), this.getUI() && this.getUI().remove(), this.eventManager.emit("removeEditor"), this.eventManager.events.forEach((function (t, n) { e.off(n) })), this.eventManager = null; t >= 0; t -= 1) Va[t] === this && Va.splice(t, 1) }, t.hide = function () { this.eventManager.emit("hide", this) }, t.show = function () { this.eventManager.emit("show", this), this.getCodeMirror().refresh() }, t.scrollTop = function (e) { return this.getCurrentModeEditor().scrollTop(e) }, t.setUI = function (e) { this._ui = e }, t.getUI = function () { return this._ui }, t.reset = function () { this.wwEditor.reset(), this.mdEditor.reset() }, t.getRange = function () { return this.getCurrentModeEditor().getRange() }, t.getTextObject = function (e) { return this.getCurrentModeEditor().getTextObject(e) }, t.getSelectedText = function () { var e = this.getRange(); return this.getTextObject(e).getTextContent() || "" }, t.setPlaceholder = function (e) { this.mdEditor.setPlaceholder(e), this.wwEditor.setPlaceholder(e) }, t.setCodeBlockLanguages = function (e) { var t = this; void 0 === e && (e = []), e.forEach((function (e) { t.codeBlockLanguages.indexOf(e) < 0 && t.codeBlockLanguages.push(e) })), this.eventManager.emit("setCodeBlockLanguages", this.codeBlockLanguages) }, e.getInstances = function () { return Va }, e.factory = function (t) { return t.viewer ? new Ur(t) : new e(t) }, e.setLanguage = function (e, t) { Wr.setLanguage(e, t) }, e }(); Ka._createMarkdownToHTML = function (e) { var t = e.extendedAutolinks, n = e.customHTMLRenderer, r = e.referenceDefinition, i = e.customParser, o = e.frontMatter, a = new v.Parser({ disallowedHtmlBlockTags: ["br"], extendedAutolinks: t, referenceDefinition: r, disallowDeepHeading: !0, customParser: i, frontMatter: o }), s = Object(v.createRenderHTML)({ gfm: !0, convertors: C(null, n) }); return function (e) { return s(a.parse(e)) } }, Ka.isViewer = !1, Ka.codeBlockManager = Nt, Ka.WwCodeBlockManager = jn, Ka.WwTableManager = Mn, Ka.WwTableSelectionManager = An, Ka.CommandManager = Sr; var Ga = Ka; n(39), n(40), n(41), n(42); Ga.setLanguage(["en", "en-US"], { Markdown: "Markdown", WYSIWYG: "WYSIWYG", Write: "Write", Preview: "Preview", Headings: "Headings", Paragraph: "Paragraph", Bold: "Bold", Italic: "Italic", Strike: "Strike", Code: "Inline code", Line: "Line", Blockquote: "Blockquote", "Unordered list": "Unordered list", "Ordered list": "Ordered list", Task: "Task", Indent: "Indent", Outdent: "Outdent", "Insert link": "Insert link", "Insert CodeBlock": "Insert codeBlock", "Insert table": "Insert table", "Insert image": "Insert image", Heading: "Heading", "Image URL": "Image URL", "Select image file": "Select image file", Description: "Description", OK: "OK", More: "More", Cancel: "Cancel", File: "File", URL: "URL", "Link text": "Link text", "Add row": "Add row", "Add col": "Add col", "Remove row": "Remove row", "Remove col": "Remove col", "Align left": "Align left", "Align center": "Align center", "Align right": "Align right", "Remove table": "Remove table", "Would you like to paste as table?": "Would you like to paste as table?", "Text color": "Text color", "Auto scroll enabled": "Auto scroll enabled", "Auto scroll disabled": "Auto scroll disabled", "Choose language": "Choose language" }); t.default = Ga }]).default }));