(function() {
  "use strict";
  const API_URL = `${"https://radddwqhqhtkareelypr.supabase.co"}/functions/v1`;
  const SUPABASE_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJhZGRkd3FocWh0a2FyZWVseXByIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzIzMDA4MDgsImV4cCI6MjA4Nzg3NjgwOH0.Juyv8Mx0PXF5PFcg0PZpoxsT_aAF8EebPSj_YFjaP1g";
  async function apiCall(endpoint, data) {
    if (!"https://radddwqhqhtkareelypr.supabase.co".startsWith("http")) {
      throw new Error(
        'GuardRAIl is not configured: Supabase URL is missing. Copy .env.example to .env, set VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY, then run "npm run build" again.'
      );
    }
    if (SUPABASE_ANON_KEY.length < 20) {
      throw new Error(
        'GuardRAIl is not configured: Supabase anon key is missing or invalid. Copy .env.example to .env, set VITE_SUPABASE_ANON_KEY, then run "npm run build" again.'
      );
    }
    const PII_KEYS = ["email", "name", "password", "prompt", "text", "content", "originalText", "refinedText", "accessCode", "authToken"];
    const logData = {};
    for (const [key, value] of Object.entries(data)) {
      const lowerKey = key.toLowerCase();
      const isPII = PII_KEYS.some((piiKey) => lowerKey.includes(piiKey.toLowerCase()));
      if (isPII) {
        if (typeof value === "string") {
          if (lowerKey.includes("email")) {
            const parts = value.split("@");
            logData[key] = parts.length === 2 ? `${parts[0].substring(0, 2)}...@${parts[1]}` : "[email]";
          } else if (lowerKey.includes("password")) {
            logData[key] = "[REDACTED]";
          } else {
            logData[key] = `[${value.length} chars]`;
          }
        } else {
          logData[key] = `[${typeof value}]`;
        }
      } else if (key === "conversationHistory" && Array.isArray(value)) {
        logData[key] = `[Array of ${value.length} messages]`;
      } else if (typeof value === "string" && value.length > 100) {
        logData[key] = `[${value.length} chars]`;
      } else {
        logData[key] = value;
      }
    }
    console.log(`GuardRAIl apiCall (${endpoint}): Sending:`, logData);
    try {
      const jsonBody = JSON.stringify(data);
      const timeoutMs = endpoint === "refinePrompt" || endpoint === "polishLearningPrompt" || endpoint === "analyzePrompt" ? 3e4 : 15e3;
      const controller = new AbortController();
      const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
      const url = `${API_URL}/${endpoint}`;
      console.log(`GuardRAIl apiCall (${endpoint}): Fetching:`, url);
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "apikey": SUPABASE_ANON_KEY,
          // Required for Supabase Edge Functions
          "Authorization": `Bearer ${SUPABASE_ANON_KEY}`
          // Also required by some Supabase configurations
        },
        body: jsonBody,
        signal: controller.signal
      });
      clearTimeout(timeoutId);
      const responseText = await response.text();
      console.log(`GuardRAIl apiCall (${endpoint}): Response status:`, response.status, "Response length:", responseText.length);
      if (!response.ok) {
        console.error(`GuardRAIl apiCall (${endpoint}): Error response:`, responseText.substring(0, 500));
        if (response.status === 401) {
          const projectRef = "https://radddwqhqhtkareelypr.supabase.co".startsWith("http") ? new URL("https://radddwqhqhtkareelypr.supabase.co").hostname.split(".")[0] : "YOUR_PROJECT_REF";
          console.error(`GuardRAIl apiCall (${endpoint}): ⚠️ 401 Unauthorized - Edge Function requires --no-verify-jwt deployment`);
          console.error(`GuardRAIl apiCall (${endpoint}): Deploy with: supabase functions deploy ${endpoint} --project-ref ${projectRef} --no-verify-jwt`);
        }
      }
      let result;
      try {
        result = JSON.parse(responseText);
      } catch {
        throw new Error(`Invalid JSON response: ${responseText.substring(0, 200)}`);
      }
      if (!response.ok) {
        const errorMsg = result.error || `API error: ${response.status}`;
        console.error(`GuardRAIl API error (${endpoint}):`, errorMsg);
        throw new Error(errorMsg);
      }
      return result;
    } catch (err) {
      console.error(`GuardRAIl apiCall (${endpoint}): Error details:`, {
        error: err,
        errorType: err?.constructor?.name,
        errorMessage: err instanceof Error ? err.message : String(err),
        errorName: err instanceof Error ? err.name : void 0,
        url: `${API_URL}/${endpoint}`
      });
      if (err instanceof TypeError && err.message.includes("fetch")) {
        const errorMsg = err.message || "Unknown fetch error";
        console.error(`GuardRAIl apiCall (${endpoint}): Fetch error:`, errorMsg);
        console.error(`GuardRAIl apiCall (${endpoint}): Diagnostic info:`, {
          url: `${API_URL}/${endpoint}`,
          hasApikey: true,
          apikeyLength: SUPABASE_ANON_KEY?.length || 0,
          errorType: err.constructor?.name,
          errorMessage: err.message
        });
        if (errorMsg.includes("CORS") || errorMsg.includes("cors")) {
          throw new Error(`CORS error: The Edge Function may not be deployed or CORS is misconfigured. URL: ${API_URL}/${endpoint}`);
        }
        const fullUrl = `${API_URL}/${endpoint}`;
        const hint = fullUrl.startsWith("http") ? `Deploy with: supabase functions deploy ${endpoint} --no-verify-jwt (and link your project if needed).` : 'Set VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY in .env, then run "npm run build" again.';
        throw new Error(`Network error: ${errorMsg}. ${hint} URL: ${fullUrl}`);
      }
      if (err instanceof Error && err.name === "AbortError") {
        throw new Error("Request timed out - please try again");
      }
      if (err instanceof Error) {
        throw new Error(`${endpoint} error: ${err.message}`);
      }
      throw err;
    }
  }
  async function isGuardrailDisabled() {
    const data = await chrome.storage.sync.get(["guardrail_disabled"]);
    return data.guardrail_disabled === true;
  }
  async function getAuthData() {
    const data = await chrome.storage.sync.get([
      "guardrail_student_id",
      "guardrail_auth_user_id",
      "guardrail_student_email",
      "guardrail_student_name",
      "guardrail_classroom_id",
      "guardrail_classroom_name",
      "guardrail_classroom_access_code",
      "guardrail_auth_token"
    ]);
    console.log("GuardRAIl getAuthData:", {
      hasStudentId: !!data.guardrail_student_id,
      studentId: data.guardrail_student_id,
      hasAuthUserId: !!data.guardrail_auth_user_id,
      hasAuthToken: !!data.guardrail_auth_token
    });
    return data;
  }
  chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
    console.log("GuardRAIl: Received message:", message.type);
    handleMessage(message).then((result) => {
      console.log("GuardRAIl: Message handled:", message.type, result);
      sendResponse(result);
    }).catch((err) => {
      console.error("GuardRAIl: Message error:", message.type, err);
      sendResponse({ error: err.message || "Unknown error" });
    });
    return true;
  });
  async function handleMessage(message) {
    switch (message.type) {
      case "VALIDATE_ACCESS_CODE":
        return validateAccessCode(message.accessCode);
      case "CREATE_STUDENT":
        return createStudent(
          message.email,
          message.name,
          message.password,
          message.accessCode
        );
      case "CREATE_STUDENT_FROM_OAUTH":
        return createStudentFromOAuth(
          message.authUserId,
          message.accessCode,
          message.name
        );
      case "LOGIN_STUDENT":
        return loginStudent(
          message.email,
          message.password,
          message.accessCode
        );
      case "CHECK_STUDENT_EXISTS":
        return checkStudentExists(
          message.email,
          message.classroomId
        );
      case "ANALYZE_PROMPT": {
        if (await isGuardrailDisabled()) {
          console.log("GuardRAIl: Disabled - allowing prompt through without analysis");
          return {
            classification: "learning",
            rating: 10,
            promptId: "disabled",
            conversationId: message.conversationId || null,
            disabled: true
          };
        }
        const result = await analyzePrompt(
          message.prompt,
          message.platform,
          message.conversationId,
          message.url,
          message.previousMessage,
          message.conversationContext,
          message.isPostHandoff
        );
        if (result && typeof result === "object" && "ratingProvider" in result) {
          console.log("GuardRAIl: Prompt rated via", result.ratingProvider);
        }
        return result;
      }
      case "REFINE_PROMPT": {
        if (await isGuardrailDisabled()) {
          console.log("GuardRAIl: Disabled - passing through original prompt");
          return {
            refinedPrompt: message.originalPrompt,
            isFinal: true,
            disabled: true
          };
        }
        console.log("GuardRAIl handleMessage REFINE_PROMPT received:", {
          hasOriginalPrompt: !!message.originalPrompt,
          originalPromptType: typeof message.originalPrompt,
          originalPromptValue: message.originalPrompt,
          hasConversationHistory: !!message.conversationHistory,
          conversationHistoryType: typeof message.conversationHistory,
          conversationHistoryIsArray: Array.isArray(message.conversationHistory),
          conversationHistoryLength: message.conversationHistory?.length,
          isPostHandoffIntervention: !!message.isPostHandoffIntervention,
          hasChatGPTContext: !!message.chatGPTContext
        });
        return refinePrompt(
          message.originalPrompt,
          message.conversationHistory,
          message.promptId,
          message.conversationId,
          message.isPostHandoffIntervention,
          message.interventionLevel,
          message.chatGPTContext,
          message.chatGPTQuestion,
          message.studentWorkingOn,
          message.clientForceFinal
        );
      }
      case "POLISH_LEARNING_PROMPT": {
        if (await isGuardrailDisabled()) {
          return {
            refinedPrompt: message.originalPrompt,
            disabled: true
          };
        }
        return polishLearningPrompt(
          message.originalPrompt,
          message.subjectAnswer,
          message.taskAnswer,
          message.stuckAnswer,
          message.promptId,
          message.conversationId
        );
      }
      case "SUBMIT_FEEDBACK":
        return submitFeedback(
          message.source,
          message.subject,
          message.message,
          message.studentId,
          message.conversationId,
          message.promptId,
          message.conversationSnapshot
        );
      case "GET_AUTH_STATUS":
        return getAuthStatus();
      case "GET_STATS":
        return getStats();
      case "SIGN_OUT":
        return signOut();
      case "LOG_POST_HANDOFF":
        return logPostHandoff(
          message.prompt,
          message.bypassTriggered,
          message.interventionLevel,
          message.rating,
          message.classification,
          message.studentResponse,
          message.conversationId,
          message.chatGPTQuestion
        );
      case "ANALYZE_CHATGPT_RESPONSE":
        return analyzeChatGPTResponse(
          message.response,
          message.conversationContext,
          message.handoffState
        );
      case "TEST_VAGUE":
        if (message.inputs !== void 0) {
          return apiCall("testVague", { inputs: message.inputs });
        }
        return apiCall("testVague", { content: message.content });
      default:
        throw new Error(`Unknown message type: ${message.type}`);
    }
  }
  async function validateAccessCode(accessCode) {
    return apiCall("validateAccessCode", { accessCode });
  }
  async function createStudentFromOAuth(authUserId, accessCode, name) {
    console.log("GuardRAIl createStudentFromOAuth: Creating with:", {
      hasAuthUserId: !!authUserId,
      hasName: !!name,
      hasAccessCode: !!accessCode
    });
    const result = await apiCall("createStudentFromOAuth", { authUserId, accessCode, name });
    console.log("GuardRAIl createStudentFromOAuth: Result received:", {
      hasStudentId: !!result.studentId,
      studentId: result.studentId,
      hasAuthUserId: !!result.authUserId,
      hasClassroomId: !!result.classroomId
    });
    if (!result.studentId) {
      throw new Error("Student creation failed - no studentId in response");
    }
    const storageData = {
      guardrail_student_id: result.studentId,
      guardrail_auth_user_id: result.authUserId,
      guardrail_student_name: result.name,
      guardrail_student_email: "",
      // Will be set from auth user
      guardrail_classroom_id: result.classroomId,
      guardrail_classroom_name: result.className,
      guardrail_classroom_access_code: accessCode.toUpperCase().trim()
    };
    await chrome.storage.sync.set(storageData);
    console.log("GuardRAIl createStudentFromOAuth: Storage updated");
    return {
      studentId: result.studentId,
      authUserId: result.authUserId,
      name: result.name,
      classroomId: result.classroomId,
      className: result.className
    };
  }
  async function createStudent(email, name, password, accessCode) {
    console.log("GuardRAIl createStudent: Creating with:", {
      emailDomain: email.split("@")[1] || "[no domain]",
      hasName: !!name,
      hasPassword: !!password,
      hasAccessCode: !!accessCode
    });
    const result = await apiCall("createStudent", { email, name, password, accessCode });
    console.log("GuardRAIl createStudent: Result received:", {
      hasStudentId: !!result.studentId,
      studentId: result.studentId,
      hasAuthUserId: !!result.authUserId,
      hasClassroomId: !!result.classroomId
    });
    if (!result.studentId) {
      throw new Error("Student creation failed - no studentId in response");
    }
    const storageData = {
      guardrail_student_id: result.studentId,
      guardrail_auth_user_id: result.authUserId,
      guardrail_student_name: result.name,
      guardrail_student_email: email,
      guardrail_classroom_id: result.classroomId,
      guardrail_classroom_name: result.className,
      guardrail_classroom_access_code: accessCode.toUpperCase().trim()
    };
    console.log("GuardRAIl createStudent: Saving to storage:", {
      studentId: storageData.guardrail_student_id,
      authUserId: storageData.guardrail_auth_user_id,
      classroomId: storageData.guardrail_classroom_id
    });
    try {
      await chrome.storage.sync.set(storageData);
    } catch (err) {
      console.error("GuardRAIl: Storage failed:", err);
      throw new Error("Failed to save authentication - please try again");
    }
    const verify = await chrome.storage.sync.get("guardrail_student_id");
    console.log("GuardRAIl createStudent: Verification after save:", {
      saved: !!verify.guardrail_student_id,
      studentId: verify.guardrail_student_id
    });
    return result;
  }
  async function loginStudent(email, password, accessCode) {
    console.log("GuardRAIl loginStudent: Logging in with:", {
      emailDomain: email.split("@")[1] || "[no domain]",
      hasPassword: !!password,
      hasAccessCode: !!accessCode
    });
    const result = await apiCall("loginStudent", { email, password, accessCode });
    console.log("GuardRAIl loginStudent: Result received:", {
      hasStudentId: !!result.studentId,
      studentId: result.studentId,
      hasAuthUserId: !!result.authUserId
    });
    if (!result.studentId) {
      throw new Error("Student login failed - invalid email or password");
    }
    const storageData = {
      guardrail_student_id: result.studentId,
      guardrail_auth_user_id: result.authUserId,
      guardrail_student_name: result.name,
      guardrail_student_email: email,
      guardrail_classroom_id: result.classroomId,
      guardrail_classroom_name: result.className,
      guardrail_classroom_access_code: accessCode.toUpperCase().trim()
    };
    try {
      await chrome.storage.sync.set(storageData);
    } catch (err) {
      console.error("GuardRAIl: Storage failed:", err);
      throw new Error("Failed to save authentication - please try again");
    }
    return result;
  }
  async function checkStudentExists(email, classroomId) {
    console.log("GuardRAIl checkStudentExists: Checking:", {
      emailDomain: email.split("@")[1] || "[no domain]",
      hasClassroomId: !!classroomId
    });
    const result = await apiCall("checkStudentExists", { email, classroomId });
    return result;
  }
  async function analyzePrompt(prompt, platform, conversationId, url, previousMessage, conversationContext, isPostHandoff) {
    let auth = await getAuthData();
    console.log("GuardRAIl analyzePrompt: Initial auth data:", {
      hasStudentId: !!auth.guardrail_student_id,
      studentId: auth.guardrail_student_id
    });
    if (!auth.guardrail_student_id) {
      console.error("GuardRAIl analyzePrompt: No studentId - user must authenticate");
      throw new Error("Not authenticated - please sign in via the extension popup");
    }
    return apiCall("analyzePrompt", {
      prompt,
      studentId: auth.guardrail_student_id,
      classroomId: auth.guardrail_classroom_id,
      platform,
      conversationId,
      url,
      ...previousMessage !== void 0 && { previousMessage },
      ...conversationContext !== void 0 && { conversationContext },
      ...isPostHandoff !== void 0 && { isPostHandoff }
    });
  }
  async function refinePrompt(originalPrompt, conversationHistory, promptId, conversationId, isPostHandoffIntervention, interventionLevel, chatGPTContext, chatGPTQuestion, studentWorkingOn, clientForceFinal) {
    let auth = await getAuthData();
    console.log("GuardRAIl refinePrompt: Initial auth data:", {
      hasStudentId: !!auth.guardrail_student_id,
      studentId: auth.guardrail_student_id
    });
    if (!auth.guardrail_student_id) {
      console.error("GuardRAIl refinePrompt: No studentId - user must authenticate");
      throw new Error("Not authenticated - please sign in via the extension popup");
    }
    console.log("GuardRAIl refinePrompt: Received args:", {
      originalPrompt: originalPrompt?.substring?.(0, 50) || originalPrompt,
      conversationHistoryType: typeof conversationHistory,
      conversationHistoryIsArray: Array.isArray(conversationHistory),
      conversationHistoryLength: conversationHistory?.length,
      isPostHandoffIntervention: !!isPostHandoffIntervention,
      hasChatGPTContext: !!chatGPTContext,
      chatGPTContextLength: chatGPTContext?.length || 0,
      hasChatGPTQuestion: !!chatGPTQuestion
    });
    if (!originalPrompt) {
      console.error("GuardRAIl refinePrompt: originalPrompt is missing");
      throw new Error("originalPrompt is required");
    }
    if (!conversationHistory || !Array.isArray(conversationHistory)) {
      console.error("GuardRAIl refinePrompt: conversationHistory invalid:", conversationHistory);
      throw new Error("conversationHistory must be an array");
    }
    if (conversationHistory.length === 0) {
      console.error("GuardRAIl refinePrompt: conversationHistory is empty");
      throw new Error("conversationHistory cannot be empty");
    }
    const payload = {
      originalPrompt: String(originalPrompt),
      conversationHistory,
      studentId: String(auth.guardrail_student_id),
      promptId: promptId || null,
      conversationId: conversationId || null,
      isPostHandoffIntervention: !!isPostHandoffIntervention,
      interventionLevel: interventionLevel || null,
      chatGPTContext: chatGPTContext || null,
      chatGPTQuestion: chatGPTQuestion || null,
      studentWorkingOn: studentWorkingOn && studentWorkingOn.trim() ? studentWorkingOn.trim() : null,
      ...clientForceFinal && { clientForceFinal: true }
    };
    console.log("GuardRAIl refinePrompt: Sending payload with context:", {
      isPostHandoffIntervention: payload.isPostHandoffIntervention,
      hasChatGPTContext: !!payload.chatGPTContext,
      contextLength: payload.chatGPTContext?.length || 0
    });
    return apiCall("refinePrompt", payload);
  }
  async function polishLearningPrompt(originalPrompt, subjectAnswer, taskAnswer, stuckAnswer, promptId, conversationId) {
    const auth = await getAuthData();
    if (!auth.guardrail_student_id) {
      throw new Error("Not authenticated - please sign in via the extension popup");
    }
    return apiCall("polishLearningPrompt", {
      originalPrompt: String(originalPrompt),
      subjectAnswer: String(subjectAnswer ?? ""),
      taskAnswer: String(taskAnswer ?? ""),
      stuckAnswer: String(stuckAnswer ?? ""),
      studentId: auth.guardrail_student_id,
      promptId: promptId || null,
      conversationId: conversationId || null
    });
  }
  async function submitFeedback(source, subject, message, studentId, conversationId, promptId, conversationSnapshot) {
    const payload = {
      source,
      subject: subject ?? "",
      message,
      studentId: studentId ?? null
    };
    if (conversationId) payload.conversationId = conversationId;
    if (promptId) payload.promptId = promptId;
    if (conversationSnapshot != null) payload.conversationSnapshot = conversationSnapshot;
    return apiCall("submitFeedback", payload);
  }
  async function getAuthStatus() {
    const auth = await getAuthData();
    const hasPasswordAuth = !!(auth.guardrail_student_id && auth.guardrail_auth_user_id);
    const hasTokenAuth = !!(auth.guardrail_student_id && auth.guardrail_auth_token);
    const isAuth = hasPasswordAuth || hasTokenAuth;
    console.log("GuardRAIl getAuthStatus: Auth data:", {
      isAuthenticated: isAuth,
      studentId: auth.guardrail_student_id,
      hasPassword: hasPasswordAuth,
      hasToken: hasTokenAuth,
      hasEmail: !!auth.guardrail_student_email,
      hasName: !!auth.guardrail_student_name
    });
    return {
      isAuthenticated: isAuth,
      studentId: auth.guardrail_student_id,
      studentName: auth.guardrail_student_name,
      studentEmail: auth.guardrail_student_email,
      classroomId: auth.guardrail_classroom_id,
      classroomName: auth.guardrail_classroom_name,
      hasPassword: hasPasswordAuth
    };
  }
  async function getStats() {
    const auth = await getAuthData();
    console.log("GuardRAIl getStats: Auth data:", {
      hasStudentId: !!auth.guardrail_student_id,
      studentId: auth.guardrail_student_id,
      hasAuthToken: !!auth.guardrail_auth_token
    });
    if (!auth.guardrail_student_id) {
      console.error("GuardRAIl getStats: No studentId found in auth data");
      throw new Error("Not authenticated");
    }
    console.log("GuardRAIl getStats: Calling API with studentId:", auth.guardrail_student_id);
    const result = await apiCall("getStudentStats", {
      studentId: auth.guardrail_student_id,
      authToken: auth.guardrail_auth_token
    });
    console.log("GuardRAIl getStats: API result:", result);
    return result;
  }
  async function signOut() {
    await chrome.storage.sync.remove([
      "guardrail_student_id",
      "guardrail_auth_user_id",
      "guardrail_student_email",
      "guardrail_student_name",
      "guardrail_classroom_id",
      "guardrail_classroom_name",
      "guardrail_classroom_access_code",
      "guardrail_auth_token"
    ]);
    return { success: true };
  }
  async function logPostHandoff(prompt, bypassTriggered, interventionLevel, rating, classification, studentResponse, conversationId, chatGPTQuestion) {
    try {
      const authData = await getAuthData();
      const studentId = authData.guardrail_student_id;
      if (!studentId) {
        console.log("GuardRAIl: Not authenticated, skipping post-handoff log");
        return { success: false };
      }
      const response = await fetch(`${API_URL}/logPostHandoff`, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "apikey": SUPABASE_ANON_KEY,
          "Authorization": `Bearer ${SUPABASE_ANON_KEY}`
        },
        body: JSON.stringify({
          prompt,
          bypassTriggered,
          interventionLevel,
          rating,
          classification,
          studentResponse,
          conversationId,
          chatGPTQuestion: chatGPTQuestion || null,
          studentId
        })
      });
      if (!response.ok) {
        throw new Error(`HTTP ${response.status}`);
      }
      return { success: true };
    } catch (error) {
      console.error("Log post-handoff error:", error);
      return { success: false };
    }
  }
  async function analyzeChatGPTResponse(response, conversationContext, handoffState) {
    try {
      const authData = await getAuthData();
      const studentId = authData.guardrail_student_id;
      if (!studentId) {
        console.log("GuardRAIl: Not authenticated, skipping ChatGPT compliance analysis");
        throw new Error("Not authenticated");
      }
      const response_1 = await fetch(`${API_URL}/analyzeChatGPTResponse`, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "apikey": SUPABASE_ANON_KEY,
          "Authorization": `Bearer ${SUPABASE_ANON_KEY}`
        },
        body: JSON.stringify({
          response,
          studentId,
          conversationContext: conversationContext || null,
          handoffState: handoffState || null
        })
      });
      if (!response_1.ok) {
        throw new Error(`HTTP ${response_1.status}`);
      }
      return await response_1.json();
    } catch (error) {
      console.error("Analyze ChatGPT response error:", error);
      throw error;
    }
  }
  chrome.runtime.onInstalled.addListener(() => {
    console.log("GuardRAIl v2 installed");
  });
})();
