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 javax.swing.undo.UndoManager;
import javax.net.ssl.*;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import javax.imageio.metadata.*;
import javax.imageio.stream.*;
import java.text.SimpleDateFormat;
import java.text.NumberFormat;
import net.coobird.thumbnailator.Thumbnailator;
import java.awt.datatransfer.*;
import java.awt.dnd.*;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.DataFlavor;
import javax.swing.border.*;
import java.awt.datatransfer.StringSelection;
import javax.swing.event.AncestorListener;
import javax.swing.event.AncestorEvent;
import javax.swing.Timer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.text.*;
class main {
static class JavaEval extends DynPrintLog {
String expression;
boolean realEval = true;
transient boolean calculating;
transient Object value;
transient JTextArea taInput;
transient Throwable error;
transient JPanel babiesPanel;
void start() { super.start();
loadImage2("#1101447");
makeDependent_postProcess = new Runnable() { public void run() { try { updateBabySymbols();
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "updateBabySymbols();"; }};
dm_vmBus_onMessage("gcDone", new Runnable() { public void run() { try { updateBabySymbols();
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "updateBabySymbols();"; }});
doEvery(300.0, new Runnable() { public void run() { try { updateBabySymbols();
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "updateBabySymbols();"; }}); // just to be sure to updat eit sometimes
}
JComponent visualize() {
return centerAndSouthWithMargins(
jvsplit(
centerAndEastWithMarginInbetween(
onCtrlEnter(taInput = jEnableUndoRedo(typeWriterTextArea(expression)), runnableThread(new Runnable() { public void run() { try { evalIt();
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "evalIt();"; }})),
vstackWithSpacing(
jbutton("Fresh", runnableThread(new Runnable() { public void run() { try { refresh(); evalIt() ;
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "refresh(); evalIt()"; }})),
jbutton("Eval", runnableThread(new Runnable() { public void run() { try { evalIt();
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "evalIt();"; }})),
withToolTip("Don't interpret", dm_fieldCheckBox("Real", "realEval")))),
super.visualize()),
jScrollWithoutBorder(babiesPanel = leftAlignedLine()));
}
void refresh() {
call(dm_transpiler(), "refresh");
loadFunctions_clearCache();
print("Refreshed translator.");
}
void evalIt() {
if (calculating) return;
calculating = true;
AutoCloseable __0 = afterwards(new Runnable() { public void run() { try { calculating = false ;
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "calculating = false"; }}); try {
dm_javaEvalModule_doIt(gtt(taInput), realEval);
} finally { _close(__0); }}
void updateBabySymbols() { AutoCloseable __1 = enter(); try {
dm_q().add(new Runnable() { public void run() { try {
final int n = l(dependentClasses());
final BufferedImage img = scaleImageToWidth(loadImage2("#1101447"), 24);
{ swing(new Runnable() { public void run() { try {
removeAllComponents(babiesPanel);
for (int _repeat_2 = 0; _repeat_2 < n; _repeat_2++) {
babiesPanel.add(toolTip("You have made one cute little subprocess!", jimage(img)));
}
revalidate(babiesPanel);
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "removeAllComponents(babiesPanel);\r\n repeat n {\r\n babiesPanel...."; }}); }
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "final int n = l(dependentClasses());\r\n final BufferedImage img = scaleIm..."; }});
} finally { _close(__1); }}
}
static BufferedImage loadImage2(String snippetIDOrURL) {
return loadBufferedImage(snippetIDOrURL);
}
static BufferedImage loadImage2(File file) {
return loadBufferedImage(file);
}
static RuntimeException rethrow(Throwable t) {
if (t instanceof Error)
_handleError((Error) t);
throw t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t);
}
static AutoCloseable dm_vmBus_onMessage(final String msg, final VF1 onMessage) {
return dm_ownResource(vmBus_onMessage(msg, onMessage));
}
static AutoCloseable dm_vmBus_onMessage(String msg, final VF2 onMessage) {
return dm_ownResource(vmBus_onMessage(msg, onMessage));
}
static AutoCloseable dm_vmBus_onMessage(String msg, Runnable onMessage) {
return dm_ownResource(vmBus_onMessage(msg, onMessage));
}
// firstDelay = delay
static FixedRateTimer doEvery(long delay, final Object r) {
return doEvery(delay, delay, r);
}
static FixedRateTimer doEvery(long delay, long firstDelay, final Object r) {
FixedRateTimer timer = new FixedRateTimer(shorten(programID() + ": " + r, 80));
timer.scheduleAtFixedRate(smartTimerTask(r, timer, toInt(delay)), toInt(firstDelay), toInt(delay));
return timer;
}
// reversed argument order for fun
static FixedRateTimer doEvery(double initialSeconds, double delaySeconds, final Object r) {
return doEvery(toMS(delaySeconds), toMS(initialSeconds), r);
}
static FixedRateTimer doEvery(double delaySeconds, final Object r) {
return doEvery(toMS(delaySeconds), r);
}
static JPanel centerAndSouthWithMargins(Component c, Component s) {
return applyDefaultMargin(centerAndSouth(c, withTopMargin(s)));
}
static JSplitPane jvsplit(Component n, Component s) {
return jvsplit(n, s, 0.5);
}
static JSplitPane jvsplit(Component n, Component s, double splitPoint, int delay) {
// delay now ignored
return jvsplit(n, s, splitPoint);
}
static JSplitPane jvsplit(Component n, Component s, double splitPoint) {
return setSplitPaneOnFirstShowing(
swingNu(JSplitPane.class, JSplitPane.VERTICAL_SPLIT, wrap(n), wrap(s)),
splitPoint);
}
static JPanel centerAndEastWithMarginInbetween(Component c, final Component e) {
return centerAndEast(c, withLeftMargin(e));
}
static A onCtrlEnter(final A c, final Object action) {
addKeyListener(c, ctrlEnterKeyListener(action));
return c;
}
static A jEnableUndoRedo(A textcomp) {
return jenableUndoRedo(textcomp);
}
static JTextArea typeWriterTextArea() {
return newTypeWriterTextArea();
}
static JTextArea typeWriterTextArea(String text) {
return newTypeWriterTextArea(text);
}
static Runnable runnableThread(final Runnable r) {
return new Runnable() { public void run() { try { startThread(r) ;
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "startThread(r)"; }};
}
static int vstackWithSpacing_default = 10;
static JPanel vstackWithSpacing(final List parts) {
return vstackWithSpacing(parts, vstackWithSpacing_default);
}
static JPanel vstackWithSpacing(final List parts, final int spacing) {
return swing(new F0() { JPanel get() { try {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.weightx = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.insets = new Insets(spacing/2, 0, spacing/2, 0); // well...
smartAddWithLayout(panel, gbc, toObjectArray(parts));
//gbc = (GridBagConstraints) gbc.clone();
//gbc.fill = GridBagConstraints.BOTH;
gbc.weighty = 1;
gbc.insets = new Insets(0, 0, 0, 0);
panel.add(jrigid(), gbc);
return panel;
} catch (Exception __e) { throw rethrow(__e); } }
public String toString() { return "JPanel panel = new JPanel(new GridBagLayout);\r\n new GridBagConstraints gbc..."; }});
}
static JPanel vstackWithSpacing(Component... parts) {
return vstackWithSpacing(asList(parts), vstackWithSpacing_default);
}
static JButton jbutton(String text, Object action) {
return newButton(text, action);
}
// button without action
static JButton jbutton(String text) {
return newButton(text, null);
}
/*static JButton jbutton(BufferedImage img, O action) {
ret setButtonImage(img, jbutton("", action));
}*/
static JButton jbutton(Action action) {
return swingNu(JButton.class, action);
}
static A withToolTip(A c, final Object toolTip) {
return setToolTipText(c, toolTip);
}
static A withToolTip(Object toolTip, A c) {
return setToolTipText(toolTip, c);
}
static JCheckBox dm_fieldCheckBox(String field) {
return dm_fieldCheckBox(humanizeFormLabel(field), field);
}
static JCheckBox dm_fieldCheckBox(String text, String field) {
// magic parameter swap :)
if (isIdentifier(text) && !isIdentifier(field)) { String temp = field; field = text; text = temp; }
return jLiveValueCheckBox(text, dm_fieldLiveValue(field));
}
static JScrollPane jScrollWithoutBorder(final Component c) {
return setMargin(0, jscroll(c));
}
static JPanel leftAlignedLine(Component... components) {
return jline(components);
}
static JPanel leftAlignedLine(List components) {
return jline(components);
}
static A call(Object o) {
return (A) callF(o);
}
// varargs assignment fixer for a single string array argument
static A call(Object o, String method, String[] arg) {
return call(o, method, new Object[] {arg});
}
static A call(Object o, String method, Object... args) {
return (A) call_cached(o, method, args);
}
static Object dm_transpiler() {
return dm_getModule(dm_requireModule("#1017065/Transpiler"));
}
static void loadFunctions_clearCache() {
call(getOptMC("loadFunctions_cache"), "clear");
}
static volatile StringBuffer local_log = new StringBuffer(); // not redirected
static volatile Appendable print_log = local_log; // might be redirected, e.g. to main bot
// in bytes - will cut to half that
static volatile int print_log_max = 1024*1024;
static volatile int local_log_max = 100*1024;
//static int print_maxLineLength = 0; // 0 = unset
static boolean print_silent; // total mute if set
static Object print_byThread_lock = new Object();
static volatile ThreadLocal