()
| 1279 | } |
| 1280 | |
| 1281 | function initImportPage() { |
| 1282 | const confirmBtn = $("importConfirmBtn"); |
| 1283 | const errorMsg = $("importErrorMsg"); |
| 1284 | const uploadZone = $("importUploadZone"); |
| 1285 | const figureFile = $("importFigureFile"); |
| 1286 | const figurePreview = $("importFigurePreview"); |
| 1287 | const figureStatus = $("importFigureStatus"); |
| 1288 | const providerInput = $("importProvider"); |
| 1289 | const providerButtons = $("importProviderButtons"); |
| 1290 | const svgModelInput = $("importSvgModel"); |
| 1291 | const apiKeyInput = $("importApiKey"); |
| 1292 | const baseUrlGroup = $("importBaseUrlGroup"); |
| 1293 | const baseUrlInput = $("importBaseUrl"); |
| 1294 | const samBackend = $("importSamBackend"); |
| 1295 | const samPrompt = $("importSamPrompt"); |
| 1296 | const samApiKeyGroup = $("importSamApiKeyGroup"); |
| 1297 | const samApiKeyInput = $("importSamApiKey"); |
| 1298 | let uploadedFigurePath = null; |
| 1299 | |
| 1300 | function getProviderLabel(provider) { |
| 1301 | const normalized = normalizeProviderValue(provider); |
| 1302 | if (normalized === "openai_response") { |
| 1303 | return t("providers.openai_response"); |
| 1304 | } |
| 1305 | if (normalized === "openrouter") { |
| 1306 | return t("providers.openrouter"); |
| 1307 | } |
| 1308 | if (normalized === "gemini") { |
| 1309 | return t("providers.gemini"); |
| 1310 | } |
| 1311 | return t("providers.custom"); |
| 1312 | } |
| 1313 | |
| 1314 | function loadImportState() { |
| 1315 | try { |
| 1316 | const raw = window.sessionStorage.getItem(IMPORT_STATE_KEY); |
| 1317 | if (!raw) { |
| 1318 | return null; |
| 1319 | } |
| 1320 | const parsed = JSON.parse(raw); |
| 1321 | return parsed && typeof parsed === "object" ? parsed : null; |
| 1322 | } catch (_err) { |
| 1323 | return null; |
| 1324 | } |
| 1325 | } |
| 1326 | |
| 1327 | function saveImportState() { |
| 1328 | const state = { |
| 1329 | provider: normalizeProviderValue(providerInput?.value ?? "gemini"), |
| 1330 | svgModel: svgModelInput?.value ?? "", |
| 1331 | apiKey: apiKeyInput?.value ?? "", |
| 1332 | baseUrl: baseUrlInput?.value ?? DEFAULT_CUSTOM_BASE_URL, |
| 1333 | samBackend: samBackend?.value ?? "roboflow", |
| 1334 | samPrompt: samPrompt?.value ?? "icon,person,robot,animal", |
| 1335 | samApiKey: samApiKeyInput?.value ?? "", |
| 1336 | uploadedFigurePath, |
| 1337 | previewUrl: figurePreview?.src ?? "", |
| 1338 | figureStatus: figureStatus?.textContent ?? "", |
no test coverage detected