@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/i18n.cjs +5 -2374
- package/dist/i18n.mjs +4 -2374
- package/dist/index.cjs +438 -2508
- package/dist/index.mjs +437 -2508
- package/dist/player.cjs +1263 -3292
- package/dist/player.mjs +1262 -3290
- package/dist/react-ui.cjs +427 -84
- package/dist/react-ui.mjs +427 -82
- package/package.json +5 -3
package/dist/react-ui.mjs
CHANGED
|
@@ -5,11 +5,9 @@ import { GoogleGenerativeAI } from '@google/generative-ai';
|
|
|
5
5
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
6
|
import * as ReactDOM5 from 'react-dom';
|
|
7
7
|
import ReactDOM5__default, { createPortal, unstable_batchedUpdates } from 'react-dom';
|
|
8
|
-
import Image2 from 'next/image';
|
|
9
8
|
import default2 from 'path';
|
|
10
9
|
import default3 from 'process';
|
|
11
10
|
import { fileURLToPath } from 'url';
|
|
12
|
-
import dynamic from 'next/dynamic';
|
|
13
11
|
import Editor from '@monaco-editor/react';
|
|
14
12
|
|
|
15
13
|
var __create = Object.create;
|
|
@@ -7192,6 +7190,12 @@ var ExecutionService = class _ExecutionService {
|
|
|
7192
7190
|
}
|
|
7193
7191
|
return _ExecutionService.instance;
|
|
7194
7192
|
}
|
|
7193
|
+
/**
|
|
7194
|
+
* Clear all registered providers.
|
|
7195
|
+
*/
|
|
7196
|
+
clearProviders() {
|
|
7197
|
+
this.providers.clear();
|
|
7198
|
+
}
|
|
7195
7199
|
/**
|
|
7196
7200
|
* Register a provider.
|
|
7197
7201
|
*/
|
|
@@ -7208,20 +7212,25 @@ var ExecutionService = class _ExecutionService {
|
|
|
7208
7212
|
* Get the best provider for a language based on priority and availability.
|
|
7209
7213
|
*/
|
|
7210
7214
|
async getBestProvider(language2) {
|
|
7211
|
-
const
|
|
7215
|
+
const lang = language2.toLowerCase();
|
|
7216
|
+
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));
|
|
7217
|
+
console.log(`[ExecutionService] Finding best provider for '${language2}' (normalized: '${lang}'). Found ${sortedProviders.length} potential providers.`);
|
|
7212
7218
|
for (const provider of sortedProviders) {
|
|
7213
7219
|
if (await provider.isAvailable()) {
|
|
7220
|
+
console.log(`[ExecutionService] Selected provider: ${provider.name} (ID: ${provider.id})`);
|
|
7214
7221
|
return provider;
|
|
7215
7222
|
}
|
|
7216
7223
|
}
|
|
7217
7224
|
return null;
|
|
7218
7225
|
}
|
|
7219
7226
|
/**
|
|
7220
|
-
* Execute code using the best available provider.
|
|
7227
|
+
* Execute code using the best available provider with automatic fallback.
|
|
7221
7228
|
*/
|
|
7222
7229
|
async execute(code4, language2, stdin) {
|
|
7223
|
-
const
|
|
7224
|
-
|
|
7230
|
+
const lang = language2.toLowerCase();
|
|
7231
|
+
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));
|
|
7232
|
+
console.log(`[ExecutionService] Executing for '${language2}'. Providers in order:`, providers.map((p4) => `${p4.name} (${p4.id})`));
|
|
7233
|
+
if (providers.length === 0) {
|
|
7225
7234
|
return {
|
|
7226
7235
|
stdout: "",
|
|
7227
7236
|
stderr: `No execution provider available for language: ${language2}`,
|
|
@@ -7229,16 +7238,28 @@ var ExecutionService = class _ExecutionService {
|
|
|
7229
7238
|
message: "EXECUTION_ERROR_NO_PROVIDER"
|
|
7230
7239
|
};
|
|
7231
7240
|
}
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
exitCode
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
+
let lastError = null;
|
|
7242
|
+
for (const provider of providers) {
|
|
7243
|
+
try {
|
|
7244
|
+
if (!await provider.isAvailable()) continue;
|
|
7245
|
+
const result = await provider.execute(code4, language2, stdin);
|
|
7246
|
+
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
|
|
7247
|
+
result.exitCode === 1 && !result.stderr;
|
|
7248
|
+
if (isRecoverable && providers.indexOf(provider) < providers.length - 1) {
|
|
7249
|
+
lastError = result;
|
|
7250
|
+
continue;
|
|
7251
|
+
}
|
|
7252
|
+
return result;
|
|
7253
|
+
} catch (error) {
|
|
7254
|
+
lastError = error;
|
|
7255
|
+
}
|
|
7241
7256
|
}
|
|
7257
|
+
return {
|
|
7258
|
+
stdout: "",
|
|
7259
|
+
stderr: lastError?.stderr || lastError?.message || "All execution providers failed",
|
|
7260
|
+
exitCode: 1,
|
|
7261
|
+
message: "EXECUTION_ERROR_ALL_FAILED"
|
|
7262
|
+
};
|
|
7242
7263
|
}
|
|
7243
7264
|
};
|
|
7244
7265
|
var executionService = ExecutionService.getInstance();
|
|
@@ -7246,9 +7267,7 @@ var executionService = ExecutionService.getInstance();
|
|
|
7246
7267
|
// src/lib/execution/providers/Judge0Provider.ts
|
|
7247
7268
|
init_react_shim();
|
|
7248
7269
|
var Judge0Provider = class {
|
|
7249
|
-
constructor(apiUrl, apiKey) {
|
|
7250
|
-
this.id = "judge0";
|
|
7251
|
-
this.name = "Judge0 Professional";
|
|
7270
|
+
constructor(apiUrl, apiKey, options) {
|
|
7252
7271
|
this.languageMap = {
|
|
7253
7272
|
"python": 71,
|
|
7254
7273
|
"javascript": 63,
|
|
@@ -7261,6 +7280,9 @@ var Judge0Provider = class {
|
|
|
7261
7280
|
};
|
|
7262
7281
|
this.apiUrl = apiUrl;
|
|
7263
7282
|
this.apiKey = apiKey;
|
|
7283
|
+
this.id = options?.id || "judge0";
|
|
7284
|
+
this.name = options?.name || "Judge0 Professional";
|
|
7285
|
+
this.customPriority = options?.priority;
|
|
7264
7286
|
}
|
|
7265
7287
|
async isAvailable() {
|
|
7266
7288
|
return !!this.apiUrl;
|
|
@@ -7296,11 +7318,15 @@ var Judge0Provider = class {
|
|
|
7296
7318
|
};
|
|
7297
7319
|
}
|
|
7298
7320
|
try {
|
|
7321
|
+
console.log(`[Judge0Provider] Calling ${this.name} at ${this.apiUrl}...`);
|
|
7299
7322
|
const response = await fetch(`${this.apiUrl}/submissions?base64_encoded=true&wait=true`, {
|
|
7300
7323
|
method: "POST",
|
|
7301
7324
|
headers: {
|
|
7302
7325
|
"Content-Type": "application/json",
|
|
7303
|
-
...this.apiKey &&
|
|
7326
|
+
...this.apiKey && (this.apiUrl.includes("rapidapi.com") ? {
|
|
7327
|
+
"x-rapidapi-key": this.apiKey,
|
|
7328
|
+
"x-rapidapi-host": new URL(this.apiUrl).hostname
|
|
7329
|
+
} : { "X-Auth-Token": this.apiKey })
|
|
7304
7330
|
},
|
|
7305
7331
|
body: JSON.stringify({
|
|
7306
7332
|
source_code: this.toBase64(code4),
|
|
@@ -7309,9 +7335,45 @@ var Judge0Provider = class {
|
|
|
7309
7335
|
})
|
|
7310
7336
|
});
|
|
7311
7337
|
if (!response.ok) {
|
|
7312
|
-
|
|
7338
|
+
const errorText = await response.text();
|
|
7339
|
+
console.error(`[Judge0Provider] ${this.name} HTTP Error ${response.status}:`, errorText);
|
|
7340
|
+
throw new Error(`PROVIDER_HTTP_ERROR: ${response.status} - ${errorText}`);
|
|
7341
|
+
}
|
|
7342
|
+
let result = await response.json();
|
|
7343
|
+
console.log(`[Judge0Provider] ${this.name} initial result:`, result);
|
|
7344
|
+
if (result.message) {
|
|
7345
|
+
if (result.message.includes("not subscribed")) {
|
|
7346
|
+
console.warn(`[Judge0Provider] ${this.name} auth failed, triggering fallback...`);
|
|
7347
|
+
throw new Error("AUTH_FAILED: Not subscribed");
|
|
7348
|
+
}
|
|
7349
|
+
if (result.message.includes("rate limit")) {
|
|
7350
|
+
console.warn(`[Judge0Provider] ${this.name} rate limited, triggering fallback...`);
|
|
7351
|
+
throw new Error("RATE_LIMIT_EXCEEDED");
|
|
7352
|
+
}
|
|
7353
|
+
}
|
|
7354
|
+
let attempts = 0;
|
|
7355
|
+
const maxAttempts = 10;
|
|
7356
|
+
while ((result.status?.id === 1 || result.status?.id === 2) && attempts < maxAttempts) {
|
|
7357
|
+
console.log(`[Judge0Provider] ${this.name} polling... (status: ${result.status?.description})`);
|
|
7358
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
7359
|
+
const pollResponse = await fetch(`${this.apiUrl}/submissions/${result.token}?base64_encoded=true`, {
|
|
7360
|
+
headers: {
|
|
7361
|
+
"Content-Type": "application/json",
|
|
7362
|
+
...this.apiKey && (this.apiUrl.includes("rapidapi.com") ? {
|
|
7363
|
+
"x-rapidapi-key": this.apiKey,
|
|
7364
|
+
"x-rapidapi-host": new URL(this.apiUrl).hostname
|
|
7365
|
+
} : { "X-Auth-Token": this.apiKey })
|
|
7366
|
+
}
|
|
7367
|
+
});
|
|
7368
|
+
if (pollResponse.ok) {
|
|
7369
|
+
result = await pollResponse.json();
|
|
7370
|
+
console.log(`[Judge0Provider] ${this.name} poll result (attempt ${attempts + 1}):`, result);
|
|
7371
|
+
} else {
|
|
7372
|
+
console.error(`[Judge0Provider] Poll failed: ${pollResponse.status}`);
|
|
7373
|
+
break;
|
|
7374
|
+
}
|
|
7375
|
+
attempts++;
|
|
7313
7376
|
}
|
|
7314
|
-
const result = await response.json();
|
|
7315
7377
|
return {
|
|
7316
7378
|
stdout: this.fromBase64(result.stdout),
|
|
7317
7379
|
stderr: this.fromBase64(result.stderr),
|
|
@@ -7321,18 +7383,16 @@ var Judge0Provider = class {
|
|
|
7321
7383
|
time: result.time ? parseFloat(result.time) * 1e3 : void 0,
|
|
7322
7384
|
memory: result.memory ? parseInt(result.memory) : void 0,
|
|
7323
7385
|
message: result.status?.description,
|
|
7386
|
+
status: result.status,
|
|
7324
7387
|
token: result.token
|
|
7325
7388
|
};
|
|
7326
7389
|
} catch (error) {
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
stderr: error instanceof Error ? error.message : String(error),
|
|
7330
|
-
exitCode: 1,
|
|
7331
|
-
message: "EXECUTION_ERROR"
|
|
7332
|
-
};
|
|
7390
|
+
console.error(`[Judge0Provider] ${this.name} execution error:`, error);
|
|
7391
|
+
throw error;
|
|
7333
7392
|
}
|
|
7334
7393
|
}
|
|
7335
7394
|
getPriority(language2) {
|
|
7395
|
+
if (this.customPriority !== void 0) return this.customPriority;
|
|
7336
7396
|
const compiled = ["cpp", "c", "java", "csharp"];
|
|
7337
7397
|
return compiled.includes(language2.toLowerCase()) ? 10 : 5;
|
|
7338
7398
|
}
|
|
@@ -7341,6 +7401,104 @@ var Judge0Provider = class {
|
|
|
7341
7401
|
}
|
|
7342
7402
|
};
|
|
7343
7403
|
|
|
7404
|
+
// src/lib/execution/providers/PistonProvider.ts
|
|
7405
|
+
init_react_shim();
|
|
7406
|
+
var PistonProvider = class {
|
|
7407
|
+
constructor(apiUrl, apiKey, options) {
|
|
7408
|
+
this.cachedRuntimes = null;
|
|
7409
|
+
this.apiUrl = apiUrl.endsWith("/") ? apiUrl.slice(0, -1) : apiUrl;
|
|
7410
|
+
this.apiKey = apiKey;
|
|
7411
|
+
this.id = options?.id || "piston";
|
|
7412
|
+
this.name = options?.name || "Piston Engine";
|
|
7413
|
+
this.customPriority = options?.priority;
|
|
7414
|
+
}
|
|
7415
|
+
async isAvailable() {
|
|
7416
|
+
try {
|
|
7417
|
+
const response = await fetch(`${this.apiUrl}/runtimes`);
|
|
7418
|
+
if (response.ok) {
|
|
7419
|
+
this.cachedRuntimes = await response.json();
|
|
7420
|
+
return true;
|
|
7421
|
+
}
|
|
7422
|
+
return false;
|
|
7423
|
+
} catch (e2) {
|
|
7424
|
+
return false;
|
|
7425
|
+
}
|
|
7426
|
+
}
|
|
7427
|
+
async execute(code4, language2, stdin) {
|
|
7428
|
+
try {
|
|
7429
|
+
if (!this.cachedRuntimes) {
|
|
7430
|
+
const response2 = await fetch(`${this.apiUrl}/runtimes`);
|
|
7431
|
+
if (response2.ok) {
|
|
7432
|
+
this.cachedRuntimes = await response2.json();
|
|
7433
|
+
} else {
|
|
7434
|
+
throw new Error("Could not fetch Piston runtimes");
|
|
7435
|
+
}
|
|
7436
|
+
}
|
|
7437
|
+
const lowerLang = language2.toLowerCase();
|
|
7438
|
+
let targetLang = lowerLang;
|
|
7439
|
+
if (lowerLang === "js") targetLang = "javascript";
|
|
7440
|
+
if (lowerLang === "c" || lowerLang === "cpp") targetLang = "gcc";
|
|
7441
|
+
const runtime = this.cachedRuntimes.find(
|
|
7442
|
+
(r4) => r4.language === targetLang || r4.aliases && r4.aliases.includes(targetLang)
|
|
7443
|
+
);
|
|
7444
|
+
if (!runtime) {
|
|
7445
|
+
return {
|
|
7446
|
+
stdout: "",
|
|
7447
|
+
stderr: `Language '${language2}' (mapped to '${targetLang}') is not supported by this Piston instance.`,
|
|
7448
|
+
exitCode: 1,
|
|
7449
|
+
message: "UNSUPPORTED_LANGUAGE"
|
|
7450
|
+
};
|
|
7451
|
+
}
|
|
7452
|
+
console.log(`[PistonProvider] Calling ${this.name} (${runtime.language} ${runtime.version}) at ${this.apiUrl}...`);
|
|
7453
|
+
const headers = {
|
|
7454
|
+
"Content-Type": "application/json"
|
|
7455
|
+
};
|
|
7456
|
+
if (this.apiKey) {
|
|
7457
|
+
headers["X-API-Key"] = this.apiKey;
|
|
7458
|
+
}
|
|
7459
|
+
const response = await fetch(`${this.apiUrl}/execute`, {
|
|
7460
|
+
method: "POST",
|
|
7461
|
+
headers,
|
|
7462
|
+
body: JSON.stringify({
|
|
7463
|
+
language: runtime.language,
|
|
7464
|
+
version: runtime.version,
|
|
7465
|
+
files: [{ content: code4 }],
|
|
7466
|
+
stdin: stdin || ""
|
|
7467
|
+
})
|
|
7468
|
+
});
|
|
7469
|
+
if (!response.ok) {
|
|
7470
|
+
const errorText = await response.text();
|
|
7471
|
+
console.error(`[PistonProvider] HTTP Error ${response.status}:`, errorText);
|
|
7472
|
+
throw new Error(`PISTON_HTTP_ERROR: ${response.status} - ${errorText}`);
|
|
7473
|
+
}
|
|
7474
|
+
const result = await response.json();
|
|
7475
|
+
console.log(`[PistonProvider] result:`, result);
|
|
7476
|
+
if (result.message) {
|
|
7477
|
+
throw new Error(`PISTON_ERROR: ${result.message}`);
|
|
7478
|
+
}
|
|
7479
|
+
const run = result.run || {};
|
|
7480
|
+
const compile = result.compile || {};
|
|
7481
|
+
return {
|
|
7482
|
+
stdout: run.stdout || "",
|
|
7483
|
+
stderr: (compile.stderr || "") + (run.stderr || ""),
|
|
7484
|
+
compileOutput: compile.stdout || "",
|
|
7485
|
+
exitCode: run.code === 0 ? 0 : 1,
|
|
7486
|
+
message: run.signal ? `Terminated by signal: ${run.signal}` : void 0
|
|
7487
|
+
};
|
|
7488
|
+
} catch (error) {
|
|
7489
|
+
console.error(`[PistonProvider] execution error:`, error);
|
|
7490
|
+
throw error;
|
|
7491
|
+
}
|
|
7492
|
+
}
|
|
7493
|
+
getPriority(language2) {
|
|
7494
|
+
if (this.customPriority !== void 0) return this.customPriority;
|
|
7495
|
+
return 20;
|
|
7496
|
+
}
|
|
7497
|
+
getSupportedLanguages() {
|
|
7498
|
+
return ["python", "javascript", "js", "lua", "c", "cpp", "csharp"];
|
|
7499
|
+
}
|
|
7500
|
+
};
|
|
7501
|
+
|
|
7344
7502
|
// src/lib/execution/providers/LiteProvider.ts
|
|
7345
7503
|
init_react_shim();
|
|
7346
7504
|
var LiteProvider = class {
|
|
@@ -7556,9 +7714,40 @@ var AIProvider = class {
|
|
|
7556
7714
|
|
|
7557
7715
|
// src/lib/execution/index.ts
|
|
7558
7716
|
function initExecutionSystem(config) {
|
|
7717
|
+
executionService.clearProviders();
|
|
7559
7718
|
executionService.registerProvider(new LiteProvider());
|
|
7560
|
-
if (config?.
|
|
7561
|
-
executionService.registerProvider(new Judge0Provider(
|
|
7719
|
+
if (config?.judge0Fallback?.url) {
|
|
7720
|
+
executionService.registerProvider(new Judge0Provider(
|
|
7721
|
+
config.judge0Fallback.url,
|
|
7722
|
+
config.judge0Fallback.key,
|
|
7723
|
+
{
|
|
7724
|
+
id: "judge0-fallback",
|
|
7725
|
+
name: config.judge0Fallback.name || "Judge0 Fallback (RapidAPI)",
|
|
7726
|
+
priority: config.judge0Fallback.priority || 8
|
|
7727
|
+
}
|
|
7728
|
+
));
|
|
7729
|
+
}
|
|
7730
|
+
if (config?.pistonPrimary?.url) {
|
|
7731
|
+
executionService.registerProvider(new PistonProvider(
|
|
7732
|
+
config.pistonPrimary.url,
|
|
7733
|
+
config.pistonPrimary.key,
|
|
7734
|
+
{
|
|
7735
|
+
id: "piston-primary",
|
|
7736
|
+
name: config.pistonPrimary.name || "Piston Primary (Self-hosted)",
|
|
7737
|
+
priority: config.pistonPrimary.priority || 20
|
|
7738
|
+
}
|
|
7739
|
+
));
|
|
7740
|
+
}
|
|
7741
|
+
if (config?.judge0Primary?.url) {
|
|
7742
|
+
executionService.registerProvider(new Judge0Provider(
|
|
7743
|
+
config.judge0Primary.url,
|
|
7744
|
+
config.judge0Primary.key,
|
|
7745
|
+
{
|
|
7746
|
+
id: "judge0-primary",
|
|
7747
|
+
name: config.judge0Primary.name || "Judge0 Primary (Self-hosted)",
|
|
7748
|
+
priority: config.judge0Primary.priority || 15
|
|
7749
|
+
}
|
|
7750
|
+
));
|
|
7562
7751
|
}
|
|
7563
7752
|
if (config?.geminiKey) {
|
|
7564
7753
|
executionService.registerProvider(new AIProvider(config.geminiKey));
|
|
@@ -7568,8 +7757,11 @@ function initExecutionSystem(config) {
|
|
|
7568
7757
|
// src/services/APIKeyService.ts
|
|
7569
7758
|
init_react_shim();
|
|
7570
7759
|
var GEMINI_API_KEY_SERVICE_NAME = "gemini";
|
|
7571
|
-
var
|
|
7572
|
-
var
|
|
7760
|
+
var JUDGE0_PRIMARY_API_KEY_SERVICE_NAME = "judge0_primary";
|
|
7761
|
+
var JUDGE0_PRIMARY_API_URL_SERVICE_NAME = "judge0_primary_url";
|
|
7762
|
+
var JUDGE0_FALLBACK_API_KEY_SERVICE_NAME = "judge0_fallback";
|
|
7763
|
+
var JUDGE0_FALLBACK_API_URL_SERVICE_NAME = "judge0_fallback_url";
|
|
7764
|
+
var PISTON_PRIMARY_API_URL_SERVICE_NAME = "piston_primary_url";
|
|
7573
7765
|
var LOCAL_STORAGE_PREFIX = "iqk_api_keys_";
|
|
7574
7766
|
function _encode(data) {
|
|
7575
7767
|
if (typeof window !== "undefined" && typeof window.btoa === "function") {
|
|
@@ -7655,6 +7847,96 @@ var APIKeyService = class {
|
|
|
7655
7847
|
}
|
|
7656
7848
|
};
|
|
7657
7849
|
|
|
7850
|
+
// src/lib/execution/CodeWrapper.ts
|
|
7851
|
+
init_react_shim();
|
|
7852
|
+
var CodeWrapper = class {
|
|
7853
|
+
/**
|
|
7854
|
+
* Wraps code with necessary boilerplate for the given language.
|
|
7855
|
+
*/
|
|
7856
|
+
static wrap(code4, language2, options = {}) {
|
|
7857
|
+
const lang = language2.toLowerCase();
|
|
7858
|
+
if (lang === "c" || lang === "cpp") {
|
|
7859
|
+
return this.wrapC(code4, options.testCaseInput || [], options.functionSignature);
|
|
7860
|
+
}
|
|
7861
|
+
return code4;
|
|
7862
|
+
}
|
|
7863
|
+
static wrapC(code4, input, signature) {
|
|
7864
|
+
if (code4.includes("int main") || code4.includes("void main")) {
|
|
7865
|
+
return code4;
|
|
7866
|
+
}
|
|
7867
|
+
if (!signature) {
|
|
7868
|
+
return `
|
|
7869
|
+
#include <stdio.h>
|
|
7870
|
+
#include <stdlib.h>
|
|
7871
|
+
#include <stdbool.h>
|
|
7872
|
+
#include <string.h>
|
|
7873
|
+
|
|
7874
|
+
${code4}
|
|
7875
|
+
|
|
7876
|
+
int main() {
|
|
7877
|
+
// No signature provided, assuming competitive programming style if stdin is used
|
|
7878
|
+
return 0;
|
|
7879
|
+
}
|
|
7880
|
+
`;
|
|
7881
|
+
}
|
|
7882
|
+
const sig = signature?.trim();
|
|
7883
|
+
const match = sig?.match(/(\w+)\s+(\w+)\s*\((.*)\)/);
|
|
7884
|
+
if (!match) {
|
|
7885
|
+
if (input.length === 2) {
|
|
7886
|
+
return `
|
|
7887
|
+
#include <stdio.h>
|
|
7888
|
+
#include <stdlib.h>
|
|
7889
|
+
#include <stdbool.h>
|
|
7890
|
+
#include <string.h>
|
|
7891
|
+
|
|
7892
|
+
${code4}
|
|
7893
|
+
|
|
7894
|
+
int main() {
|
|
7895
|
+
int v0, v1;
|
|
7896
|
+
if (scanf("%d %d", &v0, &v1) == 2) {
|
|
7897
|
+
// Try to call 'add' if it exists in the code
|
|
7898
|
+
${code4.includes("add") ? 'printf("%d", add(v0, v1));' : "// Function not found"}
|
|
7899
|
+
}
|
|
7900
|
+
return 0;
|
|
7901
|
+
}
|
|
7902
|
+
`;
|
|
7903
|
+
}
|
|
7904
|
+
return code4;
|
|
7905
|
+
}
|
|
7906
|
+
const [, , funcName, paramsStr] = match;
|
|
7907
|
+
const params = paramsStr.split(",").map((p4) => p4.trim()).filter((p4) => p4.length > 0);
|
|
7908
|
+
let scanfFormat = "";
|
|
7909
|
+
let scanfArgs = "";
|
|
7910
|
+
let callArgs = "";
|
|
7911
|
+
params.forEach((p4, i3) => {
|
|
7912
|
+
const parts = p4.split(/\s+/);
|
|
7913
|
+
const type = parts[0];
|
|
7914
|
+
parts[parts.length - 1];
|
|
7915
|
+
let fmt = "%d";
|
|
7916
|
+
if (type === "float" || type === "double") fmt = "%lf";
|
|
7917
|
+
if (type === "char*") fmt = "%s";
|
|
7918
|
+
scanfFormat += (i3 === 0 ? "" : " ") + fmt;
|
|
7919
|
+
scanfArgs += `, &v${i3}`;
|
|
7920
|
+
callArgs += (i3 === 0 ? "" : ", ") + `v${i3}`;
|
|
7921
|
+
});
|
|
7922
|
+
return `
|
|
7923
|
+
#include <stdio.h>
|
|
7924
|
+
#include <stdlib.h>
|
|
7925
|
+
#include <stdbool.h>
|
|
7926
|
+
#include <string.h>
|
|
7927
|
+
|
|
7928
|
+
${code4}
|
|
7929
|
+
|
|
7930
|
+
int main() {
|
|
7931
|
+
${params.map((p4, i3) => `${p4.split(/\s+/)[0]} v${i3};`).join("\n ")}
|
|
7932
|
+
if (scanf("${scanfFormat}"${scanfArgs}) != ${params.length}) return 1;
|
|
7933
|
+
printf("%d", ${funcName}(${callArgs}));
|
|
7934
|
+
return 0;
|
|
7935
|
+
}
|
|
7936
|
+
`;
|
|
7937
|
+
}
|
|
7938
|
+
};
|
|
7939
|
+
|
|
7658
7940
|
// src/services/CodeEvaluationService.ts
|
|
7659
7941
|
var CodeEvaluationService = class {
|
|
7660
7942
|
constructor() {
|
|
@@ -7662,27 +7944,46 @@ var CodeEvaluationService = class {
|
|
|
7662
7944
|
}
|
|
7663
7945
|
/**
|
|
7664
7946
|
* Ensure execution system is initialized with latest keys.
|
|
7947
|
+
* Order of precedence: LocalStorage (User choice) > Environment Variables (System default)
|
|
7665
7948
|
*/
|
|
7666
7949
|
ensureInitialized() {
|
|
7667
7950
|
if (typeof window === "undefined") return;
|
|
7668
|
-
const geminiKey = APIKeyService.getAPIKey(GEMINI_API_KEY_SERVICE_NAME) ||
|
|
7669
|
-
const
|
|
7670
|
-
const
|
|
7951
|
+
const geminiKey = APIKeyService.getAPIKey(GEMINI_API_KEY_SERVICE_NAME) || "";
|
|
7952
|
+
const judge0PrimaryUrl = APIKeyService.getAPIKey(JUDGE0_PRIMARY_API_URL_SERVICE_NAME) || "/api/judge0";
|
|
7953
|
+
const judge0PrimaryKey = APIKeyService.getAPIKey(JUDGE0_PRIMARY_API_KEY_SERVICE_NAME) || "Code@Orchable";
|
|
7954
|
+
const judge0FallbackUrl = APIKeyService.getAPIKey(JUDGE0_FALLBACK_API_URL_SERVICE_NAME) || "https://judge0-ce.p.rapidapi.com";
|
|
7955
|
+
const judge0FallbackKey = APIKeyService.getAPIKey(JUDGE0_FALLBACK_API_KEY_SERVICE_NAME) || "9343426db9mshd122142ba1d0927p1259d6jsne24390a88e67";
|
|
7956
|
+
const pistonPrimaryUrl = APIKeyService.getAPIKey(PISTON_PRIMARY_API_URL_SERVICE_NAME) || "/api/piston";
|
|
7957
|
+
const pistonPrimaryKey = "Piston@Orchable";
|
|
7671
7958
|
initExecutionSystem({
|
|
7672
|
-
geminiKey,
|
|
7673
|
-
|
|
7674
|
-
|
|
7959
|
+
geminiKey: geminiKey || void 0,
|
|
7960
|
+
pistonPrimary: {
|
|
7961
|
+
url: pistonPrimaryUrl,
|
|
7962
|
+
key: pistonPrimaryKey
|
|
7963
|
+
} ,
|
|
7964
|
+
judge0Primary: {
|
|
7965
|
+
url: judge0PrimaryUrl,
|
|
7966
|
+
key: judge0PrimaryKey
|
|
7967
|
+
} ,
|
|
7968
|
+
judge0Fallback: {
|
|
7969
|
+
url: judge0FallbackUrl,
|
|
7970
|
+
key: judge0FallbackKey
|
|
7971
|
+
}
|
|
7675
7972
|
});
|
|
7676
7973
|
}
|
|
7677
7974
|
async evaluateSingleTestCase(question, userCode, testCase) {
|
|
7678
7975
|
try {
|
|
7976
|
+
const wrappedCode = CodeWrapper.wrap(userCode, question.codingLanguage, {
|
|
7977
|
+
functionSignature: question.functionSignature,
|
|
7978
|
+
testCaseInput: testCase.input
|
|
7979
|
+
});
|
|
7679
7980
|
const result = await executionService.execute(
|
|
7680
|
-
|
|
7981
|
+
wrappedCode,
|
|
7681
7982
|
question.codingLanguage,
|
|
7682
7983
|
Array.isArray(testCase.input) ? testCase.input.join("\n") : String(testCase.input || "")
|
|
7683
7984
|
);
|
|
7684
|
-
const actual = (result.stdout || "").trim();
|
|
7685
|
-
const expected = (testCase.expectedOutput || "").trim();
|
|
7985
|
+
const actual = String(result.stdout || "").trim();
|
|
7986
|
+
const expected = String(testCase.expectedOutput || "").trim();
|
|
7686
7987
|
const statusPassed = result.exitCode === 0;
|
|
7687
7988
|
const outputMatches = actual === expected;
|
|
7688
7989
|
const passed = statusPassed && outputMatches;
|
|
@@ -62838,13 +63139,30 @@ function rehypeKatex(options) {
|
|
|
62838
63139
|
});
|
|
62839
63140
|
};
|
|
62840
63141
|
}
|
|
62841
|
-
var ScratchBlocksRenderer2 =
|
|
62842
|
-
() => Promise.resolve().then(() => (init_ScratchBlocksRenderer(), ScratchBlocksRenderer_exports)).then((
|
|
62843
|
-
|
|
63142
|
+
var ScratchBlocksRenderer2 = React78__default.lazy(
|
|
63143
|
+
() => Promise.resolve().then(() => (init_ScratchBlocksRenderer(), ScratchBlocksRenderer_exports)).then((module) => ({
|
|
63144
|
+
default: module.ScratchBlocksRenderer
|
|
63145
|
+
}))
|
|
62844
63146
|
);
|
|
63147
|
+
var ScratchRendererErrorBoundary = class extends React78__default.Component {
|
|
63148
|
+
constructor() {
|
|
63149
|
+
super(...arguments);
|
|
63150
|
+
this.state = { failed: false };
|
|
63151
|
+
}
|
|
63152
|
+
static getDerivedStateFromError() {
|
|
63153
|
+
return { failed: true };
|
|
63154
|
+
}
|
|
63155
|
+
componentDidCatch(error) {
|
|
63156
|
+
console.error("ScratchBlocksRenderer failed to load:", error);
|
|
63157
|
+
}
|
|
63158
|
+
render() {
|
|
63159
|
+
return this.state.failed ? this.props.fallback : this.props.children;
|
|
63160
|
+
}
|
|
63161
|
+
};
|
|
62845
63162
|
var ClientScratchRenderer = ({ code: code4, isInline }) => {
|
|
62846
63163
|
const { i18n } = useTranslation();
|
|
62847
|
-
const
|
|
63164
|
+
const fallback = isInline ? /* @__PURE__ */ React78__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__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__default.createElement("code", null, code4));
|
|
63165
|
+
const content3 = /* @__PURE__ */ React78__default.createElement(ScratchRendererErrorBoundary, { key: `${isInline ? "inline" : "block"}:${code4}`, fallback }, /* @__PURE__ */ React78__default.createElement(React78__default.Suspense, { fallback }, /* @__PURE__ */ React78__default.createElement(
|
|
62848
63166
|
ScratchBlocksRenderer2,
|
|
62849
63167
|
{
|
|
62850
63168
|
code: code4,
|
|
@@ -62852,7 +63170,7 @@ var ClientScratchRenderer = ({ code: code4, isInline }) => {
|
|
|
62852
63170
|
fromLang: "en",
|
|
62853
63171
|
toLang: i18n.language === "vi" ? "vi" : "en"
|
|
62854
63172
|
}
|
|
62855
|
-
);
|
|
63173
|
+
)));
|
|
62856
63174
|
if (isInline) {
|
|
62857
63175
|
return /* @__PURE__ */ React78__default.createElement("span", { className: "inline-block align-middle" }, content3);
|
|
62858
63176
|
}
|
|
@@ -62908,18 +63226,21 @@ var MarkdownRenderer = ({ content: content3, className }) => {
|
|
|
62908
63226
|
}
|
|
62909
63227
|
));
|
|
62910
63228
|
}
|
|
62911
|
-
return
|
|
62912
|
-
|
|
62913
|
-
|
|
62914
|
-
|
|
62915
|
-
|
|
62916
|
-
|
|
62917
|
-
|
|
62918
|
-
|
|
62919
|
-
|
|
62920
|
-
|
|
62921
|
-
|
|
62922
|
-
|
|
63229
|
+
return (
|
|
63230
|
+
// This renderer is intentionally framework-neutral. Next Image
|
|
63231
|
+
// optimization was already disabled in the previous implementation.
|
|
63232
|
+
// eslint-disable-next-line @next/next/no-img-element
|
|
63233
|
+
/* @__PURE__ */ React78__default.createElement(
|
|
63234
|
+
"img",
|
|
63235
|
+
{
|
|
63236
|
+
src,
|
|
63237
|
+
alt: props.alt || "",
|
|
63238
|
+
loading: "lazy",
|
|
63239
|
+
decoding: "async",
|
|
63240
|
+
sizes: "100vw",
|
|
63241
|
+
className: "max-w-full w-full h-auto rounded-lg my-4"
|
|
63242
|
+
}
|
|
63243
|
+
)
|
|
62923
63244
|
);
|
|
62924
63245
|
},
|
|
62925
63246
|
table: ({ node: node2, ...props }) => /* @__PURE__ */ React78__default.createElement("div", { className: "overflow-x-auto my-4 rounded-lg border border-border" }, /* @__PURE__ */ React78__default.createElement("table", { ...props, className: "w-full text-sm border-collapse" })),
|
|
@@ -66728,8 +67049,8 @@ var styleHookSingleton = function() {
|
|
|
66728
67049
|
var styleSingleton = function() {
|
|
66729
67050
|
var useStyle = styleHookSingleton();
|
|
66730
67051
|
var Sheet2 = function(_a2) {
|
|
66731
|
-
var styles2 = _a2.styles,
|
|
66732
|
-
useStyle(styles2,
|
|
67052
|
+
var styles2 = _a2.styles, dynamic = _a2.dynamic;
|
|
67053
|
+
useStyle(styles2, dynamic);
|
|
66733
67054
|
return null;
|
|
66734
67055
|
};
|
|
66735
67056
|
return Sheet2;
|
|
@@ -74242,7 +74563,8 @@ var CodingQuestionUI = ({
|
|
|
74242
74563
|
question,
|
|
74243
74564
|
onAnswerChange,
|
|
74244
74565
|
userAnswer,
|
|
74245
|
-
showCorrectAnswer = false
|
|
74566
|
+
showCorrectAnswer = false,
|
|
74567
|
+
showExecutionSettings
|
|
74246
74568
|
}) => {
|
|
74247
74569
|
const [code4, setCode] = useState("");
|
|
74248
74570
|
const [isRunningTests, setIsRunningTests] = useState(false);
|
|
@@ -74250,21 +74572,27 @@ var CodingQuestionUI = ({
|
|
|
74250
74572
|
const [showSettings, setShowSettings] = useState(false);
|
|
74251
74573
|
const [keys2, setKeys] = useState({
|
|
74252
74574
|
gemini: "",
|
|
74253
|
-
|
|
74254
|
-
|
|
74575
|
+
judge0PrimaryUrl: "",
|
|
74576
|
+
judge0PrimaryKey: "",
|
|
74577
|
+
judge0FallbackUrl: "",
|
|
74578
|
+
judge0FallbackKey: ""
|
|
74255
74579
|
});
|
|
74256
74580
|
const { toast: toast2 } = useToast();
|
|
74257
74581
|
useEffect(() => {
|
|
74258
74582
|
setKeys({
|
|
74259
74583
|
gemini: APIKeyService.getAPIKey(GEMINI_API_KEY_SERVICE_NAME) || "",
|
|
74260
|
-
|
|
74261
|
-
|
|
74584
|
+
judge0PrimaryUrl: APIKeyService.getAPIKey(JUDGE0_PRIMARY_API_URL_SERVICE_NAME) || "",
|
|
74585
|
+
judge0PrimaryKey: APIKeyService.getAPIKey(JUDGE0_PRIMARY_API_KEY_SERVICE_NAME) || "",
|
|
74586
|
+
judge0FallbackUrl: APIKeyService.getAPIKey(JUDGE0_FALLBACK_API_URL_SERVICE_NAME) || "",
|
|
74587
|
+
judge0FallbackKey: APIKeyService.getAPIKey(JUDGE0_FALLBACK_API_KEY_SERVICE_NAME) || ""
|
|
74262
74588
|
});
|
|
74263
74589
|
}, []);
|
|
74264
74590
|
const handleSaveKeys = () => {
|
|
74265
74591
|
APIKeyService.saveAPIKey(GEMINI_API_KEY_SERVICE_NAME, keys2.gemini);
|
|
74266
|
-
APIKeyService.saveAPIKey(
|
|
74267
|
-
APIKeyService.saveAPIKey(
|
|
74592
|
+
APIKeyService.saveAPIKey(JUDGE0_PRIMARY_API_URL_SERVICE_NAME, keys2.judge0PrimaryUrl);
|
|
74593
|
+
APIKeyService.saveAPIKey(JUDGE0_PRIMARY_API_KEY_SERVICE_NAME, keys2.judge0PrimaryKey);
|
|
74594
|
+
APIKeyService.saveAPIKey(JUDGE0_FALLBACK_API_URL_SERVICE_NAME, keys2.judge0FallbackUrl);
|
|
74595
|
+
APIKeyService.saveAPIKey(JUDGE0_FALLBACK_API_KEY_SERVICE_NAME, keys2.judge0FallbackKey);
|
|
74268
74596
|
setShowSettings(false);
|
|
74269
74597
|
toast2({
|
|
74270
74598
|
title: "Settings Saved",
|
|
@@ -74297,7 +74625,7 @@ var CodingQuestionUI = ({
|
|
|
74297
74625
|
setIsRunningTests(false);
|
|
74298
74626
|
}
|
|
74299
74627
|
};
|
|
74300
|
-
return /* @__PURE__ */ React78__default.createElement(Card, { className: "w-full border-none shadow-none bg-transparent" }, /* @__PURE__ */ React78__default.createElement(CardHeader, { className: "p-0 pb-6" }, /* @__PURE__ */ React78__default.createElement("div", { className: "flex justify-between items-start" }, /* @__PURE__ */ React78__default.createElement("div", null, /* @__PURE__ */ React78__default.createElement(CardTitle, { className: "text-2xl font-bold tracking-tight mb-2" }, /* @__PURE__ */ React78__default.createElement(MarkdownRenderer, { content: question.prompt })), question.points && /* @__PURE__ */ React78__default.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React78__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__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__default.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React78__default.createElement(
|
|
74628
|
+
return /* @__PURE__ */ React78__default.createElement(Card, { className: "w-full border-none shadow-none bg-transparent" }, /* @__PURE__ */ React78__default.createElement(CardHeader, { className: "p-0 pb-6" }, /* @__PURE__ */ React78__default.createElement("div", { className: "flex justify-between items-start" }, /* @__PURE__ */ React78__default.createElement("div", null, /* @__PURE__ */ React78__default.createElement(CardTitle, { className: "text-2xl font-bold tracking-tight mb-2" }, /* @__PURE__ */ React78__default.createElement(MarkdownRenderer, { content: question.prompt })), question.points && /* @__PURE__ */ React78__default.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React78__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__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__default.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React78__default.createElement(
|
|
74301
74629
|
Button,
|
|
74302
74630
|
{
|
|
74303
74631
|
variant: "outline",
|
|
@@ -74316,21 +74644,38 @@ var CodingQuestionUI = ({
|
|
|
74316
74644
|
placeholder: "AI fallback key...",
|
|
74317
74645
|
className: "w-full bg-black/20 border border-white/10 rounded px-3 py-1.5 text-sm focus:border-primary/50 outline-none"
|
|
74318
74646
|
}
|
|
74319
|
-
)), /* @__PURE__ */ React78__default.createElement("div", { className: "grid grid-cols-2 gap-4" }, /* @__PURE__ */ React78__default.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React78__default.createElement("label", { className: "text-xs font-bold uppercase tracking-wider opacity-60" }, "Judge0
|
|
74647
|
+
)), /* @__PURE__ */ React78__default.createElement("div", { className: "grid grid-cols-2 gap-4" }, /* @__PURE__ */ React78__default.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React78__default.createElement("label", { className: "text-xs font-bold uppercase tracking-wider opacity-60" }, "Judge0 Primary URL (Self-hosted)"), /* @__PURE__ */ React78__default.createElement(
|
|
74648
|
+
"input",
|
|
74649
|
+
{
|
|
74650
|
+
type: "text",
|
|
74651
|
+
value: keys2.judge0PrimaryUrl,
|
|
74652
|
+
onChange: (e2) => setKeys({ ...keys2, judge0PrimaryUrl: e2.target.value }),
|
|
74653
|
+
placeholder: "https://your-server.com",
|
|
74654
|
+
className: "w-full bg-black/20 border border-white/10 rounded px-3 py-1.5 text-sm focus:border-primary/50 outline-none"
|
|
74655
|
+
}
|
|
74656
|
+
)), /* @__PURE__ */ React78__default.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React78__default.createElement("label", { className: "text-xs font-bold uppercase tracking-wider opacity-60" }, "Judge0 Primary Key"), /* @__PURE__ */ React78__default.createElement(
|
|
74657
|
+
"input",
|
|
74658
|
+
{
|
|
74659
|
+
type: "password",
|
|
74660
|
+
value: keys2.judge0PrimaryKey,
|
|
74661
|
+
onChange: (e2) => setKeys({ ...keys2, judge0PrimaryKey: e2.target.value }),
|
|
74662
|
+
className: "w-full bg-black/20 border border-white/10 rounded px-3 py-1.5 text-sm focus:border-primary/50 outline-none"
|
|
74663
|
+
}
|
|
74664
|
+
))), /* @__PURE__ */ React78__default.createElement("div", { className: "grid grid-cols-2 gap-4" }, /* @__PURE__ */ React78__default.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React78__default.createElement("label", { className: "text-xs font-bold uppercase tracking-wider opacity-60" }, "Judge0 Fallback URL (RapidAPI)"), /* @__PURE__ */ React78__default.createElement(
|
|
74320
74665
|
"input",
|
|
74321
74666
|
{
|
|
74322
74667
|
type: "text",
|
|
74323
|
-
value: keys2.
|
|
74324
|
-
onChange: (e2) => setKeys({ ...keys2,
|
|
74325
|
-
placeholder: "https://judge0-
|
|
74668
|
+
value: keys2.judge0FallbackUrl,
|
|
74669
|
+
onChange: (e2) => setKeys({ ...keys2, judge0FallbackUrl: e2.target.value }),
|
|
74670
|
+
placeholder: "https://judge0-ce.p.rapidapi.com",
|
|
74326
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"
|
|
74327
74672
|
}
|
|
74328
|
-
)), /* @__PURE__ */ React78__default.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React78__default.createElement("label", { className: "text-xs font-bold uppercase tracking-wider opacity-60" }, "Judge0
|
|
74673
|
+
)), /* @__PURE__ */ React78__default.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React78__default.createElement("label", { className: "text-xs font-bold uppercase tracking-wider opacity-60" }, "Judge0 Fallback Key"), /* @__PURE__ */ React78__default.createElement(
|
|
74329
74674
|
"input",
|
|
74330
74675
|
{
|
|
74331
74676
|
type: "password",
|
|
74332
|
-
value: keys2.
|
|
74333
|
-
onChange: (e2) => setKeys({ ...keys2,
|
|
74677
|
+
value: keys2.judge0FallbackKey,
|
|
74678
|
+
onChange: (e2) => setKeys({ ...keys2, judge0FallbackKey: e2.target.value }),
|
|
74334
74679
|
className: "w-full bg-black/20 border border-white/10 rounded px-3 py-1.5 text-sm focus:border-primary/50 outline-none"
|
|
74335
74680
|
}
|
|
74336
74681
|
)))), /* @__PURE__ */ React78__default.createElement("div", { className: "flex justify-end pt-2" }, /* @__PURE__ */ React78__default.createElement(Button, { size: "sm", onClick: handleSaveKeys }, "Apply Changes"))))), /* @__PURE__ */ React78__default.createElement(CardContent, { className: "p-0 space-y-6" }, /* @__PURE__ */ React78__default.createElement("div", { className: "relative group" }, /* @__PURE__ */ React78__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__default.createElement("div", { className: "relative border border-white/10 rounded-xl overflow-hidden bg-[#1e1e1e] shadow-2xl" }, /* @__PURE__ */ React78__default.createElement("div", { className: "flex items-center justify-between px-4 py-2 bg-[#252526] border-b border-white/5" }, /* @__PURE__ */ React78__default.createElement("div", { className: "flex items-center gap-1.5" }, /* @__PURE__ */ React78__default.createElement("div", { className: "w-3 h-3 rounded-full bg-[#ff5f56]" }), /* @__PURE__ */ React78__default.createElement("div", { className: "w-3 h-3 rounded-full bg-[#ffbd2e]" }), /* @__PURE__ */ React78__default.createElement("div", { className: "w-3 h-3 rounded-full bg-[#27c93f]" }), /* @__PURE__ */ React78__default.createElement("span", { className: "ml-2 text-xs font-mono text-muted-foreground uppercase tracking-widest opacity-50" }, "solution.", question.codingLanguage))), /* @__PURE__ */ React78__default.createElement(
|
|
@@ -74364,15 +74709,15 @@ var CodingQuestionUI = ({
|
|
|
74364
74709
|
isRunningTests ? /* @__PURE__ */ React78__default.createElement(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ React78__default.createElement(Play, { className: "mr-2 h-4 w-4 fill-current" }),
|
|
74365
74710
|
isRunningTests ? "Evaluating..." : "Run Test Cases"
|
|
74366
74711
|
), /* @__PURE__ */ React78__default.createElement("span", { className: "text-xs text-muted-foreground italic" }, "* Verification uses tiered execution (Native ", ">", " Lite ", ">", " AI)")), /* @__PURE__ */ React78__default.createElement("div", { className: "space-y-3" }, /* @__PURE__ */ React78__default.createElement(Tabs2, { defaultValue: "console", className: "w-full" }, /* @__PURE__ */ React78__default.createElement("div", { className: "flex items-center justify-between mb-2" }, /* @__PURE__ */ React78__default.createElement(TabsList2, { className: "bg-muted/50 p-1 rounded-lg border h-auto" }, /* @__PURE__ */ React78__default.createElement(TabsTrigger2, { value: "console", className: "px-4 py-1.5 data-[state=active]:bg-background data-[state=active]:shadow-sm" }, /* @__PURE__ */ React78__default.createElement(Terminal, { className: "w-3.5 h-3.5 mr-2" }), "Console"), showCorrectAnswer && /* @__PURE__ */ React78__default.createElement(TabsTrigger2, { value: "solution", className: "px-4 py-1.5 data-[state=active]:bg-background data-[state=active]:shadow-sm" }, /* @__PURE__ */ React78__default.createElement(Info, { className: "w-3.5 h-3.5 mr-2" }), "Reference Solution"))), /* @__PURE__ */ React78__default.createElement(TabsContent2, { value: "console", className: "mt-0 focus-visible:outline-none" }, /* @__PURE__ */ React78__default.createElement("div", { className: cn(
|
|
74367
|
-
"rounded-xl border border-
|
|
74712
|
+
"rounded-xl border border-border bg-muted/30 dark:bg-black/40 backdrop-blur-md overflow-hidden min-h-[160px] flex flex-col",
|
|
74368
74713
|
testResults.length > 0 ? "h-auto" : "h-[160px]"
|
|
74369
|
-
) }, /* @__PURE__ */ React78__default.createElement("div", { className: "flex items-center px-4 py-2 border-b border-
|
|
74370
|
-
"flex items-start p-3 rounded-lg border transition-all",
|
|
74371
|
-
result.passed ? "bg-green-500/5 border-green-500/
|
|
74372
|
-
) }, /* @__PURE__ */ React78__default.createElement("div", { className: "mt-1 mr-3 shrink-0" }, result.passed ? /* @__PURE__ */ React78__default.createElement(CircleCheck, { className: "h-5 w-5" }) : /* @__PURE__ */ React78__default.createElement(CircleX, { className: "h-5 w-5" })), /* @__PURE__ */ React78__default.createElement("div", { className: "flex-1 min-w-0" }, /* @__PURE__ */ React78__default.createElement("div", { className: "flex items-center justify-between mb-1" }, /* @__PURE__ */ React78__default.createElement("span", { className: "font-bold" }, "Test Case #", index3 + 1), /* @__PURE__ */ React78__default.createElement("span", { className: cn(
|
|
74373
|
-
"text-[10px] uppercase font-black px-1.5 py-0.5 rounded",
|
|
74374
|
-
result.passed ? "bg-green-500/
|
|
74375
|
-
) }, result.passed ? "Accepted" : "Failed")), /* @__PURE__ */ React78__default.createElement("div", { className: "grid grid-cols-1 gap-2 opacity-90" }, /* @__PURE__ */ React78__default.createElement("div", { className: "text-xs" }, /* @__PURE__ */ React78__default.createElement("span", { className: "opacity-
|
|
74714
|
+
) }, /* @__PURE__ */ React78__default.createElement("div", { className: "flex items-center px-4 py-2 border-b border-border bg-muted/50 dark:bg-white/5" }, /* @__PURE__ */ React78__default.createElement("span", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-[0.2em]" }, "Execution Output")), /* @__PURE__ */ React78__default.createElement("div", { className: "p-4 flex-1 font-mono text-sm" }, testResults.length > 0 ? /* @__PURE__ */ React78__default.createElement("div", { className: "grid gap-3" }, testResults.map((result, index3) => /* @__PURE__ */ React78__default.createElement("div", { key: result.testCaseId, className: "group animate-in fade-in slide-in-from-left-2 duration-300" }, /* @__PURE__ */ React78__default.createElement("div", { className: cn(
|
|
74715
|
+
"flex items-start p-3 rounded-lg border transition-all shadow-sm",
|
|
74716
|
+
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"
|
|
74717
|
+
) }, /* @__PURE__ */ React78__default.createElement("div", { className: "mt-1 mr-3 shrink-0" }, result.passed ? /* @__PURE__ */ React78__default.createElement(CircleCheck, { className: "h-5 w-5 fill-green-500/20" }) : /* @__PURE__ */ React78__default.createElement(CircleX, { className: "h-5 w-5 fill-red-500/20" })), /* @__PURE__ */ React78__default.createElement("div", { className: "flex-1 min-w-0" }, /* @__PURE__ */ React78__default.createElement("div", { className: "flex items-center justify-between mb-1" }, /* @__PURE__ */ React78__default.createElement("span", { className: "font-bold text-sm" }, "Test Case #", index3 + 1), /* @__PURE__ */ React78__default.createElement("span", { className: cn(
|
|
74718
|
+
"text-[10px] uppercase font-black px-1.5 py-0.5 rounded tracking-tighter",
|
|
74719
|
+
result.passed ? "bg-green-500/10 text-green-600 dark:text-green-400" : "bg-red-500/10 text-red-600 dark:text-red-400"
|
|
74720
|
+
) }, result.passed ? "Accepted" : "Failed")), /* @__PURE__ */ React78__default.createElement("div", { className: "grid grid-cols-1 gap-2 opacity-90" }, /* @__PURE__ */ React78__default.createElement("div", { className: "text-xs font-medium leading-relaxed" }, /* @__PURE__ */ React78__default.createElement("span", { className: "opacity-60 mr-2 font-mono" }, ">"), result.reasoning), !result.passed && /* @__PURE__ */ React78__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__default.createElement("div", { className: "flex gap-6" }, /* @__PURE__ */ React78__default.createElement("div", null, /* @__PURE__ */ React78__default.createElement("div", { className: "text-muted-foreground mb-1 uppercase text-[9px] font-extrabold tracking-widest" }, "Input"), /* @__PURE__ */ React78__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__default.createElement("div", null, /* @__PURE__ */ React78__default.createElement("div", { className: "text-muted-foreground mb-1 uppercase text-[9px] font-extrabold tracking-widest" }, "Expected"), /* @__PURE__ */ React78__default.createElement("code", { className: "text-green-600 dark:text-green-400 font-mono font-bold" }, String(question.testCases[index3].expectedOutput))), /* @__PURE__ */ React78__default.createElement("div", null, /* @__PURE__ */ React78__default.createElement("div", { className: "text-muted-foreground mb-1 uppercase text-[9px] font-extrabold tracking-widest" }, "Actual"), /* @__PURE__ */ React78__default.createElement("code", { className: "text-red-600 dark:text-red-400 font-mono font-bold" }, String(result.actualOutput))))))))))) : /* @__PURE__ */ React78__default.createElement("div", { className: "h-full flex flex-col items-center justify-center text-muted-foreground/30 py-8 italic text-xs" }, /* @__PURE__ */ React78__default.createElement(Terminal, { className: "h-8 w-8 mb-3 opacity-20" }), /* @__PURE__ */ React78__default.createElement("p", null, isRunningTests ? "Processing internal execution pipeline..." : "Run tests to see diagnostic output"))))), showCorrectAnswer && /* @__PURE__ */ React78__default.createElement(TabsContent2, { value: "solution", className: "mt-0 focus-visible:outline-none" }, /* @__PURE__ */ React78__default.createElement("div", { className: "relative border border-white/10 rounded-xl overflow-hidden bg-[#1e1e1e] shadow-2xl" }, /* @__PURE__ */ React78__default.createElement("div", { className: "flex items-center px-4 py-2 bg-[#252526] border-b border-white/5" }, /* @__PURE__ */ React78__default.createElement("span", { className: "text-xs font-mono text-muted-foreground uppercase tracking-widest opacity-50" }, "reference_solution.", question.codingLanguage)), /* @__PURE__ */ React78__default.createElement(
|
|
74376
74721
|
Editor,
|
|
74377
74722
|
{
|
|
74378
74723
|
height: "300px",
|