\n\n";
}), t = t.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm, function(t, e, n) {
var i = e.length;
return "" + a(n) + "\n\n";
});
}
function f(t, e) {
t += "~0";
var n = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
return B ? t = t.replace(n, function(t, n, i) {
var r = n, o = i.search(/[*+-]/g) > -1 ? "ul" : "ol", a = m(r, o, e);
return a = a.replace(/\s+$/, ""), a = "<" + o + ">" + a + "" + o + ">\n";
}) : (n = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g,
t = t.replace(n, function(t, e, n, i) {
var r = e, o = n, a = i.search(/[*+-]/g) > -1 ? "ul" : "ol", s = m(o, a);
return s = r + "<" + a + ">\n" + s + "" + a + ">\n";
})), t = t.replace(/~0/, "");
}
function m(t, e, n) {
B++, t = t.replace(/\n{2,}$/, "\n"), t += "~0";
var i = $[e], r = new RegExp("(^[ \\t]*)(" + i + ")[ \\t]+([^\\r]+?(\\n+))(?=(~0|\\1(" + i + ")[ \\t]+))", "gm"), s = !1;
return t = t.replace(r, function(t, e, i, r) {
var l = r, c = /\n\n$/.test(l), u = c || l.search(/\n{2,}/) > -1;
return u || s ? l = o(I(l), !0) : (l = f(I(l), !0), l = l.replace(/\n$/, ""), n || (l = a(l))),
s = c, "
" + l + "
\n";
}), t = t.replace(/~0/g, ""), B--, t;
}
function g(t) {
return t += "~0", t = t.replace(/(?:\n\n|^\n?)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g, function(t, e, n) {
var i = e, r = n;
return i = y(I(i)), i = D(i), i = i.replace(/^\n+/g, ""), i = i.replace(/\n+$/g, ""),
i = "
" + i + "\n
", "\n\n" + i + "\n\n" + r;
}), t = t.replace(/~0/, "");
}
function v(t) {
return t = t.replace(/(^\n+|\n+$)/g, ""), "\n\n~K" + (F.push(t) - 1) + "K\n\n";
}
function b(t) {
return t = t.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm, function(t, e, n, i, r) {
var o = i;
return o = o.replace(/^([ \t]*)/g, ""), o = o.replace(/[ \t]*$/g, ""), o = y(o),
o = o.replace(/:\/\//g, "~P"), e + "" + o + "";
});
}
function y(t) {
return t = t.replace(/&/g, "&"), t = t.replace(//g, ">"),
t = M(t, "*_{}[]\\", !1);
}
function x(t) {
return t = t.replace(/([\W_]|^)(\*\*|__)(?=\S)([^\r]*?\S[\*_]*)\2([\W_]|$)/g, "$1$3$4"),
t = t.replace(/([\W_]|^)(\*|_)(?=\S)([^\r\*_]*?\S)\2([\W_]|$)/g, "$1$3$4");
}
function w(t) {
return t = t.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm, function(t, e) {
var n = e;
return n = n.replace(/^[ \t]*>[ \t]?/gm, "~0"), n = n.replace(/~0/g, ""), n = n.replace(/^[ \t]+$/gm, ""),
n = o(n), n = n.replace(/(^|\n)/g, "$1 "), n = n.replace(/(\s*
[^\r]+?<\/pre>)/gm, function(t, e) {
var n = e;
return n = n.replace(/^ /gm, "~0"), n = n.replace(/~0/g, "");
}), v("
\n" + n + "\n
");
});
}
function S(t, e) {
t = t.replace(/^\n+/g, ""), t = t.replace(/\n+$/g, "");
for (var n = t.split(/\n{2,}/g), i = [], r = /~K(\d+)K/, o = n.length, s = 0; s < o; s++) {
var l = n[s];
r.test(l) ? i.push(l) : /\S/.test(l) && (l = a(l), l = l.replace(/^([ \t]*)/g, "
"),
l += "
", i.push(l));
}
if (!e) {
o = i.length;
for (var s = 0; s < o; s++) for (var c = !0; c; ) c = !1, i[s] = i[s].replace(/~K(\d+)K/g, function(t, e) {
return c = !0, F[e];
});
}
return i.join("\n\n");
}
function C(t) {
return t = t.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, "&"), t = t.replace(/<(?![a-z\/?!]|~D)/gi, "<");
}
function _(t) {
return t = t.replace(/\\(\\)/g, L), t = t.replace(/\\([`*_{}\[\]()>#+-.!])/g, L);
}
function k(t, e, n, i) {
if (e) return t;
if (")" !== i.charAt(i.length - 1)) return "<" + n + i + ">";
for (var r = i.match(/[()]/g), o = 0, a = 0; a < r.length; a++) "(" === r[a] ? o <= 0 ? o = 1 : o++ : o--;
var s = "";
if (o < 0) {
var l = new RegExp("\\){1," + -o + "}$");
i = i.replace(l, function(t) {
return s = t, "";
});
}
if (s) {
var c = i.charAt(i.length - 1);
U.test(c) || (s = c + s, i = i.substr(0, i.length - 1));
}
return "<" + n + i + ">" + s;
}
function E(t) {
t = t.replace(H, k);
var e = function(t, e) {
return '' + R.plainLinkText(e) + "";
};
return t = t.replace(/<((https?|ftp):[^'">\s]+)>/gi, e);
}
function T(t) {
return t = t.replace(/~E(\d+)E/g, function(t, e) {
var n = parseInt(e);
return String.fromCharCode(n);
});
}
function I(t) {
return t = t.replace(/^(\t|[ ]{1,4})/gm, "~0"), t = t.replace(/~0/g, "");
}
function D(t) {
if (!/\t/.test(t)) return t;
var e, n = [ " ", " ", " ", " " ], i = 0;
return t.replace(/[\n\t]/g, function(t, r) {
return "\n" === t ? (i = r + 1, t) : (e = (r - i) % 4, i = r + 1, n[e]);
});
}
function N(t) {
if (!t) return "";
t.length;
return t.replace(z, function(t, e) {
return "~D" == t ? "%24" : ":" == t ? ":" : "%" + t.charCodeAt(0).toString(16);
});
}
function M(t, e, n) {
var i = "([" + e.replace(/([\[\]\\])/g, "\\$1") + "])";
n && (i = "\\\\" + i);
var r = new RegExp(i, "g");
return t = t.replace(r, L);
}
function L(t, e) {
var n = e.charCodeAt(0);
return "~E" + n + "E";
}
var A = {};
this.setOptions = function(t) {
A = t;
};
var R = this.hooks = new n();
R.addNoop("plainLinkText"), R.addNoop("preConversion"), R.addNoop("postNormalization"),
R.addNoop("preBlockGamut"), R.addNoop("postBlockGamut"), R.addNoop("preSpanGamut"),
R.addNoop("postSpanGamut"), R.addNoop("postConversion");
var P, O, F, B;
this.makeHtml = function(n) {
if (P) throw new Error("Recursive call to converter.makeHtml");
return P = new i(), O = new i(), F = [], B = 0, n = R.preConversion(n), n = n.replace(/~/g, "~T"),
n = n.replace(/\$/g, "~D"), n = n.replace(/\r\n/g, "\n"), n = n.replace(/\r/g, "\n"),
n = "\n\n" + n + "\n\n", n = D(n), n = n.replace(/^[ \t]+$/gm, ""), n = R.postNormalization(n),
n = e(n), n = t(n), n = o(n), n = T(n), n = n.replace(/~D/g, "$$"), n = n.replace(/~T/g, "~"),
n = R.postConversion(n), F = O = P = null, n;
};
var j = function(t) {
return o(t);
}, $ = {
ol: "\\d+[.]",
ul: "[*+-]"
}, G = "[-A-Z0-9+&@#/%?=~_|[\\]()!:,.;]", q = "[-A-Z0-9+&@#/%=~_|[\\])]", H = new RegExp('(="|<)?\\b(https?|ftp)(://' + G + "*" + q + ")(?=$|\\W)", "gi"), U = new RegExp(q, "i"), z = /(?:["'*()[\]:]|~D)/g;
};
}(), define("libs/Markdown.Converter", function() {}), function() {
function t(t) {
return t.replace(/^\s+|\s+$/g, "");
}
function e(t) {
return t.replace(/\s+$/g, "");
}
function n(t) {
return t.replace(new RegExp("^(\\t|[ ]{1,4})", "gm"), "");
}
function i(t, e) {
return t.indexOf(e) != -1;
}
function r(t, e) {
return t.replace(/<[^>]*>?/gi, function(t) {
return t.match(e) ? t : "";
});
}
function o(t, e) {
for (var n = {}, i = 0; i < t.length; i++) n[t[i]] = t[i];
for (i = 0; i < e.length; i++) n[e[i]] = e[i];
var r = [];
for (var o in n) n.hasOwnProperty(o) && r.push(n[o]);
return r;
}
function a(t) {
return "\x02" != t.charAt(0) && (t = "\x02" + t), "\x03" != t.charAt(t.length - 1) && (t += "\x03"),
t;
}
function s(t) {
return "\x02" == t.charAt(0) && (t = t.substr(1)), "\x03" == t.charAt(t.length - 1) && (t = t.substr(0, t.length - 1)),
t;
}
function l(t, e) {
return r(c(t, e), m);
}
function c(t, e) {
var n = e.blockGamutHookCallback(t);
return n = p(n), n = n.replace(/~D/g, "$$").replace(/~T/g, "~"), n = e.previousPostConversion(n);
}
function u(t) {
return t.replace(/\\\|/g, "~I").replace(/\\:/g, "~i");
}
function d(t) {
return t.replace(/~I/g, "|").replace(/~i/g, ":");
}
function p(t) {
return t = t.replace(/~E(\d+)E/g, function(t, e) {
var n = parseInt(e);
return String.fromCharCode(n);
});
}
function h(t) {
return t.toLowerCase().replace(/\s+/g, "-").replace(/[^\w\-]+/g, "").replace(/\-\-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
}
function f(t, e) {
var n = e;
return n = n.replace(/&\#8220;/g, '"'), n = n.replace(/&\#8221;/g, '"'), n = n.replace(/&\#8216;/g, "'"),
n = n.replace(/&\#8217;/g, "'"), n = n.replace(/&\#8212;/g, "---"), n = n.replace(/&\#8211;/g, "--"),
n = n.replace(/&\#8230;/g, "...");
}
var m = new RegExp([ "^(<\\/?(a|abbr|acronym|applet|area|b|basefont|", "bdo|big|button|cite|code|del|dfn|em|figcaption|", "font|i|iframe|img|input|ins|kbd|label|map|", "mark|meter|object|param|progress|q|ruby|rp|rt|s|", "samp|script|select|small|span|strike|strong|", "sub|sup|textarea|time|tt|u|var|wbr)[^>]*>|", "<(br)\\s?\\/?>)$" ].join(""), "i");
Array.indexOf || (Array.prototype.indexOf = function(t) {
for (var e = 0; e < this.length; e++) if (this[e] == t) return e;
return -1;
}), Markdown.Extra = function() {
this.converter = null, this.hashBlocks = [], this.footnotes = {}, this.usedFootnotes = [],
this.attributeBlocks = !1, this.googleCodePrettify = !1, this.highlightJs = !1,
this.tableClass = "", this.tabWidth = 4;
}, Markdown.Extra.init = function(t, e) {
var n = new Markdown.Extra(), r = [], o = [], a = [], s = [ "unHashExtraBlocks" ];
return e = e || {}, e.extensions = e.extensions || [ "all" ], i(e.extensions, "all") && (e.extensions = [ "tables", "fenced_code_gfm", "def_list", "attr_list", "footnotes", "smartypants", "strikethrough", "newlines" ]),
o.push("wrapHeaders"), i(e.extensions, "attr_list") && (r.push("hashFcbAttributeBlocks"),
o.push("hashHeaderAttributeBlocks"), s.push("applyAttributeBlocks"), n.attributeBlocks = !0),
i(e.extensions, "fenced_code_gfm") && (o.push("fencedCodeBlocks"), r.push("fencedCodeBlocks")),
i(e.extensions, "tables") && o.push("tables"), i(e.extensions, "def_list") && o.push("definitionLists"),
i(e.extensions, "footnotes") && (r.push("stripFootnoteDefinitions"), o.push("doFootnotes"),
s.push("printFootnotes")), i(e.extensions, "smartypants") && s.push("runSmartyPants"),
i(e.extensions, "strikethrough") && a.push("strikethrough"), i(e.extensions, "newlines") && a.push("newlines"),
t.hooks.chain("postNormalization", function(t) {
return n.doTransform(r, t) + "\n";
}), t.hooks.chain("preBlockGamut", function(t, e) {
return n.blockGamutHookCallback = e, t = u(t), t = n.doTransform(o, t) + "\n", t = d(t);
}), t.hooks.chain("postSpanGamut", function(t) {
return n.doTransform(a, t);
}), n.previousPostConversion = t.hooks.postConversion, t.hooks.chain("postConversion", function(t) {
return t = n.doTransform(s, t), n.hashBlocks = [], n.footnotes = {}, n.usedFootnotes = [],
t;
}), "highlighter" in e && (n.googleCodePrettify = "prettify" === e.highlighter,
n.highlightJs = "highlight" === e.highlighter), "table_class" in e && (n.tableClass = e.table_class),
n.converter = t, n;
}, Markdown.Extra.prototype.doTransform = function(t, e) {
for (var n = 0; n < t.length; n++) e = this[t[n]](e);
return e;
}, Markdown.Extra.prototype.hashExtraBlock = function(t) {
return "\n
~X" + (this.hashBlocks.push(t) - 1) + "X
\n";
}, Markdown.Extra.prototype.hashExtraInline = function(t) {
return "~X" + (this.hashBlocks.push(t) - 1) + "X";
}, Markdown.Extra.prototype.unHashExtraBlocks = function(t) {
function e() {
var i = !1;
t = t.replace(/(?:
)?~X(\d+)X(?:<\/p>)?/g, function(t, e) {
i = !0;
var r = parseInt(e, 10);
return n.hashBlocks[r];
}), i === !0 && e();
}
var n = this;
return e(), t;
}, Markdown.Extra.prototype.wrapHeaders = function(t) {
function e(t) {
return "\n" + t + "\n";
}
return t = t.replace(/^.+[ \t]*\n=+[ \t]*\n+/gm, e), t = t.replace(/^.+[ \t]*\n-+[ \t]*\n+/gm, e),
t = t.replace(/^\#{1,6}[ \t]*.+?[ \t]*\#*\n+/gm, e);
};
var g = "\\{[ \\t]*((?:[#.][-_:a-zA-Z0-9]+[ \\t]*)+)\\}", v = new RegExp("^(#{1,6}.*#{0,6})[ \\t]+" + g + "[ \\t]*(?:\\n|0x03)", "gm"), b = new RegExp("^(.*)[ \\t]+" + g + "[ \\t]*\\n(?=[\\-|=]+\\s*(?:\\n|0x03))", "gm"), y = new RegExp("^(```[^`\\n]*)[ \\t]+" + g + "[ \\t]*\\n(?=([\\s\\S]*?)\\n```[ \\t]*(\\n|0x03))", "gm");
Markdown.Extra.prototype.hashHeaderAttributeBlocks = function(t) {
function e(t, e, i) {
return "
~XX" + (n.hashBlocks.push(i) - 1) + "XX
\n" + e + "\n";
}
var n = this;
return t = t.replace(v, e), t = t.replace(b, e);
}, Markdown.Extra.prototype.hashFcbAttributeBlocks = function(t) {
function e(t, e, i) {
return "
~XX" + (n.hashBlocks.push(i) - 1) + "XX
\n" + e + "\n";
}
var n = this;
return t.replace(y, e);
}, Markdown.Extra.prototype.applyAttributeBlocks = function(t) {
var e = this, n = new RegExp('
~XX(\\d+)XX
[\\s]*(?:<(h[1-6]|pre)(?: +class="(\\S+)")?(>[\\s\\S]*?\\2>))', "gm");
return t = t.replace(n, function(t, n, i, r, a) {
if (!i) return "";
for (var s = parseInt(n, 10), l = e.hashBlocks[s], c = l.match(/#[^\s#.]+/g) || [], u = c[0] ? ' id="' + c[0].substr(1, c[0].length - 1) + '"' : "", d = l.match(/\.[^\s#.]+/g) || [], p = 0; p < d.length; p++) d[p] = d[p].substr(1, d[p].length - 1);
var h = "";
return r && (d = o(d, [ r ])), d.length > 0 && (h = ' class="' + d.join(" ") + '"'),
"<" + i + u + h + a;
});
}, Markdown.Extra.prototype.tables = function(e) {
function n(e, n, r, o, a, s) {
n = n.replace(/^ *[|]/m, ""), r = r.replace(/^ *[|]/m, ""), o = o.replace(/^ *[|]/gm, ""),
n = n.replace(/[|] *$/m, ""), r = r.replace(/[|] *$/m, ""), o = o.replace(/[|] *$/gm, ""),
alignspecs = r.split(/ *[|] */), align = [];
for (var c = 0; c < alignspecs.length; c++) {
var u = alignspecs[c];
u.match(/^ *-+: *$/m) ? align[c] = ' align="right"' : u.match(/^ *:-+: *$/m) ? align[c] = ' align="center"' : u.match(/^ *:-+ *$/m) ? align[c] = ' align="left"' : align[c] = "";
}
var d = n.split(/ *[|] */), p = d.length, h = i.tableClass ? ' class="' + i.tableClass + '"' : "", f = [ "
\n", "\n", "
\n" ].join("");
for (c = 0; c < p; c++) {
var m = l(t(d[c]), i);
f += [ "
", m, "
\n" ].join("");
}
f += "
\n\n";
var g = o.split("\n");
for (c = 0; c < g.length; c++) if (!g[c].match(/^\s*$/)) {
for (var v = g[c].split(/ *[|] */), b = p - v.length, y = 0; y < b; y++) v.push("");
for (f += "
\n", y = 0; y < p; y++) {
var x = l(t(v[y]), i);
f += [ "
", x, "
\n" ].join("");
}
f += "
\n";
}
return f += "
\n", i.hashExtraBlock(f);
}
var i = this, r = new RegExp([ "^", "[ ]{0,3}", "[|]", "(.+)\\n", "[ ]{0,3}", "[|]([ ]*[-:]+[-| :]*)\\n", "(", "(?:[ ]*[|].*\\n?)*", ")", "(?:\\n|$)" ].join(""), "gm"), o = new RegExp([ "^", "[ ]{0,3}", "(\\S.*[|].*)\\n", "[ ]{0,3}", "([-:]+[ ]*[|][-| :]*)\\n", "(", "(?:.*[|].*\\n?)*", ")", "(?:\\n|$)" ].join(""), "gm");
return e = e.replace(r, n), e = e.replace(o, n);
}, Markdown.Extra.prototype.stripFootnoteDefinitions = function(t) {
var e = this;
return t = t.replace(/\n[ ]{0,3}\[\^(.+?)\]\:[ \t]*\n?([\s\S]*?)\n{1,2}((?=\n[ ]{0,3}\S)|$)/g, function(t, n, i) {
return n = h(n), i += "\n", i = i.replace(/^[ ]{0,3}/g, ""), e.footnotes[n] = i,
"\n";
});
}, Markdown.Extra.prototype.doFootnotes = function(t) {
var e = this;
if (e.isConvertingFootnote === !0) return t;
var n = 0;
return t = t.replace(/\[\^(.+?)\]/g, function(t, i) {
var r = h(i), o = e.footnotes[r];
if (void 0 === o) return t;
n++, e.usedFootnotes.push(r);
var a = '' + n + "";
return e.hashExtraInline(a);
});
}, Markdown.Extra.prototype.printFootnotes = function(t) {
var e = this;
if (0 === e.usedFootnotes.length) return t;
t += '\n\n
\n\n\n\n';
for (var n = 0; n < e.usedFootnotes.length; n++) {
var i = e.usedFootnotes[n], r = e.footnotes[i];
e.isConvertingFootnote = !0;
var o = l(r, e);
delete e.isConvertingFootnote, t += '
";
}, Markdown.Extra.prototype.fencedCodeBlocks = function(e) {
function n(t) {
return t = t.replace(/&/g, "&"), t = t.replace(//g, ">"),
t = t.replace(/~D/g, "$$"), t = t.replace(/~T/g, "~");
}
var i = this;
return e = e.replace(/(?:^|\n)```([^`\n]*)\n([\s\S]*?)\n```[ \t]*(?=\n)/g, function(e, r, o) {
var a = t(r), s = o, l = i.googleCodePrettify ? ' class="prettyprint"' : "", c = "";
a && (c = i.googleCodePrettify || i.highlightJs ? ' class="language-' + a + '"' : ' class="' + a + '"');
var u = [ "
", n(s), "
" ].join("");
return i.hashExtraBlock(u);
});
}, Markdown.Extra.prototype.educatePants = function(t) {
var e = this, n = "", i = 0;
t.replace(/(?:)|(<)([a-zA-Z1-6]+)([^\n]*?>)([\s\S]*?)(<\/\2>)/g, function(r, o, a, s, l, c, u) {
var d = t.substring(i, u);
return n += e.applyPants(d), e.smartyPantsLastChar = n.substring(n.length - 1),
i = u + r.length, o ? (/code|kbd|pre|script|noscript|iframe|math|ins|del|pre/i.test(a) ? e.smartyPantsLastChar = l.substring(l.length - 1) : l = e.educatePants(l),
void (n += o + a + s + l + c)) : void (n += r);
});
var r = t.substring(i);
return n += e.applyPants(r), e.smartyPantsLastChar = n.substring(n.length - 1),
n;
}, Markdown.Extra.prototype.applyPants = function(t) {
return t = t.replace(/---/g, "—").replace(/--/g, "–"), t = t.replace(/\.\.\./g, "…").replace(/\.\s\.\s\./g, "…"),
t = t.replace(/``/g, "“").replace(/''/g, "”"), /^'$/.test(t) ? /\S/.test(this.smartyPantsLastChar) ? "’" : "‘" : /^"$/.test(t) ? /\S/.test(this.smartyPantsLastChar) ? "”" : "“" : (t = t.replace(/^'(?=[!"#\$\%'()*+,\-.\/:;<=>?\@\[\\]\^_`{|}~]\B)/, "’"),
t = t.replace(/^"(?=[!"#\$\%'()*+,\-.\/:;<=>?\@\[\\]\^_`{|}~]\B)/, "”"), t = t.replace(/"'(?=\w)/g, "“‘"),
t = t.replace(/'"(?=\w)/g, "‘“"), t = t.replace(/'(?=\d{2}s)/g, "’"),
t = t.replace(/(\s| |--|&[mn]dash;|&\#8211;|&\#8212;|&\#x201[34];)'(?=\w)/g, "$1‘"),
t = t.replace(/([^\s\[\{\(\-])'/g, "$1’"), t = t.replace(/'(?=\s|s\b)/g, "’"),
t = t.replace(/'/g, "‘"), t = t.replace(/(\s| |--|&[mn]dash;|&\#8211;|&\#8212;|&\#x201[34];)"(?=\w)/g, "$1“"),
t = t.replace(/([^\s\[\{\(\-])"/g, "$1”"), t = t.replace(/"(?=\s)/g, "”"),
t = t.replace(/"/gi, "“"));
}, Markdown.Extra.prototype.runSmartyPants = function(t) {
return this.smartyPantsLastChar = "", t = this.educatePants(t), t = t.replace(/(<([a-zA-Z1-6]+)\b([^\n>]*?)(\/)?>)/g, f);
}, Markdown.Extra.prototype.definitionLists = function(e) {
var n = new RegExp([ "(\\x02\\n?|\\n\\n)", "(?:", "(", "(", "[ ]{0,3}", "((?:[ \\t]*\\S.*\\n)+)", "\\n?", "[ ]{0,3}:[ ]+", ")", "([\\s\\S]+?)", "(", "(?=\\0x03)", "|", "(?=", "\\n{2,}", "(?=\\S)", "(?!", "[ ]{0,3}", "(?:\\S.*\\n)+?", "\\n?", "[ ]{0,3}:[ ]+", ")", "(?!", "[ ]{0,3}:[ ]+", ")", ")", ")", ")", ")" ].join(""), "gm"), i = this;
return e = a(e), e = e.replace(n, function(e, n, r) {
var o = t(i.processDefListItems(r));
return o = "
\n" + o + "\n
", n + i.hashExtraBlock(o) + "\n\n";
}), s(e);
}, Markdown.Extra.prototype.processDefListItems = function(i) {
var r = this, o = new RegExp([ "(\\x02\\n?|\\n\\n+)", "(", "[ ]{0,3}", "(?![:][ ]|[ ])", "(?:\\S.*\\n)+?", ")", "(?=\\n?[ ]{0,3}:[ ])" ].join(""), "gm"), u = new RegExp([ "\\n(\\n+)?", "(", "[ ]{0,3}", "[:][ ]+", ")", "([\\s\\S]+?)", "(?=\\n*", "(?:", "\\n[ ]{0,3}[:][ ]|", "
|\\x03", ")", ")" ].join(""), "gm");
return i = a(i), i = i.replace(/\n{2,}(?=\\x03)/, "\n"), i = i.replace(o, function(e, n, i) {
for (var o = t(i).split("\n"), a = "", s = 0; s < o.length; s++) {
var c = o[s];
c = l(t(c), r), a += "\n
" + c + "
";
}
return a + "\n";
}), i = i.replace(u, function(t, i, o, a) {
return i || a.match(/\n{2,}/) ? (a = Array(o.length + 1).join(" ") + a, a = n(a) + "\n\n",
a = "\n" + c(a, r) + "\n") : (a = e(a), a = l(n(a), r)), "\n
Allows StackEdit to interpret LaTeX mathematical expressions.
\n
\n
\n \n
\n \n
\n
\n
\n \n
\n \n
\n
\n
\nMore info';
}), define("text!libs/mathjax_config.js", [], function() {
return 'MathJax.Hub.Config({\n\tskipStartupTypeset: true,\n "HTML-CSS": {\n preferredFont: "TeX",\n availableFonts: [\n "TeX"\n ],\n linebreaks: {\n automatic: true\n },\n EqnChunk: 10,\n imageFont: null\n },\n tex2jax: <%= tex2jax || \'{ inlineMath: [["$","$"],["\\\\\\\\\\\\\\\\(","\\\\\\\\\\\\\\\\)"]], displayMath: [["$$","$$"],["\\\\\\\\[","\\\\\\\\]"]], processEscapes: true }\' %>,\n TeX: $.extend({\n noUndefined: {\n attributes: {\n mathcolor: "red",\n mathbackground: "#FFEEEE",\n mathsize: "90%"\n }\n },\n Safe: {\n allow: {\n URLs: "safe",\n classes: "safe",\n cssIDs: "safe",\n styles: "safe",\n fontsize: "all"\n }\n }\n }, <%= tex %>),\n messageStyle: "none"\n});\n';
}), define("libs/mathjax_init", [ "settings", "text!libs/mathjax_config.js" ], function(t, e) {
var n = document.createElement("script");
n.type = "text/x-mathjax-config", n.innerHTML = _.template(e, {
tex: t.extensionSettings.mathJax ? t.extensionSettings.mathJax.tex : "undefined",
tex2jax: t.extensionSettings.mathJax ? t.extensionSettings.mathJax.tex2jax : void 0
}), document.getElementsByTagName("head")[0].appendChild(n);
}), define("extensions/mathJax", [ "utils", "classes/Extension", "text!html/mathJaxSettingsBlock.html", "mathjax" ], function(t, e, n) {
function i(t, e, n) {
var i = u.slice(t, e + 1).join("").replace(/&/g, "&").replace(//g, ">");
for (x.Browser.isMSIE && (i = i.replace(/(%[^\n]*)\n/g, "$1 \n")); e > t; ) u[e] = "",
e--;
u[t] = "@@" + m.length + "@@", n && (i = n(i)), m.push(i), d = p = h = null;
}
function r(t) {
d = p = h = null, m = [];
var e;
/`/.test(t) ? (t = t.replace(/~/g, "~T").replace(/(^|[^\\])(`+)([^\n]*?[^`\n])\2(?!`)/gm, function(t) {
return t.replace(/\$/g, "~D");
}), e = function(t) {
return t.replace(/~([TD])/g, function(t, e) {
return {
T: "~",
D: "$"
}[e];
});
}) : e = function(t) {
return t;
}, u = w(t.replace(/\r\n?/g, "\n"), S);
for (var n = 1, r = u.length; n < r; n += 2) {
var o = u[n];
"@" === o.charAt(0) ? (u[n] = "@@" + m.length + "@@", m.push(o)) : d ? p == y && "\n" == o.charAt(0) ? (h && (n = h,
i(d, n, e)), d = p = h = null, f = 0) : o === p ? f ? h = n : i(d, n, e) : o.match(/\n.*\n/) ? (h && (n = h,
i(d, n, e)), d = p = h = null, f = 0) : "{" === o ? f++ : "}" === o && f && f-- : o === y || "$$" === o ? (d = n,
p = o, f = 0) : "begin" === o.substr(1, 5) && (d = n, p = "\\end" + o.substr(6),
f = 0);
}
return h && i(d, h, e), e(u.join(""));
}
function o(t) {
return t = t.replace(/@@(\d+)@@/g, function(t, e) {
return m[e];
}), m = null, t;
}
function a() {
v = !1, x.cancelTypeset = !1, x.Queue([ "Typeset", x, b ]), x.Queue(c);
}
function s() {
v || (v = !0, x.Cancel(), x.Queue(a));
}
var l = new e("mathJax", "MathJax", (!0));
l.settingsBlock = n, l.defaultConfig = {
tex: "{}",
tex2jax: '{ inlineMath: [["$","$"],["\\\\\\\\(","\\\\\\\\)"]], displayMath: [["$$","$$"],["\\\\[","\\\\]"]], processEscapes: true }'
}, l.onLoadSettings = function() {
t.setInputValue("#input-mathjax-config-tex", l.config.tex), t.setInputValue("#input-mathjax-config-tex2jax", l.config.tex2jax);
}, l.onSaveSettings = function(e, n) {
e.tex = t.getInputJsValue("#input-mathjax-config-tex", n), e.tex2jax = t.getInputJsValue("#input-mathjax-config-tex2jax", n);
}, l.onPagedownConfigure = function(t) {
b = document.getElementById("preview-contents");
var e = t.getConverter();
e.hooks.chain("preConversion", r), e.hooks.chain("postConversion", o);
};
var c;
l.onAsyncPreview = function(t) {
c = t, s();
};
var u, d, p, h, f, m, g = !1, v = !1, b = null, y = "$", x = MathJax.Hub;
x.Queue(function() {
g = !0, x.processUpdateTime = 50, x.Config({
"HTML-CSS": {
EqnChunk: 10,
EqnChunkFactor: 1
},
SVG: {
EqnChunk: 10,
EqnChunkFactor: 1
}
});
});
var w, S = /(\$\$?|\\(?:begin|end)\{[a-z]*\*?\}|\\[\\{}$]|[{}]|(?:\n\s*)+|@@\d+@@)/i;
return w = 3 === "aba".split(/(b)/).length ? function(t, e) {
return t.split(e);
} : function(t, e) {
var n, i = [];
if (!e.global) {
n = e.toString();
var r = "";
n = n.replace(/^\/(.*)\/([im]*)$/, function(t, e, n) {
return r = n, e;
}), e = RegExp(n, r + "g");
}
for (var o = e.lastIndex = 0; n = e.exec(t); ) i.push(t.substring(o, n.index)),
i.push.apply(i, n.slice(1)), o = n.index + n[0].length;
return i.push(t.substring(o)), i;
}, function() {
var t = MathJax.Hub;
if (!t.Cancel) {
t.cancelTypeset = !1, t.Register.StartupHook("HTML-CSS Jax Config", function() {
var e = MathJax.OutputJax["HTML-CSS"], n = e.Translate;
e.Augment({
Translate: function(i, r) {
if (t.cancelTypeset || r.cancelled) throw Error("MathJax Canceled");
return n.call(e, i, r);
}
});
}), t.Register.StartupHook("SVG Jax Config", function() {
var e = MathJax.OutputJax.SVG, n = e.Translate;
e.Augment({
Translate: function(i, r) {
if (t.cancelTypeset || r.cancelled) throw Error("MathJax Canceled");
return n.call(e, i, r);
}
});
}), t.Register.StartupHook("TeX Jax Config", function() {
var e = MathJax.InputJax.TeX, n = e.Translate;
e.Augment({
Translate: function(i, r) {
if (t.cancelTypeset || r.cancelled) throw Error("MathJax Canceled");
return n.call(e, i, r);
}
});
});
var e = t.processError;
t.processError = function(n, i, r) {
return "MathJax Canceled" !== n.message ? e.call(t, n, i, r) : (MathJax.Message.Clear(0, 0),
i.jaxIDs = [], i.jax = {}, i.scripts = [], i.i = i.j = 0, i.cancelled = !0, null);
}, t.Cancel = function() {
this.cancelTypeset = !0;
};
}
}(), l;
}), define("text!html/partialRenderingSettingsBlock.html", [], function() {
return "
Renders modified sections only.
\n
\n\t
Note: Document sections are based on title elements (h1, h2...). Therefore if\n\tyour document does not contain any title, performance will not be increased.
\n
";
}), define("extensions/partialRendering", [ "underscore", "crel", "extensions/markdownExtra", "classes/Extension", "text!html/partialRenderingSettingsBlock.html" ], function(t, e, n, i, r) {
function o() {
var e = [], n = "\n";
if (m = !1, t.each(g, function(t) {
var i = '\n\n\n' + t.text + "\n\n";
f && (i = i.replace(/^```.*\n[\s\S]*?\n```|\n[ ]{0,3}\[\^(.+?)\]\:[ \t]*\n?([\s\S]*?)\n{1,2}((?=\n[ ]{0,3}\S)|$)/gm, function(t, e) {
return e ? (m = !0, n += t.replace(/^\s*\n/gm, "") + "\n", "") : t;
})), i = i.replace(/^```.*\n[\s\S]*?\n```|^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*(\S+?)>?(?=\s|$)[ \t]*\n?[ \t]*((\n*)["(](.+?)[")][ \t]*)?(?:\n+)/gm, function(t, e) {
return e ? (n += t.replace(/^\s*\n/gm, "") + "\n", "") : t;
}), e.push({
id: t.id,
text: i + "\n"
});
}), y = [], b = [], d = void 0, x === !0 || u != n) return x = !1, u = n, b = v,
v = e, void (y = e);
var i = v.length;
t.some(v, function(t, n) {
if (n >= e.length || t.text != e[n].text) return i = n, !0;
});
var r = -v.length;
t.some(v.slice().reverse(), function(t, n) {
if (n >= e.length || t.text != e[e.length - n - 1].text) return r = -n, !0;
}), i - r > v.length && (r = i - v.length);
var o = v.slice(0, i);
y = e.slice(i, e.length + r);
var a = v.slice(v.length + r, v.length);
d = t.first(a), b = v.slice(i, v.length + r), v = o.concat(y).concat(a);
}
function a(t) {
var e = t.id.substring(3), n = w[e];
n && S.removeChild(n), w[e] = t, S.appendChild(t);
}
function s() {
function n(n) {
for (var i = e("div", {
id: "wmd-preview-section-" + n.id,
"class": "wmd-preview-section preview-content"
}), o = !1; r; ) {
var s = r.nextSibling, l = "se-preview-section-delimiter" == r.className;
if (o === !0 && "DIV" == r.tagName && l) break;
o = !0, "DIV" == r.tagName && "footnotes" == r.className ? t.each(r.querySelectorAll("ol > li"), a) : l || i.appendChild(r),
r = s;
}
return i;
}
t.each(b, function(t) {
var e = document.getElementById("wmd-preview-section-" + t.id);
h.removeChild(e);
});
var i = document.getElementById("wmd-preview"), r = i.firstChild, o = document.createDocumentFragment();
t.each(y, function(t) {
o.appendChild(n(t));
}), i.innerHTML = "";
var s = p;
void 0 !== d && (s = document.getElementById("wmd-preview-section-" + d.id)), h.insertBefore(o, s),
p.innerHTML = "", delete p.exportableHtml;
var l = [];
if (m === !0) {
var c = e("ol");
t.each(h.querySelectorAll("a.footnote"), function(t, e) {
t.textContent = e + 1;
var n = t.id.substring(6);
l.push(n);
var i = w[n];
i && c.appendChild(i.cloneNode(!0));
}), l.length > 0 && p.appendChild(e("div", {
"class": "footnotes"
}, e("hr"), c)), Object.keys(w).forEach(function(t) {
l.indexOf(t) === -1 && (S.removeChild(w[t]), delete w[t]);
});
}
}
var l = new i("partialRendering", "Partial Rendering", (!0));
l.settingsBlock = r;
var c, u, d, p, h, f = !1, m = !1, g = [], v = [], b = [], y = [], x = !1, w = {}, S = document.createDocumentFragment();
return l.onSectionsCreated = function(t) {
g = t;
}, l.onPagedownConfigure = function(e) {
c = e.getConverter(), c.hooks.chain("preConversion", function() {
o();
var e = t.map(y, function(t) {
return t.text;
});
return e.push(u + "\n\n"), e.join("");
}), e.hooks.chain("onPreviewRefresh", function() {
s();
});
}, l.onInit = function() {
n.enabled && t.some(n.config.extensions, function(t) {
return "footnotes" == t;
}) && (f = !0);
}, l.onReady = function() {
p = e("div", {
id: "wmd-preview-section-footnotes",
"class": "preview-content"
}), h = document.getElementById("preview-contents"), h.appendChild(p);
}, l.onFileSelected = function() {
x = !0;
}, l;
}), define("extensions/markdownSectionParser", [ "underscore", "extensions/markdownExtra", "extensions/mathJax", "extensions/partialRendering", "classes/Extension", "crel" ], function(t, e, n, i, r, o) {
function a(t, e) {
function n(t, e) {
var n = o.substring(a, e);
u.push({
id: ++h,
text: n,
textWithFrontMatter: i + n
}), i = "";
}
if (t === p) {
var i = (p.frontMatter || {})._frontMatter || "", r = e.substring(i.length), o = r + "\n\n";
u = [];
var a = 0;
o.replace(d, function(t, e) {
n(a, e), a = e;
}), n(a, r.length), s.onSectionsCreated(u);
}
}
var s, l = new r("markdownSectionParser", "Markdown section parser");
l.onEventMgrCreated = function(t) {
s = t;
};
var c, u = [], d = "^.+[ \\t]*\\n=+[ \\t]*\\n+|^.+[ \\t]*\\n-+[ \\t]*\\n+|^\\#{1,6}[ \\t]*.+?[ \\t]*\\#*\\n+";
l.onPagedownConfigure = function(r) {
e.enabled && t.some(e.config.extensions, function(t) {
return "fenced_code_gfm" == t;
}) && (d = "^```[^`\\n]*\\n[\\s\\S]*?\\n```|" + d), n.enabled && (d = "^[ \\t]*\\n\\$\\$[\\s\\S]*?\\$\\$|" + d,
d = "^[ \\t]*\\n\\\\\\\\[[\\s\\S]*?\\\\\\\\]|" + d, d = "^[ \\t]*\\n\\\\?\\\\begin\\{[a-z]*\\*?\\}[\\s\\S]*?\\\\end\\{[a-z]*\\*?\\}|" + d),
d = new RegExp(d, "gm");
var a = r.getConverter();
i.enabled || (a.hooks.chain("preConversion", function() {
return t.reduce(u, function(t, e) {
return t + '\n\n\n' + e.text + "\n\n";
}, "");
}), r.hooks.chain("onPreviewRefresh", function() {
function t() {
for (var t = o("div", {
"class": "wmd-preview-section preview-content"
}), e = !1; n; ) {
var i = n.nextSibling, r = "se-preview-section-delimiter" == n.className;
if (e === !0 && "DIV" == n.tagName && r) break;
e = !0, r || t.appendChild(n), n = i;
}
return t;
}
var e = document.getElementById("wmd-preview"), n = e.firstChild, i = document.createDocumentFragment();
u.forEach(function(e) {
i.appendChild(t(e));
}), c.innerHTML = "", c.appendChild(e), c.appendChild(i);
}));
}, l.onReady = function() {
c = document.getElementById("preview-contents");
};
var p;
l.onFileSelected = function(t) {
p = t;
};
var h = 0;
return l.onFileOpen = a, l.onContentChanged = a, l;
}), define("text!html/buttonMarkdownSyntax.html", [], function() {
return '\n
\n\t
Markdown syntax
\n \n\t
\n
Phrase Emphasis
\n\n
*italic* **bold**\n_italic_ __bold__\n
\n\n
Links
\n\n
Inline:
\n\n
An [example](http://url.com/ "Title")\n
\n\n
Reference-style labels (titles are optional):
\n\n
An [example][id]. Then, anywhere\nelse in the doc, define the link:\n\n [id]: http://example.com/ "Title"\n
> Email-style angle brackets\n> are used for blockquotes.\n\n> > And, they can be nested.\n\n> #### Headers in blockquotes\n>\n> * You can quote a list.\n> * Etc.\n
\n\n
Code Spans
\n\n
`<code>` spans are delimited\nby backticks.\n\nYou can include literal backticks\nlike `` `this` ``.\n
\n\n
Preformatted Code Blocks
\n\n
Indent every line of a code block by at least 4 spaces or 1 tab.
\n\n
This is a normal paragraph.\n\n This is a preformatted\n code block.\n
\n';
}), define("extensions/dialogAbout", [ "jquery", "underscore", "constants", "utils", "classes/Extension", "monetizejs", "text!html/dialogAbout.html" ], function(t, e, n, i, r, o, a) {
var s, l = new r("dialogAbout", 'Dialog "About"');
l.onEventMgrCreated = function(t) {
s = t;
};
var c = new o({
applicationID: "ESTHdCYOi18iLhhO"
});
return l.onReady = function() {
i.addModal("modal-about", e.template(a, {
version: n.VERSION
})), t(".modal-about .sponsorship-button").click(function() {
c.getPayments({
summary: !0
}, function() {
s.onMessage("Please refresh the page for your sponsorship to take effect.");
});
});
}, l;
}), define("text!html/dialogManagePublicationLocation.html", [], function() {
return '
" ].join("");
n += e.chain(s).sortBy(function(t) {
return t.name.toLowerCase();
}).reduce(function(t, n) {
return t + e.template(E, {
folderDesc: n
});
}, "").value(), o.innerHTML = n, e.each(o.querySelectorAll(".folder"), function(n) {
n = t(n), n.click(function() {
var i = s[n.data("folderIndex")];
e.each(I, function(t) {
t.folder && t.folder.removeFile(t), i && i.addFile(t);
}), f.onFoldersChanged(), t(g.querySelectorAll(".document-list")).removeClass("hide"),
t(g.querySelectorAll(".choose-folder, .select-folder-list")).addClass("hide");
});
}), t(g.querySelectorAll(".document-list")).addClass("hide"), t(g.querySelectorAll(".choose-folder, .select-folder-list")).removeClass("hide");
}
});
y = h.parent(), t(g.querySelectorAll(".action-cancel")).click(function() {
t(g.querySelectorAll(".document-list")).removeClass("hide"), t(g.querySelectorAll(".confirm-delete, .choose-folder, .selected-document-list, .select-folder-list")).addClass("hide");
}), t(v).on("click", ".button-delete", function(e) {
e.stopPropagation();
var n = t(this), i = n.parent(), r = s[i.data("folderIndex")], o = l[i.data("fileIndex")];
I = [], D = [], r ? (D.push(r), I = r.fileList) : o && I.push(o), u();
}).on("click", ".button-rename", function(e) {
e.stopPropagation();
var n, i = t(this.parentNode), r = s[i.data("folderIndex")], o = l[i.data("fileIndex")];
r ? n = r.name : o && (n = o.title), i.find(".name").addClass("hide"), i.find(".input-rename").removeClass("hide").val(n)[0].select();
}).on("blur keyup", ".input-rename", function(e) {
function n() {
var e = i.parent(), n = t.trim(i.val()), r = s[e.data("folderIndex")], o = l[e.data("fileIndex")];
n && r && n != r.name ? (r.name = n, f.onFoldersChanged()) : n && o && n != o.title ? (o.title = n,
f.onTitleChanged(o)) : (i.addClass("hide"), e.find(".name").removeClass("hide"));
}
var i = t(this);
void 0 === e.keyCode ? n() : 13 == e.keyCode ? (n(), e.stopPropagation()) : 27 == e.keyCode && (i.val(""),
n(), e.stopPropagation());
}).on("click", ".file .checkbox", function(t) {
t.stopPropagation();
}).on("change", ".file .checkbox input", function() {
t(this).parents(".file-list").prev().find(".checkbox input").prop("checked", !1),
N();
}).on("click", ".folder .checkbox", function(t) {
t.stopPropagation();
}).on("change", ".folder .checkbox input", function() {
t(this).parents(".folder").next().find(".checkbox input").prop("checked", this.checked),
N();
});
}, h;
}), define("extensions/workingIndicator", [ "jquery", "underscore", "crel", "classes/Extension" ], function(t, e, n, i) {
var r, o, a = new i("workingIndicator", "Working Indicator"), s = [ "@<%= prefix %>keyframes <%= name %> {", " 0% { opacity:<%= z %>; }", " <%= start %>.01% { opacity:<%= alpha %>; }", " <%= start %>.02% { opacity:1; }", " <%= ((start + trail) % 100) %>.01% { opacity:<%= alpha %>; }", " 100% { opacity:<%= z %>; }", "}" ].join("\n");
return a.onAsyncRunning = function(t) {
r.toggleClass("working", t), o.toggleClass("hide", !t);
}, a.onReady = function() {
function i(t) {
t.z = Math.max(1 - (1 - t.alpha) / t.trail * (100 - t.start), t.alpha), a += e.template(s, e.extend({
prefix: ""
}, t)), a += e.template(s, e.extend({
prefix: "-webkit-"
}, t));
}
var a = "";
r = t(document.body), o = t('
'), t(".working-indicator").append(o);
for (var l = 0; l < 3; l++) {
var c = "working-indicator-bar" + l;
i({
name: c,
alpha: .25,
start: 20 * l,
trail: 50
});
var u = c + " 0.7s linear infinite";
o.append(t('
Generates a table of contents when a [TOC] marker is found.
\n
\n\t
\n\t\t\n\t\t
\n\t\t\n\t\t\t\n\t\t
\n\t
\n\t
\n\t\t\n\t\t
\n\t\t\t\n\t\t
\n\t
\n\t
\n \n
\n
\n \n
\n
\n
\n\t\n
';
}), define("extensions/toc", [ "jquery", "underscore", "utils", "classes/Extension", "text!html/buttonToc.html", "text!html/tocSettingsBlock.html" ], function(t, e, n, i, r, o) {
function a(t, e, n) {
this.tagName = t, this.anchor = e, this.text = n, this.children = [];
}
function s(t, n) {
function i() {
void 0 !== r && (r.children.length > 0 && (r.children = s(r.children, n + 1)), l.push(r));
}
n = n || 1;
var r, o = "H" + n, l = [];
return e.each(t, function(t) {
t.tagName != o ? n !== c.config.maxDepth && (void 0 === r && (r = new a()), r.children.push(t)) : (i(),
r = t);
}), i(), l;
}
function l() {
function t(t) {
for (var r = t.id || n.slugify(t.textContent) || "title", o = r, a = 0; e.has(i, o); ) o = r + "-" + ++a;
return i[o] = !0, t.id = o, o;
}
var i = {}, r = [];
return e.each(u.querySelectorAll("h1, h2, h3, h4, h5, h6"), function(e) {
r.push(new a(e.tagName, t(e), e.textContent));
}), r = s(r), '
\n
\n' + r.join("") + "
\n
\n";
}
var c = new i("toc", "Table of Contents", (!0));
c.settingsBlock = o, c.defaultConfig = {
marker: "\\[(TOC|toc)\\]",
maxDepth: 6,
button: !0
}, c.onLoadSettings = function() {
n.setInputValue("#input-toc-marker", c.config.marker), n.setInputValue("#input-toc-maxdepth", c.config.maxDepth),
n.setInputChecked("#input-toc-button", c.config.button);
}, c.onSaveSettings = function(t, e) {
t.marker = n.getInputRegExpValue("#input-toc-marker", e), t.maxDepth = n.getInputIntValue("#input-toc-maxdepth"),
t.button = n.getInputChecked("#input-toc-button");
}, c.onCreatePreviewButton = function() {
if (c.config.button) return r;
}, a.prototype.childrenToString = function() {
if (0 === this.children.length) return "";
var t = "
\n";
return e.each(this.children, function(e) {
t += e.toString();
}), t += "
\n";
}, a.prototype.toString = function() {
var t = "
Note: The mapping between Markdown and HTML is based on the\n\tposition of the title elements (h1, h2...) in the page. Therefore if\n\tyour document does not contain any title, the mapping will be linear and\n\tconsequently less accurate.
\n
";
}), define("extensions/scrollSync", [ "jquery", "underscore", "classes/Extension", "text!html/scrollSyncSettingsBlock.html" ], function(t, e, n, i) {
function r(t, n, i) {
var r, o = e.find(n, function(e, n) {
return r = n, t < e.endOffset;
});
if (void 0 !== o) {
var a = (t - o.startOffset) / (o.height || 1), s = i[r];
return s.startOffset + s.height * a;
}
}
function o(t, e, n, i, r) {
function o() {
var l = Date.now(), c = (l - s) / 200;
if (c < 1) {
var u = e + a * Math.cos((1 - c) * Math.PI / 2);
t.scrollTop = u, i(u), p = setTimeout(o, 1);
} else h = void 0, t.scrollTop = n, setTimeout(r, 100);
}
h && (clearTimeout(p), h()), h = r;
var a = n - e, s = Date.now();
o();
}
var a = new n("scrollSync", "Scroll Sync", (!0), (!0));
a.settingsBlock = i;
var s;
a.onSectionsCreated = function(t) {
s = t;
};
var l, c, u, d, p, h, f = [], m = [], g = e.debounce(function() {
f = [];
var t, n;
e.each(l.querySelectorAll(".wmd-input-section"), function(e) {
if (void 0 === t) return void (t = 0);
e = e.firstChild;
var n = e.offsetTop;
f.push({
startOffset: t,
endOffset: n,
height: n - t
}), t = n;
}), n = l.scrollHeight, f.push({
startOffset: t,
endOffset: n,
height: n - t
}), m = [];
var i;
e.each(c.querySelectorAll(".wmd-preview-section"), function(t) {
if (void 0 === i) return void (i = 0);
var e = t.offsetTop;
m.push({
startOffset: i,
endOffset: e,
height: e - i
}), i = e;
}), n = c.scrollHeight, m.push({
startOffset: i,
endOffset: n,
height: n - i
}), u = -10, d = -10, S();
}, 500), v = !0, b = !1, y = !1, x = !1, w = !1, S = e.throttle(function() {
if (v && 0 !== f.length && f.length === m.length) {
var t = l.scrollTop;
t < 0 && (t = 0);
var n, i = c.scrollTop;
if (b === !0) {
if (Math.abs(t - u) <= 9) return;
if (b = !1, u = t, n = r(t, f, m), n = e.min([ n, c.scrollHeight - c.offsetHeight ]),
Math.abs(n - i) <= 9) return void (d = i);
o(c, i, n, function(t) {
w = !0, d = t;
}, function() {
w = !1;
});
} else if (y === !0) {
if (Math.abs(i - d) <= 9) return;
if (y = !1, d = i, n = r(i, m, f), n = e.min([ n, l.scrollHeight - l.offsetHeight ]),
Math.abs(n - t) <= 9) return void (u = t);
o(l, t, n, function(t) {
x = !0, u = t;
}, function() {
x = !1;
});
}
}
}, 100);
a.onLayoutResize = function() {
b = !0, g();
}, a.onFileClosed = function() {
f = [];
};
var C = !1;
a.onReady = function() {
c = document.querySelector(".preview-container"), l = document.querySelector("#wmd-input"),
t(c).scroll(function() {
w === !1 && C === !1 && (y = !0, b = !1, S()), C = !1;
}), t(l).scroll(function() {
x === !1 && (b = !0, y = !1, S());
}), t(".preview-panel").on("hide.layout.toggle", function() {
v = !1;
}).on("shown.layout.toggle", function() {
v = !0;
}), t(".extension-preview-buttons .table-of-contents").on("click", "a", function(e) {
e.preventDefault();
var n = this.hash, i = t(n);
if (i.length) {
var o = i[0].getBoundingClientRect().top - c.getBoundingClientRect().top + c.scrollTop;
c.scrollTop = o;
var a = r(o, m, f);
l.scrollTop = a;
}
});
};
var _, k;
return a.onPagedownConfigure = function(t) {
_ = document.getElementById("preview-contents"), t.getConverter().hooks.chain("postConversion", function(t) {
return k = _.offsetHeight, _.style.height = k + "px", t;
});
}, a.onPreviewFinished = function() {
_.style.removeProperty("height");
var t = _.offsetHeight;
b = !0, t < k && (C = !0), g();
}, a;
}), define("text!html/buttonSyncSettingsBlock.html", [], function() {
return '
Adds a "Synchronize documents" button in the navigation bar.
\n
\n\t
\n\t\t\n\t\t
\n\t\t\t ms\n\t\t
\n\t
\n\t
\n\t\t\n\t\t
\n\t\t\t\n\t\t
\n\t
\n
';
}), define("extensions/buttonSync", [ "jquery", "underscore", "crel", "utils", "classes/Extension", "mousetrap", "text!html/buttonSyncSettingsBlock.html" ], function(t, e, n, i, r, o, a) {
var s = new r("buttonSync", 'Button "Synchronize"', (!1), (!0));
s.settingsBlock = a, s.defaultConfig = {
syncPeriod: 18e4,
syncShortcut: "mod+s"
}, s.onLoadSettings = function() {
i.setInputValue("#input-sync-period", s.config.syncPeriod), i.setInputValue("#input-sync-shortcut", s.config.syncShortcut);
}, s.onSaveSettings = function(t, e) {
t.syncPeriod = i.getInputIntValue("#input-sync-period", e, 0), t.syncShortcut = i.getInputTextValue("#input-sync-shortcut", e);
};
var l;
s.onSynchronizerCreated = function(t) {
l = t;
};
var c, u = !1, d = !1, p = function() {
void 0 !== c && (u === !0 || l.hasSync() === !1 || d ? c.addClass("disabled") : c.removeClass("disabled"));
}, h = 0;
return s.onPeriodicRun = function() {
!s.config.syncPeriod || h + s.config.syncPeriod > i.currentTime || l.sync() && (h = i.currentTime);
}, s.onCreateButton = function() {
var e = n("a", {
"class": "btn btn-success button-synchronize",
title: "Force synchronization Ctrl/Cmd+S"
}, n("i", {
"class": "icon-refresh"
}));
return c = t(e), c.click(function() {
c.hasClass("disabled") || l.sync() && (h = i.currentTime);
}), e;
}, s.onReady = p, s.onFileCreated = p, s.onFileDeleted = p, s.onSyncImportSuccess = p,
s.onSyncExportSuccess = p, s.onSyncRemoved = p, s.onSyncRunning = function(t) {
u = t, p();
}, s.onOfflineChanged = function(t) {
d = t, p();
}, s.onReady = function() {
o.bind(s.config.syncShortcut, function(t) {
l.sync() && (h = i.currentTime), t.preventDefault();
}), t(".action-force-synchronization").click(function() {
l.sync() && (h = i.currentTime);
});
}, s;
}), define("extensions/buttonPublish", [ "jquery", "underscore", "crel", "classes/Extension" ], function(t, e, n, i) {
function r() {
void 0 !== o && (c === !0 || u === !1 || d === !0 ? o.addClass("disabled") : o.removeClass("disabled"));
}
var o, a, s, l = new i("buttonPublish", 'Button "Publish"'), c = !1, u = !1, d = !1;
l.onPublisherCreated = function(t) {
s = t;
}, l.onCreateButton = function() {
var e = n("a", {
"class": "btn btn-success button-publish",
title: "Update document publication"
}, n("i", {
"class": "icon-upload"
}));
return o = t(e).click(function() {
o.hasClass("disabled") || s.publish();
}), e;
}, l.onPublishRunning = function(t) {
c = t, r();
}, l.onOfflineChanged = function(t) {
d = t, r();
};
var p = function() {
u = 0 !== e.size(a.publishLocations), r();
};
return l.onFileSelected = function(t) {
a = t, p();
}, l.onReady = function() {
t(".action-update-publication").click(s.publish);
}, l.onPublishRemoved = p, l.onNewPublishSuccess = p, l;
}), define("text!html/buttonStat.html", [], function() {
return '\n
It's still in beta. Some of the features may not be available just yet.
", "You can always click Next to go through the StackEdit 4 tour." ].join(""),
placement: "bottom"
}, {
element: ".document-panel .toggle-button",
title: "Documents",
content: [ '
The document panel allows you to manage your local documents.
', "Tip: Use Ctrl+[ and Ctrl+] to toggle documents." ].join(""),
placement: "left",
reflex: !0
}, {
element: ".menu-panel .toggle-button",
title: "Menu",
content: [ '
The menu panel allows you to synchronize your documents on Google Drive, Dropbox or to publish them on GitHub, Blogger...
', 'Tip: Use the menu panel to access the settings.' ].join(""),
placement: "right",
reflex: !0
}, {
element: ".navbar-inner > .nav .button-open-discussion, .navbar .buttons-dropdown > .nav > .btn:not(:hidden)",
title: "Comments/discussions",
content: [ '
New in StackEdit 4: the comments button lets you create inline discussions!
', "Tip: Reopen the Hello! document from Settings>Utils to discover other new features." ].join(""),
placement: "right",
reflex: !0
}, {
element: ".navbar-inner",
title: "Happy StackWriting!",
content: [ '
Enjoy, and don\'t forget to rate 5 stars on the Chrome Web Store...
\n\n';
}), define("extensions/comments", [ "jquery", "underscore", "utils", "storage", "crel", "rangy", "classes/Extension", "text!html/commentsPopoverContent.html", "bootstrap" ], function(t, e, n, i, r, o, a, s) {
function l(t, e, n) {
e = Math.round(e);
for (var i = e - 21; i < e + 22; ) S[i] && (e = i + 22), i++;
!n && (S[e] = 1);
var r = -8;
t.className.indexOf(" icon-split") !== -1 && (r = -12);
var o = e + r;
t.style.top = o + "px", t.style.right = "12px";
}
function c(e, n) {
this.commentElt = e, this.$commentElt = t(e).addClass("active"), this.fileDesc = n,
this.discussionIndex = e.discussionIndex;
}
function u(t) {
var e = _.getPopoverElt(), n = 0;
e.offsetWidth < x.offsetWidth - 10 && (n = x.offsetWidth - 10 - e.offsetWidth),
e.style.left = n + "px", e.querySelector(".arrow").style.left = x.offsetWidth - parseInt(t.style.right) - t.offsetWidth / 2 - n + "px";
var i = window.innerHeight - _.hr.getBoundingClientRect().top;
i < 0 && (e.style.top = parseInt(e.style.top) + i + "px");
}
function d() {
_ && _.$commentElt.popover("toggle").popover("destroy");
}
function p() {
var t = _.getDiscussion(), n = i["author.name"], r = [];
return t.commentList && (r = t.commentList.map(function(t) {
var i = t.author || "Anonymous";
return e.template(m, {
author: i,
content: t.content,
reply: t.author != n
});
})), "conflict" == t.type && r.unshift(e.template(m, {
author: "StackEdit",
content: "Conflicting changes have been detected.",
reply: !0
})), r.join("");
}
var h, f = new a("comments", "Comments", (!1), (!0)), m = [ "
\">", '
<%= author %>
', '
<%= content %>
', "
" ].join(""), g = [ '', ' ', ' ', " ", " \u201c<%- title %>\u201d", "" ].join("");
f.onEventMgrCreated = function(t) {
h = t;
};
var v, b;
f.onEditorCreated = function(t) {
v = t, b = v.selectionMgr;
};
var y, x, w, S = [], C = r("a", {
"class": "discussion icon-comment new"
});
c.prototype.getDiscussion = function() {
return this.discussionIndex ? this.fileDesc.discussionList[this.discussionIndex] : this.fileDesc.newDiscussion;
}, c.prototype.getPopoverElt = function() {
return document.querySelector(".comments-popover .popover:last-child");
};
var _, k, E, T, I, D, N = {}, M = [], L = !1, A = e.debounce(function() {
function t() {
var i;
if (0 === o.length) return e.filter(N, function(t, n) {
return !e.has(E.discussionList, n);
}).forEach(function(t) {
x.removeChild(t), delete N[t.discussionIndex];
}), l(C, w, !0), _ && !_.discussionIndex && (y.scrollTop += parseInt(C.style.top) - y.scrollTop - 3 * y.offsetHeight / 4,
u(C)), M = e.sortBy(N, function(t) {
return t.selectionEnd;
}), I.toggleClass("some", 0 !== M.length), I.toggleClass("replied", L), void D.toggleClass("icon-chat", 0 !== M.length);
var a = o.shift(), s = N[a.discussionIndex];
s || (s = r("a"));
var c = "discussion", d = !a.commentList || !n || e.last(a.commentList).author != n;
d && (L = !0), c += "conflict" == a.type ? " icon-split" : " icon-comment", c += d ? " replied" : " added",
s.className = c, s.discussionIndex = a.discussionIndex, s.selectionEnd = a.selectionEnd,
i = b.getCoordinates(a.selectionEnd), l(s, i.y), x.appendChild(s), N[a.discussionIndex] = s,
_ && _.getDiscussion() === a && (y.scrollTop += parseInt(s.style.top) - y.scrollTop - 3 * y.offsetHeight / 4,
u(s)), T = setTimeout(t, 5);
}
if (void 0 !== E) {
L = !1, M = [];
var n = i["author.name"];
S = [];
var o = e.sortBy(E.discussionList, function(t) {
return t.selectionEnd;
});
clearTimeout(T), T = setTimeout(t, 5);
}
}, 50);
return f.onLayoutResize = A, f.onFileOpen = function(t) {
E = t, A();
}, f.onContentChanged = function(t) {
E === t && A();
}, f.onCursorCoordinates = function(t, e) {
w = e, l(C, e, !0);
}, f.onCommentsChanged = function(t) {
if (E === t) {
if (void 0 !== _) {
var e = _;
e.discussionIndex && (e.getPopoverElt().querySelector(".discussion-comment-list").innerHTML = p());
try {
k.undoToRange(e.rangyRange);
} catch (n) {}
var i = e.getDiscussion();
e.selectionRange = b.createRange(i.selectionStart, i.selectionEnd), e.rangyRange = o.createRange(),
e.rangyRange.setStart(e.selectionRange.startContainer, e.selectionRange.startOffset),
e.rangyRange.setEnd(e.selectionRange.endContainer, e.selectionRange.endOffset),
setTimeout(function() {
_ === e && k.applyToRange(e.rangyRange);
}, 50);
}
A();
}
}, f.onEditorPopover = function() {
d();
}, f.onDiscussionCreated = function(t) {
E === t && A();
}, f.onDiscussionRemoved = function(t, e) {
E === t && (void 0 !== _ && _.discussionIndex == e.discussionIndex && d(), A());
}, f.onReady = function() {
k = o.createCssClassApplier("comment-highlight", {
normalize: !1
});
var a = "";
y = document.getElementById("wmd-input"), x = document.querySelector("#wmd-input > .editor-margin"),
x.appendChild(C);
var l = t(r("div", {
"class": "comments-popover"
}));
t(document.body).append(l).on("click", function(t) {
_ && _.$commentElt[0] !== t.target && d();
}).popover({
placement: "auto top",
container: ".comments-popover",
html: !0,
title: function() {
if (!_) return !0;
var t = _.getDiscussion(), n = t.selectionEnd - t.selectionStart, i = v.getValue().substr(t.selectionStart, n > 20 ? 20 : n);
return n > 20 && (i += "..."), e.template(g, {
title: i
});
},
content: function() {
var t = e.template(s, {
commentList: p()
});
return t;
},
selector: "#wmd-input > .editor-margin > .discussion"
}), t(x).on("show.bs.popover", function(t) {
h.onEditorPopover();
var e = new c(t.target, E);
_ = e;
var n = e.getDiscussion();
if (!n) {
var i = Math.min(b.selectionStart, b.selectionEnd), r = Math.max(b.selectionStart, b.selectionEnd);
if (i === r) {
var o = b.getClosestWordOffset(i);
i = o.start, r = o.end;
}
n = {
selectionStart: i,
selectionEnd: r,
commentList: []
}, E.newDiscussion = n;
}
e.selectionRange = b.createRange(n.selectionStart, n.selectionEnd), y.scrollTop += parseInt(t.target.style.top) - y.scrollTop - 3 * y.offsetHeight / 4;
}).on("shown.bs.popover", function(r) {
var s = _, l = s.getPopoverElt();
s.$authorInputElt = t(l.querySelector(".input-comment-author")).val(i["author.name"]),
s.$contentInputElt = t(l.querySelector(".input-comment-content")), s.hr = l.querySelector("hr"),
u(s.commentElt), l.querySelector(".scrollport").scrollTop = 9999999;
var c = t(l.querySelector(".action-add-comment"));
t().add(s.$contentInputElt).add(s.$authorInputElt).keydown(function(t) {
13 === t.which && (t.preventDefault(), c.click());
}), c.click(function(t) {
var i = n.getInputTextValue(s.$authorInputElt), r = n.getInputTextValue(s.$contentInputElt, t);
if (!t.isPropagationStopped()) {
var o = s.getDiscussion();
s.$contentInputElt.val(""), d(), o.commentList = o.commentList || [], o.commentList.push({
author: i,
content: r
});
var a = s.fileDesc.discussionList || {};
if (o.discussionIndex) s.fileDesc.discussionList = a, h.onCommentsChanged(s.fileDesc); else {
var l;
do l = n.id(); while (e.has(a, l));
o.discussionIndex = l, a[l] = o, s.fileDesc.discussionList = a, h.onDiscussionCreated(s.fileDesc, o);
}
y.focus();
}
});
var p = t(l.querySelector(".action-remove-discussion"));
r.target.discussionIndex ? p.click(function() {
d();
var t = s.getDiscussion();
delete s.fileDesc.discussionList[t.discussionIndex], s.fileDesc.discussionList = s.fileDesc.discussionList,
h.onDiscussionRemoved(s.fileDesc, t), y.focus();
}) : p.hide(), s.rangyRange = o.createRange(), s.rangyRange.setStart(s.selectionRange.startContainer, s.selectionRange.startOffset),
s.rangyRange.setEnd(s.selectionRange.endContainer, s.selectionRange.endOffset),
setTimeout(function() {
_ === s && k.applyToRange(s.rangyRange);
}, 50), s.$contentInputElt.focus().val(a);
}).on("hide.bs.popover", function() {
if (_) {
_.$commentElt.removeClass("active"), a = _.$contentInputElt.val(), i["author.name"] = _.$authorInputElt.val();
try {
k.undoToRange(_.rangyRange);
} catch (t) {}
_ = void 0, delete E.newDiscussion;
}
}), l.on("click", ".popover", function(t) {
t.stopPropagation();
});
var f = t(C);
I = t(".button-open-discussion").click(function(n) {
var i = f;
if (_) if (_.discussionIndex) {
var r = -1;
M.some(function(t, e) {
if (t === _.commentElt) return r = e, !0;
}), i = t(M[r + 1]);
} else i = t(e.first(M)); else b.selectionStart === b.selectionEnd && M.length && (i = t(e.first(M)));
0 === i.length ? (d(), v.focus(), v.adjustCursorPosition(!0)) : i.click(), n.stopPropagation();
}), D = I.find("i");
}, f;
}), define("text!html/findReplace.html", [], function() {
return '\n
Helps find and replace text in the current document.
\n
\n\t
\n\t\t\n\t\t
\n\t\t\t\n\t\t
\n\t
\n
';
}), define("extensions/findReplace", [ "jquery", "underscore", "crel", "utils", "classes/Extension", "mousetrap", "rangy", "text!html/findReplace.html", "text!html/findReplaceSettingsBlock.html" ], function(t, e, n, i, r, o, a, s, l) {
function c() {
u(), M.forEach(function(t) {
try {
x.undoToRange(t);
} catch (e) {}
}), M = [];
}
function u() {
if (S) {
try {
S && w.undoToRange(S);
} catch (t) {}
S = void 0;
}
}
function d(t) {
function e(t) {
return t.container === s.container ? {
container: o.endContainer.parentElement.nextSibling,
offsetInContainer: t.offsetInContainer - s.offsetInContainer,
offset: t.offset
} : t;
}
if (O) {
var n = k.val(), i = I.prop("checked"), r = D.prop("checked");
if (t || n != A || i != R || r != P) {
A = n, R = i, P = r, c();
var o, s = {};
L = [];
var l = 0, u = n.length;
if (u) try {
var d = i ? "gm" : "gmi";
if (n = r ? n : n.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), N = new RegExp(n, d),
b.getValue().replace(N, function(t, e) {
L.push({
start: e,
end: e + t.length
});
}), l = L.length, L.length < 200) {
var p = [];
L.forEach(function(t) {
p.push(t.start), p.push(t.end);
}), p = b.selectionMgr.findOffsets(p);
for (var h = 0; h < p.length; h += 2) {
var f = p[h], m = p[h + 1], g = e(f), v = e(m), y = a.createRange();
y.setStart(g.container, g.offsetInContainer), y.setEnd(v.container, v.offsetInContainer),
s = m, o = y, x.applyToRange(y), M[f.offset] = y;
}
b.selectionMgr.hasFocus && b.selectionMgr.updateSelectionRange();
}
} catch (w) {}
T.innerHTML = l;
}
}
}
function p() {
y.onEditorPopover(), O = !0, _.show(), k.focus()[0].setSelectionRange(0, k.val().length),
b.selectionMgr.adjustTop = 50, b.selectionMgr.adjustBottom = 220, d(!0);
}
function h() {
O = !1, _.hide(), c(), b.selectionMgr.adjustTop = 0, b.selectionMgr.adjustBottom = 0,
b.focus();
}
function f() {
u();
var t = Math.min(b.selectionMgr.selectionStart, b.selectionMgr.selectionEnd), n = e.find(L, function(e) {
return e.start > t;
});
if (n || (n = e.first(L)), n) {
if (S = M[n.start], !S) {
var i = b.selectionMgr.createRange(n.start, n.end);
S = a.createRange(), S.setStart(i.startContainer, i.startOffset), S.setEnd(i.endContainer, i.endOffset);
}
w.applyToRange(S), S.start = n.start, S.end = n.end, b.selectionMgr.setSelectionStartEnd(n.start, n.end),
b.selectionMgr.updateCursorCoordinates(!0);
}
}
function m() {
if (!S) return f();
var t = E.val();
b.replace(S.start, S.end, t), setTimeout(function() {
f(), E.focus();
}, 1);
}
function g() {
var t = E.val();
b.replaceAll(N, t);
}
var v = new r("findReplace", "Find and Replace", (!0), (!0));
v.settingsBlock = l, v.defaultConfig = {
findReplaceShortcut: "mod+f"
}, v.onLoadSettings = function() {
i.setInputValue("#input-find-replace-shortcut", v.config.findReplaceShortcut);
}, v.onSaveSettings = function(t, e) {
t.findReplaceShortcut = i.getInputTextValue("#input-find-replace-shortcut", e);
};
var b;
v.onEditorCreated = function(t) {
b = t;
};
var y;
v.onEventMgrCreated = function(t) {
y = t;
};
var x, w, S, C, _, k, E, T, I, D, N, M = [], L = [], A = "", R = !1, P = !1, O = !1;
return v.onEditorPopover = function() {
h();
}, v.onContentChanged = e.bind(d, null, !0), v.onFileOpen = e.bind(d, null, !0),
v.onReady = function() {
x = a.createCssClassApplier("find-replace-highlight", {
normalize: !1
}), w = a.createCssClassApplier("find-replace-select", {
normalize: !1
}), C = document.querySelector("#wmd-input .editor-content");
var i = n("div", {
"class": "find-replace"
});
_ = t(i).hide(), i.innerHTML = s, document.querySelector(".layout-wrapper-l2").appendChild(i),
t(".button-find-replace-dismiss").click(function() {
h();
}), T = i.querySelector(".found-counter"), I = _.find(".checkbox-case-sensitive").change(e.bind(d, null, !1)),
D = _.find(".checkbox-regexp").change(e.bind(d, null, !1)), _.find(".search-button").click(f),
k = t("#input-find-replace-search-for").keyup(e.bind(d, null, !1)), _.find(".replace-button").click(m),
E = t("#input-find-replace-replace-with"), _.find(".replace-all-button").click(g),
t().add(k).add(E).keydown(function(t) {
13 === t.which && (t.preventDefault(), f());
}), o.bind(v.config.findReplaceShortcut, function(t) {
var e = b.selectionMgr.getSelectedText();
e && k.val(e), p(), t.preventDefault();
});
}, v;
}), define("text!html/htmlSanitizerSettingsBlock.html", [], function() {
return '
Prevents cross-site-scripting attacks (XSS).
\n
Careful: Disable at your own risk!
\n';
}), define("extensions/htmlSanitizer", [ "jquery", "underscore", "utils", "logger", "classes/Extension", "text!html/htmlSanitizerSettingsBlock.html" ], function(t, e, n, i, r, o) {
function a(t, e) {
var i, r = e ? m : f;
if (i = n.urlResolve(t).href, "" !== i && !i.match(r)) return "unsafe:" + i;
}
function s(t) {
var e, n = {}, i = t.split(",");
for (e = 0; e < i.length; e++) n[i[e]] = !0;
return n;
}
function l(t, e) {
function n(t, n, r, o) {
if (n = n && n.toLowerCase(), D[n]) for (;s.last() && N[s.last()]; ) i("", s.last());
I[n] && s.last() == n && i("", n), o = k[n] || !!o, o || s.push(n);
var a = {};
r.replace(b, function(t, e, n, i, r) {
var o = n || i || r || "";
a[e] = c(o);
}), e.start && e.start(n, a, o);
}
function i(t, n) {
var i, r = 0;
if (n = n && n.toLowerCase()) for (r = s.length - 1; r >= 0 && s[r] != n; r--) ;
if (r >= 0) {
for (i = s.length - 1; i >= r; i--) e.end && e.end(s[i]);
s.length = r;
}
}
var r, o, a, s = [], l = t;
for (s.last = function() {
return s[s.length - 1];
}; t; ) {
if (o = !0, s.last() && M[s.last()]) t = t.replace(new RegExp("(.*)<\\s*\\/\\s*" + s.last() + "[^>]*>", "i"), function(t, n) {
return n = n.replace(w, "$1").replace(C, "$1"), e.chars && e.chars(c(n)), "";
}), i("", s.last()); else if (0 === t.indexOf("", r) === r && (e.comment && e.comment(t.substring(4, r)),
t = t.substring(r + 3), o = !1)) : S.test(t) ? (a = t.match(S), a && (t = t.replace(a[0], ""),
o = !1)) : x.test(t) ? (a = t.match(v), a && (t = t.substring(a[0].length), a[0].replace(v, i),
o = !1)) : y.test(t) && (a = t.match(g), a && (t = t.substring(a[0].length), a[0].replace(g, n),
o = !1)), o) {
r = t.indexOf("<");
var u = r < 0 ? t : t.substring(0, r);
t = r < 0 ? "" : t.substring(r), e.chars && e.chars(c(u));
}
if (t == l) return s.reverse(), s.forEach(function(t) {
h.push(""), h.push(t), h.push(">");
});
l = t;
}
i();
}
function c(t) {
if (!t) return "";
var e = O.exec(t), n = e[1], i = e[3], r = e[2];
return r && (P.innerHTML = r.replace(//g, ">");
}
function d(t, n) {
var i = !1, r = e.bind(t.push, t);
return {
start: function(t, o, a) {
t = t && t.toLowerCase(), !i && M[t] && (i = t), i || L[t] !== !0 || (r("<"), r(t),
e.forEach(o, function(e, i) {
var o = i && i.toLowerCase(), a = "img" === t && "src" === o || "background" === o;
R[o] !== !0 || A[o] === !0 && !n(e, a) || (r(" "), r(i), r('="'), r(u(e)), r('"'));
}), r(a ? "/>" : ">"));
},
end: function(t) {
t = t && t.toLowerCase(), i || L[t] !== !0 || (r(""), r(t), r(">")), t == i && (i = !1);
},
chars: function(t) {
i || r(u(t));
},
comment: function(t) {
i || (r(""));
}
};
}
var p = new r("htmlSanitizer", "HTML Sanitizer", (!0));
p.settingsBlock = o;
var h;
p.onPagedownConfigure = function(t) {
var e = t.getConverter();
e.hooks.chain("postConversion", function(t) {
return h = [], t.split('').forEach(function(t) {
l(t, d(h, function(t, e) {
return !/^unsafe/.test(a(t, e));
})), h.push('');
}), h.slice(0, -1).join("");
});
};
var f = /^\s*(https?|ftp|mailto|tel|file):/, m = /^\s*(https?|ftp|file):|data:image\//, g = /^<\s*([\w:-]+)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*>/, v = /^<\s*\/\s*([\w:-]+)[^>]*>/, b = /([\w:-]+)(?:\s*=\s*(?:(?:"((?:[^"])*)")|(?:'((?:[^'])*)')|([^>\s]+)))?/g, y = /^, x = /^<\s*\//, w = //g, S = /]*?)>/i, C = //g, _ = /([^\#-~| |!])/g, k = s("area,br,col,hr,img,wbr"), E = s("colgroup,dd,dt,li,p,tbody,td,tfoot,th,thead,tr"), T = s("rp,rt"), I = e.extend({}, T, E), D = e.extend({}, E, s("address,article,aside,blockquote,caption,center,del,dir,div,dl,figure,figcaption,footer,h1,h2,h3,h4,h5,h6,header,hgroup,hr,ins,map,menu,nav,ol,pre,script,section,table,ul")), N = e.extend({}, T, s("a,abbr,acronym,b,bdi,bdo,big,br,cite,code,del,dfn,em,font,i,img,ins,kbd,label,map,mark,q,ruby,rp,rt,s,samp,small,span,strike,strong,sub,sup,time,tt,u,var")), M = s("script,style");
D.iframe = !0;
var L = e.extend({}, k, D, N, I), A = s("background,cite,href,longdesc,src,usemap"), R = e.extend({}, A, s("abbr,align,alt,axis,bgcolor,border,cellpadding,cellspacing,class,clear,color,cols,colspan,compact,coords,dir,face,headers,height,hreflang,hspace,ismap,lang,language,nohref,nowrap,rel,rev,rows,rowspan,rules,scope,scrolling,shape,size,span,start,summary,target,title,type,valign,value,vspace,width"));
R.id = !0, R.allowfullscreen = !0;
var P = document.createElement("pre"), O = /^(\s*)([\s\S]*?)(\s*)$/;
return p;
}), function(t) {
var e = "waitForImages";
t.waitForImages = {
hasImageProperties: [ "backgroundImage", "listStyleImage", "borderImage", "borderCornerImage" ]
}, t.expr[":"].uncached = function(e) {
if (!t(e).is('img[src!=""]')) return !1;
var n = new Image();
return n.src = e.src, !n.complete;
}, t.fn.waitForImages = function(n, i, r) {
var o = 0, a = 0;
if (t.isPlainObject(arguments[0]) && (r = arguments[0].waitForAll, i = arguments[0].each,
n = arguments[0].finished), n = n || t.noop, i = i || t.noop, r = !!r, !t.isFunction(n) || !t.isFunction(i)) throw new TypeError("An invalid callback was supplied.");
return this.each(function() {
var s = t(this), l = [], c = t.waitForImages.hasImageProperties || [], u = /url\(\s*(['"]?)(.*?)\1\s*\)/g;
r ? s.find("*").andSelf().each(function() {
var e = t(this);
e.is("img:uncached") && l.push({
src: e.attr("src"),
element: e[0]
}), t.each(c, function(t, n) {
var i, r = e.css(n);
if (!r) return !0;
for (;i = u.exec(r); ) l.push({
src: i[2],
element: e[0]
});
});
}) : s.find("img:uncached").each(function() {
l.push({
src: this.src,
element: this
});
}), o = l.length, a = 0, 0 === o && n.call(s[0]), t.each(l, function(r, l) {
var c = new Image();
t(c).bind("load." + e + " error." + e, function(t) {
if (a++, i.call(l.element, a, o, "load" == t.type), a == o) return n.call(s[0]),
!1;
}), c.src = l.src;
});
});
};
}(jQuery), define("jquery-waitforimages", function() {}), define("eventMgr", [ "jquery", "underscore", "crel", "mousetrap", "utils", "logger", "classes/Extension", "settings", "text!html/settingsExtensionsAccordion.html", "extensions/yamlFrontMatterParser", "extensions/markdownSectionParser", "extensions/partialRendering", "extensions/buttonMarkdownSyntax", "extensions/googleAnalytics", "extensions/twitter", "extensions/dialogAbout", "extensions/dialogManagePublication", "extensions/dialogManageSynchronization", "extensions/dialogManageSharing", "extensions/dialogOpenHarddrive", "extensions/documentTitle", "extensions/documentSelector", "extensions/documentPanel", "extensions/documentManager", "extensions/workingIndicator", "extensions/notifications", "extensions/umlDiagrams", "extensions/markdownExtra", "extensions/toc", "extensions/mathJax", "extensions/emailConverter", "extensions/scrollSync", "extensions/buttonSync", "extensions/buttonPublish", "extensions/buttonStat", "extensions/buttonHtmlCode", "extensions/buttonViewer", "extensions/welcomeTour", "extensions/shortcuts", "extensions/userCustom", "extensions/comments", "extensions/findReplace", "extensions/htmlSanitizer", "bootstrap", "jquery-waitforimages" ], function(t, e, n, i, r, o, a, s, l) {
function c(t) {
return e.chain(h).map(function(e) {
return e.enabled && e[t];
}).compact().value();
}
function u(t) {
return m[t] = c(t), function() {
o.log(t, arguments);
var n = arguments;
e.each(m[t], function(t) {
try {
t.apply(null, n);
} catch (i) {
console.error(e.isObject(i) ? i.stack : i);
}
});
};
}
function d(t) {
p[t] = u(t);
}
var p = {}, h = e.chain(arguments).map(function(t) {
return t instanceof a && t;
}).compact().value(), f = s.extensionSettings || {};
e.each(h, function(t) {
t.config = e.extend({}, t.defaultConfig, f[t.extensionId]), window.viewerMode === !0 && t.disableInViewer === !0 ? t.enabled = !1 : t.enabled = !t.isOptional || void 0 === t.config.enabled || t.config.enabled === !0;
});
var m = {};
p.addListener = function(t, e) {
try {
m[t].push(e);
} catch (n) {
console.error("No event listener called " + t);
}
}, u("onInit")(), p.onLoadSettings = function() {
o.log("onLoadSettings"), e.each(h, function(t) {
var e = !t.isOptional || void 0 === t.config.enabled || t.config.enabled === !0;
r.setInputChecked("#input-enable-extension-" + t.extensionId, e), "markdownExtra" == t.extensionId ? r.setInputChecked("#input-settings-markdown-extra", e) : "mathJax" == t.extensionId && r.setInputChecked("#input-settings-mathjax", e);
var n = t.onLoadSettings;
n && n();
});
}, p.onSaveSettings = function(t, n) {
o.log("onSaveSettings"), e.each(h, function(i) {
var o = e.extend({}, i.defaultConfig);
o.enabled = r.getInputChecked("#input-enable-extension-" + i.extensionId);
var a;
"markdownExtra" == i.extensionId ? (a = r.getInputChecked("#input-settings-markdown-extra"),
a != i.enabled && (o.enabled = a)) : "mathJax" == i.extensionId && (a = r.getInputChecked("#input-settings-mathjax"),
a != i.enabled && (o.enabled = a));
var s = i.onSaveSettings;
s && s(o, n), t[i.extensionId] = o;
});
}, d("onMessage"), d("onError"), d("onOfflineChanged"), d("onUserActive"), d("onAsyncRunning"),
d("onPeriodicRun"), d("onEditorCreated"), d("onFileMgrCreated"), d("onSynchronizerCreated"),
d("onPublisherCreated"), d("onSharingCreated"), d("onEventMgrCreated"), d("onFileCreated"),
d("onFileDeleted"), d("onFileSelected"), d("onFileOpen"), d("onFileClosed"), d("onContentChanged"),
d("onTitleChanged"), d("onFoldersChanged"), d("onSyncRunning"), d("onSyncSuccess"),
d("onSyncImportSuccess"), d("onSyncExportSuccess"), d("onSyncRemoved"), d("onPublishRunning"),
d("onPublishSuccess"), d("onNewPublishSuccess"), d("onPublishRemoved"), d("onLayoutCreated"),
d("onLayoutResize"), d("onExtensionButtonResize"), d("onPagedownConfigure"), d("onSectionsCreated"),
d("onCursorCoordinates"), d("onEditorPopover"), d("onDiscussionCreated"), d("onDiscussionRemoved"),
d("onCommentsChanged"), d("onTweet");
var g, v, b = u("onPreviewFinished"), y = c("onAsyncPreview");
p.onAsyncPreview = function() {
function t(n) {
var i = n.length ? n.shift() : function() {
setTimeout(function() {
var t = "";
e.each(g.children, function(n) {
if (!n.exportableHtml) {
var i = n.cloneNode(!0);
e.each(i.querySelectorAll(".MathJax_SVG, .MathJax_SVG_Display, .MathJax_Preview"), function(t) {
t.parentNode.removeChild(t);
}), n.exportableHtml = i.innerHTML;
}
t += n.exportableHtml;
});
var n = r.trim(t), i = n.replace(/ .*?<\/span> /g, "");
b(n, i);
}, 10);
};
i(function() {
t(n);
});
}
o.log("onAsyncPreview"), t(y.concat([ function(t) {
v.waitForImages(t);
} ]));
};
var x = u("onReady");
return p.onReady = function() {
g = document.getElementById("preview-contents"), v = t(g);
var r = function(t) {
var i = n("div", {
"class": "btn-group"
}), r = t();
return e.isString(r) ? i.innerHTML = r : e.isElement(r) && i.appendChild(r), i;
};
if (window.viewerMode === !1) {
var a = e.chain(h).sortBy(function(t) {
return t.extensionName.toLowerCase();
}).reduce(function(t, n) {
return t + (n.settingsBlock ? e.template(l, {
extensionId: n.extensionId,
extensionName: n.extensionName,
isOptional: n.isOptional,
settingsBlock: n.settingsBlock
}) : "");
}, "").value();
document.querySelector(".accordion-extensions").innerHTML = a, o.log("onCreateButton");
var s = c("onCreateButton"), u = document.createDocumentFragment();
e.each(s, function(t) {
u.appendChild(r(t));
}), document.querySelector(".extension-buttons").appendChild(u);
}
o.log("onCreatePreviewButton");
var d = c("onCreatePreviewButton"), f = document.createDocumentFragment();
e.each(d, function(t) {
f.appendChild(r(t));
});
var m = document.querySelector(".extension-preview-buttons");
m.appendChild(f), i.bind("escape", function() {
p.onEditorPopover();
}), x();
}, p.onEventMgrCreated(p), p;
}), function() {
var t = /\blang(?:uage)?-(?!\*)(\w+)\b/i, e = self.Prism = {
util: {
type: function(t) {
return Object.prototype.toString.call(t).match(/\[object (\w+)\]/)[1];
},
clone: function(t) {
var n = e.util.type(t);
switch (n) {
case "Object":
var i = {};
for (var r in t) t.hasOwnProperty(r) && (i[r] = e.util.clone(t[r]));
return i;
case "Array":
return t.slice();
}
return t;
}
},
languages: {
extend: function(t, n) {
var i = e.util.clone(e.languages[t]);
for (var r in n) i[r] = n[r];
return i;
},
insertBefore: function(t, n, i, r) {
r = r || e.languages;
var o = r[t], a = {};
for (var s in o) if (o.hasOwnProperty(s)) {
if (s == n) for (var l in i) i.hasOwnProperty(l) && (a[l] = i[l]);
a[s] = o[s];
}
return r[t] = a;
},
DFS: function(t, n) {
for (var i in t) n.call(t, i, t[i]), "Object" === e.util.type(t) && e.languages.DFS(t[i], n);
}
},
highlightAll: function(t, n) {
for (var i, r = document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'), o = 0; i = r[o++]; ) e.highlightElement(i, t === !0, n);
},
highlightElement: function(i, r, o) {
for (var a, s, l = i; l && !t.test(l.className); ) l = l.parentNode;
if (l && (a = (l.className.match(t) || [ , "" ])[1], s = e.languages[a]), s) {
i.className = i.className.replace(t, "").replace(/\s+/g, " ") + " language-" + a,
l = i.parentNode, /pre/i.test(l.nodeName) && (l.className = l.className.replace(t, "").replace(/\s+/g, " ") + " language-" + a);
var c = i.textContent;
if (c) {
c = c.replace(/&/g, "&").replace(/ t.length) break t;
if (!(h instanceof r)) {
l.lastIndex = 0;
var f = l.exec(h);
if (f) {
u && (d = f[1].length);
var m = f.index - 1 + d, f = f[0].slice(d), g = f.length, v = m + g, b = h.slice(0, m + 1), y = h.slice(v + 1), x = [ p, 1 ];
b && x.push(b);
var w = new r(s, c ? e.tokenize(f, c) : f);
x.push(w), y && x.push(y), Array.prototype.splice.apply(o, x);
}
}
}
}
return o;
},
hooks: {
all: {},
add: function(t, n) {
var i = e.hooks.all;
i[t] = i[t] || [], i[t].push(n);
},
run: function(t, n) {
var i = e.hooks.all[t];
if (i && i.length) for (var r, o = 0; r = i[o++]; ) r(n);
}
}
}, n = e.Token = function(t, e) {
this.type = t, this.content = e;
};
if (n.stringify = function(t, i, r) {
if ("string" == typeof t) return t;
if ("[object Array]" == Object.prototype.toString.call(t)) return t.map(function(e) {
return n.stringify(e, i, t);
}).join("");
var o = {
type: t.type,
content: n.stringify(t.content, i, r),
tag: "span",
classes: [ "token", t.type ],
attributes: {},
language: i,
parent: r
};
"comment" == o.type && (o.attributes.spellcheck = "true"), e.hooks.run("wrap", o);
var a = "";
for (var s in o.attributes) a += s + '="' + (o.attributes[s] || "") + '"';
return "<" + o.tag + ' class="' + o.classes.join(" ") + '" ' + a + ">" + o.content + "" + o.tag + ">";
}, !self.document) return void self.addEventListener("message", function(t) {
var n = JSON.parse(t.data), i = n.language, r = n.code;
self.postMessage(JSON.stringify(e.tokenize(r, e.languages[i]))), self.close();
}, !1);
var i = document.getElementsByTagName("script");
i = i[i.length - 1], i && (e.filename = i.src, document.addEventListener && !i.hasAttribute("data-manual") && document.addEventListener("DOMContentLoaded", e.highlightAll));
}(), define("prism-core", function(t) {
return function() {
var e;
return e || t.Prism;
};
}(this));
var DIFF_DELETE = -1, DIFF_INSERT = 1, DIFF_EQUAL = 0;
diff_match_patch.Diff, diff_match_patch.prototype.diff_main = function(t, e, n, i) {
"undefined" == typeof i && (i = this.Diff_Timeout <= 0 ? Number.MAX_VALUE : new Date().getTime() + 1e3 * this.Diff_Timeout);
var r = i;
if (null == t || null == e) throw new Error("Null input. (diff_main)");
if (t == e) return t ? [ [ DIFF_EQUAL, t ] ] : [];
"undefined" == typeof n && (n = !0);
var o = n, a = this.diff_commonPrefix(t, e), s = t.substring(0, a);
t = t.substring(a), e = e.substring(a), a = this.diff_commonSuffix(t, e);
var l = t.substring(t.length - a);
t = t.substring(0, t.length - a), e = e.substring(0, e.length - a);
var c = this.diff_compute_(t, e, o, r);
return s && c.unshift([ DIFF_EQUAL, s ]), l && c.push([ DIFF_EQUAL, l ]), this.diff_cleanupMerge(c),
c;
}, diff_match_patch.prototype.diff_compute_ = function(t, e, n, i) {
var r;
if (!t) return [ [ DIFF_INSERT, e ] ];
if (!e) return [ [ DIFF_DELETE, t ] ];
var o = t.length > e.length ? t : e, a = t.length > e.length ? e : t, s = o.indexOf(a);
if (s != -1) return r = [ [ DIFF_INSERT, o.substring(0, s) ], [ DIFF_EQUAL, a ], [ DIFF_INSERT, o.substring(s + a.length) ] ],
t.length > e.length && (r[0][0] = r[2][0] = DIFF_DELETE), r;
if (1 == a.length) return [ [ DIFF_DELETE, t ], [ DIFF_INSERT, e ] ];
var l = this.diff_halfMatch_(t, e);
if (l) {
var c = l[0], u = l[1], d = l[2], p = l[3], h = l[4], f = this.diff_main(c, d, n, i), m = this.diff_main(u, p, n, i);
return f.concat([ [ DIFF_EQUAL, h ] ], m);
}
return n && t.length > 100 && e.length > 100 ? this.diff_lineMode_(t, e, i) : this.diff_bisect_(t, e, i);
}, diff_match_patch.prototype.diff_lineMode_ = function(t, e, n) {
var i = this.diff_linesToChars_(t, e);
t = i.chars1, e = i.chars2;
var r = i.lineArray, o = this.diff_main(t, e, !1, n);
this.diff_charsToLines_(o, r), this.diff_cleanupSemantic(o), o.push([ DIFF_EQUAL, "" ]);
for (var a = 0, s = 0, l = 0, c = "", u = ""; a < o.length; ) {
switch (o[a][0]) {
case DIFF_INSERT:
l++, u += o[a][1];
break;
case DIFF_DELETE:
s++, c += o[a][1];
break;
case DIFF_EQUAL:
if (s >= 1 && l >= 1) {
o.splice(a - s - l, s + l), a = a - s - l;
for (var i = this.diff_main(c, u, !1, n), d = i.length - 1; d >= 0; d--) o.splice(a, 0, i[d]);
a += i.length;
}
l = 0, s = 0, c = "", u = "";
}
a++;
}
return o.pop(), o;
}, diff_match_patch.prototype.diff_bisect_ = function(t, e, n) {
for (var i = t.length, r = e.length, o = Math.ceil((i + r) / 2), a = o, s = 2 * o, l = new Array(s), c = new Array(s), u = 0; u < s; u++) l[u] = -1,
c[u] = -1;
l[a + 1] = 0, c[a + 1] = 0;
for (var d = i - r, p = d % 2 != 0, h = 0, f = 0, m = 0, g = 0, v = 0; v < o && !(new Date().getTime() > n); v++) {
for (var b = -v + h; b <= v - f; b += 2) {
var y, x = a + b;
y = b == -v || b != v && l[x - 1] < l[x + 1] ? l[x + 1] : l[x - 1] + 1;
for (var w = y - b; y < i && w < r && t.charAt(y) == e.charAt(w); ) y++, w++;
if (l[x] = y, y > i) f += 2; else if (w > r) h += 2; else if (p) {
var S = a + d - b;
if (S >= 0 && S < s && c[S] != -1) {
var C = i - c[S];
if (y >= C) return this.diff_bisectSplit_(t, e, y, w, n);
}
}
}
for (var _ = -v + m; _ <= v - g; _ += 2) {
var C, S = a + _;
C = _ == -v || _ != v && c[S - 1] < c[S + 1] ? c[S + 1] : c[S - 1] + 1;
for (var k = C - _; C < i && k < r && t.charAt(i - C - 1) == e.charAt(r - k - 1); ) C++,
k++;
if (c[S] = C, C > i) g += 2; else if (k > r) m += 2; else if (!p) {
var x = a + d - _;
if (x >= 0 && x < s && l[x] != -1) {
var y = l[x], w = a + y - x;
if (C = i - C, y >= C) return this.diff_bisectSplit_(t, e, y, w, n);
}
}
}
}
return [ [ DIFF_DELETE, t ], [ DIFF_INSERT, e ] ];
}, diff_match_patch.prototype.diff_bisectSplit_ = function(t, e, n, i, r) {
var o = t.substring(0, n), a = e.substring(0, i), s = t.substring(n), l = e.substring(i), c = this.diff_main(o, a, !1, r), u = this.diff_main(s, l, !1, r);
return c.concat(u);
}, diff_match_patch.prototype.diff_linesToChars_ = function(t, e) {
function n(t) {
for (var e = "", n = 0, o = -1, a = i.length; o < t.length - 1; ) {
o = t.indexOf("\n", n), o == -1 && (o = t.length - 1);
var s = t.substring(n, o + 1);
n = o + 1, (r.hasOwnProperty ? r.hasOwnProperty(s) : void 0 !== r[s]) ? e += String.fromCharCode(r[s]) : (e += String.fromCharCode(a),
r[s] = a, i[a++] = s);
}
return e;
}
var i = [], r = {};
i[0] = "";
var o = n(t), a = n(e);
return {
chars1: o,
chars2: a,
lineArray: i
};
}, diff_match_patch.prototype.diff_charsToLines_ = function(t, e) {
for (var n = 0; n < t.length; n++) {
for (var i = t[n][1], r = [], o = 0; o < i.length; o++) r[o] = e[i.charCodeAt(o)];
t[n][1] = r.join("");
}
}, diff_match_patch.prototype.diff_commonPrefix = function(t, e) {
if (!t || !e || t.charAt(0) != e.charAt(0)) return 0;
for (var n = 0, i = Math.min(t.length, e.length), r = i, o = 0; n < r; ) t.substring(o, r) == e.substring(o, r) ? (n = r,
o = n) : i = r, r = Math.floor((i - n) / 2 + n);
return r;
}, diff_match_patch.prototype.diff_commonSuffix = function(t, e) {
if (!t || !e || t.charAt(t.length - 1) != e.charAt(e.length - 1)) return 0;
for (var n = 0, i = Math.min(t.length, e.length), r = i, o = 0; n < r; ) t.substring(t.length - r, t.length - o) == e.substring(e.length - r, e.length - o) ? (n = r,
o = n) : i = r, r = Math.floor((i - n) / 2 + n);
return r;
}, diff_match_patch.prototype.diff_commonOverlap_ = function(t, e) {
var n = t.length, i = e.length;
if (0 == n || 0 == i) return 0;
n > i ? t = t.substring(n - i) : n < i && (e = e.substring(0, n));
var r = Math.min(n, i);
if (t == e) return r;
for (var o = 0, a = 1; ;) {
var s = t.substring(r - a), l = e.indexOf(s);
if (l == -1) return o;
a += l, 0 != l && t.substring(r - a) != e.substring(0, a) || (o = a, a++);
}
}, diff_match_patch.prototype.diff_halfMatch_ = function(t, e) {
function n(t, e, n) {
for (var i, r, o, s, l = t.substring(n, n + Math.floor(t.length / 4)), c = -1, u = ""; (c = e.indexOf(l, c + 1)) != -1; ) {
var d = a.diff_commonPrefix(t.substring(n), e.substring(c)), p = a.diff_commonSuffix(t.substring(0, n), e.substring(0, c));
u.length < p + d && (u = e.substring(c - p, c) + e.substring(c, c + d), i = t.substring(0, n - p),
r = t.substring(n + d), o = e.substring(0, c - p), s = e.substring(c + d));
}
return 2 * u.length >= t.length ? [ i, r, o, s, u ] : null;
}
if (this.Diff_Timeout <= 0) return null;
var i = t.length > e.length ? t : e, r = t.length > e.length ? e : t;
if (i.length < 4 || 2 * r.length < i.length) return null;
var o, a = this, s = n(i, r, Math.ceil(i.length / 4)), l = n(i, r, Math.ceil(i.length / 2));
if (!s && !l) return null;
o = l ? s && s[4].length > l[4].length ? s : l : s;
var c, u, d, p;
t.length > e.length ? (c = o[0], u = o[1], d = o[2], p = o[3]) : (d = o[0], p = o[1],
c = o[2], u = o[3]);
var h = o[4];
return [ c, u, d, p, h ];
}, diff_match_patch.prototype.diff_cleanupSemantic = function(t) {
for (var e = !1, n = [], i = 0, r = null, o = 0, a = 0, s = 0, l = 0, c = 0; o < t.length; ) t[o][0] == DIFF_EQUAL ? (n[i++] = o,
a = l, s = c, l = 0, c = 0, r = t[o][1]) : (t[o][0] == DIFF_INSERT ? l += t[o][1].length : c += t[o][1].length,
r && r.length <= Math.max(a, s) && r.length <= Math.max(l, c) && (t.splice(n[i - 1], 0, [ DIFF_DELETE, r ]),
t[n[i - 1] + 1][0] = DIFF_INSERT, i--, i--, o = i > 0 ? n[i - 1] : -1, a = 0, s = 0,
l = 0, c = 0, r = null, e = !0)), o++;
for (e && this.diff_cleanupMerge(t), this.diff_cleanupSemanticLossless(t), o = 1; o < t.length; ) {
if (t[o - 1][0] == DIFF_DELETE && t[o][0] == DIFF_INSERT) {
var u = t[o - 1][1], d = t[o][1], p = this.diff_commonOverlap_(u, d), h = this.diff_commonOverlap_(d, u);
p >= h ? (p >= u.length / 2 || p >= d.length / 2) && (t.splice(o, 0, [ DIFF_EQUAL, d.substring(0, p) ]),
t[o - 1][1] = u.substring(0, u.length - p), t[o + 1][1] = d.substring(p), o++) : (h >= u.length / 2 || h >= d.length / 2) && (t.splice(o, 0, [ DIFF_EQUAL, u.substring(0, h) ]),
t[o - 1][0] = DIFF_INSERT, t[o - 1][1] = d.substring(0, d.length - h), t[o + 1][0] = DIFF_DELETE,
t[o + 1][1] = u.substring(h), o++), o++;
}
o++;
}
}, diff_match_patch.prototype.diff_cleanupSemanticLossless = function(t) {
function e(t, e) {
if (!t || !e) return 6;
var n = t.charAt(t.length - 1), i = e.charAt(0), r = n.match(diff_match_patch.nonAlphaNumericRegex_), o = i.match(diff_match_patch.nonAlphaNumericRegex_), a = r && n.match(diff_match_patch.whitespaceRegex_), s = o && i.match(diff_match_patch.whitespaceRegex_), l = a && n.match(diff_match_patch.linebreakRegex_), c = s && i.match(diff_match_patch.linebreakRegex_), u = l && t.match(diff_match_patch.blanklineEndRegex_), d = c && e.match(diff_match_patch.blanklineStartRegex_);
return u || d ? 5 : l || c ? 4 : r && !a && s ? 3 : a || s ? 2 : r || o ? 1 : 0;
}
for (var n = 1; n < t.length - 1; ) {
if (t[n - 1][0] == DIFF_EQUAL && t[n + 1][0] == DIFF_EQUAL) {
var i = t[n - 1][1], r = t[n][1], o = t[n + 1][1], a = this.diff_commonSuffix(i, r);
if (a) {
var s = r.substring(r.length - a);
i = i.substring(0, i.length - a), r = s + r.substring(0, r.length - a), o = s + o;
}
for (var l = i, c = r, u = o, d = e(i, r) + e(r, o); r.charAt(0) === o.charAt(0); ) {
i += r.charAt(0), r = r.substring(1) + o.charAt(0), o = o.substring(1);
var p = e(i, r) + e(r, o);
p >= d && (d = p, l = i, c = r, u = o);
}
t[n - 1][1] != l && (l ? t[n - 1][1] = l : (t.splice(n - 1, 1), n--), t[n][1] = c,
u ? t[n + 1][1] = u : (t.splice(n + 1, 1), n--));
}
n++;
}
}, diff_match_patch.nonAlphaNumericRegex_ = /[^a-zA-Z0-9]/, diff_match_patch.whitespaceRegex_ = /\s/,
diff_match_patch.linebreakRegex_ = /[\r\n]/, diff_match_patch.blanklineEndRegex_ = /\n\r?\n$/,
diff_match_patch.blanklineStartRegex_ = /^\r?\n\r?\n/, diff_match_patch.prototype.diff_cleanupEfficiency = function(t) {
for (var e = !1, n = [], i = 0, r = null, o = 0, a = !1, s = !1, l = !1, c = !1; o < t.length; ) t[o][0] == DIFF_EQUAL ? (t[o][1].length < this.Diff_EditCost && (l || c) ? (n[i++] = o,
a = l, s = c, r = t[o][1]) : (i = 0, r = null), l = c = !1) : (t[o][0] == DIFF_DELETE ? c = !0 : l = !0,
r && (a && s && l && c || r.length < this.Diff_EditCost / 2 && a + s + l + c == 3) && (t.splice(n[i - 1], 0, [ DIFF_DELETE, r ]),
t[n[i - 1] + 1][0] = DIFF_INSERT, i--, r = null, a && s ? (l = c = !0, i = 0) : (i--,
o = i > 0 ? n[i - 1] : -1, l = c = !1), e = !0)), o++;
e && this.diff_cleanupMerge(t);
}, diff_match_patch.prototype.diff_cleanupMerge = function(t) {
t.push([ DIFF_EQUAL, "" ]);
for (var e, n = 0, i = 0, r = 0, o = "", a = ""; n < t.length; ) switch (t[n][0]) {
case DIFF_INSERT:
r++, a += t[n][1], n++;
break;
case DIFF_DELETE:
i++, o += t[n][1], n++;
break;
case DIFF_EQUAL:
i + r > 1 ? (0 !== i && 0 !== r && (e = this.diff_commonPrefix(a, o), 0 !== e && (n - i - r > 0 && t[n - i - r - 1][0] == DIFF_EQUAL ? t[n - i - r - 1][1] += a.substring(0, e) : (t.splice(0, 0, [ DIFF_EQUAL, a.substring(0, e) ]),
n++), a = a.substring(e), o = o.substring(e)), e = this.diff_commonSuffix(a, o),
0 !== e && (t[n][1] = a.substring(a.length - e) + t[n][1], a = a.substring(0, a.length - e),
o = o.substring(0, o.length - e))), 0 === i ? t.splice(n - r, i + r, [ DIFF_INSERT, a ]) : 0 === r ? t.splice(n - i, i + r, [ DIFF_DELETE, o ]) : t.splice(n - i - r, i + r, [ DIFF_DELETE, o ], [ DIFF_INSERT, a ]),
n = n - i - r + (i ? 1 : 0) + (r ? 1 : 0) + 1) : 0 !== n && t[n - 1][0] == DIFF_EQUAL ? (t[n - 1][1] += t[n][1],
t.splice(n, 1)) : n++, r = 0, i = 0, o = "", a = "";
}
"" === t[t.length - 1][1] && t.pop();
var s = !1;
for (n = 1; n < t.length - 1; ) t[n - 1][0] == DIFF_EQUAL && t[n + 1][0] == DIFF_EQUAL && (t[n][1].substring(t[n][1].length - t[n - 1][1].length) == t[n - 1][1] ? (t[n][1] = t[n - 1][1] + t[n][1].substring(0, t[n][1].length - t[n - 1][1].length),
t[n + 1][1] = t[n - 1][1] + t[n + 1][1], t.splice(n - 1, 1), s = !0) : t[n][1].substring(0, t[n + 1][1].length) == t[n + 1][1] && (t[n - 1][1] += t[n + 1][1],
t[n][1] = t[n][1].substring(t[n + 1][1].length) + t[n + 1][1], t.splice(n + 1, 1),
s = !0)), n++;
s && this.diff_cleanupMerge(t);
}, diff_match_patch.prototype.diff_xIndex = function(t, e) {
var n, i = 0, r = 0, o = 0, a = 0;
for (n = 0; n < t.length && (t[n][0] !== DIFF_INSERT && (i += t[n][1].length), t[n][0] !== DIFF_DELETE && (r += t[n][1].length),
!(i > e)); n++) o = i, a = r;
return t.length != n && t[n][0] === DIFF_DELETE ? a : a + (e - o);
}, diff_match_patch.prototype.diff_prettyHtml = function(t) {
for (var e = [], n = /&/g, i = //g, o = /\n/g, a = 0; a < t.length; a++) {
var s = t[a][0], l = t[a][1], c = l.replace(n, "&").replace(i, "<").replace(r, ">").replace(o, "¶ ");
switch (s) {
case DIFF_INSERT:
e[a] = '' + c + "";
break;
case DIFF_DELETE:
e[a] = '' + c + "";
break;
case DIFF_EQUAL:
e[a] = "" + c + "";
}
}
return e.join("");
}, diff_match_patch.prototype.diff_text1 = function(t) {
for (var e = [], n = 0; n < t.length; n++) t[n][0] !== DIFF_INSERT && (e[n] = t[n][1]);
return e.join("");
}, diff_match_patch.prototype.diff_text2 = function(t) {
for (var e = [], n = 0; n < t.length; n++) t[n][0] !== DIFF_DELETE && (e[n] = t[n][1]);
return e.join("");
}, diff_match_patch.prototype.diff_levenshtein = function(t) {
for (var e = 0, n = 0, i = 0, r = 0; r < t.length; r++) {
var o = t[r][0], a = t[r][1];
switch (o) {
case DIFF_INSERT:
n += a.length;
break;
case DIFF_DELETE:
i += a.length;
break;
case DIFF_EQUAL:
e += Math.max(n, i), n = 0, i = 0;
}
}
return e += Math.max(n, i);
}, diff_match_patch.prototype.diff_toDelta = function(t) {
for (var e = [], n = 0; n < t.length; n++) switch (t[n][0]) {
case DIFF_INSERT:
e[n] = "+" + encodeURI(t[n][1]);
break;
case DIFF_DELETE:
e[n] = "-" + t[n][1].length;
break;
case DIFF_EQUAL:
e[n] = "=" + t[n][1].length;
}
return e.join("\t").replace(/%20/g, " ");
}, diff_match_patch.prototype.diff_fromDelta = function(t, e) {
for (var n = [], i = 0, r = 0, o = e.split(/\t/g), a = 0; a < o.length; a++) {
var s = o[a].substring(1);
switch (o[a].charAt(0)) {
case "+":
try {
n[i++] = [ DIFF_INSERT, decodeURI(s) ];
} catch (l) {
throw new Error("Illegal escape in diff_fromDelta: " + s);
}
break;
case "-":
case "=":
var c = parseInt(s, 10);
if (isNaN(c) || c < 0) throw new Error("Invalid number in diff_fromDelta: " + s);
var u = t.substring(r, r += c);
"=" == o[a].charAt(0) ? n[i++] = [ DIFF_EQUAL, u ] : n[i++] = [ DIFF_DELETE, u ];
break;
default:
if (o[a]) throw new Error("Invalid diff operation in diff_fromDelta: " + o[a]);
}
}
if (r != t.length) throw new Error("Delta length (" + r + ") does not equal source text length (" + t.length + ").");
return n;
}, diff_match_patch.prototype.match_main = function(t, e, n) {
if (null == t || null == e || null == n) throw new Error("Null input. (match_main)");
return n = Math.max(0, Math.min(n, t.length)), t == e ? 0 : t.length ? t.substring(n, n + e.length) == e ? n : this.match_bitap_(t, e, n) : -1;
}, diff_match_patch.prototype.match_bitap_ = function(t, e, n) {
function i(t, i) {
var r = t / e.length, a = Math.abs(n - i);
return o.Match_Distance ? r + a / o.Match_Distance : a ? 1 : r;
}
if (e.length > this.Match_MaxBits) throw new Error("Pattern too long for this browser.");
var r = this.match_alphabet_(e), o = this, a = this.Match_Threshold, s = t.indexOf(e, n);
s != -1 && (a = Math.min(i(0, s), a), s = t.lastIndexOf(e, n + e.length), s != -1 && (a = Math.min(i(0, s), a)));
var l = 1 << e.length - 1;
s = -1;
for (var c, u, d, p = e.length + t.length, h = 0; h < e.length; h++) {
for (c = 0, u = p; c < u; ) i(h, n + u) <= a ? c = u : p = u, u = Math.floor((p - c) / 2 + c);
p = u;
var f = Math.max(1, n - u + 1), m = Math.min(n + u, t.length) + e.length, g = Array(m + 2);
g[m + 1] = (1 << h) - 1;
for (var v = m; v >= f; v--) {
var b = r[t.charAt(v - 1)];
if (0 === h ? g[v] = (g[v + 1] << 1 | 1) & b : g[v] = (g[v + 1] << 1 | 1) & b | ((d[v + 1] | d[v]) << 1 | 1) | d[v + 1],
g[v] & l) {
var y = i(h, v - 1);
if (y <= a) {
if (a = y, s = v - 1, !(s > n)) break;
f = Math.max(1, 2 * n - s);
}
}
}
if (i(h + 1, n) > a) break;
d = g;
}
return s;
}, diff_match_patch.prototype.match_alphabet_ = function(t) {
for (var e = {}, n = 0; n < t.length; n++) e[t.charAt(n)] = 0;
for (var n = 0; n < t.length; n++) e[t.charAt(n)] |= 1 << t.length - n - 1;
return e;
}, diff_match_patch.prototype.patch_addContext_ = function(t, e) {
if (0 != e.length) {
for (var n = e.substring(t.start2, t.start2 + t.length1), i = 0; e.indexOf(n) != e.lastIndexOf(n) && n.length < this.Match_MaxBits - this.Patch_Margin - this.Patch_Margin; ) i += this.Patch_Margin,
n = e.substring(t.start2 - i, t.start2 + t.length1 + i);
i += this.Patch_Margin;
var r = e.substring(t.start2 - i, t.start2);
r && t.diffs.unshift([ DIFF_EQUAL, r ]);
var o = e.substring(t.start2 + t.length1, t.start2 + t.length1 + i);
o && t.diffs.push([ DIFF_EQUAL, o ]), t.start1 -= r.length, t.start2 -= r.length,
t.length1 += r.length + o.length, t.length2 += r.length + o.length;
}
}, diff_match_patch.prototype.patch_make = function(t, e, n) {
var i, r;
if ("string" == typeof t && "string" == typeof e && "undefined" == typeof n) i = t,
r = this.diff_main(i, e, !0), r.length > 2 && (this.diff_cleanupSemantic(r), this.diff_cleanupEfficiency(r)); else if (t && "object" == typeof t && "undefined" == typeof e && "undefined" == typeof n) r = t,
i = this.diff_text1(r); else if ("string" == typeof t && e && "object" == typeof e && "undefined" == typeof n) i = t,
r = e; else {
if ("string" != typeof t || "string" != typeof e || !n || "object" != typeof n) throw new Error("Unknown call format to patch_make.");
i = t, r = n;
}
if (0 === r.length) return [];
for (var o = [], a = new diff_match_patch.patch_obj(), s = 0, l = 0, c = 0, u = i, d = i, p = 0; p < r.length; p++) {
var h = r[p][0], f = r[p][1];
switch (s || h === DIFF_EQUAL || (a.start1 = l, a.start2 = c), h) {
case DIFF_INSERT:
a.diffs[s++] = r[p], a.length2 += f.length, d = d.substring(0, c) + f + d.substring(c);
break;
case DIFF_DELETE:
a.length1 += f.length, a.diffs[s++] = r[p], d = d.substring(0, c) + d.substring(c + f.length);
break;
case DIFF_EQUAL:
f.length <= 2 * this.Patch_Margin && s && r.length != p + 1 ? (a.diffs[s++] = r[p],
a.length1 += f.length, a.length2 += f.length) : f.length >= 2 * this.Patch_Margin && s && (this.patch_addContext_(a, u),
o.push(a), a = new diff_match_patch.patch_obj(), s = 0, u = d, l = c);
}
h !== DIFF_INSERT && (l += f.length), h !== DIFF_DELETE && (c += f.length);
}
return s && (this.patch_addContext_(a, u), o.push(a)), o;
}, diff_match_patch.prototype.patch_deepCopy = function(t) {
for (var e = [], n = 0; n < t.length; n++) {
var i = t[n], r = new diff_match_patch.patch_obj();
r.diffs = [];
for (var o = 0; o < i.diffs.length; o++) r.diffs[o] = i.diffs[o].slice();
r.start1 = i.start1, r.start2 = i.start2, r.length1 = i.length1, r.length2 = i.length2,
e[n] = r;
}
return e;
}, diff_match_patch.prototype.patch_apply = function(t, e) {
if (0 == t.length) return [ e, [] ];
t = this.patch_deepCopy(t);
var n = this.patch_addPadding(t);
e = n + e + n, this.patch_splitMax(t);
for (var i = 0, r = [], o = 0; o < t.length; o++) {
var a, s = t[o].start2 + i, l = this.diff_text1(t[o].diffs), c = -1;
if (l.length > this.Match_MaxBits ? (a = this.match_main(e, l.substring(0, this.Match_MaxBits), s),
a != -1 && (c = this.match_main(e, l.substring(l.length - this.Match_MaxBits), s + l.length - this.Match_MaxBits),
(c == -1 || a >= c) && (a = -1))) : a = this.match_main(e, l, s), a == -1) r[o] = !1,
i -= t[o].length2 - t[o].length1; else {
r[o] = !0, i = a - s;
var u;
if (u = c == -1 ? e.substring(a, a + l.length) : e.substring(a, c + this.Match_MaxBits),
l == u) e = e.substring(0, a) + this.diff_text2(t[o].diffs) + e.substring(a + l.length); else {
var d = this.diff_main(l, u, !1);
if (l.length > this.Match_MaxBits && this.diff_levenshtein(d) / l.length > this.Patch_DeleteThreshold) r[o] = !1; else {
this.diff_cleanupSemanticLossless(d);
for (var p, h = 0, f = 0; f < t[o].diffs.length; f++) {
var m = t[o].diffs[f];
m[0] !== DIFF_EQUAL && (p = this.diff_xIndex(d, h)), m[0] === DIFF_INSERT ? e = e.substring(0, a + p) + m[1] + e.substring(a + p) : m[0] === DIFF_DELETE && (e = e.substring(0, a + p) + e.substring(a + this.diff_xIndex(d, h + m[1].length))),
m[0] !== DIFF_DELETE && (h += m[1].length);
}
}
}
}
}
return e = e.substring(n.length, e.length - n.length), [ e, r ];
}, diff_match_patch.prototype.patch_addPadding = function(t) {
for (var e = this.Patch_Margin, n = "", i = 1; i <= e; i++) n += String.fromCharCode(i);
for (var i = 0; i < t.length; i++) t[i].start1 += e, t[i].start2 += e;
var r = t[0], o = r.diffs;
if (0 == o.length || o[0][0] != DIFF_EQUAL) o.unshift([ DIFF_EQUAL, n ]), r.start1 -= e,
r.start2 -= e, r.length1 += e, r.length2 += e; else if (e > o[0][1].length) {
var a = e - o[0][1].length;
o[0][1] = n.substring(o[0][1].length) + o[0][1], r.start1 -= a, r.start2 -= a, r.length1 += a,
r.length2 += a;
}
if (r = t[t.length - 1], o = r.diffs, 0 == o.length || o[o.length - 1][0] != DIFF_EQUAL) o.push([ DIFF_EQUAL, n ]),
r.length1 += e, r.length2 += e; else if (e > o[o.length - 1][1].length) {
var a = e - o[o.length - 1][1].length;
o[o.length - 1][1] += n.substring(0, a), r.length1 += a, r.length2 += a;
}
return n;
}, diff_match_patch.prototype.patch_splitMax = function(t) {
for (var e = this.Match_MaxBits, n = 0; n < t.length; n++) if (!(t[n].length1 <= e)) {
var i = t[n];
t.splice(n--, 1);
for (var r = i.start1, o = i.start2, a = ""; 0 !== i.diffs.length; ) {
var s = new diff_match_patch.patch_obj(), l = !0;
for (s.start1 = r - a.length, s.start2 = o - a.length, "" !== a && (s.length1 = s.length2 = a.length,
s.diffs.push([ DIFF_EQUAL, a ])); 0 !== i.diffs.length && s.length1 < e - this.Patch_Margin; ) {
var c = i.diffs[0][0], u = i.diffs[0][1];
c === DIFF_INSERT ? (s.length2 += u.length, o += u.length, s.diffs.push(i.diffs.shift()),
l = !1) : c === DIFF_DELETE && 1 == s.diffs.length && s.diffs[0][0] == DIFF_EQUAL && u.length > 2 * e ? (s.length1 += u.length,
r += u.length, l = !1, s.diffs.push([ c, u ]), i.diffs.shift()) : (u = u.substring(0, e - s.length1 - this.Patch_Margin),
s.length1 += u.length, r += u.length, c === DIFF_EQUAL ? (s.length2 += u.length,
o += u.length) : l = !1, s.diffs.push([ c, u ]), u == i.diffs[0][1] ? i.diffs.shift() : i.diffs[0][1] = i.diffs[0][1].substring(u.length));
}
a = this.diff_text2(s.diffs), a = a.substring(a.length - this.Patch_Margin);
var d = this.diff_text1(i.diffs).substring(0, this.Patch_Margin);
"" !== d && (s.length1 += d.length, s.length2 += d.length, 0 !== s.diffs.length && s.diffs[s.diffs.length - 1][0] === DIFF_EQUAL ? s.diffs[s.diffs.length - 1][1] += d : s.diffs.push([ DIFF_EQUAL, d ])),
l || t.splice(++n, 0, s);
}
}
}, diff_match_patch.prototype.patch_toText = function(t) {
for (var e = [], n = 0; n < t.length; n++) e[n] = t[n];
return e.join("");
}, diff_match_patch.prototype.patch_fromText = function(t) {
var e = [];
if (!t) return e;
for (var n = t.split("\n"), i = 0, r = /^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/; i < n.length; ) {
var o = n[i].match(r);
if (!o) throw new Error("Invalid patch string: " + n[i]);
var a = new diff_match_patch.patch_obj();
for (e.push(a), a.start1 = parseInt(o[1], 10), "" === o[2] ? (a.start1--, a.length1 = 1) : "0" == o[2] ? a.length1 = 0 : (a.start1--,
a.length1 = parseInt(o[2], 10)), a.start2 = parseInt(o[3], 10), "" === o[4] ? (a.start2--,
a.length2 = 1) : "0" == o[4] ? a.length2 = 0 : (a.start2--, a.length2 = parseInt(o[4], 10)),
i++; i < n.length; ) {
var s = n[i].charAt(0);
try {
var l = decodeURI(n[i].substring(1));
} catch (c) {
throw new Error("Illegal escape in patch_fromText: " + l);
}
if ("-" == s) a.diffs.push([ DIFF_DELETE, l ]); else if ("+" == s) a.diffs.push([ DIFF_INSERT, l ]); else if (" " == s) a.diffs.push([ DIFF_EQUAL, l ]); else {
if ("@" == s) break;
if ("" !== s) throw new Error('Invalid patch mode "' + s + '" in: ' + l);
}
i++;
}
}
return e;
}, diff_match_patch.patch_obj = function() {
this.diffs = [], this.start1 = null, this.start2 = null, this.length1 = 0, this.length2 = 0;
}, diff_match_patch.patch_obj.prototype.toString = function() {
var t, e;
t = 0 === this.length1 ? this.start1 + ",0" : 1 == this.length1 ? this.start1 + 1 : this.start1 + 1 + "," + this.length1,
e = 0 === this.length2 ? this.start2 + ",0" : 1 == this.length2 ? this.start2 + 1 : this.start2 + 1 + "," + this.length2;
for (var n, i = [ "@@ -" + t + " +" + e + " @@\n" ], r = 0; r < this.diffs.length; r++) {
switch (this.diffs[r][0]) {
case DIFF_INSERT:
n = "+";
break;
case DIFF_DELETE:
n = "-";
break;
case DIFF_EQUAL:
n = " ";
}
i[r + 1] = n + encodeURI(this.diffs[r][1]) + "\n";
}
return i.join("").replace(/%20/g, " ");
}, this.diff_match_patch = diff_match_patch, this.DIFF_DELETE = DIFF_DELETE, this.DIFF_INSERT = DIFF_INSERT,
this.DIFF_EQUAL = DIFF_EQUAL, define("diff_match_patch_uncompressed", function(t) {
return function() {
var e;
return e || t.diff_match_patch;
};
}(this)), !function(t) {
if ("object" == typeof exports) module.exports = t(); else if ("function" == typeof define && define.amd) define("jsondiffpatch", t); else {
var e;
"undefined" != typeof window ? e = window : "undefined" != typeof global ? e = global : "undefined" != typeof self && (e = self),
e.jsondiffpatch = t();
}
}(function() {
return function t(e, n, i) {
function r(a, s) {
if (!n[a]) {
if (!e[a]) {
var l = "function" == typeof require && require;
if (!s && l) return l(a, !0);
if (o) return o(a, !0);
throw new Error("Cannot find module '" + a + "'");
}
var c = n[a] = {
exports: {}
};
e[a][0].call(c.exports, function(t) {
var n = e[a][1][t];
return r(n ? n : t);
}, c, c.exports, t, e, n, i);
}
return n[a].exports;
}
for (var o = "function" == typeof require && require, a = 0; a < i.length; a++) r(i[a]);
return r;
}({
1: [ function(t, e, n) {
var i = e.exports = {};
i.nextTick = function() {
var t = "undefined" != typeof window && window.setImmediate, e = "undefined" != typeof window && window.postMessage && window.addEventListener;
if (t) return function(t) {
return window.setImmediate(t);
};
if (e) {
var n = [];
return window.addEventListener("message", function(t) {
var e = t.source;
if ((e === window || null === e) && "process-tick" === t.data && (t.stopPropagation(),
n.length > 0)) {
var i = n.shift();
i();
}
}, !0), function(t) {
n.push(t), window.postMessage("process-tick", "*");
};
}
return function(t) {
setTimeout(t, 0);
};
}(), i.title = "browser", i.browser = !0, i.env = {}, i.argv = [], i.binding = function(t) {
throw new Error("process.binding is not supported");
}, i.cwd = function() {
return "/";
}, i.chdir = function(t) {
throw new Error("process.chdir is not supported");
};
}, {} ],
2: [ function(t, e, n) {
var i = t("../pipe").Pipe, r = function() {};
r.prototype.setResult = function(t) {
return this.result = t, this.hasResult = !0, this;
}, r.prototype.exit = function() {
return this.exiting = !0, this;
}, r.prototype.switchTo = function(t, e) {
return "string" == typeof t || t instanceof i ? this.nextPipe = t : (this.next = t,
e && (this.nextPipe = e)), this;
}, r.prototype.push = function(t, e) {
return t.parent = this, "undefined" != typeof e && (t.childName = e), t.root = this.root || this,
t.options = t.options || this.options, this.children ? (this.children[this.children.length - 1].next = t,
this.children.push(t)) : (this.children = [ t ], this.nextAfterChildren = this.next || null,
this.next = t), t.next = this, this;
}, n.Context = r;
}, {
"../pipe": 15
} ],
3: [ function(t, e, n) {
var i = t("./context").Context, r = function(t, e) {
this.left = t, this.right = e, this.pipe = "diff";
};
r.prototype = new i(), n.DiffContext = r;
}, {
"./context": 2
} ],
4: [ function(t, e, n) {
var i = t("./context").Context, r = function(t, e) {
this.left = t, this.delta = e, this.pipe = "patch";
};
r.prototype = new i(), n.PatchContext = r;
}, {
"./context": 2
} ],
5: [ function(t, e, n) {
var i = t("./context").Context, r = function(t) {
this.delta = t, this.pipe = "reverse";
};
r.prototype = new i(), n.ReverseContext = r;
}, {
"./context": 2
} ],
6: [ function(t, e, n) {
e.exports = function(t, e) {
var n;
return "string" == typeof e && (n = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)(Z|([+\-])(\d{2}):(\d{2}))$/.exec(e)) ? new Date(Date.UTC(+n[1], +n[2] - 1, +n[3], +n[4], +n[5], +n[6])) : e;
};
}, {} ],
7: [ function(t, e, n) {
var i = t("./processor").Processor, r = t("./pipe").Pipe, o = t("./contexts/diff").DiffContext, a = t("./contexts/patch").PatchContext, s = t("./contexts/reverse").ReverseContext, l = t("./filters/trivial"), c = t("./filters/nested"), u = t("./filters/arrays"), d = t("./filters/dates"), p = t("./filters/texts"), h = function(t) {
this.processor = new i(t), this.processor.pipe(new r("diff").append(c.collectChildrenDiffFilter, l.diffFilter, d.diffFilter, p.diffFilter, c.objectsDiffFilter, u.diffFilter).shouldHaveResult()),
this.processor.pipe(new r("patch").append(c.collectChildrenPatchFilter, u.collectChildrenPatchFilter, l.patchFilter, p.patchFilter, c.patchFilter, u.patchFilter).shouldHaveResult()),
this.processor.pipe(new r("reverse").append(c.collectChildrenReverseFilter, u.collectChildrenReverseFilter, l.reverseFilter, p.reverseFilter, c.reverseFilter, u.reverseFilter).shouldHaveResult());
};
h.prototype.options = function() {
return this.processor.options.apply(this.processor, arguments);
}, h.prototype.diff = function(t, e) {
return this.processor.process(new o(t, e));
}, h.prototype.patch = function(t, e) {
return this.processor.process(new a(t, e));
}, h.prototype.reverse = function(t) {
return this.processor.process(new s(t));
}, h.prototype.unpatch = function(t, e) {
return this.patch(t, this.reverse(e));
}, n.DiffPatcher = h;
}, {
"./contexts/diff": 3,
"./contexts/patch": 4,
"./contexts/reverse": 5,
"./filters/arrays": 9,
"./filters/dates": 10,
"./filters/nested": 12,
"./filters/texts": 13,
"./filters/trivial": 14,
"./pipe": 15,
"./processor": 16
} ],
8: [ function(t, e, n) {
(function(e) {
var i = t("./diffpatcher").DiffPatcher;
n.DiffPatcher = i, n.create = function(t) {
return new i(t);
}, n.dateReviver = t("./date-reviver");
var r;
n.diff = function() {
return r || (r = new i()), r.diff.apply(r, arguments);
}, n.patch = function() {
return r || (r = new i()), r.patch.apply(r, arguments);
}, n.unpatch = function() {
return r || (r = new i()), r.unpatch.apply(r, arguments);
}, n.reverse = function() {
return r || (r = new i()), r.reverse.apply(r, arguments);
};
var o = "undefined" != typeof e && "string" == typeof e.execPath;
if (o) {
var a = t("./formatters/index");
n.formatters = a, n.console = a.console;
} else n.homepage = "https://github.com/benjamine/jsondiffpatch", n.version = "0.1.5";
}).call(this, t("/home/sheila/proj/JsonDiffPatch/node_modules/gulp-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"));
}, {
"./date-reviver": 6,
"./diffpatcher": 7,
"/home/sheila/proj/JsonDiffPatch/node_modules/gulp-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js": 1
} ],
9: [ function(t, e, n) {
var i = t("../contexts/diff").DiffContext, r = t("../contexts/patch").PatchContext, o = t("../contexts/reverse").ReverseContext, a = t("./lcs"), s = 3, l = "function" == typeof Array.isArray ? Array.isArray : function(t) {
return t instanceof Array;
}, c = "function" == typeof Array.prototype.indexOf ? function(t, e) {
return t.indexOf(e);
} : function(t, e) {
for (var n = t.length, i = 0; i < n; i++) if (t[i] === e) return i;
return -1;
}, u = function(t) {
if (t.leftIsArray) {
for (var e, n, r, o, l = t.options && t.options.objectHash, u = function(t, e, n, i, r) {
var o = t[n], a = e[i];
if (o === a) return !0;
if ("object" != typeof o || "object" != typeof a) return !1;
if (!l) return !1;
var s, c;
return "number" == typeof n ? (r.hashCache1 = r.hashCache1 || [], s = r.hashCache1[n],
"undefined" == typeof s && (r.hashCache1[n] = s = l(o, n))) : s = l(o), "undefined" != typeof s && ("number" == typeof i ? (r.hashCache2 = r.hashCache2 || [],
c = r.hashCache2[i], "undefined" == typeof c && (r.hashCache2[i] = c = l(a, i))) : c = l(a),
"undefined" != typeof c && s === c);
}, d = {}, p = 0, h = 0, f = t.left, m = t.right, g = f.length, v = m.length; p < g && p < v && u(f, m, p, p, d); ) e = p,
o = new i(t.left[e], t.right[e]), t.push(o, e), p++;
for (;h + p < g && h + p < v && u(f, m, g - 1 - h, v - 1 - h, d); ) n = g - 1 - h,
r = v - 1 - h, o = new i(t.left[n], t.right[r]), t.push(o, r), h++;
var b;
if (p + h === g) {
if (g === v) return void t.setResult(void 0).exit();
for (b = b || {
_t: "a"
}, e = p; e < v - h; e++) b[e] = [ m[e] ];
return void t.setResult(b).exit();
}
if (p + h === v) {
for (b = b || {
_t: "a"
}, e = p; e < g - h; e++) b["_" + e] = [ f[e], 0, 0 ];
return void t.setResult(b).exit();
}
d = {};
var y = f.slice(p, g - h), x = m.slice(p, v - h), w = a.get(y, x, u, d), S = [];
for (b = b || {
_t: "a"
}, e = p; e < g - h; e++) c(w.indices1, e - p) < 0 && (b["_" + e] = [ f[e], 0, 0 ],
S.push(e));
var C = !0;
t.options && t.options.arrays && t.options.arrays.detectMove === !1 && (C = !1);
var _ = !1;
t.options && t.options.arrays && t.options.arrays.includeValueOnMove && (_ = !0);
var k = S.length;
for (e = p; e < v - h; e++) {
var E = c(w.indices2, e - p);
if (E < 0) {
var T = !1;
if (C && k > 0) for (n = 0; n < k; n++) if (u(y, x, S[n] - p, e - p, d)) {
b["_" + S[n]].splice(1, 2, e, s), _ || (b["_" + S[n]][0] = ""), n = S[n], r = e,
o = new i(t.left[n], t.right[r]), t.push(o, r), S.splice(n, 1), T = !0;
break;
}
T || (b[e] = [ m[e] ]);
} else n = w.indices1[E] + p, r = w.indices2[E] + p, o = new i(t.left[n], t.right[r]),
t.push(o, r);
}
t.setResult(b).exit();
}
};
u.filterName = "arrays";
var d = {
numerically: function(t, e) {
return t - e;
},
numericallyBy: function(t) {
return function(e, n) {
return e[t] - n[t];
};
}
}, p = function(t) {
if (t.nested && "a" === t.delta._t) {
var e, n, i = t.delta, o = t.left, a = [], l = [], c = [];
for (e in i) if ("_t" !== e) if ("_" === e[0]) {
if (0 !== i[e][2] && i[e][2] !== s) throw new Error("only removal or move can be applied at original array indices, invalid diff type: " + i[e][2]);
a.push(parseInt(e.slice(1), 10));
} else 1 === i[e].length ? l.push({
index: parseInt(e, 10),
value: i[e][0]
}) : c.push({
index: parseInt(e, 10),
delta: i[e]
});
for (a = a.sort(d.numerically), e = a.length - 1; e >= 0; e--) {
n = a[e];
var u = i["_" + n], p = o.splice(n, 1)[0];
u[2] === s && l.push({
index: u[1],
value: p
});
}
l = l.sort(d.numericallyBy("index"));
var h = l.length;
for (e = 0; e < h; e++) {
var f = l[e];
o.splice(f.index, 0, f.value);
}
var m, g = c.length;
if (g > 0) for (e = 0; e < g; e++) {
var v = c[e];
m = new r(t.left[v.index], v.delta), t.push(m, v.index);
}
return t.children ? void t.exit() : void t.setResult(t.left).exit();
}
};
p.filterName = "arrays";
var h = function(t) {
if (t && t.children && "a" === t.delta._t) {
for (var e, n = t.children.length, i = 0; i < n; i++) e = t.children[i], t.left[e.childName] = e.result;
t.setResult(t.left).exit();
}
};
h.filterName = "arraysCollectChildren";
var f = function(t) {
if (!t.nested) return void (t.delta[2] === s && (t.newName = "_" + t.delta[1], t.setResult([ t.delta[0], parseInt(t.childName.substr(1), 10), s ]).exit()));
if ("a" === t.delta._t) {
var e, n;
for (e in t.delta) "_t" !== e && (n = new o(t.delta[e]), t.push(n, e));
t.exit();
}
};
f.filterName = "arrays";
var m = function(t, e, n) {
var i = e;
if ("string" == typeof e && "_" === e[0]) i = parseInt(e.substr(1), 10); else {
var r = "_" + e;
if (l(n) && 0 === n[2]) i = r; else for (var o in t) {
var a = t[o];
l(a) && a[2] === s && a[1].toString() === e && (i = o.substr(1));
}
}
return i;
}, g = function(t) {
if (t && t.children && "a" === t.delta._t) {
for (var e, n = t.children.length, i = {
_t: "a"
}, r = 0; r < n; r++) {
e = t.children[r];
var o = e.newName;
"undefined" == typeof o && (o = m(t.delta, e.childName, e.result)), i[o] !== e.result && (i[o] = e.result);
}
t.setResult(i).exit();
}
};
g.filterName = "arraysCollectChildren", n.diffFilter = u, n.patchFilter = p, n.collectChildrenPatchFilter = h,
n.reverseFilter = f, n.collectChildrenReverseFilter = g;
}, {
"../contexts/diff": 3,
"../contexts/patch": 4,
"../contexts/reverse": 5,
"./lcs": 11
} ],
10: [ function(t, e, n) {
var i = function(t) {
t.left instanceof Date ? (t.right instanceof Date ? t.left.getTime() !== t.right.getTime() ? t.setResult([ t.left, t.right ]) : t.setResult(void 0) : t.setResult([ t.left, t.right ]),
t.exit()) : t.right instanceof Date && t.setResult([ t.left, t.right ]).exit();
};
i.filterName = "dates", n.diffFilter = i;
}, {} ],
11: [ function(t, e, n) {
var i = function(t, e, n, i) {
return t[n] === e[i];
}, r = function(t, e, n, i) {
var r, o, a = t.length, s = e.length, l = [ a + 1 ];
for (r = 0; r < a + 1; r++) for (l[r] = [ s + 1 ], o = 0; o < s + 1; o++) l[r][o] = 0;
for (l.match = n, r = 1; r < a + 1; r++) for (o = 1; o < s + 1; o++) n(t, e, r - 1, o - 1, i) ? l[r][o] = l[r - 1][o - 1] + 1 : l[r][o] = Math.max(l[r - 1][o], l[r][o - 1]);
return l;
}, o = function(t, e, n, i, r, a) {
if (0 === i || 0 === r) return {
sequence: [],
indices1: [],
indices2: []
};
if (t.match(e, n, i - 1, r - 1, a)) {
var s = o(t, e, n, i - 1, r - 1, a);
return s.sequence.push(e[i - 1]), s.indices1.push(i - 1), s.indices2.push(r - 1),
s;
}
return t[i][r - 1] > t[i - 1][r] ? o(t, e, n, i, r - 1, a) : o(t, e, n, i - 1, r, a);
}, a = function(t, e, n, a) {
a = a || {};
var s = r(t, e, n || i, a), l = o(s, t, e, t.length, e.length, a);
return "string" == typeof t && "string" == typeof e && (l.sequence = l.sequence.join("")),
l;
};
n.get = a;
}, {} ],
12: [ function(t, e, n) {
var i = t("../contexts/diff").DiffContext, r = t("../contexts/patch").PatchContext, o = t("../contexts/reverse").ReverseContext, a = function(t) {
if (t && t.children) {
for (var e, n = t.children.length, i = t.result, r = 0; r < n; r++) e = t.children[r],
"undefined" != typeof e.result && (i = i || {}, i[e.childName] = e.result);
i && t.leftIsArray && (i._t = "a"), t.setResult(i).exit();
}
};
a.filterName = "collectChildren";
var s = function(t) {
if (!t.leftIsArray && "object" === t.leftType) {
var e, n;
for (e in t.left) n = new i(t.left[e], t.right[e]), t.push(n, e);
for (e in t.right) "undefined" == typeof t.left[e] && (n = new i((void 0), t.right[e]),
t.push(n, e));
return t.children && 0 !== t.children.length ? void t.exit() : void t.setResult(void 0).exit();
}
};
s.filterName = "objects";
var l = function(t) {
if (t.nested && !t.delta._t) {
var e, n;
for (e in t.delta) n = new r(t.left[e], t.delta[e]), t.push(n, e);
t.exit();
}
};
l.filterName = "objects";
var c = function(t) {
if (t && t.children && !t.delta._t) {
for (var e, n = t.children.length, i = 0; i < n; i++) e = t.children[i], t.left[e.childName] !== e.result && (t.left[e.childName] = e.result);
t.setResult(t.left).exit();
}
};
c.filterName = "collectChildren";
var u = function(t) {
if (t.nested && !t.delta._t) {
var e, n;
for (e in t.delta) n = new o(t.delta[e]), t.push(n, e);
t.exit();
}
};
u.filterName = "objects";
var d = function(t) {
if (t && t.children && !t.delta._t) {
for (var e, n = t.children.length, i = {}, r = 0; r < n; r++) e = t.children[r],
i[e.childName] !== e.result && (i[e.childName] = e.result);
t.setResult(i).exit();
}
};
d.filterName = "collectChildren", n.collectChildrenDiffFilter = a, n.objectsDiffFilter = s,
n.patchFilter = l, n.collectChildrenPatchFilter = c, n.reverseFilter = u, n.collectChildrenReverseFilter = d;
}, {
"../contexts/diff": 3,
"../contexts/patch": 4,
"../contexts/reverse": 5
} ],
13: [ function(t, e, n) {
var i = 2, r = 60, o = null, a = function() {
if (!o) {
var e;
if ("undefined" != typeof diff_match_patch) e = new diff_match_patch(); else if ("function" == typeof t) {
var n = t("../../external/diff_match_patch_uncompressed");
e = new n.diff_match_patch();
}
if (!e) {
var i = new Error("text diff_match_patch library not found");
throw i.diff_match_patch_not_found = !0, i;
}
o = {
diff: function(t, n) {
return e.patch_toText(e.patch_make(t, n));
},
patch: function(t, n) {
for (var i = e.patch_apply(e.patch_fromText(n), t), r = 0; r < i[1].length; r++) if (!i[1][r]) {
var o = new Error("text patch failed");
o.textPatchFailed = !0;
}
return i[0];
}
};
}
return o;
}, s = function(t) {
if ("string" === t.leftType) {
var e = t.options && t.options.textDiff && t.options.textDiff.minLength || r;
if (t.left.length < e || t.right.length < e) return void t.setResult([ t.left, t.right ]).exit();
var n = a().diff;
t.setResult([ n(t.left, t.right), 0, i ]).exit();
}
};
s.filterName = "texts";
var l = function(t) {
if (!t.nested && t.delta[2] === i) {
var e = a().patch;
t.setResult(e(t.left, t.delta[0])).exit();
}
};
l.filterName = "texts";
var c = function(t) {
var e, n, i, r, o, a, s, l, c = null, u = /^@@ +\-(\d+),(\d+) +\+(\d+),(\d+) +@@$/;
for (i = t.split("\n"), e = 0, n = i.length; e < n; e++) {
r = i[e];
var d = r.slice(0, 1);
"@" === d ? (c = u.exec(r), a = e, s = null, l = null, i[a] = "@@ -" + c[3] + "," + c[4] + " +" + c[1] + "," + c[2] + " @@") : "+" === d ? (s = e,
i[e] = "-" + i[e].slice(1), "+" === i[e - 1].slice(0, 1) && (o = i[e], i[e] = i[e - 1],
i[e - 1] = o)) : "-" === d && (l = e, i[e] = "+" + i[e].slice(1));
}
return i.join("\n");
}, u = function(t) {
t.nested || t.delta[2] === i && t.setResult([ c(t.delta[0]), 0, i ]).exit();
};
u.filterName = "texts", n.diffFilter = s, n.patchFilter = l, n.reverseFilter = u;
}, {} ],
14: [ function(t, e, n) {
var i = "function" == typeof Array.isArray ? Array.isArray : function(t) {
return t instanceof Array;
}, r = function(t) {
if (t.left === t.right) return void t.setResult(void 0).exit();
if ("undefined" == typeof t.left) {
if ("function" == typeof t.right) throw new Error("functions are not supported");
return void t.setResult([ t.right ]).exit();
}
if ("undefined" == typeof t.right) return void t.setResult([ t.left, 0, 0 ]).exit();
if ("function" == typeof t.left || "function" == typeof t.right) throw new Error("functions are not supported");
return t.leftType = null === t.left ? "null" : typeof t.left, t.rightType = null === t.right ? "null" : typeof t.right,
t.leftType !== t.rightType ? void t.setResult([ t.left, t.right ]).exit() : "boolean" === t.leftType || "number" === t.leftType ? void t.setResult([ t.left, t.right ]).exit() : ("object" === t.leftType && (t.leftIsArray = i(t.left)),
"object" === t.rightType && (t.rightIsArray = i(t.right)), t.leftIsArray !== t.rightIsArray ? void t.setResult([ t.left, t.right ]).exit() : void 0);
};
r.filterName = "trivial";
var o = function(t) {
return "undefined" == typeof t.delta ? void t.setResult(t.left).exit() : (t.nested = !i(t.delta),
t.nested ? void 0 : 1 === t.delta.length ? void t.setResult(t.delta[0]).exit() : 2 === t.delta.length ? void t.setResult(t.delta[1]).exit() : 3 === t.delta.length && 0 === t.delta[2] ? void t.setResult(void 0).exit() : void 0);
};
o.filterName = "trivial";
var a = function(t) {
return "undefined" == typeof t.delta ? void t.setResult(t.delta).exit() : (t.nested = !i(t.delta),
t.nested ? void 0 : 1 === t.delta.length ? void t.setResult([ t.delta[0], 0, 0 ]).exit() : 2 === t.delta.length ? void t.setResult([ t.delta[1], t.delta[0] ]).exit() : 3 === t.delta.length && 0 === t.delta[2] ? void t.setResult([ t.delta[0] ]).exit() : void 0);
};
a.filterName = "trivial", n.diffFilter = r, n.patchFilter = o, n.reverseFilter = a;
}, {} ],
15: [ function(t, e, n) {
var i = function(t) {
this.name = t, this.filters = [];
};
i.prototype.process = function(t) {
if (!this.processor) throw new Error("add this pipe to a processor before using it");
for (var e = this.debug, n = this.filters.length, i = t, r = 0; r < n; r++) {
var o = this.filters[r];
if (e && this.log("filter: " + o.filterName), o(i), "object" == typeof i && i.exiting) {
i.exiting = !1;
break;
}
}
!i.next && this.resultCheck && this.resultCheck(i);
}, i.prototype.log = function(t) {
console.log("[jsondiffpatch] " + this.name + " pipe, " + t);
}, i.prototype.append = function() {
return this.filters.push.apply(this.filters, arguments), this;
}, i.prototype.prepend = function() {
return this.filters.unshift.apply(this.filters, arguments), this;
}, i.prototype.indexOf = function(t) {
if (!t) throw new Error("a filter name is required");
for (var e = 0; e < this.filters.length; e++) {
var n = this.filters[e];
if (n.filterName === t) return e;
}
throw new Error("filter not found: " + t);
}, i.prototype.list = function() {
for (var t = [], e = 0; e < this.filters.length; e++) {
var n = this.filters[e];
t.push(n.filterName);
}
return t;
}, i.prototype.after = function(t) {
var e = this.indexOf(t), n = Array.prototype.slice.call(arguments, 1);
if (!n.length) throw new Error("a filter is required");
return n.unshift(e + 1, 0), Array.prototype.splice.apply(this.filters, n), this;
}, i.prototype.before = function(t) {
var e = this.indexOf(t), n = Array.prototype.slice.call(arguments, 1);
if (!n.length) throw new Error("a filter is required");
return n.unshift(e, 0), Array.prototype.splice.apply(this.filters, n), this;
}, i.prototype.clear = function() {
return this.filters.length = 0, this;
}, i.prototype.shouldHaveResult = function(t) {
if (t === !1) return void (this.resultCheck = null);
if (!this.resultCheck) {
var e = this;
return this.resultCheck = function(t) {
if (!t.hasResult) {
console.log(t);
var n = new Error(e.name + " failed");
throw n.noResult = !0, n;
}
}, this;
}
}, n.Pipe = i;
}, {} ],
16: [ function(t, e, n) {
var i = function(t) {
this.selfOptions = t, this.pipes = {};
};
i.prototype.options = function(t) {
return t && (this.selfOptions = t), this.selfOptions;
}, i.prototype.pipe = function(t, e) {
if ("string" == typeof t) {
if ("undefined" == typeof e) return this.pipes[t];
this.pipes[t] = e;
}
if (t && t.name) {
if (e = t, e.processor === this) return e;
this.pipes[e.name] = e;
}
return e.processor = this, e;
}, i.prototype.process = function(t, e) {
var n = t;
n.options = this.options();
for (var i, r, o = e || t.pipe || "default"; o; ) "undefined" != typeof n.nextAfterChildren && (n.next = n.nextAfterChildren,
n.nextAfterChildren = null), "string" == typeof o && (o = this.pipe(o)), o.process(n),
r = n, i = o, o = null, n && n.next && (n = n.next, o = r.nextPipe || n.pipe || i);
return n.hasResult ? n.result : void 0;
}, n.Processor = i;
}, {} ]
}, {}, [ 8 ])(8);
}), "undefined" == typeof WeakMap && !function() {
var t = Object.defineProperty, e = Date.now() % 1e9, n = function() {
this.name = "__st" + (1e9 * Math.random() >>> 0) + (e++ + "__");
};
n.prototype = {
set: function(e, n) {
var i = e[this.name];
i && i[0] === e ? i[1] = n : t(e, this.name, {
value: [ e, n ],
writable: !0
});
},
get: function(t) {
var e;
return (e = t[this.name]) && e[0] === t ? e[1] : void 0;
},
"delete": function(t) {
this.set(t, void 0);
}
}, window.WeakMap = n;
}(), define("WeakMap", function() {}), function(t) {
function e(t) {
x.push(t), y || (y = !0, g(i));
}
function n(t) {
return window.ShadowDOMPolyfill && window.ShadowDOMPolyfill.wrapIfNeeded(t) || t;
}
function i() {
y = !1;
var t = x;
x = [], t.sort(function(t, e) {
return t.uid_ - e.uid_;
});
var e = !1;
t.forEach(function(t) {
var n = t.takeRecords();
r(t), n.length && (t.callback_(n, t), e = !0);
}), e && i();
}
function r(t) {
t.nodes_.forEach(function(e) {
var n = m.get(e);
n && n.forEach(function(e) {
e.observer === t && e.removeTransientObservers();
});
});
}
function o(t, e) {
for (var n = t; n; n = n.parentNode) {
var i = m.get(n);
if (i) for (var r = 0; r < i.length; r++) {
var o = i[r], a = o.options;
if (n === t || a.subtree) {
var s = e(a);
s && o.enqueue(s);
}
}
}
}
function a(t) {
this.callback_ = t, this.nodes_ = [], this.records_ = [], this.uid_ = ++w;
}
function s(t, e) {
this.type = t, this.target = e, this.addedNodes = [], this.removedNodes = [], this.previousSibling = null,
this.nextSibling = null, this.attributeName = null, this.attributeNamespace = null,
this.oldValue = null;
}
function l(t) {
var e = new s(t.type, t.target);
return e.addedNodes = t.addedNodes.slice(), e.removedNodes = t.removedNodes.slice(),
e.previousSibling = t.previousSibling, e.nextSibling = t.nextSibling, e.attributeName = t.attributeName,
e.attributeNamespace = t.attributeNamespace, e.oldValue = t.oldValue, e;
}
function c(t, e) {
return S = new s(t, e);
}
function u(t) {
return C ? C : (C = l(S), C.oldValue = t, C);
}
function d() {
S = C = void 0;
}
function p(t) {
return t === C || t === S;
}
function h(t, e) {
return t === e ? t : C && p(t) ? C : null;
}
function f(t, e, n) {
this.observer = t, this.target = e, this.options = n, this.transientObservedNodes = [];
}
var m = new WeakMap(), g = window.msSetImmediate;
if (!g) {
var v = [], b = String(Math.random());
window.addEventListener("message", function(t) {
if (t.data === b) {
var e = v;
v = [], e.forEach(function(t) {
t();
});
}
}), g = function(t) {
v.push(t), window.postMessage(b, "*");
};
}
var y = !1, x = [], w = 0;
a.prototype = {
observe: function(t, e) {
if (t = n(t), !e.childList && !e.attributes && !e.characterData || e.attributeOldValue && !e.attributes || e.attributeFilter && e.attributeFilter.length && !e.attributes || e.characterDataOldValue && !e.characterData) throw new SyntaxError();
var i = m.get(t);
i || m.set(t, i = []);
for (var r, o = 0; o < i.length; o++) if (i[o].observer === this) {
r = i[o], r.removeListeners(), r.options = e;
break;
}
r || (r = new f(this, t, e), i.push(r), this.nodes_.push(t)), r.addListeners();
},
disconnect: function() {
this.nodes_.forEach(function(t) {
for (var e = m.get(t), n = 0; n < e.length; n++) {
var i = e[n];
if (i.observer === this) {
i.removeListeners(), e.splice(n, 1);
break;
}
}
}, this), this.records_ = [];
},
takeRecords: function() {
var t = this.records_;
return this.records_ = [], t;
}
};
var S, C;
f.prototype = {
enqueue: function(t) {
var n = this.observer.records_, i = n.length;
if (n.length > 0) {
var r = n[i - 1], o = h(r, t);
if (o) return void (n[i - 1] = o);
} else e(this.observer);
n[i] = t;
},
addListeners: function() {
this.addListeners_(this.target);
},
addListeners_: function(t) {
var e = this.options;
e.attributes && t.addEventListener("DOMAttrModified", this, !0), e.characterData && t.addEventListener("DOMCharacterDataModified", this, !0),
e.childList && t.addEventListener("DOMNodeInserted", this, !0), (e.childList || e.subtree) && t.addEventListener("DOMNodeRemoved", this, !0);
},
removeListeners: function() {
this.removeListeners_(this.target);
},
removeListeners_: function(t) {
var e = this.options;
e.attributes && t.removeEventListener("DOMAttrModified", this, !0), e.characterData && t.removeEventListener("DOMCharacterDataModified", this, !0),
e.childList && t.removeEventListener("DOMNodeInserted", this, !0), (e.childList || e.subtree) && t.removeEventListener("DOMNodeRemoved", this, !0);
},
addTransientObserver: function(t) {
if (t !== this.target) {
this.addListeners_(t), this.transientObservedNodes.push(t);
var e = m.get(t);
e || m.set(t, e = []), e.push(this);
}
},
removeTransientObservers: function() {
var t = this.transientObservedNodes;
this.transientObservedNodes = [], t.forEach(function(t) {
this.removeListeners_(t);
for (var e = m.get(t), n = 0; n < e.length; n++) if (e[n] === this) {
e.splice(n, 1);
break;
}
}, this);
},
handleEvent: function(t) {
switch (t.stopImmediatePropagation(), t.type) {
case "DOMAttrModified":
var e = t.attrName, n = t.relatedNode.namespaceURI, i = t.target, r = new c("attributes", i);
r.attributeName = e, r.attributeNamespace = n;
var a = t.attrChange === MutationEvent.ADDITION ? null : t.prevValue;
o(i, function(t) {
if (t.attributes && (!t.attributeFilter || !t.attributeFilter.length || t.attributeFilter.indexOf(e) !== -1 || t.attributeFilter.indexOf(n) !== -1)) return t.attributeOldValue ? u(a) : r;
});
break;
case "DOMCharacterDataModified":
var i = t.target, r = c("characterData", i), a = t.prevValue;
o(i, function(t) {
if (t.characterData) return t.characterDataOldValue ? u(a) : r;
});
break;
case "DOMNodeRemoved":
this.addTransientObserver(t.target);
case "DOMNodeInserted":
var s, l, i = t.relatedNode, p = t.target;
"DOMNodeInserted" === t.type ? (s = [ p ], l = []) : (s = [], l = [ p ]);
var h = p.previousSibling, f = p.nextSibling, r = c("childList", i);
r.addedNodes = s, r.removedNodes = l, r.previousSibling = h, r.nextSibling = f,
o(i, function(t) {
if (t.childList) return r;
});
}
d();
}
}, t.JsMutationObserver = a, t.MutationObserver || (t.MutationObserver = a);
}(this), define("MutationObservers", function() {}), Prism.languages.markup = {
comment: /<!--[\w\W]*?-->/g,
prolog: /<\?.+?\?>/,
doctype: /<!DOCTYPE.+?>/,
cdata: /<!\[CDATA\[[\w\W]*?]]>/i,
tag: {
pattern: /<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/gi,
inside: {
tag: {
pattern: /^<\/?[\w:-]+/i,
inside: {
punctuation: /^<\/?/,
namespace: /^[\w-]+?:/
}
},
"attr-value": {
pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi,
inside: {
punctuation: /=|>|"/g
}
},
punctuation: /\/?>/g,
"attr-name": {
pattern: /[\w:-]+/g,
inside: {
namespace: /^[\w-]+?:/
}
}
}
},
entity: /&#?[\da-z]{1,8};/gi
}, Prism.hooks.add("wrap", function(t) {
"entity" === t.type && (t.attributes.title = t.content.replace(/&/, "&"));
}), define("bower-libs/prism/components/prism-markup", function() {}), Prism.languages.latex = {
keyword: /\\(?:[^a-zA-Z]|[a-zA-Z]+)/g,
lparen: /[[({]/g,
rparen: /[\])}]/g,
comment: /%.*/g
}, define("libs/prism-latex", function() {}), Prism.languages.md = function() {
var t = "(&|[-A-Z0-9+@#/%?=~_|[\\]()!:,.;])", e = "(&|[-A-Z0-9+@#/%=~_|[\\])])", n = new RegExp("(https?|ftp)(://" + t + "*" + e + ")(?=$|\\W)", "gi"), i = /(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)/gi, r = Prism.languages.latex, o = /\n/gm, a = {};
a["pre gfm"] = {
pattern: /^`{3}.*\n(?:[\s\S]*?)\n`{3} *$/gm,
inside: {
"md md-pre": /`{3}/,
lf: o
}
}, a["h1 alt"] = {
pattern: /^(.+)[ \t]*\n=+[ \t]*$/gm,
inside: {}
}, a["h2 alt"] = {
pattern: /^(.+)[ \t]*\n-+[ \t]*$/gm,
inside: {}
};
for (var s = 6; s >= 1; s--) a["h" + s] = {
pattern: new RegExp("^#{" + s + "}.+$", "gm"),
inside: {
"md md-hash": new RegExp("^#{" + s + "}")
}
};
a.li = {
pattern: /^[ \t]*([*+\-]|\d+\.)[ \t].+(?:\n|[ \t].*\n)*/gm,
inside: {
"md md-li": /^[ \t]*([*+\-]|\d+\.)[ \t]/m,
"pre gfm": {
pattern: /^((?: {4}|\t)+)`{3}.*\n(?:[\s\S]*?)\n\1`{3} *$/gm,
inside: {
"md md-pre": /`{3}/,
lf: o
}
},
lf: o
}
}, a.pre = {
pattern: /(^|(?:^|(?:^|\n)(?![ \t]*([*+\-]|\d+\.)[ \t]).*\n)\s*?\n)(\s*(?: {4}|\t).*(?:\n|$))+/g,
lookbehind: !0,
inside: {
lf: o
}
}, a.table = {
pattern: new RegExp([ "^", "[ ]{0,3}", "[|]", "(.+)\\n", "[ ]{0,3}", "[|]([ ]*[-:]+[-| :]*)\\n", "(", "(?:[ ]*[|].*\\n?)*", ")", "(?:\\n|$)" ].join(""), "gm"),
inside: {
lf: o
}
}, a["table alt"] = {
pattern: new RegExp([ "^", "[ ]{0,3}", "(\\S.*[|].*)\\n", "[ ]{0,3}", "([-:]+[ ]*[|][-| :]*)\\n", "(", "(?:.*[|].*\\n?)*", ")", "(?:\\n|$)" ].join(""), "gm"),
inside: {
lf: o
}
}, a.hr = {
pattern: /^([*\-_] *){3,}$/gm
}, a.blockquote = {
pattern: /^ {0,3}> *[^\n]+$/gm,
inside: {
"md md-gt": /^ {0,3}> */,
li: a.li
}
}, a["math block"] = {
pattern: /(\$\$|\\\\\[|\\\\\\\\\()[\s\S]*?(\$\$|\\\\\]|\\\\\\\\\))/g,
inside: {
"md md-bracket-start": /^(\$\$|\\\\\[|\\\\\\\\\()/,
"md md-bracket-end": /(\$\$|\\\\\]|\\\\\\\\\))/,
lf: o,
rest: r
}
}, a["latex block"] = {
pattern: /\\?\\begin\{([a-z]*\*?)\}[\s\S]*?\\?\\end\{\1\}/g,
inside: {
keyword: /\\?\\(begin|end)/,
lf: o,
rest: r
}
}, a.fndef = {
pattern: /^ {0,3}\[\^.*?\]:[ \t]+.*$/gm,
inside: {
"ref-id": {
pattern: /\[\^.*?\]/,
inside: {
"md md-bracket-start": /\[/,
"md md-bracket-end": /\]/
}
}
}
}, a.linkdef = {
pattern: /^ {0,3}\[.*?\]:[ \t]+.*$/gm,
inside: {
"link-id": {
pattern: /\[.*?\]/,
inside: {
"md md-bracket-start": /\[/,
"md md-bracket-end": /\]/
}
},
url: n,
linktitle: /['\"\(][^\'\"\)]*['\"\)]/
}
}, a.p = {
pattern: /.+/g,
inside: {
"md md-toc": /^\s*\[(toc|TOC)\]\s*$/g
}
}, a.lf = /^\n$/gm, a.img = {
pattern: /!\[[^\]]*\]\([^\)]+\)/g,
inside: {
"md md-bang": /^!/,
"md md-bracket-start": /\[/,
"md md-alt": /[^\[]+(?=\])/,
"md md-bracket-end": /\](?=\()/,
"md img-parens": {
pattern: /\([^\)]+\)/,
inside: {
"md md-paren-start": /^\(/,
"md md-title": /(['\u2018][^'\u2019]*['\u2019]|["\u201c][^"\u201d]*["\u201d])(?=\)$)/,
"md md-src": /[^\('" \t]+(?=[\)'" \t])/,
"md md-paren-end": /\)$/
}
}
}
}, a.link = {
pattern: /\[(?:(\\.)|[^\[\]])*\]\([^\(\)\s]+(\(\S*?\))??[^\(\)\s]*?(\s(['\u2018][^'\u2019]*['\u2019]|["\u201c][^"\u201d]*["\u201d]))?\)/gm,
inside: {
"md md-bracket-start": {
pattern: /(^|[^\\])\[/,
lookbehind: !0
},
"md md-underlined-text": {
pattern: /(?:(\\.)|[^\[\]])+(?=\])/
},
"md md-bracket-end": /\]\s?\(/,
"md md-paren-end": /\)$/,
"md md-href": /.*/
}
}, a.fn = {
pattern: /\[\^(.*?)\]/g,
inside: {
ref: {
pattern: /^\[[^\[\]]+\] ?/,
inside: {
"md md-bracket-start": /\[/,
"md md-ref": /^[^\[\]]+/,
"md md-bracket-end": /\]/
}
}
}
}, a.imgref = {
pattern: /!\[(.*?)\] ?\[(.*?)\]/g,
inside: {
"md md-bang": /^!/,
"ref-end": {
pattern: /\[[^\[\]]+\]$/,
inside: {
"md md-bracket-start": /\[/,
"md md-href": /[^\[\]]+(?=]$)/,
"md md-bracket-end": /\]/
}
},
"ref-start": {
pattern: /^\[[^\[\]]+\] ?/,
inside: {
"md md-bracket-start": /\[/,
"md md-alt": /^[^\[\]]+/,
"md md-bracket-end": /\]/
}
}
}
}, a.linkref = {
pattern: /\[(.*?)\] ?\[(.*?)\]/g,
inside: {
"ref-end": {
pattern: /\[[^\[\]]+\]$/,
inside: {
"md md-bracket-start": /\[/,
"md md-href": /[^\[\]]+(?=]$)/,
"md md-bracket-end": /\]/
}
},
"ref-start": {
pattern: /^\[[^\[\]]+\] ?/,
inside: {
"md md-bracket-start": /\[/,
"md md-underlined-text": /^[^\[\]]+/,
"md md-bracket-end": /\]/
}
}
}
}, a.code = {
pattern: /(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/g,
lookbehind: !0,
inside: {
"md md-code": /`/
}
}, a.math = {
pattern: /\$.*?\$/g,
inside: {
"md md-bracket-start": /^\$/,
"md md-bracket-end": /\$$/,
rest: r
}
}, a.strong = {
pattern: /([_\*])\1((?!\1{2}).)*\1{2}/g,
inside: {
"md md-strong": /([_\*])\1/g
}
}, a.em = {
pattern: /(^|[^\\])(\*|_)(\S[^\2]*?)??[^\s\\]+?\2/g,
lookbehind: !0,
inside: {
"md md-em md-start": /^(\*|_)/,
"md md-em md-close": /(\*|_)$/
}
}, a.strike = {
pattern: /(^|\n|\W)(~~)(?=\S)([^\r]*?\S)\2/gm,
lookbehind: !0,
inside: {
"md md-s": /(~~)/,
"md-strike-text": /[^~]+/
}
};
for (var l = {
code: a.code,
math: a.math,
fn: a.fn,
img: a.img,
link: a.link,
imgref: a.imgref,
linkref: a.linkref,
url: n,
email: i,
strong: a.strong,
em: a.em,
strike: a.strike,
conflict: /\u29f8\u29f8/g,
comment: Prism.languages.markup.comment,
tag: Prism.languages.markup.tag,
entity: Prism.languages.markup.entity
}, c = 6; c >= 1; c--) a["h" + c].inside.rest = l;
a["h1 alt"].inside.rest = l, a["h2 alt"].inside.rest = l, a.table.inside.rest = l,
a["table alt"].inside.rest = l, a.p.inside.rest = l, a.blockquote.inside.rest = l,
a.li.inside.rest = l, a.fndef.inside.rest = l, l = {
code: a.code,
fn: a.fn,
link: a.link,
linkref: a.linkref,
conflict: /\u29f8\u29f8/g
}, a.strong.inside.rest = l, a.em.inside.rest = l, a.strike.inside.rest = l;
var u = {
code: a.code,
strong: a.strong,
em: a.em,
strike: a.strike,
conflict: /\u29f8\u29f8/g,
comment: Prism.languages.markup.comment,
tag: Prism.languages.markup.tag,
entity: Prism.languages.markup.entity
};
return a.link.inside["md md-underlined-text"].inside = u, a.linkref.inside["ref-start"].inside["md md-underlined-text"].inside = u,
a;
}(), define("libs/prism-markdown", function() {}), define("editor", [ "jquery", "underscore", "utils", "settings", "eventMgr", "prism-core", "diff_match_patch_uncompressed", "jsondiffpatch", "crel", "rangy", "MutationObservers", "libs/prism-markdown" ], function(t, e, n, i, r, o, a, s, l, c) {
function u() {
this.isWatching = !1;
var t;
this.startWatching = function() {
this.isWatching = !0, t = t || new MutationObserver(S), t.observe(N, {
childList: !0,
subtree: !0,
characterData: !0
});
}, this.stopWatching = function() {
t.disconnect(), this.isWatching = !1;
}, this.noWatch = function(t) {
this.isWatching === !0 ? (this.stopWatching(), t(), this.startWatching()) : t();
};
}
function d() {
var t = this, o = 0, a = 0;
this.selectionStart = 0, this.selectionEnd = 0, this.cursorY = 0, this.adjustTop = 0,
this.adjustBottom = 0, this.findOffsets = function(t) {
var e = [];
if (!t.length) return e;
for (var n = t.shift(), i = document.createTreeWalker(N, 4, null, !1), r = "", o = 0; i.nextNode(); ) {
r = i.currentNode.nodeValue || "";
for (var a = o + r.length; a > n; ) {
if (e.push({
container: i.currentNode,
offsetInContainer: n - o,
offset: n
}), !t.length) return e;
n = t.shift();
}
o = a;
}
do e.push({
container: i.currentNode,
offsetInContainer: r.length,
offset: n
}), n = t.shift(); while (n);
return e;
}, this.createRange = function(t, n) {
t = t < 0 ? 0 : t, n = n < 0 ? 0 : n;
var i, r, o = document.createRange(), a = [];
e.isNumber(t) && (a.push(t), i = a.length - 1), e.isNumber(n) && (a.push(n), r = a.length - 1),
a = this.findOffsets(a);
var s = e.isObject(t) ? t : a[i];
o.setStart(s.container, s.offsetInContainer);
var l = s;
return n && n != t && (l = e.isObject(n) ? n : a[r]), o.setEnd(l.container, l.offsetInContainer),
o;
};
var s, l = n.debounce(function() {
D.toggleClass("has-selection", this.selectionStart !== this.selectionEnd);
var t = this.getCoordinates(this.selectionEnd, this.selectionEndContainer, this.selectionEndOffset);
if (this.cursorY !== t.y && (this.cursorY = t.y, r.onCursorCoordinates(t.x, t.y)),
s) {
var e, n;
if (e = n = I.offsetHeight / 2 * i.cursorFocusRatio, e = this.adjustTop || e, n = this.adjustBottom || e,
e && n) {
var o = I.scrollTop + e, a = I.scrollTop + I.offsetHeight - n;
V.cursorY < o ? I.scrollTop += V.cursorY - o : V.cursorY > a && (I.scrollTop += V.cursorY - a);
}
}
s = !1;
}, this);
this.updateCursorCoordinates = function(t) {
s = s || t, l();
}, this.updateSelectionRange = function() {
var t = Math.min(this.selectionStart, this.selectionEnd), e = Math.max(this.selectionStart, this.selectionEnd), n = this.createRange(t, e), i = c.getSelection();
i.removeAllRanges(), i.addRange(n, this.selectionStart > this.selectionEnd);
};
var u = e.debounce(function() {
o = t.selectionStart, a = t.selectionEnd;
}, 50);
this.setSelectionStartEnd = function(t, e) {
void 0 === t && (t = this.selectionStart), t < 0 && (t = 0), void 0 === e && (e = this.selectionEnd),
e < 0 && (e = 0), this.selectionStart = t, this.selectionEnd = e, G.editorStart = t,
G.editorEnd = e, u();
}, this.saveSelectionState = function() {
function e() {
if (q === !1) {
var e = t.selectionStart, n = t.selectionEnd, i = c.getSelection();
if (i.rangeCount > 0) {
var r = i.getRangeAt(0), o = r.startContainer;
if (N.compareDocumentPosition(o) & Node.DOCUMENT_POSITION_CONTAINED_BY || N === o) {
var a = r.startOffset;
o.hasChildNodes() && a > 0 && (o = o.childNodes[a - 1], a = o.textContent.length);
for (var s = o; o != N; ) {
for (;o = o.previousSibling; ) o.textContent && (a += o.textContent.length);
o = s = s.parentNode;
}
i.isBackwards() ? (e = a + r.toString().length, n = a) : (e = a, n = a + r.toString().length),
e === n && "\n" == r.startContainer.textContent && 1 == r.startOffset && (e = --n,
t.setSelectionStartEnd(e, n), t.updateSelectionRange());
}
}
t.setSelectionStartEnd(e, n);
}
X.saveSelectionState();
}
var i = !1, r = n.debounce(function() {
e(), t.updateCursorCoordinates(i), s();
}), s = n.debounce(function() {
e(), o === t.selectionStart && a === t.selectionEnd && (i = !1), t.updateCursorCoordinates(i),
i = !1;
}, 10);
return function(t, n, s) {
return s && (o = void 0, a = void 0), t ? (i = i || n, r()) : void e();
};
}(), this.getSelectedText = function() {
var t = Math.min(this.selectionStart, this.selectionEnd), e = Math.max(this.selectionStart, this.selectionEnd);
return W.substring(t, e);
}, this.getCoordinates = function(t, e, n) {
if (!e) {
var i = this.findOffsets([ t ])[0];
e = i.container, n = i.offsetInContainer;
}
var r = 0, o = 0;
if ("\n" == e.textContent) o = e.parentNode.offsetTop + e.parentNode.offsetHeight / 2; else {
var a = W[t], s = {
container: e,
offsetInContainer: n,
offset: t
}, l = {
container: e,
offsetInContainer: n,
offset: t
};
t > 0 && (void 0 === a || "\n" == a) ? 0 === s.offset ? s = t - 1 : s.offsetInContainer -= 1 : l.offset === e.textContent.length ? l = t + 1 : l.offsetInContainer += 1;
var c = this.createRange(s, l), u = c.getBoundingClientRect();
o = u.top + u.height / 2 - I.getBoundingClientRect().top + I.scrollTop;
}
return {
x: r,
y: o
};
}, this.getClosestWordOffset = function(t) {
var e = 0, n = 0, i = 0;
return W.split(/\s/).some(function(r) {
return !!(r && (e = i, n = i + r.length, n > t)) || void (i += r.length + 1);
}), {
start: e,
end: n
};
};
}
function p(t) {
void 0 !== I && V.saveSelectionState(!0, !0, t);
}
function h(t) {
var e = U.diff_commonPrefix(W, t);
e === W.length && e--;
var n = Math.min(U.diff_commonSuffix(W, t), W.length - e, t.length - e), i = t.substring(e, t.length - n), r = V.createRange(e, W.length - n);
return r.deleteContents(), r.insertNode(document.createTextNode(i)), {
start: e,
end: t.length - n
};
}
function f(t, e, n) {
X.currentMode = X.currentMode || "replace";
var i = V.createRange(Math.min(t, e), Math.max(t, e));
"" + i != n && (i.deleteContents(), i.insertNode(document.createTextNode(n)));
var r = t + n.length;
V.setSelectionStartEnd(r, r), V.updateSelectionRange(), V.updateCursorCoordinates(!0);
}
function m(t, e) {
X.currentMode = X.currentMode || "replace";
var n = W.replace(t, e);
if (n != W) {
var i = F.setValue(n);
V.setSelectionStartEnd(i.end, i.end), V.updateSelectionRange(), V.updateCursorCoordinates(!0);
}
}
function g(t, e) {
var n = V.selectionStart;
if (n !== V.selectionEnd) return !1;
var i = V.createRange(n - t.length, n);
return "" + i == t && (i.deleteContents(), i.insertNode(document.createTextNode(e)),
n = n - t.length + e.length, V.setSelectionStartEnd(n, n), V.updateSelectionRange(),
V.updateCursorCoordinates(!0), !0);
}
function v(t) {
h(t), W = t;
}
function b() {
return W;
}
function y() {
M.focus(), V.updateSelectionRange(), I.scrollTop = B;
}
function x() {
function t(t, n, i) {
H.noWatch(function() {
W != t.content && (v(t.content), G.content = t.content, r.onContentChanged(G, t.content)),
V.setSelectionStartEnd(n, i), V.updateSelectionRange(), V.updateCursorCoordinates(!0);
var o = G.discussionListJSON;
if (o != t.discussionListJSON) {
var a = G.discussionList;
G.discussionListJSON = t.discussionListJSON;
var s = G.discussionList, l = z.diff(a, s), c = !1;
e.each(l, function(t, n) {
e.isArray(t) ? 1 === t.length ? r.onDiscussionCreated(G, s[n]) : r.onDiscussionRemoved(G, a[n]) : c = !0;
}), c && r.onCommentsChanged(G);
}
}), s = n, l = i, a = t, this.currentMode = void 0, o = void 0, this.onButtonStateChange(),
p();
}
var i, o, a, s, l, c = [], u = [];
this.setCommandMode = function() {
this.currentMode = "command";
}, this.setMode = function() {}, this.onButtonStateChange = function() {}, this.saveState = n.debounce(function() {
u = [];
var t = Date.now();
if ("comment" == this.currentMode || "replace" == this.currentMode || "newlines" == o || this.currentMode != o || t - i > 1e3) for (c.push(a); c.length > 100; ) c.shift(); else s = a.selectionStartBefore,
l = a.selectionEndBefore;
a = {
selectionStartBefore: s,
selectionEndBefore: l,
selectionStartAfter: V.selectionStart,
selectionEndAfter: V.selectionEnd,
content: W,
discussionListJSON: G.discussionListJSON
}, i = t, o = this.currentMode, this.currentMode = void 0, this.onButtonStateChange();
}, this), this.saveSelectionState = e.debounce(function() {
void 0 === this.currentMode && (s = V.selectionStart, l = V.selectionEnd);
}, 50), this.canUndo = function() {
return c.length;
}, this.canRedo = function() {
return u.length;
}, this.undo = function() {
var e = c.pop();
e && (u.push(a), t.call(this, e, a.selectionStartBefore, a.selectionEndBefore));
}, this.redo = function() {
var e = u.pop();
e && (c.push(a), t.call(this, e, e.selectionStartAfter, e.selectionEndAfter));
}, this.init = function() {
var t = G.content;
c = [], u = [], i = 0, a = {
selectionStartAfter: G.selectionStart,
selectionEndAfter: G.selectionEnd,
content: t,
discussionListJSON: G.discussionListJSON
}, this.currentMode = void 0, o = void 0, N.textContent = t, S();
};
}
function w() {
H.isWatching === !0 && (X.currentMode = X.currentMode || "comment", X.saveState());
}
function S() {
var t = I.textContent;
if (N.lastChild === O && "\n" == O.textContent.slice(-1) && (t = t.slice(0, -1)),
t = t.replace(/\r\n?/g, "\n"), q === !1) {
if (t == W) return void (0 === N.children.length && (N.innerHTML = "", K.forEach(function(t) {
N.appendChild(t.elt);
}), E()));
X.currentMode = X.currentMode || "typing";
var n = e.values(G.discussionList);
G.newDiscussion && n.push(G.newDiscussion);
var i = C(W, t, n);
W = t, i === !0 && (G.discussionList = G.discussionList), G.content = W, V.saveSelectionState(),
r.onContentChanged(G, W), i && r.onCommentsChanged(G), X.saveState(), Q();
} else W = t, G.content = W, V.setSelectionStartEnd(G.editorStart, G.editorEnd),
V.updateSelectionRange(), V.updateCursorCoordinates(), X.saveSelectionState(), r.onFileOpen(G, W),
R.scrollTop = G.previewScrollTop, B = G.editorScrollTop, I.scrollTop = B, q = !1;
}
function C(t, e, n) {
if (n.length) {
var i = U.diff_main(t, e), r = !1, o = 0;
return i.forEach(function(t) {
var e = t[0], i = t[1];
if (0 === e) return void (o += i.length);
var a = o, s = i.length;
e === -1 && (a += s, s = -s), n.forEach(function(t) {
t.selectionEnd > a ? (t.selectionEnd += s, t.discussionIndex && (r = !0)) : t.selectionEnd > o && (t.selectionEnd = o,
t.discussionIndex && (r = !0)), t.selectionStart >= a ? (t.selectionStart += s,
t.discussionIndex && (r = !0)) : t.selectionStart > o && (t.selectionStart = o,
t.discussionIndex && (r = !0));
}), 1 === e && (o += i.length);
}), r;
}
}
function _(t) {
if (Z = [], J = [], Y = void 0, q === !0) return J = K, K = t, void (Z = t);
var n = K.length;
e.some(K, function(e, i) {
var r = t[i];
if (i >= t.length || e.textWithFrontMatter != r.textWithFrontMatter || e.elt.parentNode !== N || e.elt.textContent != r.textWithFrontMatter) return n = i,
!0;
});
var i = -K.length;
e.some(K.slice().reverse(), function(e, n) {
var r = t[t.length - n - 1];
if (n >= t.length || e.textWithFrontMatter != r.textWithFrontMatter || e.elt.parentNode !== N || e.elt.textContent != r.textWithFrontMatter) return i = -n,
!0;
}), n - i > K.length && (i = n - K.length);
var r = K.slice(0, n);
Z = t.slice(n, t.length + i);
var o = K.slice(K.length + i, K.length);
Y = e.first(o), J = K.slice(n, K.length + i), K = r.concat(Z).concat(o);
}
function k() {
var t = document.createDocumentFragment();
Z.forEach(function(e) {
T(e), t.appendChild(e.elt);
}), H.noWatch(function() {
if (q === !0) N.innerHTML = "", N.appendChild(t); else {
J.forEach(function(t) {
t.elt.parentNode === N && N.removeChild(t.elt), t.elt.generated = !1;
}), void 0 !== Y ? N.insertBefore(t, Y.elt) : N.appendChild(t);
for (var e = N.firstChild; e; ) {
var n = e.nextSibling;
e.generated || N.removeChild(e), e = n;
}
}
E(), V.updateSelectionRange(), V.updateCursorCoordinates();
});
}
function E() {
O = l("span", {
"class": "token lf"
}), O.textContent = "\n", N.appendChild(O);
}
function T(t) {
var e = tt(t.text);
window.viewerMode || (e = o.highlight(e, o.languages.md));
var n = t.textWithFrontMatter.substring(0, t.textWithFrontMatter.length - t.text.length);
n.length && (n = tt(n), n = n.replace(/\n/g, '\n'),
e = '' + n + "" + e);
var i = l("span", {
id: "wmd-input-section-" + t.id,
"class": "wmd-input-section"
});
i.generated = !0, i.innerHTML = e, t.elt = i;
}
var I, D, N, M, L, A, R, P, O, F = {}, B = 0, j = function() {
var t, n = 0, r = function() {
var t = Date.now();
P.refreshPreview(), n = Date.now() - t;
};
return i.lazyRendering === !0 ? e.debounce(r, 500) : function() {
clearTimeout(t), t = setTimeout(r, n < 2e3 ? n : 2e3);
};
}();
r.addListener("onPagedownConfigure", function(t) {
P = t;
});
var $ = 0;
r.addListener("onSectionsCreated", function(t) {
$ || (_(t), k()), q === !0 ? P.refreshPreview() : j();
});
var G, q = !0;
r.addListener("onFileSelected", function(t) {
q = !0, G = t;
});
var H = new u();
F.watcher = H;
var U = new a(), z = s.create({
objectHash: function(t) {
return JSON.stringify(t);
},
arrays: {
detectMove: !1
},
textDiff: {
minLength: 9999999
}
}), V = new d();
F.selectionMgr = V, t(document).on("selectionchange", ".editor-content", e.bind(V.saveSelectionState, V, !0, !1)),
F.adjustCursorPosition = p;
var W;
F.setValue = h, F.replace = f, F.replaceAll = m, F.replacePreviousText = g, F.setValueNoWatch = v,
F.getValue = b, F.focus = y;
var X = new x();
F.undoMgr = X, r.addListener("onDiscussionCreated", w), r.addListener("onDiscussionRemoved", w),
r.addListener("onCommentsChanged", w);
var Q = e.debounce(function() {
var t = window.getSelection();
V.hasFocus && !$ && V.selectionStart === V.selectionEnd && t.modify && (V.selectionStart ? (t.modify("move", "backward", "character"),
t.modify("move", "forward", "character")) : (t.modify("move", "forward", "character"),
t.modify("move", "backward", "character")));
}, 10);
F.adjustCommentOffsets = C, F.init = function() {
if (I = document.getElementById("wmd-input"), D = t(I), N = I.querySelector(".editor-content"),
M = t(N), L = I.querySelector(".editor-margin"), A = t(L), R = document.querySelector(".preview-container"),
D.addClass(i.editorFontClass), H.startWatching(), t(I).scroll(function() {
B = I.scrollTop, q === !1 && (G.editorScrollTop = B);
}), t(R).scroll(function() {
q === !1 && (G.previewScrollTop = R.scrollTop);
}), /AppleWebKit\/([\d.]+)/.exec(navigator.userAgent)) {
var n = t('').appendTo("html");
M.blur(function() {
n[0].setSelectionRange(0, 0), n.blur();
});
}
I.focus = y, I.adjustCursorPosition = p, Object.defineProperty(I, "value", {
get: function() {
return W;
},
set: h
}), Object.defineProperty(I, "selectionStart", {
get: function() {
return Math.min(V.selectionStart, V.selectionEnd);
},
set: function(t) {
V.setSelectionStartEnd(t), V.updateSelectionRange(), V.updateCursorCoordinates();
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(I, "selectionEnd", {
get: function() {
return Math.max(V.selectionStart, V.selectionEnd);
},
set: function(t) {
V.setSelectionStartEnd(void 0, t), V.updateSelectionRange(), V.updateCursorCoordinates();
},
enumerable: !0,
configurable: !0
});
var r = !1;
M.on("keydown", function(t) {
if (17 !== t.which && 91 !== t.which && 18 !== t.which && 16 !== t.which) {
V.saveSelectionState(), p();
var e = t.metaKey || t.ctrlKey;
switch (t.which) {
case 9:
e || (o("indent", {
inverse: t.shiftKey
}), t.preventDefault());
break;
case 13:
o("newline"), t.preventDefault();
}
13 !== t.which && (r = !1);
}
}).on("compositionstart", function() {
$++;
}).on("compositionend", function() {
setTimeout(function() {
$--;
}, 0);
}).on("mouseup", e.bind(V.saveSelectionState, V, !0, !1)).on("paste", function(t) {
X.currentMode = "paste", t.preventDefault();
var e, n = (t.originalEvent || t).clipboardData;
n ? e = n.getData("text/plain") : (n = window.clipboardData, e = n && n.getData("Text")),
e && (f(V.selectionStart, V.selectionEnd, e), p());
}).on("cut", function() {
X.currentMode = "cut", p();
}).on("focus", function() {
V.hasFocus = !0;
}).on("blur", function() {
V.hasFocus = !1;
});
var o = function(t, e) {
var n = b(), i = Math.min(V.selectionStart, V.selectionEnd), r = Math.max(V.selectionStart, V.selectionEnd), o = {
selectionStart: i,
selectionEnd: r,
before: n.slice(0, i),
after: n.slice(r),
selection: n.slice(i, r)
};
s[t](o, e || {}), h(o.before + o.selection + o.after), V.setSelectionStartEnd(o.selectionStart, o.selectionEnd),
V.updateSelectionRange();
}, a = /^ {0,3}>[ ]*|^[ \t]*(?:[*+\-]|(\d+)\.)[ \t]|^\s+/, s = {
indent: function(t, e) {
function n(t, e, n, i) {
return n = +n || 0, i = i || "", t.slice(0, e) + i + t.slice(e + n);
}
var i = t.before.lastIndexOf("\n") + 1;
if (e.inverse) /\s/.test(t.before.charAt(i)) && (t.before = n(t.before, i, 1), t.selectionStart--,
t.selectionEnd--), t.selection = t.selection.replace(/^[ \t]/gm, ""); else {
var r = t.before.slice(i);
if (!t.selection && !r.match(a)) return t.before += "\t", t.selectionStart++, void t.selectionEnd++;
t.before = n(t.before, i, 0, "\t"), t.selection = t.selection.replace(/\r?\n(?=[\s\S])/g, "\n\t"),
t.selectionStart++, t.selectionEnd++;
}
t.selectionEnd = t.selectionStart + t.selection.length;
},
newline: function(t) {
var e = t.before.lastIndexOf("\n") + 1;
if (r) return t.before = t.before.substring(0, e), t.selection = "", t.selectionStart = e,
t.selectionEnd = e, void (r = !1);
r = !1;
var n = t.before.slice(e), i = n.match(a), o = (i || [ "" ])[0];
if (i && i[1]) {
var s = parseInt(i[1], 10);
o = o.replace(/\d+/, s + 1);
}
o.length && (r = !0), X.currentMode = "newlines", t.before += "\n" + o, t.selection = "",
t.selectionStart += o.length + 1, t.selectionEnd = t.selectionStart;
}
};
};
var Y, K = [], J = [], Z = [], tt = function() {
var t = {
"&": "&",
"<": "<",
"\xa0": " "
};
return function(e) {
return e.replace(/[&<\u00a0]/g, function(e) {
return t[e];
});
};
}();
return r.onEditorCreated(F), F;
}), function(t, e) {
function n() {
i.READY || (b.determineEventTypes(), f.each(i.gestures, function(t) {
x.register(t);
}), b.onTouch(i.DOCUMENT, p, x.detect), b.onTouch(i.DOCUMENT, h, x.detect), i.READY = !0);
}
var i = function(t, e) {
return new i.Instance(t, e || {});
};
i.VERSION = "1.0.11", i.defaults = {
stop_browser_behavior: {
userSelect: "none",
touchAction: "pan-y",
touchCallout: "none",
contentZooming: "none",
userDrag: "none",
tapHighlightColor: "rgba(0,0,0,0)"
}
}, i.HAS_POINTEREVENTS = t.navigator.pointerEnabled || t.navigator.msPointerEnabled,
i.HAS_TOUCHEVENTS = "ontouchstart" in t, i.MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android|silk/i,
i.NO_MOUSEEVENTS = i.HAS_TOUCHEVENTS && t.navigator.userAgent.match(i.MOBILE_REGEX),
i.EVENT_TYPES = {}, i.UPDATE_VELOCITY_INTERVAL = 16, i.DOCUMENT = t.document;
var r = i.DIRECTION_DOWN = "down", o = i.DIRECTION_LEFT = "left", a = i.DIRECTION_UP = "up", s = i.DIRECTION_RIGHT = "right", l = i.POINTER_MOUSE = "mouse", c = i.POINTER_TOUCH = "touch", u = i.POINTER_PEN = "pen", d = i.EVENT_START = "start", p = i.EVENT_MOVE = "move", h = i.EVENT_END = "end";
i.plugins = i.plugins || {}, i.gestures = i.gestures || {}, i.READY = !1;
var f = i.utils = {
extend: function(t, n, i) {
for (var r in n) t[r] !== e && i || (t[r] = n[r]);
return t;
},
each: function(t, n, i) {
var r, o;
if ("forEach" in t) t.forEach(n, i); else if (t.length !== e) {
for (r = -1; o = t[++r]; ) if (n.call(i, o, r, t) === !1) return;
} else for (r in t) if (t.hasOwnProperty(r) && n.call(i, t[r], r, t) === !1) return;
},
inStr: function(t, e) {
return t.indexOf(e) > -1;
},
hasParent: function(t, e) {
for (;t; ) {
if (t == e) return !0;
t = t.parentNode;
}
return !1;
},
getCenter: function(t) {
var e = [], n = [], i = [], r = [], o = Math.min, a = Math.max;
return 1 === t.length ? {
pageX: t[0].pageX,
pageY: t[0].pageY,
clientX: t[0].clientX,
clientY: t[0].clientY
} : (f.each(t, function(t) {
e.push(t.pageX), n.push(t.pageY), i.push(t.clientX), r.push(t.clientY);
}), {
pageX: (o.apply(Math, e) + a.apply(Math, e)) / 2,
pageY: (o.apply(Math, n) + a.apply(Math, n)) / 2,
clientX: (o.apply(Math, i) + a.apply(Math, i)) / 2,
clientY: (o.apply(Math, r) + a.apply(Math, r)) / 2
});
},
getVelocity: function(t, e, n) {
return {
x: Math.abs(e / t) || 0,
y: Math.abs(n / t) || 0
};
},
getAngle: function(t, e) {
var n = e.clientX - t.clientX, i = e.clientY - t.clientY;
return 180 * Math.atan2(i, n) / Math.PI;
},
getDirection: function(t, e) {
var n = Math.abs(t.clientX - e.clientX), i = Math.abs(t.clientY - e.clientY);
return n >= i ? t.clientX - e.clientX > 0 ? o : s : t.clientY - e.clientY > 0 ? a : r;
},
getDistance: function(t, e) {
var n = e.clientX - t.clientX, i = e.clientY - t.clientY;
return Math.sqrt(n * n + i * i);
},
getScale: function(t, e) {
return t.length >= 2 && e.length >= 2 ? this.getDistance(e[0], e[1]) / this.getDistance(t[0], t[1]) : 1;
},
getRotation: function(t, e) {
return t.length >= 2 && e.length >= 2 ? this.getAngle(e[1], e[0]) - this.getAngle(t[1], t[0]) : 0;
},
isVertical: function(t) {
return t == a || t == r;
},
toggleDefaultBehavior: function(t, e, n) {
if (e && t && t.style) {
f.each([ "webkit", "moz", "Moz", "ms", "o", "" ], function(i) {
f.each(e, function(e, r) {
i && (r = i + r.substring(0, 1).toUpperCase() + r.substring(1)), r in t.style && (t.style[r] = !n && e);
});
});
var i = function() {
return !1;
};
"none" == e.userSelect && (t.onselectstart = !n && i), "none" == e.userDrag && (t.ondragstart = !n && i);
}
}
};
i.Instance = function(t, e) {
var r = this;
return n(), this.element = t, this.enabled = !0, this.options = f.extend(f.extend({}, i.defaults), e || {}),
this.options.stop_browser_behavior && f.toggleDefaultBehavior(this.element, this.options.stop_browser_behavior, !1),
this.eventStartHandler = b.onTouch(t, d, function(t) {
r.enabled && x.startDetect(r, t);
}), this.eventHandlers = [], this;
}, i.Instance.prototype = {
on: function(t, e) {
var n = t.split(" ");
return f.each(n, function(t) {
this.element.addEventListener(t, e, !1), this.eventHandlers.push({
gesture: t,
handler: e
});
}, this), this;
},
off: function(t, e) {
var n, i, r = t.split(" ");
return f.each(r, function(t) {
for (this.element.removeEventListener(t, e, !1), n = -1; i = this.eventHandlers[++n]; ) i.gesture === t && i.handler === e && this.eventHandlers.splice(n, 1);
}, this), this;
},
trigger: function(t, e) {
e || (e = {});
var n = i.DOCUMENT.createEvent("Event");
n.initEvent(t, !0, !0), n.gesture = e;
var r = this.element;
return f.hasParent(e.target, r) && (r = e.target), r.dispatchEvent(n), this;
},
enable: function(t) {
return this.enabled = t, this;
},
dispose: function() {
var t, e;
for (this.options.stop_browser_behavior && f.toggleDefaultBehavior(this.element, this.options.stop_browser_behavior, !0),
t = -1; e = this.eventHandlers[++t]; ) this.element.removeEventListener(e.gesture, e.handler, !1);
return this.eventHandlers = [], b.unbindDom(this.element, i.EVENT_TYPES[d], this.eventStartHandler),
null;
}
};
var m = null, g = !1, v = !1, b = i.event = {
bindDom: function(t, e, n) {
var i = e.split(" ");
f.each(i, function(e) {
t.addEventListener(e, n, !1);
});
},
unbindDom: function(t, e, n) {
var i = e.split(" ");
f.each(i, function(e) {
t.removeEventListener(e, n, !1);
});
},
onTouch: function(t, e, n) {
var r = this, o = function(o) {
var a = o.type.toLowerCase();
if (!f.inStr(a, "mouse") || !v) {
f.inStr(a, "touch") || f.inStr(a, "pointerdown") || f.inStr(a, "mouse") && 1 === o.which ? g = !0 : f.inStr(a, "mouse") && !o.which && (g = !1),
(f.inStr(a, "touch") || f.inStr(a, "pointer")) && (v = !0);
var s = 0;
g && (i.HAS_POINTEREVENTS && e != h ? s = y.updatePointer(e, o) : f.inStr(a, "touch") ? s = o.touches.length : v || (s = f.inStr(a, "up") ? 0 : 1),
s > 0 && e == h ? e = p : s || (e = h), (s || null === m) && (m = o), n.call(x, r.collectEventData(t, e, r.getTouchList(m, e), o)),
i.HAS_POINTEREVENTS && e == h && (s = y.updatePointer(e, o))), s || (m = null, g = !1,
v = !1, y.reset());
}
};
return this.bindDom(t, i.EVENT_TYPES[e], o), o;
},
determineEventTypes: function() {
var t;
t = i.HAS_POINTEREVENTS ? y.getEvents() : i.NO_MOUSEEVENTS ? [ "touchstart", "touchmove", "touchend touchcancel" ] : [ "touchstart mousedown", "touchmove mousemove", "touchend touchcancel mouseup" ],
i.EVENT_TYPES[d] = t[0], i.EVENT_TYPES[p] = t[1], i.EVENT_TYPES[h] = t[2];
},
getTouchList: function(t) {
return i.HAS_POINTEREVENTS ? y.getTouchList() : t.touches ? t.touches : (t.identifier = 1,
[ t ]);
},
collectEventData: function(t, e, n, i) {
var r = c;
return (f.inStr(i.type, "mouse") || y.matchType(l, i)) && (r = l), {
center: f.getCenter(n),
timeStamp: Date.now(),
target: i.target,
touches: n,
eventType: e,
pointerType: r,
srcEvent: i,
preventDefault: function() {
var t = this.srcEvent;
t.preventManipulation && t.preventManipulation(), t.preventDefault && t.preventDefault();
},
stopPropagation: function() {
this.srcEvent.stopPropagation();
},
stopDetect: function() {
return x.stopDetect();
}
};
}
}, y = i.PointerEvent = {
pointers: {},
getTouchList: function() {
var t = [];
return f.each(this.pointers, function(e) {
t.push(e);
}), t;
},
updatePointer: function(t, e) {
return t == h ? delete this.pointers[e.pointerId] : (e.identifier = e.pointerId,
this.pointers[e.pointerId] = e), Object.keys(this.pointers).length;
},
matchType: function(t, e) {
if (!e.pointerType) return !1;
var n = e.pointerType, i = {};
return i[l] = n === l, i[c] = n === c, i[u] = n === u, i[t];
},
getEvents: function() {
return [ "pointerdown MSPointerDown", "pointermove MSPointerMove", "pointerup pointercancel MSPointerUp MSPointerCancel" ];
},
reset: function() {
this.pointers = {};
}
}, x = i.detection = {
gestures: [],
current: null,
previous: null,
stopped: !1,
startDetect: function(t, e) {
this.current || (this.stopped = !1, this.current = {
inst: t,
startEvent: f.extend({}, e),
lastEvent: !1,
lastVelocityEvent: !1,
velocity: !1,
name: ""
}, this.detect(e));
},
detect: function(t) {
if (this.current && !this.stopped) {
t = this.extendEventData(t);
var e = this.current.inst, n = e.options;
return f.each(this.gestures, function(i) {
if (!this.stopped && n[i.name] !== !1 && e.enabled !== !1 && i.handler.call(i, t, e) === !1) return this.stopDetect(),
!1;
}, this), this.current && (this.current.lastEvent = t), t.eventType == h && !t.touches.length - 1 && this.stopDetect(),
t;
}
},
stopDetect: function() {
this.previous = f.extend({}, this.current), this.current = null, this.stopped = !0;
},
getVelocityData: function(t, e, n, r) {
var o = this.current, a = o.lastVelocityEvent, s = o.velocity;
a && t.timeStamp - a.timeStamp > i.UPDATE_VELOCITY_INTERVAL ? (s = f.getVelocity(t.timeStamp - a.timeStamp, t.center.clientX - a.center.clientX, t.center.clientY - a.center.clientY),
o.lastVelocityEvent = t) : o.velocity || (s = f.getVelocity(e, n, r), o.lastVelocityEvent = t),
o.velocity = s, t.velocityX = s.x, t.velocityY = s.y;
},
getInterimData: function(t) {
var e, n, i = this.current.lastEvent;
t.eventType == h ? (e = i && i.interimAngle, n = i && i.interimDirection) : (e = i && f.getAngle(i.center, t.center),
n = i && f.getDirection(i.center, t.center)), t.interimAngle = e, t.interimDirection = n;
},
extendEventData: function(t) {
var e = this.current, n = e.startEvent;
t.touches.length == n.touches.length && t.touches !== n.touches || (n.touches = [],
f.each(t.touches, function(t) {
n.touches.push(f.extend({}, t));
}));
var i = t.timeStamp - n.timeStamp, r = t.center.clientX - n.center.clientX, o = t.center.clientY - n.center.clientY;
return this.getVelocityData(t, i, r, o), this.getInterimData(t), f.extend(t, {
startEvent: n,
deltaTime: i,
deltaX: r,
deltaY: o,
distance: f.getDistance(n.center, t.center),
angle: f.getAngle(n.center, t.center),
direction: f.getDirection(n.center, t.center),
scale: f.getScale(n.touches, t.touches),
rotation: f.getRotation(n.touches, t.touches)
}), t;
},
register: function(t) {
var n = t.defaults || {};
return n[t.name] === e && (n[t.name] = !0), f.extend(i.defaults, n, !0), t.index = t.index || 1e3,
this.gestures.push(t), this.gestures.sort(function(t, e) {
return t.index < e.index ? -1 : t.index > e.index ? 1 : 0;
}), this.gestures;
}
};
i.gestures.Drag = {
name: "drag",
index: 50,
defaults: {
drag_min_distance: 10,
correct_for_drag_min_distance: !0,
drag_max_touches: 1,
drag_block_horizontal: !1,
drag_block_vertical: !1,
drag_lock_to_axis: !1,
drag_lock_min_distance: 25
},
triggered: !1,
handler: function(t, e) {
var n = x.current;
if (n.name != this.name && this.triggered) return e.trigger(this.name + "end", t),
void (this.triggered = !1);
if (!(e.options.drag_max_touches > 0 && t.touches.length > e.options.drag_max_touches)) switch (t.eventType) {
case d:
this.triggered = !1;
break;
case p:
if (t.distance < e.options.drag_min_distance && n.name != this.name) return;
var i = n.startEvent.center;
if (n.name != this.name && (n.name = this.name, e.options.correct_for_drag_min_distance && t.distance > 0)) {
var l = Math.abs(e.options.drag_min_distance / t.distance);
i.pageX += t.deltaX * l, i.pageY += t.deltaY * l, i.clientX += t.deltaX * l, i.clientY += t.deltaY * l,
t = x.extendEventData(t);
}
(n.lastEvent.drag_locked_to_axis || e.options.drag_lock_to_axis && e.options.drag_lock_min_distance <= t.distance) && (t.drag_locked_to_axis = !0);
var c = n.lastEvent.direction;
t.drag_locked_to_axis && c !== t.direction && (f.isVertical(c) ? t.direction = t.deltaY < 0 ? a : r : t.direction = t.deltaX < 0 ? o : s),
this.triggered || (e.trigger(this.name + "start", t), this.triggered = !0), e.trigger(this.name, t),
e.trigger(this.name + t.direction, t);
var u = f.isVertical(t.direction);
(e.options.drag_block_vertical && u || e.options.drag_block_horizontal && !u) && t.preventDefault();
break;
case h:
this.triggered && e.trigger(this.name + "end", t), this.triggered = !1;
}
}
}, i.gestures.Hold = {
name: "hold",
index: 10,
defaults: {
hold_timeout: 500,
hold_threshold: 2
},
timer: null,
handler: function(t, e) {
switch (t.eventType) {
case d:
clearTimeout(this.timer), x.current.name = this.name, this.timer = setTimeout(function() {
"hold" == x.current.name && e.trigger("hold", t);
}, e.options.hold_timeout);
break;
case p:
t.distance > e.options.hold_threshold && clearTimeout(this.timer);
break;
case h:
clearTimeout(this.timer);
}
}
}, i.gestures.Release = {
name: "release",
index: 1 / 0,
handler: function(t, e) {
t.eventType == h && e.trigger(this.name, t);
}
}, i.gestures.Swipe = {
name: "swipe",
index: 40,
defaults: {
swipe_min_touches: 1,
swipe_max_touches: 1,
swipe_velocity: .7
},
handler: function(t, e) {
if (t.eventType == h) {
if (t.touches.length < e.options.swipe_min_touches || t.touches.length > e.options.swipe_max_touches) return;
(t.velocityX > e.options.swipe_velocity || t.velocityY > e.options.swipe_velocity) && (e.trigger(this.name, t),
e.trigger(this.name + t.direction, t));
}
}
}, i.gestures.Tap = {
name: "tap",
index: 100,
defaults: {
tap_max_touchtime: 250,
tap_max_distance: 10,
tap_always: !0,
doubletap_distance: 20,
doubletap_interval: 300
},
has_moved: !1,
handler: function(t, e) {
var n, i, r;
t.eventType == d ? this.has_moved = !1 : t.eventType != p || this.moved ? t.eventType == h && "touchcancel" != t.srcEvent.type && t.deltaTime < e.options.tap_max_touchtime && !this.has_moved && (n = x.previous,
i = n && n.lastEvent && t.timeStamp - n.lastEvent.timeStamp, r = !1, n && "tap" == n.name && i && i < e.options.doubletap_interval && t.distance < e.options.doubletap_distance && (e.trigger("doubletap", t),
r = !0), r && !e.options.tap_always || (x.current.name = "tap", e.trigger(x.current.name, t))) : this.has_moved = t.distance > e.options.tap_max_distance;
}
}, i.gestures.Touch = {
name: "touch",
index: -(1 / 0),
defaults: {
prevent_default: !1,
prevent_mouseevents: !1
},
handler: function(t, e) {
return e.options.prevent_mouseevents && t.pointerType == l ? void t.stopDetect() : (e.options.prevent_default && t.preventDefault(),
void (t.eventType == d && e.trigger(this.name, t)));
}
}, i.gestures.Transform = {
name: "transform",
index: 45,
defaults: {
transform_min_scale: .01,
transform_min_rotation: 1,
transform_always_block: !1,
transform_within_instance: !1
},
triggered: !1,
handler: function(t, e) {
if (x.current.name != this.name && this.triggered) return e.trigger(this.name + "end", t),
void (this.triggered = !1);
if (!(t.touches.length < 2)) {
if (e.options.transform_always_block && t.preventDefault(), e.options.transform_within_instance) for (var n = -1; t.touches[++n]; ) if (!f.hasParent(t.touches[n].target, e.element)) return;
switch (t.eventType) {
case d:
this.triggered = !1;
break;
case p:
var i = Math.abs(1 - t.scale), r = Math.abs(t.rotation);
if (i < e.options.transform_min_scale && r < e.options.transform_min_rotation) return;
x.current.name = this.name, this.triggered || (e.trigger(this.name + "start", t),
this.triggered = !0), e.trigger(this.name, t), r > e.options.transform_min_rotation && e.trigger("rotate", t),
i > e.options.transform_min_scale && (e.trigger("pinch", t), e.trigger("pinch" + (t.scale < 1 ? "in" : "out"), t));
break;
case h:
this.triggered && e.trigger(this.name + "end", t), this.triggered = !1;
}
}
}
}, "function" == typeof define && define.amd ? define("hammerjs", [], function() {
return i;
}) : "object" == typeof module && module.exports ? module.exports = i : t.Hammer = i;
}(window), define("layout", [ "jquery", "underscore", "utils", "constants", "settings", "eventMgr", "crel", "mousetrap", "hammerjs" ], function(t, e, n, i, r, o, a, s, l) {
function c() {
U = !0, b.$elt.addClass("layout-animate");
}
function u() {
U = !1, b.$elt.removeClass("layout-animate");
}
function d(e) {
this.selector = e, this.elt = document.querySelector(e), this.$elt = t(this.elt);
}
function p(t) {
t && t.target !== b.elt && t.target !== y.elt && t.target !== k.elt || (z.forEach(function(t) {
t();
}), u(), 0 !== z.length && f(), z = []);
}
function h() {
return e.find(et, function(t) {
return v.width > t.screenWidth;
}).maxWidth;
}
function f() {
var t = x.height - 60, e = (_.elt.offsetWidth - h()) / 2;
e < i.EDITOR_DEFAULT_PADDING && (e = i.EDITOR_DEFAULT_PADDING), V.style.paddingLeft = e + "px",
V.style.paddingRight = e + "px", V.style.paddingBottom = t + "px", X.style.width = e + "px";
var n = (E.elt.offsetWidth - h()) / 2;
n < i.EDITOR_DEFAULT_PADDING && (n = i.EDITOR_DEFAULT_PADDING), W.style.paddingLeft = n + "px",
W.style.paddingRight = n + "px", W.style.paddingBottom = t + "px";
var r = rt + st + $ + ot;
window.viewerMode && (r = rt + st + $ + at);
var a = v.width - r + $;
nt.forEach(function(t, e) {
r += t.width, e === nt.length - 1 && (r -= ot), v.width < r ? Y.appendChild(t.elt) : (Q.insertBefore(t.elt, J),
a = v.width - r + $);
}), Z.css({
maxWidth: a
}), K.toggleClass("hide", 0 === Y.children.length), o.onLayoutResize();
}
function m() {
b.width = v.width + B + (C.isShown ? j : 0), b.elt.style.width = b.width + "px",
C.right = C.isShown ? 0 : -j, C.elt.style.right = C.right + "px";
}
function g() {
for (v = {
width: window.innerWidth,
height: window.innerHeight
}; ;) {
if (b.y = w.isOpen ? 0 : -P, b.x = S.isOpen ? 0 : C.isOpen ? -(B + j) : -B, b.width = v.width + B + j,
b.height = v.height - b.y, y.left = B, y.width = v.width, y.height = b.height, x.top = P,
x.width = v.width, x.height = b.height - P, b.applyCss(), y.applyCss(), x.applyCss(),
window.viewerMode) return k.width = x.width, k.height = x.height, E.width = x.width,
E.height = x.height, k.applyCss(), E.applyCss(), f();
if (!(w.isOpen && x.height < O.height + A)) {
if (lt) {
if (k.isOpen) {
if (k.halfSize && (k.height = (x.height + A) / 2), k.height < F.height && (k.height = F.height),
k.y = x.height - k.height, k.y < O.height) {
var t = x.height - O.height;
if (t < F.height) {
k.isOpen = !1, k.$elt.trigger("hide.layout.toggle").trigger("hidden.layout.toggle");
continue;
}
k.height = t, k.y = x.height - k.height;
}
} else k.y = x.height - A;
k.width = x.width, _.height = k.y, _.width = x.width, E.top = A, E.height = k.height - A,
E.width = k.width, T.width = R, I.width = R, I.x = (k.width - R) / 2, D.width = E.width;
} else {
if (k.isOpen) {
if (k.halfSize && (k.width = (x.width + A) / 2), k.width < F.width && (k.width = F.width),
k.x = x.width - k.width, k.x < O.width) {
var e = x.width - O.width;
if (e < F.width) {
k.isOpen = !1, k.$elt.trigger("hide.layout.toggle").trigger("hidden.layout.toggle");
continue;
}
k.width = e, k.x = x.width - k.width;
}
} else k.x = x.width - A;
k.height = x.height, _.width = k.x, _.height = x.height, E.left = A, E.width = k.width - A,
E.height = k.height, T.height = R, I.height = R, I.y = (k.height - R) / 2, D.height = E.height;
}
break;
}
w.isOpen = !1, w.$elt.trigger("hide.layout.toggle").trigger("hidden.layout.toggle");
}
T.$elt.toggleClass("open", w.isOpen), I.$elt.toggleClass("open", k.isOpen), D.$elt.toggleClass("open", k.isOpen),
_.applyCss(), k.applyCss(), E.applyCss(), I.applyCss(), D.applyCss(), T.applyCss(),
m(), N.adjustPosition(), f();
}
var v, b, y, x, w, S, C, _, k, E, T, I, D, N, M, L = {}, A = 32, R = 60, P = 50, O = {
width: 250,
height: 140
}, F = {
width: 330,
height: 160
}, B = 280, j = 320, $ = 200, G = 18, q = 130, H = {
x: -45,
y: -6
}, U = !1, z = [];
d.prototype.applyCss = function() {
void 0 !== this.top && (this.elt.style.top = this.top + "px"), void 0 !== this.left && (this.elt.style.left = this.left + "px"),
void 0 !== this.bottom && (this.elt.style.bottom = this.bottom + "px"), void 0 !== this.right && (this.elt.style.right = this.right + "px"),
void 0 === this.x && void 0 === this.y || (this.x = this.x || 0, this.y = this.y || 0,
this.elt.style["-webkit-transform"] = "translate(" + this.x + "px, " + this.y + "px)",
this.elt.style["-ms-transform"] = "translate(" + this.x + "px, " + this.y + "px)",
this.elt.style.transform = "translate(" + this.x + "px, " + this.y + "px)"), U && this.width < this.oldWidth ? z.push(e.bind(function() {
this.elt.style.width = this.width + "px";
}, this)) : void 0 !== this.width && (this.elt.style.width = this.width + "px"),
this.oldWidth = this.width, U && this.height < this.oldHeight ? z.push(e.bind(function() {
this.elt.style.height = this.height + "px";
}, this)) : void 0 !== this.height && (this.elt.style.height = this.height + "px"),
this.oldHeight = this.height, clearTimeout(M), U && (M = setTimeout(p, 800));
}, d.prototype.createToggler = function(i) {
var r, o = 0;
this.toggle = function(a) {
a !== this.isOpen && (this.isOpen = e.isBoolean(a) ? a : !this.isOpen, this.isOpen ? (this.isShown = !0,
this.$elt.addClass("panel-open").trigger("show.layout.toggle"), i && (r = t(n.createBackdrop(b.elt)).on("click.backdrop", e.bind(function() {
this.toggle(!1);
}, this)), this.$elt.addClass("bring-to-front")), z.push(e.bind(function() {
0 === --o && this.isOpen && this.$elt.trigger("shown.layout.toggle");
}, this))) : (this.$elt.trigger("hide.layout.toggle"), r && (r.off("click.backdrop"),
r[0].removeBackdrop(), r = void 0), z.push(e.bind(function() {
0 === --o && (this.isOpen || (this.isShown = !1, this.$elt.removeClass("panel-open bring-to-front").trigger("hidden.layout.toggle")));
}, this))), o++, c(), g());
};
}, d.prototype.initHammer = function(t) {
this.hammer = l(this.elt, {
drag: !!t,
drag_max_touches: 0,
gesture: !1,
hold: !1,
release: !1,
swipe: !t,
tap: !1,
touch: !1,
transform: !1
});
};
var V, W, X, Q, Y, K, J, Z, tt = [ {
screenWidth: 0,
maxWidth: 600 * r.maxWidthRatio
}, {
screenWidth: 1e3,
maxWidth: 700 * r.maxWidthRatio
}, {
screenWidth: 1200,
maxWidth: 800 * r.maxWidthRatio
}, {
screenWidth: 1400,
maxWidth: 900 * r.maxWidthRatio
} ], et = tt.slice(0).reverse(), nt = [], it = [ 80, 80, 160, 160, 80, 40 ].map(function(t) {
return t + 18;
}), rt = 86, ot = 40, at = 100, st = 88, lt = "vertical" == r.layoutOrientation;
return L.init = function() {
function n(t, e) {
e = e || 0, c += [ "@media (min-width: " + e + "px) {", "#wmd-input {", " font-size: " + t + "px;", "}", "#preview-contents {", " font-size: " + t + "px;", "}", "}" ].join("\n");
}
var i = 0;
if (t(document.body).on("show.bs.modal", ".modal", function() {
S.toggle(!1), C.toggle(!1), i++;
}).on("hidden.bs.modal", ".modal", function() {
i--;
}), function(t) {
t.position = "absolute", t.top = 0, t.left = 0, t.bottom = 0, t.right = 0, t.overflow = "hidden";
}(document.body.style), document.documentElement.style.overflow = "hidden", b = new d(".layout-wrapper-l1"),
y = new d(".layout-wrapper-l2"), x = new d(".layout-wrapper-l3"), w = new d(".navbar"),
S = new d(".menu-panel"), C = new d(".document-panel"), _ = new d("#wmd-input"),
k = new d(".preview-panel"), E = new d(".preview-container"), T = new d(".layout-toggler-navbar"),
I = new d(".layout-toggler-preview"), D = new d(".layout-resizer-preview"), N = new d(".extension-preview-buttons"),
V = _.elt.querySelector(".editor-content"), W = document.getElementById("preview-contents"),
X = _.elt.querySelector(".editor-margin"), Q = w.elt.querySelector(".navbar-inner"),
Y = w.elt.querySelector(".buttons-dropdown .dropdown-menu"), K = w.$elt.find(".buttons-dropdown"),
J = w.elt.querySelector(".title-container"), Z = w.$elt.find(".file-title-navbar, .input-file-title"),
t([ b.elt, y.elt, x.elt ]).on("scroll", function() {
this.scrollLeft = 0;
}), e.each(w.elt.querySelectorAll(".right-buttons"), function(t) {
nt.push({
elt: t,
width: it.shift()
});
}), e.each(w.elt.querySelectorAll(".left-buttons"), function(t) {
nt.push({
elt: t,
width: it.shift()
});
}), b.$elt.toggleClass("layout-vertical", lt), b.$elt.on("webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend", p),
w.isOpen = !0, w.createToggler(), T.$elt.click(e.bind(w.toggle, w)), k.isOpen = !0,
k.createToggler(), k.halfSize = !0, I.$elt.click(e.bind(k.toggle, k)), k.$elt.on("show.layout.toggle", function() {
e.defer(function() {
k.isOpen || (window.location.href = "viewer");
});
}), C.isOpen = !1, C.createToggler(!0), C.$elt.find(".toggle-button").click(e.bind(C.toggle, C)),
C.$elt.on("click", "a[data-toggle!=collapse]", e.bind(C.toggle, C, !1)), C.$elt.on("hidden.layout.toggle", function() {
m(), i || _.elt.focus();
}), S.isOpen = !1, !window.viewerMode) {
S.createToggler(!0), S.$elt.find(".toggle-button").click(e.bind(S.toggle, S)), S.$elt.on("click", "a[data-toggle!=collapse]", e.bind(S.toggle, S, !1)),
S.$elt.on("show.bs.collapse hidden.layout.toggle", function() {
S.$elt.find(".in").collapse("hide");
}), S.$elt.on("hidden.layout.toggle", function() {
i || _.elt.focus();
}), D.initHammer(!0);
var o;
D.hammer.on("dragstart", function() {
o = {
width: k.width,
height: k.height
};
}).on("drag", function(t) {
lt ? k.height = o.height - t.gesture.deltaY : k.width = o.width - t.gesture.deltaX,
t.gesture.preventDefault(), k.halfSize = !1, g();
});
}
N.initHammer(!0), N.adjustPosition = function() {
if (N.isDragged) {
var t = -v.width + N.elt.offsetWidth, e = -v.height + N.elt.offsetHeight;
this.x < t && (this.x = t), this.y < e && (this.y = e), this.x > 0 && (this.x = 0),
this.y > 0 && (this.y = 0), this.applyCss();
}
};
var l;
N.hammer.on("dragstart", function() {
N.isOpen = !0, N.isDragged = !0, N.$elt.removeClass("closed animate"), y.$elt.addClass("dragging"),
l = {
x: N.x,
y: N.y
};
}).on("drag", function(t) {
N.x = l.x + t.gesture.deltaX, N.y = l.y + t.gesture.deltaY, N.adjustPosition(),
t.gesture.preventDefault();
}).on("dragend", function() {
y.$elt.removeClass("dragging"), N.$elt.find(".btn-group").toggleClass("dropup", v.height / 2 > -N.y);
}), s.stopCallback = function() {
return S.isOpen || C.isOpen || i;
}, t(window).resize(g).focus(function() {
S.isOpen || C.isOpen || i || _.elt.focus();
});
var c = "";
n(16 * r.fontSizeRatio), n(17 * r.fontSizeRatio, 600), n(18 * r.fontSizeRatio, 1200);
var u = a("style", {
type: "text/css"
});
u.innerHTML = c, document.head.appendChild(u), g();
}, o.addListener("onReady", function() {
function n() {
clearTimeout(r), N.isDragged || (N.isOpen = !0, N.x = H.x, N.applyCss(), N.$elt.removeClass("closed"));
}
function i() {
clearTimeout(r), r = setTimeout(function() {
N.isDragged || o || (N.isOpen = !1, N.x = H.x + N.elt.offsetWidth + G, N.applyCss(),
N.$elt.addClass("closed"));
}, 3e3);
}
N.x = H.x, N.y = H.y, N.applyCss(), setTimeout(function() {
N.$elt.addClass("animate");
}, 0);
var r, o = !1;
n(), i(), N.$elt.hover(n, i).on("show.bs.dropdown", function() {
o = !0;
}).on("hidden.bs.dropdown", function() {
o = !1, i();
}), e.each(N.elt.querySelectorAll(".btn-group"), function(e) {
var n = t(e);
n.on("shown.bs.dropdown", function() {
n.find(".dropdown-menu").css({
right: -N.elt.offsetWidth + n.width() + n.position().left
});
var t = -N.y - q;
v.height / 2 > -N.y && (t = v.height + N.y - N.elt.offsetHeight - q), n.find(".markdown-syntax, .table-of-contents").css({
maxHeight: t
});
}).addClass("dropup");
});
}), o.addListener("onExtensionButtonResize", function() {
N.isDragged ? N.adjustPosition() : N.isOpen || (N.$elt.removeClass("animate"), N.x = H.x + N.elt.offsetWidth + G,
N.applyCss(), setTimeout(function() {
N.$elt.addClass("animate");
}, 0));
}), o.onLayoutCreated(L), L;
}), define("text!html/bodyEditor.html", [], function() {
return '
Careful:\n You\'re using the public CouchDB instance.\n Anybody can open, edit and delete your files there! To setup your own CouchDB instance click\n here.\n
\n\n
\n
\n \n\n
\n \n Multiple IDs can be provided (space separated)\n
The following documents will be\n removed from CouchDB:
\n\n \n
\n \n
\n
\n
\n\n\n
\n
\n
\n\n
\n \n
Save on CouchDB
\n
\n
\n
Careful:\n You\'re using the public CouchDB instance.\n Anybody can open, edit and delete your files there! To setup your own CouchDB instance click\n here.\n
\n\n
\n This will save "" to CouchDB and keep it synchronized.\n
\n
\n
Tip: You can use a\n YAML front matter to specify tags for your document.
\n
Alternatively, you can place comma separated tags in square brackets at the beginning of the document title.
\n
\n
\n \n
\n
\n
\n\n\n
\n\t
\n\t\t
\n\n\t\t\t
\n\t\t\t\t\n\t\t\t\t
Synchronization
\n\t\t\t
\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t"" is synchronized with the\n\t\t\t\t\tfollowing location(s):\n\t\t\t\t
\n\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\t
Note: Removing a synchronized location will not delete any\n\t\t\t\t\tfile.
\n\t\t\t\t
\n\t\t\t
\n\t\t\t\n\t\t
\n\t
\n
\n\n\n
\n\t
\n\t\t
\n\n\t\t\t
\n\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\tPublish on \n\t\t\t\t
\n\t\t\t
\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t Host must be accessible publicly,\n\t\t\t\t\t\t\t\tunless you\'re hosting your own StackEdit instance.\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t File path is composed of both\n\t\t\t\t\t\t\t\tfolder and filename. \n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tJetpack plugin is required for\n\t\t\t\t\t\t\t\tself-hosted sites.\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t File path is composed of both\n\t\t\t\t\t\t\t\tfolder and filename. \n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t If no file ID is supplied, a new file\n\t\t\t\t\t\t\t\twill be created in your Google Drive root folder. You can move\n\t\t\t\t\t\t\t\tthe file afterwards within Google Drive.\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t If no file name is supplied, the\n\t\t\t\t\t\t\t\tdocument title will be used.\n\t\t\t\t\t\t
Tip: You can use a\n YAML front matter to specify the title of your page.
\n
Interpreted variables:title.
\n\t\t\t\t
\n\t\t\t\t
\n
About URL: For newly created page , Blogger API will append a generated number to the url like about-me-1234.html, if you deeply care about your URL naming, you should first create the page on Blogger and then update them with StackEdit specifying the pageId when publishing.\n
\n
About page visibility: Blogger API does not respect published status for pages.When publishing the page to Blogger, the page will be live but not added to the page listing. You should arrange the page listing from Blogger dashboard.\n
\n\t\t\t\t
\n\t\t\t
\n\t\t\t\n\t\t
\n\t
\n
\n\n\n
\n\t
\n\t\t
\n\n\t\t\t
\n\t\t\t\t\n\t\t\t\t
Publication
\n\t\t\t
\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t"" is published on the following\n\t\t\t\t\tlocation(s):\n\t\t\t\t
\n\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\t
Note: Removing a publish location will not delete the actual publication.
\n\t\t\t\t
\n\t\t\t
\n\t\t\t\n\t\t
\n\t
\n
\n\n\n
\n\t
\n\t\t
\n\n\t\t\t
\n\t\t\t\t\n\t\t\t\t
Sharing
\n\t\t\t
\n\t\t\t
\n
Collaborate on "" using the following link(s):
\n \t
No sharing link yet!\n \t
\n \n \t
\n
Note: To collaborate on this document, just save it on CouchDB.\n To collaborate via Google Drive or Dropbox, you have to share the file manually from Google Drive/Dropbox websites.
\n \t
\n \n
Share a read-only version of "" using the following link(s):
\n \t
No sharing link yet!\n \t
\n \n \t
\n
Note: To share a read-only version of this document, just publish it as a Gist in\n Markdown format.
\n \t
\n \t
\n \t\t
Tip: You can open any markdown URL within StackEdit Viewer using viewer#!url=.
\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tPlease sign in first with Google. Once linked with your Google accounts, changing account is not possible unless you reset the application.\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n \n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t Existing authorization has to be revoked in\n\t\t\t\t\t\t\t\t\t\tGoogle Dashboard\n\t\t\t\t\t\t\t\t\t\tfor this change to take effect.\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t If unchecked, access will be restricted to folder\n\t\t\t\t\t\t\t\t\t\t/Applications/StackEdit for existing files.\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t Existing authorization has to be revoked in\n\t\t\t\t\t\t\t\t\t\tGitHub settings\n\t\t\t\t\t\t\t\t\t\tfor this change to take effect.\n\t\t\t\t\t\t\t\t\t
');
n.find("a").click(_), e.insertBefore(n[0], e.firstChild), j = j.add(n);
});
});
}, 3e3);
return c.addListener("onOfflineChanged", $), c.addListener("onReady", function() {
function n(t) {
if (t = t || "default", r != t) {
var e = "less!themes/" + t;
window.baseDir.indexOf("-min") !== -1 && (e = "css!themes/" + t), requirejs.undef(e),
require([ e ]), r = t;
}
}
t(document.body).on("shown.bs.modal", ".modal", function() {
var e = t(this);
setTimeout(function() {
e.find(".btn:first").focus(), e.find("button:first").focus(), e.find("input:enabled:visible:first").focus();
}, 50);
}).on("hidden.bs.modal", ".modal", function() {
i.focus(), n(window.theme);
}).on("keypress", ".modal", function(e) {
13 != e.which || t(e.target).is("textarea") || t(this).find(".modal-footer a:last").click();
}), t(".action-insert-link").click(function(e) {
var n = a.getInputTextValue(t("#input-insert-link"), e);
void 0 !== n && (T.insertLinkCallback(n), T.insertLinkCallback = void 0);
}), t(".action-insert-image").click(function(e) {
var n = a.getInputTextValue(t("#input-insert-image"), e);
void 0 !== n && (T.insertLinkCallback(n), T.insertLinkCallback = void 0);
}), t(".modal-insert-link, .modal-insert-image").on("hidden.bs.modal", function() {
void 0 !== T.insertLinkCallback && (T.insertLinkCallback(null), T.insertLinkCallback = void 0);
}), t(".action-load-settings").click(function() {
x();
}), t(".action-apply-settings").click(function(t) {
w(t), t.isPropagationStopped() || window.location.reload();
}), t(".action-add-google-drive-account").click(function() {
3 !== l.gdriveMultiAccount && (l.gdriveMultiAccount++, s.settings = JSON.stringify(l),
window.location.reload());
});
var r = window.theme;
R = t("#input-settings-theme"), R.on("change", function() {
n(this.value);
}), t(".action-import-docs-settings").click(function() {
t("#input-file-import-docs-settings").click();
});
var u;
if (t("#input-file-import-docs-settings").change(function(n) {
var i = (n.dataTransfer || n.target).files;
t(".modal-settings").modal("hide"), e.each(i, function(e) {
var n = new FileReader();
n.onload = function(e) {
return function(n) {
try {
u = JSON.parse(n.target.result);
var i = parseInt(u.version.match(/^v(\d+)$/)[1], 10), r = parseInt(s.version.match(/^v(\d+)$/)[1], 10);
i > r ? c.onError("Incompatible version. Please upgrade StackEdit.") : t(".modal-import-docs-settings").modal("show");
} catch (o) {
c.onError("Wrong format: " + e.name);
}
t("#input-file-import-docs-settings").val("");
};
}(e), n.readAsText(e);
});
}), t(".action-import-docs-settings-confirm").click(function() {
s.clear();
var t = /^file\.|^folder\.|^publish\.|^settings$|^sync\.|^google\.|^author\.|^themeV4$|^version$/;
e.each(u, function(e, n) {
t.test(n) && (s[n] = e);
}), window.location.reload();
}), t(".action-export-docs-settings").click(function() {
a.saveAs(JSON.stringify(s), "StackEdit local storage.json");
}), t(".action-default-settings").click(function() {
s.removeItem("settings"), s.removeItem("theme"), l.dropboxFullAccess || s.removeItem("dropbox.lastChangeId"),
window.location.reload();
}), t(".action-app-reset").click(function() {
s.clear(), window.location.reload();
}), t(".action-reset-input").click(function() {
a.resetModalInputs();
}), a.createTooltip(".tooltip-lazy-rendering", "Disable preview rendering while typing in order to offload CPU. Refresh preview after 500 ms of inactivity."),
a.createTooltip(".tooltip-default-content", [ "Thanks for supporting StackEdit by adding a backlink in your documents!
", 'NOTE: Backlinks in Stack Exchange Q/A are not welcome.' ].join("")),
a.createTooltip(".tooltip-template", h), a.createTooltip(".tooltip-pdf-options", f),
t("div.dropdown-menu").click(function(t) {
t.stopPropagation();
}), t(".modal-non-unique").modal({
backdrop: "static",
keyboard: !1,
show: !1
}), e.each(document.querySelectorAll("img"), function(e) {
var n = t(e), i = n.data("stackeditSrc");
i && n.attr("src", window.baseDir + "/img/" + i);
}), window.viewerMode === !1) {
var d = e.reduce(o.THEME_LIST, function(t, e, n) {
return t + '";
}, "");
document.getElementById("input-settings-theme").innerHTML = d;
}
t(".modal-header").append(' Try StackEdit 5!'),
$();
}), T;
}), define("text!WELCOME.md", [], function() {
return 'Welcome to StackEdit!\n===================\n\n\nHey! I\'m your first Markdown document in **StackEdit**[^stackedit]. Don\'t delete me, I\'m very helpful! I can be recovered anyway in the **Utils** tab of the **Settings** dialog.\n\n----------\n\n\nDocuments\n-------------\n\nStackEdit stores your documents in your browser, which means all your documents are automatically saved locally and are accessible **offline!**\n\n> **Note:**\n\n> - StackEdit is accessible offline after the application has been loaded for the first time.\n> - Your local documents are not shared between different browsers or computers.\n> - Clearing your browser\'s data may **delete all your local documents!** Make sure your documents are synchronized with **Google Drive** or **Dropbox** (check out the [ Synchronization](#synchronization) section).\n\n#### Create a document\n\nThe document panel is accessible using the button in the navigation bar. You can create a new document by clicking **New document** in the document panel.\n\n#### Switch to another document\n\nAll your local documents are listed in the document panel. You can switch from one to another by clicking a document in the list or you can toggle documents using Ctrl+[ and Ctrl+].\n\n#### Rename a document\n\nYou can rename the current document by clicking the document title in the navigation bar.\n\n#### Delete a document\n\nYou can delete the current document by clicking **Delete document** in the document panel.\n\n#### Export a document\n\nYou can save the current document to a file by clicking **Export to disk** from the menu panel.\n\n> **Tip:** Check out the [ Publish a document](#publish-a-document) section for a description of the different output formats.\n\n\n----------\n\n\nSynchronization\n-------------------\n\nStackEdit can be combined with **Google Drive** and **Dropbox** to have your documents saved in the *Cloud*. The synchronization mechanism takes care of uploading your modifications or downloading the latest version of your documents.\n\n> **Note:**\n\n> - Full access to **Google Drive** or **Dropbox** is required to be able to import any document in StackEdit. Permission restrictions can be configured in the settings.\n> - Imported documents are downloaded in your browser and are not transmitted to a server.\n> - If you experience problems saving your documents on Google Drive, check and optionally disable browser extensions, such as Disconnect.\n\n#### Open a document\n\nYou can open a document from **Google Drive** or the **Dropbox** by opening the **Synchronize** sub-menu and by clicking **Open from...**. Once opened, any modification in your document will be automatically synchronized with the file in your **Google Drive** / **Dropbox** account.\n\n#### Save a document\n\nYou can save any document by opening the **Synchronize** sub-menu and by clicking **Save on...**. Even if your document is already synchronized with **Google Drive** or **Dropbox**, you can export it to a another location. StackEdit can synchronize one document with multiple locations and accounts.\n\n#### Synchronize a document\n\nOnce your document is linked to a **Google Drive** or a **Dropbox** file, StackEdit will periodically (every 3 minutes) synchronize it by downloading/uploading any modification. A merge will be performed if necessary and conflicts will be detected.\n\nIf you just have modified your document and you want to force the synchronization, click the button in the navigation bar.\n\n> **Note:** The button is disabled when you have no document to synchronize.\n\n#### Manage document synchronization\n\nSince one document can be synchronized with multiple locations, you can list and manage synchronized locations by clicking **Manage synchronization** in the **Synchronize** sub-menu. This will let you remove synchronization locations that are associated to your document.\n\n> **Note:** If you delete the file from **Google Drive** or from **Dropbox**, the document will no longer be synchronized with that location.\n\n----------\n\n\nPublication\n-------------\n\nOnce you are happy with your document, you can publish it on different websites directly from StackEdit. As for now, StackEdit can publish on **Blogger**, **Dropbox**, **Gist**, **GitHub**, **Google Drive**, **Tumblr**, **WordPress** and on any SSH server.\n\n#### Publish a document\n\nYou can publish your document by opening the **Publish** sub-menu and by choosing a website. In the dialog box, you can choose the publication format:\n\n- Markdown, to publish the Markdown text on a website that can interpret it (**GitHub** for instance),\n- HTML, to publish the document converted into HTML (on a blog for example),\n- Template, to have a full control of the output.\n\n> **Note:** The default template is a simple webpage wrapping your document in HTML format. You can customize it in the **Advanced** tab of the **Settings** dialog.\n\n#### Update a publication\n\nAfter publishing, StackEdit will keep your document linked to that publication which makes it easy for you to update it. Once you have modified your document and you want to update your publication, click on the button in the navigation bar.\n\n> **Note:** The button is disabled when your document has not been published yet.\n\n#### Manage document publication\n\nSince one document can be published on multiple locations, you can list and manage publish locations by clicking **Manage publication** in the menu panel. This will let you remove publication locations that are associated to your document.\n\n> **Note:** If the file has been removed from the website or the blog, the document will no longer be published on that location.\n\n----------\n\n\nMarkdown Extra\n--------------------\n\nStackEdit supports **Markdown Extra**, which extends **Markdown** syntax with some nice features.\n\n> **Tip:** You can disable any **Markdown Extra** feature in the **Extensions** tab of the **Settings** dialog.\n\n> **Note:** You can find more information about **Markdown** syntax [here][2] and **Markdown Extra** extension [here][3].\n\n\n### Tables\n\n**Markdown Extra** has a special syntax for tables:\n\nItem | Value\n-------- | ---\nComputer | $1600\nPhone | $12\nPipe | $1\n\nYou can specify column alignment with one or two colons:\n\n| Item | Value | Qty |\n| :------- | ----: | :---: |\n| Computer | $1600 | 5 |\n| Phone | $12 | 12 |\n| Pipe | $1 | 234 |\n\n\n### Definition Lists\n\n**Markdown Extra** has a special syntax for definition lists too:\n\nTerm 1\nTerm 2\n: Definition A\n: Definition B\n\nTerm 3\n\n: Definition C\n\n: Definition D\n\n\t> part of definition D\n\n\n### Fenced code blocks\n\nGitHub\'s fenced code blocks are also supported with **Highlight.js** syntax highlighting:\n\n```\n// Foo\nvar bar = 0;\n```\n\n> **Tip:** To use **Prettify** instead of **Highlight.js**, just configure the **Markdown Extra** extension in the **Settings** dialog.\n\n> **Note:** You can find more information:\n\n> - about **Prettify** syntax highlighting [here][5],\n> - about **Highlight.js** syntax highlighting [here][6].\n\n\n### Footnotes\n\nYou can create footnotes like this[^footnote].\n\n [^footnote]: Here is the *text* of the **footnote**.\n\n\n### SmartyPants\n\nSmartyPants converts ASCII punctuation characters into "smart" typographic punctuation HTML entities. For example:\n\n| | ASCII | HTML |\n ----------------- | ---------------------------- | ------------------\n| Single backticks | `\'Isn\'t this fun?\'` | \'Isn\'t this fun?\' |\n| Quotes | `"Isn\'t this fun?"` | "Isn\'t this fun?" |\n| Dashes | `-- is en-dash, --- is em-dash` | -- is en-dash, --- is em-dash |\n\n\n### Table of contents\n\nYou can insert a table of contents using the marker `[TOC]`:\n\n[TOC]\n\n\n### MathJax\n\nYou can render *LaTeX* mathematical expressions using **MathJax**, as on [math.stackexchange.com][1]:\n\nThe *Gamma function* satisfying $\\Gamma(n) = (n-1)!\\quad\\forall n\\in\\mathbb N$ is via the Euler integral\n\n$$\n\\Gamma(z) = \\int_0^\\infty t^{z-1}e^{-t}dt\\,.\n$$\n\n> **Tip:** To make sure mathematical expressions are rendered properly on your website, include **MathJax** into your template:\n\n```\n\n```\n\n> **Note:** You can find more information about **LaTeX** mathematical expressions [here][4].\n\n\n### UML diagrams\n\nYou can also render sequence diagrams like this:\n\n```sequence\nAlice->Bob: Hello Bob, how are you?\nNote right of Bob: Bob thinks\nBob-->Alice: I am good thanks!\n```\n\nAnd flow charts like this:\n\n```flow\nst=>start: Start\ne=>end\nop=>operation: My Operation\ncond=>condition: Yes or No?\n\nst->op->cond\ncond(yes)->e\ncond(no)->op\n```\n\n> **Note:** You can find more information:\n\n> - about **Sequence diagrams** syntax [here][7],\n> - about **Flow charts** syntax [here][8].\n\n### Support StackEdit\n\n[](https://monetizejs.com/authorize?client_id=ESTHdCYOi18iLhhO&summary=true)\n\n [^stackedit]: [StackEdit](https://stackedit.io/) is a full-featured, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites.\n\n\n [1]: http://math.stackexchange.com/\n [2]: http://daringfireball.net/projects/markdown/syntax "Markdown"\n [3]: https://github.com/jmcmanus/pagedown-extra "Pagedown Extra"\n [4]: http://meta.math.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference\n [5]: https://code.google.com/p/google-code-prettify/\n [6]: http://highlightjs.org/\n [7]: http://bramp.github.io/js-sequence-diagrams/\n [8]: http://adrai.github.io/flowchart.js/\n';
}), define("fileMgr", [ "jquery", "underscore", "constants", "core", "utils", "storage", "settings", "eventMgr", "fileSystem", "classes/FileDescriptor", "text!WELCOME.md" ], function(t, e, n, i, r, o, a, s, l, c, u) {
var d = {};
return d.currentFile = void 0, d.selectFile = function(r) {
if (r = r || d.currentFile, void 0 === r) {
var o = e.size(l);
r = 0 === o ? d.createFile(n.WELCOME_DOCUMENT_TITLE, u) : e.max(l, function(t) {
return t.selectTime || 0;
});
}
d.currentFile !== r && (d.currentFile = r, r.selectTime = new Date().getTime(),
s.onFileSelected(r), t(".action-edit-document").toggleClass("hide", r.fileIndex != n.TEMPORARY_FILE_INDEX)),
i.initEditor(r);
}, d.createFile = function(t, i, u, d, p) {
if (i = void 0 !== i ? i : a.defaultContent, !t) {
t = n.DEFAULT_FILE_TITLE;
for (var h = 2, f = function(e) {
return e.title == t;
}; e.some(l, f); ) t = n.DEFAULT_FILE_TITLE + h++;
}
var m = n.TEMPORARY_FILE_INDEX;
if (!p) do m = "file." + r.id(); while (e.has(l, m));
d = d || {};
var g = e.reduce(d, function(t, e) {
return r.storeAttributes(e), t + e.syncIndex + ";";
}, ";");
o[m + ".title"] = t, o[m + ".content"] = i, o[m + ".sync"] = g, o[m + ".publish"] = ";";
var v = new c(m, t, d);
return u && (v.discussionListJSON = u), p || (r.appendIndexToArray("file.list", m),
l[m] = v, s.onFileCreated(v)), v;
}, d.deleteFile = function(t) {
t = t || d.currentFile, t.folder && (t.folder.removeFile(t), s.onFoldersChanged()),
r.removeIndexFromArray("file.list", t.fileIndex), delete l[t.fileIndex], d.currentFile === t && (d.currentFile = void 0,
d.selectFile()), s.onFileDeleted(t);
}, d.getFileFromSyncIndex = function(t) {
return e.find(l, function(n) {
return e.has(n.syncLocations, t);
});
}, d.getFileFromPublishIndex = function(t) {
return e.find(l, function(n) {
return e.has(n.publishLocations, t);
});
}, s.addListener("onReady", function() {
function e() {
if (a) {
o.addClass("hide"), r.removeClass("hide");
var e = t.trim(o.val()), n = d.currentFile;
e && e != n.title && (n.title = e, s.onTitleChanged(n)), o.val(n.title), i.focus(),
a = !1;
}
}
var i = t("#wmd-input");
d.selectFile();
var r = t(".file-title-navbar"), o = t(".input-file-title");
t(".action-create-file").click(function() {
setTimeout(function() {
var t = d.createFile();
d.selectFile(t), r.click();
}, 400);
}), t(".action-remove-file-confirm").click(function() {
t(".modal-remove-file-confirm").modal("show");
}), t(".action-remove-file").click(function() {
d.deleteFile();
});
var a;
r.click(function() {
if (window.viewerMode !== !0) {
r.addClass("hide");
var t = o.removeClass("hide");
a = !0, setTimeout(function() {
t.focus().get(0).select();
}, 10);
}
}), o.blur(function() {
setTimeout(function() {
e();
}, 0);
}).keypress(function(t) {
13 == t.keyCode && (e(), t.preventDefault()), 27 == t.keyCode && (o.val(""), e());
}), t(".action-open-stackedit").click(function() {
window.location.href = "editor";
}), t(".action-edit-document").click(function() {
var t = i.val(), e = d.currentFile.title, n = d.createFile(e, t);
d.selectFile(n), window.location.href = "editor";
}), t(".action-welcome-file").click(function() {
var t = d.createFile(n.WELCOME_DOCUMENT_TITLE, u);
d.selectFile(t);
});
}), s.onFileMgrCreated(d), d;
}), define("classes/Provider", [ "underscore", "utils", "settings", "eventMgr", "fileMgr", "editor", "diff_match_patch_uncompressed", "jsondiffpatch" ], function(t, e, n, i, r, o, a, s) {
function l(t, e) {
this.providerId = t, this.providerName = e, this.isPublishEnabled = !0;
}
l.prototype.parseDiscussionList = function(e) {
try {
var n = JSON.parse(e);
return t.each(n, function(e, n) {
if (e.discussionIndex != n || !t.isNumber(e.selectionStart) || !t.isNumber(e.selectionEnd)) throw "invalid";
e.commentList && e.commentList.forEach(function(e) {
if (e.author && !t.isString(e.author) || !t.isString(e.content)) throw "invalid";
});
}), n;
} catch (i) {}
}, l.prototype.serializeContent = function(t, e) {
return e.length > 2 ? t + "" : t;
}, l.prototype.parseContent = function(t) {
var e, n = "{}", i = /$/.exec(t);
return i && (e = this.parseDiscussionList(i[1])) && (t = t.substring(0, i.index),
n = i[1]), {
content: t,
discussionList: e || {},
discussionListJSON: n
};
};
var c = new a();
c.Match_Threshold = 0, c.Patch_DeleteThreshold = 0;
var u = s.create({
objectHash: function(t) {
return JSON.stringify(t);
},
textDiff: {
minLength: 9999999
}
}), d = "merge" == n.conflictMode;
return l.prototype.syncMerge = function(n, a, s, l, p, h) {
function f(t) {
function e() {
(i[1] || r[1]) && (i[1] && r[1] ? (i[1] = "\u29f8\u29f8" + i[1] + "\u29f8\u29f8",
r[1] += "\u29f8\u29f8", n.push(i), n.push(r)) : n.push([ 0, i[1] + r[1] ]), i = [ -1, "" ],
r = [ 1, "" ]);
}
var n = [], i = [ -1, "" ], r = [ 1, "" ], o = 20;
return t.forEach(function(a, s) {
function l() {
return 0 === s || s === t.length - 1;
}
var c = a[0], u = a[1];
if (0 === c) if (l() || u.length > o) {
if (i[1] || r[1]) {
var d = /\s/.exec(u);
if (d) {
var p = d.index, h = u.substring(0, p);
u = u.substring(p), i[1] += h, r[1] += h;
}
}
if (u) {
for (var f = u.length; f && /\S/.test(u[f - 1]); ) f--;
var m = u.substring(f);
u = u.substring(0, f), l() || u.length > o ? (e(), n.push([ 0, u ])) : (i[1] += u,
r[1] += u), i[1] += m, r[1] += m;
}
} else i[1] += u, r[1] += u; else c === -1 ? i[1] += u : 1 === c && (r[1] += u);
}), i[1] == r[1] ? n.push([ 0, r[1] ]) : e(), n;
}
var m = n.content, g = n.title, v = n.discussionListJSON, b = n.discussionList, y = e.crc32(m), x = e.crc32(g), w = e.crc32(v), S = e.crc32(s), C = e.crc32(l), _ = e.crc32(h), k = a.contentCRC != y, E = a.contentCRC != S, T = m != s && E, I = T && k;
a.titleCRC = a.titleCRC || x;
var D, N, M = a.titleCRC != x, L = a.titleCRC != C, A = g != l && L, R = A && M, P = a.discussionListCRC != w, O = a.discussionListCRC != _, F = v != h && O, B = F && P, j = [], $ = s, G = l, q = p, H = !1, U = !1, z = !1;
if (!d && (I || R || B) || I && void 0 === a.content || R && void 0 === a.title || B && void 0 === a.discussionList) r.createFile(g + " (backup)", m, v),
i.onMessage('Conflict detected on "' + g + '". A backup has been created locally.'); else {
if (I) {
var V = a.content;
D = c.diff_main(V, m), c.diff_cleanupSemantic(D), N = c.patch_make(V, D);
var W = c.patch_apply(N, s);
if ($ = W[0], !W[1].every(t.identity)) {
D = c.diff_main(m, $), D = f(D), $ = "";
var X;
D.forEach(function(t) {
var e = t[0], n = t[1];
0 === e || X ? 0 === e && X && (X.selectionEnd = $.length, j.push(X), X = void 0) : X = {
selectionStart: $.length,
type: "conflict"
}, $ += n;
}), X && (X.selectionEnd = $.length, j.push(X));
}
}
T && (P && (H = !0), O ? U = !0 : (H = !0, q = b)), B && (z = !0), R && (N = c.patch_make(a.title, g),
G = c.patch_apply(N, l)[0]);
}
var Q;
if (T) {
var Y = [];
r.currentFile === n && (Q = {
selectionStart: o.selectionMgr.selectionStart,
selectionEnd: o.selectionMgr.selectionEnd
}, Y.push(Q), n.newDiscussion && Y.push(n.newDiscussion)), H && (Y = Y.concat(t.values(b))),
F |= o.adjustCommentOffsets(m, $, Y);
}
if (U) {
var K = t.values(p);
o.adjustCommentOffsets(s, $, K);
}
if (z) {
var J = JSON.parse(a.discussionList);
D = u.diff(J, b), u.patch(p, D), t.each(p, function(t, e) {
t || delete p[e];
});
}
return j.length && (F = !0, j.forEach(function(n) {
var i;
do i = e.id(); while (t.has(q, i));
n.discussionIndex = i, q[i] = n;
})), A && (n.title = G, i.onTitleChanged(n), i.onMessage('"' + g + '" has been renamed to "' + G + '" on ' + this.providerName + ".")),
(T || F) && o.watcher.noWatch(t.bind(function() {
if (T && (r.currentFile === n && (o.setValueNoWatch($), Q && o.selectionMgr.setSelectionStartEnd(Q.selectionStart, Q.selectionEnd)),
n.content = $, i.onContentChanged(n, $)), F) {
n.discussionList = q;
var e = u.diff(b, q), a = !1;
t.each(e, function(e, r) {
t.isArray(e) ? 1 === e.length ? i.onDiscussionCreated(n, q[r]) : i.onDiscussionRemoved(n, b[r]) : a = !0;
}), a && i.onCommentsChanged(n);
}
o.undoMgr.currentMode = "sync", o.undoMgr.saveState(), i.onMessage('"' + l + '" has been updated from ' + this.providerName + "."),
j.length && i.onMessage('"' + l + '" has conflicts that you have to review.');
}, this)), {
contentCRC: S,
titleCRC: C,
discussionListCRC: _
};
}, l;
}), define("classes/AsyncTask", [ "underscore", "constants", "utils", "eventMgr" ], function(t, e, n, i) {
function r(t) {
this.finished = !1, this.timeout = e.ASYNC_TASK_DEFAULT_TIMEOUT, this.retryCounter = 0,
this.runCallbacks = [], this.successCallbacks = [], this.errorCallbacks = [], this.force = t;
}
function o() {
if (c === !0) return void (l + u.timeout < n.currentTime && u.error(new Error("A timeout occurred.")));
if (void 0 === u) {
if (0 === s.length || !s[0].force && p === !1) return;
u = s.shift(), l = n.currentTime, d === !1 && (d = !0, i.onAsyncRunning(!0));
}
l <= n.currentTime && (c = !0, u.chain());
}
function a(e, n, r) {
try {
t.each(n, function(t) {
t(r);
});
} finally {
e.finished = !0, u === e && (u = void 0, c = !1), 0 === s.length ? (d = !1, i.onAsyncRunning(!1)) : o();
}
}
var s = [];
r.prototype.onRun = function(t) {
this.runCallbacks.push(t);
}, r.prototype.onSuccess = function(t) {
this.successCallbacks.push(t);
}, r.prototype.onError = function(t) {
this.errorCallbacks.push(t);
};
var l = 0;
r.prototype.chain = function(t) {
if (l = n.currentTime, n.logStackTrace(), this.finished !== !0) {
if (void 0 === this.queue && (this.queue = this.runCallbacks.slice()), void 0 !== t) return void t();
if (0 === this.queue.length) return void a(this, this.successCallbacks);
var e = this.queue.shift();
e();
}
}, r.prototype.error = function(t) {
if (n.logStackTrace(), this.finished !== !0) throw t = t || new Error("Unknown error"),
t.message && i.onError(t), a(this, this.errorCallbacks, t), t;
};
var c = !1;
r.prototype.retry = function(t, e) {
if (this.finished !== !0) {
if (e = e || 5, this.queue = void 0, this.retryCounter >= e) return void this.error(t);
var i = 1e3 * Math.pow(2, this.retryCounter++);
l = n.currentTime + i, c = !1, o();
}
}, r.prototype.enqueue = function() {
s.push(this), o();
};
var u, d = !1, p = !1;
return i.addListener("onUserActive", function() {
p = !0;
}), i.addListener("onPeriodicRun", o), r;
}), define("helpers/dropboxHelper", [ "jquery", "underscore", "constants", "core", "utils", "storage", "logger", "settings", "eventMgr", "classes/AsyncTask" ], function(t, e, n, i, r, o, a, s, l, c) {
function u(e) {
e.onRun(function() {
return v === !0 ? (f = void 0, e.error(new Error("Operation not available in offline mode.|stopPublish"))) : void 0 !== f ? e.chain() : void t.ajax({
url: "libs/dropbox.min.js",
dataType: "script",
timeout: n.AJAX_TIMEOUT
}).done(function() {
f = new Dropbox.Client({
key: s.dropboxFullAccess === !0 ? n.DROPBOX_APP_KEY : n.DROPBOX_RESTRICTED_APP_KEY,
secret: s.dropboxFullAccess === !0 ? n.DROPBOX_APP_SECRET : n.DROPBOX_RESTRICTED_APP_SECRET
}), f.authDriver(new Dropbox.AuthDriver.Popup({
receiverUrl: n.BASE_URL + "html/dropbox-oauth-receiver.html",
rememberUser: !0
})), e.chain();
}).fail(function(t) {
var n = {
status: t.status,
responseText: t.statusText
};
p(n, e);
});
});
}
function d(t) {
t.onRun(function() {
function e() {
r.redirectConfirm("You are being redirected to Dropbox authorization page.", function() {
t.chain(i);
}, function() {
t.error(new Error("Operation canceled."));
});
}
function i() {
o === !1 ? t.timeout = n.ASYNC_TASK_LONG_TIMEOUT : f.reset(), f.authenticate({
interactive: !o
}, function(n, i) {
return i.isAuthenticated() === !0 ? (m = !0, t.chain()) : o === !0 ? (o = !1, t.chain(e)) : void t.error(new Error("Access to Dropbox account is not authorized."));
});
}
if (m === !0) return t.chain();
var o = !0;
t.chain(i);
});
}
function p(t, n) {
var r = !0;
if (t) if (a.error(t), "string" == typeof t) r = t; else {
if (r = "Dropbox error (" + t.status + ": " + t.responseText + ").", 401 === t.status || 403 === t.status) return m = !1,
r = "Access to Dropbox account is not authorized.", n.retry(new Error(r), 1);
if (400 === t.status && t.responseText.indexOf("oauth_nonce") !== -1) return e.each(e.keys(o), function(t) {
0 === t.indexOf("dropbox-auth") && o.removeItem(t);
}), m = !1, n.retry(new Error(r), 1);
t.status <= 0 && (f = void 0, m = !1, i.setOffline(), r = "|stopPublish");
}
n.error(new Error(r));
}
function h(e) {
e.onRun(function() {
function i() {
r.redirectConfirm("You are being redirected to Dropbox Chooser page.", function() {
e.chain();
}, function() {
e.error(new Error("Operation canceled."));
});
}
return b === !0 ? e.chain() : void t.ajax({
url: "https://www.dropbox.com/static/api/1/dropbox.js",
dataType: "script",
timeout: n.AJAX_TIMEOUT
}).done(function() {
b = !0, e.chain(i);
}).fail(function(t) {
var n = {
status: t.status,
responseText: t.statusText
};
p(n, e);
});
});
}
var f, m = !1, g = {}, v = !1;
l.addListener("onOfflineChanged", function(t) {
v = t;
}), g.upload = function(t, e, n) {
var i, r = new c();
u(r), d(r), r.onRun(function() {
f.writeFile(t, e, function(e, n) {
return e ? (400 === e.status && (e = 'Could not upload document into path "' + t + '".'),
void p(e, r)) : (i = n, r.chain());
});
}), r.onSuccess(function() {
n(void 0, i);
}), r.onError(function(t) {
n(t);
}), r.enqueue();
}, g.checkChanges = function(t, e) {
var n = [], i = t || 0, r = new c();
u(r), d(r), r.onRun(function() {
function t() {
f.pullChanges(i, function(e, o) {
return e ? p(e, r) : (i = o.cursor(), void 0 !== o.changes && (n = n.concat(o.changes)),
void (o.shouldPullAgain ? r.chain(t) : r.chain()));
});
}
r.chain(t);
}), r.onSuccess(function() {
e(void 0, n, i);
}), r.onError(function(t) {
e(t);
}), r.enqueue();
}, g.downloadMetadata = function(t, e) {
var n = [], i = new c();
u(i), d(i), i.onRun(function() {
function e() {
if (0 === t.length) return i.chain();
var r = t[0];
f.stat(r, function(r, o) {
return o ? (n.push(o), t.shift(), i.chain(e)) : void p(r, i);
});
}
i.chain(e);
}), i.onSuccess(function() {
e(void 0, n);
}), i.onError(function(t) {
e(t);
}), i.enqueue();
}, g.downloadContent = function(t, n) {
var i = [], r = new c();
u(r), d(r), r.onRun(function() {
function n() {
if (0 === t.length) return r.chain();
var o = t[0];
i.push(o);
var a;
return o.isFile === !0 ? a = o : void 0 !== o.wasRemoved && (a = o.stat), a ? void f.readFile(a.path, function(i, o) {
return e.isString(o) ? (a.content = o, t.shift(), r.chain(n)) : void p(i, r);
}) : (t.shift(), r.chain(n));
}
r.chain(n);
}), r.onSuccess(function() {
n(void 0, i);
}), r.onError(function(t) {
n(t);
}), r.enqueue();
};
var b = !1;
return g.picker = function(t) {
var e = [], i = new c();
i.timeout = n.ASYNC_TASK_LONG_TIMEOUT, u(i), h(i), i.onRun(function() {
var t = {};
t.multiselect = !0, t.linkType = "direct", t.success = function(t) {
for (var n = 0; n < t.length; n++) {
var r = t[n].link;
r = r.replace(/.*\/view\/[^\/]*/, ""), e.push(decodeURI(r));
}
i.chain();
}, t.cancel = function() {
i.chain();
}, Dropbox.choose(t);
}), i.onSuccess(function() {
t(void 0, e);
}), i.onError(function(e) {
t(e);
}), i.enqueue();
}, g;
}), define("providers/dropboxProvider", [ "underscore", "utils", "storage", "settings", "classes/Provider", "eventMgr", "fileMgr", "helpers/dropboxHelper" ], function(t, e, n, i, r, o, a, s) {
function l(t) {
if (void 0 !== t) return t.match(/^[^\\<>:"\|?\*]+$/) ? 0 !== t.indexOf("/") ? "/" + t : t : void o.onError('"' + t + '" contains invalid characters.');
}
function c(t) {
return "sync." + p + "." + encodeURIComponent(t.toLowerCase());
}
function u(t, n, i, r) {
r = r || "{}";
var o = {};
return o.provider = h, o.path = t, o.version = n, o.contentCRC = e.crc32(i), o.discussionListCRC = e.crc32(r),
o.syncIndex = c(t), f === !0 && (o.content = i, o.discussionList = r), o;
}
function d(e) {
s.downloadMetadata(e, function(e, n) {
e || s.downloadContent(n, function(e, n) {
if (!e) {
var i = [];
t.each(n, function(t) {
var e = h.parseContent(t.content), n = u(t.path, t.versionTag, e.content, e.discussionListJSON), r = {};
r[n.syncIndex] = n;
var o = a.createFile(t.name, e.content, e.discussionListJSON, r);
a.selectFile(o), i.push(o);
}), 0 !== i.length && o.onSyncImportSuccess(i, h);
}
});
});
}
var p = "dropbox", h = new r(p, "Dropbox");
h.defaultPublishFormat = "template", h.getSyncLocationLink = h.getPublishLocationLink = function(t) {
var e = t.path.split("/").map(encodeURIComponent), n = e.pop();
return [ "https://www.dropbox.com/home", e.join("/"), "?select=", n ].join("");
};
var f = "merge" == i.conflictMode;
return h.importFiles = function() {
s.picker(function(e, n) {
if (!e && 0 !== n.length) {
var i = [];
t.each(n, function(t) {
var e = c(t), n = a.getFileFromSyncIndex(e);
return void 0 !== n ? o.onError('"' + n.title + '" is already in your local documents.') : void i.push(t);
}), d(i);
}
});
}, h.exportFile = function(t, n, i, r, d, p) {
var f = e.getInputTextValue("#input-sync-export-dropbox-path", t);
if (f = l(f), void 0 === f) return p(!0);
var m = c(f), g = a.getFileFromSyncIndex(m);
if (void 0 !== g) {
var v = g.title;
return o.onError('File path is already synchronized with "' + v + '".'), p(!0);
}
var b = h.serializeContent(i, r);
s.upload(f, b, function(t, e) {
if (t) return p(t);
var n = u(e.path, e.versionTag, i, r);
p(void 0, n);
});
}, h.syncUp = function(t, e, n, i, r, o, a, l, c) {
if (l.contentCRC == e && l.discussionListCRC == o) return c(void 0, !1);
var u = h.serializeContent(t, r);
s.upload(l.path, u, function(n, a) {
return n ? c(n, !0) : (l.version = a.versionTag, f === !0 && (l.content = t, l.discussionList = r),
l.contentCRC = e, l.titleCRC = i, l.discussionListCRC = o, void c(void 0, !0));
});
}, h.syncDown = function(i) {
var r = n[p + ".lastChangeId"];
s.checkChanges(r, function(r, l, u) {
if (r) return i(r);
var d = [];
t.each(l, function(t) {
var e = c(t.path), n = a.getFileFromSyncIndex(e), i = n && n.syncLocations[e];
if (i) return t.fileDesc = n, t.syncAttributes = i, t.wasRemoved === !0 ? void d.push(t) : void (i.version != t.stat.versionTag && d.push(t));
}), s.downloadContent(d, function(t, r) {
function a() {
if (0 === r.length) return n[p + ".lastChangeId"] = u, i();
var t = r.pop(), s = t.fileDesc, l = t.syncAttributes;
if (t.wasRemoved === !0) return o.onError('"' + s.title + '" has been removed from Dropbox.'),
s.removeSyncLocation(l), o.onSyncRemoved(s, l);
var c = t.stat, d = h.parseContent(c.content), m = d.content, g = d.discussionListJSON, v = d.discussionList, b = h.syncMerge(s, l, m, s.title, v, g);
l.version = c.versionTag, f === !0 && (l.content = m, l.discussionList = v), l.contentCRC = b.contentCRC,
l.discussionListCRC = b.discussionListCRC, e.storeAttributes(l), setTimeout(a, 5);
}
return t ? void i(t) : void setTimeout(a, 5);
});
});
}, h.publish = function(t, e, n, i, r) {
var o = l(t.path);
return void 0 === o ? r(!0) : void s.upload(o, i, r);
}, h.newPublishAttributes = function(t) {
var n = {};
if (n.path = e.getInputTextValue("#input-publish-dropbox-path", t), !t.isPropagationStopped()) return n;
}, h;
}), function(t, e) {
var n, i = t.document;
n = function() {
var n, r, o, a, s, l, c, u, d, p, h, f, m, g = {}, v = {}, b = !1, y = {
ENTER: 13,
ESC: 27,
SPACE: 32
}, x = [];
return v = {
buttons: {
holder: '',
submit: '',
ok: '',
cancel: ''
},
input: '',
message: '
{{message}}
',
log: '{{message}}'
}, m = function() {
var t, n, r = !1, o = i.createElement("fakeelement"), a = {
WebkitTransition: "webkitTransitionEnd",
MozTransition: "transitionend",
OTransition: "otransitionend",
transition: "transitionend"
};
for (t in a) if (o.style[t] !== e) {
n = a[t], r = !0;
break;
}
return {
type: n,
supported: r
};
}, n = function(t) {
return i.getElementById(t);
}, g = {
labels: {
ok: "OK",
cancel: "Cancel"
},
delay: 5e3,
buttonReverse: !1,
buttonFocus: "ok",
transition: e,
addListeners: function(t) {
var e, n, l, c, u, d = "undefined" != typeof o, p = "undefined" != typeof r, h = "undefined" != typeof f, m = "", g = this;
e = function(e) {
return "undefined" != typeof e.preventDefault && e.preventDefault(), l(e), "undefined" != typeof f && (m = f.value),
"function" == typeof t && ("undefined" != typeof f ? t(!0, m) : t(!0)), !1;
}, n = function(e) {
return "undefined" != typeof e.preventDefault && e.preventDefault(), l(e), "function" == typeof t && t(!1),
!1;
}, l = function(t) {
g.hide(), g.unbind(i.body, "keyup", c), g.unbind(a, "focus", u), d && g.unbind(o, "click", e),
p && g.unbind(r, "click", n);
}, c = function(t) {
var i = t.keyCode;
(i === y.SPACE && !h || h && i === y.ENTER) && e(t), i === y.ESC && p && n(t);
}, u = function(t) {
h ? f.focus() : !p || g.buttonReverse ? o.focus() : r.focus();
}, this.bind(a, "focus", u), this.bind(s, "focus", u), d && this.bind(o, "click", e),
p && this.bind(r, "click", n), this.bind(i.body, "keyup", c), this.transition.supported || this.setFocus();
},
bind: function(t, e, n) {
"function" == typeof t.addEventListener ? t.addEventListener(e, n, !1) : t.attachEvent && t.attachEvent("on" + e, n);
},
handleErrors: function() {
if ("undefined" != typeof t.onerror) {
var e = this;
return t.onerror = function(t, n, i) {
e.error("[" + t + " on line " + i + " of " + n + "]", 0);
}, !0;
}
return !1;
},
appendButtons: function(t, e) {
return this.buttonReverse ? e + t : t + e;
},
build: function(t) {
var e = "", n = t.type, i = t.message, r = t.cssClass || "";
switch (e += '
', e += 'Reset Focus',
"none" === g.buttonFocus && (e += ''),
"prompt" === n && (e += '
'), e += '',
e += v.message.replace("{{message}}", i), "prompt" === n && (e += v.input), e += v.buttons.holder,
e += "", "prompt" === n && (e += "