// Path: srcc/yjs/lang/compiler/NanoHTTPD.java
// public enum Status implements IStatus {
//     SWITCH_PROTOCOL(101, "Switching Protocols"), OK(200, "OK"), CREATED(201, "Created"), ACCEPTED(202, "Accepted"), NO_CONTENT(204, "No Content"), PARTIAL_CONTENT(206, "Partial Content"), REDIRECT(301,
//         "Moved Permanently"), NOT_MODIFIED(304, "Not Modified"), BAD_REQUEST(400, "Bad Request"), UNAUTHORIZED(401,
//         "Unauthorized"), FORBIDDEN(403, "Forbidden"), NOT_FOUND(404, "Not Found"), METHOD_NOT_ALLOWED(405, "Method Not Allowed"), RANGE_NOT_SATISFIABLE(416,
//         "Requested Range Not Satisfiable"), INTERNAL_ERROR(500, "Internal Server Error");
//     private final int requestStatus;
//     private final String description;
// 
//     Status(int requestStatus, String description) {
//         this.requestStatus = requestStatus;
//         this.description = description;
//     }
// 
//     @Override
//     public int getRequestStatus() {
//         return this.requestStatus;
//     }
// 
//     @Override
//     public String getDescription() {
//         return "" + this.requestStatus + " " + description;
//     }
// }


import java.awt.Event;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.ProcessBuilder.Redirect;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.StandardWatchEventKinds;
import java.nio.file.WatchEvent;
import java.nio.file.WatchEvent.Kind;
import java.nio.file.WatchKey;
import java.nio.file.WatchService;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import yjs.lang.compiler.*;
import yjs.lang.compiler.NanoHTTPD.Response.Status;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import javax.script.SimpleScriptContext;
			
		}
	}
	
	public NanoHTTPD createServer(int port){
		YJSServer server = new YJSServer(port);
		return server;
	}
	
	private class YJSServer extends NanoHTTPD{
		private final ConcurrentHashMap<String, ReplSession> sessions = 
			new ConcurrentHashMap<>();
	
		private final Timer timer = new Timer(true);
		private final int port;
		public YJSServer(int port) {
			super(port);
			this.port = port;
			timer.scheduleAtFixedRate(new TimerTask() {
				public void run() {
					long cur = System.currentTimeMillis() - 5 * 60 * 1000;
					for(ReplSession entr: sessions.values()){
						if(entr.lastUsedTime.get() < cur){
							sessions.remove(entr.id);
						}
					}
				}
			}, 0, 5 * 60* 1000); //every 5 min
		}
		
// Path: srcc/yjs/lang/compiler/NanoHTTPD.java
// public enum Status implements IStatus {
//     SWITCH_PROTOCOL(101, "Switching Protocols"), OK(200, "OK"), CREATED(201, "Created"), ACCEPTED(202, "Accepted"), NO_CONTENT(204, "No Content"), PARTIAL_CONTENT(206, "Partial Content"), REDIRECT(301,
//         "Moved Permanently"), NOT_MODIFIED(304, "Not Modified"), BAD_REQUEST(400, "Bad Request"), UNAUTHORIZED(401,
//         "Unauthorized"), FORBIDDEN(403, "Forbidden"), NOT_FOUND(404, "Not Found"), METHOD_NOT_ALLOWED(405, "Method Not Allowed"), RANGE_NOT_SATISFIABLE(416,
//         "Requested Range Not Satisfiable"), INTERNAL_ERROR(500, "Internal Server Error");
//     private final int requestStatus;
//     private final String description;
// 
//     Status(int requestStatus, String description) {
//         this.requestStatus = requestStatus;
//         this.description = description;
//     }
// 
//     @Override
//     public int getRequestStatus() {
//         return this.requestStatus;
//     }
// 
//     @Override
//     public String getDescription() {
//         return "" + this.requestStatus + " " + description;
//     }
// }


// Path: srcc/yjs/lang/compiler/YJSMain.java
import java.awt.Event;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.ProcessBuilder.Redirect;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.StandardWatchEventKinds;
import java.nio.file.WatchEvent;
import java.nio.file.WatchEvent.Kind;
import java.nio.file.WatchKey;
import java.nio.file.WatchService;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import yjs.lang.compiler.*;
import yjs.lang.compiler.NanoHTTPD.Response.Status;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import javax.script.SimpleScriptContext;

			
		}
	}
	
	public NanoHTTPD createServer(int port){
		YJSServer server = new YJSServer(port);
		return server;
	}
	
	private class YJSServer extends NanoHTTPD{
		private final ConcurrentHashMap<String, ReplSession> sessions = 
			new ConcurrentHashMap<>();
	
		private final Timer timer = new Timer(true);
		private final int port;
		public YJSServer(int port) {
			super(port);
			this.port = port;
			timer.scheduleAtFixedRate(new TimerTask() {
				public void run() {
					long cur = System.currentTimeMillis() - 5 * 60 * 1000;
					for(ReplSession entr: sessions.values()){
						if(entr.lastUsedTime.get() < cur){
							sessions.remove(entr.id);
						}
					}
				}
			}, 0, 5 * 60* 1000); //every 5 min
		}
		
		private Response cors(IHTTPSession session, Status status, String mimeType, String txt) {