Warning: session_start(): open(/var/lib/php/sessions/sess_t93p31gqibnp7gauh3q34b27jm, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
import java.util.*;
import java.util.zip.*;
import java.util.List;
import java.util.regex.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.concurrent.locks.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.table.*;
import java.io.*;
import java.net.*;
import java.lang.reflect.*;
import java.lang.ref.*;
import java.lang.management.*;
import java.security.*;
import java.security.spec.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.*;
import java.math.*;
import x30_pkg.x30_util;
import static x30_pkg.x30_util.VF1;
import static x30_pkg.x30_util.l;
import static x30_pkg.x30_util.indexOf;
import static x30_pkg.x30_util.getOpt;
import static x30_pkg.x30_util.setOpt;
import static x30_pkg.x30_util.callOpt;
import static x30_pkg.x30_util.newWeakHashMap;
import static x30_pkg.x30_util.newDangerousWeakHashMap;
import static x30_pkg.x30_util.get;
import static x30_pkg.x30_util.get_raw;
import static x30_pkg.x30_util.assertTrue;
import static x30_pkg.x30_util.isHeadless;
import static x30_pkg.x30_util.isAndroid;
import static x30_pkg.x30_util.isTrue;
import x30_pkg.x30_util.DynamicObject;
import loadableUtils.utils;
import static loadableUtils.utils._threadInfo;
import static loadableUtils.utils._threadInheritInfo;
import static loadableUtils.utils._threadInfo_addMakerAndRetriever;
import static loadableUtils.utils.dm_currentModule;
import static loadableUtils.utils.dm_current_mandatory;
import static loadableUtils.utils.match;
import static loadableUtils.utils.getOpt_raw;
import static loadableUtils.utils.setOpt_raw;
import static loadableUtils.utils.getField;
import static loadableUtils.utils.fieldType;
import static loadableUtils.utils.format3;
import static loadableUtils.utils.vm_generalIdentityHashSet;
import static loadableUtils.utils.vm_generalHashMap;
import static loadableUtils.utils.vm_generalWeakSubMap;
import static loadableUtils.utils.bindToComponent;
import static loadableUtils.utils.struct;
import static loadableUtils.utils.structure;
import static loadableUtils.utils.loadPage;
import static loadableUtils.utils.loadPage_utf8;
import static loadableUtils.utils.loadPageSilentlyWithTimeout;
import static loadableUtils.utils.loadPageSilently;
import static loadableUtils.utils.loadSnippet;
import static loadableUtils.utils.loadSnippetQuietly;
import static loadableUtils.utils.sendToLocalBot;
import static loadableUtils.utils.sendToLocalBotOpt;
import static loadableUtils.utils.sendToLocalBotQuietly;
import static loadableUtils.utils.componentPopupMenu;
import static loadableUtils.utils.componentPopupMenu_top;
import static loadableUtils.utils.componentPopupMenu_initForComponent;
import static loadableUtils.utils.componentPopupMenu_getEvent;
import static loadableUtils.utils.listPopupMenu;
import static loadableUtils.utils.tablePopupMenu;
import static loadableUtils.utils.tablePopupMenuFirst;
import static loadableUtils.utils.rowSorter_setComparators;
import static loadableUtils.utils.sexyTableWithoutDrag;
import static loadableUtils.utils.dm_current_generic;
import static loadableUtils.utils.dm_current_mandatory_generic;
import static loadableUtils.utils.cset;
import static loadableUtils.utils.DynamicObject_loading;
import static loadableUtils.utils.concepts_unlisted;
import static loadableUtils.utils.makePopupMenuConditional;
import static loadableUtils.utils.makeConceptsTable_idWidth;
import static loadableUtils.utils.showConceptsTable_afterUpdate;
import static loadableUtils.utils.dynamicObjectIsLoading;
import static loadableUtils.utils.rethrow;
import static loadableUtils.utils.hasBot;
import static loadableUtils.utils.concepts_internStringsLongerThan;
import static loadableUtils.utils.concepts_setUnlistedByDefault;
import static loadableUtils.utils.realMC_tl;
import loadableUtils.utils.F0;
import loadableUtils.utils.F1;
import loadableUtils.utils.IF0;
import loadableUtils.utils.IF1;
import loadableUtils.utils.IVF1;
import loadableUtils.utils.IVF2;
import loadableUtils.utils.Matches;
import loadableUtils.utils.BetterLabel;
import loadableUtils.utils.SingleComponentPanel;
import loadableUtils.utils.Snippet;
import loadableUtils.utils.Q;
import loadableUtils.utils.ImageSurface;
import loadableUtils.utils.structure_Data;
import loadableUtils.utils.structure_ClassInfo;
import loadableUtils.utils.RGBImage;
import loadableUtils.utils.RGB;
import loadableUtils.utils.BWImage;
import loadableUtils.utils.MakesBufferedImage;
import loadableUtils.utils.MultiSet;
import loadableUtils.utils.Concept;
import loadableUtils.utils.Concepts;
import loadableUtils.utils.RC;
import loadableUtils.utils.IConceptIndex;
import loadableUtils.utils.IConceptCounter;
import loadableUtils.utils.IFieldIndex;
import loadableUtils.utils.Derefable;
import loadableUtils.utils.ImageSurfaceSelector;
import loadableUtils.utils.SimpleCRUD;
import loadableUtils.utils.PersistableThrowable;
import loadableUtils.utils.DynModule;
import loadableUtils.utils.DynPrintLog;
import loadableUtils.utils.DynObjectTable;
import loadableUtils.utils.DynImageSurface;
import loadableUtils.utils.DynCalculatedList;
import loadableUtils.utils.GlobalID;
import loadableUtils.utils.Rect;
import loadableUtils.utils.Pt;
import loadableUtils.utils.SynchronizedArrayList;
import loadableUtils.utils.SecretValue;
import loadableUtils.utils.HCRUD;
import loadableUtils.utils.HCRUD_Data;
import loadableUtils.utils.HCRUD_Concepts;
import loadableUtils.utils.ValueConverterForField;
import loadableUtils.utils.DefaultValueConverterForField;
import loadableUtils.utils.OrError;
import loadableUtils.utils.HTML;
import java.text.*;
import java.text.SimpleDateFormat;
import java.nio.charset.Charset;
import java.text.NumberFormat;
import javax.swing.undo.UndoManager;
import java.awt.datatransfer.StringSelection;
import java.util.TimeZone;
import java.awt.geom.*;
import javax.imageio.metadata.*;
import javax.imageio.stream.*;
import javax.swing.border.*;
class main {
static public class AvorDemonstrator extends DynAvorDemonstrator {
public void start2() {
super.start2();
alwaysRedirectToHttps = false;
}
public void startDB() {
bootstrapDBFrom("#1029802");
super.startDB();
}
}
static public boolean _moduleClass_AvorDemonstrator = true;
static public String programID;
static public void _onLoad_initUtils() {
utils.__javax = javax();
}
static public void _onLoad_defaultClassFinder() {
setDefaultClassFinder(new F1() {
public Class get(String name) {
Class c = findClass_fullName(name);
if (c != null)
return c;
if (name.startsWith("main$"))
return loadableUtils.utils.findClass_fullName("loadableUtils.utils" + name.substring(4));
return null;
}
});
}
static public ThreadLocal dynamicObjectIsLoading_threadLocal() {
return DynamicObject_loading;
}
static volatile public Concepts mainConcepts;
static public Concepts db_mainConcepts() {
if (mainConcepts == null)
mainConcepts = newConceptsWithClassFinder(getDBProgramID());
return mainConcepts;
}
static public void cleanMeUp_concepts() {
if (db_mainConcepts() != null)
db_mainConcepts().cleanMeUp();
}
static public void bootstrapDBFrom(String progID) {
bootstrapConceptsFrom(progID);
}
static public Class javax() {
return getJavaX();
}
static public void setDefaultClassFinder(Object cf) {
_defaultClassFinder_value = cf;
}
static public HashMap findClass_fullName_cache = new HashMap();
static public Class findClass_fullName(String name) {
synchronized (findClass_fullName_cache) {
if (findClass_fullName_cache.containsKey(name))
return findClass_fullName_cache.get(name);
Class c;
try {
c = Class.forName(name);
} catch (ClassNotFoundException e) {
c = null;
}
findClass_fullName_cache.put(name, c);
return c;
}
}
static public Object _defaultClassFinder_value = defaultDefaultClassFinder();
static public Object _defaultClassFinder() {
return _defaultClassFinder_value;
}
static public Concepts newConceptsWithClassFinder(String progID) {
Concepts cc = new Concepts(progID);
cc.classFinder = _defaultClassFinder();
return cc;
}
static public String getDBProgramID_id;
static public String getDBProgramID() {
return nempty(getDBProgramID_id) ? getDBProgramID_id : programIDWithCase();
}
static public void bootstrapConceptsFrom(String progID) {
for (String ending : ll("", ".gz")) {
File f1 = getProgramFile(progID, "concepts.structure" + ending);
File f2 = getProgramFile(programID(), "concepts.structure" + ending);
if ((!f2.exists() || eq(ending, ".gz") && fileSize(f2) <= 24) && f1.exists())
copyFile(f1, f2);
}
}
static public Class __javax;
static public Class getJavaX() {
try {
return __javax;
} catch (Exception __e) {
throw rethrow(__e);
}
}
static public Object defaultDefaultClassFinder() {
return new F1() {
public Class get(String name) {
Class c = get2(name);
return c;
}
public Class get2(String name) {
if (eq(name, ""))
return mc();
{
Class c = findClass_fullName(name);
if (c != null)
return c;
}
if (startsWithAny(name, "loadableUtils.utils$", "main$", mcDollar()))
for (String pkg : ll("loadableUtils.utils$", mcDollar())) {
String newName = pkg + afterDollar(name);
{
Class c = findClass_fullName(newName);
if (c != null)
return c;
}
}
return null;
}
};
}
static public boolean nempty(Collection c) {
return !empty(c);
}
static public boolean nempty(CharSequence s) {
return !empty(s);
}
static public boolean nempty(Object[] o) {
return !empty(o);
}
static public boolean nempty(byte[] o) {
return !empty(o);
}
static public boolean nempty(int[] o) {
return !empty(o);
}
static public boolean nempty(Map m) {
return !empty(m);
}
static public boolean nempty(Iterator i) {
return i != null && i.hasNext();
}
static public boolean nempty(Object o) {
return !empty(o);
}
static public boolean nempty(IntRange r) {
return !empty(r);
}
static public String programIDWithCase() {
return nempty(caseID()) ? programID() + "/" + quoteUnlessIdentifierOrInteger(caseID()) : programID();
}
static public List ll(A... a) {
ArrayList l = new ArrayList(a.length);
if (a != null)
for (A x : a) l.add(x);
return l;
}
static public File getProgramFile(String progID, String fileName) {
if (new File(fileName).isAbsolute())
return new File(fileName);
return new File(getProgramDir(progID), fileName);
}
static public File getProgramFile(String fileName) {
return getProgramFile(getProgramID(), fileName);
}
static public String programID() {
return getProgramID();
}
static public String programID(Object o) {
return getProgramID(o);
}
static public boolean eq(Object a, Object b) {
return a == b || a != null && b != null && a.equals(b);
}
static public long fileSize(String path) {
return getFileSize(path);
}
static public long fileSize(File f) {
return getFileSize(f);
}
static public File copyFile(File src, File dest) {
try {
FileInputStream inputStream = new FileInputStream(src.getPath());
FileOutputStream outputStream = newFileOutputStream(dest.getPath());
try {
copyStream(inputStream, outputStream);
inputStream.close();
} finally {
outputStream.close();
}
return dest;
} catch (Exception __e) {
throw rethrow(__e);
}
}
static public Object get2(Object o, String field1, String field2) {
return get(get(o, field1), field2);
}
static public Class mc() {
return main.class;
}
static public boolean startsWithAny(String a, Collection b) {
for (String prefix : unnullForIteration(b)) if (startsWith(a, prefix))
return true;
return false;
}
static public boolean startsWithAny(String a, String... b) {
if (b != null)
for (String prefix : unnullForIteration(b)) if (startsWith(a, prefix))
return true;
return false;
}
static public boolean startsWithAny(String a, Collection b, Matches m) {
for (String prefix : unnullForIteration(b)) if (startsWith(a, prefix, m))
return true;
return false;
}
static public String mcDollar() {
return mcName() + "$";
}
static public String afterDollar(String s) {
return substring(s, smartIndexOf(s, '$') + 1);
}
static public boolean empty(Collection c) {
return c == null || c.isEmpty();
}
static public boolean empty(Iterable c) {
return c == null || !c.iterator().hasNext();
}
static public boolean empty(CharSequence s) {
return s == null || s.length() == 0;
}
static public boolean empty(Map map) {
return map == null || map.isEmpty();
}
static public boolean empty(Object[] o) {
return o == null || o.length == 0;
}
static public boolean empty(Object o) {
if (o instanceof Collection)
return empty((Collection) o);
if (o instanceof String)
return empty((String) o);
if (o instanceof Map)
return empty((Map) o);
if (o instanceof Object[])
return empty((Object[]) o);
if (o instanceof byte[])
return empty((byte[]) o);
if (o == null)
return true;
throw fail("unknown type for 'empty': " + getType(o));
}
static public boolean empty(Iterator i) {
return i == null || !i.hasNext();
}
static public boolean empty(double[] a) {
return a == null || a.length == 0;
}
static public boolean empty(float[] a) {
return a == null || a.length == 0;
}
static public boolean empty(int[] a) {
return a == null || a.length == 0;
}
static public boolean empty(long[] a) {
return a == null || a.length == 0;
}
static public boolean empty(byte[] a) {
return a == null || a.length == 0;
}
static public boolean empty(short[] a) {
return a == null || a.length == 0;
}
static public boolean empty(MultiSet ms) {
return ms == null || ms.isEmpty();
}
static public boolean empty(MultiMap mm) {
return mm == null || mm.isEmpty();
}
static public boolean empty(File f) {
return getFileSize(f) == 0;
}
static public boolean empty(IntRange r) {
return r == null || r.empty();
}
static volatile public String caseID_caseID;
static public String caseID() {
return caseID_caseID;
}
static public void caseID(String id) {
caseID_caseID = id;
}
static public String quoteUnlessIdentifierOrInteger(String s) {
return quoteIfNotIdentifierOrInteger(s);
}
static public File getProgramDir() {
return programDir();
}
static public File getProgramDir(String snippetID) {
return programDir(snippetID);
}
static public String getProgramID() {
return nempty(programID) ? formatSnippetIDOpt(programID) : "?";
}
static public String getProgramID(Class c) {
String id = (String) getOpt(c, "programID");
if (nempty(id))
return formatSnippetID(id);
return "?";
}
static public String getProgramID(Object o) {
return getProgramID(getMainClass(o));
}
static public String str(Object o) {
return o == null ? "null" : o.toString();
}
static public String str(char[] c) {
return new String(c);
}
static public long getFileSize(String path) {
return path == null ? 0 : new File(path).length();
}
static public long getFileSize(File f) {
return f == null ? 0 : f.length();
}
static public FileOutputStream newFileOutputStream(File path) throws IOException {
return newFileOutputStream(path.getPath());
}
static public FileOutputStream newFileOutputStream(String path) throws IOException {
return newFileOutputStream(path, false);
}
static public FileOutputStream newFileOutputStream(File path, boolean append) throws IOException {
return newFileOutputStream(path.getPath(), append);
}
static public FileOutputStream newFileOutputStream(String path, boolean append) throws IOException {
mkdirsForFile(path);
FileOutputStream f = new FileOutputStream(path, append);
_registerIO(f, path, true);
return f;
}
static public void copyStream(InputStream in, OutputStream out) {
try {
byte[] buf = new byte[65536];
while (true) {
int n = in.read(buf);
if (n <= 0)
return;
out.write(buf, 0, n);
}
} catch (Exception __e) {
throw rethrow(__e);
}
}
static public String unnullForIteration(String s) {
return s == null ? "" : s;
}
static public Collection unnullForIteration(Collection l) {
return l == null ? immutableEmptyList() : l;
}
static public List unnullForIteration(List l) {
return l == null ? immutableEmptyList() : l;
}
static public int[] unnullForIteration(int[] l) {
return l == null ? emptyIntArray() : l;
}
static public char[] unnullForIteration(char[] l) {
return l == null ? emptyCharArray() : l;
}
static public double[] unnullForIteration(double[] l) {
return l == null ? emptyDoubleArray() : l;
}
static public Map unnullForIteration(Map l) {
return l == null ? immutableEmptyMap() : l;
}
static public Iterable unnullForIteration(Iterable i) {
return i == null ? immutableEmptyList() : i;
}
static public A[] unnullForIteration(A[] a) {
return a == null ? (A[]) emptyObjectArray() : a;
}
static public BitSet unnullForIteration(BitSet b) {
return b == null ? new BitSet() : b;
}
static public Pt unnullForIteration(Pt p) {
return p == null ? new Pt() : p;
}
static public Pair unnullForIteration(Pair p) {
return p != null ? p : new Pair(null, null);
}
static public long unnullForIteration(Long l) {
return l == null ? 0L : l;
}
static public boolean startsWith(String a, String b) {
return a != null && a.startsWith(unnull(b));
}
static public boolean startsWith(String a, char c) {
return nemptyString(a) && a.charAt(0) == c;
}
static public boolean startsWith(String a, String b, Matches m) {
if (!startsWith(a, b))
return false;
m.m = new String[] { substring(a, strL(b)) };
return true;
}
static public boolean startsWith(List a, List b) {
if (a == null || listL(b) > listL(a))
return false;
for (int i = 0; i < listL(b); i++) if (neq(a.get(i), b.get(i)))
return false;
return true;
}
static public String mcName() {
return mc().getName();
}
static public String substring(String s, int x) {
return substring(s, x, strL(s));
}
static public String substring(String s, int x, int y) {
if (s == null)
return null;
if (x < 0)
x = 0;
int n = s.length();
if (y < x)
y = x;
if (y > n)
y = n;
if (x >= y)
return "";
return s.substring(x, y);
}
static public String substring(String s, IntRange r) {
return r == null ? null : substring(s, r.start, r.end);
}
static public String substring(String s, CharSequence l) {
return substring(s, lCharSequence(l));
}
static public int smartIndexOf(String s, String sub, int i) {
if (s == null)
return 0;
i = s.indexOf(sub, min(i, l(s)));
return i >= 0 ? i : l(s);
}
static public int smartIndexOf(String s, int i, char c) {
return smartIndexOf(s, c, i);
}
static public int smartIndexOf(String s, char c, int i) {
if (s == null)
return 0;
i = s.indexOf(c, min(i, l(s)));
return i >= 0 ? i : l(s);
}
static public int smartIndexOf(String s, String sub) {
return smartIndexOf(s, sub, 0);
}
static public int smartIndexOf(String s, char c) {
return smartIndexOf(s, c, 0);
}
static public int smartIndexOf(List l, A sub) {
return smartIndexOf(l, sub, 0);
}
static public int smartIndexOf(List l, int start, A sub) {
return smartIndexOf(l, sub, start);
}
static public int smartIndexOf(List l, A sub, int start) {
int i = indexOf(l, sub, start);
return i < 0 ? l(l) : i;
}
static public RuntimeException fail() {
throw new RuntimeException("fail");
}
static public RuntimeException fail(Throwable e) {
throw asRuntimeException(e);
}
static public RuntimeException fail(Object msg) {
throw new RuntimeException(String.valueOf(msg));
}
static public RuntimeException fail(Object... objects) {
throw new Fail(objects);
}
static public RuntimeException fail(String msg) {
throw new RuntimeException(msg == null ? "" : msg);
}
static public RuntimeException fail(String msg, Throwable innerException) {
throw new RuntimeException(msg, innerException);
}
static public String getType(Object o) {
return getClassName(o);
}
static public String quoteIfNotIdentifierOrInteger(String s) {
if (s == null)
return null;
return isJavaIdentifier(s) || isInteger(s) ? s : quote(s);
}
static public File programDir_mine;
static public File programDir() {
return programDir(getProgramID());
}
static public File programDir(String snippetID) {
boolean me = sameSnippetID(snippetID, programID());
if (programDir_mine != null && me)
return programDir_mine;
File dir = new File(javaxDataDir(), formatSnippetIDOpt(snippetID));
if (me) {
String c = caseID();
if (nempty(c))
dir = newFile(dir, c);
}
return dir;
}
static public File programDir(String snippetID, String subPath) {
return new File(programDir(snippetID), subPath);
}
static public String formatSnippetIDOpt(String s) {
return isSnippetID(s) ? formatSnippetID(s) : s;
}
static public String formatSnippetID(String id) {
return "#" + parseSnippetID(id);
}
static public String formatSnippetID(long id) {
return "#" + id;
}
static public Class getMainClass() {
return mc();
}
static public Class getMainClass(Object o) {
try {
if (o == null)
return null;
if (o instanceof Class && eq(((Class) o).getName(), "x30"))
return (Class) o;
ClassLoader cl = (o instanceof Class ? (Class) o : o.getClass()).getClassLoader();
if (cl == null)
return null;
String name = mainClassNameForClassLoader(cl);
return loadClassFromClassLoader_orNull(cl, name);
} catch (Exception __e) {
throw rethrow(__e);
}
}
public static File mkdirsForFile(File file) {
File dir = file.getParentFile();
if (dir != null) {
dir.mkdirs();
if (!dir.isDirectory())
if (dir.isFile())
throw fail("Please delete the file " + f2s(dir) + " - it is supposed to be a directory!");
else
throw fail("Unknown IO exception during mkdirs of " + f2s(file));
}
return file;
}
public static String mkdirsForFile(String path) {
mkdirsForFile(new File(path));
return path;
}
static public void _registerIO(Object object, String path, boolean opened) {
}
static public List immutableEmptyList() {
return Collections.emptyList();
}
static public int[] emptyIntArray_a = new int[0];
static public int[] emptyIntArray() {
return emptyIntArray_a;
}
static public char[] emptyCharArray = new char[0];
static public char[] emptyCharArray() {
return emptyCharArray;
}
static public double[] emptyDoubleArray = new double[0];
static public double[] emptyDoubleArray() {
return emptyDoubleArray;
}
static public Map immutableEmptyMap() {
return Collections.emptyMap();
}
static public Object[] emptyObjectArray_a = new Object[0];
static public Object[] emptyObjectArray() {
return emptyObjectArray_a;
}
static public String unnull(String s) {
return s == null ? "" : s;
}
static public Collection unnull(Collection l) {
return l == null ? emptyList() : l;
}
static public List unnull(List l) {
return l == null ? emptyList() : l;
}
static public int[] unnull(int[] l) {
return l == null ? emptyIntArray() : l;
}
static public char[] unnull(char[] l) {
return l == null ? emptyCharArray() : l;
}
static public double[] unnull(double[] l) {
return l == null ? emptyDoubleArray() : l;
}
static public Map unnull(Map l) {
return l == null ? emptyMap() : l;
}
static public Iterable unnull(Iterable i) {
return i == null ? emptyList() : i;
}
static public A[] unnull(A[] a) {
return a == null ? (A[]) emptyObjectArray() : a;
}
static public BitSet unnull(BitSet b) {
return b == null ? new BitSet() : b;
}
static public Pt unnull(Pt p) {
return p == null ? new Pt() : p;
}
static public Pair unnull(Pair p) {
return p != null ? p : new Pair(null, null);
}
static public int unnull(Integer i) {
return i == null ? 0 : i;
}
static public long unnull(Long l) {
return l == null ? 0L : l;
}
static public boolean nemptyString(String s) {
return s != null && s.length() > 0;
}
static public int strL(String s) {
return s == null ? 0 : s.length();
}
static public int listL(Collection l) {
return l == null ? 0 : l.size();
}
static public boolean neq(Object a, Object b) {
return !eq(a, b);
}
static public int lCharSequence(CharSequence s) {
return s == null ? 0 : s.length();
}
static public int min(int a, int b) {
return Math.min(a, b);
}
static public long min(long a, long b) {
return Math.min(a, b);
}
static public float min(float a, float b) {
return Math.min(a, b);
}
static public float min(float a, float b, float c) {
return min(min(a, b), c);
}
static public double min(double a, double b) {
return Math.min(a, b);
}
static public double min(double[] c) {
double x = Double.MAX_VALUE;
for (double d : c) x = Math.min(x, d);
return x;
}
static public float min(float[] c) {
float x = Float.MAX_VALUE;
for (float d : c) x = Math.min(x, d);
return x;
}
static public byte min(byte[] c) {
byte x = 127;
for (byte d : c) if (d < x)
x = d;
return x;
}
static public short min(short[] c) {
short x = 0x7FFF;
for (short d : c) if (d < x)
x = d;
return x;
}
static public int min(int[] c) {
int x = Integer.MAX_VALUE;
for (int d : c) if (d < x)
x = d;
return x;
}
static public RuntimeException asRuntimeException(Throwable t) {
if (t instanceof Error)
_handleError((Error) t);
return t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t);
}
static public String getClassName(Object o) {
return o == null ? "null" : o instanceof Class ? ((Class) o).getName() : o.getClass().getName();
}
static public boolean isJavaIdentifier(String s) {
if (empty(s) || !Character.isJavaIdentifierStart(s.charAt(0)))
return false;
for (int i = 1; i < s.length(); i++) if (!Character.isJavaIdentifierPart(s.charAt(i)))
return false;
return true;
}
static public boolean isInteger(String s) {
int n = l(s);
if (n == 0)
return false;
int i = 0;
if (s.charAt(0) == '-')
if (++i >= n)
return false;
while (i < n) {
char c = s.charAt(i);
if (c < '0' || c > '9')
return false;
++i;
}
return true;
}
static public String quote(Object o) {
if (o == null)
return "null";
return quote(str(o));
}
static public String quote(String s) {
if (s == null)
return "null";
StringBuilder out = new StringBuilder((int) (l(s) * 1.5 + 2));
quote_impl(s, out);
return out.toString();
}
static public void quote_impl(String s, StringBuilder out) {
out.append('"');
int l = s.length();
for (int i = 0; i < l; i++) {
char c = s.charAt(i);
if (c == '\\' || c == '"')
out.append('\\').append(c);
else if (c == '\r')
out.append("\\r");
else if (c == '\n')
out.append("\\n");
else if (c == '\t')
out.append("\\t");
else if (c == '\0')
out.append("\\0");
else
out.append(c);
}
out.append('"');
}
static public boolean sameSnippetID(String a, String b) {
if (!isSnippetID(a) || !isSnippetID(b))
return false;
return parseSnippetID(a) == parseSnippetID(b);
}
static public File javaxDataDir_dir;
static public File javaxDataDir() {
return javaxDataDir_dir != null ? javaxDataDir_dir : new File(userHome(), "JavaX-Data");
}
static public File javaxDataDir(String... subs) {
return newFile(javaxDataDir(), subs);
}
static public File newFile(File base, String... names) {
for (String name : names) base = new File(base, name);
return base;
}
static public File newFile(String name) {
return name == null ? null : new File(name);
}
static public File newFile(String base, String... names) {
return newFile(newFile(base), names);
}
public static boolean isSnippetID(String s) {
try {
parseSnippetID(s);
return true;
} catch (RuntimeException e) {
return false;
}
}
public static long parseSnippetID(String snippetID) {
long id = Long.parseLong(shortenSnippetID(snippetID));
if (id == 0)
throw fail("0 is not a snippet ID");
return id;
}
static public String mainClassNameForClassLoader(ClassLoader cl) {
return or((String) callOpt(cl, "mainClassName"), "main");
}
static public Class loadClassFromClassLoader_orNull(ClassLoader cl, String name) {
try {
return cl == null ? null : cl.loadClass(name);
} catch (ClassNotFoundException e) {
return null;
}
}
static public String f2s(File f) {
return f == null ? null : f.getAbsolutePath();
}
static public String f2s(String s) {
return f2s(newFile(s));
}
static public String f2s(java.nio.file.Path p) {
return p == null ? null : f2s(p.toFile());
}
static public ArrayList emptyList() {
return new ArrayList();
}
static public ArrayList emptyList(int capacity) {
return new ArrayList(max(0, capacity));
}
static public ArrayList emptyList(Iterable l) {
return l instanceof Collection ? emptyList(((Collection) l).size()) : emptyList();
}
static public ArrayList emptyList(Object[] l) {
return emptyList(l(l));
}
static public ArrayList emptyList(Class c) {
return new ArrayList();
}
static public Map emptyMap() {
return new HashMap();
}
static public void _handleError(Error e) {
call(javax(), "_handleError", e);
}
static public String _userHome;
static public String userHome() {
if (_userHome == null)
return actualUserHome();
return _userHome;
}
static public File userHome(String path) {
return new File(userDir(), path);
}
static public String shortenSnippetID(String snippetID) {
if (snippetID.startsWith("#"))
snippetID = snippetID.substring(1);
String httpBlaBla = "http://tinybrain.de/";
if (snippetID.startsWith(httpBlaBla))
snippetID = snippetID.substring(httpBlaBla.length());
return "" + parseLong(snippetID);
}
static public A or(A a, A b) {
return a != null ? a : b;
}
static public int max(int a, int b) {
return Math.max(a, b);
}
static public int max(int a, int b, int c) {
return max(max(a, b), c);
}
static public long max(int a, long b) {
return Math.max((long) a, b);
}
static public long max(long a, long b) {
return Math.max(a, b);
}
static public double max(int a, double b) {
return Math.max((double) a, b);
}
static public float max(float a, float b) {
return Math.max(a, b);
}
static public double max(double a, double b) {
return Math.max(a, b);
}
static public int max(Collection c) {
int x = Integer.MIN_VALUE;
for (int i : c) x = max(x, i);
return x;
}
static public double max(double[] c) {
if (c.length == 0)
return Double.MIN_VALUE;
double x = c[0];
for (int i = 1; i < c.length; i++) x = Math.max(x, c[i]);
return x;
}
static public float max(float[] c) {
if (c.length == 0)
return Float.MAX_VALUE;
float x = c[0];
for (int i = 1; i < c.length; i++) x = Math.max(x, c[i]);
return x;
}
static public byte max(byte[] c) {
byte x = -128;
for (byte d : c) if (d > x)
x = d;
return x;
}
static public short max(short[] c) {
short x = -0x8000;
for (short d : c) if (d > x)
x = d;
return x;
}
static public int max(int[] c) {
int x = Integer.MIN_VALUE;
for (int d : c) if (d > x)
x = d;
return x;
}
static public Object callF(Object f, Object... args) {
try {
if (f instanceof String)
return callMC((String) f, args);
return x30_util.callF(f, args);
} catch (Exception __e) {
throw rethrow(__e);
}
}
static public A callF(F0 f) {
return f == null ? null : f.get();
}
static public A callF(IF0 f) {
return f == null ? null : f.get();
}
static public B callF(F1 f, A a) {
return f == null ? null : f.get(a);
}
static public B callF(IF1 f, A a) {
return f == null ? null : f.get(a);
}
static public C callF(F2 f, A a, B b) {
return f == null ? null : f.get(a, b);
}
static public void callF(VF1 f, A a) {
if (f != null)
f.get(a);
}
static public Object callMC(String method, Object... args) {
return call(mc(), method, args);
}
static public Object call(Object o) {
return callF(o);
}
static public Object call(Object o, String method, Object... args) {
return call_withVarargs(o, method, args);
}
static public String actualUserHome_value;
static public String actualUserHome() {
if (actualUserHome_value == null) {
if (isAndroid())
actualUserHome_value = "/storage/emulated/0/";
else
actualUserHome_value = System.getProperty("user.home");
}
return actualUserHome_value;
}
static public File actualUserHome(String sub) {
return newFile(new File(actualUserHome()), sub);
}
static public File userDir() {
return new File(userHome());
}
static public File userDir(String path) {
return new File(userHome(), path);
}
static public long parseLong(String s) {
if (empty(s))
return 0;
return Long.parseLong(dropSuffix("L", s));
}
static public long parseLong(Object s) {
return Long.parseLong((String) s);
}
static public Object call_withVarargs(Object o, String method, Object... args) {
try {
if (o == null)
return null;
if (o instanceof Class) {
Class c = (Class) o;
_MethodCache cache = callOpt_getCache(c);
Method me = cache.findStaticMethod(method, args);
if (me != null)
return invokeMethod(me, null, args);
List methods = cache.cache.get(method);
if (methods != null)
methodSearch: for (Method m : methods) {
{
if (!(m.isVarArgs()))
continue;
}
{
if (!(isStaticMethod(m)))
continue;
}
Object[] newArgs = massageArgsForVarArgsCall(m, args);
if (newArgs != null)
return invokeMethod(m, null, newArgs);
}
throw fail("Method " + c.getName() + "." + method + "(" + joinWithComma(classNames(args)) + ") not found");
} else {
Class c = o.getClass();
_MethodCache cache = callOpt_getCache(c);
Method me = cache.findMethod(method, args);
if (me != null)
return invokeMethod(me, o, args);
List methods = cache.cache.get(method);
if (methods != null)
methodSearch: for (Method m : methods) {
{
if (!(m.isVarArgs()))
continue;
}
Object[] newArgs = massageArgsForVarArgsCall(m, args);
if (newArgs != null)
return invokeMethod(m, o, newArgs);
}
throw fail("Method " + c.getName() + "." + method + "(" + joinWithComma(classNames(args)) + ") not found");
}
} catch (Exception __e) {
throw rethrow(__e);
}
}
static public String dropSuffix(String suffix, String s) {
return s.endsWith(suffix) ? s.substring(0, l(s) - l(suffix)) : s;
}
static final public Map callOpt_cache = newDangerousWeakHashMap();
static public Object callOpt_cached(Object o, String methodName, Object... args) {
try {
if (o == null)
return null;
if (o instanceof Class) {
Class c = (Class) o;
_MethodCache cache = callOpt_getCache(c);
Method me = cache.findMethod(methodName, args);
if (me == null || (me.getModifiers() & Modifier.STATIC) == 0)
return null;
return invokeMethod(me, null, args);
} else {
Class c = o.getClass();
_MethodCache cache = callOpt_getCache(c);
Method me = cache.findMethod(methodName, args);
if (me == null)
return null;
return invokeMethod(me, o, args);
}
} catch (Exception __e) {
throw rethrow(__e);
}
}
static public _MethodCache callOpt_getCache(Class c) {
_MethodCache cache = callOpt_cache.get(c);
if (cache == null)
callOpt_cache.put(c, cache = new _MethodCache(c));
return cache;
}
static public Object invokeMethod(Method m, Object o, Object... args) {
try {
try {
return m.invoke(o, args);
} catch (InvocationTargetException e) {
throw rethrow(getExceptionCause(e));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(e.getMessage() + " - was calling: " + m + ", args: " + joinWithSpace(classNames(args)));
}
} catch (Exception __e) {
throw rethrow(__e);
}
}
static public boolean isStaticMethod(Method m) {
return methodIsStatic(m);
}
static public Object[] massageArgsForVarArgsCall(Method m, Object[] args) {
Class>[] types = m.getParameterTypes();
int n = types.length - 1, nArgs = args.length;
if (nArgs < n)
return null;
for (int i = 0; i < n; i++) if (!argumentCompatibleWithType(args[i], types[i]))
return null;
Class varArgType = types[n].getComponentType();
for (int i = n; i < nArgs; i++) if (!argumentCompatibleWithType(args[i], varArgType))
return null;
Object[] newArgs = new Object[n + 1];
arraycopy(args, 0, newArgs, 0, n);
Object[] varArgs = arrayOfType(varArgType, nArgs - n);
arraycopy(args, n, varArgs, 0, nArgs - n);
newArgs[n] = varArgs;
return newArgs;
}
static public String joinWithComma(Collection c) {
return join(", ", c);
}
static public String joinWithComma(String... c) {
return join(", ", c);
}
static public String joinWithComma(Pair p) {
return p == null ? "" : joinWithComma(str(p.a), str(p.b));
}
static public List classNames(Collection l) {
return getClassNames(l);
}
static public List classNames(Object[] l) {
return getClassNames(Arrays.asList(l));
}
static public Throwable getExceptionCause(Throwable e) {
Throwable c = e.getCause();
return c != null ? c : e;
}
static public String joinWithSpace(Iterable c) {
return join(" ", c);
}
static public String joinWithSpace(String... c) {
return join(" ", c);
}
static public boolean methodIsStatic(Method m) {
return (m.getModifiers() & Modifier.STATIC) != 0;
}
static public boolean argumentCompatibleWithType(Object arg, Class type) {
return arg == null ? !type.isPrimitive() : isInstanceX(type, arg);
}
static public void arraycopy(Object[] a, Object[] b) {
if (a != null && b != null)
arraycopy(a, 0, b, 0, Math.min(a.length, b.length));
}
static public void arraycopy(Object src, int srcPos, Object dest, int destPos, int n) {
if (n != 0)
System.arraycopy(src, srcPos, dest, destPos, n);
}
static public A[] arrayOfType(Class type, int n) {
return makeArray(type, n);
}
static public A[] arrayOfType(int n, Class type) {
return arrayOfType(type, n);
}
public static String join(String glue, Iterable strings) {
if (strings == null)
return "";
if (strings instanceof Collection) {
if (((Collection) strings).size() == 1)
return str(first(((Collection) strings)));
}
StringBuilder buf = new StringBuilder();
Iterator i = strings.iterator();
if (i.hasNext()) {
buf.append(i.next());
while (i.hasNext()) buf.append(glue).append(i.next());
}
return buf.toString();
}
public static String join(String glue, String... strings) {
return join(glue, Arrays.asList(strings));
}
static public String join(Iterable strings) {
return join("", strings);
}
static public String join(Iterable strings, String glue) {
return join(glue, strings);
}
public static String join(String[] strings) {
return join("", strings);
}
static public String join(String glue, Pair p) {
return p == null ? "" : str(p.a) + glue + str(p.b);
}
static public List getClassNames(Collection l) {
List out = new ArrayList();
if (l != null)
for (Object o : l) out.add(o == null ? null : getClassName(o));
return out;
}
static public boolean isInstanceX(Class type, Object arg) {
if (type == boolean.class)
return arg instanceof Boolean;
if (type == int.class)
return arg instanceof Integer;
if (type == long.class)
return arg instanceof Long;
if (type == float.class)
return arg instanceof Float;
if (type == short.class)
return arg instanceof Short;
if (type == char.class)
return arg instanceof Character;
if (type == byte.class)
return arg instanceof Byte;
if (type == double.class)
return arg instanceof Double;
return type.isInstance(arg);
}
static public A[] makeArray(Class type, int n) {
return (A[]) Array.newInstance(type, n);
}
static public Object first(Object list) {
return first((Iterable) list);
}
static public A first(List list) {
return empty(list) ? null : list.get(0);
}
static public A first(A[] bla) {
return bla == null || bla.length == 0 ? null : bla[0];
}
static public A first(IterableIterator i) {
return first((Iterator) i);
}
static public A first(Iterator i) {
return i == null || !i.hasNext() ? null : i.next();
}
static public A first(Iterable i) {
if (i == null)
return null;
Iterator it = i.iterator();
return it.hasNext() ? it.next() : null;
}
static public Character first(String s) {
return empty(s) ? null : s.charAt(0);
}
static public Character first(CharSequence s) {
return empty(s) ? null : s.charAt(0);
}
static public A first(Pair p) {
return p == null ? null : p.a;
}
static public Byte first(byte[] l) {
return empty(l) ? null : l[0];
}
final static public class _MethodCache {
final public Class c;
final public HashMap> cache = new HashMap();
public _MethodCache(Class c) {
this.c = c;
_init();
}
public void _init() {
Class _c = c;
while (_c != null) {
for (Method m : _c.getDeclaredMethods()) if (!isAbstract(m) && !reflection_isForbiddenMethod(m))
multiMapPut(cache, m.getName(), makeAccessible(m));
_c = _c.getSuperclass();
}
for (Class intf : allInterfacesImplementedBy(c)) for (Method m : intf.getDeclaredMethods()) if (m.isDefault() && !reflection_isForbiddenMethod(m))
multiMapPut(cache, m.getName(), makeAccessible(m));
}
public Method findMethod(String method, Object[] args) {
try {
List m = cache.get(method);
if (m == null)
return null;
int n = m.size();
for (int i = 0; i < n; i++) {
Method me = m.get(i);
if (call_checkArgs(me, args, false))
return me;
}
return null;
} catch (Exception __e) {
throw rethrow(__e);
}
}
public Method findStaticMethod(String method, Object[] args) {
try {
List m = cache.get(method);
if (m == null)
return null;
int n = m.size();
for (int i = 0; i < n; i++) {
Method me = m.get(i);
if (isStaticMethod(me) && call_checkArgs(me, args, false))
return me;
}
return null;
} catch (Exception __e) {
throw rethrow(__e);
}
}
}
static public class Fail extends RuntimeException implements IFieldsToList {
public Object[] objects;
public Fail() {
}
public Fail(Object... objects) {
this.objects = objects;
}
public String toString() {
return shortClassName(this) + "(" + objects + ")";
}
public Object[] _fieldsToList() {
return new Object[] { objects };
}
}
abstract static public class DynAvorDemonstrator extends DynNewBot2 {
public void start() {
start2();
super.start();
}
public void start2() {
botName = heading = "AVOR Demonstrator";
adminName = "AVOR Demonstrator Admin";
showTalkToBotLink = true;
alwaysRedirectToHttps = true;
}
public Object html2(IWebRequest req) {
String uri = addSlash(req.uri());
Matches m = new Matches();
if (startsWith(uri, "/uiDemonstrator/", m))
return serveUIDemonstrator(webRequest_modifyURI(addSlashPrefix(m.rest()), req));
return super.html2(req);
}
public HCRUD_Concepts crudData(Class c, Req req) {
HCRUD_Concepts cc = super.crudData(c, req);
cc.verbose = true;
return cc;
}
public List crudClasses(Req req) {
List l = super.crudClasses(req);
return req.masterAuthed ? listPlus(l, Avatar.class) : l;
}
public void makeFramer(Req req) {
super.makeFramer(req);
req.framer.addNavItem(appendQueryToURL(baseLink + "/uiDemonstrator", "cookie", "test_" + aRandomID()), "UI Demonstrator", "targetBlank", true);
}
public Object serveUIDemonstrator(IWebRequest req) {
String cookie = or2(req.params().get("cookie"), "test_" + aRandomID());
return hhtml(hhead_title("UI Demonstrator [" + botName + "]") + hframeset_cols("*,*", hframe("botFrame", appendQueryToURL(baseLink + "/demo", "_autoOpenBot", 1, "cookie", cookie)) + hframeset_rows("*,*", hframe("botAdminFrame", baseLink + "/crud/Conversation") + hframe("botThoughtsFrame", appendQueryToURL(baseLink + "/thoughts", "cookie", cookie)))));
}
}
static public interface IWebRequest {
public String uri();
public Map params();
public Map headers();
public Map files();
default public String clientIP() {
return unnull(getClientIPFromHeaders(headers()));
}
default public String getHeader(String name) {
return mapGet(headers(), name);
}
default public String domain() {
return getHeader("host");
}
public String cookie();
public boolean isHttps();
default public void noSpam() {
}
default public String get(String param) {
return mapGet(params(), param);
}
default public String userAgent() {
return getHeader("user-agent");
}
}
static public interface IFieldsToList {
public Object[] _fieldsToList();
}
static public class Worker extends Concept {
public String loginName, displayName;
public boolean available = false;
public long lastOnline;
public Ref image = new Ref();
static public String _fieldOrder = "loginName displayName";
public String renderAsHTML() {
return htmlEncode2(loginName + " (display name: " + displayName + ")");
}
}
abstract static public class DynNewBot2 extends DynPrintLogAndEnabled {
public void setEleu(Object eleu) {
mainBot = eleu;
}
public int maxRefsToShow = 5;
volatile public long requestsServed;
transient public String templateID = "#1029809";
static public String cssID = "#1029808";
transient public String botName = "DynNewBot2";
transient public String heading = "DynNewBot2";
transient public String adminName = "DynNewBot2 Admin";
transient public String botImageID = "#1102935";
transient public String userImageID = "#1102803";
transient public String chatHeaderImageID = "#1102802";
transient public String timeZone = ukTimeZone_string();
transient public String baseLink = "";
transient public boolean newDesign = true;
transient public boolean ariaLiveTrick = false;
transient public boolean ariaLiveTrick2 = true;
public class WorkerChat {
public int workerLongPollTick = 200;
public int workerLongPollMaxWait = 1000 * 30;
public long lastWorkerRequested;
public String mainAdminLink = "/";
public Object html(DynNewBot2.Req req) {
Map params = req.params;
String uri = req.uri, uri2 = appendSlash(uri);
boolean requestAuthed = req.auth != null;
Conversation conv = req.conv;
if (startsWith(uri2, "/worker/")) {
if (!req.webRequest.isHttps())
return subBot_serveRedirect("https://" + req.webRequest.domain() + req.uri + htmlQuery(req.params));
if (!requestAuthed)
return serveAuthForm(params.get("uri"));
if (nempty(params.get("turnBotOn")))
conv.turnBotOn();
return serveWorkerPage(req);
}
return null;
}
public String serveWorkerPage(DynNewBot2.Req req) {
AuthedDialogID auth = req.auth;
Conversation conv = req.conv;
String uri = req.uri;
Map params = req.params;
String cookie = conv.cookie;
String uri2 = afterLastSlash(uri);
if (eq(uri2, "availableWorkers"))
return "Available workers: " + or2(joinWithComma(map(workersAvailable(), w -> w.renderAsHTML())), "-");
if (nempty(params.get("workerLogOut")))
cset(auth, "loggedIn", null);
if (auth.loggedIn != null && nempty(params.get("workerAvailableBox")))
if (cset_trueIfChanged(auth.loggedIn, "available", nempty(params.get("workerAvailable"))))
noteConversationChange();
if (nempty(params.get("acceptConversation"))) {
if (conv.worker == null) {
cset(conv, "worker", auth.loggedIn);
conv.turnBotOff();
}
}
String loginID = params.get("workerLogIn");
if (nempty(loginID))
cset(auth, "loggedIn", getConcept(Worker.class, parseLong(loginID)));
Map map = prependEmptyOptionForHSelect(mapToOrderedMap(conceptsSortedByFieldCI(Worker.class, "loginName"), w -> pair(w.id, w.loginName)));
if (auth.loggedIn == null)
return hsansserif() + p("You are not logged in as a worker") + hpostform("Log in as: " + hselect("workerLogIn", map, conceptID(auth.loggedIn)) + " " + hsubmit("OK"), "action", botMod().baseLink + "/worker");
if (eq(uri2, "conversation")) {
if (conv == null)
return "Conversation not found";
String onOffURL = botMod().baseLink + "/worker/botOnOff" + hquery("cookie", cookie) + "&on=";
return hsansserif() + loadJQuery() + hhidden("cookie", cookie) + hpostform(hhidden("cookie", cookie) + p(renderBotStatus(conv)) + p(conv.botOn ? hsubmit("Accept conversation", "name", "acceptConversation") : hsubmit("Turn bot back on", "name", "turnBotOn")), "action", botMod().baseLink + "/worker/innerFrameSet", "target", "innerFrameSet") + hscriptsrc(botMod().baseLink + "/script" + hquery("workerMode", 1, "cookie", conv.cookie));
}
if (eq(uri2, "conversations")) {
cset(auth.loggedIn, "lastOnline", now());
boolean poll = eq("1", params.get("poll"));
String content = "";
if (poll) {
long seenChange = parseLong(params.get("lastChange"));
vmBus_send("chatBot_startingWorkerPoll", mc(), conv);
long start = sysNow();
List msgs;
boolean first = true;
while (licensed() && sysNow() < start + workerLongPollMaxWait && lastConversationChange == seenChange) sleep(workerLongPollTick);
printVars_str("lastWorkerRequested", lastWorkerRequested, "seenChange", seenChange);
if (lastWorkerRequested > seenChange)
content = hscript("\r\n window.parent.parent.frames[0].sendDesktopNotification(\"A worker is requested!\", { action: function() { window.focus(); } });\r\n window.parent.parent.frames[0].playWorkerRequestedSound();\r\n ");
}
long pingThreshold = now() - activeConversationTimeout();
List convos = sortByCalculatedFieldDesc(c -> c.lastMsgTime(), conceptsWithFieldGreaterThan(Conversation.class, "lastPing", pingThreshold));
content += hhiddenWithID("lastConversationChange", lastConversationChange) + tag("table", hsimpletableheader("IP", "Country", "Bot/worker status", "Last change", "Last messages") + mapToLines(convos, c -> {
List lastMsgs = lastTwo(c.msgs);
String style = c == conv ? "background: #90EE90" : null;
String convLink = botMod().baseLink + "/worker/innerFrameSet" + hquery("cookie", c.cookie);
return tag("tr", td(ahref(convLink, c.ip, "target", "innerFrameSet")) + td(getCountry(c)) + td(renderBotStatus(c)) + td(renderHowLongAgo(c.lastMsgTime())) + td(ahref(convLink, hparagraphs(lambdaMap(__56 -> renderMsgForWorkerChat(__56), lastMsgs)), "target", "innerFrameSet", "style", "text-decoration: none")), "style", style);
}), "class", "responstable");
if (poll)
return content;
String incrementalURL = botMod().baseLink + "/worker/conversations?poll=1&lastChange=";
return hhtml(hhead(hsansserif() + loadJQuery() + hscript_clickableRows()) + hbody(h3(botName) + hpostform("Logged in as " + htmlEncode2(auth.loggedIn.loginName) + " (display name: " + htmlEncode2(auth.loggedIn.displayName) + ")" + hhidden("workerAvailableBox", 1) + " " + hcheckboxWithText("workerAvailable", "I am available", auth.loggedIn.available, "onclick", "form.submit()") + " " + hsubmit("Log out", "name", "workerLogOut"), "target", "innerFrameSet", "action", botMod().baseLink + "/worker/innerFrameSet") + p("Available workers: " + b(or2(joinWithComma(map(workersAvailable(), w -> w.displayName)), "none"))) + h3("Active conversations") + hcss_responstable() + hdivWithID("contentArea", content) + hscript("\r\n function poll_start() {\r\n var lastChange = $(\"#lastConversationChange\").val();\r\n if (!lastChange)\r\n setTimeout(poll_start, 1000);\r\n else {\r\n var url = \"#INCREMENTALURL#\" + lastChange;\r\n console.log(\"Loading \" + url);\r\n $.get(url, function(src) {\r\n if (src.match(/^ERROR/)) console.log(src);\r\n else {\r\n console.log(\"Loaded \" + src.length + \" chars\");\r\n $(\"#contentArea\").html(src);\r\n }\r\n setTimeout(poll_start, 1000);\r\n }, 'text')\r\n .fail(function() {\r\n console.log(\"Rescheduling after fail\");\r\n setTimeout(poll_start, 1000);\r\n });\r\n }\r\n }\r\n poll_start();\r\n ".replace("#INCREMENTALURL#", incrementalURL))));
}
if (eq(uri2, "notificationArea"))
return hhtml(hhead(hsansserif() + loadJQuery()) + hbody(hdesktopNotifications() + div(small(span(hbutton("CLICK HERE to enable notification sounds!"), "id", "enableSoundsBtn") + " | " + span("", "id", "notiStatus")), "style", "float: right") + hscript("\r\n function enableSounds() {\r\n document.removeEventListener('click', enableSounds);\r\n $(\"#enableSoundsBtn\").html(\"Notification sounds enabled\");\r\n }\r\n document.addEventListener('click', enableSounds);\r\n \r\n if (window.workerRequestedSound == null) {\r\n console.log(\"Loading worker requested sound\");\r\n window.workerRequestedSound = new Audio(\"https://botcompany.de/files/1400404/worker-requested.mp3\");\r\n }\r\n \r\n function playWorkerRequestedSound() {\r\n console.log(\"Playing worker requested sound\");\r\n window.workerRequestedSound.play();\r\n }\r\n window.playWorkerRequestedSound = playWorkerRequestedSound;\r\n\r\n ")));
if (eq(uri2, "innerFrameSet"))
return hhtml(hhead_title("Worker Chat [" + auth.loggedIn.loginName + "]") + hframeset_cols("*,*", tag("frame", "", "name", "conversations", "src", botMod().baseLink + "/worker/conversations" + hquery("cookie", cookie)) + tag("frame", "", "name", "conversation", "src", conv == null ? null : botMod().baseLink + "/worker/conversation" + hquery("cookie", cookie))));
return hhtml(hhead_title("Worker Chat [" + auth.loggedIn.loginName + "]") + hframeset_rows("50,*", tag("frame", "", "name", "notificationArea", "src", botMod().baseLink + "/worker/notificationArea") + tag("frame", "", "name", "innerFrameSet", "src", conv == null ? null : botMod().baseLink + "/worker/innerFrameSet" + hquery("cookie", cookie))));
}
public String renderMsgForWorkerChat(Msg msg) {
return (msg.fromWorker != null ? htmlEncode2(msg.fromWorker.displayName) : msg.fromUser ? "User" : "Bot") + ": " + b(htmlEncode2If(shouldHtmlEncodeMsg(msg), msg.text));
}
public Collection workersAvailable() {
long timestamp = now() - workerLongPollMaxWait - 10000;
return filter(list(Worker.class), w -> w.available && w.lastOnline >= timestamp);
}
public boolean anyWorkersAvailable() {
return nempty(workersAvailable());
}
public String renderBotStatus(Conversation conv) {
return "Bot is " + b(conv.botOn ? "on" : "off") + "
" + "Assigned worker: " + b(conv.worker == null ? "none" : conv.worker.displayName);
}
}
transient public WorkerChat workerChat = new WorkerChat();
transient public ReliableSingleThread rstBotActions = dm_rst(this, new Runnable() {
public void run() {
try {
botActions();
} catch (Exception __e) {
throw rethrow(__e);
}
}
public String toString() {
return "botActions();";
}
});
transient public String defaultHeaderColorLeft = "#2a27da";
transient public String defaultHeaderColorRight = "#00ccff";
transient public boolean enableUsers = false;
transient public boolean useWebSockets = false;
transient public boolean showRegisterLink = false;
transient public boolean showTalkToBotLink = false;
transient public boolean alwaysRedirectToHttps = false;
transient public boolean redirectOnLogout = false;
transient public boolean showFullErrors = false;
transient public boolean lockWhileDoingBotActions = false;
transient public boolean standardButtonsAsSymbols = false;
transient public boolean enableVars = false;
transient public boolean enableAvatars = false;
transient public boolean enableRandomActions = false;
transient public boolean recordExecutionsAndInputs = true;
transient public boolean phoneNumberSpecialInputField = true;
transient public boolean enableRadioButtons = false;
transient public boolean newDialogAfterWindowClosed = false;
transient public boolean showJoiningConversation = false;
transient public boolean quickRadioButtons = false;
transient public boolean useDynamicComboBoxes = false;
transient public boolean prefixPrintsWithConvID = true;
transient public boolean enableUndoStates = false;
transient public boolean showCRUDToEveryone = false;
transient public boolean showOnlySelectedObject = false;
transient public boolean storeBaseClassesInStructure = false;
transient public boolean botDisabled = false;
transient public boolean useBotNameAsModuleName = true;
transient public boolean showMailSenderInfo = true;
public String mailSenderInfo;
transient public int typingTimeshift = 2000;
transient public ThreadLocal currentReq = new ThreadLocal();
transient volatile public Scorer consistencyCheckResults;
transient public Lock statsLock = lock();
transient public Map specialPurposes = litcimap("bad email address", "Please enter a valid e-mail address", "bad phone number", "Please enter a valid phone number");
transient public String nameOfReferencesColumn = "Referenced by";
public void start() {
super.start();
if (useBotNameAsModuleName)
dm_setModuleName(botName);
dm_assertFirstSibling();
concepts_setUnlistedByDefault(true);
standardTimeZone();
standardTimeZone_name = timeZone;
print("DB program ID: " + dbProgramID());
realPW();
pWebChatBot();
dm_doEvery(60.0, new Runnable() {
public void run() {
try {
cleanConversations();
} catch (Exception __e) {
throw rethrow(__e);
}
}
public String toString() {
return "cleanConversations();";
}
});
rstBotActions.trigger();
}
public void indexAllLinkableClasses() {
ensureConceptClassesAreIndexed(allLinkableClasses());
}
public JComponent visualize() {
JComponent _c = super.visualize();
addToControlArea(jPopDownButton_noText(popDownButtonEntries()));
return _c;
}
public Object[] popDownButtonEntries() {
return litobjectarray("Show/edit master password...", runnableThread(new Runnable() {
public void run() {
try {
AutoCloseable __22 = enter();
try {
editMasterPassword();
} finally {
_close(__22);
}
} catch (Exception __e) {
throw rethrow(__e);
}
}
public String toString() {
return "temp enter(); editMasterPassword();";
}
}), !showMailSenderInfo ? null : "Show/edit mail sender info...", runnableThread(new Runnable() {
public void run() {
try {
AutoCloseable __23 = enter();
try {
editMailSenderInfo();
} finally {
_close(__23);
}
} catch (Exception __e) {
throw rethrow(__e);
}
}
public String toString() {
return "temp enter(); editMailSenderInfo();";
}
}));
}
static public class Req {
public IWebRequest webRequest;
public String uri;
public Map params;
public AuthedDialogID auth;
public Domain authDomainObj;
public String authDomain;
public HTMLFramer1 framer;
public boolean masterAuthed = false;
public Conversation conv;
public String subURI;
public String uri() {
return uri;
}
public Map params() {
return params;
}
public boolean requestAuthed() {
return auth != null;
}
public String get(String param) {
return webRequest.get(param);
}
public void markNoSpam() {
webRequest.noSpam();
}
public void noSpam() {
markNoSpam();
}
public String uriWithParams() {
return appendParamsToURL(uri, params);
}
public HTMLFramer1 framer() {
return framer;
}
}
public boolean calcMasterAuthed(Req req) {
return req != null && req.auth != null && req.auth.master;
}
public Object html(IWebRequest request) {
AutoCloseable __18 = enter();
try {
vmBus_logMethodCall("html", "this", this, "request", request);
try {
return html2(request);
} catch (Throwable e) {
printStackTrace(e);
return subBot_serve500(showFullErrors || calcMasterAuthed(currentReq.get()) ? getStackTrace(e) : "Error.");
} finally {
currentReq.set(null);
}
} finally {
_close(__18);
}
}
public void requestServed() {
}
public Object html2(IWebRequest request) {
htmlencode_forParams_useV2();
{
Lock __2 = statsLock;
lock(__2);
try {
requestsServed++;
change();
requestServed();
vmBus_logMethodCall("html", "this", this, "requestsServed", requestsServed);
} finally {
unlock(__2);
}
}
Req req = webRequestToReq(request);
if (alwaysRedirectToHttps) {
Object __10 = redirectToHttps(req);
if (__10 != null)
return __10;
}
vmBus_logMethodCall("html", "Calling html3");
return html3(req);
}
public Req webRequestToReq(IWebRequest request) {
Req req = new Req();
req.webRequest = request;
req.uri = request.uri();
req.params = request.params();
return req;
}
public Object html3(Req req) {
IWebRequest request = req.webRequest;
String uri = req.uri;
Map params = req.params;
if (eq(params.get("_newConvCookie"), "1"))
return hrefresh(appendQueryToURL(req.uri, mapPlus(mapMinus(req.params, "_newConvCookie"), "cookie", "test_" + aGlobalID())));
String cookie = request.cookie();
boolean workerMode = nempty(params.get("workerMode")) || startsWith(uri, "/worker");
String domain = request.domain(), _domain = domain;
saveDeliveredDomain(domain);
Domain domainObj = findDomainObj(domain);
String convCookie = params.get("cookie");
Conversation conv = botDisabled ? null : isRequestFromBot(req) ? null : nempty(convCookie) ? getConv(convCookie) : nempty(cookie) ? getConv(cookie) : null;
req.conv = conv;
AutoCloseable tempThing = conv == null || !prefixPrintsWithConvID ? null : temp_printPrefix("Conv " + conv.cookie + ": ");
AutoCloseable __19 = tempThing;
try {
currentReq.set(req);
String botConfig = params.get("_botConfig");
Map botConfigParams = decodeURIParams(botConfig);
String simulatedDomain = botConfigParams.get("domain");
Domain domainObj2 = nempty(simulatedDomain) ? findDomainObj(simulatedDomain) : domainObj;
if (nempty(botConfigParams))
cset(conv, "botConfig", botConfigParams);
if (conv != null && !workerMode)
if (cset_trueIfChanged(conv, "ip", request.clientIP(), "domain", domain, "domainObj", domainObj2)) {
calcCountry(conv);
initAvatar(conv);
}
{
Object __11 = handleAuth(req, cookie);
if (__11 != null)
return __11;
}
Matches m = new Matches();
if (startsWith(uri, "/worker-image/", m)) {
long id = parseLong(m.rest());
return subBot_serveFile_maxCache(workerImageFile(id), "image/jpeg");
}
if (startsWith(uri, "/uploaded-image/", m)) {
long id = parseLong(m.rest());
UploadedImage img = getConcept(UploadedImage.class, id);
return img == null ? serve404() : subBot_serveFile_maxCache(img.imageFile(), "image/jpeg");
}
if (startsWith(uri, "/uploaded-sound/", m)) {
long id = parseLong(m.rest());
UploadedSound sound = getConcept(UploadedSound.class, id);
return sound == null ? serve404() : subBot_serveFile_maxCache(sound.soundFile(), mp3mimeType());
}
if (startsWith(uri, "/uploaded-file/", m)) {
long id = parseLong(dropAfterSlash(m.rest()));
UploadedFile f = getConcept(UploadedFile.class, id);
return f == null ? serve404() : subBot_serveFile_maxCache(f.theFile(), or2(params.get("ct"), or2(trim(f.mimeType), binaryMimeType())));
}
AuthedDialogID auth = authObject(cookie);
if (eq(params.get("logout"), "1")) {
cdelete(auth);
if (redirectOnLogout)
return hrefresh(req.uri);
auth = null;
}
fillReqAuthFromCookie(req, cookie, auth);
boolean requestAuthed = req.auth != null;
boolean masterAuthed = req.masterAuthed;
Domain authDomainObj = req.authDomainObj;
String authDomain = req.authDomain;
if (requestAuthed)
req.markNoSpam();
{
Object __12 = serve2(req);
if (__12 != null)
return __12;
}
makeFramer(req);
HTMLFramer1 framer = req.framer;
if (requestAuthed || showCRUDToEveryone) {
Object __13 = serveCRUD(req);
if (__13 != null)
return __13;
}
if (!requestAuthed && settings().talkToBotOnlyWithAuth)
return serveAuthForm(params.get("uri"));
if (eq(uri, "/emoji-picker/index.js"))
return withHeader(subBot_maxCacheHeaders(serveInputStream(bufferedFileInputStream(loadLibrary("#1400436")), "text/javascript")));
if (eq(uri, "/emoji-picker-test"))
return loadSnippet("#1029870");
if (eq(uri, "/logs")) {
if (!masterAuthed)
return serveAuthForm(rawLink(uri));
return webChatBotLogsHTML2(rawLink(uri), params);
}
if (eq(uri, "/refchecker")) {
if (!masterAuthed)
return serveAuthForm(rawLink(uri));
ConceptsRefChecker refChecker = new ConceptsRefChecker(db_mainConcepts());
List errors = refChecker.run();
if (eq(params.get("fix"), "1"))
return serveText(refChecker.fixAll());
else
return serveText(jsonEncode_breakAtLevels(2, litorderedmap("errors", allToString(errors))));
}
if (eq(uri, "/backupDBNow")) {
if (!masterAuthed)
return serveAuthForm(rawLink(uri));
return serveText("Backed up DB as " + fileInfo(backupConceptsNow()));
}
if (eq(uri, "/auth-only")) {
if (!requestAuthed)
return serveAuthForm(params.get("uri"));
return "";
}
if (eq(uri, "/leads-api"))
return serveLeadsAPI(request);
if (workerChat != null) {
Object __14 = workerChat.html(req);
if (__14 != null)
return __14;
}
String message = trim(params.get("btn"));
if (empty(message))
message = trim(params.get("message"));
if (match("new dialog", message)) {
Lock __3 = dbLock();
lock(__3);
try {
conv.newDialog();
message = null;
} finally {
unlock(__3);
}
}
if (eqic(message, "!toggle notifications")) {
cset(conv, "notificationsOn", !conv.notificationsOn);
message = null;
}
if (eqic(message, "!undo states")) {
conv.add(new Msg(false, n2(conv.undoStates, "undo state")));
message = null;
}
this.conv.set(conv);
if (nempty(message) && !lastUserMessageWas(conv, message)) {
Lock __4 = dbLock();
lock(__4);
try {
print("Adding message: " + message);
possiblyTriggerNewDialog(conv);
if (workerMode) {
Msg msg = new Msg(false, message);
msg.fromWorker = auth.loggedIn;
conv.add(msg);
} else {
conv.add(new Msg(true, message));
addScheduledAction(new OnUserMessage(conv));
}
} finally {
unlock(__4);
}
}
String testMode = params.get("testMode");
if (nempty(testMode)) {
print("Setting testMode", testMode);
cset(conv, "testMode", eq("1", testMode));
}
if (eq(uri, "/msg"))
return withHeader("OK");
if (eq(uri, "/typing")) {
if (workerMode) {
conv.botTyping = now();
print(conv.botTyping + " Bot typing in: " + conv.cookie);
} else {
conv.userTyping = now();
print(conv.userTyping + " User typing in: " + conv.cookie);
}
return withHeader("OK");
}
if (eq(uri, "/renderMessages")) {
long msgTime = parseLong(params.get("msgTime"));
List msgs = conv.allMsgs();
if (msgTime != 0)
msgs = filter(msgs, msg -> msg.time == msgTime);
StringBuilder buf = new StringBuilder();
renderMessages(conv, buf, msgs, msg -> false);
return hhtml_title_body(nMessages(msgs), hstylesheetsrc(cssURL()) + p(nMessages(msgs) + " found") + buf);
}
if (eq(uri, "/incremental")) {
if (newDialogAfterWindowClosed && !conv.isActive()) {
print("Clearing conversation, timed out");
Lock __5 = dbLock();
lock(__5);
try {
conv.newDialog();
} finally {
unlock(__5);
}
}
long start = sysNow(), start2 = now();
print("start2", start2);
cset(conv, "lastPing", now());
possiblyTriggerNewDialog(conv);
int a = parseInt(params.get("a"));
int reloadCounter = conv.reloadCounter;
List msgs;
boolean first = true;
int timeout = toInt(req.params.get("timeout"));
long endTime = start + (timeout <= 0 || timeout > longPollMaxWait / 1000 ? longPollMaxWait : timeout * 1000L);
while (licensed() && sysNow() < endTime) {
int as = conv.archiveSize();
msgs = cloneSubList(conv.msgs, a - as);
boolean reloadTriggered = conv.reloadCounter > reloadCounter;
boolean actuallyNewDialog = a < as;
boolean newDialog = actuallyNewDialog || reloadTriggered;
if (newDialog)
msgs = cloneList(conv.msgs);
long typing = workerMode ? conv.userTyping : conv.botTyping;
boolean otherPartyTyping = typing >= start2 - typingTimeshift;
boolean anyEvent = nempty(msgs) || newDialog || otherPartyTyping;
if (!anyEvent) {
if (first) {
first = false;
}
sleep(longPollTick);
} else {
if (eq(req.params.get("json"), "1"))
return serveJSON_breakAtLevels(2, litorderedmap("n", conv.allCount(), "newDialog", trueOrNull(newDialog), "otherPartyTyping", trueOrNull(otherPartyTyping), "msgs", map(msgs, msg -> litorderedmap("time", msg.time, "fromUser", msg.fromUser, "fromWorker", msg.fromWorker == null ? null : msg.fromWorker.displayName, "text", msg.text, "labels", msg.labels))));
StringBuilder buf = new StringBuilder();
if (newDialog) {
String l = or2_trim(domainObj2.headerColorLeft, defaultDomain().headerColorLeft, defaultHeaderColorLeft), r = or2_trim(domainObj2.headerColorRight, defaultDomain().headerColorRight, defaultHeaderColorRight);
buf.append(hcss(".chat_header { background: linear-gradient(135deg, " + hexColorToCSSRGB(l) + " 0%, " + hexColorToCSSRGB(r) + " 100%); }"));
buf.append(hscript("$('#chatBot_notiToggleText').text(" + jsQuote("Turn " + (conv.notificationsOn ? "off" : "on") + " notifications") + ");"));
if (showJoiningConversation) {
buf.append(hscript("$('#otherSideTyping .joining').html(" + jsQuote(nameOfBotSide(conv) + " now joining conversation...") + ");" + "setTimeout(function() { $('#otherSideTyping .joining').html(''); }, 5000);"));
}
}
if (otherPartyTyping) {
buf.append(hscript("showTyping(" + jsQuote(conv.botImg()) + ");"));
}
renderMessages(conv, buf, msgs);
if (ariaLiveTrick2 && !workerMode) {
Msg msg = lastBotMsg(msgs);
if (msg != null) {
String author = msg.fromWorker != null ? htmlEncode2(msg.fromWorker.displayName) : botName;
buf.append(hscript("$(\"#screenreadertrick\").html(" + jsQuote(author + " says: " + msg.text) + ");"));
}
}
if (a != 0 && anyInterestingMessages(msgs, workerMode))
buf.append(hscript(stringIf(conv.notificationsOn, "window.playChatNotification();\n") + "window.setTitleStatus(" + jsQuote((workerMode ? "User" : botName) + " says…") + ");"));
String html = str(buf);
return withHeader("\n" + html);
}
}
return withHeader("");
}
if (eqOneOf(uri, "/script", "/demo")) {
Lock __6 = dbLock();
lock(__6);
try {
String myTemplateID = templateID;
String templateIDParam = req.params.get("templateID");
if (nempty(templateIDParam) && allowedTemplateID(templateIDParam))
myTemplateID = templateIDParam;
String html = loadSnippet_cached(myTemplateID);
String botLayout = req.params.get("botLayout");
String layout = or2(botLayout, defaultBotLayout());
html = modifyTemplateBeforeDelivery(html, req);
String heading = or2(headingForReq(req), or2(trim(domainObj2.botName), this.heading));
String botImg = botImageForDomain(domainObj);
UploadedSound sound = settings().notificationSound.get();
String notificationSound = sound != null ? sound.soundURL() : defaultNotificationSound();
String miscParam = workerMode ? "workerMode=1&" : "";
if (nempty(botLayout))
miscParam += "botLayout=" + urlencode(botLayout) + "&";
String incrementalURL = baseLink + "/incremental?" + miscParam + "a=";
String typingURL = baseLink + "/typing?" + miscParam;
String msgURL = baseLink + "/msg?" + miscParam + "message=";
if (eqic(layout, "sahil")) {
html = replaceDollarVars(html, "incrementalURL", incrementalURL, "typingURL", typingURL, "msgURL", msgURL, "n", 0, "notificationSound", notificationSound, "workerMode", workerMode, "heading", heading, "botImg", botImg);
} else {
String langlinks = "";
if (html.contains(langlinks))
html = html.replace(langlinks, ahref(rawLink("eng"), "English") + " | " + ahref(rawLink("deu"), "German"));
html = html.replace("#COUNTRY#", lower(conv.country));
html = html.replace("#BOTIMG#", botImg);
html = html.replace("#N#", "0");
html = html.replace("#INCREMENTALURL#", incrementalURL);
html = html.replace("#MSGURL#", msgURL);
html = html.replace("#TYPINGURL#", typingURL);
html = html.replace("#CSS_ID#", psI_str(cssID));
if (ariaLiveTrick || ariaLiveTrick2)
html = html.replace("aria-live=\"polite\">", ">");
html = html.replace("#OTHERSIDE#", workerMode ? "User" : "Representative");
if (nempty(params.get("debug")))
html = html.replace("var showActions = false;", "var showActions = true;");
html = html.replace("#AUTOOPEN#", jsBool(workerMode || eq(params.get("_autoOpenBot"), "1") || botAutoOpen(domainObj2)));
html = html.replace("#BOT_ON#", jsBool(botOn() || eq(uri, "/demo")));
html = html.replace("$HEADING", heading);
html = html.replace("#WORKERMODE", jsBool(workerMode));
html = html.replace("#NOTIFICATIONSOUND#", notificationSound);
html = html.replace("", "");
html = hreplaceTitle(html, heading);
}
if (eq(uri, "/demo"))
return hhtml(hhead(htitle(heading) + loadJQuery2()) + hbody(hjavascript(html)));
else
return withHeader(subBot_serveJavaScript(html));
} finally {
unlock(__6);
}
}
{
Object __15 = serveOtherPage(req);
if (__15 != null)
return __15;
}
if (eq(uri, "/")) {
Object __16 = serveHomePage();
if (__16 != null)
return __16;
}
String uri2 = dropSlashPrefix(uri);
if (!startsWith(uri, "/crud/") && nempty(uri2)) {
UploadedFile fileToServe = conceptWhere(UploadedFile.class, "liveURI", urldecode(uri2));
if (fileToServe != null)
return subBot_serveFile(fileToServe.theFile(), nempty(fileToServe.mimeType) ? fileToServe.mimeType : guessMimeTypeFromFileName(afterLastSlash(fileToServe.liveURI)));
}
if (!requestAuthed)
return serveAuthForm(params.get("uri"));
if (masterAuthed && eq(uri, "/dialogTree")) {
BotStep step = getConcept(BotStep.class, toLong(params.get("stepID")));
if (step == null)
return serve404("Step not found");
return hhtml_head_title_body("Dialog Tree for " + step, hmobilefix() + hsansserif() + h2("Dialog Tree") + hcss_linkColorInherit() + hcss("\r\n .dialogTree li { margin-top: 0.8em; }\r\n ") + renderDialogTree(step));
}
if (eq(uri, "/thoughts"))
return serveThoughts(req);
if (masterAuthed && eq(uri, "/search"))
return serveSearch(req);
if (eq(uri, "/leads-csv")) {
String text = leadsToCSV(conceptsWhere(Lead.class, mapToParams(filtersForClass(Lead.class, req))));
String name = "bot-leads" + (authDomainObj == null ? "" : "-" + replace(str(authDomainObj), "/", "-")) + "-" + ymd_minus_hm() + ".csv";
return serveCSVWithFileName(name, text);
}
if (eq(uri, "/cleanConversations") && masterAuthed) {
cleanConversations();
return hrefresh(baseLink + "/crud/Conversation");
}
if (eq(uri, "/deleteDeliveredDomains") && masterAuthed) {
deleteDeliveredDomains();
return hrefresh(baseLink + "/crud/DeliveredDomain");
}
if (eq(uri, "/emojis")) {
framer.title = "Emoji List";
framer.contents.add(htmlTable2(map(emojiShortNameMap(), (code, emoji) -> litorderedmap("Shortcode", code, "Emoji", emoji))));
}
if (eq(uri, "/embedCode")) {
String goDaddyEmbedCode = "";
framer.title = "Embed Code";
framer.contents.add(h2("Chat bot embed code") + (empty(goDaddyEmbedCode) ? "" : h3("GoDaddy Site Builder") + p("Add an HTML box with this code:") + pre(htmlEncode2(goDaddyEmbedCode)) + h3("Other")) + p("Add this code in front of your " + tt(htmlEncode2("