Clazz.declarePackage ("JSV.util");
Clazz.load (null, "JSV.util.JSVEscape", ["java.lang.Character", "JU.BS", "$.SB", "J.util.Txt"], function () {
c$ = Clazz.declareType (JSV.util, "JSVEscape");
c$.eS = $_M(c$, "eS", 
function (str) {
if (str == null) return "\"\"";
var haveEscape = false;
var i = 0;
for (; i < "\\\\\tt\rr\nn\"\"".length; i += 2) if (str.indexOf ("\\\\\tt\rr\nn\"\"".charAt (i)) >= 0) {
haveEscape = true;
break;
}
if (haveEscape) while (i < "\\\\\tt\rr\nn\"\"".length) {
var pt = -1;
var ch = "\\\\\tt\rr\nn\"\"".charAt (i++);
var ch2 = "\\\\\tt\rr\nn\"\"".charAt (i++);
var sb =  new JU.SB ();
var pt0 = 0;
while ((pt = str.indexOf (ch, pt + 1)) >= 0) {
sb.append (str.substring (pt0, pt)).appendC ('\\').appendC (ch2);
pt0 = pt + 1;
}
sb.append (str.substring (pt0, str.length));
str = sb.toString ();
}
for (i = str.length; --i >= 0; ) if (str.charCodeAt (i) > 0x7F) str = str.substring (0, i) + JSV.util.JSVEscape.unicode (str.charAt (i)) + str.substring (i + 1);

return "\"" + str + "\"";
}, "~S");
c$.unicode = $_M(c$, "unicode", 
($fz = function (c) {
var s = "0000" + Integer.toHexString (c.charCodeAt (0));
return "\\u" + s.substring (s.length - 4);
}, $fz.isPrivate = true, $fz), "~S");
c$.getHexColorFromRGB = $_M(c$, "getHexColorFromRGB", 
function (rgb) {
if (rgb == 0) return "000000";
var r = "00" + Integer.toHexString ((rgb >> 16) & 0xFF);
r = r.substring (r.length - 2);
var g = "00" + Integer.toHexString ((rgb >> 8) & 0xFF);
g = g.substring (g.length - 2);
var b = "00" + Integer.toHexString (rgb & 0xFF);
b = b.substring (b.length - 2);
return r + g + b;
}, "~N");
c$.toJSON = $_M(c$, "toJSON", 
function (infoType, info, addCR) {
var sb =  new JU.SB ();
var sep = "";
if (info == null) return JSV.util.JSVEscape.packageJSON (infoType, Clazz.castNullAs ("String"), addCR);
if (Clazz.instanceOf (info, Integer) || Clazz.instanceOf (info, Float) || Clazz.instanceOf (info, Double)) return JSV.util.JSVEscape.packageJSON (infoType, info.toString (), addCR);
if (Clazz.instanceOf (info, String)) return JSV.util.JSVEscape.packageJSON (infoType, JSV.util.JSVEscape.fixString (info), addCR);
if (Clazz.instanceOf (info, Array)) {
sb.append ("[");
var imax = (info).length;
for (var i = 0; i < imax; i++) {
sb.append (sep).append (JSV.util.JSVEscape.fixString ((info)[i]));
sep = ",";
}
sb.append ("]");
return JSV.util.JSVEscape.packageJSON (infoType, sb, addCR);
}if (Clazz.instanceOf (info, Array)) {
sb.append ("[");
var imax = (info).length;
for (var i = 0; i < imax; i++) {
sb.append (sep).appendI ((info)[i]);
sep = ",";
}
sb.append ("]");
return JSV.util.JSVEscape.packageJSON (infoType, sb, addCR);
}if (Clazz.instanceOf (info, Array)) {
sb.append ("[");
var imax = (info).length;
for (var i = 0; i < imax; i++) {
sb.append (sep).appendF ((info)[i]);
sep = ",";
}
sb.append ("]");
return JSV.util.JSVEscape.packageJSON (infoType, sb, addCR);
}if (Clazz.instanceOf (info, Array)) {
sb.append ("[");
var imax = (info).length;
for (var i = 0; i < imax; i++) {
sb.append (sep).appendD ((info)[i]);
sep = ",";
}
sb.append ("]");
return JSV.util.JSVEscape.packageJSON (infoType, sb, addCR);
}if (Clazz.instanceOf (info, Array)) {
sb.append ("[");
if (addCR) sb.append ("\n");
var imax = (info).length;
for (var i = 0; i < imax; i++) {
sb.append (sep).append (JSV.util.JSVEscape.toJSON (null, (info)[i], addCR));
if (addCR) sb.append ("\n");
sep = ",";
}
sb.append ("]");
return JSV.util.JSVEscape.packageJSON (infoType, sb, addCR);
}if (Clazz.instanceOf (info, Array)) {
sb.append ("[");
var imax = (info).length;
for (var i = 0; i < imax; i++) {
sb.append (sep).append (JSV.util.JSVEscape.toJSON (null, (info)[i], addCR));
sep = ",";
}
sb.append ("]");
return JSV.util.JSVEscape.packageJSON (infoType, sb, addCR);
}if (Clazz.instanceOf (info, Array)) {
sb.append ("[");
var imax = (info).length;
for (var i = 0; i < imax; i++) {
sb.append (sep).append (JSV.util.JSVEscape.toJSON (null, (info)[i], addCR));
sep = ",";
}
sb.append ("]");
return JSV.util.JSVEscape.packageJSON (infoType, sb, addCR);
}if (Clazz.instanceOf (info, Array)) {
sb.append ("[");
var imax = (info).length;
for (var i = 0; i < imax; i++) {
sb.append (sep).append (JSV.util.JSVEscape.toJSON (null, (info)[i], addCR));
sep = ",";
}
sb.append ("]");
return JSV.util.JSVEscape.packageJSON (infoType, sb, addCR);
}if (Clazz.instanceOf (info, Array)) {
sb.append ("[");
var imax = (info).length;
for (var i = 0; i < imax; i++) {
sb.append (sep).append (JSV.util.JSVEscape.toJSON (null, (info)[i], addCR));
sep = ",";
}
sb.append ("]");
return JSV.util.JSVEscape.packageJSON (infoType, sb, addCR);
}if (Clazz.instanceOf (info, Array)) {
sb.append ("[");
var imax = (info).length;
for (var i = 0; i < imax; i++) {
sb.append (sep).append (JSV.util.JSVEscape.toJSON (null, (info)[i], addCR));
sep = ",";
}
sb.append ("]");
return JSV.util.JSVEscape.packageJSON (infoType, sb, addCR);
}if (Clazz.instanceOf (info, java.util.List)) {
sb.append ("[ ");
var imax = (info).size ();
for (var i = 0; i < imax; i++) {
sb.append (sep).append (JSV.util.JSVEscape.toJSON (null, (info).get (i), addCR));
sep = ",";
}
sb.append (" ]");
return JSV.util.JSVEscape.packageJSON (infoType, sb, addCR);
}if (Clazz.instanceOf (info, java.util.Map)) {
sb.append ("{ ");
var e = (info).keySet ().iterator ();
while (e.hasNext ()) {
var key = e.next ();
sb.append (sep).append (JSV.util.JSVEscape.packageJSON (key, JSV.util.JSVEscape.toJSON (null, (info).get (key), addCR), addCR));
sep = ",";
}
sb.append (" }");
return JSV.util.JSVEscape.packageJSON (infoType, sb, addCR);
}return JSV.util.JSVEscape.packageJSON (infoType, JSV.util.JSVEscape.fixString (info.toString ()), addCR);
}, "~S,~O,~B");
c$.fixString = $_M(c$, "fixString", 
($fz = function (s) {
if (s == null || s.indexOf ("{\"") == 0) return s;
s = J.util.Txt.simpleReplace (s, "\"", "''");
s = J.util.Txt.simpleReplace (s, "\n", " | ");
return "\"" + s + "\"";
}, $fz.isPrivate = true, $fz), "~S");
c$.packageJSON = $_M(c$, "packageJSON", 
($fz = function (infoType, sb, addCR) {
return JSV.util.JSVEscape.packageJSON (infoType, sb.toString (), addCR);
}, $fz.isPrivate = true, $fz), "~S,JU.SB,~B");
c$.packageJSON = $_M(c$, "packageJSON", 
($fz = function (infoType, info, addCR) {
if (infoType == null) return info;
return "\"" + infoType + "\": " + info + (addCR ? "\n" : "");
}, $fz.isPrivate = true, $fz), "~S,~S,~B");
c$.escapeUrl = $_M(c$, "escapeUrl", 
function (url) {
url = J.util.Txt.simpleReplace (url, "\n", "");
url = J.util.Txt.simpleReplace (url, "%", "%25");
url = J.util.Txt.simpleReplace (url, "[", "%5B");
url = J.util.Txt.simpleReplace (url, "]", "%5D");
url = J.util.Txt.simpleReplace (url, " ", "%20");
url = J.util.Txt.simpleReplace (url, "?", "%3F");
return url;
}, "~S");
c$.unescapeBitSet = $_M(c$, "unescapeBitSet", 
function (str) {
var ch;
var len;
if (str == null || (len = (str = str.trim ()).length) < 4 || str.equalsIgnoreCase ("({null})") || (ch = str.charAt (0)) != '(' && ch != '[' || str.charAt (len - 1) != (ch == '(' ? ')' : ']') || str.charAt (1) != '{' || str.indexOf ('}') != len - 2) return null;
len -= 2;
for (var i = len; --i >= 2; ) if (!Character.isDigit (ch = str.charAt (i)) && ch != ' ' && ch != '\t' && ch != ':') return null;

var lastN = len;
while (Character.isDigit (str.charAt (--lastN))) {
}
if (++lastN == len) lastN = 0;
 else try {
lastN = Integer.parseInt (str.substring (lastN, len));
} catch (e) {
if (Clazz.exceptionOf (e, NumberFormatException)) {
return null;
} else {
throw e;
}
}
var bs = JU.BS.newN (lastN);
lastN = -1;
var iPrev = -1;
var iThis = -2;
for (var i = 2; i <= len; i++) {
switch (ch = str.charAt (i)) {
case '\t':
case ' ':
case '}':
if (iThis < 0) break;
if (iThis < lastN) return null;
lastN = iThis;
if (iPrev < 0) iPrev = iThis;
bs.setBits (iPrev, iThis + 1);
iPrev = -1;
iThis = -2;
break;
case ':':
iPrev = lastN = iThis;
iThis = -2;
break;
default:
if (Character.isDigit (ch)) {
if (iThis < 0) iThis = 0;
iThis = (iThis * 10) + (ch.charCodeAt (0) - 48);
}}
}
return (iPrev >= 0 ? null : bs);
}, "~S");
c$.isAB = $_M(c$, "isAB", 
function (x) {
{
return Clazz.isAI(x);
}}, "~O");
Clazz.defineStatics (c$,
"escapable", "\\\\\tt\rr\nn\"\"");
});
