@thanh01.pmt/interactive-quiz-kit 1.0.89 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react-ui.cjs CHANGED
@@ -5,11 +5,9 @@ var reactI18next = require('react-i18next');
5
5
  var generativeAi = require('@google/generative-ai');
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
7
  var ReactDOM5 = require('react-dom');
8
- var Image2 = require('next/image');
9
8
  var default2 = require('path');
10
9
  var default3 = require('process');
11
10
  var url = require('url');
12
- var dynamic = require('next/dynamic');
13
11
  var Editor = require('@monaco-editor/react');
14
12
 
15
13
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -34,10 +32,8 @@ function _interopNamespace(e) {
34
32
 
35
33
  var React78__namespace = /*#__PURE__*/_interopNamespace(React78);
36
34
  var ReactDOM5__namespace = /*#__PURE__*/_interopNamespace(ReactDOM5);
37
- var Image2__default = /*#__PURE__*/_interopDefault(Image2);
38
35
  var default2__default = /*#__PURE__*/_interopDefault(default2);
39
36
  var default3__default = /*#__PURE__*/_interopDefault(default3);
40
- var dynamic__default = /*#__PURE__*/_interopDefault(dynamic);
41
37
  var Editor__default = /*#__PURE__*/_interopDefault(Editor);
42
38
 
43
39
  var __create = Object.create;
@@ -7220,6 +7216,12 @@ var ExecutionService = class _ExecutionService {
7220
7216
  }
7221
7217
  return _ExecutionService.instance;
7222
7218
  }
7219
+ /**
7220
+ * Clear all registered providers.
7221
+ */
7222
+ clearProviders() {
7223
+ this.providers.clear();
7224
+ }
7223
7225
  /**
7224
7226
  * Register a provider.
7225
7227
  */
@@ -7236,20 +7238,25 @@ var ExecutionService = class _ExecutionService {
7236
7238
  * Get the best provider for a language based on priority and availability.
7237
7239
  */
7238
7240
  async getBestProvider(language2) {
7239
- const sortedProviders = Array.from(this.providers.values()).filter((p4) => p4.getSupportedLanguages().includes(language2)).sort((a2, b2) => b2.getPriority(language2) - a2.getPriority(language2));
7241
+ const lang = language2.toLowerCase();
7242
+ const sortedProviders = Array.from(this.providers.values()).filter((p4) => p4.getSupportedLanguages().map((l2) => l2.toLowerCase()).includes(lang)).sort((a2, b2) => b2.getPriority(lang) - a2.getPriority(lang));
7243
+ console.log(`[ExecutionService] Finding best provider for '${language2}' (normalized: '${lang}'). Found ${sortedProviders.length} potential providers.`);
7240
7244
  for (const provider of sortedProviders) {
7241
7245
  if (await provider.isAvailable()) {
7246
+ console.log(`[ExecutionService] Selected provider: ${provider.name} (ID: ${provider.id})`);
7242
7247
  return provider;
7243
7248
  }
7244
7249
  }
7245
7250
  return null;
7246
7251
  }
7247
7252
  /**
7248
- * Execute code using the best available provider.
7253
+ * Execute code using the best available provider with automatic fallback.
7249
7254
  */
7250
7255
  async execute(code4, language2, stdin) {
7251
- const provider = await this.getBestProvider(language2);
7252
- if (!provider) {
7256
+ const lang = language2.toLowerCase();
7257
+ const providers = Array.from(this.providers.values()).filter((p4) => p4.getSupportedLanguages().map((l2) => l2.toLowerCase()).includes(lang)).sort((a2, b2) => b2.getPriority(lang) - a2.getPriority(lang));
7258
+ console.log(`[ExecutionService] Executing for '${language2}'. Providers in order:`, providers.map((p4) => `${p4.name} (${p4.id})`));
7259
+ if (providers.length === 0) {
7253
7260
  return {
7254
7261
  stdout: "",
7255
7262
  stderr: `No execution provider available for language: ${language2}`,
@@ -7257,16 +7264,28 @@ var ExecutionService = class _ExecutionService {
7257
7264
  message: "EXECUTION_ERROR_NO_PROVIDER"
7258
7265
  };
7259
7266
  }
7260
- try {
7261
- return await provider.execute(code4, language2, stdin);
7262
- } catch (error) {
7263
- return {
7264
- stdout: "",
7265
- stderr: error.message || "Unknown execution error",
7266
- exitCode: 1,
7267
- message: "EXECUTION_ERROR_INTERNAL"
7268
- };
7267
+ let lastError = null;
7268
+ for (const provider of providers) {
7269
+ try {
7270
+ if (!await provider.isAvailable()) continue;
7271
+ const result = await provider.execute(code4, language2, stdin);
7272
+ const isRecoverable = result.message === "RATE_LIMIT_EXCEEDED" || result.message === "AUTH_FAILED" || result.message === "UNSUPPORTED_LANGUAGE" || result.message === "EXECUTION_ERROR" || result.status?.id === 13 || // Internal Error
7273
+ result.exitCode === 1 && !result.stderr;
7274
+ if (isRecoverable && providers.indexOf(provider) < providers.length - 1) {
7275
+ lastError = result;
7276
+ continue;
7277
+ }
7278
+ return result;
7279
+ } catch (error) {
7280
+ lastError = error;
7281
+ }
7269
7282
  }
7283
+ return {
7284
+ stdout: "",
7285
+ stderr: lastError?.stderr || lastError?.message || "All execution providers failed",
7286
+ exitCode: 1,
7287
+ message: "EXECUTION_ERROR_ALL_FAILED"
7288
+ };
7270
7289
  }
7271
7290
  };
7272
7291
  var executionService = ExecutionService.getInstance();
@@ -7274,9 +7293,7 @@ var executionService = ExecutionService.getInstance();
7274
7293
  // src/lib/execution/providers/Judge0Provider.ts
7275
7294
  init_react_shim();
7276
7295
  var Judge0Provider = class {
7277
- constructor(apiUrl, apiKey) {
7278
- this.id = "judge0";
7279
- this.name = "Judge0 Professional";
7296
+ constructor(apiUrl, apiKey, options) {
7280
7297
  this.languageMap = {
7281
7298
  "python": 71,
7282
7299
  "javascript": 63,
@@ -7289,6 +7306,9 @@ var Judge0Provider = class {
7289
7306
  };
7290
7307
  this.apiUrl = apiUrl;
7291
7308
  this.apiKey = apiKey;
7309
+ this.id = options?.id || "judge0";
7310
+ this.name = options?.name || "Judge0 Professional";
7311
+ this.customPriority = options?.priority;
7292
7312
  }
7293
7313
  async isAvailable() {
7294
7314
  return !!this.apiUrl;
@@ -7324,11 +7344,15 @@ var Judge0Provider = class {
7324
7344
  };
7325
7345
  }
7326
7346
  try {
7347
+ console.log(`[Judge0Provider] Calling ${this.name} at ${this.apiUrl}...`);
7327
7348
  const response = await fetch(`${this.apiUrl}/submissions?base64_encoded=true&wait=true`, {
7328
7349
  method: "POST",
7329
7350
  headers: {
7330
7351
  "Content-Type": "application/json",
7331
- ...this.apiKey && { "X-Auth-Token": this.apiKey }
7352
+ ...this.apiKey && (this.apiUrl.includes("rapidapi.com") ? {
7353
+ "x-rapidapi-key": this.apiKey,
7354
+ "x-rapidapi-host": new URL(this.apiUrl).hostname
7355
+ } : { "X-Auth-Token": this.apiKey })
7332
7356
  },
7333
7357
  body: JSON.stringify({
7334
7358
  source_code: this.toBase64(code4),
@@ -7337,9 +7361,45 @@ var Judge0Provider = class {
7337
7361
  })
7338
7362
  });
7339
7363
  if (!response.ok) {
7340
- throw new Error(`Judge0 API error: ${response.statusText}`);
7364
+ const errorText = await response.text();
7365
+ console.error(`[Judge0Provider] ${this.name} HTTP Error ${response.status}:`, errorText);
7366
+ throw new Error(`PROVIDER_HTTP_ERROR: ${response.status} - ${errorText}`);
7367
+ }
7368
+ let result = await response.json();
7369
+ console.log(`[Judge0Provider] ${this.name} initial result:`, result);
7370
+ if (result.message) {
7371
+ if (result.message.includes("not subscribed")) {
7372
+ console.warn(`[Judge0Provider] ${this.name} auth failed, triggering fallback...`);
7373
+ throw new Error("AUTH_FAILED: Not subscribed");
7374
+ }
7375
+ if (result.message.includes("rate limit")) {
7376
+ console.warn(`[Judge0Provider] ${this.name} rate limited, triggering fallback...`);
7377
+ throw new Error("RATE_LIMIT_EXCEEDED");
7378
+ }
7379
+ }
7380
+ let attempts = 0;
7381
+ const maxAttempts = 10;
7382
+ while ((result.status?.id === 1 || result.status?.id === 2) && attempts < maxAttempts) {
7383
+ console.log(`[Judge0Provider] ${this.name} polling... (status: ${result.status?.description})`);
7384
+ await new Promise((resolve) => setTimeout(resolve, 1e3));
7385
+ const pollResponse = await fetch(`${this.apiUrl}/submissions/${result.token}?base64_encoded=true`, {
7386
+ headers: {
7387
+ "Content-Type": "application/json",
7388
+ ...this.apiKey && (this.apiUrl.includes("rapidapi.com") ? {
7389
+ "x-rapidapi-key": this.apiKey,
7390
+ "x-rapidapi-host": new URL(this.apiUrl).hostname
7391
+ } : { "X-Auth-Token": this.apiKey })
7392
+ }
7393
+ });
7394
+ if (pollResponse.ok) {
7395
+ result = await pollResponse.json();
7396
+ console.log(`[Judge0Provider] ${this.name} poll result (attempt ${attempts + 1}):`, result);
7397
+ } else {
7398
+ console.error(`[Judge0Provider] Poll failed: ${pollResponse.status}`);
7399
+ break;
7400
+ }
7401
+ attempts++;
7341
7402
  }
7342
- const result = await response.json();
7343
7403
  return {
7344
7404
  stdout: this.fromBase64(result.stdout),
7345
7405
  stderr: this.fromBase64(result.stderr),
@@ -7349,18 +7409,16 @@ var Judge0Provider = class {
7349
7409
  time: result.time ? parseFloat(result.time) * 1e3 : void 0,
7350
7410
  memory: result.memory ? parseInt(result.memory) : void 0,
7351
7411
  message: result.status?.description,
7412
+ status: result.status,
7352
7413
  token: result.token
7353
7414
  };
7354
7415
  } catch (error) {
7355
- return {
7356
- stdout: "",
7357
- stderr: error instanceof Error ? error.message : String(error),
7358
- exitCode: 1,
7359
- message: "EXECUTION_ERROR"
7360
- };
7416
+ console.error(`[Judge0Provider] ${this.name} execution error:`, error);
7417
+ throw error;
7361
7418
  }
7362
7419
  }
7363
7420
  getPriority(language2) {
7421
+ if (this.customPriority !== void 0) return this.customPriority;
7364
7422
  const compiled = ["cpp", "c", "java", "csharp"];
7365
7423
  return compiled.includes(language2.toLowerCase()) ? 10 : 5;
7366
7424
  }
@@ -7369,6 +7427,104 @@ var Judge0Provider = class {
7369
7427
  }
7370
7428
  };
7371
7429
 
7430
+ // src/lib/execution/providers/PistonProvider.ts
7431
+ init_react_shim();
7432
+ var PistonProvider = class {
7433
+ constructor(apiUrl, apiKey, options) {
7434
+ this.cachedRuntimes = null;
7435
+ this.apiUrl = apiUrl.endsWith("/") ? apiUrl.slice(0, -1) : apiUrl;
7436
+ this.apiKey = apiKey;
7437
+ this.id = options?.id || "piston";
7438
+ this.name = options?.name || "Piston Engine";
7439
+ this.customPriority = options?.priority;
7440
+ }
7441
+ async isAvailable() {
7442
+ try {
7443
+ const response = await fetch(`${this.apiUrl}/runtimes`);
7444
+ if (response.ok) {
7445
+ this.cachedRuntimes = await response.json();
7446
+ return true;
7447
+ }
7448
+ return false;
7449
+ } catch (e2) {
7450
+ return false;
7451
+ }
7452
+ }
7453
+ async execute(code4, language2, stdin) {
7454
+ try {
7455
+ if (!this.cachedRuntimes) {
7456
+ const response2 = await fetch(`${this.apiUrl}/runtimes`);
7457
+ if (response2.ok) {
7458
+ this.cachedRuntimes = await response2.json();
7459
+ } else {
7460
+ throw new Error("Could not fetch Piston runtimes");
7461
+ }
7462
+ }
7463
+ const lowerLang = language2.toLowerCase();
7464
+ let targetLang = lowerLang;
7465
+ if (lowerLang === "js") targetLang = "javascript";
7466
+ if (lowerLang === "c" || lowerLang === "cpp") targetLang = "gcc";
7467
+ const runtime = this.cachedRuntimes.find(
7468
+ (r4) => r4.language === targetLang || r4.aliases && r4.aliases.includes(targetLang)
7469
+ );
7470
+ if (!runtime) {
7471
+ return {
7472
+ stdout: "",
7473
+ stderr: `Language '${language2}' (mapped to '${targetLang}') is not supported by this Piston instance.`,
7474
+ exitCode: 1,
7475
+ message: "UNSUPPORTED_LANGUAGE"
7476
+ };
7477
+ }
7478
+ console.log(`[PistonProvider] Calling ${this.name} (${runtime.language} ${runtime.version}) at ${this.apiUrl}...`);
7479
+ const headers = {
7480
+ "Content-Type": "application/json"
7481
+ };
7482
+ if (this.apiKey) {
7483
+ headers["X-API-Key"] = this.apiKey;
7484
+ }
7485
+ const response = await fetch(`${this.apiUrl}/execute`, {
7486
+ method: "POST",
7487
+ headers,
7488
+ body: JSON.stringify({
7489
+ language: runtime.language,
7490
+ version: runtime.version,
7491
+ files: [{ content: code4 }],
7492
+ stdin: stdin || ""
7493
+ })
7494
+ });
7495
+ if (!response.ok) {
7496
+ const errorText = await response.text();
7497
+ console.error(`[PistonProvider] HTTP Error ${response.status}:`, errorText);
7498
+ throw new Error(`PISTON_HTTP_ERROR: ${response.status} - ${errorText}`);
7499
+ }
7500
+ const result = await response.json();
7501
+ console.log(`[PistonProvider] result:`, result);
7502
+ if (result.message) {
7503
+ throw new Error(`PISTON_ERROR: ${result.message}`);
7504
+ }
7505
+ const run = result.run || {};
7506
+ const compile = result.compile || {};
7507
+ return {
7508
+ stdout: run.stdout || "",
7509
+ stderr: (compile.stderr || "") + (run.stderr || ""),
7510
+ compileOutput: compile.stdout || "",
7511
+ exitCode: run.code === 0 ? 0 : 1,
7512
+ message: run.signal ? `Terminated by signal: ${run.signal}` : void 0
7513
+ };
7514
+ } catch (error) {
7515
+ console.error(`[PistonProvider] execution error:`, error);
7516
+ throw error;
7517
+ }
7518
+ }
7519
+ getPriority(language2) {
7520
+ if (this.customPriority !== void 0) return this.customPriority;
7521
+ return 20;
7522
+ }
7523
+ getSupportedLanguages() {
7524
+ return ["python", "javascript", "js", "lua", "c", "cpp", "csharp"];
7525
+ }
7526
+ };
7527
+
7372
7528
  // src/lib/execution/providers/LiteProvider.ts
7373
7529
  init_react_shim();
7374
7530
  var LiteProvider = class {
@@ -7584,9 +7740,40 @@ var AIProvider = class {
7584
7740
 
7585
7741
  // src/lib/execution/index.ts
7586
7742
  function initExecutionSystem(config) {
7743
+ executionService.clearProviders();
7587
7744
  executionService.registerProvider(new LiteProvider());
7588
- if (config?.judge0Url) {
7589
- executionService.registerProvider(new Judge0Provider(config.judge0Url, config.judge0Key));
7745
+ if (config?.judge0Fallback?.url) {
7746
+ executionService.registerProvider(new Judge0Provider(
7747
+ config.judge0Fallback.url,
7748
+ config.judge0Fallback.key,
7749
+ {
7750
+ id: "judge0-fallback",
7751
+ name: config.judge0Fallback.name || "Judge0 Fallback (RapidAPI)",
7752
+ priority: config.judge0Fallback.priority || 8
7753
+ }
7754
+ ));
7755
+ }
7756
+ if (config?.pistonPrimary?.url) {
7757
+ executionService.registerProvider(new PistonProvider(
7758
+ config.pistonPrimary.url,
7759
+ config.pistonPrimary.key,
7760
+ {
7761
+ id: "piston-primary",
7762
+ name: config.pistonPrimary.name || "Piston Primary (Self-hosted)",
7763
+ priority: config.pistonPrimary.priority || 20
7764
+ }
7765
+ ));
7766
+ }
7767
+ if (config?.judge0Primary?.url) {
7768
+ executionService.registerProvider(new Judge0Provider(
7769
+ config.judge0Primary.url,
7770
+ config.judge0Primary.key,
7771
+ {
7772
+ id: "judge0-primary",
7773
+ name: config.judge0Primary.name || "Judge0 Primary (Self-hosted)",
7774
+ priority: config.judge0Primary.priority || 15
7775
+ }
7776
+ ));
7590
7777
  }
7591
7778
  if (config?.geminiKey) {
7592
7779
  executionService.registerProvider(new AIProvider(config.geminiKey));
@@ -7596,8 +7783,11 @@ function initExecutionSystem(config) {
7596
7783
  // src/services/APIKeyService.ts
7597
7784
  init_react_shim();
7598
7785
  var GEMINI_API_KEY_SERVICE_NAME = "gemini";
7599
- var JUDGE0_API_KEY_SERVICE_NAME = "judge0";
7600
- var JUDGE0_API_URL_SERVICE_NAME = "judge0_url";
7786
+ var JUDGE0_PRIMARY_API_KEY_SERVICE_NAME = "judge0_primary";
7787
+ var JUDGE0_PRIMARY_API_URL_SERVICE_NAME = "judge0_primary_url";
7788
+ var JUDGE0_FALLBACK_API_KEY_SERVICE_NAME = "judge0_fallback";
7789
+ var JUDGE0_FALLBACK_API_URL_SERVICE_NAME = "judge0_fallback_url";
7790
+ var PISTON_PRIMARY_API_URL_SERVICE_NAME = "piston_primary_url";
7601
7791
  var LOCAL_STORAGE_PREFIX = "iqk_api_keys_";
7602
7792
  function _encode(data) {
7603
7793
  if (typeof window !== "undefined" && typeof window.btoa === "function") {
@@ -7683,6 +7873,96 @@ var APIKeyService = class {
7683
7873
  }
7684
7874
  };
7685
7875
 
7876
+ // src/lib/execution/CodeWrapper.ts
7877
+ init_react_shim();
7878
+ var CodeWrapper = class {
7879
+ /**
7880
+ * Wraps code with necessary boilerplate for the given language.
7881
+ */
7882
+ static wrap(code4, language2, options = {}) {
7883
+ const lang = language2.toLowerCase();
7884
+ if (lang === "c" || lang === "cpp") {
7885
+ return this.wrapC(code4, options.testCaseInput || [], options.functionSignature);
7886
+ }
7887
+ return code4;
7888
+ }
7889
+ static wrapC(code4, input, signature) {
7890
+ if (code4.includes("int main") || code4.includes("void main")) {
7891
+ return code4;
7892
+ }
7893
+ if (!signature) {
7894
+ return `
7895
+ #include <stdio.h>
7896
+ #include <stdlib.h>
7897
+ #include <stdbool.h>
7898
+ #include <string.h>
7899
+
7900
+ ${code4}
7901
+
7902
+ int main() {
7903
+ // No signature provided, assuming competitive programming style if stdin is used
7904
+ return 0;
7905
+ }
7906
+ `;
7907
+ }
7908
+ const sig = signature?.trim();
7909
+ const match = sig?.match(/(\w+)\s+(\w+)\s*\((.*)\)/);
7910
+ if (!match) {
7911
+ if (input.length === 2) {
7912
+ return `
7913
+ #include <stdio.h>
7914
+ #include <stdlib.h>
7915
+ #include <stdbool.h>
7916
+ #include <string.h>
7917
+
7918
+ ${code4}
7919
+
7920
+ int main() {
7921
+ int v0, v1;
7922
+ if (scanf("%d %d", &v0, &v1) == 2) {
7923
+ // Try to call 'add' if it exists in the code
7924
+ ${code4.includes("add") ? 'printf("%d", add(v0, v1));' : "// Function not found"}
7925
+ }
7926
+ return 0;
7927
+ }
7928
+ `;
7929
+ }
7930
+ return code4;
7931
+ }
7932
+ const [, , funcName, paramsStr] = match;
7933
+ const params = paramsStr.split(",").map((p4) => p4.trim()).filter((p4) => p4.length > 0);
7934
+ let scanfFormat = "";
7935
+ let scanfArgs = "";
7936
+ let callArgs = "";
7937
+ params.forEach((p4, i3) => {
7938
+ const parts = p4.split(/\s+/);
7939
+ const type = parts[0];
7940
+ parts[parts.length - 1];
7941
+ let fmt = "%d";
7942
+ if (type === "float" || type === "double") fmt = "%lf";
7943
+ if (type === "char*") fmt = "%s";
7944
+ scanfFormat += (i3 === 0 ? "" : " ") + fmt;
7945
+ scanfArgs += `, &v${i3}`;
7946
+ callArgs += (i3 === 0 ? "" : ", ") + `v${i3}`;
7947
+ });
7948
+ return `
7949
+ #include <stdio.h>
7950
+ #include <stdlib.h>
7951
+ #include <stdbool.h>
7952
+ #include <string.h>
7953
+
7954
+ ${code4}
7955
+
7956
+ int main() {
7957
+ ${params.map((p4, i3) => `${p4.split(/\s+/)[0]} v${i3};`).join("\n ")}
7958
+ if (scanf("${scanfFormat}"${scanfArgs}) != ${params.length}) return 1;
7959
+ printf("%d", ${funcName}(${callArgs}));
7960
+ return 0;
7961
+ }
7962
+ `;
7963
+ }
7964
+ };
7965
+
7686
7966
  // src/services/CodeEvaluationService.ts
7687
7967
  var CodeEvaluationService = class {
7688
7968
  constructor() {
@@ -7690,27 +7970,46 @@ var CodeEvaluationService = class {
7690
7970
  }
7691
7971
  /**
7692
7972
  * Ensure execution system is initialized with latest keys.
7973
+ * Order of precedence: LocalStorage (User choice) > Environment Variables (System default)
7693
7974
  */
7694
7975
  ensureInitialized() {
7695
7976
  if (typeof window === "undefined") return;
7696
- const geminiKey = APIKeyService.getAPIKey(GEMINI_API_KEY_SERVICE_NAME) || void 0;
7697
- const judge0Url = APIKeyService.getAPIKey(JUDGE0_API_URL_SERVICE_NAME) || void 0;
7698
- const judge0Key = APIKeyService.getAPIKey(JUDGE0_API_KEY_SERVICE_NAME) || void 0;
7977
+ const geminiKey = APIKeyService.getAPIKey(GEMINI_API_KEY_SERVICE_NAME) || "";
7978
+ const judge0PrimaryUrl = APIKeyService.getAPIKey(JUDGE0_PRIMARY_API_URL_SERVICE_NAME) || "/api/judge0";
7979
+ const judge0PrimaryKey = APIKeyService.getAPIKey(JUDGE0_PRIMARY_API_KEY_SERVICE_NAME) || "Code@Orchable";
7980
+ const judge0FallbackUrl = APIKeyService.getAPIKey(JUDGE0_FALLBACK_API_URL_SERVICE_NAME) || "https://judge0-ce.p.rapidapi.com";
7981
+ const judge0FallbackKey = APIKeyService.getAPIKey(JUDGE0_FALLBACK_API_KEY_SERVICE_NAME) || "9343426db9mshd122142ba1d0927p1259d6jsne24390a88e67";
7982
+ const pistonPrimaryUrl = APIKeyService.getAPIKey(PISTON_PRIMARY_API_URL_SERVICE_NAME) || "/api/piston";
7983
+ const pistonPrimaryKey = "Piston@Orchable";
7699
7984
  initExecutionSystem({
7700
- geminiKey,
7701
- judge0Url,
7702
- judge0Key
7985
+ geminiKey: geminiKey || void 0,
7986
+ pistonPrimary: {
7987
+ url: pistonPrimaryUrl,
7988
+ key: pistonPrimaryKey
7989
+ } ,
7990
+ judge0Primary: {
7991
+ url: judge0PrimaryUrl,
7992
+ key: judge0PrimaryKey
7993
+ } ,
7994
+ judge0Fallback: {
7995
+ url: judge0FallbackUrl,
7996
+ key: judge0FallbackKey
7997
+ }
7703
7998
  });
7704
7999
  }
7705
8000
  async evaluateSingleTestCase(question, userCode, testCase) {
7706
8001
  try {
8002
+ const wrappedCode = CodeWrapper.wrap(userCode, question.codingLanguage, {
8003
+ functionSignature: question.functionSignature,
8004
+ testCaseInput: testCase.input
8005
+ });
7707
8006
  const result = await executionService.execute(
7708
- userCode,
8007
+ wrappedCode,
7709
8008
  question.codingLanguage,
7710
8009
  Array.isArray(testCase.input) ? testCase.input.join("\n") : String(testCase.input || "")
7711
8010
  );
7712
- const actual = (result.stdout || "").trim();
7713
- const expected = (testCase.expectedOutput || "").trim();
8011
+ const actual = String(result.stdout || "").trim();
8012
+ const expected = String(testCase.expectedOutput || "").trim();
7714
8013
  const statusPassed = result.exitCode === 0;
7715
8014
  const outputMatches = actual === expected;
7716
8015
  const passed = statusPassed && outputMatches;
@@ -62866,13 +63165,30 @@ function rehypeKatex(options) {
62866
63165
  });
62867
63166
  };
62868
63167
  }
62869
- var ScratchBlocksRenderer2 = dynamic__default.default(
62870
- () => Promise.resolve().then(() => (init_ScratchBlocksRenderer(), ScratchBlocksRenderer_exports)).then((mod) => mod.ScratchBlocksRenderer),
62871
- { ssr: false }
63168
+ var ScratchBlocksRenderer2 = React78__namespace.default.lazy(
63169
+ () => Promise.resolve().then(() => (init_ScratchBlocksRenderer(), ScratchBlocksRenderer_exports)).then((module) => ({
63170
+ default: module.ScratchBlocksRenderer
63171
+ }))
62872
63172
  );
63173
+ var ScratchRendererErrorBoundary = class extends React78__namespace.default.Component {
63174
+ constructor() {
63175
+ super(...arguments);
63176
+ this.state = { failed: false };
63177
+ }
63178
+ static getDerivedStateFromError() {
63179
+ return { failed: true };
63180
+ }
63181
+ componentDidCatch(error) {
63182
+ console.error("ScratchBlocksRenderer failed to load:", error);
63183
+ }
63184
+ render() {
63185
+ return this.state.failed ? this.props.fallback : this.props.children;
63186
+ }
63187
+ };
62873
63188
  var ClientScratchRenderer = ({ code: code4, isInline }) => {
62874
63189
  const { i18n } = reactI18next.useTranslation();
62875
- const content3 = /* @__PURE__ */ React78__namespace.default.createElement(
63190
+ const fallback = isInline ? /* @__PURE__ */ React78__namespace.default.createElement("code", { className: "bg-muted px-1.5 py-0.5 rounded text-sm font-mono opacity-70", "aria-label": "Loading scratch block" }, code4) : /* @__PURE__ */ React78__namespace.default.createElement("pre", { className: "bg-muted p-4 rounded-lg overflow-x-auto my-4 text-sm font-mono opacity-70", "aria-label": "Loading scratch block" }, /* @__PURE__ */ React78__namespace.default.createElement("code", null, code4));
63191
+ const content3 = /* @__PURE__ */ React78__namespace.default.createElement(ScratchRendererErrorBoundary, { key: `${isInline ? "inline" : "block"}:${code4}`, fallback }, /* @__PURE__ */ React78__namespace.default.createElement(React78__namespace.default.Suspense, { fallback }, /* @__PURE__ */ React78__namespace.default.createElement(
62876
63192
  ScratchBlocksRenderer2,
62877
63193
  {
62878
63194
  code: code4,
@@ -62880,7 +63196,7 @@ var ClientScratchRenderer = ({ code: code4, isInline }) => {
62880
63196
  fromLang: "en",
62881
63197
  toLang: i18n.language === "vi" ? "vi" : "en"
62882
63198
  }
62883
- );
63199
+ )));
62884
63200
  if (isInline) {
62885
63201
  return /* @__PURE__ */ React78__namespace.default.createElement("span", { className: "inline-block align-middle" }, content3);
62886
63202
  }
@@ -62936,18 +63252,21 @@ var MarkdownRenderer = ({ content: content3, className }) => {
62936
63252
  }
62937
63253
  ));
62938
63254
  }
62939
- return /* @__PURE__ */ React78__namespace.default.createElement(
62940
- Image2__default.default,
62941
- {
62942
- src,
62943
- alt: props.alt || "",
62944
- width: 0,
62945
- height: 0,
62946
- sizes: "100vw",
62947
- style: { width: "100%", height: "auto" },
62948
- className: "max-w-full rounded-lg my-4",
62949
- unoptimized: true
62950
- }
63255
+ return (
63256
+ // This renderer is intentionally framework-neutral. Next Image
63257
+ // optimization was already disabled in the previous implementation.
63258
+ // eslint-disable-next-line @next/next/no-img-element
63259
+ /* @__PURE__ */ React78__namespace.default.createElement(
63260
+ "img",
63261
+ {
63262
+ src,
63263
+ alt: props.alt || "",
63264
+ loading: "lazy",
63265
+ decoding: "async",
63266
+ sizes: "100vw",
63267
+ className: "max-w-full w-full h-auto rounded-lg my-4"
63268
+ }
63269
+ )
62951
63270
  );
62952
63271
  },
62953
63272
  table: ({ node: node2, ...props }) => /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "overflow-x-auto my-4 rounded-lg border border-border" }, /* @__PURE__ */ React78__namespace.default.createElement("table", { ...props, className: "w-full text-sm border-collapse" })),
@@ -66756,8 +67075,8 @@ var styleHookSingleton = function() {
66756
67075
  var styleSingleton = function() {
66757
67076
  var useStyle = styleHookSingleton();
66758
67077
  var Sheet2 = function(_a2) {
66759
- var styles2 = _a2.styles, dynamic2 = _a2.dynamic;
66760
- useStyle(styles2, dynamic2);
67078
+ var styles2 = _a2.styles, dynamic = _a2.dynamic;
67079
+ useStyle(styles2, dynamic);
66761
67080
  return null;
66762
67081
  };
66763
67082
  return Sheet2;
@@ -74270,7 +74589,8 @@ var CodingQuestionUI = ({
74270
74589
  question,
74271
74590
  onAnswerChange,
74272
74591
  userAnswer,
74273
- showCorrectAnswer = false
74592
+ showCorrectAnswer = false,
74593
+ showExecutionSettings
74274
74594
  }) => {
74275
74595
  const [code4, setCode] = React78.useState("");
74276
74596
  const [isRunningTests, setIsRunningTests] = React78.useState(false);
@@ -74278,21 +74598,27 @@ var CodingQuestionUI = ({
74278
74598
  const [showSettings, setShowSettings] = React78.useState(false);
74279
74599
  const [keys2, setKeys] = React78.useState({
74280
74600
  gemini: "",
74281
- judge0Url: "",
74282
- judge0Key: ""
74601
+ judge0PrimaryUrl: "",
74602
+ judge0PrimaryKey: "",
74603
+ judge0FallbackUrl: "",
74604
+ judge0FallbackKey: ""
74283
74605
  });
74284
74606
  const { toast: toast2 } = useToast();
74285
74607
  React78.useEffect(() => {
74286
74608
  setKeys({
74287
74609
  gemini: APIKeyService.getAPIKey(GEMINI_API_KEY_SERVICE_NAME) || "",
74288
- judge0Url: APIKeyService.getAPIKey(JUDGE0_API_URL_SERVICE_NAME) || "",
74289
- judge0Key: APIKeyService.getAPIKey(JUDGE0_API_KEY_SERVICE_NAME) || ""
74610
+ judge0PrimaryUrl: APIKeyService.getAPIKey(JUDGE0_PRIMARY_API_URL_SERVICE_NAME) || "",
74611
+ judge0PrimaryKey: APIKeyService.getAPIKey(JUDGE0_PRIMARY_API_KEY_SERVICE_NAME) || "",
74612
+ judge0FallbackUrl: APIKeyService.getAPIKey(JUDGE0_FALLBACK_API_URL_SERVICE_NAME) || "",
74613
+ judge0FallbackKey: APIKeyService.getAPIKey(JUDGE0_FALLBACK_API_KEY_SERVICE_NAME) || ""
74290
74614
  });
74291
74615
  }, []);
74292
74616
  const handleSaveKeys = () => {
74293
74617
  APIKeyService.saveAPIKey(GEMINI_API_KEY_SERVICE_NAME, keys2.gemini);
74294
- APIKeyService.saveAPIKey(JUDGE0_API_URL_SERVICE_NAME, keys2.judge0Url);
74295
- APIKeyService.saveAPIKey(JUDGE0_API_KEY_SERVICE_NAME, keys2.judge0Key);
74618
+ APIKeyService.saveAPIKey(JUDGE0_PRIMARY_API_URL_SERVICE_NAME, keys2.judge0PrimaryUrl);
74619
+ APIKeyService.saveAPIKey(JUDGE0_PRIMARY_API_KEY_SERVICE_NAME, keys2.judge0PrimaryKey);
74620
+ APIKeyService.saveAPIKey(JUDGE0_FALLBACK_API_URL_SERVICE_NAME, keys2.judge0FallbackUrl);
74621
+ APIKeyService.saveAPIKey(JUDGE0_FALLBACK_API_KEY_SERVICE_NAME, keys2.judge0FallbackKey);
74296
74622
  setShowSettings(false);
74297
74623
  toast2({
74298
74624
  title: "Settings Saved",
@@ -74325,7 +74651,7 @@ var CodingQuestionUI = ({
74325
74651
  setIsRunningTests(false);
74326
74652
  }
74327
74653
  };
74328
- return /* @__PURE__ */ React78__namespace.default.createElement(Card, { className: "w-full border-none shadow-none bg-transparent" }, /* @__PURE__ */ React78__namespace.default.createElement(CardHeader, { className: "p-0 pb-6" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex justify-between items-start" }, /* @__PURE__ */ React78__namespace.default.createElement("div", null, /* @__PURE__ */ React78__namespace.default.createElement(CardTitle, { className: "text-2xl font-bold tracking-tight mb-2" }, /* @__PURE__ */ React78__namespace.default.createElement(MarkdownRenderer, { content: question.prompt })), question.points && /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React78__namespace.default.createElement("span", { className: "px-2 py-0.5 rounded-full bg-primary/10 text-primary text-xs font-medium border border-primary/20" }, question.points, " Points"), /* @__PURE__ */ React78__namespace.default.createElement("span", { className: "px-2 py-0.5 rounded-full bg-muted text-muted-foreground text-xs font-medium border" }, question.codingLanguage.toUpperCase()))), /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React78__namespace.default.createElement(
74654
+ return /* @__PURE__ */ React78__namespace.default.createElement(Card, { className: "w-full border-none shadow-none bg-transparent" }, /* @__PURE__ */ React78__namespace.default.createElement(CardHeader, { className: "p-0 pb-6" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex justify-between items-start" }, /* @__PURE__ */ React78__namespace.default.createElement("div", null, /* @__PURE__ */ React78__namespace.default.createElement(CardTitle, { className: "text-2xl font-bold tracking-tight mb-2" }, /* @__PURE__ */ React78__namespace.default.createElement(MarkdownRenderer, { content: question.prompt })), question.points && /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React78__namespace.default.createElement("span", { className: "px-2 py-0.5 rounded-full bg-primary/10 text-primary text-xs font-medium border border-primary/20" }, question.points, " Points"), /* @__PURE__ */ React78__namespace.default.createElement("span", { className: "px-2 py-0.5 rounded-full bg-muted text-muted-foreground text-xs font-medium border" }, question.codingLanguage.toUpperCase()))), (showExecutionSettings ?? process.env.NEXT_PUBLIC_SHOW_EXECUTION_SETTINGS === "true") && /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React78__namespace.default.createElement(
74329
74655
  Button,
74330
74656
  {
74331
74657
  variant: "outline",
@@ -74344,21 +74670,38 @@ var CodingQuestionUI = ({
74344
74670
  placeholder: "AI fallback key...",
74345
74671
  className: "w-full bg-black/20 border border-white/10 rounded px-3 py-1.5 text-sm focus:border-primary/50 outline-none"
74346
74672
  }
74347
- )), /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "grid grid-cols-2 gap-4" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React78__namespace.default.createElement("label", { className: "text-xs font-bold uppercase tracking-wider opacity-60" }, "Judge0 API URL (native code)"), /* @__PURE__ */ React78__namespace.default.createElement(
74673
+ )), /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "grid grid-cols-2 gap-4" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React78__namespace.default.createElement("label", { className: "text-xs font-bold uppercase tracking-wider opacity-60" }, "Judge0 Primary URL (Self-hosted)"), /* @__PURE__ */ React78__namespace.default.createElement(
74674
+ "input",
74675
+ {
74676
+ type: "text",
74677
+ value: keys2.judge0PrimaryUrl,
74678
+ onChange: (e2) => setKeys({ ...keys2, judge0PrimaryUrl: e2.target.value }),
74679
+ placeholder: "https://your-server.com",
74680
+ className: "w-full bg-black/20 border border-white/10 rounded px-3 py-1.5 text-sm focus:border-primary/50 outline-none"
74681
+ }
74682
+ )), /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React78__namespace.default.createElement("label", { className: "text-xs font-bold uppercase tracking-wider opacity-60" }, "Judge0 Primary Key"), /* @__PURE__ */ React78__namespace.default.createElement(
74683
+ "input",
74684
+ {
74685
+ type: "password",
74686
+ value: keys2.judge0PrimaryKey,
74687
+ onChange: (e2) => setKeys({ ...keys2, judge0PrimaryKey: e2.target.value }),
74688
+ className: "w-full bg-black/20 border border-white/10 rounded px-3 py-1.5 text-sm focus:border-primary/50 outline-none"
74689
+ }
74690
+ ))), /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "grid grid-cols-2 gap-4" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React78__namespace.default.createElement("label", { className: "text-xs font-bold uppercase tracking-wider opacity-60" }, "Judge0 Fallback URL (RapidAPI)"), /* @__PURE__ */ React78__namespace.default.createElement(
74348
74691
  "input",
74349
74692
  {
74350
74693
  type: "text",
74351
- value: keys2.judge0Url,
74352
- onChange: (e2) => setKeys({ ...keys2, judge0Url: e2.target.value }),
74353
- placeholder: "https://judge0-instance.com",
74694
+ value: keys2.judge0FallbackUrl,
74695
+ onChange: (e2) => setKeys({ ...keys2, judge0FallbackUrl: e2.target.value }),
74696
+ placeholder: "https://judge0-ce.p.rapidapi.com",
74354
74697
  className: "w-full bg-black/20 border border-white/10 rounded px-3 py-1.5 text-sm focus:border-primary/50 outline-none"
74355
74698
  }
74356
- )), /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React78__namespace.default.createElement("label", { className: "text-xs font-bold uppercase tracking-wider opacity-60" }, "Judge0 API Key"), /* @__PURE__ */ React78__namespace.default.createElement(
74699
+ )), /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React78__namespace.default.createElement("label", { className: "text-xs font-bold uppercase tracking-wider opacity-60" }, "Judge0 Fallback Key"), /* @__PURE__ */ React78__namespace.default.createElement(
74357
74700
  "input",
74358
74701
  {
74359
74702
  type: "password",
74360
- value: keys2.judge0Key,
74361
- onChange: (e2) => setKeys({ ...keys2, judge0Key: e2.target.value }),
74703
+ value: keys2.judge0FallbackKey,
74704
+ onChange: (e2) => setKeys({ ...keys2, judge0FallbackKey: e2.target.value }),
74362
74705
  className: "w-full bg-black/20 border border-white/10 rounded px-3 py-1.5 text-sm focus:border-primary/50 outline-none"
74363
74706
  }
74364
74707
  )))), /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex justify-end pt-2" }, /* @__PURE__ */ React78__namespace.default.createElement(Button, { size: "sm", onClick: handleSaveKeys }, "Apply Changes"))))), /* @__PURE__ */ React78__namespace.default.createElement(CardContent, { className: "p-0 space-y-6" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "relative group" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "absolute -inset-0.5 bg-gradient-to-r from-blue-500/20 to-purple-500/20 rounded-xl blur opacity-30 group-hover:opacity-100 transition duration-1000 group-hover:duration-200" }), /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "relative border border-white/10 rounded-xl overflow-hidden bg-[#1e1e1e] shadow-2xl" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex items-center justify-between px-4 py-2 bg-[#252526] border-b border-white/5" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex items-center gap-1.5" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "w-3 h-3 rounded-full bg-[#ff5f56]" }), /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "w-3 h-3 rounded-full bg-[#ffbd2e]" }), /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "w-3 h-3 rounded-full bg-[#27c93f]" }), /* @__PURE__ */ React78__namespace.default.createElement("span", { className: "ml-2 text-xs font-mono text-muted-foreground uppercase tracking-widest opacity-50" }, "solution.", question.codingLanguage))), /* @__PURE__ */ React78__namespace.default.createElement(
@@ -74392,15 +74735,15 @@ var CodingQuestionUI = ({
74392
74735
  isRunningTests ? /* @__PURE__ */ React78__namespace.default.createElement(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ React78__namespace.default.createElement(Play, { className: "mr-2 h-4 w-4 fill-current" }),
74393
74736
  isRunningTests ? "Evaluating..." : "Run Test Cases"
74394
74737
  ), /* @__PURE__ */ React78__namespace.default.createElement("span", { className: "text-xs text-muted-foreground italic" }, "* Verification uses tiered execution (Native ", ">", " Lite ", ">", " AI)")), /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "space-y-3" }, /* @__PURE__ */ React78__namespace.default.createElement(Tabs2, { defaultValue: "console", className: "w-full" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex items-center justify-between mb-2" }, /* @__PURE__ */ React78__namespace.default.createElement(TabsList2, { className: "bg-muted/50 p-1 rounded-lg border h-auto" }, /* @__PURE__ */ React78__namespace.default.createElement(TabsTrigger2, { value: "console", className: "px-4 py-1.5 data-[state=active]:bg-background data-[state=active]:shadow-sm" }, /* @__PURE__ */ React78__namespace.default.createElement(Terminal, { className: "w-3.5 h-3.5 mr-2" }), "Console"), showCorrectAnswer && /* @__PURE__ */ React78__namespace.default.createElement(TabsTrigger2, { value: "solution", className: "px-4 py-1.5 data-[state=active]:bg-background data-[state=active]:shadow-sm" }, /* @__PURE__ */ React78__namespace.default.createElement(Info, { className: "w-3.5 h-3.5 mr-2" }), "Reference Solution"))), /* @__PURE__ */ React78__namespace.default.createElement(TabsContent2, { value: "console", className: "mt-0 focus-visible:outline-none" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: cn(
74395
- "rounded-xl border border-white/5 bg-black/40 backdrop-blur-md overflow-hidden min-h-[160px] flex flex-col",
74738
+ "rounded-xl border border-border bg-muted/30 dark:bg-black/40 backdrop-blur-md overflow-hidden min-h-[160px] flex flex-col",
74396
74739
  testResults.length > 0 ? "h-auto" : "h-[160px]"
74397
- ) }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex items-center px-4 py-2 border-b border-white/5 bg-white/5" }, /* @__PURE__ */ React78__namespace.default.createElement("span", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-[0.2em]" }, "Execution Output")), /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "p-4 flex-1 font-mono text-sm" }, testResults.length > 0 ? /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "grid gap-3" }, testResults.map((result, index3) => /* @__PURE__ */ React78__namespace.default.createElement("div", { key: result.testCaseId, className: "group animate-in fade-in slide-in-from-left-2 duration-300" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: cn(
74398
- "flex items-start p-3 rounded-lg border transition-all",
74399
- result.passed ? "bg-green-500/5 border-green-500/20 text-green-400" : "bg-red-500/5 border-red-500/20 text-red-400"
74400
- ) }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "mt-1 mr-3 shrink-0" }, result.passed ? /* @__PURE__ */ React78__namespace.default.createElement(CircleCheck, { className: "h-5 w-5" }) : /* @__PURE__ */ React78__namespace.default.createElement(CircleX, { className: "h-5 w-5" })), /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex-1 min-w-0" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex items-center justify-between mb-1" }, /* @__PURE__ */ React78__namespace.default.createElement("span", { className: "font-bold" }, "Test Case #", index3 + 1), /* @__PURE__ */ React78__namespace.default.createElement("span", { className: cn(
74401
- "text-[10px] uppercase font-black px-1.5 py-0.5 rounded",
74402
- result.passed ? "bg-green-500/20" : "bg-red-500/20"
74403
- ) }, result.passed ? "Accepted" : "Failed")), /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "grid grid-cols-1 gap-2 opacity-90" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "text-xs" }, /* @__PURE__ */ React78__namespace.default.createElement("span", { className: "opacity-50 font-semibold mr-2" }, ">", " Status:"), result.reasoning), !result.passed && /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "mt-2 p-2 bg-black/40 rounded border border-white/5 text-[11px] overflow-x-auto" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex gap-4" }, /* @__PURE__ */ React78__namespace.default.createElement("div", null, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "text-muted-foreground mb-1 uppercase text-[9px] font-bold" }, "Input"), /* @__PURE__ */ React78__namespace.default.createElement("code", { className: "text-white/80" }, Array.isArray(question.testCases[index3].input) ? question.testCases[index3].input.join(", ") : question.testCases[index3].input)), /* @__PURE__ */ React78__namespace.default.createElement("div", null, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "text-muted-foreground mb-1 uppercase text-[9px] font-bold" }, "Expected"), /* @__PURE__ */ React78__namespace.default.createElement("code", { className: "text-green-400" }, question.testCases[index3].expectedOutput)), /* @__PURE__ */ React78__namespace.default.createElement("div", null, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "text-muted-foreground mb-1 uppercase text-[9px] font-bold" }, "Actual"), /* @__PURE__ */ React78__namespace.default.createElement("code", { className: "text-red-400" }, result.actualOutput)))))))))) : /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "h-full flex flex-col items-center justify-center text-muted-foreground/30 py-8 italic text-xs" }, /* @__PURE__ */ React78__namespace.default.createElement(Terminal, { className: "h-8 w-8 mb-3 opacity-20" }), /* @__PURE__ */ React78__namespace.default.createElement("p", null, isRunningTests ? "Processing internal execution pipeline..." : "Run tests to see diagnostic output"))))), showCorrectAnswer && /* @__PURE__ */ React78__namespace.default.createElement(TabsContent2, { value: "solution", className: "mt-0 focus-visible:outline-none" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "relative border border-white/10 rounded-xl overflow-hidden bg-[#1e1e1e] shadow-2xl" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex items-center px-4 py-2 bg-[#252526] border-b border-white/5" }, /* @__PURE__ */ React78__namespace.default.createElement("span", { className: "text-xs font-mono text-muted-foreground uppercase tracking-widest opacity-50" }, "reference_solution.", question.codingLanguage)), /* @__PURE__ */ React78__namespace.default.createElement(
74740
+ ) }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex items-center px-4 py-2 border-b border-border bg-muted/50 dark:bg-white/5" }, /* @__PURE__ */ React78__namespace.default.createElement("span", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-[0.2em]" }, "Execution Output")), /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "p-4 flex-1 font-mono text-sm" }, testResults.length > 0 ? /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "grid gap-3" }, testResults.map((result, index3) => /* @__PURE__ */ React78__namespace.default.createElement("div", { key: result.testCaseId, className: "group animate-in fade-in slide-in-from-left-2 duration-300" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: cn(
74741
+ "flex items-start p-3 rounded-lg border transition-all shadow-sm",
74742
+ result.passed ? "bg-green-50/50 dark:bg-green-500/5 border-green-500/30 text-green-700 dark:text-green-400" : "bg-red-50/50 dark:bg-red-500/5 border-red-500/30 text-red-700 dark:text-red-400"
74743
+ ) }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "mt-1 mr-3 shrink-0" }, result.passed ? /* @__PURE__ */ React78__namespace.default.createElement(CircleCheck, { className: "h-5 w-5 fill-green-500/20" }) : /* @__PURE__ */ React78__namespace.default.createElement(CircleX, { className: "h-5 w-5 fill-red-500/20" })), /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex-1 min-w-0" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex items-center justify-between mb-1" }, /* @__PURE__ */ React78__namespace.default.createElement("span", { className: "font-bold text-sm" }, "Test Case #", index3 + 1), /* @__PURE__ */ React78__namespace.default.createElement("span", { className: cn(
74744
+ "text-[10px] uppercase font-black px-1.5 py-0.5 rounded tracking-tighter",
74745
+ result.passed ? "bg-green-500/10 text-green-600 dark:text-green-400" : "bg-red-500/10 text-red-600 dark:text-red-400"
74746
+ ) }, result.passed ? "Accepted" : "Failed")), /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "grid grid-cols-1 gap-2 opacity-90" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "text-xs font-medium leading-relaxed" }, /* @__PURE__ */ React78__namespace.default.createElement("span", { className: "opacity-60 mr-2 font-mono" }, ">"), result.reasoning), !result.passed && /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "mt-3 p-3 bg-muted/40 dark:bg-black/40 rounded-lg border border-border text-[11px] overflow-x-auto shadow-inner" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex gap-6" }, /* @__PURE__ */ React78__namespace.default.createElement("div", null, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "text-muted-foreground mb-1 uppercase text-[9px] font-extrabold tracking-widest" }, "Input"), /* @__PURE__ */ React78__namespace.default.createElement("code", { className: "text-foreground/90 font-mono font-bold" }, Array.isArray(question.testCases[index3].input) ? question.testCases[index3].input.join(", ") : question.testCases[index3].input)), /* @__PURE__ */ React78__namespace.default.createElement("div", null, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "text-muted-foreground mb-1 uppercase text-[9px] font-extrabold tracking-widest" }, "Expected"), /* @__PURE__ */ React78__namespace.default.createElement("code", { className: "text-green-600 dark:text-green-400 font-mono font-bold" }, String(question.testCases[index3].expectedOutput))), /* @__PURE__ */ React78__namespace.default.createElement("div", null, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "text-muted-foreground mb-1 uppercase text-[9px] font-extrabold tracking-widest" }, "Actual"), /* @__PURE__ */ React78__namespace.default.createElement("code", { className: "text-red-600 dark:text-red-400 font-mono font-bold" }, String(result.actualOutput))))))))))) : /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "h-full flex flex-col items-center justify-center text-muted-foreground/30 py-8 italic text-xs" }, /* @__PURE__ */ React78__namespace.default.createElement(Terminal, { className: "h-8 w-8 mb-3 opacity-20" }), /* @__PURE__ */ React78__namespace.default.createElement("p", null, isRunningTests ? "Processing internal execution pipeline..." : "Run tests to see diagnostic output"))))), showCorrectAnswer && /* @__PURE__ */ React78__namespace.default.createElement(TabsContent2, { value: "solution", className: "mt-0 focus-visible:outline-none" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "relative border border-white/10 rounded-xl overflow-hidden bg-[#1e1e1e] shadow-2xl" }, /* @__PURE__ */ React78__namespace.default.createElement("div", { className: "flex items-center px-4 py-2 bg-[#252526] border-b border-white/5" }, /* @__PURE__ */ React78__namespace.default.createElement("span", { className: "text-xs font-mono text-muted-foreground uppercase tracking-widest opacity-50" }, "reference_solution.", question.codingLanguage)), /* @__PURE__ */ React78__namespace.default.createElement(
74404
74747
  Editor__default.default,
74405
74748
  {
74406
74749
  height: "300px",