// Path: app/src/main/java/com/rai220/securityalarmbot/utils/L.java
// public class L {
//     private static final String TAG = "SecurityAlarmBot";
// 
//     private static final int MAX_LOG_SIZE = 10 * 1000;
//     private static final LinkedList<String> logs = new LinkedList<>();
// 
//     private L() {
//     }
// 
//     public static void e(String error) {
//         Log.e(TAG, error);
//         saveToLog("e", error);
//     }
// 
//     public static void e(Throwable th) {
//         e(null, th);
//     }
// 
//     public static void e(String message, Throwable th) {
//         Log.e(TAG, "", th);
//         StackTraceElement[] stack = th.getStackTrace();
//         StackTraceElement lastElement = stack[stack.length - 1];
//         String where = lastElement.getClassName() + ":" + lastElement.getLineNumber();
//         Answers.getInstance().logCustom(new CustomEvent("Error").putCustomAttribute("error_text", where));
//         if (message != null) {
//             Crashlytics.log(message);
//         }
//         Crashlytics.logException(th);
// 
//         saveToLog("e", where);
//     }
// 
//     public static void i(Object obj) {
//         saveToLog("I", "" + obj);
//         Log.i(TAG, "" + obj);
//     }
// 
//     public static void d(Object obj) {
//         Log.d(TAG, "" + obj);
//     }
// 
//     public static String logsToString() {
//         synchronized (logs) {
//             return Joiner.on("\n").join(logs);
//         }
//     }
// 
//     private static void saveToLog(String level, String text) {
//         synchronized (logs) {
//             logs.addLast("" + System.currentTimeMillis() + " (" + level + ") " + text);
//             if (logs.size() > MAX_LOG_SIZE) {
//                 logs.removeFirst();
//             }
//         }
//     }
// }


import com.google.gson.Gson;
import com.rai220.securityalarmbot.utils.L;
import java.util.List;
import java.util.Map;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
    public static List<String> clarify(byte[] jpeg) {
        try {
            RequestBody requestBody = new MultipartBody.Builder()
                    .setType(MultipartBody.FORM)
                    .addFormDataPart("encoded_data", "file.jpg", MultipartBody.create(MediaType.parse("image/jpeg"), jpeg))
                    .build();

            Request request = new Request.Builder()
                    .addHeader("Authorization", "Bearer " + "nc8xqOaMYTJp7fMZiUbi396r7ZFkeB")
                    .url("https://api.clarifai.com/v1/tag/")
                    .post(requestBody)
                    .build();
            Response response = client.newCall(request).execute();
            if (response.isSuccessful()) {
                String result = response.body().string();
                Map obj = gson.fromJson(result, Map.class);
                List resultsList = (List) obj.get("results");
                if (resultsList.size() > 0) {
                    Map res = (Map) ((Map) resultsList.get(0)).get("result");
                    Map tag = (Map) res.get("tag");
                    List classes = (List) tag.get("classes");
                    List<String> myClasses = (List) tag.get("classes");
                    for (int i = 0; i < classes.size(); i++) {
                        myClasses.add(classes.get(i).toString().toUpperCase());
                    }
                    return myClasses;
                }
                L.i(result);
            }
        } catch (Throwable ex) {
// Path: app/src/main/java/com/rai220/securityalarmbot/utils/L.java
// public class L {
//     private static final String TAG = "SecurityAlarmBot";
// 
//     private static final int MAX_LOG_SIZE = 10 * 1000;
//     private static final LinkedList<String> logs = new LinkedList<>();
// 
//     private L() {
//     }
// 
//     public static void e(String error) {
//         Log.e(TAG, error);
//         saveToLog("e", error);
//     }
// 
//     public static void e(Throwable th) {
//         e(null, th);
//     }
// 
//     public static void e(String message, Throwable th) {
//         Log.e(TAG, "", th);
//         StackTraceElement[] stack = th.getStackTrace();
//         StackTraceElement lastElement = stack[stack.length - 1];
//         String where = lastElement.getClassName() + ":" + lastElement.getLineNumber();
//         Answers.getInstance().logCustom(new CustomEvent("Error").putCustomAttribute("error_text", where));
//         if (message != null) {
//             Crashlytics.log(message);
//         }
//         Crashlytics.logException(th);
// 
//         saveToLog("e", where);
//     }
// 
//     public static void i(Object obj) {
//         saveToLog("I", "" + obj);
//         Log.i(TAG, "" + obj);
//     }
// 
//     public static void d(Object obj) {
//         Log.d(TAG, "" + obj);
//     }
// 
//     public static String logsToString() {
//         synchronized (logs) {
//             return Joiner.on("\n").join(logs);
//         }
//     }
// 
//     private static void saveToLog(String level, String text) {
//         synchronized (logs) {
//             logs.addLast("" + System.currentTimeMillis() + " (" + level + ") " + text);
//             if (logs.size() > MAX_LOG_SIZE) {
//                 logs.removeFirst();
//             }
//         }
//     }
// }


// Path: app/src/main/java/com/rai220/securityalarmbot/photo/ClarifyAiHelper.java
import com.google.gson.Gson;
import com.rai220.securityalarmbot.utils.L;
import java.util.List;
import java.util.Map;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

    public static List<String> clarify(byte[] jpeg) {
        try {
            RequestBody requestBody = new MultipartBody.Builder()
                    .setType(MultipartBody.FORM)
                    .addFormDataPart("encoded_data", "file.jpg", MultipartBody.create(MediaType.parse("image/jpeg"), jpeg))
                    .build();

            Request request = new Request.Builder()
                    .addHeader("Authorization", "Bearer " + "nc8xqOaMYTJp7fMZiUbi396r7ZFkeB")
                    .url("https://api.clarifai.com/v1/tag/")
                    .post(requestBody)
                    .build();
            Response response = client.newCall(request).execute();
            if (response.isSuccessful()) {
                String result = response.body().string();
                Map obj = gson.fromJson(result, Map.class);
                List resultsList = (List) obj.get("results");
                if (resultsList.size() > 0) {
                    Map res = (Map) ((Map) resultsList.get(0)).get("result");
                    Map tag = (Map) res.get("tag");
                    List classes = (List) tag.get("classes");
                    List<String> myClasses = (List) tag.get("classes");
                    for (int i = 0; i < classes.size(); i++) {
                        myClasses.add(classes.get(i).toString().toUpperCase());
                    }
                    return myClasses;
                }
                L.i(result);
            }
        } catch (Throwable ex) {
            L.e(ex);