(function() { //#region ../../packages/core/src/utils/browser-backup/limits.ts var LIMITS = Object.freeze({ fileBytes: 536870912, lineBytes: 67108864, binaryBytes: 33554432, nodes: 1e5, depth: 256, entries: 1e6, databases: 1e3, stores: 1e4, batchRecords: 100, timeoutMs: 15e3 }); function check(condition, message) { if (!condition) throw new Error(message); } function errorMessage(error) { return error instanceof Error || error instanceof DOMException ? `${error.name}: ${error.message}` : String(error); } function object(value) { check(value !== null && typeof value === "object" && !Array.isArray(value), "Expected object"); return value; } function string(value) { check(typeof value === "string", "Expected string"); return value; } function integer(value, max = Number.MAX_SAFE_INTEGER) { check(typeof value === "number" && Number.isSafeInteger(value) && value >= 0 && value <= max, "Invalid integer"); return value; } function array(value, max = LIMITS.nodes) { check(Array.isArray(value) && value.length <= max, "Invalid or oversized array"); return value; } //#endregion //#region ../../packages/core/src/utils/browser-backup/codec.ts var views = { Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, BigInt64Array, BigUint64Array, DataView }; function toBase64(bytes) { const chunks = []; for (let i = 0; i < bytes.length; i += 8192) chunks.push(String.fromCharCode(...bytes.subarray(i, i + 8192))); return btoa(chunks.join("")); } async function encode(value) { const nodes = []; const seen = /* @__PURE__ */ new Map(); let binaryBytes = 0; let arraySlots = 0; async function binary(blob) { binaryBytes += blob instanceof Blob ? blob.size : blob.byteLength; check(binaryBytes <= LIMITS.binaryBytes, "Record binary exceeds limit"); return toBase64(new Uint8Array(blob instanceof Blob ? await blob.arrayBuffer() : blob)); } async function visit(item, depth) { if (item !== null && typeof item === "object" && seen.has(item)) return seen.get(item); check(depth <= LIMITS.depth && nodes.length < LIMITS.nodes, "Record graph exceeds limit"); const id = nodes.length; const node = []; nodes.push(node); if (item !== null && typeof item === "object") seen.set(item, id); if (item === null || typeof item === "string" || typeof item === "boolean") node.push("scalar", item); else if (typeof item === "undefined") node.push("undefined"); else if (typeof item === "number") node.push("number", Object.is(item, -0) ? "-0" : String(item)); else if (typeof item === "bigint") node.push("bigint", String(item)); else if (item instanceof Date) node.push("date", String(item.getTime())); else if (item instanceof RegExp) node.push("regexp", item.source, item.flags); else if (item instanceof ArrayBuffer) node.push("buffer", await binary(item)); else if (ArrayBuffer.isView(item)) { const name = Object.keys(views).find((key) => Object.getPrototypeOf(item) === views[key].prototype); check(name && item.buffer instanceof ArrayBuffer, "Unsupported binary view"); node.push("view", name, await visit(item.buffer, depth + 1), item.byteOffset, item.byteLength); } else if (typeof File !== "undefined" && item instanceof File) node.push("file", await binary(item), item.type, item.name, item.lastModified); else if (item instanceof Blob) node.push("blob", await binary(item), item.type); else if (item instanceof Map) { const entries = []; for (const [key, entry] of item) entries.push([await visit(key, depth + 1), await visit(entry, depth + 1)]); node.push("map", entries); } else if (item instanceof Set) { const entries = []; for (const entry of item) entries.push(await visit(entry, depth + 1)); node.push("set", entries); } else if (item instanceof Number || item instanceof String || item instanceof Boolean) node.push("boxed", await visit(item.valueOf(), depth + 1)); else if (item !== null && typeof item === "object" && (Array.isArray(item) || Object.getPrototypeOf(item) === Object.prototype || Object.getPrototypeOf(item) === null)) { if (Array.isArray(item)) arraySlots += item.length; check(arraySlots <= LIMITS.nodes * 4, "Record array allocation exceeds limit"); const entries = []; for (const key of Object.keys(item)) { const descriptor = Object.getOwnPropertyDescriptor(item, key); check("value" in descriptor, "Accessors are unsupported"); entries.push([key, await visit(descriptor.value, depth + 1)]); } check(Object.getOwnPropertySymbols(item).length === 0, "Symbol properties are unsupported"); node.push(Array.isArray(item) ? "array" : "object", entries, Array.isArray(item) ? item.length : null); } else throw new Error(`Unsupported value type: ${Object.prototype.toString.call(item)}`); return id; } return { root: await visit(value, 0), nodes }; } //#endregion //#region ../../packages/core/src/utils/browser-backup/database.ts function transactionDone(tx) { return new Promise((resolve, reject) => { const timer = setTimeout(() => { try { tx.abort(); } catch {} reject(/* @__PURE__ */ new Error("Transaction timed out")); }, LIMITS.timeoutMs); tx.oncomplete = () => { clearTimeout(timer); resolve(); }; tx.onabort = () => { clearTimeout(timer); reject(tx.error ?? /* @__PURE__ */ new Error("Transaction aborted")); }; }); } function openExisting(factory, name) { return open(factory, name); } function open(factory, name, schema) { return new Promise((resolve, reject) => { const request = schema ? factory.open(name, schema.version) : factory.open(name); let settled = false; let upgradeError; const fail = (error) => { settled = true; clearTimeout(timer); reject(error); }; const timer = setTimeout(() => fail(/* @__PURE__ */ new Error("Database open timed out; close other tabs using this database")), LIMITS.timeoutMs); request.onblocked = () => fail(/* @__PURE__ */ new Error("Database open blocked; close other tabs using this database")); request.onupgradeneeded = (event) => { if (settled || !schema || event.oldVersion !== 0) { request.transaction.abort(); upgradeError = /* @__PURE__ */ new Error("Database missing or changed; existing databases are never upgraded"); return; } try { for (const store of schema.stores) { const target = request.result.createObjectStore(store.name, { keyPath: store.keyPath, autoIncrement: store.autoIncrement }); for (const index of store.indexes) target.createIndex(index.name, index.keyPath, index); } } catch (error) { upgradeError = error; request.transaction.abort(); } }; request.onerror = () => fail(upgradeError ?? request.error); request.onsuccess = () => { clearTimeout(timer); if (settled) { request.result.close(); return; } settled = true; const db = request.result; db.onversionchange = () => db.close(); resolve(db); }; }); } function storeSchema(store) { return { name: store.name, keyPath: store.keyPath, autoIncrement: store.autoIncrement, indexes: Array.from(store.indexNames, (name) => { const index = store.index(name); return { name, keyPath: index.keyPath, unique: index.unique, multiEntry: index.multiEntry }; }) }; } async function readSchema(db) { const names = Array.from(db.objectStoreNames); if (names.length === 0) return { name: db.name, version: db.version, stores: [] }; const tx = db.transaction(names, "readonly"); const done = transactionDone(tx); const stores = names.map((name) => storeSchema(tx.objectStore(name))); await done; return { name: db.name, version: db.version, stores }; } function estimateBytes(value) { const pending = [value]; const seen = /* @__PURE__ */ new Set(); let bytes = 0; let visited = 0; while (pending.length && bytes < 4194304 && visited++ < LIMITS.nodes) { const item = pending.pop(); if (typeof item === "string") bytes += item.length * 2; else if (item && typeof item === "object" && !seen.has(item)) { seen.add(item); if (item instanceof Blob) bytes += item.size; else if (item instanceof ArrayBuffer || ArrayBuffer.isView(item)) bytes += item.byteLength; else if (item instanceof Map) for (const [key, value] of item) pending.push(key, value); else if (item instanceof Set) for (const value of item) pending.push(value); else for (const key of Object.keys(item)) { bytes += key.length * 2; pending.push(item[key]); } } else bytes += 8; } return pending.length ? Infinity : bytes; } async function readBatch(db, store, after) { const tx = db.transaction(store, "readonly"); const done = transactionDone(tx); const rows = []; let bytes = 0; const cursor = tx.objectStore(store).openCursor(after === void 0 ? void 0 : IDBKeyRange.lowerBound(after, true)); cursor.onsuccess = () => { const result = cursor.result; if (!result) return; try { const value = result.value; rows.push({ key: result.primaryKey, value }); bytes += estimateBytes(value); } catch (error) { rows.push({ key: result.primaryKey, value: void 0, error }); } if (rows.length < LIMITS.batchRecords && bytes < 4194304) result.continue(); }; await done; return rows; } //#endregion //#region \0@oxc-project+runtime@0.154.0/helpers/esm/typeof.js function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) { return typeof o; } : function(o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } //#endregion //#region \0@oxc-project+runtime@0.154.0/helpers/esm/toPrimitive.js function toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } //#endregion //#region \0@oxc-project+runtime@0.154.0/helpers/esm/toPropertyKey.js function toPropertyKey(t) { var i = toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } //#endregion //#region \0@oxc-project+runtime@0.154.0/helpers/esm/defineProperty.js function _defineProperty(e, r, t) { return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } //#endregion //#region ../../packages/core/src/utils/browser-backup/format.ts var FORMAT = "zaixianwan-browser-backup"; var TOOL_VERSION = "1.0.0"; function keyPath(value, nullable) { if (nullable && value === null) return null; const path = (input) => { const text = string(input); check(text.length <= 1024 && (text === "" || text.split(".").every((part) => /^[$_\p{ID_Start}][$\u200C\u200D\p{ID_Continue}]*$/u.test(part))), "Invalid keyPath"); return text; }; if (Array.isArray(value)) { check(value.length > 0 && value.length <= 1e3, "Invalid compound keyPath"); return value.map(path); } return path(value); } function validateSchema(value) { const db = object(value); const name = string(db.name); const version = integer(db.version); check(version > 0, "Invalid database version"); const storeNames = /* @__PURE__ */ new Set(); return { name, version, stores: array(db.stores, LIMITS.stores).map((item) => { const store = object(item); const name = string(store.name); check(!storeNames.has(name), "Duplicate store"); storeNames.add(name); const path = keyPath(store.keyPath, true); check(typeof store.autoIncrement === "boolean", "Invalid autoIncrement"); check(!store.autoIncrement || path !== "" && !Array.isArray(path), "Invalid generated keyPath"); const indexNames = /* @__PURE__ */ new Set(); const indexes = array(store.indexes, LIMITS.stores).map((item) => { const index = object(item); const name = string(index.name); check(!indexNames.has(name), "Duplicate index"); indexNames.add(name); const path = keyPath(index.keyPath, false); check(typeof index.unique === "boolean" && typeof index.multiEntry === "boolean", "Invalid index options"); check(!index.multiEntry || !Array.isArray(path), "Invalid multiEntry keyPath"); return { name, keyPath: path, unique: index.unique, multiEntry: index.multiEntry }; }); return { name, keyPath: path, autoIncrement: store.autoIncrement, indexes }; }) }; } async function digest(payload) { const bytes = new TextEncoder().encode(payload); return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256", bytes)), (byte) => byte.toString(16).padStart(2, "0")).join(""); } var BackupWriter = class { constructor() { _defineProperty(this, "parts", []); _defineProperty(this, "previousHash", ""); _defineProperty(this, "bytes", 0); _defineProperty(this, "entries", 0); } async add(entry, final = false) { const payload = JSON.stringify(entry); check(payload.length <= LIMITS.lineBytes, "Entry exceeds 64 MiB"); const sha256 = await digest(`${this.previousHash}\n${payload}`); const part = new Blob([JSON.stringify({ payload, sha256 }), "\n"]); check(part.size <= LIMITS.lineBytes, "Entry exceeds 64 MiB; choose a smaller record source"); check(this.bytes + part.size <= LIMITS.fileBytes - (final ? 0 : 16777216), "Backup reaches 512 MiB limit; export databases separately"); check(this.entries < LIMITS.entries - (final ? 0 : 1), "Too many entries"); this.parts.push(part); this.bytes += part.size; this.entries++; this.previousHash = sha256; } finish() { return new Blob(this.parts, { type: "application/x-ndjson" }); } }; //#endregion //#region ../../packages/core/src/utils/browser-backup/index.ts function excludedLocalStorageKey(key) { return /^zaixianwan:user:/.test(key) || key === "trial:firstLaunchTime"; } async function discoverDatabases() { check(typeof indexedDB?.databases === "function", "无法枚举数据库 / Database enumeration unavailable; enter a database name manually"); return (await indexedDB.databases()).flatMap((db) => typeof db.name === "string" ? [db.name] : []); } async function exportBackup(options) { check(new Set(options.databases).size === options.databases.length && options.databases.length <= LIMITS.databases, "Invalid database selection"); const writer = new BackupWriter(); const issues = []; let omittedIssues = 0; const report = (location, error) => { if (issues.length < 1e4) issues.push({ location: location.slice(0, 1024), reason: errorMessage(error).slice(0, 1024) }); else omittedIssues++; }; let records = 0; let localCount = 0; const progress = (location) => options.onProgress?.({ records, localStorage: localCount, bytes: writer.bytes, location }); await writer.add({ type: "header", format: FORMAT, version: 1, toolVersion: TOOL_VERSION, origin: location.origin, createdAt: (/* @__PURE__ */ new Date()).toISOString() }); for (const name of options.databases) { let db; try { progress(name); db = await openExisting(indexedDB, name); const schema = validateSchema(await readSchema(db)); await writer.add({ type: "database", schema }); for (const store of schema.stores) { let lastKey; let position = 0; try { while (true) { const batch = await readBatch(db, store.name, lastKey); if (!batch.length) break; for (const row of batch) { position++; try { if ("error" in row) throw row.error; const data = await encode([row.key, row.value]); await writer.add({ type: "record", database: name, store: store.name, data }); records++; } catch (error) { report(`${name}/${store.name}/record ${position}`, error); } } lastKey = batch[batch.length - 1].key; progress(`${name}/${store.name}`); await new Promise((resolve) => setTimeout(resolve, 0)); } } catch (error) { report(`${name}/${store.name}/after record ${position}`, error); } } } catch (error) { report(name, error); } finally { db?.close(); } } if (options.localStorage) try { const storage = window.localStorage; const keys = Array.from({ length: storage.length }, (_, i) => storage.key(i)).filter((key) => key !== null); for (const key of keys) { if (excludedLocalStorageKey(key)) continue; try { const value = storage.getItem(key); check(value !== null, "Key removed during export"); await writer.add({ type: "localStorage", key, value }); localCount++; } catch (error) { report(`localStorage/${key}`, error); } } } catch (error) { report("localStorage", error); } await writer.add({ type: "footer", entries: writer.entries, records, localStorage: localCount, issues, omittedIssues }, true); progress("complete"); return { file: writer.finish(), failures: issues.length + omittedIssues, records, localStorage: localCount, issues, filename: `browser-backup-${location.hostname}-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.zxb` }; } //#endregion //#region ../../packages/core/src/utils/browser-backup/panel.ts function mountExporter(container, language = document.documentElement.lang) { const zh = !language || language.startsWith("zh"); const traditional = /^zh-(?:Hant(?:-|$)|TW$|HK$|MO$)/i.test(language); const t = (cn, en, hant) => traditional ? hant : zh ? cn : en; const root = container.attachShadow({ mode: "open" }); const style = document.createElement("style"); style.textContent = ` :host{display:block;color:inherit;font:15px/1.8 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans CJK SC","Microsoft YaHei",sans-serif} h2{font-size:22px;line-height:1.4;margin:0 0 12px;font-weight:650}p{margin:12px 0;overflow-wrap:anywhere}.origin{font-size:13px;opacity:.7} fieldset{border:1px solid #8884;border-radius:8px;padding:16px;margin:16px 0}label{display:block;margin:10px 0;overflow-wrap:anywhere}summary{cursor:pointer}details{margin-top:16px} button,input{font:inherit}button{padding:10px 20px;cursor:pointer;border:1px solid #8885;border-radius:8px;background:transparent;color:inherit}button:disabled{opacity:.5;cursor:wait} .primary,.download{display:inline-block;padding:10px 24px;border:1px solid #15965d;border-radius:8px;background:#15965d;color:#fff;text-decoration:none;font-weight:600}.primary{margin-top:12px;background:#2563eb;border-color:#2563eb}.download{margin-top:4px}.next-step{margin-top:20px;padding-top:4px;border-top:1px solid #8884}.continue{display:inline-block;padding:8px 16px;border:1px solid #8886;border-radius:8px;text-decoration:none;font-weight:600} input[type=text]{max-width:100%;box-sizing:border-box}pre{white-space:pre-wrap;overflow-wrap:anywhere;max-height:320px;overflow:auto;font-size:13px}a{color:inherit}button:focus-visible,input:focus-visible,a:focus-visible{outline:2px solid #168f66;outline-offset:3px} [hidden]{display:none!important}`; root.append(style); const heading = document.createElement("h2"); heading.textContent = t("保存一份备份", "Save a backup", "儲存一份備份"); const note = document.createElement("p"); note.textContent = t("游戏进度和网站设置会一起备份。先保存并暂停游戏,再点击下面的按钮。", "Game progress and website settings are included. Save and pause your game, then click the button below.", "遊戲進度和網站設定會一起備份。先儲存並暫停遊戲,再點擊下面的按鈕。"); const originNote = document.createElement("p"); originNote.className = "origin"; originNote.textContent = t(`正在备份:${location.origin}`, `Backing up: ${location.origin}`, `正在備份:${location.origin}`); const fields = document.createElement("fieldset"); const legend = document.createElement("legend"); legend.textContent = t("选择要备份的内容", "Choose what to back up", "選擇要備份的內容"); const list = document.createElement("div"); const checkboxes = /* @__PURE__ */ new Map(); const addDatabase = (name) => { if (checkboxes.has(name)) return; const label = document.createElement("label"); const input = document.createElement("input"); input.type = "checkbox"; input.checked = true; label.append(input, document.createTextNode(` ${name || "(empty name)"}`)); list.append(label); checkboxes.set(name, input); }; const scan = document.createElement("button"); scan.type = "button"; scan.textContent = t("重新查找数据", "Look for data again", "重新尋找資料"); const manualLabel = document.createElement("label"); manualLabel.textContent = t("无法枚举时,可输入已知数据库名:", "If enumeration fails, enter a known database name:", "無法列舉時,可輸入已知資料庫名稱:"); const manual = document.createElement("input"); manual.type = "text"; manualLabel.append(manual); const add = document.createElement("button"); add.type = "button"; add.textContent = t("添加数据库", "Add database", "新增資料庫"); add.onclick = () => { addDatabase(manual.value); manual.value = ""; }; const localLabel = document.createElement("label"); const local = document.createElement("input"); local.type = "checkbox"; local.checked = true; localLabel.append(local, document.createTextNode(t(" 同时备份网站设置(可选)", " Include website settings (optional)", " 同時備份網站設定(可選)"))); const advanced = document.createElement("details"); const advancedTitle = document.createElement("summary"); advancedTitle.textContent = t("没有找到数据?高级选项", "Missing data? Advanced options", "沒有找到資料?進階選項"); advanced.append(advancedTitle, scan, manualLabel, add); const selection = document.createElement("details"); const selectionTitle = document.createElement("summary"); selectionTitle.textContent = t("选择备份内容(通常不用改)", "Choose backup data (usually no changes needed)", "選擇備份內容(通常不用改)"); selection.append(selectionTitle, list); fields.append(legend, localLabel, selection, advanced); const start = document.createElement("button"); start.type = "button"; start.className = "primary"; start.textContent = t("生成备份", "Create backup", "產生備份"); const status = document.createElement("p"); status.setAttribute("role", "status"); status.setAttribute("aria-live", "polite"); const downloads = document.createElement("div"); const nextStep = document.createElement("div"); nextStep.className = "next-step"; nextStep.hidden = true; const nextNote = document.createElement("p"); nextNote.textContent = t("保存好文件后,去新站选择这份备份,再点“开始恢复”。", "Once the file is saved, open the new website, choose this backup, and click “Start restoring”.", "儲存好檔案後,去新站選擇這份備份,再點「開始還原」。"); const restoreLink = document.createElement("a"); restoreLink.className = "continue"; restoreLink.href = traditional ? "https://zaixianwan.win/zh-Hant/settings/data#restore" : "https://zaixianwan.win/settings/data#restore"; restoreLink.target = "_blank"; restoreLink.rel = "noopener"; restoreLink.textContent = t("去新站恢复进度", "Restore on the new website", "去新站還原進度"); nextStep.append(nextNote, restoreLink); const details = document.createElement("pre"); details.setAttribute("aria-label", t("失败项", "Failures", "失敗項目")); const report = document.createElement("details"); const reportTitle = document.createElement("summary"); reportTitle.textContent = t("查看备份详情", "View backup details", "查看備份詳情"); report.append(reportTitle, details); report.hidden = true; const recoveryOptions = document.createElement("details"); const recoveryTitle = document.createElement("summary"); recoveryTitle.textContent = t("备份遇到问题?", "Having trouble with the backup?", "備份遇到問題?"); const retry = document.createElement("button"); retry.type = "button"; retry.textContent = t("重新生成备份", "Create backup again", "重新產生備份"); retry.onclick = () => start.click(); recoveryOptions.append(recoveryTitle, fields, retry); recoveryOptions.hidden = true; root.append(heading, note, start, status, downloads, nextStep, originNote, report, recoveryOptions); let disposed = false; const urls = []; const setBusy = (busy) => { fields.disabled = busy; start.disabled = busy; retry.disabled = busy; }; scan.onclick = async () => { setBusy(true); status.textContent = t("正在查找已保存的数据…", "Looking for saved data…", "正在尋找已儲存的資料…"); try { const names = await discoverDatabases(); list.replaceChildren(); checkboxes.clear(); names.forEach(addDatabase); if (!names.length) recoveryOptions.hidden = false; status.textContent = names.length ? t("准备好了,可以生成备份。", "Ready to create your backup.", "準備好了,可以產生備份。") : t("没有找到存档,可以继续备份网站设置。", "No saves found. You can still back up website settings.", "沒有找到存檔,可以繼續備份網站設定。"); } catch (error) { recoveryOptions.hidden = false; status.textContent = t("查找数据失败:", "Could not find data: ", "尋找資料失敗:") + errorMessage(error); } finally { setBusy(false); } }; start.onclick = async () => { setBusy(true); status.textContent = t("正在生成备份…", "Creating your backup…", "正在產生備份…"); nextStep.hidden = true; downloads.replaceChildren(); details.textContent = ""; report.hidden = true; try { const result = await exportBackup({ databases: [...checkboxes].filter(([, input]) => input.checked).map(([name]) => name), localStorage: local.checked }); if (disposed) return; const url = URL.createObjectURL(result.file); urls.push(url); const link = document.createElement("a"); link.href = url; link.className = "download"; link.download = result.filename; link.textContent = t("下载备份", "Download backup", "下載備份"); link.onclick = () => { nextStep.hidden = false; }; downloads.replaceChildren(link); start.hidden = true; status.textContent = result.failures ? t("备份已生成,部分内容未能保存,详情见下方。", "Your backup is ready. Some items could not be saved; see the details below.", "備份已產生,部分內容未能儲存,詳情見下方。") : t("备份已生成!点击“下载备份”,把文件保存好。", "Your backup is ready! Click “Download backup” to save the file.", "備份已產生!點擊「下載備份」,把檔案儲存好。"); if (!result.records && !result.localStorage) status.textContent = t("这个网页还没有可备份的数据。", "This page has no data to back up yet.", "這個網頁還沒有可備份的資料。"); if (result.failures || !result.records && !result.localStorage) recoveryOptions.hidden = false; report.hidden = !result.failures; details.textContent = `${result.records} ${t("条数据", "entries", "筆資料")} · ${result.localStorage} ${t("项设置", "settings", "項設定")} · ${result.failures} ${t("项失败", "failures", "項失敗")}\n` + result.issues.map((item) => `${item.location}: ${item.reason}`).join("\n"); } catch (error) { recoveryOptions.hidden = false; status.textContent = errorMessage(error); } finally { setBusy(false); } }; scan.click(); return () => { disposed = true; urls.forEach((url) => URL.revokeObjectURL(url)); root.replaceChildren(); }; } //#endregion //#region ../../packages/core/src/utils/browser-backup/console.ts var PANEL_ID = "zaixianwan-browser-backup-exporter"; /** @public The recovery bookmarklet imports this name from the built console entry. */ function openExporter() { const existing = document.getElementById(PANEL_ID); if (existing) { existing.focus(); return; } if (!document.body || location.origin === "null") throw new Error("Open the original website in the original browser profile first"); const zh = !document.documentElement.lang || document.documentElement.lang.startsWith("zh"); const dialog = document.createElement("dialog"); dialog.id = PANEL_ID; dialog.setAttribute("aria-label", zh ? "浏览器备份" : "Browser backup"); dialog.style.cssText = "box-sizing:border-box;width:min(700px,calc(100vw - 32px));max-height:85vh;overflow:auto;padding:28px;color:#202820;background:#fff;border:1px solid #888;border-radius:14px;z-index:2147483647"; const close = document.createElement("button"); close.type = "button"; close.style.cssText = "display:block;margin:0 0 16px auto;border:0;background:transparent;color:inherit;cursor:pointer;padding:4px 8px;font:14px system-ui,\"Noto Sans CJK SC\",sans-serif"; close.textContent = zh ? "关闭" : "Close"; const container = document.createElement("div"); dialog.append(close, container); document.body.append(dialog); const dispose = mountExporter(container); const cleanup = () => { dispose(); dialog.remove(); }; close.onclick = cleanup; dialog.addEventListener("cancel", (event) => { event.preventDefault(); cleanup(); }); dialog.showModal(); } //#endregion //#region ../../packages/core/src/utils/browser-backup/offline.ts openExporter(); //#endregion })();