diff --git a/.gitattributes b/.gitattributes index 2d97a62a9..c6eadbbd8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -16,3 +16,5 @@ frontend/index.html text eol=lf # WSL/bash scripts stay LF (see agent-assets/.gitattributes same rule) *.sh text eol=lf + +mikazuki/engines/moss/patches/*.patch text eol=lf -whitespace diff --git a/.gitignore b/.gitignore index 1bf8dd33d..14a3d47af 100644 --- a/.gitignore +++ b/.gitignore @@ -145,6 +145,10 @@ extensions/diffsynth/ /extensions/moss/ /extensions/.moss.lock +# Isolated KohakuMoss runtime and cross-process lock +/extensions/kohaku-moss/ +/extensions/.kohaku-moss.lock + # Local project memory /MEMORY.md @@ -152,8 +156,22 @@ extensions/diffsynth/ /qwen-image-2.1-processor/ /tokenizer-cache/ -# Generated frontend assets (existing tracked release assets remain tracked) +# Generated frontend assets /frontend/dist/ # User-owned settings, credentials, presets and task archives. /user_data/ + +# launcher (.NET) build artifacts +launcher/bin/ +launcher/obj/ + +# Local verification output +/junit*.xml +/pytest*.xml +/frontend/.vite/ +/frontend/.vitest/ +/frontend/coverage/ + +# Local MOSS integration notes +/mikazuki/engines/moss/FIELD_NOTES.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 53986e4f3..ccfdbf74c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,33 +3,46 @@ 本文件记录 **wochenlong/lora-scripts-next**(产品名 **Next Trainer**)面向镜像与 AutoDL 的发行说明;上游 kohya-ss/sd-scripts 的变更请见其仓库。 --- -## 未发布 +## 未发布(dev) -### 新增 - -- **MOSS-Image LoRA(#480 / #483)**:接入 MOSS-Image 训练,Kohya 为推荐及默认引擎,内置原生 trainer、缓存与 ConvRot INT8 支持;`MOSS (anima_lora)` 保留为次选独立运行时。支持原生 Diffusers 与 Comfy 单文件输入,详见 [MOSS-Image 训练指南](docs/MOSS.md)。 - -### 修复 - -- **DiffSynth 指纹不再包含 mtime(#410)**:目录拷贝、云镜像打包、解压或启动脚本触碰文件都会改写时间戳,导致可用环境被误报「环境或源码已变化」并要求重装(AutoDL 定制镜像上会反复复发)。指纹改为**内容哈希**(`content-v2`)并持久化方案标记:时间戳变化不再误报,旧状态**一次性迁移**(不要求重装),内容真的被改动、训练入口/独立 Python 缺失时仍会正确报错。 - - **预装 DiffSynth 的定制镜像需要同步这两个文件后重建镜像才生效**:`mikazuki/engines/diffsynth/extension_state.py`、`mikazuki/engines/diffsynth/install_worker.py`;只更新 `install_state.json` 不算修复(下次时间戳再变还会复发)。 +(下一个开发周期:AI Toolkit 模型格式与训练体验,详见 docs/roadmap.md) -- **Krea2 tokenizer 的 `extra_special_tokens` 为 list 时加载失败(#416)**:探测/下载/启动前会把旧的 list 形态规范化为 transformers 期望的 mapping(`{"additional_special_tokens": [...]}`),手动放置的 tokenizer 同样会被治好;已是 mapping 的配置不动,坏 JSON 安全跳过。 -- **Kohya 加载 Anima 2.9B 前明确拦截(#408)**:`validate_model` 只读 safetensors 头部统计 DiT block 数,超过 28 即拒绝并提示「请改用 Anima Fast(设置 → 训练引擎 安装),或改用 Anima 2B」,不再等到加载时抛一串 `blocks.28.*` 权重名;2B 与 Anima Fast 路径不受影响,坏文件/无法识别不会被误判。 -- **标签编辑的「选择已有数据集」弹窗为空(#440)**:`ManagedDatasetPicker` 现在会监听受控的 `open` 属性(标签编辑隐藏内部按钮、直接控制弹窗),弹窗打开时执行与内部按钮相同的初始化并拉取数据集列表;关闭后重开正常刷新,`browse()` 的 generation 机制继续防止并发响应覆盖 - **训练引擎下拉显示安装状态(#443)**:每个引擎带状态后缀(已就绪 / 未安装 / 需修复 / 安装中 / 已停用 / 未验证),模型不支持的引擎继续灰显并保留「该模型暂不支持」提示,另加一条可操作提示列出「当前模型支持但未安装/待修复」的引擎;引擎状态接口失败时静默降级为纯引擎名 - **AI Toolkit 新增 SD 1.5 与 Ideogram 4 LoRA(#446)**:两个模型都直接读取 Comfy 格式单文件,无需用户转换 diffusers 目录 - **SD 1.5(arch `sd1`)**:`single_file` 模式加载 Comfy/LDM 全量 checkpoint(`model.diffusion_model.*` / `cond_stage_model.*` / `first_stage_model.*`),由驱动层绑定本地 diffusers 配置目录(仅 config 与 tokenizer,不含权重,默认 `sd-models/sd15/config`,可由「训练用模型」面板从 HF / ModelScope 下载),离线启动不访问 Hub - **Ideogram 4(arch `ideogram4`)**:`comfyui_files` 模式直接使用 Comfy-Org 单文件(条件 DiT + Flux2 VAE,与 Musubi 同一套下载源),驱动层在内存中整理 FP8 `weight_scale` 形状并剔除 `comfy_quant` 标记后交给上游扩展,不写 diffusers 目录、不产生缓存副本;文本编码器使用本地 Qwen3-VL-8B BF16 目录。沿用**非商用**许可提示,整合包不预置权重 -- **底模已是 FP8 时自动关闭 fp8_base/fp8_scaled(#417)**:只读 safetensors 头部探测 DiT dtype,已是 FP8 权重时自动关闭这两项并提示;非 FP8 底模的成对约束不变 -- **max_train_steps 与 max_train_epochs 同时填写(#418)**:按**步数优先**只保留 max_train_steps 并明确提示(上游以 epoch 优先,会让「steps=100」实跑到按 epoch 推导的步数),表单文案同步写清 -- **AI Toolkit 的 Ideogram 4 文本编码器改为 Comfy FP8 单文件(#446 跟进)**:驱动层把 tokenizer/config 仍指向本地目录、权重走 Comfy 单文件(上游 mixin 原生支持 `comfy_quant` 单文件加载),资源清单改为「TE 单文件 + config/tokenizer 目录(约几 MB)」,用户不再需要 ~16 GB 的 bf16 目录;`model_directory` 分支与 `config/model_assets.toml` 覆盖仍可回退到 bf16 目录 + +### 修复(近一个月 issue 第三批) + +- **标签编辑的「选择已有数据集」弹窗为空(#440)**:`ManagedDatasetPicker` 现在会监听受控的 `open` 属性(标签编辑隐藏内部按钮、直接控制弹窗),弹窗打开时执行与内部按钮相同的初始化并拉取数据集列表;关闭后重开正常刷新,`browse()` 的 generation 机制继续防止并发响应覆盖 + +### 修复(近一个月 issue 第四批) + +- **底模已是 FP8 时自动关闭 fp8_base/fp8_scaled(#417)**:只读 safetensors 头部探测 DiT 的 dtype,已是 FP8 权重时自动关闭这两项并提示(两个都关本就是合法状态),不再等到上游拒绝;非 FP8 底模的成对约束不变 +- **max_train_steps 与 max_train_epochs 同时填写(#418)**:musubi 侧以 epoch 优先,会让「steps=100」实跑到按 epoch 推导的步数;现在按**步数优先**只保留 max_train_steps 并明确提示,表单两处文案也写清「以步数为准」 + +### 新增 - **Ideogram 4(AI Toolkit)无条件采样 LoRA 设为可选(#446 跟进)**:新增可选资源 `unconditional_lora`(第三方产物 `ostris/ideogram_4_unconditional_lora`,103.9 MB)与表单可选字段「无条件 LoRA 路径」——填了走非对称 CFG 预览,不填走单 DiT CFG;顺带修掉 `text_encoder_tokenizer_path` 被字段白名单误报「未支持」的噪音警告 -- **DiffSynth 软链权重误报(#390)**:路径规范化不再跟随叶子软链,AutoDL 那类「`*.safetensors` 名字指向无后缀实体」的挂载不再被后缀校验误拒 +- **AI Toolkit 的 Ideogram 4 文本编码器改为 Comfy FP8 单文件(#446 跟进)**:不再要求用户准备 ~16 GB 的 bf16 Qwen3-VL-8B 目录——驱动层把 tokenizer/config 仍指向本地目录、权重改走 Comfy 单文件(上游 mixin 原生支持 `comfy_quant` 单文件加载),资源清单同步改为「TE 单文件 + config/tokenizer 目录(约几 MB)」 + +- **Windows 启动器 `NextTrainer.exe`(#435)**:放在整合包根目录(与 `启动.bat` 并存)。双击启动等价于 `启动.bat`,但接管进程树:关窗 / `Q` 真正停掉服务,端口占用或启动失败给中文提示,`U` 一键更新(先停服 → 运行更新脚本 → `R` 重启)。C# NativeAOT 编译(约 5 MB,无 .NET 运行时依赖)。构建脚本 `build-scripts/06-build-launcher.ps1`,已接入 2026 全量 / musubi-only / kohya-only / resume 的打包流程 + +### 修复(近一个月 issue 第二批) + +- **DiffSynth 软链权重误报(#390)**:路径规范化不再跟随叶子软链,AutoDL 那类「`*.safetensors` 名字指向无后缀实体」的挂载不再被后缀校验拒绝 - **单条提交的 autosave 快照重名(#334)**:`/api/run` 的配置快照名加入随机后缀,同一秒内连续提交不再互相覆盖(批量提交此前已修) -- **anima-fast 小数据集丢图提示(#338)**:预检在「图片数偏少 + train_batch_size>1」时预警上游 bucket 采样会整桶丢弃图片(启动日志里只有一条 WARNING 就会被忽略掉),并给出 batch_size=1 / num_repeats / bucket_reso_steps / validation_split_num 的处理建议 -- **Anima TE 缓存固化 caption_dropout_rate(#333)**:文档写明「改动该值需删除 `_anima_te.npz` 再重训」的限制([开发进度](docs/dev-progress.md));上游缓存键的一致性校验待跟进 +- **anima-fast 小数据集丢图提示(#338)**:预检在「图片数偏少 + train_batch_size>1」时明确警告上游 bucket 采样会整桶丢弃图片(及 1 batch 步数远低于预期的原因),并给出 batch_size=1 / num_repeats / bucket_reso_steps / validation_split_num 的处理建议 +- **Anima TE 缓存固化 caption_dropout_rate(#333)**:先在文档中写明「改动该值需删除 `_anima_te.npz` 再重训」的限制;上游缓存键的一致性校验待跟进 + +### 修复(近一个月 issue 第一批) +- **Krea2 tokenizer 的 `extra_special_tokens` 为 list 时加载失败(#416)**:探测/下载/启动前会把旧的 list 形态规范化为 transformers 期望的 mapping,手动放置的 tokenizer 同样会被治好 +- **Kohya 加载 Anima 2.9B 前明确拦截(#408)**:只读 safetensors 头部统计 block 数,超过 28 即拒绝并提示改用 Anima Fast,不再等到加载时抛一串 `blocks.28.*` 权重名 +- **DiffSynth 指纹不再含 mtime(#410)**:目录拷贝 / 云镜像 / 备份还原导致的时间戳变化不再误报环境异常;旧状态一次性迁移,不要求重装;内容改动仍能识别 + - 已回移到 `main`(PR #438)。**预装 DiffSynth 的定制镜像需同步 `mikazuki/engines/diffsynth/extension_state.py` 与 `install_worker.py` 后重建镜像**;只改 `install_state.json` 不算修复(时间戳再变仍会复发)——文件到位后,现存实例在下一次状态检查时会自动迁移,无需重装 + +--- +## v3.2.0 — 2026-10-11 ### 整合包更新修复 diff --git a/NOTICE.md b/NOTICE.md index 8a58d67e0..a9200483b 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -60,6 +60,18 @@ Next Trainer ships this engine as an **optional plugin** (`extensions/anima_lora The referenced repository features per-block or full-model `torch.compile`, static-shape token bucketing, and compile-friendly forward paths. On consumer GPUs this yields substantially faster step times than the default Kohya/sd-scripts path at the cost of higher VRAM and a separate Python/CUDA runtime. See **Performance** in `docs/anima-fast.md` for measured comparisons in this repo. +### KohakuMossTrainer(实验性高性能可选引擎) + +The optional **KohakuMossTrainer** engine (`model_train_type: kohaku-moss-image-lora`) integrates, through an isolated Python environment and the upstream `kogine` CLI: + +- `KohakuBlueleaf/KohakuMossTrainer`: https://github.com/KohakuBlueleaf/KohakuMossTrainer +- pinned integration commit: `5bb1a81ed030cc87c540d5e02fe60aab887199b4` +- integration coordination: https://github.com/KohakuBlueleaf/KohakuMossTrainer/issues/1 + +KohakuMossTrainer is distributed under **KohakuMoss License 1.0**, described upstream as Apache License 2.0 with an additional naming requirement. Next Trainer exposes the upstream name prominently in the engine name and UI, installs the pinned source into `extensions/kohaku-moss/`, and does not create a MOSS/Kohya fork. Please retain the upstream license and notices when redistributing an installed runtime. + +We thank **Kohaku-Blueleaf(Kohaku / 龙娘)** for KohakuMossTrainer and the broader LyCORIS ecosystem. The integration directly depends on `lycoris-lora>=4.1.2`. + ### LyCORIS LoKr, LoHa, and other advanced LoRA variants are powered by: diff --git a/README-zh.md b/README-zh.md index c6ed105d8..8f6a4af1d 100644 --- a/README-zh.md +++ b/README-zh.md @@ -1,120 +1,120 @@ -
-
-
- 多模型、多引擎的本地训练工作台
- 从数据集整理到模型训练,在一个界面里完成。
-
- 下载 · - 快速开始 · - 使用文档 · - English -
- - -## MOSS-Image 训练效果展示 - -由 [KohakuBlueleaf](https://github.com/KohakuBlueleaf) 使用其训练器 [KohakuMossTrainer](https://github.com/KohakuBlueleaf/KohakuMossTrainer) 完成的 **100 步风格 LoRA 测试**。上排为基础模型,下排为加载 LoRA 后的效果。经作者同意引用,用于展示 MOSS-Image 的训练效果;本图结果由 KohakuMossTrainer 训练获得。 - -[](assets/readme/kohaku-moss-style-lora.png) - -## 3.3.0 更新了什么 - -- **多引擎工作台**:统一支持 Kohya、Anima Fast、Musubi、AI Toolkit、DiffSynth-Studio 和 MOSS(anima_lora),并补充模型与引擎对应表及训练教程入口。 -- **Kohya 运行环境独立化**:Kohya 使用 `extensions/kohya/` 独立环境;训练器源码更新与引擎环境分离,Kohya 可按需安装、修复和审计。 -- **更新不再丢失 Kohya**:源码更新和整合包更新都会保留用户拥有的训练运行时;整合包更新器排除 `Next-Trainer/extensions/`,不会因更新主程序卸载 Kohya。 -- **MOSS-Image**:新增 MOSS-Image LoRA 训练,默认推荐 Kohya,`anima_lora` 作为次选路径。 -- **AI Toolkit 与 Ideogram 4**:加入 AI Toolkit 训练引擎和 Ideogram 4 LoRA 入口,按需安装,不强制下载可选引擎环境。 -- **插件市场调整**:当前没有可用插件内容,已从用户界面和默认构建中隐藏,也不会强制下载空的 marketplace 依赖。 -- **3.3.1-dev 整合包**:提供小于 2 GB 的 lite 包,包含基础运行环境、前端、WD 打标模型和离线 tokenizer,不预装 Kohya。 - -[完整更新日志](CHANGELOG.md) - -## 开始使用 - -**Windows 用户**:推荐直接下载当前整合包 [Next-Trainer-v3.3.1-dev-lite.7z](https://github.com/wochenlong/lora-scripts-next/releases/download/v3.3.1-dev/Next-Trainer-v3.3.1-dev-lite.7z),解压后使用包内启动脚本。该包包含基础运行环境、前端、WD 打标模型和离线 tokenizer,不预装 Kohya,也不会下载空的插件市场依赖;首次训练时可在 **设置 → 训练引擎** 按需安装引擎。需要 NVIDIA 显卡,详细步骤和包型区别见[快速开始](docs/getting-started.md)。 - -**版本说明**:当前推荐整合包版本为 `3.3.1-dev`。预装 Kohya 的大体积包单独发布,不放在 GitHub Release;插件市场当前没有可用内容,已从用户界面和默认构建中隐藏。 - -想使用最新源码或在 Linux 上运行?请看[从源码运行](docs/getting-started.md#从源码运行)。 - -### 如何更新 - -**源码安装:** - -1. 关闭 WebUI 和正在运行的训练任务。 -2. 在项目目录执行 `git status`,确认自己的修改已提交或已备份。 -3. 稳定版切换到 `main` 后执行 `git pull --ff-only`;只想跟进下一版本时使用 `git fetch origin` 后再切换到 `dev`。 -4. 重新运行 `run_gui.bat`(Windows)或 `bash run_gui.sh`(Linux)。如果依赖发生变化,按启动器提示重新运行 `install-cn.ps1` / `setup_environment.py`,不要删除整个项目目录里的用户数据。 - -源码更新只更新仓库代码;已安装的 Kohya 环境位于 `extensions/kohya/`,不要手动删除该目录。升级后如果页面提示 Kohya 环境损坏,再进入 **设置 → 训练引擎 → Kohya → 修复/安装**,由程序按当前版本重新检查或修复。 - -**整合包安装:** - -- 优先双击包根目录的 `Update-Next-Trainer-Release.bat`,它会下载最新 Release 并合并程序文件;无法访问 Release 时可使用 `Update-Next-Trainer.bat` 走 Git 更新。 -- 更新前必须关闭 WebUI。更新器会保留 `Next-Trainer\extensions\`、模型、输出、日志、训练集和配置;其中 `Next-Trainer\extensions\kohya\` 就是 Kohya 独立环境,不会被更新包覆盖。 -- 更新完成后重新双击 `run_gui.bat`。如果启动器提示依赖变化,再运行包内 `update\update_dependencies.bat`;不要先删除 `python_embeded` 或 `extensions\kohya`。 - -**没有更新脚本的旧整合包:**不要把新版 7z 直接解压到旧目录并选择覆盖。先关闭程序,将旧包中的 `Next-Trainer\extensions\kohya\` 整个目录复制到安全位置,再下载新版并解压到新目录,最后把该目录复制回新版的 `Next-Trainer\extensions\kohya\`;同时迁移 `sd-models`、`output`、`logs`、`train`、`config`、`huggingface` 和 `tagger-models`。复制完成后从新版根目录启动。这个步骤把“程序代码更新”和“Kohya 环境”分开,避免旧版覆盖方式再次丢失引擎。 - -lite 包本身不预装 Kohya;首次使用时请在 **设置 → 训练引擎** 安装。安装完成后,后续更新只要使用上面的更新器并保留 `Next-Trainer\extensions\kohya\`,就不会因为更新主程序而卸载 Kohya。详细的整合包更新契约见[整合包更新说明](docs/portable-packaging-git-update.md)。 - -## 支持的训练引擎 - - - -**Kohya · Anima Fast · Musubi · AI Toolkit · DiffSynth-Studio · MOSS (anima_lora)** - -引擎可在 **设置 → 训练引擎** 中按需安装,再到训练页选择对应引擎。从 3.1.1 或更早版本升级后,首次使用 Kohya 训练前需先安装 Kohya 引擎。可用引擎以所用训练器版本为准;接入引擎不代表已经支持其上游的全部模型和功能。 - -训练 Qwen-Image-2.1 时,选择 **DiffSynth-Studio → LoRA**,再切换 **文生图 T2I** 或 **Edit 图像编辑**。Edit 当前要求 Batch 1,可通过梯度累积增加有效批量。 - -训练 MOSS-Image LoRA 时,推荐使用且默认选择 **Kohya**;**MOSS (anima_lora)** 作为次选引擎保留。 - -## 支持的模型 - - - -**MOSS-Image · Qwen-Image-2.1 · Anima · SD 1.5 · SDXL · Flux · FLUX.2 Klein · Krea 2 · Ideogram 4** - -不同模型支持的训练目标、硬件要求和引擎安装方式有所区别,详见下方训练教程。 - -### 模型与训练引擎对应表 - -✅ 表示已集成的 LoRA 训练入口;— 表示暂无对应入口。此表以当前分支的训练模块为准,不代表上游引擎的全部能力;具体模型版本和硬件要求仍以对应引擎教程为准。 - -| 模型 | Kohya | Anima Fast | Musubi | AI Toolkit | DiffSynth-Studio | MOSS (anima_lora) | -| --- | :---: | :---: | :---: | :---: | :---: | :---: | -| MOSS-Image | ✅ | — | — | — | — | ✅ | -| Qwen-Image-2.1 | — | — | — | ✅ | ✅ | — | -| Krea 2 | — | — | ✅ | ✅ | — | — | -| Anima | ✅ | ✅ | — | ✅ | — | — | -| FLUX.2 Klein | — | — | — | ✅ | — | — | -| Ideogram 4 | — | — | ✅ | ✅ | — | — | -| Flux | ✅ | — | — | ✅ | — | — | -| SDXL | ✅ | — | — | ✅ | — | — | -| SD 1.5 | ✅ | — | — | ✅ | — | — | - -Kohya 还提供 Anima、SDXL、SD 1.5 的全量训练入口。MOSS-Image 默认使用 Kohya,`MOSS (anima_lora)` 为备选。Lumina 保留 Kohya LoRA 入口,可通过 `?model=lumina` 访问,但不在常规模型选择列表中展示。 - -上方配图均为概念示意,其中画面不代表各标注模型的实际生成效果或评测结果。 - -## 训练教程 - -- [MOSS-Image](docs/MOSS.md) -- [Qwen-Image-2.1](docs/diffsynth.md) -- [Anima](docs/anima-training.md) -- [Anima Fast](docs/anima-fast.md) -- [Krea 2 (Linux / 多卡)](docs/krea2-linux-multigpu.md) -- [Ideogram 4 (Musubi)](docs/ideogram4-musubi.md) -- [TOML / CLI](docs/cli-args.md) - -[界面导览](docs/interface-tour.md) · [打标模型准备](docs/tagger-models.md) · [训练监控](docs/train-monitor.md) · [全部文档](docs/README.md) - - ---- - -[使用文档](docs/README.md) · [问题反馈](https://github.com/wochenlong/lora-scripts-next/issues) · [开源致谢](docs/credits.md) · [贡献者](CONTRIBUTORS.md) +
+
+
+ 多模型、多引擎的本地训练工作台
+ 从数据集整理到模型训练,在一个界面里完成。
+
+ 下载 · + 快速开始 · + 使用文档 · + English +
+ + +## MOSS-Image 训练效果展示 + +由 [KohakuBlueleaf](https://github.com/KohakuBlueleaf) 使用其训练器 [KohakuMossTrainer](https://github.com/KohakuBlueleaf/KohakuMossTrainer) 完成的 **100 步风格 LoRA 测试**。上排为基础模型,下排为加载 LoRA 后的效果。经作者同意引用,用于展示 MOSS-Image 的训练效果;本图结果由 KohakuMossTrainer 训练获得(当前源码已将其接入为可选训练引擎)。 + +[](assets/readme/kohaku-moss-style-lora.png) + +## 3.3.0 更新了什么 + +- **多引擎工作台**:统一支持 Kohya、Anima Fast、Musubi、AI Toolkit、DiffSynth-Studio 和 MOSS(anima_lora),并补充模型与引擎对应表及训练教程入口。 +- **Kohya 运行环境独立化**:Kohya 使用 `extensions/kohya/` 独立环境;训练器源码更新与引擎环境分离,Kohya 可按需安装、修复和审计。 +- **更新不再丢失 Kohya**:源码更新和整合包更新都会保留用户拥有的训练运行时;整合包更新器排除 `Next-Trainer/extensions/`,不会因更新主程序卸载 Kohya。 +- **MOSS-Image**:默认仍推荐 Kohya;当前源码同时接入可选 [KohakuMossTrainer](https://github.com/KohakuBlueleaf/KohakuMossTrainer) 和 `anima_lora` 路径,整合包是否包含该入口以具体版本为准。 +- **AI Toolkit 与 Ideogram 4**:加入 AI Toolkit 训练引擎和 Ideogram 4 LoRA 入口,按需安装,不强制下载可选引擎环境。 +- **插件市场调整**:当前没有可用插件内容,已从用户界面和默认构建中隐藏,也不会强制下载空的 marketplace 依赖。 +- **3.3.1-dev 整合包**:提供小于 2 GB 的 lite 包,包含基础运行环境、前端、WD 打标模型和离线 tokenizer,不预装 Kohya。 + +[完整更新日志](CHANGELOG.md) + +## 开始使用 + +**Windows 用户**:推荐直接下载当前整合包 [Next-Trainer-v3.3.1-dev-lite.7z](https://github.com/wochenlong/lora-scripts-next/releases/download/v3.3.1-dev/Next-Trainer-v3.3.1-dev-lite.7z),解压后使用包内启动脚本。该包包含基础运行环境、前端、WD 打标模型和离线 tokenizer,不预装 Kohya,也不会下载空的插件市场依赖;首次训练时可在 **设置 → 训练引擎** 按需安装引擎。需要 NVIDIA 显卡,详细步骤和包型区别见[快速开始](docs/getting-started.md)。 + +**版本说明**:当前推荐整合包版本为 `3.3.1-dev`。预装 Kohya 的大体积包单独发布,不放在 GitHub Release;插件市场当前没有可用内容,已从用户界面和默认构建中隐藏。 + +想使用最新源码或在 Linux 上运行?请看[从源码运行](docs/getting-started.md#从源码运行)。 + +### 如何更新 + +**源码安装:** + +1. 关闭 WebUI 和正在运行的训练任务。 +2. 在项目目录执行 `git status`,确认自己的修改已提交或已备份。 +3. 稳定版切换到 `main` 后执行 `git pull --ff-only`;只想跟进下一版本时使用 `git fetch origin` 后再切换到 `dev`。 +4. 重新运行 `run_gui.bat`(Windows)或 `bash run_gui.sh`(Linux)。如果依赖发生变化,按启动器提示重新运行 `install-cn.ps1` / `setup_environment.py`,不要删除整个项目目录里的用户数据。 + +源码更新只更新仓库代码;已安装的 Kohya 环境位于 `extensions/kohya/`,不要手动删除该目录。升级后如果页面提示 Kohya 环境损坏,再进入 **设置 → 训练引擎 → Kohya → 修复/安装**,由程序按当前版本重新检查或修复。 + +**整合包安装:** + +- 优先双击包根目录的 `Update-Next-Trainer-Release.bat`,它会下载最新 Release 并合并程序文件;无法访问 Release 时可使用 `Update-Next-Trainer.bat` 走 Git 更新。 +- 更新前必须关闭 WebUI。更新器会保留 `Next-Trainer\extensions\`、模型、输出、日志、训练集和配置;其中 `Next-Trainer\extensions\kohya\` 就是 Kohya 独立环境,不会被更新包覆盖。 +- 更新完成后重新双击 `run_gui.bat`。如果启动器提示依赖变化,再运行包内 `update\update_dependencies.bat`;不要先删除 `python_embeded` 或 `extensions\kohya`。 + +**没有更新脚本的旧整合包:**不要把新版 7z 直接解压到旧目录并选择覆盖。先关闭程序,将旧包中的 `Next-Trainer\extensions\kohya\` 整个目录复制到安全位置,再下载新版并解压到新目录,最后把该目录复制回新版的 `Next-Trainer\extensions\kohya\`;同时迁移 `sd-models`、`output`、`logs`、`train`、`config`、`huggingface` 和 `tagger-models`。复制完成后从新版根目录启动。这个步骤把“程序代码更新”和“Kohya 环境”分开,避免旧版覆盖方式再次丢失引擎。 + +lite 包本身不预装 Kohya;首次使用时请在 **设置 → 训练引擎** 安装。安装完成后,后续更新只要使用上面的更新器并保留 `Next-Trainer\extensions\kohya\`,就不会因为更新主程序而卸载 Kohya。详细的整合包更新契约见[整合包更新说明](docs/portable-packaging-git-update.md)。 + +## 支持的训练引擎 + + + +**Kohya · Anima Fast · Musubi · AI Toolkit · DiffSynth-Studio · KohakuMossTrainer · MOSS (anima_lora)** + +引擎可在 **设置 → 训练引擎** 中按需安装,再到训练页选择对应引擎。从 3.1.1 或更早版本升级后,首次使用 Kohya 训练前需先安装 Kohya 引擎。可用引擎以所用训练器版本为准;接入引擎不代表已经支持其上游的全部模型和功能。 + +训练 Qwen-Image-2.1 时,选择 **DiffSynth-Studio → LoRA**,再切换 **文生图 T2I** 或 **Edit 图像编辑**。Edit 当前要求 Batch 1,可通过梯度累积增加有效批量。 + +训练 MOSS-Image LoRA 时,推荐使用且默认选择 **Kohya**;也可按需安装并切换 **KohakuMossTrainer**(Kohaku / 龙娘开发的高性能 LyCORIS 训练引擎)或 **MOSS (anima_lora)**。 + +## 支持的模型 + + + +**MOSS-Image · Qwen-Image-2.1 · Anima · SD 1.5 · SDXL · Flux · FLUX.2 Klein · Krea 2 · Ideogram 4** + +不同模型支持的训练目标、硬件要求和引擎安装方式有所区别,详见下方训练教程。 + +### 模型与训练引擎对应表 + +✅ 表示已集成的 LoRA 训练入口;— 表示暂无对应入口。此表以当前分支的训练模块为准,不代表上游引擎的全部能力;具体模型版本和硬件要求仍以对应引擎教程为准。 + +| 模型 | Kohya | Anima Fast | Musubi | AI Toolkit | DiffSynth-Studio | KohakuMossTrainer | MOSS (anima_lora) | +| --- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | +| MOSS-Image | ✅ | — | — | — | — | ✅ | ✅ | +| Qwen-Image-2.1 | — | — | — | ✅ | ✅ | — | — | +| Krea 2 | — | — | ✅ | ✅ | — | — | — | +| Anima | ✅ | ✅ | — | ✅ | — | — | — | +| FLUX.2 Klein | — | — | — | ✅ | — | — | — | +| Ideogram 4 | — | — | ✅ | ✅ | — | — | — | +| Flux | ✅ | — | — | ✅ | — | — | — | +| SDXL | ✅ | — | — | ✅ | — | — | — | +| SD 1.5 | ✅ | — | — | ✅ | — | — | — | + +Kohya 还提供 Anima、SDXL、SD 1.5 的全量训练入口。MOSS-Image 默认使用 Kohya,并提供 `KohakuMossTrainer` 与 `MOSS (anima_lora)` 可选引擎。Lumina 保留 Kohya LoRA 入口,可通过 `?model=lumina` 访问,但不在常规模型选择列表中展示。 + +上方配图均为概念示意,其中画面不代表各标注模型的实际生成效果或评测结果。 + +## 训练教程 + +- [MOSS-Image](docs/MOSS.md) +- [Qwen-Image-2.1](docs/diffsynth.md) +- [Anima](docs/anima-training.md) +- [Anima Fast](docs/anima-fast.md) +- [Krea 2 (Linux / 多卡)](docs/krea2-linux-multigpu.md) +- [Ideogram 4 (Musubi)](docs/ideogram4-musubi.md) +- [TOML / CLI](docs/cli-args.md) + +[界面导览](docs/interface-tour.md) · [打标模型准备](docs/tagger-models.md) · [训练监控](docs/train-monitor.md) · [全部文档](docs/README.md) + + +--- + +[使用文档](docs/README.md) · [问题反馈](https://github.com/wochenlong/lora-scripts-next/issues) · [开源致谢](docs/credits.md) · [贡献者](CONTRIBUTORS.md) diff --git a/README.md b/README.md index c790f4fb8..fbb14c122 100644 --- a/README.md +++ b/README.md @@ -1,120 +1,120 @@ -
-
-
- A local training workbench for multiple models and engines
- Prepare datasets, train models, and follow your runs in one place.
-
- Download · - Quick start · - Documentation · - 中文 -
- - -## MOSS-Image training showcase - -A **100-step style LoRA test** by [KohakuBlueleaf](https://github.com/KohakuBlueleaf), trained with their [KohakuMossTrainer](https://github.com/KohakuBlueleaf/KohakuMossTrainer). The top row shows the base model; the bottom row shows the LoRA results. Shared with the author's permission as a MOSS-Image training example; these results were produced with KohakuMossTrainer. - -[](assets/readme/kohaku-moss-style-lora.png) - -## What's new in 3.3.0 - -- **Multi-engine workbench:** Kohya, Anima Fast, Musubi, AI Toolkit, DiffSynth-Studio, and MOSS (`anima_lora`) are presented through one engine workflow, with an updated model/engine matrix and tutorial index. -- **Independent Kohya runtime:** Kohya uses its own environment under `extensions/kohya/`; trainer source updates are separated from engine installation, repair, and auditing. -- **Kohya survives updates:** source and portable-package updates preserve user-owned training runtimes; the portable updater excludes `Next-Trainer/extensions/` so updating the main program does not uninstall Kohya. -- **MOSS-Image:** MOSS-Image LoRA training is available with Kohya as the recommended/default engine and `anima_lora` as an optional secondary path. -- **AI Toolkit and Ideogram 4:** AI Toolkit training and an Ideogram 4 LoRA entry are available as optional engines and are not force-installed. -- **Plugin marketplace:** the currently empty marketplace is hidden from users and skipped by default, so its unused dependencies are not downloaded. -- **3.3.1-dev portable package:** a sub-2 GB lite package includes the base runtime, frontend, WD tagger model, and offline tokenizer assets without preinstalling Kohya. - -[Full changelog](CHANGELOG.md) - -## Get started - -**Windows users:** download the current [Next-Trainer-v3.3.1-dev-lite.7z](https://github.com/wochenlong/lora-scripts-next/releases/download/v3.3.1-dev/Next-Trainer-v3.3.1-dev-lite.7z), extract it, and use the included launcher. It contains the base runtime, frontend, WD tagger model, and offline tokenizer assets. Kohya is not preinstalled, and the empty plugin marketplace is not downloaded; install a training engine from **Settings → Training engines** when needed. An NVIDIA GPU is required; see [setup and package selection](docs/getting-started.en.md). - -**Release status:** the recommended portable package is `3.3.1-dev`. The larger preinstalled-Kohya package is distributed separately from GitHub Releases; the empty plugin marketplace is hidden from users and skipped by default during builds. - -For the latest source version or Linux setup, follow [run from source](docs/getting-started.en.md#from-source). - -### Updating - -**Source installation:** - -1. Close the WebUI and stop active training jobs. -2. Run `git status` in the project directory and commit or back up any local changes. -3. For the stable version, switch to `main` and run `git pull --ff-only`. To follow the next development version, run `git fetch origin` and then switch to `dev`. -4. Start again with `run_gui.bat` on Windows or `bash run_gui.sh` on Linux. If the launcher reports changed dependencies, rerun `install-cn.ps1` / `setup_environment.py` as instructed; do not delete the project directory's user data. - -Source updates change repository code only. The installed Kohya environment lives under `extensions/kohya/`; do not delete it manually. If the UI reports a broken Kohya environment after an upgrade, use **Settings → Training engines → Kohya → Repair/Install** so the current version can audit or repair it. - -**Portable package:** - -- Prefer `Update-Next-Trainer-Release.bat` from the package root. It downloads the latest Release and merges the program files. If GitHub Release downloads are unavailable, use `Update-Next-Trainer.bat` for a Git update. -- Close the WebUI before updating. The updater preserves `Next-Trainer\extensions\`, models, outputs, logs, training data, and configuration. `Next-Trainer\extensions\kohya\` is the independent Kohya environment and is excluded from the update merge. -- Start again with `run_gui.bat`. If the launcher reports changed dependencies, run the included `update\update_dependencies.bat`; do not delete `python_embeded` or `extensions\kohya` first. - -**Old portable packages without an updater:** do not extract a new 7z directly over the old directory. Close the application, copy the old `Next-Trainer\extensions\kohya\` directory to a safe location, extract the new package into a new directory, then restore that directory to `Next-Trainer\extensions\kohya\`. Also migrate `sd-models`, `output`, `logs`, `train`, `config`, `huggingface`, and `tagger-models`. Launch from the new package. This keeps the program update separate from the Kohya environment and avoids losing the engine through an old overwrite workflow. - -The lite package does not include Kohya. Install it from **Settings → Training engines** when needed. After installation, use the updater above and keep `Next-Trainer\extensions\kohya\`; updating the main program will not uninstall Kohya. See the [portable update contract](docs/portable-packaging-git-update.md) for the detailed rules. - -## Supported training engines - - - -**Kohya · Anima Fast · Musubi · AI Toolkit · DiffSynth-Studio · MOSS (anima_lora)** - -Install engines from **Settings → Training engines**, then select the appropriate engine on the training page. After upgrading from 3.1.1 or older, install Kohya once before running Kohya training. Available engines depend on your trainer version; not every model or feature supported upstream is integrated here. - -For Qwen-Image-2.1, select **DiffSynth-Studio → LoRA**, then choose **Text-to-image** or **Edit**. Edit currently requires batch size 1 and can use gradient accumulation for a larger effective batch. - -For MOSS-Image LoRA, use **Kohya** (recommended and selected by default). **MOSS (anima_lora)** remains available as a secondary engine. - -## Supported models - - - -**MOSS-Image · Qwen-Image-2.1 · Anima · SD 1.5 · SDXL · Flux · FLUX.2 Klein · Krea 2 · Ideogram 4** - -Training targets, hardware requirements, and optional engine installation vary by model. See the training tutorials below. - -### Model / engine compatibility - -✅ = an integrated LoRA entry; — = no integrated entry. This table follows this branch's training modules, not the full capabilities of upstream engines. Model variants and hardware requirements still depend on the selected engine. - -| Model | Kohya | Anima Fast | Musubi | AI Toolkit | DiffSynth-Studio | MOSS (anima_lora) | -| --- | :---: | :---: | :---: | :---: | :---: | :---: | -| MOSS-Image | ✅ | — | — | — | — | ✅ | -| Qwen-Image-2.1 | — | — | — | ✅ | ✅ | — | -| Krea 2 | — | — | ✅ | ✅ | — | — | -| Anima | ✅ | ✅ | — | ✅ | — | — | -| FLUX.2 Klein | — | — | — | ✅ | — | — | -| Ideogram 4 | — | — | ✅ | ✅ | — | — | -| Flux | ✅ | — | — | ✅ | — | — | -| SDXL | ✅ | — | — | ✅ | — | — | -| SD 1.5 | ✅ | — | — | ✅ | — | — | - -Kohya also provides full fine-tuning entries for Anima, SDXL, and SD 1.5. MOSS-Image defaults to Kohya; `MOSS (anima_lora)` is an alternative. Lumina has a Kohya LoRA entry accessible via `?model=lumina`, but is hidden from the normal model picker. - -The illustrations above are conceptual; their artwork is not a benchmark or a sample generated by each labelled model. - -## Training tutorials - -- [MOSS-Image](docs/MOSS.md) -- [Qwen-Image-2.1](docs/diffsynth.md) -- [Anima](docs/anima-training.md) -- [Anima Fast](docs/anima-fast.md) -- [Krea 2 (Linux / multi-GPU)](docs/krea2-linux-multigpu.md) -- [Ideogram 4 (Musubi)](docs/ideogram4-musubi.md) -- [TOML / CLI](docs/cli-args.md) - -[Interface tour](docs/interface-tour.md) · [Tagger model setup](docs/tagger-models.md) · [Training monitor](docs/train-monitor.md) · [All documentation](docs/README.md) - - ---- - -[Documentation](docs/README.md) · [Report an issue](https://github.com/wochenlong/lora-scripts-next/issues) · [Credits](docs/credits.md) · [Contributors](CONTRIBUTORS.md) +
+
+
+ A local training workbench for multiple models and engines
+ Prepare datasets, train models, and follow your runs in one place.
+
+ Download · + Quick start · + Documentation · + 中文 +
+ + +## MOSS-Image training showcase + +A **100-step style LoRA test** by [KohakuBlueleaf](https://github.com/KohakuBlueleaf), trained with their [KohakuMossTrainer](https://github.com/KohakuBlueleaf/KohakuMossTrainer). The top row shows the base model; the bottom row shows the LoRA results. Shared with the author's permission as a MOSS-Image training example; these results were produced with KohakuMossTrainer (also available as an optional engine in the current source version). + +[](assets/readme/kohaku-moss-style-lora.png) + +## What's new in 3.3.0 + +- **Multi-engine workbench:** Kohya, Anima Fast, Musubi, AI Toolkit, DiffSynth-Studio, and MOSS (`anima_lora`) are presented through one engine workflow, with an updated model/engine matrix and tutorial index. +- **Independent Kohya runtime:** Kohya uses its own environment under `extensions/kohya/`; trainer source updates are separated from engine installation, repair, and auditing. +- **Kohya survives updates:** source and portable-package updates preserve user-owned training runtimes; the portable updater excludes `Next-Trainer/extensions/` so updating the main program does not uninstall Kohya. +- **MOSS-Image:** Kohya remains the recommended/default engine. The current source also integrates optional [KohakuMossTrainer](https://github.com/KohakuBlueleaf/KohakuMossTrainer) and `anima_lora` paths; availability in portable packages depends on the package version. +- **AI Toolkit and Ideogram 4:** AI Toolkit training and an Ideogram 4 LoRA entry are available as optional engines and are not force-installed. +- **Plugin marketplace:** the currently empty marketplace is hidden from users and skipped by default, so its unused dependencies are not downloaded. +- **3.3.1-dev portable package:** a sub-2 GB lite package includes the base runtime, frontend, WD tagger model, and offline tokenizer assets without preinstalling Kohya. + +[Full changelog](CHANGELOG.md) + +## Get started + +**Windows users:** download the current [Next-Trainer-v3.3.1-dev-lite.7z](https://github.com/wochenlong/lora-scripts-next/releases/download/v3.3.1-dev/Next-Trainer-v3.3.1-dev-lite.7z), extract it, and use the included launcher. It contains the base runtime, frontend, WD tagger model, and offline tokenizer assets. Kohya is not preinstalled, and the empty plugin marketplace is not downloaded; install a training engine from **Settings → Training engines** when needed. An NVIDIA GPU is required; see [setup and package selection](docs/getting-started.en.md). + +**Release status:** the recommended portable package is `3.3.1-dev`. The larger preinstalled-Kohya package is distributed separately from GitHub Releases; the empty plugin marketplace is hidden from users and skipped by default during builds. + +For the latest source version or Linux setup, follow [run from source](docs/getting-started.en.md#from-source). + +### Updating + +**Source installation:** + +1. Close the WebUI and stop active training jobs. +2. Run `git status` in the project directory and commit or back up any local changes. +3. For the stable version, switch to `main` and run `git pull --ff-only`. To follow the next development version, run `git fetch origin` and then switch to `dev`. +4. Start again with `run_gui.bat` on Windows or `bash run_gui.sh` on Linux. If the launcher reports changed dependencies, rerun `install-cn.ps1` / `setup_environment.py` as instructed; do not delete the project directory's user data. + +Source updates change repository code only. The installed Kohya environment lives under `extensions/kohya/`; do not delete it manually. If the UI reports a broken Kohya environment after an upgrade, use **Settings → Training engines → Kohya → Repair/Install** so the current version can audit or repair it. + +**Portable package:** + +- Prefer `Update-Next-Trainer-Release.bat` from the package root. It downloads the latest Release and merges the program files. If GitHub Release downloads are unavailable, use `Update-Next-Trainer.bat` for a Git update. +- Close the WebUI before updating. The updater preserves `Next-Trainer\extensions\`, models, outputs, logs, training data, and configuration. `Next-Trainer\extensions\kohya\` is the independent Kohya environment and is excluded from the update merge. +- Start again with `run_gui.bat`. If the launcher reports changed dependencies, run the included `update\update_dependencies.bat`; do not delete `python_embeded` or `extensions\kohya` first. + +**Old portable packages without an updater:** do not extract a new 7z directly over the old directory. Close the application, copy the old `Next-Trainer\extensions\kohya\` directory to a safe location, extract the new package into a new directory, then restore that directory to `Next-Trainer\extensions\kohya\`. Also migrate `sd-models`, `output`, `logs`, `train`, `config`, `huggingface`, and `tagger-models`. Launch from the new package. This keeps the program update separate from the Kohya environment and avoids losing the engine through an old overwrite workflow. + +The lite package does not include Kohya. Install it from **Settings → Training engines** when needed. After installation, use the updater above and keep `Next-Trainer\extensions\kohya\`; updating the main program will not uninstall Kohya. See the [portable update contract](docs/portable-packaging-git-update.md) for the detailed rules. + +## Supported training engines + + + +**Kohya · Anima Fast · Musubi · AI Toolkit · DiffSynth-Studio · KohakuMossTrainer · MOSS (anima_lora)** + +Install engines from **Settings → Training engines**, then select the appropriate engine on the training page. After upgrading from 3.1.1 or older, install Kohya once before running Kohya training. Available engines depend on your trainer version; not every model or feature supported upstream is integrated here. + +For Qwen-Image-2.1, select **DiffSynth-Studio → LoRA**, then choose **Text-to-image** or **Edit**. Edit currently requires batch size 1 and can use gradient accumulation for a larger effective batch. + +For MOSS-Image LoRA, use **Kohya** (recommended and selected by default); **KohakuMossTrainer** (high-performance LyCORIS trainer by KohakuBlueleaf) and **MOSS (anima_lora)** are also available as optional engines. + +## Supported models + + + +**MOSS-Image · Qwen-Image-2.1 · Anima · SD 1.5 · SDXL · Flux · FLUX.2 Klein · Krea 2 · Ideogram 4** + +Training targets, hardware requirements, and optional engine installation vary by model. See the training tutorials below. + +### Model / engine compatibility + +✅ = an integrated LoRA entry; — = no integrated entry. This table follows this branch's training modules, not the full capabilities of upstream engines. Model variants and hardware requirements still depend on the selected engine. + +| Model | Kohya | Anima Fast | Musubi | AI Toolkit | DiffSynth-Studio | KohakuMossTrainer | MOSS (anima_lora) | +| --- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | +| MOSS-Image | ✅ | — | — | — | — | ✅ | ✅ | +| Qwen-Image-2.1 | — | — | — | ✅ | ✅ | — | — | +| Krea 2 | — | — | ✅ | ✅ | — | — | — | +| Anima | ✅ | ✅ | — | ✅ | — | — | — | +| FLUX.2 Klein | — | — | — | ✅ | — | — | — | +| Ideogram 4 | — | — | ✅ | ✅ | — | — | — | +| Flux | ✅ | — | — | ✅ | — | — | — | +| SDXL | ✅ | — | — | ✅ | — | — | — | +| SD 1.5 | ✅ | — | — | ✅ | — | — | — | + +Kohya also provides full fine-tuning entries for Anima, SDXL, and SD 1.5. MOSS-Image defaults to Kohya, with `KohakuMossTrainer` and `MOSS (anima_lora)` as optional engines. Lumina has a Kohya LoRA entry accessible via `?model=lumina`, but is hidden from the normal model picker. + +The illustrations above are conceptual; their artwork is not a benchmark or a sample generated by each labelled model. + +## Training tutorials + +- [MOSS-Image](docs/MOSS.md) +- [Qwen-Image-2.1](docs/diffsynth.md) +- [Anima](docs/anima-training.md) +- [Anima Fast](docs/anima-fast.md) +- [Krea 2 (Linux / multi-GPU)](docs/krea2-linux-multigpu.md) +- [Ideogram 4 (Musubi)](docs/ideogram4-musubi.md) +- [TOML / CLI](docs/cli-args.md) + +[Interface tour](docs/interface-tour.md) · [Tagger model setup](docs/tagger-models.md) · [Training monitor](docs/train-monitor.md) · [All documentation](docs/README.md) + + +--- + +[Documentation](docs/README.md) · [Report an issue](https://github.com/wochenlong/lora-scripts-next/issues) · [Credits](docs/credits.md) · [Contributors](CONTRIBUTORS.md) diff --git a/build-scripts/06-build-launcher.ps1 b/build-scripts/06-build-launcher.ps1 new file mode 100644 index 000000000..95ba05673 --- /dev/null +++ b/build-scripts/06-build-launcher.ps1 @@ -0,0 +1,28 @@ +#Requires -Version 5.1 +<# +.SYNOPSIS + Compile the NextTrainer.exe launcher (NativeAOT) and place it at the portable + package root, next to the existing .bat fallbacks (#435). +#> +param( + [Parameter(Mandatory = $true)][string]$PackageRoot +) + +$ErrorActionPreference = "Stop" +$repoRoot = Split-Path $PSScriptRoot -Parent +$project = Join-Path $repoRoot "launcher" +$outDir = Join-Path $env:TEMP "nexttrainer-launcher" + +$dotnet = Get-Command dotnet -ErrorAction SilentlyContinue +if (-not $dotnet) { + Write-Warning "dotnet SDK 未安装,跳过启动器编译(包内仍保留 .bat 入口)。请安装 .NET 9 SDK 后重跑。" + return +} + +& dotnet publish $project -c Release -r win-x64 -p:PublishAot=true -o $outDir +if ($LASTEXITCODE -ne 0) { throw "dotnet publish launcher failed (exit $LASTEXITCODE)" } + +$exe = Join-Path $outDir "NextTrainer.exe" +if (-not (Test-Path $exe)) { throw "launcher exe missing after publish: $exe" } +Copy-Item -LiteralPath $exe -Destination (Join-Path $PackageRoot "NextTrainer.exe") -Force +Write-Host " launcher -> $(Join-Path $PackageRoot 'NextTrainer.exe')" diff --git a/build-scripts/build_portable_2026_full.ps1 b/build-scripts/build_portable_2026_full.ps1 index c1ae7bda3..e23682b95 100644 --- a/build-scripts/build_portable_2026_full.ps1 +++ b/build-scripts/build_portable_2026_full.ps1 @@ -134,6 +134,10 @@ if (-not $SkipMusubi) { Write-Log "[4/5] Applying 2026 root (启动 / 检查更新 / 说明)..." "Cyan" & $applyRoot -PortableRoot $portableDir +# ---- Step 4b: launcher exe (thin shell over 启动.bat, #435) ---- +Write-Log "[4b/5] Building NextTrainer.exe launcher..." "Cyan" +& (Join-Path $PSScriptRoot "06-build-launcher.ps1") -PackageRoot $portableDir + # ---- Step 5: 7z ---- $7zExe = "C:\Program Files\7-Zip\7z.exe" if (-not (Test-Path $7zExe)) { diff --git a/build-scripts/build_portable_kohya_only.ps1 b/build-scripts/build_portable_kohya_only.ps1 index 0e8ef7e40..62c93bf3f 100644 --- a/build-scripts/build_portable_kohya_only.ps1 +++ b/build-scripts/build_portable_kohya_only.ps1 @@ -82,4 +82,7 @@ if (Test-Path $note) { "@ } +# ---- launcher exe (thin shell over the .bat entries, #435) ---- +& (Join-Path $PSScriptRoot "06-build-launcher.ps1") -PackageRoot $portableDir + Write-Host "DONE kohya-only v$Version" -ForegroundColor Green diff --git a/build-scripts/build_portable_musubi_only.ps1 b/build-scripts/build_portable_musubi_only.ps1 index f3660c65b..829304ed5 100644 --- a/build-scripts/build_portable_musubi_only.ps1 +++ b/build-scripts/build_portable_musubi_only.ps1 @@ -126,6 +126,9 @@ $applyRoot = Join-Path $PSScriptRoot "apply_portable_2026_root.ps1" if (Test-Path $applyRoot) { Write-Log "Applying 2026 root..." "Cyan" & $applyRoot -PortableRoot $portableDir + +# ---- launcher exe (thin shell over the .bat entries, #435) ---- +& (Join-Path $PSScriptRoot "06-build-launcher.ps1") -PackageRoot $portableDir } $note = Join-Path $portableDir "说明.txt" diff --git a/build-scripts/resume_portable_2026_full.ps1 b/build-scripts/resume_portable_2026_full.ps1 index beaa04ee8..23b9b7fed 100644 --- a/build-scripts/resume_portable_2026_full.ps1 +++ b/build-scripts/resume_portable_2026_full.ps1 @@ -63,6 +63,9 @@ if (-not $SkipMusubi) { Write-Log "[2/3] Applying 2026 root..." "Cyan" & $applyRoot -PortableRoot $portableDir +# ---- launcher exe (thin shell over the .bat entries, #435) ---- +& (Join-Path $PSScriptRoot "06-build-launcher.ps1") -PackageRoot $portableDir + $archiveName = "Next-Trainer-v${Version}-kohya-musubi.7z" $archivePath = Join-Path $buildDir $archiveName $7zExe = "C:\Program Files\7-Zip\7z.exe" diff --git a/docs/MOSS.md b/docs/MOSS.md index 488843a23..5d6b37b9d 100644 --- a/docs/MOSS.md +++ b/docs/MOSS.md @@ -2,16 +2,31 @@ ## 1. 是什么 -Next Trainer 提供两条 **MOSS-Image LoRA** 路径: +Next Trainer 提供三条 **MOSS-Image LoRA** 路径: - **Kohya(推荐、默认)**:使用内置 `sd-scripts` 的原生 MOSS trainer,功能和维护路径更稳定。 +- **KohakuMossTrainer(可选实验性高性能引擎)**:集成 [KohakuBlueleaf/KohakuMossTrainer](https://github.com/KohakuBlueleaf/KohakuMossTrainer),支持原生 LyCORIS(LoKr / LoRA 等)、显存计划档位与 Comfy / LyCORIS 双格式导出。 - **MOSS (anima_lora)**:保留为独立运行时的备选方案(流程:预缓存文本/VAE → 训 DiT LoRA)。 -MOSS-Image 是独立模型家族,不能套用 Anima / AI Toolkit 的模型、缓存或配置;两种 MOSS 引擎的配置和缓存也不能混用。 -- 运行环境在 `extensions/moss/`(钉住上游 [`sorryhyun/anima_lora` @ `moss_lora`](https://github.com/sorryhyun/anima_lora/tree/moss_lora)),与 Anima Fast 分离。 +MOSS-Image 是独立模型家族,不能套用 Anima / AI Toolkit 的模型、缓存或配置;各 MOSS 引擎的配置和缓存也不能混用。 +- `MOSS (anima_lora)` 运行环境在 `extensions/moss/`(钉住上游 [`sorryhyun/anima_lora` @ `moss_lora`](https://github.com/sorryhyun/anima_lora/tree/moss_lora)),与 Anima Fast 分离。 - 上游为 alpha:不保证每张卡的显存上限或成片质量;ComfyUI 侧 LoRA 回载验收可后续补丁。 -训练页默认选择:**模型 = MOSS-Image;引擎 = Kohya;目标 = LoRA**。需要原有流程时可手动切换到 **MOSS (anima_lora)**。 +训练页默认选择:**模型 = MOSS-Image;引擎 = Kohya;目标 = LoRA**。需要其它流程时可手动切换到 **KohakuMossTrainer** 或 **MOSS (anima_lora)**。 + +### KohakuMossTrainer(可选实验性引擎) + +在 MOSS-Image 训练页手动选择 **KohakuMossTrainer**。默认仍是 Kohya;已有 MOSS (anima_lora) 路径不变。此引擎复用 Next Trainer 的训练引擎安装门页、下载源设置、任务日志与状态管理,独立安装到 `extensions/kohaku-moss/`,不另建训练核心或修改其它引擎环境。 + +- Windows 和 Linux 使用独立 Python 3.12 / venv,显式安装 `lycoris-lora>=4.1.2` 并锁定 `kohakuvault<1.0`;安装不会下载模型。 +- 安装、修复和卸载均从「设置 → 训练引擎」操作;有运行或排队任务时禁止修改该引擎环境。 +- 原生调用为 `kogine run scripts/train/moss.py --config <生成的配置>`,参数由训练表单映射到上游配置。 +- 停止条件是 `max_train_steps`,`max_train_epochs` 只作备注。支持导出 `comfy`、`lycoris` 或 `both`(双格式 `.safetensors`)。预览、量化、多卡和显存方案仍受上游支持范围限制。 +- `minimal` 档禁用文本编码器 streaming、训练内存计划及数据批次的 pinned memory;Windows 下若本机 MSVC 编译 Triton 内核失败,LyCORIS 适配器会自动探测并降级回退 PyTorch 实现。 +- Comfy 编码器暂存目录为 `.cache/kohaku-moss/comfy-layout/`,与 MOSS (anima_lora) 隔离;旧 `.cache/moss/` 保留给原引擎,不自动删除或迁移。 +- 已验证 Windows(RTX 5090 D / RTX 4090)独立环境安装及 10~50 步短训:Comfy BF16 Base、`minimal`、512²~1024² 目标面积、batch 1、LoKr Rank/Alpha 16(4090 上 1024² 训练峰值分配显存约 `2.9 ~ 3.2 GiB`);loss 和梯度有限、无跳步,检查点权重实际更新,Comfy / LyCORIS 双格式导出张量可正常读取。 + +感谢 [Kohaku-Blueleaf(Kohaku / 龙娘)与 KohakuMossTrainer](https://github.com/KohakuBlueleaf/KohakuMossTrainer) 以及 [LyCORIS](https://github.com/KohakuBlueleaf/LyCORIS)。许可证与来源见 [NOTICE](../NOTICE.md),集成协作见 [#492](https://github.com/wochenlong/lora-scripts-next/issues/492)。 ## 2. 要提前下载什么模型 diff --git a/docs/README.md b/docs/README.md index 8fc11bf05..4bc3015e0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -10,9 +10,12 @@ ## Training / 训练 +- [MOSS-Image](MOSS.md): Kohya (default), KohakuMossTrainer, and MOSS (`anima_lora`) LoRA training. +- [Qwen-Image-2.1 (DiffSynth)](diffsynth.md): T2I and Edit LoRA training with DiffSynth-Studio. - [Anima training / Anima 训练](anima-training.md): training targets and VRAM guidance. - [Anima Fast](anima-fast.md): optional runtime, configuration, and training. - [Krea 2 multi-GPU / Krea 2 多卡](krea2-linux-multigpu.md): Linux deployment and multi-GPU usage. +- [Ideogram 4 (Musubi)](ideogram4-musubi.md): experimental FP8 LoRA training on Musubi. - [TOML and CLI / TOML 与命令行](cli-args.md): command-line training entry points. - [Tagger models / 打标模型](tagger-models.md): model files and installation paths. - [Training monitor / 训练监控](train-monitor.md). diff --git a/docs/anima-training.md b/docs/anima-training.md index b399a1344..9636c321e 100644 --- a/docs/anima-training.md +++ b/docs/anima-training.md @@ -37,7 +37,8 @@ Download-Anima-Model.bat ## 训练类型 - **LoRA** — 默认训练类型,适合大多数场景 -- **LoKr** — 使用 LyCORIS 后端(`lycoris.kohya` + `algo=lokr`),支持 CP 分解、DoRA 等高级参数 +- **DoRA** — 独立入口,适合想直接训练 DoRA 适配器的用户;选择后后端会自动配置所需参数 +- **LoKr** — 使用 LyCORIS 后端(`lycoris.kohya` + `algo=lokr`),支持 CP 分解、`dora_wd` 等高级参数。它的 `dora_wd` 是 LoKr 高级权重分解选项,不等同于上面的独立 DoRA 类型入口 - **T-LoRA** — 时间步动态 LoRA,根据扩散时间步自动调整 rank,配合正交初始化防止过拟合(详见下方教程) ## 预览图生成 diff --git a/docs/credits.md b/docs/credits.md index b77b79b25..4097740a7 100644 --- a/docs/credits.md +++ b/docs/credits.md @@ -66,6 +66,14 @@ When redistributing source or portable builds, please keep [NOTICE.md](../NOTICE 以可选插件形式集成(`extensions/anima_lora/`)。说明见 [docs/anima-fast.md](anima-fast.md)。 +## KohakuMossTrainer(可选引擎) + +| 项目 | 链接 | 许可 | +|------|------|------| +| KohakuBlueleaf / KohakuMossTrainer | https://github.com/KohakuBlueleaf/KohakuMossTrainer | KohakuMoss License 1.0 | + +以可选插件形式集成(`extensions/kohaku-moss/`),用于 MOSS-Image 高性能 LoRA / LyCORIS 训练。说明见 [docs/MOSS.md](MOSS.md) 与 [NOTICE.md](../NOTICE.md)。 + ## 网络模块与其它组件 | 项目 | 链接 | 说明 | diff --git a/docs/examples/anima-lora-benchmark-kohya.toml b/docs/examples/anima-lora-benchmark-kohya.toml index 7e6f1f74c..274f24176 100644 --- a/docs/examples/anima-lora-benchmark-kohya.toml +++ b/docs/examples/anima-lora-benchmark-kohya.toml @@ -40,11 +40,16 @@ logging_dir = "./logs/benchmark/anima_lora_kohya_bench" # TensorBo # | 适配器 (lora_type) | network_module | 额外必填项(示例) | # |--------------------|--------------------------|---------------------------------------| # | lora(默认) | networks.lora_anima | 无 | +# | dora | lycoris.kohya | lora_type = "dora"(后端自动注入) | # | lokr | lycoris.kohya | lycoris_algo = "lokr" | # | tlora | networks.tlora_anima | tlora_min_rank, tlora_rank_schedule | # | loha | networks.loha | 无 | # | vera / lora_fa | networks.lora_anima | 无(模块内部分支) | # +# DoRA 示例(独立入口;不要同时填写 LoKr 的 lokr_factor/full_matrix): +# lora_type = "dora" +# dropout = 0.1 # 可选:LyCORIS DoRA dropout +# # LoKr 示例(取消注释并注释掉上方 lora 块即可切换): # network_module = "lycoris.kohya" # lycoris_algo = "lokr" diff --git a/docs/portable-getting-started.md b/docs/portable-getting-started.md index dd8259c4e..c2245c384 100644 --- a/docs/portable-getting-started.md +++ b/docs/portable-getting-started.md @@ -2,6 +2,17 @@ 面向 **Next Trainer 便携整合包**(归档名 `Next-Trainer-v*.7z`)用户的进阶说明。快速上手:下载 → 双击 `启动.bat` → 浏览器开练。 +## 启动器(NextTrainer.exe) + +整合包根目录同时提供一个 **`NextTrainer.exe`**(C# NativeAOT,约 5 MB,无 .NET 运行时依赖): + +- 双击启动 = 等价于 `启动.bat`(启动服务并自动打开浏览器),但会**接管进程树**:关闭窗口或按 `Q` 会真正停掉整个服务,不会留下后台残留 +- 按 `U` 一键更新:先停服 → 运行 `检查更新.bat` → 按 `R` 重启 +- 端口被占用或启动失败时给出中文提示(不是一闪而过) +- 开发/自检:`NextTrainer.exe --selftest`(启动 → 等端口 → 停服 → 退出码 0/1) + +启动器只做壳,不预装任何东西;`启动.bat` 仍是兜底入口。 + 当前最新正式版:**v3.0.0**([GitHub Release](https://github.com/wochenlong/lora-scripts-next/releases/tag/v3.0.0) · [魔搭 Next-Lab/next-trainer-releases](https://www.modelscope.cn/datasets/Next-Lab/next-trainer-releases))。 > **Krea 2**:请用 **musubi** 包(魔搭 `releases/v3.0.0/Next-Trainer-v3.0.0-musubi.7z`),步骤见 **[portable-1.5-krea2-guide.md](portable-1.5-krea2-guide.md)**。 diff --git a/docs/roadmap.md b/docs/roadmap.md index ac3db8f21..e875729b0 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -25,9 +25,12 @@ Next Trainer 的定位是多引擎专业训练工作台。3.x 持续扩大主流 **继续推进的范围:** - 简单预处理,例如放大、透明背景转白底。 -- 本地大模型自然语言打标,与 Tag 模型明确区分。 - 完善管理、打标、编辑与训练间的路径和操作衔接。 -- 常规模型支持更新,包括评估通过 Musubi 接入 Ideogram-4;须独立完成本仓适配与验收。 +- Ideogram-4 已通过 Musubi 接入(本仓适配与补丁完成),GPU 真机验收仍在进行([#424](https://github.com/wochenlong/lora-scripts-next/issues/424));验收完成前不在发布说明中作为已验收能力宣传。 + +**暂不在本版范围:** + +- 本地大模型自然语言打标(与 Tag 模型明确区分)按维护者决定推迟,待后续版本再评估(当前仍只有 Tag 模型打标与词库/本地模型/API 的中文释义)。 视频、音频管理以及 API 打标属于后续扩展,不因界面预留入口就列为首期已支持。发布准备时复查相关历史问题,记录风险与规避方式,不以清空所有历史 Issue 作为统一门槛。 diff --git a/frontend/MIGRATION.md b/frontend/MIGRATION.md index 4b02c19ef..5b90d99d3 100644 --- a/frontend/MIGRATION.md +++ b/frontend/MIGRATION.md @@ -267,3 +267,18 @@ Validation is mocked and CPU-only: schema serialization/constraints, shared modu selection, settings pagination, status gating, one-click install streams, cancellation, and preflight-before-submit are covered. No model download, runtime installation, or GPU training is performed by these frontend tests. + +### Optional KohakuMossTrainer engine + +- Added the upstream Kohaku MOSS schema through the existing training workbench and managed-engine APIs; existing default engines and saved configuration identities are unchanged. +- Required enum-union conditions now exclude inactive algorithm/precision parameters. Kohaku configurations retain numeric learning rates and do not reuse Kohya-only transformations. +- The gate reuses the current install/cancel/disposal guards; submission preflights the same payload sent to `/api/run`. Runtime installation and actual GPU training require platform validation separately from frontend checks. +- Audit fixes (2026-10-23): FP16 and pipeline companion fields use the same conditional serializer; invalid upstream combinations now fail before task creation. Existing Kohaku installs require one managed reinstall to add optimizer dependencies. +- Kohaku task progress, JSONL losses and step-directory previews now use the shared task-page contract. The gate ignores out-of-order status responses without starving slow responses; unmount cleanup is unchanged. + +### main / dev integration for PR #519 (2026-11-03) + +- Retained the dev training workbench, KohakuMossTrainer integration and server-side download-source resolution while merging main's release/update documentation and Windows MOSS source verification fixes. +- Regenerated the tracked production frontend with Node 22.17.1 and the existing lockfile; it matches the dev build output. +- Validation: `npm run check` passed (75 files / 505 tests, typecheck, lint, production build). Backend contract suites passed (135 + 119 tests; 6 skips). Large synthetic-weight suites were interrupted on Windows and are not included in those totals. No engine installation or GPU training was performed. +- PR #519 remains subject to IryNeko review before merging into main. diff --git a/frontend/dist/assets/DatasetPage-D9ZJsVAH.js b/frontend/dist/assets/DatasetPage-D9ZJsVAH.js deleted file mode 100644 index 8b6054245..000000000 --- a/frontend/dist/assets/DatasetPage-D9ZJsVAH.js +++ /dev/null @@ -1 +0,0 @@ -import{N as nt,O as Ft,P as Lt,Q as It,U as jt,R as Ia,S as Wt,T as _o,V as At,W as ko,X as wo,Y as $o,Z as Eo,k as A,l as g,_ as Bt,d as Se,$ as rt,b as d,c as v,e as a,H as ie,a0 as Yt,g as e,x as De,v as Y,a1 as aa,a2 as it,i as U,t as l,y as Jt,n as dt,a3 as Co,a4 as Do,a5 as To,o as Xt,a6 as Mo,M as Aa,a7 as So,s as Me,F as Q,f as le,p as oe,a8 as Po,a9 as Vo,aa as Uo,ab as xo,ac as Fo,ad as Qt,ae as Lo,u as xe,j as b,af as Ae,ag as Ke,w as O,ah as ye,h as P,ai as ea,aj as ha,r as be,ak as Zt,a as Ba,al as la,am as oa,I as ze,an as el,q as ut,C as ct,ao as La,ap as vt,aq as Io,ar as ba,as as Ao,at as Sa,au as Bo,av as Ro,aw as al,ax as No,ay as Oo,az as Za,aA as qo,aB as zo,aC as Rt,aD as Go,J as Ua,G as tt,aE as Ho,aF as lt,aG as Ko,L as Pa,B as Nt,aH as jo,aI as Wo,E as Yo,aJ as Jo,aK as Va,aL as Xo,aM as Qo,aN as ma,aO as Zo,aP as es,aQ as as,aR as ts,aS as ls,aT as os}from"./index-Cb9PW7j5.js";import{E as F}from"./index-CoDol4wt.js";import{E as Ge}from"./index-BrO66bA-.js";import{u as tl,d as Te}from"./useTagTranslations-D89weTmX.js";import{P as ss,u as ns,d as te,a as ot,p as rs,b as is}from"./useServerPathPick-BxRKg2GB.js";import{r as ds,a as us}from"./downloadSources-JTkXfeHs.js";import{u as cs}from"./userPresets-nFFeCJUs.js";const ll=Ia({modelValue:{type:[String,Number,Boolean],default:void 0},size:Wt,disabled:{type:Boolean,default:void 0},label:{type:[String,Number,Boolean],default:void 0},value:{type:[String,Number,Boolean],default:void 0},name:{type:String,default:void 0}}),vs=Ia({...ll,border:Boolean}),ol={[jt]:s=>Ft(s)||Lt(s)||It(s),[nt]:s=>Ft(s)||Lt(s)||It(s)},sl=Symbol("radioGroupKey"),ps=Ia({...ll}),nl={label:"label",value:"value",disabled:"disabled"},gs=Ia({id:{type:String,default:void 0},size:Wt,disabled:{type:Boolean,default:void 0},modelValue:{type:[String,Number,Boolean],default:void 0},fill:{type:String,default:""},textColor:{type:String,default:""},name:{type:String,default:void 0},validateEvent:{type:Boolean,default:!0},options:{type:At(Array)},props:{type:At(Object),default:()=>nl},type:{type:String,values:["radio","button"],default:"radio"},..._o(["ariaLabel"])}),fs=ol,rl=(s,t)=>{const n=g(),u=ko(sl,void 0),o=A(()=>!!u),h=A(()=>Bt(s.value)?s.label:s.value),p=A({get(){return o.value?u.modelValue:s.modelValue},set(w){o.value?u.changeEvent(w):t&&t("update:modelValue",w),n.value.checked=s.modelValue===h.value}}),f=wo(A(()=>u?.size)),c=$o(A(()=>u?.disabled)),$=g(!1),k=A(()=>c.value||o.value&&p.value!==h.value?-1:0);return Eo({from:"label act as value",replacement:"value",version:"3.0.0",scope:"el-radio",ref:"https://element-plus.org/en-US/component/radio.html"},A(()=>o.value&&Bt(s.value))),{radioRef:n,isGroup:o,radioGroup:u,focus:$,size:f,disabled:c,tabIndex:k,modelValue:p,actualValue:h}},ms=["value","name","disabled","checked"];var hs=Se({name:"ElRadio",__name:"radio",props:vs,emits:ol,setup(s,{emit:t}){const n=s,u=t,o=rt("radio"),{radioRef:h,radioGroup:p,focus:f,size:c,disabled:$,modelValue:k,actualValue:w}=rl(n,u);function D(){Jt(()=>u(nt,k.value))}return(T,z)=>(d(),v("label",{class:Y([e(o).b(),e(o).is("disabled",e($)),e(o).is("focus",e(f)),e(o).is("bordered",s.border),e(o).is("checked",e(k)===e(w)),e(o).m(e(c))])},[a("span",{class:Y([e(o).e("input"),e(o).is("disabled",e($)),e(o).is("checked",e(k)===e(w))])},[ie(a("input",{ref_key:"radioRef",ref:h,"onUpdate:modelValue":z[0]||(z[0]=E=>aa(k)?k.value=E:null),class:Y(e(o).e("original")),value:e(w),name:s.name||e(p)?.name,disabled:e($),checked:e(k)===e(w),type:"radio",onFocus:z[1]||(z[1]=E=>f.value=!0),onBlur:z[2]||(z[2]=E=>f.value=!1),onChange:D,onClick:z[3]||(z[3]=De(()=>{},["stop"]))},null,42,ms),[[Yt,e(k)]]),a("span",{class:Y(e(o).e("inner"))},null,2)],2),a("span",{class:Y(e(o).e("label")),onKeydown:z[4]||(z[4]=De(()=>{},["stop"]))},[it(T.$slots,"default",{},()=>[U(l(s.label),1)])],34)],2))}}),il=hs;const bs=["value","name","disabled"];var ys=Se({name:"ElRadioButton",__name:"radio-button",props:ps,setup(s){const t=s,n=rt("radio"),{radioRef:u,focus:o,size:h,disabled:p,modelValue:f,radioGroup:c,actualValue:$}=rl(t),k=A(()=>({backgroundColor:c?.fill||"",borderColor:c?.fill||"",boxShadow:c?.fill?`-1px 0 0 0 ${c.fill}`:"",color:c?.textColor||""}));return(w,D)=>(d(),v("label",{class:Y([e(n).b("button"),e(n).is("active",e(f)===e($)),e(n).is("disabled",e(p)),e(n).is("focus",e(o)),e(n).bm("button",e(h))])},[ie(a("input",{ref_key:"radioRef",ref:u,"onUpdate:modelValue":D[0]||(D[0]=T=>aa(f)?f.value=T:null),class:Y(e(n).be("button","original-radio")),value:e($),type:"radio",name:s.name||e(c)?.name,disabled:e(p),onFocus:D[1]||(D[1]=T=>o.value=!0),onBlur:D[2]||(D[2]=T=>o.value=!1),onClick:D[3]||(D[3]=De(()=>{},["stop"]))},null,42,bs),[[Yt,e(f)]]),a("span",{class:Y(e(n).be("button","inner")),style:dt(e(f)===e($)?k.value:{}),onKeydown:D[4]||(D[4]=De(()=>{},["stop"]))},[it(w.$slots,"default",{},()=>[U(l(s.label),1)])],38)],2))}}),pt=ys;const _s=["id","aria-label","aria-labelledby"];var ks=Se({name:"ElRadioGroup",__name:"radio-group",props:gs,emits:fs,setup(s,{emit:t}){const n=s,u=t,o=rt("radio"),h=Co(),p=g(),{formItem:f}=Do(),{inputId:c,isLabeledByFormItem:$}=To(n,{formItemContext:f}),k=E=>{u(jt,E),Jt(()=>u(nt,E))};Xt(()=>{const E=p.value.querySelectorAll("[type=radio]"),S=E[0];!Array.from(E).some(G=>G.checked)&&S&&(S.tabIndex=0)});const w=A(()=>n.name||h.value),D=A(()=>({...nl,...n.props})),T=E=>{const{label:S,value:G,disabled:J}=D.value,W={label:E[S],value:E[G],disabled:E[J]};return{...Uo(E,[S,G,J]),...W}},z=A(()=>n.type==="button"?pt:il);return Mo(sl,Aa({...So(n),changeEvent:k,name:w})),Me(()=>n.modelValue,(E,S)=>{n.validateEvent&&!xo(E,S)&&f?.validate("change").catch(Fo)}),(E,S)=>(d(),v("div",{id:e(c),ref_key:"radioGroupRef",ref:p,class:Y(e(o).b("group")),role:"radiogroup","aria-label":e($)?void 0:s.ariaLabel||"radio-group","aria-labelledby":e($)?e(f).labelId:void 0},[it(E.$slots,"default",{},()=>[(d(!0),v(Q,null,le(s.options,(G,J)=>(d(),oe(Vo(z.value),Po({key:J},{ref_for:!0},T(G)),null,16))),128))])],10,_s))}}),dl=ks;const ws=Lo(il,{RadioButton:pt,RadioGroup:dl}),$s=Qt(dl);Qt(pt);const Es={class:"tag-filter-box"},Cs={class:"tag-filter-controls"},Ds={class:"tag-filter-list"},Ts=["checked","onChange"],Ms={class:"tag-filter-copy"},Ss={class:"tag-filter-name"},Ps={key:0},Vs={key:0,class:"tag-filter-meta"},Us={key:0,class:"tag-filter-meta"},xs={class:"tag-filter-actions"},Fs=Se({__name:"TagFilterPanel",props:{tags:{},selectedTags:{},logic:{},search:{},searchMode:{},sortBy:{},order:{},excludeInput:{},filteredCount:{},showSelectAll:{type:Boolean,default:!0},translationEnabled:{type:Boolean,default:!1},translationProvider:{default:"danbooru"}},emits:["update:logic","update:search","update:searchMode","update:sortBy","update:order","update:excludeInput","toggleTag","clear","selectAll"],setup(s,{emit:t}){const n=t,{t:u}=xe(),{translationFor:o}=tl();function h(p){n("update:logic",String(p))}return(p,f)=>(d(),v("div",Es,[a("strong",null,l(e(u)("datasetEditor.tagFilter.title")),1),b(e(Ae),{"model-value":s.search,placeholder:e(u)("datasetEditor.tagFilter.searchPlaceholder"),"onUpdate:modelValue":f[0]||(f[0]=c=>n("update:search",c))},null,8,["model-value","placeholder"]),a("div",Cs,[b(e(Ke),{"model-value":s.sortBy,"aria-label":e(u)("datasetEditor.tagFilter.sortLabel"),"onUpdate:modelValue":f[1]||(f[1]=c=>n("update:sortBy",c))},{default:O(()=>[b(e(ye),{value:"frequency",label:e(u)("datasetEditor.tagFilter.sortFrequency")},null,8,["label"]),b(e(ye),{value:"alphabetical",label:e(u)("datasetEditor.tagFilter.sortAlphabetical")},null,8,["label"]),b(e(ye),{value:"length",label:e(u)("datasetEditor.tagFilter.sortLength")},null,8,["label"]),b(e(ye),{value:"tokenLength",label:e(u)("datasetEditor.tagFilter.sortTokenLength")},null,8,["label"])]),_:1},8,["model-value","aria-label"]),b(e(Ke),{"model-value":s.order,"aria-label":e(u)("datasetEditor.tagFilter.orderLabel"),"onUpdate:modelValue":f[2]||(f[2]=c=>n("update:order",c))},{default:O(()=>[b(e(ye),{value:"desc",label:e(u)("datasetEditor.tagFilter.orderDesc")},null,8,["label"]),b(e(ye),{value:"asc",label:e(u)("datasetEditor.tagFilter.orderAsc")},null,8,["label"])]),_:1},8,["model-value","aria-label"]),b(e(Ke),{"model-value":s.searchMode,"aria-label":e(u)("datasetEditor.tagFilter.searchModeLabel"),"onUpdate:modelValue":f[3]||(f[3]=c=>n("update:searchMode",c))},{default:O(()=>[b(e(ye),{value:"substring",label:e(u)("datasetEditor.tagFilter.searchModeSubstring")},null,8,["label"]),b(e(ye),{value:"prefix",label:e(u)("datasetEditor.tagFilter.searchModePrefix")},null,8,["label"]),b(e(ye),{value:"suffix",label:e(u)("datasetEditor.tagFilter.searchModeSuffix")},null,8,["label"])]),_:1},8,["model-value","aria-label"])]),b(e($s),{"model-value":s.logic,class:"tag-filter-logic","onUpdate:modelValue":h},{default:O(()=>[(d(),v(Q,null,le(["and","or","none"],c=>b(e(ws),{key:c,value:c},{default:O(()=>[U(l(e(u)(`datasetEditor.tagFilter.logic.${c}`)),1)]),_:2},1032,["value"])),64))]),_:1},8,["model-value"]),a("div",Ds,[(d(!0),v(Q,null,le(s.tags,c=>(d(),v("label",{key:c.tag,class:Y(["tag-filter-item",{selected:s.selectedTags.has(c.tag)}])},[a("input",{type:"checkbox",checked:s.selectedTags.has(c.tag),onChange:$=>n("toggleTag",c.tag)},null,40,Ts),a("span",Ms,[a("span",Ss,l(c.tag),1),s.translationEnabled&&e(o)(c.tag,s.translationProvider)?(d(),v("small",Ps,l(e(o)(c.tag,s.translationProvider)),1)):P("",!0)]),a("small",null,l(c.count),1)],2))),128)),s.tags.length?P("",!0):(d(),v("p",Vs,l(e(u)("datasetEditor.tagFilter.empty")),1))]),s.selectedTags.size?(d(),v("small",Us,l(e(u)("datasetEditor.tagFilter.selectedCount",{k:s.selectedTags.size})),1)):P("",!0),b(e(Ae),{"model-value":s.excludeInput,placeholder:e(u)("datasetEditor.tagFilter.excludePlaceholder"),title:e(u)("datasetEditor.tagFilter.excludeTip"),"onUpdate:modelValue":f[4]||(f[4]=c=>n("update:excludeInput",c))},null,8,["model-value","placeholder","title"]),a("div",xs,[b(e(ea),{disabled:!s.selectedTags.size,onClick:f[5]||(f[5]=c=>n("clear"))},{default:O(()=>[U(l(e(u)("datasetEditor.tagFilter.clear")),1)]),_:1},8,["disabled"]),s.showSelectAll?(d(),oe(e(ea),{key:0,disabled:!s.filteredCount,title:e(u)("datasetEditor.tagFilter.selectAllTip"),onClick:f[6]||(f[6]=c=>n("selectAll"))},{default:O(()=>[U(l(e(u)("datasetEditor.tagFilter.selectAll",{n:s.filteredCount})),1)]),_:1},8,["disabled","title"])):P("",!0)])]))}}),Ls={class:"caption-translation-toolbar","aria-live":"polite"},Is={class:"caption-translation-heading"},As={key:0,class:"caption-translation-warning"},Bs={key:1,class:"caption-translation-progress"},Rs={key:0},Ns={key:1},Os={key:2,class:"caption-translation-error"},qs=Se({__name:"TagTranslationControls",props:{enabled:{type:Boolean},available:{type:Boolean},unavailableHint:{},loading:{type:Boolean},error:{},progressCompleted:{},progressTotal:{},progressUnresolved:{}},emits:["update:enabled"],setup(s,{emit:t}){const n=t,{t:u}=xe();return(o,h)=>(d(),v("div",Ls,[a("div",Is,[a("span",null,l(e(u)("datasetEditor.caption.translationEnabled")),1),b(e(ha),{"model-value":s.enabled,"aria-label":e(u)("datasetEditor.caption.translationEnabled"),"onUpdate:modelValue":h[0]||(h[0]=p=>n("update:enabled",!!p))},null,8,["model-value","aria-label"])]),s.available?P("",!0):(d(),v("small",As,l(s.unavailableHint),1)),s.loading||s.progressTotal?(d(),v("small",Bs,[s.loading?(d(),v("span",Rs,l(e(u)("datasetEditor.caption.translationLoading")),1)):P("",!0),s.progressTotal?(d(),v("span",Ns,[U(l(s.progressCompleted)+"/"+l(s.progressTotal),1),s.progressUnresolved?(d(),v(Q,{key:0},[U("("+l(e(u)("datasetEditor.caption.translationUnresolved",{n:s.progressUnresolved}))+")",1)],64)):P("",!0)])):P("",!0)])):P("",!0),s.error?(d(),v("small",Os,l(s.error),1)):P("",!0)]))}}),zs={class:"caption-translation-dialog"},Gs={class:"caption-translation-dialog-hint"},Hs={class:"translation-settings-section"},Ks={class:"translation-settings-section-heading"},js=["aria-label"],Ws=["aria-checked","onClick"],Ys={class:"translation-settings-section"},Js={class:"translation-settings-section-heading"},Xs={class:"caption-translation-dialog-hint"},Qs={key:0,class:"caption-translation-update"},Zs={key:1,class:"caption-translation-ok"},en={key:2,class:"caption-translation-error"},an={class:"caption-translation-cache-row"},tn={class:"translation-settings-actions"},ln={class:"caption-translation-dialog-hint"},on={key:0},sn={key:1,class:"caption-translation-error"},nn=Se({__name:"TagTranslationSettingsDialog",props:{modelValue:{type:Boolean},loading:{type:Boolean},error:{},provider:{},llmMode:{},dictionary:{},dictionaryBusy:{type:Boolean}},emits:["update:modelValue","update:provider","update:llm-mode","checkDictionary","updateDictionary","retryDictionary","cancelDictionary"],setup(s,{emit:t}){const n=s,u=t,{t:o}=xe(),h=A(()=>[{key:"dictionary",label:o("datasetEditor.caption.translationProviderDanbooru")},{key:"local",label:o("datasetEditor.caption.translationProviderLocalModel")},{key:"api",label:o("datasetEditor.caption.translationProviderApi")}]),p=A(()=>n.provider!=="llm"?"dictionary":n.llmMode==="local"?"local":"api");function f(c){if(c==="dictionary"){u("update:provider","danbooru");return}u("update:provider","llm"),u("update:llm-mode",c==="local"?"local":"remote")}return(c,$)=>{const k=be("RouterLink");return d(),oe(e(Zt),{"model-value":s.modelValue,title:e(o)("datasetEditor.caption.translationSettingsTitle"),width:"min(640px, 94vw)","onUpdate:modelValue":$[5]||($[5]=w=>u("update:modelValue",w))},{footer:O(()=>[b(e(ea),{onClick:$[4]||($[4]=w=>u("update:modelValue",!1))},{default:O(()=>[U(l(e(o)("datasetEditor.caption.translationCancel")),1)]),_:1})]),default:O(()=>[a("div",zs,[a("p",Gs,l(e(o)("datasetEditor.caption.translationSettingsHint")),1),a("section",Hs,[a("div",Ks,[a("strong",null,l(e(o)("datasetEditor.caption.translationProvider")),1)]),a("div",{class:"caption-translation-provider",role:"radiogroup","aria-label":e(o)("datasetEditor.caption.translationProvider")},[(d(!0),v(Q,null,le(h.value,w=>(d(),v("button",{key:w.key,type:"button",role:"radio","aria-checked":p.value===w.key,class:Y({active:p.value===w.key}),onClick:D=>f(w.key)},l(w.label),11,Ws))),128))],8,js)]),a("section",Ys,[a("div",Js,[a("strong",null,l(e(o)("datasetEditor.caption.translationDictionaryTitle")),1),a("span",null,l(s.dictionary.row_count||0)+" "+l(e(o)("datasetEditor.caption.translationDictionaryRows")),1)]),a("p",Xs,l(s.dictionary.installed?e(o)("datasetEditor.caption.translationDictionaryReady"):e(o)("datasetEditor.caption.translationDictionaryMissing")),1),s.dictionary.state==="ready"&&s.dictionary.update_available?(d(),v("small",Qs,l(e(o)("datasetEditor.caption.translationDictionaryUpdateAvailable")),1)):s.dictionary.state==="ready"&&s.dictionary.last_checked_at?(d(),v("small",Zs,l(e(o)("datasetEditor.caption.translationDictionaryUpToDate")),1)):P("",!0),s.dictionary.error?(d(),v("small",en,l(s.dictionary.error),1)):P("",!0),a("div",an,[a("span",null,[U(l(s.dictionary.state),1),s.dictionary.downloaded_bytes?(d(),v(Q,{key:0},[U(" · "+l(s.dictionary.downloaded_bytes)+"/"+l(s.dictionary.total_bytes||"?"),1)],64)):P("",!0)]),a("span",tn,[b(e(ea),{loading:s.dictionaryBusy,onClick:$[0]||($[0]=w=>u("checkDictionary"))},{default:O(()=>[U(l(e(o)("datasetEditor.caption.translationDictionaryCheck")),1)]),_:1},8,["loading"]),s.dictionary.installed?(d(),oe(e(ea),{key:0,loading:s.dictionaryBusy,disabled:s.dictionary.update_available!==!0||s.dictionary.state==="checking",onClick:$[1]||($[1]=w=>u("updateDictionary"))},{default:O(()=>[U(l(e(o)("datasetEditor.caption.translationDictionaryUpdate")),1)]),_:1},8,["loading","disabled"])):(d(),oe(e(ea),{key:1,loading:s.dictionaryBusy,onClick:$[2]||($[2]=w=>u("retryDictionary"))},{default:O(()=>[U(l(e(o)("datasetEditor.caption.translationDictionaryRetry")),1)]),_:1},8,["loading"])),s.dictionary.state==="downloading"?(d(),oe(e(ea),{key:2,loading:s.dictionaryBusy,onClick:$[3]||($[3]=w=>u("cancelDictionary"))},{default:O(()=>[U(l(e(o)("datasetEditor.caption.translationDictionaryCancel")),1)]),_:1},8,["loading"])):P("",!0)])])]),a("p",ln,[U(l(e(o)("datasetEditor.caption.translationSettingsMoved"))+" ",1),b(k,{class:"translation-settings-link",to:"/settings/api"},{default:O(()=>[U(l(e(o)("settings.nav.api")),1)]),_:1})]),s.loading?(d(),v("small",on,l(e(o)("datasetEditor.caption.translationLoading")),1)):P("",!0),s.error?(d(),v("small",sn,l(s.error),1)):P("",!0)])]),_:1},8,["model-value","title"])}}}),rn={class:"managed-picker"},dn=["disabled","aria-expanded"],un=["aria-label"],cn=["aria-selected"],vn=["aria-selected"],pn={key:0,class:"dataset-source-path"},gn={for:"dataset-server-path"},fn=["placeholder"],mn=["disabled"],hn={key:1,class:"dataset-source-managed"},bn={class:"managed-picker-heading"},yn=["aria-label"],_n={key:0,class:"managed-picker-path"},kn={key:1,role:"status"},wn={key:2,role:"alert"},$n={key:3,class:"managed-picker-folders"},En=["disabled","onClick"],Cn={key:0},Dn=["onClick"],Tn={key:0},Mn=["disabled"],ul=Se({__name:"ManagedDatasetPicker",props:{disabled:{type:Boolean,default:void 0},initialPath:{default:void 0},loaded:{type:Boolean,default:void 0},hideButton:{type:Boolean,default:void 0},open:{type:Boolean,default:void 0}},emits:["select","update:open"],setup(s,{emit:t}){const n=s,u=t,{t:o}=xe(),h=g(!1),p=A({get:()=>n.open??h.value,set:ae=>{h.value=ae,u("update:open",ae)}}),f=g(!1),c=g(""),$=g([]),k=g(null),w=g("managed"),D=g(""),T=g(!1),{open:z,initialPath:E,pick:S,onConfirm:G,onCancel:J}=ns();let W=0;const pe=A(()=>k.value?.entries.filter(ae=>ae.kind==="directory")??[]);async function de(ae,q=""){const C=++W;f.value=!0,c.value="";try{if(ae){const N=await te.contents(ae,q);C===W&&(k.value=N)}else{const N=await te.list();C===W&&($.value=N.datasets,k.value=null)}}catch(N){C===W&&(c.value=N instanceof Error?N.message:String(N))}finally{C===W&&(f.value=!1)}}function me(){p.value=!1,W++,f.value=!1,J()}async function _e(){if(T.value)return;const ae=W;T.value=!0;try{const q=await S({mode:"folder",initialPath:D.value});q&&p.value&&ae===W&&(D.value=q)}finally{T.value=!1}}function ke(){w.value="managed",D.value=n.initialPath||"",de()}function we(){p.value?me():(p.value=!0,ke())}Me(()=>n.open===!0,(ae,q)=>{!ae||q||ke()},{immediate:!0});function Z(){k.value?.relative_path?de(k.value.name,k.value.relative_path.split("/").slice(0,-1).join("/")):de()}function ue(){if(w.value==="server"){if(!D.value.trim())return;u("select",D.value.trim()),me();return}!k.value||f.value||c.value||k.value.in_use||(u("select",k.value.path),me())}return Ba(me),(ae,q)=>(d(),v("span",rn,[s.hideButton?P("",!0):(d(),v("button",{key:0,type:"button",class:Y(["dataset-tool-entry dataset-load-entry",{"is-primary":!s.loaded}]),disabled:s.disabled,"aria-expanded":p.value,onClick:De(we,["prevent"])},[b(e(la)),U(l(s.loaded?e(o)("datasetManage.changeDataset"):e(o)("datasetManage.loadDataset")),1)],10,dn)),b(e(Zt),{"model-value":p.value,title:e(o)("datasetManage.loadDataset"),width:"560px",class:"dataset-source-dialog","append-to-body":"","close-on-click-modal":!1,"onUpdate:modelValue":q[4]||(q[4]=C=>!C&&me())},{footer:O(()=>[a("button",{type:"button",class:"dataset-tool-entry",onClick:me},l(e(o)("datasetManage.cancel")),1),a("button",{type:"button",class:"primary-action managed-picker-confirm",disabled:w.value==="server"?!D.value.trim():f.value||!!c.value||!k.value||k.value.in_use,onClick:ue},l(e(o)("datasetManage.loadDataset")),9,Mn)]),default:O(()=>[a("div",{class:"dataset-source-tabs",role:"tablist","aria-label":e(o)("datasetManage.loadDataset")},[a("button",{type:"button",role:"tab","aria-selected":w.value==="managed","data-source":"managed",onClick:q[0]||(q[0]=C=>w.value="managed")},l(e(o)("datasetManage.registeredDatasets")),9,cn),a("button",{type:"button",role:"tab","aria-selected":w.value==="server","data-source":"server",onClick:q[1]||(q[1]=C=>w.value="server")},l(e(o)("datasetManage.serverFolder")),9,vn)],8,un),w.value==="server"?(d(),v("div",pn,[a("label",gn,l(e(o)("datasetEditor.pathLabel")),1),a("div",null,[ie(a("input",{id:"dataset-server-path","onUpdate:modelValue":q[2]||(q[2]=C=>D.value=C),placeholder:e(o)("datasetEditor.toolbar.pathPlaceholder"),onKeyup:oa(ue,["enter"])},null,40,fn),[[ze,D.value]]),a("button",{type:"button",class:"dataset-tool-entry",disabled:T.value,onClick:_e},l(e(o)("schemaForm.browse")),9,mn)])])):(d(),v("div",hn,[a("span",bn,[k.value?(d(),v("button",{key:0,type:"button",class:"dataset-icon-button","aria-label":e(o)("datasetManage.back"),onClick:Z},[b(e(el))],8,yn)):P("",!0),a("strong",null,l(k.value?k.value.name:e(o)("datasetManage.selectDataset")),1)]),k.value?(d(),v("span",_n,l(k.value.relative_path||"/"),1)):P("",!0),f.value?(d(),v("span",kn,l(e(o)("datasetManage.loadingTitle")),1)):c.value?(d(),v("span",wn,[U(l(c.value),1),a("button",{type:"button",onClick:q[3]||(q[3]=C=>de())},l(e(o)("datasetManage.retry")),1)])):(d(),v("span",$n,[k.value?(d(),v(Q,{key:1},[(d(!0),v(Q,null,le(pe.value,C=>(d(),v("button",{key:C.path,type:"button",class:"managed-picker-folder",onClick:N=>de(k.value.name,C.path)},[b(e(la)),U(l(C.name),1)],8,Dn))),128)),pe.value.length?P("",!0):(d(),v("span",Tn,l(e(o)("datasetManage.noSubfolders")),1))],64)):(d(),v(Q,{key:0},[(d(!0),v(Q,null,le($.value,C=>(d(),v("button",{key:C.name,type:"button",class:"managed-picker-folder",disabled:C.in_use,onClick:N=>de(C.name)},[b(e(la)),U(l(C.name),1)],8,En))),128)),$.value.length?P("",!0):(d(),v("span",Cn,l(e(o)("datasetManage.emptyTitle")),1))],64))]))]))]),_:1},8,["model-value","title"]),b(ss,{modelValue:e(z),"onUpdate:modelValue":q[5]||(q[5]=C=>aa(z)?z.value=C:null),"append-to-body":"",mode:"folder","initial-path":e(E),onConfirm:e(G),onCancel:e(J)},null,8,["modelValue","initial-path","onConfirm","onCancel"])]))}});function Sn(s){const t=s.split(/[\s_]+/).filter(Boolean);return t.length?t.reduce((n,u)=>n+1+(u.length>15?Math.ceil((u.length-15)/6):0),0):0}function Pn(s,t,n,u=new Set){const o=t.size?n==="none"?s.filter(h=>!h.tags.some(p=>t.has(p))):s.filter(h=>{const p=new Set(h.tags);return n==="and"?[...t].every(f=>p.has(f)):[...t].some(f=>p.has(f))}):s;return u.size?o.filter(h=>!h.tags.some(p=>u.has(p))):o}function Ot(s,t){return s.toLowerCase().localeCompare(t.toLowerCase())}function Vn(s,t,n){const u=n==="asc"?1:-1,o=h=>t==="frequency"?h.count:t==="length"?h.tag.length:t==="tokenLength"?Sn(h.tag):0;return[...s].sort((h,p)=>t==="alphabetical"?Ot(h.tag,p.tag)*u:(o(h)-o(p))*u||Ot(h.tag,p.tag))}function Un(s,t,n="substring"){const u=t.toLowerCase().split(/[,,\s]+/).filter(Boolean);return u.length?s.filter(({tag:o})=>{const h=o.toLowerCase();return u.some(p=>n==="prefix"?h.startsWith(p):n==="suffix"?h.endsWith(p):h.includes(p))}):s}function xn(){return{selectedTags:new Set,logic:"and",search:"",searchMode:"substring",sortBy:"frequency",order:"desc",excludeInput:""}}function Fn(s,t,n){const u=Aa(n||xn()),o=A(()=>new Set(u.excludeInput.split(/[,,\n]/).map(w=>w.trim()).filter(Boolean))),h=A(()=>Pn(s.value,u.selectedTags,u.logic,o.value)),p=A(()=>Un(Vn(t.value,u.sortBy,u.order),u.search,u.searchMode)),f=A(()=>u.selectedTags.size>0||o.value.size>0);function c(w){const D=new Set(u.selectedTags);D.has(w)?D.delete(w):D.add(w),u.selectedTags=D}function $(){u.selectedTags=new Set}function k(){$(),u.search="",u.excludeInput=""}return{state:u,filteredItems:h,visibleTagList:p,hasActiveFilter:f,excludedTags:o,toggleTag:c,clearTags:$,reset:k}}const Ln=/\s*[,,]\s*|\.\s+|\.$/;function ta(s){return s.split(Ln).map(t=>t.trim()).filter(Boolean)}function In(s,t){const n=t.trim(),u=ta(s);return!n||u.includes(n)?u.join(", "):[...u,n].join(", ")}function An(s,t){const n=t.trim();return ta(s).filter(u=>u!==n).join(", ")}function Bn(s,t,n){const u=ta(s);if(t<0||n<0||t>=u.length||n>=u.length||t===n)return u.join(", ");const[o]=u.splice(t,1);return u.splice(n,0,o),u.join(", ")}const cl="dataset-editor-session-v1",qt=500;function Rn(){try{const s=JSON.parse(localStorage.getItem(cl)||"null");return s&&typeof s=="object"?s:{}}catch{return{}}}const re=Rn(),Ra=g(typeof re.lastPath=="string"?re.lastPath:""),ya=g(typeof re.lastRoot=="string"?re.lastRoot:""),Na=g(typeof re.selected=="string"?re.selected:""),Ue=g(re.drafts&&typeof re.drafts=="object"?{...re.drafts}:{}),vl=g(!!re.showTranslations),pl=g(re.translationProvider==="llm"?"llm":"danbooru"),gt=g(typeof re.category=="string"?re.category:""),ft=g(typeof re.query=="string"?re.query:""),mt=g(typeof re.page=="number"&&re.page>0?re.page:1),ht=g(re.rightPanelMode||"caption"),Fe=Aa({selectedTags:new Set(re.tagFilter?.selectedTags||[]),logic:re.tagFilter?.logic||"and",search:re.tagFilter?.search||"",searchMode:re.tagFilter?.searchMode||"substring",sortBy:re.tagFilter?.sortBy||"frequency",order:re.tagFilter?.order||"desc",excludeInput:re.tagFilter?.excludeInput||""}),gl=g([]),fl=g([]),ml=g([]),hl=g(new Set),bl=g({can_undo:!1,can_redo:!1,changes:[]});function Oa(s,t){return`${s}\0${t}`}function sa(){const s=Object.entries(Ue.value),t=s.length>qt?s.slice(s.length-qt):s;try{localStorage.setItem(cl,JSON.stringify({lastPath:Ra.value,lastRoot:ya.value,selected:Na.value,drafts:Object.fromEntries(t),showTranslations:vl.value,translationProvider:pl.value,category:gt.value,query:ft.value,page:mt.value,rightPanelMode:ht.value,tagFilter:{selectedTags:[...Fe.selectedTags],logic:Fe.logic,search:Fe.search,searchMode:Fe.searchMode,sortBy:Fe.sortBy,order:Fe.order,excludeInput:Fe.excludeInput}}))}catch{}}function Nn(s,t){Ra.value=s,ya.value=t,sa()}function On(s){Na.value=s,sa()}function qn(s,t){return Ue.value[Oa(s,t)]}function zn(s,t,n){if(!s||!t)return;const u=Oa(s,t);Ue.value={...Ue.value,[u]:n},sa()}function Gn(s,t){const n=Oa(s,t);if(!(n in Ue.value))return;const u={...Ue.value};delete u[n],Ue.value=u,sa()}function Hn(s,t){if(!t.length)return;const n={...Ue.value};let u=!1;for(const o of t){const h=Oa(s,o);h in n&&(delete n[h],u=!0)}u&&(Ue.value=n,sa())}function Kn(){sa()}function yl(){gl.value=[],fl.value=[],ml.value=[],hl.value=new Set,Na.value="",bl.value={can_undo:!1,can_redo:!1,changes:[]}}function jn(){const s=`${ya.value}\0`;Ue.value=Object.fromEntries(Object.entries(Ue.value).filter(([t])=>!t.startsWith(s))),yl(),ya.value="",Ra.value="",gt.value="",ft.value="",mt.value=1,ht.value="caption",Fe.selectedTags.clear(),Fe.search="",Fe.excludeInput="",sa()}function Wn(){return{unload:jn,lastPath:Ra,lastRoot:ya,selected:Na,drafts:Ue,showTranslations:vl,translationProvider:pl,category:gt,query:ft,page:mt,rightPanelMode:ht,items:gl,tags:fl,categories:ml,selectedPaths:hl,history:bl,tagFilter:Fe,rememberDataset:Nn,rememberSelection:On,getDraft:qn,setDraft:zn,clearDraft:Gn,clearDrafts:Hn,rememberPreferences:Kn,resetInMemoryDataset:yl}}const Yn={class:"dataset-workspace"},Jn={class:"dataset-toolbar"},Xn={class:"dataset-toolbar-top"},Qn={class:"dataset-toolbar-label",for:"editor-dataset-path"},Zn={class:"dataset-toolbar-controls"},er=["disabled","placeholder"],ar=["disabled"],tr=["disabled","aria-label","title","aria-expanded"],lr={key:0,class:"dataset-split-menu",role:"menu"},or=["disabled"],sr={key:0,role:"status"},nr={class:"dataset-toolbar-inline dataset-toolbar-search"},rr={class:"dataset-toolbar-bottom"},ir={class:"dataset-toolbar-inline dataset-toolbar-folder"},dr={class:"dataset-toolbar-actions"},ur=["disabled"],cr={key:0},vr=["disabled"],pr=["disabled","aria-label","title"],gr={class:"dataset-gallery"},fr={class:"dataset-gallery-bar"},mr={key:0,class:"dataset-gallery-hint"},hr=["disabled"],br=["disabled","aria-label","aria-expanded"],yr={key:0,class:"dataset-select-menu",role:"menu"},_r=["disabled"],kr=["disabled"],wr=["disabled"],$r=["disabled"],Er={key:0,class:"dataset-empty"},Cr={key:1,class:"image-grid"},Dr=["title","onClick","onDblclick"],Tr=["aria-checked","aria-label","title","onClick"],Mr={key:0},Sr=["src","alt"],Pr={class:"dataset-pager"},Vr=["disabled"],Ur=["disabled"],xr=["disabled"],Fr=["disabled"],Lr=["aria-label"],Ir={class:"dataset-tool-panel-header"},Ar=["aria-label"],Br={key:0,class:"dataset-tool-panel-body caption-panel"},Rr={key:0},Nr={class:"caption-head"},Or=["src","alt","title"],qr={class:"caption-head-text"},zr=["title"],Gr={class:"caption-preview-hint"},Hr={key:0,class:"caption-file-actions"},Kr=["href"],jr=["href"],Wr=["aria-label"],Yr=["aria-pressed"],Jr=["aria-pressed"],Xr=["title","onDragstart","onDrop"],Qr={class:"caption-tag-text"},Zr={key:0,class:"caption-tag-translation"},ei=["aria-label","onClick"],ai={class:"chip-add"},ti={class:"caption-drag-hint"},li={key:2,class:"caption-editor"},oi={class:"caption-count"},si={key:1},ni={key:1,class:"dataset-tool-panel-body dataset-filter-body"},ri={class:"dataset-tool-panel-footer"},ii=["disabled"],di={key:2,class:"dataset-tool-panel-body batch-body"},ui={class:"dataset-batch-summary"},ci={class:"replace-row"},vi={class:"dataset-tool-panel-footer"},pi=["disabled"],gi=["disabled"],fi=["aria-label"],mi=["src","alt"],hi={class:"dataset-history"},bi={key:0},zt="dataset-editor-page-size",yi=Se({__name:"DatasetEditorPage",setup(s){const{t}=xe(),n=ut(),u=ct(),o=Wn(),h=g(o.lastPath.value),p=o.lastRoot,f=o.items,c=o.tags,$=o.categories,k=o.category,w=o.query,D=o.selected,T=o.selectedPaths,z=g(),E=f.value.find(i=>i.relative_path===D.value),S=g(E&&p.value?o.getDraft(p.value,E.relative_path)??E.caption:"");let G=!!E;const J=g(""),W=g(""),pe=g(""),de=g(""),me=g(!1),_e=g(!1),ke=g(!1),we=g(!1),Z=g(!1),ue=g("back"),ae=g(""),q=o.page,C=g(Number(localStorage.getItem(zt))||48),N=g(!1),H=o.rightPanelMode,L=g(!1),ee=o.history,M=g(!1),se=o.showTranslations,he=g("tags"),I=o.translationProvider,{loading:y,error:V,progress:$e,unresolved:K,resolve:da,translationFor:Ve,cancelCurrent:Be}=tl(),je=g(!1),We=g(!1),ua=g(""),na=g(!1),Re=g([]),Ye=g("default"),Ne=g("remote"),x=g([]),_=g("default"),j=g("remote"),ce=g(0),X=g({state:"missing",installed:!1,row_count:0,size_bytes:0,error:null}),ne=g(!1),Pe=g({state:"missing",model_id:"",model_filename:"",model_url:"",model_path:"",installed:!1,size_bytes:0,downloaded_bytes:0,total_bytes:0,runtime_path:"",endpoint:"internal://dataset-translation",port:0,error:null});let Le;const R=g([]),Oe=A(()=>R.value.find(i=>i.path===p.value)?.name??"");async function El(){try{const i=await te.list();R.value=i.datasets.map(({name:r,path:B})=>({name:r,path:B}))}catch{R.value=[]}}function qa(i){i.key==="Escape"&&(M.value=!1,L.value=!1,H.value!=="caption"&&(H.value="caption"))}const Ee=A(()=>Pl.value.filter(i=>(!k.value||i.category===k.value)&&(!w.value||i.caption.toLowerCase().includes(w.value.toLowerCase())||i.name.toLowerCase().includes(w.value.toLowerCase())||i.tags.some(r=>r.toLowerCase().includes(w.value.toLowerCase()))))),ca=A(()=>Math.max(1,Math.ceil(Ee.value.length/C.value))),_a=A(()=>Ee.value.slice((q.value-1)*C.value,q.value*C.value)),Ce=A(()=>f.value.find(i=>i.relative_path===D.value)),Cl=A(()=>H.value!=="caption"||!!Ce.value),Ie=A(()=>T.value.size?f.value.filter(i=>T.value.has(i.relative_path)):Ee.value),Dl=A(()=>ta(S.value)),za=A(()=>{const i=new Set(c.value.map(r=>r.tag));return f.value.forEach(r=>{r.tags.forEach(m=>i.add(m));const B=p.value?o.getDraft(p.value,r.relative_path):void 0;ta(B??r.caption).forEach(m=>i.add(m))}),[...i]}),Tl=A(()=>[...za.value].sort().join("\0")),Ml=A(()=>{const i=new Map;return f.value.forEach(r=>{const B=p.value?o.getDraft(p.value,r.relative_path):void 0;(B===void 0?r.tags:ta(B)).forEach(ve=>i.set(ve,(i.get(ve)||0)+1))}),[...i].map(([r,B])=>({tag:r,count:B})).sort((r,B)=>B.count-r.count||r.tag.localeCompare(B.tag))}),Sl=A(()=>f.value.map(i=>{const r=p.value?o.getDraft(p.value,i.relative_path):void 0;return r===void 0?i:{...i,tags:ta(r)}})),{state:ge,filteredItems:Pl,visibleTagList:Vl,hasActiveFilter:Ul,toggleTag:xl,clearTags:yt,reset:_t}=Fn(Sl,Ml,o.tagFilter),ka=A(()=>!!k.value||!!w.value.trim()||Ul.value),Ga=A(()=>f.value.length),wa=A(()=>Ee.value.length),Ha=A(()=>Ee.value.length>0&&Ee.value.every(i=>T.value.has(i.relative_path)));async function Je(i=!1){if(na.value||await ja(),!Ea.value){se.value=!1,Be(),F.warning(Et.value);return}za.value.length&&await da(za.value,I.value,"zh-CN",i)}let He;function Fl(){se.value&&(He&&clearTimeout(He),He=setTimeout(()=>{He=void 0,Je()},350))}async function Ll(i){if(!i){se.value=!1,Be();return}if(se.value=!0,na.value||await ja(),se.value=!0,!Ea.value){F.info(t("datasetEditor.caption.translationDownloading")),Il();return}if(I.value==="llm"){Ct().then(r=>{r&&se.value&&I.value==="llm"&&Je()});return}Je()}const $a=g(!1);let kt=!1;async function Il(){if(!$a.value){$a.value=!0;try{await Te.updateTagDictionary(!1);for(let i=0;i<240;i+=1){if(await new Promise(r=>setTimeout(r,1500)),kt||!se.value)return;if(await va(),X.value.installed){F.success(t("datasetEditor.caption.translationDownloaded")),Je();return}if(X.value.state==="error"){F.error(X.value.error||t("datasetEditor.caption.translationUnavailable"));return}}F.warning(t("datasetEditor.caption.translationUnavailable"))}catch(i){F.error(i instanceof Error?i.message:t("datasetEditor.caption.translationUnavailable"))}finally{$a.value=!1}}}async function Al(i){Ne.value=i;try{await Te.saveTagTranslationConfig({llm_mode:i,active_remote_id:Ye.value,remote_profiles:Re.value,local:{enabled:i==="local"}})}catch{}}function Bl(i){if(I.value=i,Be(),i==="llm"){Ct().then(r=>{r&&se.value&&I.value==="llm"&&Je()});return}se.value&&Je()}function wt(i){return i.map(r=>({...r}))}function Rl(){x.value=wt(Re.value),_.value=Ye.value,j.value=Ne.value}function Nl(){Re.value=wt(x.value),Ye.value=_.value,Ne.value=j.value}async function Ka(i=!1){if(!(We.value||!i&&Re.value.length)){We.value=!0,ua.value="";try{const r=await Te.tagTranslationConfig();Re.value=r.remote_profiles?.length?r.remote_profiles:[{...r.deepseek,id:"default",name:t("datasetEditor.caption.translationProfileNew")}],Ye.value=r.active_remote_id||Re.value[0]?.id||"default",Ne.value=r.llm_mode||(r.local?.enabled?"local":"remote"),Rl()}catch(r){ua.value=r instanceof Error?r.message:String(r)}finally{We.value=!1}}}async function ja(){await Promise.all([Ka(),va(),Ca()]),na.value=!0,!Ea.value&&se.value&&!$a.value&&(se.value=!1,Be())}const Ol=A(()=>Re.value.find(i=>i.id===Ye.value)),$t=A(()=>{const i=Ol.value;if(!i)return!1;const r=i.endpoint.trim().toLowerCase();return!!(i.api_key_configured||/^http:\/\/(127\.0\.0\.1|localhost|\[::1\])(?::\d+)?\//.test(r))}),ql=A(()=>Pe.value.state==="running"),Ea=A(()=>!!(X.value.installed||$t.value||ql.value)),Et=A(()=>t("datasetEditor.caption.translationUnavailable"));async function Ct(){await Promise.all([Ka(!0),Ca()]);const i=Ne.value==="local"?Pe.value.state==="running":$t.value;if(!i){const r=Ne.value==="local"?t("datasetEditor.caption.translationLocalUnavailable"):t("datasetEditor.caption.translationRemoteNotConfigured");je.value=!0,await Promise.all([Dt(),va()]),F.warning(r)}return i}async function zl(){je.value=!0,await Promise.all([Ka(!0),Dt(),va(),Ca()]),na.value=!0}function Gl(i){je.value=i,i||Nl()}async function Dt(){try{ce.value=(await Te.tagTranslationCache()).total}catch{ce.value=0}}async function va(){try{X.value=await Te.tagDictionaryStatus()}catch(i){X.value={...X.value,state:"error",error:i instanceof Error?i.message:String(i)}}}async function Ca(){try{Pe.value=await Te.localModelStatus()}catch(i){Pe.value={...Pe.value,state:"error",error:i instanceof Error?i.message:String(i)}}}function Wa(){Le&&clearTimeout(Le),!(X.value.state!=="downloading"&&Pe.value.state!=="downloading"&&Pe.value.state!=="installing"&&Pe.value.runtime_state!=="installing")&&(Le=setTimeout(async()=>{await Promise.all([va(),Ca()]),Wa()},1e3))}async function Hl(){ne.value=!0;try{X.value=await Te.checkTagDictionary()}catch(i){X.value={...X.value,state:"error",error:i instanceof Error?i.message:String(i)}}finally{ne.value=!1}}async function Kl(){ne.value=!0;try{X.value=await Te.updateTagDictionary(!1),Wa()}catch(i){X.value={...X.value,state:"error",error:i instanceof Error?i.message:String(i)}}finally{ne.value=!1}}async function jl(){ne.value=!0;try{X.value=await Te.retryTagDictionary(),Wa()}catch(i){X.value={...X.value,state:"error",error:i instanceof Error?i.message:String(i)}}finally{ne.value=!1}}async function Wl(){ne.value=!0;try{X.value=await Te.cancelTagDictionary()}catch(i){X.value={...X.value,state:"error",error:i instanceof Error?i.message:String(i)}}finally{ne.value=!1}}const Yl=A(()=>Ha.value?t("datasetEditor.gallery.deselectAll",{n:wa.value}):ka.value?t("datasetEditor.gallery.selectFiltered",{n:wa.value}):t("datasetEditor.gallery.selectAll",{n:wa.value})),Tt=A(()=>H.value==="filter"?t("datasetEditor.filter.drawerTitle"):H.value==="batch"?T.value.size?t("datasetEditor.batch.drawerTitleSelected",{n:T.value.size}):t("datasetEditor.batch.drawerTitle"):t("datasetEditor.caption.panelTitle"));function Mt(i){H.value=H.value===i&&i!=="caption"?"caption":i}function Ya(){H.value="caption"}function Jl(){if(H.value!=="caption"){Ya();return}fa(),D.value="",o.rememberSelection("")}function St(){const i=In(S.value,ae.value);i!==S.value&&(S.value=i),ae.value=""}function Xl(i){S.value=An(S.value,i)}const pa=g(null);function Ql(i,r){pa.value=i,r.dataTransfer?.setData("text/plain",String(i)),r.dataTransfer&&(r.dataTransfer.effectAllowed="move")}function Zl(i){i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect="move")}function eo(i,r){r.preventDefault();const B=pa.value;pa.value=null,!(B==null||B===i)&&(S.value=Bn(S.value,B,i))}function ao(){pa.value=null}let ga=!1;function fa(){if(!G||!p.value||!D.value)return;const i=f.value.find(r=>r.relative_path===D.value);i&&(S.value===i.caption?o.clearDraft(p.value,D.value):o.setDraft(p.value,D.value,S.value))}function Ja(i,r){if(r&&(r.shiftKey||r.ctrlKey||r.metaKey)){Pt(i,r);return}fa(),D.value=i.relative_path,o.rememberSelection(i.relative_path),ga=!0,S.value=p.value?o.getDraft(p.value,i.relative_path)??i.caption:i.caption,ga=!1,G=!0,H.value="caption",z.value=Ee.value.findIndex(B=>B.relative_path===i.relative_path)}function Pt(i,r){const B=Ee.value.findIndex(ve=>ve.relative_path===i.relative_path),m=new Set(T.value);if(r?.shiftKey&&z.value!==void 0&&z.value>=0){const[ve,qe]=[z.value,B].sort((Ze,Qa)=>Ze-Qa);Ee.value.slice(ve,qe+1).forEach(Ze=>m.add(Ze.relative_path))}else m.has(i.relative_path)?m.delete(i.relative_path):m.add(i.relative_path);T.value=m,z.value=B}function to(i){D.value!==i.relative_path&&Ja(i),M.value=!0}function Xa(i){const r=new Map(i.map(B=>[B.image,B]));o.clearDrafts(p.value,i.map(B=>B.image)),f.value=f.value.map(B=>{const m=r.get(B.relative_path);return m?{...B,caption:m.caption,tags:m.tags,caption_exists:m.caption_exists}:B}),Ce.value&&(S.value=Ce.value.caption),lo()}function lo(){const i=new Map;f.value.forEach(r=>r.tags.forEach(B=>i.set(B,(i.get(B)||0)+1))),c.value=[...i].map(([r,B])=>({tag:r,count:B})).sort((r,B)=>B.count-r.count||r.tag.localeCompare(B.tag))}async function Da(){const i=p.value,r=fe;if(!i)return;const B=await Te.history(i);p.value===i&&r===fe&&(ee.value=B)}let fe=0;async function oo(){if(!p.value)return Qe();if(fa(),Object.keys(o.drafts.value).some(r=>r.startsWith(`${p.value}\0`)))try{await Ge.confirm(t("datasetManage.unloadConfirm"),{type:"warning"})}catch{return}if(fe++,Be(),He&&clearTimeout(He),G=!1,S.value="",M.value=!1,N.value=!1,L.value=!1,o.unload(),_t(),h.value="",Z.value=!1,n.query.path){const r={...n.query};delete r.path,await u.replace({query:r})}}function so(i){h.value=i,Qe()}const Ta=g(!1),Xe=g(!1);let ra;function Ma(){Xe.value=!1,ra&&(document.removeEventListener("click",ra),ra=void 0)}function no(){if(Xe.value){Ma();return}Xe.value=!0,ra=i=>{i.target?.closest?.(".dataset-split")||Ma()},window.setTimeout(()=>{Xe.value&&ra&&document.addEventListener("click",ra)},0)}const ro=A(()=>p.value?"replace":"load"),io=A(()=>ro.value==="replace"?t("datasetEditor.replace"):t("datasetEditor.scan"));function uo(){if(!h.value.trim()){Ta.value=!0;return}Qe()}function Vt(i){if(Ma(),i==="pick"){Ta.value=!0;return}oo()}function co(i){if(i==="translation"){zl();return}if(i==="history"){N.value=!0;return}(i==="undo"||i==="redo")&&fo(i)}async function Qe(){if(!h.value.trim())return;const i=++fe;fa(),Z.value=!0;try{const r=await Te.scan(h.value);if(i!==fe)return;const B=o.lastRoot.value===r.root,m=H.value,ve=r.items;p.value=r.root,h.value=r.root,o.rememberDataset(h.value,p.value),f.value=ve,c.value=r.tags.sort((Ze,Qa)=>Qa.count-Ze.count),$.value=r.categories,B||(T.value=new Set,D.value="",ee.value={can_undo:!1,can_redo:!1,changes:[]},k.value="",w.value="",_t(),q.value=1,H.value="caption");const qe=B&&D.value?ve.find(Ze=>Ze.relative_path===D.value):void 0;if(qe?Ja(qe):(ga=!0,S.value="",ga=!1,G=!1),B&&(H.value=m),await Promise.all([Da(),El()]),i!==fe)return;se.value&&Je(),F.success(t("datasetEditor.scanMsg.loaded",{n:r.total}))}catch(r){i===fe&&F.error(r instanceof Error?r.message:t("datasetEditor.scanMsg.fail"))}finally{i===fe&&(Z.value=!1)}}async function vo(){if(!Ce.value)return;const i=fe;try{const r=await Te.save(p.value,Ce.value.relative_path,S.value);if(i!==fe||(Xa([r]),await Da(),i!==fe))return;F.success(t("datasetEditor.caption.saved"))}catch(r){F.error(r instanceof Error?r.message:t("datasetEditor.caption.saveFail"))}}function Ut(i){return i.split(/[,,\n]/).map(r=>r.trim()).filter(Boolean)}async function po(){if(!Ie.value.length)return;const i=fe;try{if(await Ge.confirm(t("datasetEditor.batch.confirm",{n:Ie.value.length}),T.value.size?t("datasetEditor.batch.confirmSelected"):t("datasetEditor.batch.confirmFiltered")),i!==fe)return;const r=pe.value.trim()?[{from:pe.value.trim(),to:de.value.trim()}]:[],B=await Te.batch({root:p.value,images:Ie.value.map(m=>m.relative_path),append:Ut(J.value),append_position:ue.value,remove:Ut(W.value),replace:r,clean:me.value,sort:_e.value,underscore_to_space:ke.value,strip_escape_chars:we.value});if(i!==fe||(Xa(B.items),await Da(),i!==fe))return;F.success(t("datasetEditor.batch.done",{n:B.changed})),H.value="caption"}catch(r){r!=="cancel"&&r!=="close"&&F.error(r instanceof Error?r.message:t("datasetEditor.batch.fail"))}}async function go(){if(!Oe.value||!Ie.value.length)return;const i=fe;try{await Ge.confirm(t("datasetEditor.batch.deleteConfirm",{n:Ie.value.length}),{type:"warning"})}catch{return}if(i===fe)try{const r=await te.deleteFiles(Oe.value,Ie.value.map(B=>B.relative_path));if(i!==fe)return;F.success(t("datasetEditor.batch.deleteDone",{n:r.deleted.length})),r.missing.length&&F.warning(t("datasetEditor.batch.deleteMissing",{n:r.missing.length})),await Qe()}catch(r){F.error(r instanceof Error?r.message:t("datasetEditor.batch.deleteFail"))}}async function fo(i){const r=fe;try{const B=await Te[i](p.value);if(r!==fe||(Xa(B.items),await Da(),r!==fe))return;F.success(B.changed?t(i==="undo"?"datasetEditor.historyMsg.undone":"datasetEditor.historyMsg.redone"):t("datasetEditor.historyMsg.none"))}catch(B){F.error(B instanceof Error?B.message:t("datasetEditor.historyMsg.fail"))}}function xt(){Ha.value?T.value=new Set:T.value=new Set(Ee.value.map(i=>i.relative_path)),L.value=!1}function mo(){T.value=new Set(f.value.map(i=>i.relative_path)),L.value=!1}function ho(){T.value=new Set(_a.value.map(i=>i.relative_path)),L.value=!1}function bo(){T.value=new Set,L.value=!1}function yo(){k.value="",w.value="",yt(),ge.excludeInput="",ge.logic="and"}return Me([k,w,C],()=>{q.value=1,localStorage.setItem(zt,String(C.value))}),Me(S,()=>{ga||fa()},{flush:"sync"}),Me(Tl,()=>{Fl()}),Me([se,I,k,w,q,H],()=>{o.rememberPreferences()}),Me(()=>[ge.logic,ge.selectedTags.size,ge.excludeInput],()=>{q.value=1,o.rememberPreferences()}),Me(()=>[ge.search,ge.searchMode,ge.sortBy,ge.order],()=>{o.rememberPreferences()}),Me(ca,i=>{q.value>i&&(q.value=i)}),La(()=>window.addEventListener("keydown",qa)),La(()=>{ja();const i=n?.query.path;typeof i=="string"&&i.trim()&&i!==h.value?(h.value=i,Qe()):!f.value.length&&h.value.trim()&&Qe()}),vt(()=>{window.removeEventListener("keydown",qa),M.value=!1,L.value=!1,N.value=!1}),Io(()=>{fe++,kt=!0,window.removeEventListener("keydown",qa),Ma(),Le&&clearTimeout(Le),He&&clearTimeout(He)}),(i,r)=>{const B=be("el-dialog");return d(),v(Q,null,[a("div",{class:Y(["dataset-page",{"tool-panel-open":Cl.value}])},[a("div",Yn,[a("header",Jn,[a("div",Xn,[a("label",Qn,l(e(t)("datasetEditor.pathLabel")),1),a("span",Zn,[ie(a("input",{id:"editor-dataset-path","onUpdate:modelValue":r[0]||(r[0]=m=>h.value=m),class:"dataset-direct-path",disabled:Z.value,placeholder:e(t)("datasetEditor.toolbar.pathPlaceholder"),onKeyup:r[1]||(r[1]=oa(m=>!Z.value&&Qe(),["enter"]))},null,40,er),[[ze,h.value]]),a("div",{class:Y(["dataset-split",{open:Xe.value}])},[a("button",{"data-testid":"scan-action",type:"button",class:Y(["dataset-tool-entry dataset-split-main",{"is-primary":!e(p)}]),disabled:Z.value,onClick:uo},l(io.value),11,ar),a("button",{type:"button",class:Y(["dataset-tool-entry dataset-split-caret",{"is-primary":!e(p)}]),disabled:Z.value,"aria-label":e(t)("datasetEditor.datasetMenu"),title:e(t)("datasetEditor.datasetMenu"),"aria-expanded":Xe.value,onClick:no},"▼",10,tr),Xe.value?(d(),v("div",lr,[a("button",{type:"button",role:"menuitem",onClick:r[2]||(r[2]=m=>Vt("pick"))},l(e(t)("datasetManage.selectDataset")),1),a("button",{type:"button",role:"menuitem",disabled:!e(p),onClick:r[3]||(r[3]=m=>Vt("unload"))},l(e(t)("datasetManage.unload")),9,or)])):P("",!0)],2),b(ul,{open:Ta.value,"onUpdate:open":r[4]||(r[4]=m=>Ta.value=m),"hide-button":"",disabled:Z.value,loaded:!!e(p),"initial-path":h.value,onSelect:so},null,8,["open","disabled","loaded","initial-path"]),Z.value?(d(),v("span",sr,l(e(t)("datasetEditor.scanning")),1)):P("",!0)]),a("label",nr,[a("span",null,l(e(t)("datasetEditor.toolbar.searchLabel")),1),b(e(Ae),{modelValue:e(w),"onUpdate:modelValue":r[5]||(r[5]=m=>aa(w)?w.value=m:null),placeholder:e(t)("datasetEditor.filter.queryPlaceholder"),disabled:!e(p)},null,8,["modelValue","placeholder","disabled"])])]),a("div",rr,[a("label",ir,[a("span",null,l(e(t)("datasetEditor.toolbar.folderLabel")),1),b(e(Ke),{modelValue:e(k),"onUpdate:modelValue":r[6]||(r[6]=m=>aa(k)?k.value=m:null),disabled:!e(p),"aria-label":e(t)("datasetEditor.toolbar.folderLabel")},{default:O(()=>[b(e(ye),{value:"",label:e(t)("datasetEditor.toolbar.folderAll",{n:Ga.value||0})},null,8,["label"]),(d(!0),v(Q,null,le(e($),m=>(d(),oe(e(ye),{key:`tb-${m.value||"__root__"}`,value:m.value,label:`${m.name} (${m.count})`},null,8,["value","label"]))),128))]),_:1},8,["modelValue","disabled","aria-label"])]),a("div",dr,[a("button",{type:"button",class:Y(["dataset-tool-entry",{active:e(H)==="filter",hot:ka.value}]),disabled:!e(p),onClick:r[7]||(r[7]=m=>Mt("filter"))},[U(l(e(t)("datasetEditor.filter.toggle"))+" ",1),ka.value?(d(),v("small",cr,l(e(t)("datasetEditor.filter.activeBadge")),1)):P("",!0)],10,ur),a("button",{type:"button",class:Y(["dataset-tool-entry dataset-batch-entry",{active:e(H)==="batch"||e(T).size>0}]),disabled:!e(p),onClick:r[8]||(r[8]=m=>Mt("batch"))},l(e(t)("datasetEditor.batch.toolbar",{n:e(T).size})),11,vr),b(e(Bo),{trigger:"click",onCommand:co},{dropdown:O(()=>[b(e(Ao),null,{default:O(()=>[b(e(Sa),{command:"translation"},{default:O(()=>[U(l(e(t)("datasetEditor.caption.translationSettings")),1)]),_:1}),b(e(Sa),{command:"undo",disabled:!e(ee).can_undo,divided:""},{default:O(()=>[U(l(e(t)("datasetEditor.gallery.undo")),1)]),_:1},8,["disabled"]),b(e(Sa),{command:"redo",disabled:!e(ee).can_redo},{default:O(()=>[U(l(e(t)("datasetEditor.gallery.redo")),1)]),_:1},8,["disabled"]),b(e(Sa),{command:"history",disabled:!e(p)},{default:O(()=>[U(l(e(t)("datasetEditor.gallery.history")),1)]),_:1},8,["disabled"])]),_:1})]),default:O(()=>[a("button",{type:"button",class:"dataset-tool-entry dataset-tool-more",disabled:!e(p),"aria-label":e(t)("datasetEditor.gallery.more"),title:e(t)("datasetEditor.gallery.more")},[b(e(ba))],8,pr)]),_:1})])])]),a("main",gr,[a("header",fr,[a("strong",null,l(e(T).size?e(t)("datasetEditor.gallery.count",{filtered:Ee.value.length,total:e(f).length,selected:e(T).size}):e(t)("datasetEditor.gallery.countPlain",{filtered:Ee.value.length,total:e(f).length})),1),e(p)&&e(f).length&&!e(T).size?(d(),v("span",mr,l(e(D)?e(t)("datasetEditor.gallery.shiftHint"):e(t)("datasetEditor.gallery.pickHint")),1)):P("",!0),a("div",{class:Y(["dataset-select-scope",{open:L.value}])},[a("button",{type:"button",class:Y(["dataset-select-main",{active:Ha.value}]),disabled:!e(p)||!Ee.value.length,onClick:xt},l(Yl.value),11,hr),a("button",{type:"button",class:"dataset-select-caret",disabled:!e(p),"aria-label":e(t)("datasetEditor.gallery.selectMenuAria"),"aria-expanded":L.value,onClick:r[9]||(r[9]=m=>L.value=!L.value)}," ▼ ",8,br),L.value?(d(),v("div",yr,[a("button",{type:"button",role:"menuitem",disabled:!e(f).length,onClick:mo},l(e(t)("datasetEditor.gallery.selectEntire",{n:Ga.value})),9,_r),a("button",{type:"button",role:"menuitem",disabled:!Ee.value.length,onClick:xt},l(e(t)("datasetEditor.gallery.selectFiltered",{n:wa.value})),9,kr),a("button",{type:"button",role:"menuitem",disabled:!_a.value.length,onClick:ho},l(e(t)("datasetEditor.gallery.selectPage",{n:_a.value.length})),9,wr),a("button",{type:"button",role:"menuitem",disabled:!e(T).size,onClick:bo},l(e(t)("datasetEditor.gallery.clearSelection")),9,$r)])):P("",!0)],2)]),e(p)?(d(),v("div",Cr,[(d(!0),v(Q,null,le(_a.value,m=>(d(),v("button",{key:m.relative_path,type:"button",class:Y({active:e(D)===m.relative_path,checked:e(T).has(m.relative_path)}),title:e(t)("datasetEditor.gallery.dblClickHint",{name:m.name}),onClick:ve=>Ja(m,ve),onDblclick:ve=>to(m)},[a("span",{class:Y(["image-grid-check",{checked:e(T).has(m.relative_path)}]),role:"checkbox","aria-checked":e(T).has(m.relative_path),"aria-label":e(t)("datasetEditor.gallery.toggleSelect",{name:m.name}),title:e(t)("datasetEditor.gallery.toggleSelect",{name:m.name}),onClick:De(ve=>Pt(m,ve),["stop"])},[e(T).has(m.relative_path)?(d(),v("i",Mr,"✓")):P("",!0)],10,Tr),a("img",{src:m.thumb_url,alt:m.name,loading:"lazy"},null,8,Sr),a("span",null,l(m.name),1)],42,Dr))),128))])):(d(),v("div",Er,[a("strong",null,l(e(t)("datasetEditor.gallery.emptyTitle")),1),a("span",null,l(e(t)("datasetEditor.gallery.emptyHint")),1)])),a("footer",Pr,[a("button",{type:"button",disabled:e(q)===1,onClick:r[10]||(r[10]=m=>q.value=1)},l(e(t)("datasetEditor.pager.first")),9,Vr),a("button",{type:"button",disabled:e(q)===1,onClick:r[11]||(r[11]=m=>q.value--)},l(e(t)("datasetEditor.pager.prev")),9,Ur),a("span",null,l(e(q))+" / "+l(ca.value),1),a("button",{type:"button",disabled:e(q)===ca.value,onClick:r[12]||(r[12]=m=>q.value++)},l(e(t)("datasetEditor.pager.next")),9,xr),a("button",{type:"button",disabled:e(q)===ca.value,onClick:r[13]||(r[13]=m=>q.value=ca.value)},l(e(t)("datasetEditor.pager.last")),9,Fr),b(e(Ke),{modelValue:C.value,"onUpdate:modelValue":r[14]||(r[14]=m=>C.value=m),class:"dataset-page-size","aria-label":e(t)("datasetEditor.pager.perPage",{size:C.value})},{default:O(()=>[(d(),v(Q,null,le([24,48,96,192],m=>b(e(ye),{key:m,value:m,label:e(t)("datasetEditor.pager.perPage",{size:m})},null,8,["value","label"])),64))]),_:1},8,["modelValue","aria-label"])])])]),a("aside",{class:Y(["dataset-tool-panel",[`is-${e(H)}`,{glass:e(H)!=="caption"}]]),"aria-label":Tt.value},[a("header",Ir,[a("strong",null,l(Tt.value),1),a("button",{type:"button",class:"dataset-tool-panel-close","aria-label":e(t)("datasetEditor.filter.close"),onClick:Jl}," × ",8,Ar)]),e(H)==="caption"?(d(),v("div",Br,[Ce.value?(d(),v("div",Rr,[a("div",Nr,[a("img",{class:"caption-preview",src:Ce.value.thumb_url+"&size=512",alt:Ce.value.name,title:e(t)("datasetEditor.caption.previewTip"),onClick:r[15]||(r[15]=m=>M.value=!0)},null,8,Or),a("span",qr,[a("span",{class:"caption-filename",title:Ce.value.relative_path},l(Ce.value.name),9,zr),a("small",Gr,l(e(t)("datasetEditor.caption.previewTip")),1)])]),Oe.value?(d(),v("div",Hr,[a("a",{href:e(ot)(Oe.value,Ce.value.relative_path),download:""},l(e(t)("datasetEditor.caption.downloadImage")),9,Kr),Ce.value.caption_exists?(d(),v("a",{key:0,href:e(ot)(Oe.value,Ce.value.relative_path.replace(/\.[^.]+$/,".txt")),download:""},l(e(t)("datasetEditor.caption.downloadCaption")),9,jr)):P("",!0)])):P("",!0),b(qs,{enabled:e(se),available:Ea.value,"unavailable-hint":Et.value,loading:e(y),error:e(V),"progress-completed":e($e).completed,"progress-total":e($e).total,"progress-unresolved":e(K),"onUpdate:enabled":Ll},null,8,["enabled","available","unavailable-hint","loading","error","progress-completed","progress-total","progress-unresolved"]),a("div",{class:"caption-mode",role:"group","aria-label":e(t)("datasetEditor.caption.modeAria")},[a("button",{type:"button",class:Y({active:he.value==="tags"}),"aria-pressed":he.value==="tags",onClick:r[16]||(r[16]=m=>he.value="tags")},l(e(t)("datasetEditor.caption.modeTags")),11,Yr),a("button",{type:"button",class:Y({active:he.value==="raw"}),"aria-pressed":he.value==="raw",onClick:r[17]||(r[17]=m=>he.value="raw")},l(e(t)("datasetEditor.caption.modeRaw")),11,Jr)],8,Wr),he.value==="tags"?(d(),v(Q,{key:1},[a("div",{class:"caption-chips",onDragover:Zl},[(d(!0),v(Q,null,le(Dl.value,(m,ve)=>(d(),v("span",{key:`${ve}:${m}`,class:Y(["chip",{dragging:pa.value===ve}]),draggable:"true",title:e(t)("datasetEditor.caption.dragTip"),onDragstart:qe=>Ql(ve,qe),onDrop:qe=>eo(ve,qe),onDragend:ao},[a("span",Qr,l(m),1),e(se)&&e(Ve)(m,e(I))?(d(),v("small",Zr,l(e(Ve)(m,e(I))),1)):P("",!0),a("button",{type:"button","aria-label":e(t)("datasetEditor.caption.removeAria",{tag:m}),onClick:qe=>Xl(m),onMousedown:r[18]||(r[18]=De(()=>{},["stop"]))},"×",40,ei)],42,Xr))),128))],32),a("div",ai,[b(e(Ae),{modelValue:ae.value,"onUpdate:modelValue":r[19]||(r[19]=m=>ae.value=m),placeholder:e(t)("datasetEditor.caption.addPlaceholder"),onKeyup:oa(St,["enter"])},null,8,["modelValue","placeholder"]),a("button",{type:"button",onClick:St},l(e(t)("datasetEditor.caption.add")),1)]),a("small",ti,l(e(t)("datasetEditor.caption.dragHint")),1)],64)):(d(),v("div",li,[b(e(Ae),{modelValue:S.value,"onUpdate:modelValue":r[20]||(r[20]=m=>S.value=m),type:"textarea",autosize:{minRows:4,maxRows:24},"aria-label":e(t)("datasetEditor.caption.modeRaw")},null,8,["modelValue","aria-label"]),a("small",oi,l(e(t)("datasetEditor.caption.chars",{n:S.value.length})),1)])),a("button",{type:"button",class:"primary-action",onClick:vo},l(e(t)("datasetEditor.caption.save")),1)])):(d(),v("p",si,l(e(t)("datasetEditor.caption.empty")),1))])):e(H)==="filter"?(d(),v("div",ni,[a("label",null,[U(l(e(t)("datasetEditor.queryLabel"))+" ",1),b(e(Ae),{modelValue:e(w),"onUpdate:modelValue":r[21]||(r[21]=m=>aa(w)?w.value=m:null),placeholder:e(t)("datasetEditor.filter.queryPlaceholder")},null,8,["modelValue","placeholder"])]),a("label",null,[U(l(e(t)("datasetEditor.categoryLabel"))+" ",1),b(e(Ke),{modelValue:e(k),"onUpdate:modelValue":r[22]||(r[22]=m=>aa(k)?k.value=m:null)},{default:O(()=>[b(e(ye),{value:"",label:`${e(t)("datasetEditor.allCategories")} (${Ga.value})`},null,8,["label"]),(d(!0),v(Q,null,le(e($),m=>(d(),oe(e(ye),{key:m.value||"__root__",value:m.value,label:`${m.name} (${m.count})`},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),b(Fs,{tags:e(Vl),"selected-tags":e(ge).selectedTags,logic:e(ge).logic,search:e(ge).search,"search-mode":e(ge).searchMode,"sort-by":e(ge).sortBy,order:e(ge).order,"exclude-input":e(ge).excludeInput,"filtered-count":Ee.value.length,"show-select-all":!1,"translation-enabled":e(se),"translation-provider":e(I),"onUpdate:logic":r[23]||(r[23]=m=>e(ge).logic=m),"onUpdate:search":r[24]||(r[24]=m=>e(ge).search=m),"onUpdate:searchMode":r[25]||(r[25]=m=>e(ge).searchMode=m),"onUpdate:sortBy":r[26]||(r[26]=m=>e(ge).sortBy=m),"onUpdate:order":r[27]||(r[27]=m=>e(ge).order=m),"onUpdate:excludeInput":r[28]||(r[28]=m=>e(ge).excludeInput=m),onToggleTag:e(xl),onClear:e(yt)},null,8,["tags","selected-tags","logic","search","search-mode","sort-by","order","exclude-input","filtered-count","translation-enabled","translation-provider","onToggleTag","onClear"]),a("div",ri,[a("button",{type:"button",class:"dataset-tool-secondary",disabled:!ka.value,onClick:yo},l(e(t)("datasetEditor.filter.clearAll")),9,ii),a("button",{type:"button",class:"primary-action",onClick:Ya},l(e(t)("datasetEditor.filter.done")),1)])])):(d(),v("div",di,[a("p",ui,l(e(T).size?e(t)("datasetEditor.batch.selected",{n:e(T).size}):e(t)("datasetEditor.batch.filtered",{n:Ee.value.length})),1),b(e(Ae),{modelValue:J.value,"onUpdate:modelValue":r[29]||(r[29]=m=>J.value=m),placeholder:e(t)("datasetEditor.batch.appendPlaceholder")},null,8,["modelValue","placeholder"]),b(e(Ke),{modelValue:ue.value,"onUpdate:modelValue":r[30]||(r[30]=m=>ue.value=m),"aria-label":e(t)("datasetEditor.batch.position")},{default:O(()=>[b(e(ye),{value:"back",label:e(t)("datasetEditor.batch.positionBack")},null,8,["label"]),b(e(ye),{value:"front",label:e(t)("datasetEditor.batch.positionFront")},null,8,["label"])]),_:1},8,["modelValue","aria-label"]),b(e(Ae),{modelValue:W.value,"onUpdate:modelValue":r[31]||(r[31]=m=>W.value=m),placeholder:e(t)("datasetEditor.batch.removePlaceholder")},null,8,["modelValue","placeholder"]),a("div",ci,[b(e(Ae),{modelValue:pe.value,"onUpdate:modelValue":r[32]||(r[32]=m=>pe.value=m),placeholder:e(t)("datasetEditor.batch.replaceFrom")},null,8,["modelValue","placeholder"]),b(e(Ae),{modelValue:de.value,"onUpdate:modelValue":r[33]||(r[33]=m=>de.value=m),placeholder:e(t)("datasetEditor.batch.replaceTo")},null,8,["modelValue","placeholder"])]),a("label",null,[U(l(e(t)("datasetEditor.batch.clean")),1),b(e(ha),{modelValue:me.value,"onUpdate:modelValue":r[34]||(r[34]=m=>me.value=m),"aria-label":e(t)("datasetEditor.batch.clean")},null,8,["modelValue","aria-label"])]),a("label",null,[U(l(e(t)("datasetEditor.batch.underscore")),1),b(e(ha),{modelValue:ke.value,"onUpdate:modelValue":r[35]||(r[35]=m=>ke.value=m),"aria-label":e(t)("datasetEditor.batch.underscore")},null,8,["modelValue","aria-label"])]),a("label",null,[U(l(e(t)("datasetEditor.batch.stripEscape")),1),b(e(ha),{modelValue:we.value,"onUpdate:modelValue":r[36]||(r[36]=m=>we.value=m),"aria-label":e(t)("datasetEditor.batch.stripEscape")},null,8,["modelValue","aria-label"])]),a("label",null,[U(l(e(t)("datasetEditor.batch.sort")),1),b(e(ha),{modelValue:_e.value,"onUpdate:modelValue":r[37]||(r[37]=m=>_e.value=m),"aria-label":e(t)("datasetEditor.batch.sort")},null,8,["modelValue","aria-label"])]),a("div",vi,[Oe.value?(d(),v("button",{key:0,type:"button",class:"danger-action",disabled:!Ie.value.length,onClick:go},l(e(t)("datasetEditor.batch.deleteFiles",{n:Ie.value.length})),9,pi)):P("",!0),a("button",{type:"button",class:"dataset-tool-secondary",onClick:Ya},l(e(t)("datasetEditor.batch.cancel")),1),a("button",{type:"button",class:"primary-action",disabled:!Ie.value.length,onClick:po},l(e(t)("datasetEditor.batch.applyTo",{n:Ie.value.length})),9,gi)])]))],10,Lr)],2),M.value&&Ce.value?(d(),v("div",{key:0,class:"dataset-lightbox",role:"dialog","aria-label":e(t)("datasetEditor.caption.previewAria"),onClick:r[38]||(r[38]=m=>M.value=!1)},[a("img",{src:Ce.value.image_url,alt:Ce.value.name},null,8,mi)],8,fi)):P("",!0),b(nn,{"model-value":je.value,loading:We.value,error:ua.value,provider:e(I),"llm-mode":Ne.value,dictionary:X.value,"dictionary-busy":ne.value,"onUpdate:modelValue":Gl,"onUpdate:provider":Bl,"onUpdate:llmMode":Al,onCheckDictionary:Hl,onUpdateDictionary:Kl,onRetryDictionary:jl,onCancelDictionary:Wl},null,8,["model-value","loading","error","provider","llm-mode","dictionary","dictionary-busy"]),b(B,{modelValue:N.value,"onUpdate:modelValue":r[39]||(r[39]=m=>N.value=m),title:e(t)("datasetEditor.historyDialog.title"),width:"min(820px, 94vw)"},{default:O(()=>[a("div",hi,[(d(!0),v(Q,null,le(e(ee).changes,m=>(d(),v("article",{key:`${m.label}-${m.items[0]?.image}`},[a("header",null,[a("strong",null,l(m.label),1),a("span",null,l(e(t)("datasetEditor.historyDialog.count",{n:m.count})),1)]),a("details",null,[a("summary",null,l(e(t)("datasetEditor.historyDialog.detail")),1),(d(!0),v(Q,null,le(m.items,ve=>(d(),v("div",{key:ve.image},[a("code",null,l(ve.image),1),a("del",null,l(ve.before||e(t)("datasetEditor.historyDialog.noCaption")),1),a("ins",null,l(ve.after||e(t)("datasetEditor.historyDialog.noCaption")),1)]))),128))])]))),128)),e(ee).changes.length?P("",!0):(d(),v("p",bi,l(e(t)("datasetEditor.historyDialog.empty")),1))])]),_:1},8,["modelValue","title"])],64)}}}),_i={class:"trash-dialog"},ki={key:0,class:"trash-empty"},wi={class:"trash-batch-header"},$i={key:0,class:"trash-batch-dataset"},Ei={class:"trash-batch-actions"},Ci=["disabled","onClick"],Di=["disabled","onClick"],Ti={class:"trash-batch-paths"},Mi=["disabled"],Si=["disabled"],Pi=Se({__name:"DatasetTrashDialog",props:{modelValue:{type:Boolean},datasetName:{}},emits:["update:modelValue","changed"],setup(s,{emit:t}){const n=s,u=t,{t:o}=xe(),h=A(()=>!n.datasetName),p=A(()=>n.datasetName?o("datasetTrash.title",{name:n.datasetName}):o("datasetTrash.titleGlobal")),f=g([]),c=g(!1),$=g("");Me(()=>n.modelValue,E=>{E&&k()});async function k(){c.value=!0;try{const E=n.datasetName?await te.trash(n.datasetName):await te.trashAll();f.value=E.batches}catch(E){F.error(E instanceof Error?E.message:o("datasetTrash.msg.loadFail"))}finally{c.value=!1}}function w(E){if(!E)return"-";const S=new Date(E);return Number.isNaN(S.getTime())?"-":S.toLocaleString()}async function D(E){if(!$.value){$.value=E.id;try{const S=n.datasetName?await te.restoreTrash(n.datasetName,E.id):await te.restoreTrashAny(E.id);S.restored.length&&(F.success(o("datasetTrash.msg.restored",{n:S.restored.length})),u("changed")),S.conflicts.length&&F.warning(o("datasetTrash.msg.conflicts",{n:S.conflicts.length})),await k()}catch(S){F.error(S instanceof Error?S.message:o("datasetTrash.msg.fail"))}finally{$.value=""}}}async function T(E){if(!$.value){try{await Ge.confirm(o("datasetTrash.confirmDeleteBatch",{count:E.count}),{type:"warning"})}catch{return}$.value=E.id;try{n.datasetName?await te.emptyTrash(n.datasetName,E.id):await te.emptyTrashAny(E.id),F.success(o("datasetTrash.msg.emptied")),await k()}catch(S){F.error(S instanceof Error?S.message:o("datasetTrash.msg.fail"))}finally{$.value=""}}}async function z(){if(!($.value||!f.value.length)){try{await Ge.confirm(o("datasetTrash.confirmEmptyAll"),{type:"warning"})}catch{return}$.value="*";try{n.datasetName?await te.emptyTrash(n.datasetName):await te.emptyTrashAny(),F.success(o("datasetTrash.msg.emptyDone")),await k()}catch(E){F.error(E instanceof Error?E.message:o("datasetTrash.msg.fail"))}finally{$.value=""}}}return(E,S)=>{const G=be("ElDialog"),J=Ro("loading");return d(),oe(G,{"model-value":s.modelValue,title:p.value,width:"560px","onUpdate:modelValue":S[1]||(S[1]=W=>u("update:modelValue",W))},{footer:O(()=>[a("button",{class:"secondary-action",disabled:!!$.value,onClick:S[0]||(S[0]=W=>u("update:modelValue",!1))},l(e(o)("datasetTrash.close")),9,Mi),a("button",{class:"danger-action",disabled:!!$.value||!f.value.length,onClick:z},l(e(o)("datasetTrash.emptyAll")),9,Si)]),default:O(()=>[ie((d(),v("div",_i,[!f.value.length&&!c.value?(d(),v("p",ki,l(e(o)("datasetTrash.empty")),1)):P("",!0),(d(!0),v(Q,null,le(f.value,W=>(d(),v("article",{key:W.id,class:"trash-batch"},[a("header",wi,[a("span",null,[h.value?(d(),v("strong",$i,l(W.dataset),1)):P("",!0),U(" "+l(e(o)("datasetTrash.batchInfo",{count:W.count,time:w(W.deleted_at)})),1)]),a("span",Ei,[a("button",{class:"secondary-action",disabled:!!$.value,onClick:pe=>D(W)},l(e(o)("datasetTrash.restore")),9,Ci),a("button",{class:"danger-action",disabled:!!$.value,onClick:pe=>T(W)},l(e(o)("datasetTrash.deleteBatch")),9,Di)])]),a("ul",Ti,[(d(!0),v(Q,null,le(W.paths,pe=>(d(),v("li",{key:pe},l(pe),1))),128))])]))),128))])),[[J,c.value]])]),_:1},8,["model-value","title"])}}}),Vi={class:"dataset-directory-node"},Ui={class:"dataset-directory-line"},xi=["aria-label","aria-expanded"],Fi=["title","disabled"],Li={key:0},Ii={key:0,class:"dataset-tree-hint"},Ai={key:1,class:"dataset-tree-hint"},Bi=Se({__name:"DatasetDirectoryNode",props:{name:{},path:{},locked:{type:Boolean}},emits:["select"],setup(s,{emit:t}){const n=s,u=t,{t:o}=xe(),h=g(!1),p=g(!1),f=g(!1),c=g([]);async function $(){if(h.value=!h.value,!!h.value){p.value=!0,f.value=!1;try{c.value=(await rs.list(n.path,"folder")).entries.filter(k=>k.type==="dir")}catch{f.value=!0}finally{p.value=!1}}}return(k,w)=>{const D=be("DatasetDirectoryNode",!0);return d(),v("li",Vi,[a("div",Ui,[a("button",{class:"dataset-icon-button","aria-label":s.name,"aria-expanded":h.value,onClick:$},[p.value?(d(),oe(e(al),{key:0,class:"is-loading"})):(d(),oe(e(No),{key:1,class:Y({expanded:h.value})},null,8,["class"]))],8,xi),a("button",{class:"dataset-directory-name",title:s.path,disabled:s.locked,onClick:w[0]||(w[0]=T=>u("select",s.path))},[b(e(la)),a("span",null,l(s.name),1)],8,Fi)]),h.value?(d(),v("ul",Li,[f.value?(d(),v("li",Ii,l(e(o)("datasetManage.loadErrorTitle")),1)):!p.value&&!c.value.length?(d(),v("li",Ai,l(e(o)("datasetManage.noSubfolders")),1)):P("",!0),(d(!0),v(Q,null,le(c.value,T=>(d(),oe(D,{key:T.path,name:T.name,path:T.path,locked:s.locked,onSelect:w[1]||(w[1]=z=>u("select",z))},null,8,["name","path","locked"]))),128))])):P("",!0)])}}});function _l(){const s=g(!1);let t=0;const n=f=>Array.from(f.dataTransfer?.types??[]).includes("Files");function u(f){n(f)&&(t+=1,s.value=!0)}function o(f){n(f)&&(t=Math.max(0,t-1),t||(s.value=!1))}function h(f){n(f)&&f.preventDefault()}function p(){t=0,s.value=!1}return{active:s,onDragEnter:u,onDragLeave:o,onDragOver:h,onDrop:p}}const kl=".png,.jpg,.jpeg,.webp,.bmp,.txt",Ri=kl.split(",");function Ni(s){const t=s.toLowerCase();return Ri.some(n=>t.endsWith(n))}function st(s,t=!1){return Array.from(s).map(n=>({file:n,path:t&&n.webkitRelativePath||n.name}))}async function wl(s,t,n){if(s.isFile){const u=await new Promise((o,h)=>s.file(o,h));n.push({file:u,path:t+u.name});return}if(s.isDirectory){const u=s.createReader();for(;;){const o=await new Promise((h,p)=>u.readEntries(h,p));if(!o.length)return;for(const h of o)await wl(h,`${t}${s.name}/`,n)}}}async function bt(s){const t=s?.items;if(t){const n=[];for(const u of Array.from(t)){const o=u.webkitGetAsEntry?.();o&&n.push(o)}if(n.length){const u=[];for(const o of n)await wl(o,"",u);return u}}return st(s?.files??[])}function $l(s){const t=s.filter(n=>Ni(n.path));return{accepted:t,ignored:s.length-t.length}}function Oi(s){const t=s.map(u=>u.path.split("/")),n=t[0];return!n||n.length<2||!n[0]?null:t.every(u=>u.length>1&&u[0]===n[0])?n[0]:null}const qi=["aria-label"],zi=["title","aria-label"],Gi={class:"dataset-tree-root"},Hi=["title"],Ki=["title","aria-label"],ji={class:"dataset-directory-tree"},Wi={class:"dataset-manage dataset-list-main"},Yi={class:"dataset-list-heading"},Ji=["title","aria-label"],Xi={class:"dataset-count"},Qi=["disabled"],Zi={class:"dataset-list-toolbar"},ed={class:"dataset-search"},ad=["placeholder","aria-label"],td=["aria-label"],ld={value:"updated"},od={value:"created"},sd={value:"images"},nd={class:"dataset-location-row"},rd=["title"],id={class:"dataset-location-actions"},dd=["title","aria-label","disabled"],ud={class:"dataset-manage-autorefresh"},cd=["aria-busy"],vd={class:"dataset-manage-empty-icon","aria-hidden":"true"},pd=["disabled"],gd={key:1,class:"dataset-table-scroll"},fd={class:"dataset-table"},md={class:"dataset-visually-hidden"},hd=["data-dataset-name"],bd=["disabled","title","onClick"],yd={key:0,class:"dataset-card-in-use"},_d=["aria-label","title"],kd={key:0},wd={colspan:"5",class:"dataset-no-results"},$d={key:2,class:"dataset-list-count"},Ed={class:"dataset-manage-dialog-hint"},Cd=["disabled"],Dd=["disabled"],Td={key:1,class:"dataset-drop-overlay","aria-hidden":"true"},Md={key:0},Sd=1500,Pd=15e3,Gt="dataset-manage-auto-refresh",Vd=Se({__name:"DatasetManagePage",setup(s){const{t}=xe(),n=ct(),u=g(""),o=g(!0),h=g([]),p=g(!0),f=g(!1),c=g(!1),$=g(!1),k=g(""),w=g(!1),D=g(!1),T=g(""),z=g(!1),E=g(!1),S=g(!1),G=g(localStorage.getItem(Gt)==="1"),J=g(localStorage.getItem("dataset-tree-open")==="1"||localStorage.getItem("dataset-tree-open")!=="0"&&window.innerWidth>760),W=g(""),pe=g("updated"),{active:de,onDragEnter:me,onDragLeave:_e,onDragOver:ke,onDrop:we}=_l(),Z=g(null),ue=g(!1),ae=g(0);Me(J,x=>localStorage.setItem("dataset-tree-open",x?"1":"0"));const q=A(()=>{const x=W.value.trim().toLocaleLowerCase();return h.value.filter(_=>_.name.toLocaleLowerCase().includes(x)).sort((_,j)=>{const ce=X=>pe.value==="images"?X.overview?.file_count??-1:pe.value==="created"?Date.parse(X.created_at||"")||0:Math.max(Date.parse(X.overview?.updated_at||"")||0,Date.parse(X.updated_at||"")||0);return ce(j)-ce(_)||_.name.localeCompare(j.name)})}),C=A(()=>u.value.replace(/\\/g,"/").split("/").filter(Boolean).pop()||"datasets");function N(x){const _=ne=>ne.replace(/\\/g,"/").replace(/\/$/,""),j=_(x),ce=h.value.find(ne=>j===_(ne.path)||j.startsWith(`${_(ne.path)}/`));if(!ce)return;const X=j.slice(_(ce.path).length).replace(/^\//,"");n.push({path:"/dataset/manage",query:{dataset:ce.name,...X?{directory:X}:{}}})}function H(x,_){x==="manage"?N(_.path):_.in_use||(x==="rename"?ua(_):x==="delete"&&na(_))}let L;function ee(x){if(x==null)return"-";if(x<1024)return`${x} B`;const _=["KB","MB","GB","TB"];let j=x/1024,ce=0;for(;j>=1024&&ce<_.length-1;)j/=1024,ce+=1;return`${j.toFixed(j>=100?0:1)} ${_[ce]}`}function M(x){if(!x)return"-";const _=new Date(x);return Number.isNaN(_.getTime())?"-":_.toLocaleString()}function se(x){return x.overview}function he(x,_){const j=se(x);return!j||j.state!=="ready"?j?.state==="error"?"!":"…":_==="total_bytes"?ee(j.total_bytes):_==="updated_at"?M(j.updated_at):j[_]??"-"}function I(x){const _=x.overview;if(!_||_.state!=="ready")return!0;const j=_.computed_at?Date.parse(_.computed_at):0;return Date.now()-j>Pd}function y(){return h.value.some(x=>!x.overview||x.overview.state==="computing")}async function V(){try{const x=await te.list(),_=new Map(x.datasets.map(j=>[j.name,j.in_use===!0]));for(const j of h.value)j.in_use=_.get(j.name)??!1}catch{}}async function $e(x=!1){const _=x?h.value:h.value.filter(I);await Promise.all([V(),..._.map(async j=>{try{const ce=await te.overview(j.name,x);j.overview=ce.overview}catch{j.overview={state:"error",file_count:null,captioned_count:null,total_bytes:null,updated_at:null,error:"request failed"}}})]),!G.value&&!y()&&K()}function K(){window.clearInterval(L),L=void 0}function da(){L===void 0&&(L=window.setInterval(()=>{$e()},Sd))}Me(G,x=>{localStorage.setItem(Gt,x?"1":"0"),x?da():y()||K()});async function Ve(x=!1){if(!c.value){f.value=!1,x?c.value=!0:p.value=!0;try{const _=await te.list();u.value=_.root,o.value=_.exists,h.value=_.datasets,$e(!0).then(()=>{(G.value||y())&&da()})}catch(_){f.value=!0,F.error(_ instanceof Error?_.message:t("datasetManage.msg.loadFail"))}finally{p.value=!1,c.value=!1}}}function Be(){k.value=u.value,$.value=!0}async function je(){if(!(!k.value.trim()||w.value)){w.value=!0;try{const x=await te.updateRoot(k.value.trim());u.value=x.root,o.value=x.exists,$.value=!1,F.success(t("datasetManage.msg.rootSaved")),await Ve(!0)}catch(x){F.error(x instanceof Error?x.message:t("datasetManage.msg.rootSaveFail"))}finally{w.value=!1}}}async function We(){const x=T.value.trim();if(!(!x||z.value)){z.value=!0;try{await te.create(x),D.value=!1,T.value="",F.success(t("datasetManage.msg.created")),await Ve(!0)}catch(_){F.error(_ instanceof Error?_.message:t("datasetManage.msg.createFail"))}finally{z.value=!1}}}async function ua(x){if(S.value)return;let _;try{_=(await Ge.prompt(t("datasetManage.rename"),{inputValue:x.name,inputValidator:ce=>!!ce?.trim()||t("datasetManage.createPlaceholder")})).value.trim()}catch{return}if(_!==x.name){S.value=!0;try{await te.rename(x.name,_),F.success(t("datasetManage.renamed")),await Ve(!0)}catch(j){F.error(j instanceof Error?j.message:String(j))}finally{S.value=!1}}}async function na(x){try{await Ge.confirm(t("datasetManage.confirmDelete",{name:x.name}),{type:"warning"})}catch{return}try{const _=await te.deleteDataset(x.name);F.success(t("datasetManage.msg.deleted",{n:_.deleted.length})),await Ve(!0)}catch(_){F.error(_ instanceof Error?_.message:t("datasetManage.msg.deleteFail"))}}function Re(){Ve(!0)}function Ye(x){ke(x);const _=x.target?.closest?.("[data-dataset-name]")??null;Z.value=_?.getAttribute("data-dataset-name")??null}async function Ne(x){const _=Z.value;if(Z.value=null,we(),ue.value)return;if(_&&h.value.find(ne=>ne.name===_)?.in_use){F.error(t("datasetDrop.inUse"));return}const{accepted:j,ignored:ce}=$l(await bt(x.dataTransfer));if(!j.length){F.error(t("datasetDrop.noneAccepted"));return}let X=_;if(!X)try{X=(await Ge.prompt(t("datasetDrop.needsName"),t("datasetManage.create"),{inputValue:Oi(j)??"",inputPattern:/\S+/,inputErrorMessage:t("datasetManage.createPlaceholder"),confirmButtonText:t("datasetManage.createConfirm"),cancelButtonText:t("datasetManage.cancel")})).value.trim()}catch{return}ue.value=!0,ae.value=0;try{try{await te.create(X)}catch{}const ne=await te.upload(X,j,"skip",Le=>{ae.value=Le}),Pe=t("datasetUpload.resultSummary",{ok:ne.succeeded.length,skipped:ne.skipped.length,failed:ne.failed.length});F.success(ce?`${Pe} · ${t("datasetDrop.ignored",{n:ce})}`:Pe),await Ve(!0)}catch(ne){F.error(ne instanceof Error?ne.message:t("datasetUpload.msg.uploadFail"))}finally{ue.value=!1}}return La(()=>{Ve()}),vt(K),Ba(K),(x,_)=>{const j=be("ElSwitch"),ce=be("ElDropdownItem"),X=be("ElDropdownMenu"),ne=be("ElDropdown"),Pe=be("ElInput"),Le=be("ElDialog");return d(),v("div",{class:Y(["dataset-manager-workspace",{"tree-collapsed":!J.value,"is-drop-active":e(de)}]),onDragenter:_[17]||(_[17]=De((...R)=>e(me)&&e(me)(...R),["prevent"])),onDragover:Ye,onDragleave:_[18]||(_[18]=De((...R)=>e(_e)&&e(_e)(...R),["prevent"])),onDrop:De(Ne,["prevent"])},[J.value?(d(),v("aside",{key:0,class:"dataset-explorer","aria-label":e(t)("datasetManage.explorer")},[a("header",null,[a("strong",null,l(e(t)("datasetManage.explorer")),1),a("button",{class:"dataset-icon-button",title:e(t)("datasetManage.collapseTree"),"aria-label":e(t)("datasetManage.collapseTree"),onClick:_[0]||(_[0]=R=>J.value=!1)},[b(e(Oo))],8,zi)]),a("div",Gi,[b(e(Za)),a("span",{title:u.value},l(C.value),9,Hi),a("button",{class:"dataset-icon-button",title:e(t)("datasetManage.rootSettings"),"aria-label":e(t)("datasetManage.rootSettings"),onClick:Be},[b(e(ba))],8,Ki)]),a("ul",ji,[(d(!0),v(Q,null,le(h.value,R=>(d(),oe(Bi,{key:R.path,name:R.name,path:R.path,locked:R.in_use,onSelect:N},null,8,["name","path","locked"]))),128))]),a("button",{class:"dataset-trash-link",onClick:_[1]||(_[1]=R=>E.value=!0)},[b(e(qo)),U(l(e(t)("datasetManage.trash")),1)])],8,qi)):P("",!0),a("main",Wi,[a("header",Yi,[a("div",null,[J.value?P("",!0):(d(),v("button",{key:0,class:"dataset-icon-button",title:e(t)("datasetManage.explorer"),"aria-label":e(t)("datasetManage.explorer"),onClick:_[2]||(_[2]=R=>J.value=!0)},[b(e(zo))],8,Ji)),a("h2",null,l(e(t)("datasetManage.title")),1),a("span",Xi,l(h.value.length),1)]),a("button",{class:"primary-action",disabled:p.value||f.value||!o.value,onClick:_[3]||(_[3]=R=>D.value=!0)},[b(e(Rt)),U(l(e(t)("datasetManage.create")),1)],8,Qi)]),a("div",Zi,[a("label",ed,[b(e(Go)),ie(a("input",{"onUpdate:modelValue":_[4]||(_[4]=R=>W.value=R),placeholder:e(t)("datasetManage.search"),"aria-label":e(t)("datasetManage.search")},null,8,ad),[[ze,W.value]])]),ie(a("select",{"onUpdate:modelValue":_[5]||(_[5]=R=>pe.value=R),"aria-label":e(t)("datasetManage.sort")},[a("option",ld,l(e(t)("datasetManage.sortUpdated")),1),a("option",od,l(e(t)("datasetManage.sortCreated")),1),a("option",sd,l(e(t)("datasetManage.sortImages")),1)],8,td),[[Ua,pe.value]])]),a("div",nd,[a("button",{title:u.value,onClick:Be},[b(e(Za)),a("span",null,l(u.value||C.value),1),b(e(ba))],8,rd),a("div",id,[a("button",{class:"dataset-icon-button",title:e(t)("datasetManage.refresh"),"aria-label":e(t)("datasetManage.refresh"),disabled:p.value||c.value,onClick:_[6]||(_[6]=R=>Ve(!0))},[b(e(tt),{class:Y({"is-loading":c.value})},null,8,["class"])],8,dd),a("label",ud,[b(j,{modelValue:G.value,"onUpdate:modelValue":_[7]||(_[7]=R=>G.value=R)},null,8,["modelValue"]),a("span",null,l(e(t)("datasetManage.autoRefresh")),1)])])]),p.value||!h.value.length&&c.value||f.value||!o.value||!h.value.length?(d(),v("section",{key:0,class:"dataset-manage-empty",role:"status","aria-live":"polite","aria-busy":p.value||c.value},[a("div",vd,[p.value||!h.value.length&&c.value?(d(),oe(e(al),{key:0,class:"is-loading"})):f.value||!o.value?(d(),oe(e(Ho),{key:1})):(d(),oe(e(Za),{key:2}))]),a("h2",null,l(e(t)(p.value||!h.value.length&&c.value?"datasetManage.loadingTitle":f.value?"datasetManage.loadErrorTitle":o.value?"datasetManage.emptyTitle":"datasetManage.missingTitle")),1),!p.value&&!(!h.value.length&&c.value)?(d(),v(Q,{key:0},[a("p",null,l(e(t)(f.value?"datasetManage.loadErrorHint":o.value?"datasetManage.emptyHint":"datasetManage.missingHint")),1),f.value?(d(),v("button",{key:0,class:"primary-action",disabled:c.value,onClick:_[8]||(_[8]=R=>Ve(!0))},[b(e(tt)),U(l(e(t)("datasetManage.retry")),1)],8,pd)):o.value?(d(),v("button",{key:2,class:"primary-action",onClick:_[9]||(_[9]=R=>D.value=!0)},[b(e(Rt)),U(l(e(t)("datasetManage.create")),1)])):(d(),v("button",{key:1,class:"primary-action",onClick:Be},[b(e(ba)),U(l(e(t)("datasetManage.rootSettings")),1)]))],64)):P("",!0)],8,cd)):(d(),v("div",gd,[a("table",fd,[a("thead",null,[a("tr",null,[a("th",null,l(e(t)("datasetManage.name")),1),a("th",null,l(e(t)("datasetManage.files")),1),a("th",null,l(e(t)("datasetManage.captioned")),1),a("th",null,l(e(t)("datasetManage.updatedAt")),1),a("th",null,[a("span",md,l(e(t)("datasetManage.actions")),1)])])]),a("tbody",null,[(d(!0),v(Q,null,le(q.value,R=>(d(),v("tr",{key:R.name,"data-dataset-name":R.name,class:Y({"is-drop-target":Z.value===R.name})},[a("td",null,[a("button",{class:"dataset-row-name",disabled:R.in_use,title:R.path,onClick:Oe=>N(R.path)},[b(e(la)),a("span",null,l(R.name),1)],8,bd),R.in_use?(d(),v("span",yd,l(e(t)("datasetManage.inUse")),1)):P("",!0)]),a("td",null,l(he(R,"file_count")),1),a("td",null,l(he(R,"captioned_count")),1),a("td",null,l(he(R,"updated_at")),1),a("td",null,[b(ne,{trigger:"click",onCommand:Oe=>H(Oe,R)},{dropdown:O(()=>[b(X,null,{default:O(()=>[b(ce,{command:"manage"},{default:O(()=>[U(l(e(t)("datasetManage.manage")),1)]),_:1}),b(ce,{command:"rename",disabled:R.in_use||S.value},{default:O(()=>[U(l(e(t)("datasetManage.rename")),1)]),_:1},8,["disabled"]),b(ce,{command:"delete",disabled:R.in_use,divided:""},{default:O(()=>[U(l(e(t)("datasetManage.deleteDataset")),1)]),_:1},8,["disabled"])]),_:2},1024)]),default:O(()=>[a("button",{class:"dataset-icon-button","aria-label":e(t)("datasetManage.actions")+": "+R.name,title:e(t)("datasetManage.actions")},[b(e(Ko))],8,_d)]),_:2},1032,["onCommand"])])],10,hd))),128)),q.value.length?P("",!0):(d(),v("tr",kd,[a("td",wd,l(e(t)("datasetManage.noResults")),1)]))])])])),h.value.length&&!f.value?(d(),v("footer",$d,l(e(t)("datasetManage.total",{n:q.value.length})),1)):P("",!0)]),b(Le,{modelValue:$.value,"onUpdate:modelValue":_[12]||(_[12]=R=>$.value=R),title:e(t)("datasetManage.rootDialogTitle"),width:"480px"},{footer:O(()=>[a("button",{class:"secondary-action",onClick:_[11]||(_[11]=R=>$.value=!1)},l(e(t)("datasetManage.cancel")),1),a("button",{class:"primary-action",disabled:w.value||!k.value.trim(),onClick:je},l(e(t)("datasetManage.save")),9,Cd)]),default:O(()=>[b(Pe,{modelValue:k.value,"onUpdate:modelValue":_[10]||(_[10]=R=>k.value=R),placeholder:e(t)("datasetManage.rootDialogPlaceholder"),onKeyup:oa(je,["enter"])},null,8,["modelValue","placeholder"]),a("p",Ed,l(e(t)("datasetManage.rootDialogHint")),1)]),_:1},8,["modelValue","title"]),b(Pi,{"model-value":E.value,"onUpdate:modelValue":_[13]||(_[13]=R=>E.value=R),onChanged:Re},null,8,["model-value"]),b(Le,{modelValue:D.value,"onUpdate:modelValue":_[16]||(_[16]=R=>D.value=R),title:e(t)("datasetManage.createDialogTitle"),width:"480px"},{footer:O(()=>[a("button",{class:"secondary-action",onClick:_[15]||(_[15]=R=>D.value=!1)},l(e(t)("datasetManage.cancel")),1),a("button",{class:"primary-action",disabled:z.value||!T.value.trim(),onClick:We},l(e(t)("datasetManage.createConfirm")),9,Dd)]),default:O(()=>[b(Pe,{modelValue:T.value,"onUpdate:modelValue":_[14]||(_[14]=R=>T.value=R),placeholder:e(t)("datasetManage.createPlaceholder"),onKeyup:oa(We,["enter"])},null,8,["modelValue","placeholder"])]),_:1},8,["modelValue","title"]),e(de)?(d(),v("div",Td,[b(e(lt)),a("strong",null,l(Z.value?e(t)("datasetDrop.intoRow",{name:Z.value}):e(t)("datasetDrop.release")),1),a("span",null,l(Z.value?e(t)("datasetDrop.intoRowHint"):e(t)("datasetDrop.blankHint")),1),ue.value?(d(),v("span",Md,l(e(t)("datasetDrop.uploading",{percent:ae.value})),1)):P("",!0)])):P("",!0)],34)}}});function Ht(s){return{...s,download_endpoint:ds(us())}}const ia={models:async()=>(await Nt("/api/tagger/models")).models,status:()=>Nt("/api/tagger/status"),start:s=>Pa("/api/interrogate",{method:"POST",body:JSON.stringify(Ht(s))}),prefetch:s=>Pa("/api/tagger/prefetch",{method:"POST",body:JSON.stringify(Ht({interrogator_model:s}))}),cancel:()=>Pa("/api/tagger/cancel",{method:"POST"}),reset:()=>Pa("/api/tagger/reset",{method:"POST"})},Ud={phase:"idle",message:"",model:"",download:{current:0,total:0,filename:"",bytes_current:0,bytes_total:0,percent:0},tagging:{current:0,total:0,filename:"",bytes_current:0,bytes_total:0,percent:0},updated_at:0},xd=jo("tagger",()=>{const s=g(Ud),t=g(""),n=g(!1),u=A(()=>["downloading","tagging","pending","cancelling"].includes(s.value.phase));async function o(){try{s.value=await ia.status(),t.value=""}catch(p){t.value=p instanceof Error?p.message:Wo.global.t("tagger.msg.statusFail")}}async function h(p){n.value=!0;try{await p(),await o()}finally{n.value=!1}}return{status:s,error:t,submitting:n,busy:u,refresh:o,start:p=>h(()=>ia.start(p)),prefetch:p=>h(()=>ia.prefetch(p)),cancel:()=>h(ia.cancel),reset:()=>h(ia.reset)}}),et="tagger-caption",xa="nt.tagger.captionTemplates",Fd="legacy-tagger-caption:";function Fa(s){const t=s.config.prompt,n=s.config.language;return typeof s.id!="string"||typeof s.name!="string"||typeof t!="string"||typeof n!="string"?null:{id:s.id,name:s.name,prompt:t,language:n}}function at(s){const t=Fa(s);if(!t)throw new Error("Invalid tagger caption preset");return t}function Kt(s){return{name:s.name,config:{prompt:s.prompt,language:s.language}}}function Ld(s){const t=s.getItem(xa);if(t===null)return[];try{const n=JSON.parse(t);return!n||typeof n!="object"||Array.isArray(n)?null:Object.entries(n).filter(u=>typeof u[1]=="string"&&!!u[1].trim())}catch{return null}}function Id(s=cs){async function t(){return s.list(et)}async function n(u,o=localStorage){const h=Ld(o);if(h===null)return[];if(!h.length)return o.getItem(xa)!==null&&o.removeItem(xa),[];const p=[];for(const[f,c]of h){const $=`${Fd}${f}`,k=u.find(D=>D.description===$);if(k){const D=Fa(k);D&&p.push(D);continue}const w=await s.create({name:f,train_type:et,description:$,config:{prompt:c,language:"en"}});p.push(at(w))}return o.removeItem(xa),p}return{async list(){return(await t()).flatMap(u=>{const o=Fa(u);return o?[o]:[]})},async load(u=localStorage){const o=await t(),h=o.flatMap(c=>{const $=Fa(c);return $?[$]:[]}),p=await n(o,u),f=new Set(h.map(c=>c.id));return[...h,...p.filter(c=>!f.has(c.id))]},async create(u){return at(await s.create({...Kt(u),train_type:et}))},async update(u,o){return at(await s.update(u,Kt(o)))},async remove(u){await s.remove(u)},migrateLegacy:n}}const Ad={class:"tagger-form"},Bd={class:"tagger-header-actions"},Rd=["disabled"],Nd=["aria-label","title","aria-expanded"],Od={class:"tagger-grid"},qd={class:"tagger-dataset-path"},zd={class:"path-row"},Gd=["disabled"],Hd={class:"tagger-choice-row"},Kd={class:"tagger-segments"},jd={disabled:""},Wd={class:"tagger-choice-row"},Yd={class:"tagger-segments"},Jd={class:"selected","aria-pressed":"true"},Xd={class:"tagger-model-row"},Qd={class:"tagger-model-field"},Zd={class:"tagger-option-state"},eu={key:1},au={class:"tagger-choice-row"},tu={for:"tagger-conflict"},lu=["disabled"],ou={value:"ignore"},su={value:"copy"},nu={value:"prepend"},ru={class:"tagger-run"},iu=["disabled"],du=["disabled"],uu={class:"tagger-run-status","aria-live":"polite"},cu={key:0,role:"alert"},vu={key:1,class:"meter"},pu=["aria-label"],gu=["aria-label"],fu=["aria-label"],mu={class:"tagger-panel-model"},hu=["disabled"],bu={class:"tagger-panel-tabs",role:"tablist"},yu=["data-testid","aria-selected","onClick"],_u=["disabled"],ku={class:"tagger-grid"},wu={class:"tagger-model-info"},$u={class:"tagger-grid"},Eu={class:"check-row"},Cu={class:"tagger-future"},Du={class:"tagger-grid"},Tu=["disabled"],Mu={value:"default"},Su=["value"],Pu={class:"tagger-dataset-path"},Vu={class:"tagger-actions"},Uu=["disabled"],xu=["disabled"],Fu=["disabled"],Lu=Se({__name:"TaggerPage",setup(s){const t=["wd14-convnextv2-v2","wd-convnext-v3","wd-swinv2-v3","wd-vit-v3","wd14-swinv2-v2","wd14-vit-v2","wd14-moat-v2","wd-eva02-large-tagger-v3","wd-vit-large-tagger-v3","cl_tagger_1_01"],n=Aa({path:"",interrogator_model:t[0],threshold:.35,character_threshold:.6,add_rating_tag:!1,add_model_tag:!1,additional_tags:"",exclude_tags:"",escape_tag:!0,batch_input_recursive:!1,batch_output_action_on_conflict:"ignore",replace_underscore:!0,replace_underscore_excludes:"0_0, (o)_(o), +_+, +_-, ._.,i?i:a);if(!oa.test(h))throw new Q("only letter, numbers, dashes and underscores are allowed in keys",{toml:e,ptr:n});s.push(h.trimEnd())}}while(a+1&&a{if(t.title)return t.title;const h=`settings.engines.state.${t.state}`,p=s(h);return p===h?t.state:p}),o=P(()=>{if(t.hint)return t.hint;const h=`settings.engines.hint.${t.state}`,p=s(h);return p===h?"":p});return(h,p)=>(w(),S("div",{class:"engine-status-bar","data-state":e.state,"data-testid":"engine-status-bar"},[u("div",fa,[u("b",null,_(i.value),1),o.value?(w(),S("span",ga,_(o.value),1)):A("",!0)]),u("div",ma,[e.manageOnly?A("",!0):(w(),S(Y,{key:0},[e.showRefresh?(w(),S("button",{key:0,type:"button",class:"ghost-button",disabled:e.loading,onClick:p[0]||(p[0]=r=>a("refresh"))},_(d(s)("settings.engines.actions.refresh")),9,pa)):A("",!0),e.showInstall?(w(),S("button",{key:1,type:"button",class:"ghost-button",disabled:e.loading,onClick:p[1]||(p[1]=r=>a("install"))},_(d(s)("settings.engines.actions.install")),9,va)):A("",!0),e.showRepair?(w(),S("button",{key:2,type:"button",class:"ghost-button",disabled:e.loading,onClick:p[2]||(p[2]=r=>a("repair"))},_(d(s)("settings.engines.actions.repair")),9,ha)):A("",!0),e.showReinstall?(w(),S("button",{key:3,type:"button",class:"ghost-button",disabled:e.loading,onClick:p[3]||(p[3]=r=>a("reinstall"))},_(d(s)("settings.engines.actions.reinstall")),9,ya)):A("",!0)],64)),R(d(Re),{class:"ghost-button",to:e.manageTo},{default:K(()=>[ie(_(d(s)("settings.engines.actions.manage")),1)]),_:1},8,["to"])])],8,da))}}),ba=["training_task","train_batch_size","preview_samples"];function Ot(e){const n={},t=e.training_task===void 0?"text-to-image":e.training_task;if(t!=="text-to-image"&&t!=="image-edit")return n.training_task="训练模式无效,请重新选择文生图 T2I 或 Edit 图像编辑。",n;if(t!=="image-edit"||(Number(e.train_batch_size??1)!==1&&(n.train_batch_size="Edit 的 train_batch_size 必须为 1;可通过 gradient_accumulation_steps 增加有效批大小。"),!e.sample_enabled))return n;const a=e.preview_samples;if(!Array.isArray(a)||!a.length)return n.preview_samples="Edit 预览至少需要一个样例及参考图。",n;const s=[];return a.forEach((i,o)=>{try{const h=typeof i=="string"?JSON.parse(i):null;(!h||typeof h!="object"||!("controlImages"in h)||!Array.isArray(h.controlImages)||!h.controlImages.length||h.controlImages.some(p=>typeof p!="string"||!p.trim()))&&s.push(`预览样例 ${o+1}:至少填写一张参考图的非空路径。`)}catch{s.push(`预览样例 ${o+1}:配置格式无效。`)}}),s.length&&(n.preview_samples=s.join(" ")),n}function me(e){return e==null}function yt(e){return e&&typeof e=="object"&&!Array.isArray(e)}function _a(e,n){return Object.fromEntries(Object.entries(e).filter(([t,a])=>n(t,a)))}function Se(e,n){return Object.fromEntries(Object.entries(e).map(([t,a])=>[t,n(a,t)]))}function wa(e,n,t){if(!n)return{...e};const a={};for(const s of n)e[s]!==void 0&&(a[s]=e[s]);return a}function je(e,n){return arguments.length===1?t=>je(e,t):e in globalThis&&n instanceof globalThis[e]||Object.prototype.toString.call(n).slice(8,-1)===e}function mt(e){return je("ArrayBuffer",e)||je("SharedArrayBuffer",e)}function ka(e){return mt(e)||ArrayBuffer.isView(e)}var _e;(e=>{e.is=mt,e.isSource=ka;function n(o){return ArrayBuffer.isView(o)?o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength):o}e.fromSource=n;function t(o){if(o=n(o),typeof Buffer<"u")return Buffer.from(o).toString("base64");let h="";const p=new Uint8Array(o);for(let r=0;r
(P(),X(We,null,[ye(jp,{move:r.value,ratio:c.value,size:s.value,always:e.always},null,8,["move","ratio","size","always"]),ye(jp,{move:o.value,ratio:l.value,size:i.value,vertical:"",always:e.always},null,8,["move","ratio","size","always"])],64))}}),Q3=J3;const Z3=["tabindex"],dc="ElScrollbar";var ek=le({name:dc,__name:"scrollbar",props:j3,emits:au,setup(e,{expose:t,emit:n}){const a=e,r=n,o=Ge("scrollbar");let s,i,l,c=0,u=0,d="";const f={bottom:!1,top:!1,right:!1,left:!1},p=Y(),g=Y(),m=Y(),v=Y(),h=A(()=>{const $={},ne=dr(a.height),te=dr(a.maxHeight);return ne&&($.height=ne),te&&($.maxHeight=te),[a.wrapStyle,$]}),b=A(()=>[a.wrapClass,o.e("wrap"),{[o.em("wrap","hidden-default")]:!a.native}]),_=A(()=>[o.e("view"),a.viewClass]),y=$=>f[$]??!1,k={top:"bottom",bottom:"top",left:"right",right:"left"},x=$=>{const ne=k[d];if(!ne)return;const te=$[d],J=$[ne];te&&!f[d]&&(f[d]=!0),!J&&f[ne]&&(f[ne]=!1)},C=()=>{if(g.value){v.value?.handleScroll(g.value);const $=c,ne=u;c=g.value.scrollTop,u=g.value.scrollLeft;const te={bottom:!Kp(g.value.scrollHeight-a.distance,g.value.clientHeight+c),top:c<=a.distance&&$!==0,right:!Kp(g.value.scrollWidth-a.distance,g.value.clientWidth+u)&&ne!==u,left:u<=a.distance&&ne!==0};if(r("scroll",{scrollTop:c,scrollLeft:u}),$!==c&&(d=c>$?"bottom":"top"),ne!==u&&(d=u>ne?"right":"left"),a.distance>0){if(y(d))return;x(te)}te[d]&&r("end-reached",d)}};function F($,ne){Oe($)?g.value.scrollTo($):lt($)&<(ne)&&g.value.scrollTo($,ne)}const M=$=>{if(!lt($)){Bt(dc,"value must be a number");return}g.value.scrollTop=$},H=$=>{if(!lt($)){Bt(dc,"value must be a number");return}g.value.scrollLeft=$},U=()=>{v.value?.update(),f[d]=!1,g.value&&v.value?.handleScroll(g.value)};return Ee(()=>a.noresize,$=>{$?(s?.(),i?.(),l?.()):({stop:s}=Gn(m,U),{stop:i}=Gn(g,U),l=ha("resize",U))},{immediate:!0}),Ee(()=>[a.maxHeight,a.height],()=>{a.native||Ue(()=>{U()})}),bt(Id,rn({scrollbarElement:p,wrapElement:g})),Qg(()=>{g.value&&(g.value.scrollTop=c,g.value.scrollLeft=u)}),pt(()=>{a.native||Ue(()=>{U()})}),vl(()=>U()),t({wrapRef:g,update:U,scrollTo:F,setScrollTop:M,setScrollLeft:H,handleScroll:C}),($,ne)=>(P(),X("div",{ref_key:"scrollbarRef",ref:p,class:ae(w(o).b())},[Q("div",{ref_key:"wrapRef",ref:g,class:ae(b.value),style:tt(h.value),tabindex:e.tabindex,onScroll:C},[(P(),ge(dt(e.tag),{id:e.id,ref_key:"resizeRef",ref:m,class:ae(_.value),style:tt(e.viewStyle),role:e.role,"aria-label":e.ariaLabel,"aria-orientation":e.ariaOrientation},{default:ue(()=>[he($.$slots,"default")]),_:3},8,["id","class","style","role","aria-label","aria-orientation"]))],46,Z3),e.native?me("v-if",!0):(P(),ge(Q3,{key:0,ref_key:"barRef",ref:v,always:e.always,"min-size":e.minSize},null,8,["always","min-size"]))],2))}}),tk=ek;const u0=on(tk),nk=["default","primary","success","warning","info","danger","text",""],ak=["button","submit","reset"],ru=Je({size:Gr,disabled:{type:Boolean,default:void 0},type:{type:String,values:nk,default:""},icon:{type:yn},nativeType:{type:String,values:ak,default:"button"},loading:Boolean,loadingIcon:{type:yn,default:()=>yd},plain:{type:Boolean,default:void 0},text:{type:Boolean,default:void 0},link:Boolean,bg:Boolean,autofocus:Boolean,round:{type:Boolean,default:void 0},circle:Boolean,dashed:{type:Boolean,default:void 0},color:String,dark:Boolean,autoInsertSpace:{type:Boolean,default:void 0},tag:{type:de([String,Object]),default:"button"}}),rk={click:e=>e instanceof MouseEvent},d0=Symbol(),zi=Y();function Dl(e,t=void 0){const n=at()?Ce(d0,zi):zi;return e?A(()=>n.value?.[e]??t):n}function ok(e,t){const n=Dl(),a=Ge(e,A(()=>n.value?.namespace||"el")),r=Oo(A(()=>n.value?.locale)),o=hd(A(()=>{const i=n.value?.zIndex;return Dn(i)||Number.isNaN(i)?Vv:i})),s=A(()=>w(t)||n.value?.size||"");return f0(A(()=>w(n)||{})),{ns:a,locale:r,zIndex:o,size:s}}const f0=(e,t,n=!1)=>{const a=!!at(),r=a?Dl():void 0,o=a?bt:void 0;if(!o){Bt("provideGlobalConfig","provideGlobalConfig() can only be used inside setup().");return}const s=A(()=>{const i=w(e);return r?.value?sk(r.value,i):i});return o(d0,s),o(wv,A(()=>s.value.locale)),o(_v,A(()=>s.value.namespace)),o(Hv,A(()=>s.value.zIndex)),o(Uv,{size:A(()=>s.value.size||"")}),o(Wv,A(()=>({emptyValues:s.value.emptyValues,valueOnClear:s.value.valueOnClear}))),(n||!zi.value)&&(zi.value=s.value),s},sk=(e,t)=>{const n=[...new Set([...fp(e),...fp(t)])],a={};for(const r of n)a[r]=t[r]!==void 0?t[r]:e[r];return a},ik=Je({a11y:{type:Boolean,default:!0},locale:{type:de(Object)},size:Gr,button:{type:de(Object)},card:{type:de(Object)},dialog:{type:de(Object)},link:{type:de(Object)},experimentalFeatures:{type:de(Object)},keyboardNavigation:{type:Boolean,default:!0},message:{type:de(Object)},zIndex:Number,namespace:{type:String,default:"el"},table:{type:de(Object)},...Gv}),lk={placement:"top"},ck=le({name:"ElConfigProvider",props:ik,setup(e,{slots:t}){const n=f0(e);return Ee(()=>e.message,a=>{Object.assign(lk,n?.value?.message??{},a??{})},{immediate:!0,deep:!0}),()=>he(t,"default",{config:n?.value})}}),uk=on(ck),p0=Symbol("buttonGroupContextKey"),dk=(e,t)=>{ss({from:"type.text",replacement:"link",version:"3.0.0",scope:"props",ref:"https://element-plus.org/en-US/component/button.html#button-attributes"},A(()=>e.type==="text"));const n=Ce(p0,void 0),a=Dl("button"),{form:r}=vr(),o=Ga(A(()=>n?.size)),s=hr(),i=Y(),l=Po(),c=A(()=>e.type||n?.type||a.value?.type||""),u=A(()=>e.autoInsertSpace??a.value?.autoInsertSpace??!1),d=A(()=>e.plain??a.value?.plain??!1),f=A(()=>e.round??a.value?.round??!1),p=A(()=>e.text??a.value?.text??!1),g=A(()=>e.dashed??a.value?.dashed??!1),m=A(()=>e.tag==="button"?{ariaDisabled:s.value||e.loading,disabled:s.value||e.loading,autofocus:e.autofocus,type:e.nativeType}:{}),v=A(()=>{const b=l.default?.();if(u.value&&b?.length===1){const _=b[0];if(_?.type===Ur){const y=_.children;return new RegExp("^\\p{Unified_Ideograph}{2}$","u").test(y.trim())}}return!1});return{_disabled:s,_size:o,_type:c,_ref:i,_props:m,_plain:d,_round:f,_text:p,_dashed:g,shouldAddSpace:v,handleClick:b=>{if(s.value||e.loading){b.stopPropagation();return}e.nativeType==="reset"&&r?.resetFields(),t("click",b)}}};function Gt(e,t){fk(e)&&(e="100%");const n=pk(e);return e=t===360?e:Math.min(t,Math.max(0,parseFloat(e))),n&&(e=parseInt(String(e*t),10)/100),Math.abs(e-t)<1e-6?1:(t===360?e=(e<0?e%t+t:e%t)/parseFloat(String(t)):e=e%t/parseFloat(String(t)),e)}function ri(e){return Math.min(1,Math.max(0,e))}function fk(e){return typeof e=="string"&&e.indexOf(".")!==-1&&parseFloat(e)===1}function pk(e){return typeof e=="string"&&e.indexOf("%")!==-1}function m0(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function oi(e){return Number(e)<=1?`${Number(e)*100}%`:e}function Pr(e){return e.length===1?"0"+e:String(e)}function mk(e,t,n){return{r:Gt(e,255)*255,g:Gt(t,255)*255,b:Gt(n,255)*255}}function Wp(e,t,n){e=Gt(e,255),t=Gt(t,255),n=Gt(n,255);const a=Math.max(e,t,n),r=Math.min(e,t,n);let o=0,s=0;const i=(a+r)/2;if(a===r)s=0,o=0;else{const l=a-r;switch(s=i>.5?l/(2-a-r):l/(a+r),a){case e:o=(t-n)/l+(t (P(),X(Ke,null,[ye(Zp,{move:o.value,ratio:c.value,size:i.value,always:e.always},null,8,["move","ratio","size","always"]),ye(Zp,{move:r.value,ratio:l.value,size:s.value,vertical:"",always:e.always},null,8,["move","ratio","size","always"])],64))}}),f3=d3;const p3=["tabindex"],vc="ElScrollbar";var m3=le({name:vc,__name:"scrollbar",props:o3,emits:uu,setup(e,{expose:t,emit:n}){const a=e,o=n,r=Ge("scrollbar");let i,s,l,c=0,u=0,d="";const f={bottom:!1,top:!1,right:!1,left:!1},p=q(),g=q(),m=q(),v=q(),h=A(()=>{const $={},Z=fo(a.height),te=fo(a.maxHeight);return Z&&($.height=Z),te&&($.maxHeight=te),[a.wrapStyle,$]}),b=A(()=>[a.wrapClass,r.e("wrap"),{[r.em("wrap","hidden-default")]:!a.native}]),w=A(()=>[r.e("view"),a.viewClass]),y=$=>f[$]??!1,k={top:"bottom",bottom:"top",left:"right",right:"left"},O=$=>{const Z=k[d];if(!Z)return;const te=$[d],Q=$[Z];te&&!f[d]&&(f[d]=!0),!Q&&f[Z]&&(f[Z]=!1)},C=()=>{if(g.value){v.value?.handleScroll(g.value);const $=c,Z=u;c=g.value.scrollTop,u=g.value.scrollLeft;const te={bottom:!Qp(g.value.scrollHeight-a.distance,g.value.clientHeight+c),top:c<=a.distance&&$!==0,right:!Qp(g.value.scrollWidth-a.distance,g.value.clientWidth+u)&&Z!==u,left:u<=a.distance&&Z!==0};if(o("scroll",{scrollTop:c,scrollLeft:u}),$!==c&&(d=c>$?"bottom":"top"),Z!==u&&(d=u>Z?"right":"left"),a.distance>0){if(y(d))return;O(te)}te[d]&&o("end-reached",d)}};function N($,Z){Re($)?g.value.scrollTo($):lt($)&<(Z)&&g.value.scrollTo($,Z)}const D=$=>{if(!lt($)){Bt(vc,"value must be a number");return}g.value.scrollTop=$},U=$=>{if(!lt($)){Bt(vc,"value must be a number");return}g.value.scrollLeft=$},H=()=>{v.value?.update(),f[d]=!1,g.value&&v.value?.handleScroll(g.value)};return Ee(()=>a.noresize,$=>{$?(i?.(),s?.(),l?.()):({stop:i}=jn(m,H),{stop:s}=jn(g,H),l=va("resize",H))},{immediate:!0}),Ee(()=>[a.maxHeight,a.height],()=>{a.native||He(()=>{H()})}),bt(Md,on({scrollbarElement:p,wrapElement:g})),lh(()=>{g.value&&(g.value.scrollTop=c,g.value.scrollLeft=u)}),ct(()=>{a.native||He(()=>{H()})}),_l(()=>H()),t({wrapRef:g,update:H,scrollTo:N,setScrollTop:D,setScrollLeft:U,handleScroll:C}),($,Z)=>(P(),X("div",{ref_key:"scrollbarRef",ref:p,class:ae(_(r).b())},[J("div",{ref_key:"wrapRef",ref:g,class:ae(b.value),style:tt(h.value),tabindex:e.tabindex,onScroll:C},[(P(),ge(ft(e.tag),{id:e.id,ref_key:"resizeRef",ref:m,class:ae(w.value),style:tt(e.viewStyle),role:e.role,"aria-label":e.ariaLabel,"aria-orientation":e.ariaOrientation},{default:ue(()=>[he($.$slots,"default")]),_:3},8,["id","class","style","role","aria-label","aria-orientation"]))],46,p3),e.native?me("v-if",!0):(P(),ge(f3,{key:0,ref_key:"barRef",ref:v,always:e.always,"min-size":e.minSize},null,8,["always","min-size"]))],2))}}),g3=m3;const w0=rn(g3),h3=["default","primary","success","warning","info","danger","text",""],v3=["button","submit","reset"],du=Je({size:Yo,disabled:{type:Boolean,default:void 0},type:{type:String,values:h3,default:""},icon:{type:yn},nativeType:{type:String,values:v3,default:"button"},loading:Boolean,loadingIcon:{type:yn,default:()=>Ld},plain:{type:Boolean,default:void 0},text:{type:Boolean,default:void 0},link:Boolean,bg:Boolean,autofocus:Boolean,round:{type:Boolean,default:void 0},circle:Boolean,dashed:{type:Boolean,default:void 0},color:String,dark:Boolean,autoInsertSpace:{type:Boolean,default:void 0},tag:{type:de([String,Object]),default:"button"}}),b3={click:e=>e instanceof MouseEvent},_0=Symbol(),Qs=q();function Ul(e,t=void 0){const n=at()?ke(_0,Qs):Qs;return e?A(()=>n.value?.[e]??t):n}function y3(e,t){const n=Ul(),a=Ge(e,A(()=>n.value?.namespace||"el")),o=Rr(A(()=>n.value?.locale)),r=kd(A(()=>{const s=n.value?.zIndex;return Mn(s)||Number.isNaN(s)?Xv:s})),i=A(()=>_(t)||n.value?.size||"");return S0(A(()=>_(n)||{})),{ns:a,locale:o,zIndex:r,size:i}}const S0=(e,t,n=!1)=>{const a=!!at(),o=a?Ul():void 0,r=a?bt:void 0;if(!r){Bt("provideGlobalConfig","provideGlobalConfig() can only be used inside setup().");return}const i=A(()=>{const s=_(e);return o?.value?w3(o.value,s):s});return r(_0,i),r(Pv,A(()=>i.value.locale)),r(xv,A(()=>i.value.namespace)),r(Jv,A(()=>i.value.zIndex)),r(Qv,{size:A(()=>i.value.size||"")}),r(t0,A(()=>({emptyValues:i.value.emptyValues,valueOnClear:i.value.valueOnClear}))),(n||!Qs.value)&&(Qs.value=i.value),i},w3=(e,t)=>{const n=[...new Set([..._p(e),..._p(t)])],a={};for(const o of n)a[o]=t[o]!==void 0?t[o]:e[o];return a},_3=Je({a11y:{type:Boolean,default:!0},locale:{type:de(Object)},size:Yo,button:{type:de(Object)},card:{type:de(Object)},dialog:{type:de(Object)},link:{type:de(Object)},experimentalFeatures:{type:de(Object)},keyboardNavigation:{type:Boolean,default:!0},message:{type:de(Object)},zIndex:Number,namespace:{type:String,default:"el"},table:{type:de(Object)},...n0}),S3={placement:"top"},T3=le({name:"ElConfigProvider",props:_3,setup(e,{slots:t}){const n=S0(e);return Ee(()=>e.message,a=>{Object.assign(S3,n?.value?.message??{},a??{})},{immediate:!0,deep:!0}),()=>he(t,"default",{config:n?.value})}}),E3=rn(T3),T0=Symbol("buttonGroupContextKey"),I3=(e,t)=>{li({from:"type.text",replacement:"link",version:"3.0.0",scope:"props",ref:"https://element-plus.org/en-US/component/button.html#button-attributes"},A(()=>e.type==="text"));const n=ke(T0,void 0),a=Ul("button"),{form:o}=bo(),r=Ga(A(()=>n?.size)),i=vo(),s=q(),l=xr(),c=A(()=>e.type||n?.type||a.value?.type||""),u=A(()=>e.autoInsertSpace??a.value?.autoInsertSpace??!1),d=A(()=>e.plain??a.value?.plain??!1),f=A(()=>e.round??a.value?.round??!1),p=A(()=>e.text??a.value?.text??!1),g=A(()=>e.dashed??a.value?.dashed??!1),m=A(()=>e.tag==="button"?{ariaDisabled:i.value||e.loading,disabled:i.value||e.loading,autofocus:e.autofocus,type:e.nativeType}:{}),v=A(()=>{const b=l.default?.();if(u.value&&b?.length===1){const w=b[0];if(w?.type===jo){const y=w.children;return new RegExp("^\\p{Unified_Ideograph}{2}$","u").test(y.trim())}}return!1});return{_disabled:i,_size:r,_type:c,_ref:s,_props:m,_plain:d,_round:f,_text:p,_dashed:g,shouldAddSpace:v,handleClick:b=>{if(i.value||e.loading){b.stopPropagation();return}e.nativeType==="reset"&&o?.resetFields(),t("click",b)}}};function Gt(e,t){k3(e)&&(e="100%");const n=C3(e);return e=t===360?e:Math.min(t,Math.max(0,parseFloat(e))),n&&(e=parseInt(String(e*t),10)/100),Math.abs(e-t)<1e-6?1:(t===360?e=(e<0?e%t+t:e%t)/parseFloat(String(t)):e=e%t/parseFloat(String(t)),e)}function is(e){return Math.min(1,Math.max(0,e))}function k3(e){return typeof e=="string"&&e.indexOf(".")!==-1&&parseFloat(e)===1}function C3(e){return typeof e=="string"&&e.indexOf("%")!==-1}function E0(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function ss(e){return Number(e)<=1?`${Number(e)*100}%`:e}function Oo(e){return e.length===1?"0"+e:String(e)}function A3(e,t,n){return{r:Gt(e,255)*255,g:Gt(t,255)*255,b:Gt(n,255)*255}}function em(e,t,n){e=Gt(e,255),t=Gt(t,255),n=Gt(n,255);const a=Math.max(e,t,n),o=Math.min(e,t,n);let r=0,i=0;const s=(a+o)/2;if(a===o)i=0,r=0;else{const l=a-o;switch(i=s>.5?l/(2-a-o):l/(a+o),a){case e:r=(t-n)/l+(t {{ t("settings.engines.downloadSources.title") }} {{ t("settings.engines.downloadSources.leadShort") }} {{ t("settings.engines.downloadSources.proxy.hint") }} {{ t("settings.engines.downloadSources.advancedNote") }} {{ t('network.description') }} {{ effective.warning }} {{ error }} {{ t("training.selector.unsupportedForModel", { list: unsupportedEngines.map((item) => t(`training.selector.engines.${item}`)).join(" / ") }) }} {{ t("training.selector.engineMissing", { list: missingEngines.map((item) => t(`training.selector.engines.${item}`)).join(" / ") }) }} {{ t(`training.selector.modelHints.${model}`) }}
+ {{ t("training.selector.engineLegendReady") }}
+ {{ t("training.selector.engineLegendNeedsInstall") }}
+ {{ engineHintText }}1),r}),Di(e,gv(e),n),a&&(n=_s(n,zE|qE|YE,GE));for(var o=t.length;o--;)jE(n,t[o]);return n});function JE(e,t,n,a){if(!_a(e))return e;t=Or(t,e);for(var o=-1,r=t.length,i=r-1,s=e;s!=null&&++o{{ t("settings.engines.downloadSources.advanced") }}
{{ resolved.pip }}
+ {{ channelCheckText("pip") }}
Object.assign(draft, readDownloadSour
{{ resolved.pytorch }}
+ {{ channelCheckText("pytorch") }}
Object.assign(draft, readDownloadSour
{{ resolved.huggingface }}
+ {{ channelCheckText("huggingface") }}
Object.assign(draft, readDownloadSour
{{ resolved.github }}
+ {{ channelCheckText("github") }}
Object.assign(draft, readDownloadSour
>
+
+ {{ t('network.title') }}
- {{ t("training.selector.group") }}
-