dsh-mo-image 0.4.1 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -16,7 +16,12 @@ window.__ModuleLoader__.load({
16
16
  let IconTrash = null;
17
17
  let IconPlus = null;
18
18
  let IconCloseFill = null;
19
+ let IconDragHandle = null;
19
20
  let DshToast = null;
21
+ let DshModal = null;
22
+ let DshButton = null;
23
+ let DshTooltip = null;
24
+ let useRowDragPreviewPrimitive = null;
20
25
  try {
21
26
  const primitives = require('@deepseek-ai/dsh-client-ui-primitives');
22
27
  DshSegmentedControl = primitives.SegmentedControl || null;
@@ -30,9 +35,20 @@ window.__ModuleLoader__.load({
30
35
  IconTrash = primitives.IconTrashOutlineRegular || null;
31
36
  IconPlus = primitives.IconPlusOutlineRegular || null;
32
37
  IconCloseFill = primitives.IconCloseFillRegular || null;
38
+ IconDragHandle = primitives.IconDragHandleOutlineRegular || null;
33
39
  DshToast = primitives.Toast || null;
40
+ DshModal = primitives.Modal || null;
41
+ DshButton = primitives.Button || null;
42
+ DshTooltip = primitives.Tooltip || null;
43
+ useRowDragPreviewPrimitive = typeof primitives.useRowDragPreview === 'function' ? primitives.useRowDragPreview : null;
34
44
  } catch (_error) { /* optional */ }
35
45
 
46
+ /** 行拖动预览是 DSH 原语;拿不到时拖动照旧,只是少了跟随指针的浮层。*/
47
+ function useNoopRowDragPreview() {
48
+ return React.useMemo(() => ({ start() {}, clear() { return false; } }), []);
49
+ }
50
+ const useModelRowDragPreview = useRowDragPreviewPrimitive || useNoopRowDragPreview;
51
+
36
52
  // 适配器、云端 provider preset 和本地部署器都由宿主下发,客户端不再维护
37
53
  // 第二份 preset/能力表;这里只保留加载后的只读快照。
38
54
  let imageCatalog = { adapters: [], providerPresets: [], localPresets: [], capabilities: [] };
@@ -115,6 +131,21 @@ window.__ModuleLoader__.load({
115
131
  return imageCatalog.localPresets.filter((item) => item && item.id && item.adapter);
116
132
  }
117
133
 
134
+ /** 端点归一化:忽略大小写和末尾斜杠;只用于比对,不参与请求。 */
135
+ function normalizeEndpoint(value) {
136
+ return String(value || '').trim().replace(/\/+$/, '').toLowerCase();
137
+ }
138
+
139
+ /**
140
+ * 是否内置的云端提供商:端点与宿主下发的 provider preset 一致。
141
+ * 这类提供商有名字、有官网,不是「自定义」端点;只有用户自己填地址的才打这个标。
142
+ */
143
+ function isBuiltinProvider(provider) {
144
+ const endpoint = normalizeEndpoint(provider && provider.baseUrl);
145
+ if (!endpoint) return false;
146
+ return providerPresetsForUi().some((preset) => normalizeEndpoint(preset.baseUrl) === endpoint);
147
+ }
148
+
118
149
  // DSH 的组件样式是 CSS Modules:类名形如「构建前缀_语义名」。前缀会随
119
150
  // DSH 版本/构建变化,所以这里不写死完整类名,只保留语义名;运行时从当前
120
151
  // 已加载的样式表里解析出前缀,再拼成真实类名。这样 DSH 升级换了 hash,
@@ -133,8 +164,16 @@ window.__ModuleLoader__.load({
133
164
  modelCatalog: 'modelCatalog', modelCatalogHeading: 'modelCatalogHeading', modelCatalogTitle: 'modelCatalogTitle', modelCatalogMeta: 'modelCatalogMeta',
134
165
  modelList: 'modelList', modelListHead: 'modelListHead', modelEntry: 'modelEntry', modelRow: 'modelRow', modelEmpty: 'modelEmpty',
135
166
  addModelButton: 'addModelButton', iconButton: 'iconButton', iconButtonDanger: 'iconButtonDanger',
136
- // 两列数字 + 尾部控件:沿用设置页里「推理深度的最小/最大」那一行
137
- modelReasoningRow: 'modelReasoningRow',
167
+ // 模型行沿用 DSH 设置页的列定义:拖动把手、ID、显示名称、尾部控件。
168
+ modelField: 'modelField', modelFieldLabel: 'modelFieldLabel', modelName: 'modelName', modelNameLabel: 'modelNameLabel',
169
+ modelDragHandle: 'modelDragHandle', modelDragPreview: 'modelDragPreview',
170
+ // 展开后的「模型选项」面板:沿用 DSH 设置页的 modelAdvanced 网格(grid-column: 1/-1)。
171
+ modelAdvanced: 'modelAdvanced',
172
+ candidate: 'candidate', candidateEmpty: 'candidateEmpty', candidateId: 'candidateId', candidateLabel: 'candidateLabel',
173
+ candidateList: 'candidateList', candidateSearch: 'candidateSearch', candidateToolbar: 'candidateToolbar',
174
+ fetchDialog: 'fetchDialog', error: 'error',
175
+ // 两列数字 + 尾部控件:沿用设置页里「推理深度的最 最大」那一。
176
+ modelReasoningRow: 'modelReasoningRow',
138
177
  modelReasoningValueInput: 'modelReasoningValueInput'
139
178
  };
140
179
  const MODEL_CLASS_LOCALS = {
@@ -269,14 +308,121 @@ window.__ModuleLoader__.load({
269
308
  || classPrefixInCss(cssomText(), source.anchors);
270
309
  if (cssPrefix) return cssPrefix;
271
310
  // 样式表还没注入时,再退回对话里真实渲染的模型选择器。
272
- return kind === 'model' ? classPrefixFromHostModel() : '';
311
+ return kind === 'model' ? classPrefixFromHostModel() : '';
273
312
  }
274
313
 
275
314
  let MC = buildClassMap(SETTINGS_CLASS_LOCALS, resolvedClassPrefix.settings);
276
315
  let MS = buildClassMap(MODEL_CLASS_LOCALS, resolvedClassPrefix.model);
277
316
 
278
- /** 重新解析类名前缀;变化时通知已挂载的组件重绘。 */
279
- function refreshThemeClasses() {
317
+ // ── 生图席的皮肤 ──────────────────────────────────────────────────
318
+ // official:宿主原版对话模型选择器(优先,类 材质/键盘行为全部对齐)。
319
+ // codex :检测到 dsh-codex-model-effort-selector 接管了对话席时,直接复用
320
+ // 它的 cmes-* 全局类名 DOM 形状,让两个席看起来是同一套皮肤。
321
+ // generic :未知的接管型美化插件。没公共协议,只能采样它触发器的实际样式。
322
+ // 弹层回退到原版材质;保证并排不违和,不承诺像素级。
323
+ const SEAT_SKIN = { OFFICIAL: 'official', CODEX: 'codex', GENERIC: 'generic' };
324
+ let resolvedSeatSkin = SEAT_SKIN.OFFICIAL;
325
+
326
+ function detectSeatSkinFromMarkers(markers) {
327
+ const source = markers || {};
328
+ if (source.codex) return SEAT_SKIN.CODEX;
329
+ if (source.official) return SEAT_SKIN.OFFICIAL;
330
+ if (source.generic) return SEAT_SKIN.GENERIC;
331
+ return SEAT_SKIN.OFFICIAL;
332
+ }
333
+
334
+ /** 找到和生图席同一排的对话模型触发器;找不到就不冒 generic。*/
335
+ function findChatTriggerNear(seatEl) {
336
+ if (!seatEl || typeof seatEl.closest !== 'function') return null;
337
+ let node = seatEl;
338
+ // 只往上找三层:slot 包装 standardControls 输入行。再往上就会碰。
339
+ // 左侧的权 计划按钮,把普通的 aria-haspopup 误认成模型选择器。
340
+ for (let depth = 0; depth < 3 && node; depth += 1) {
341
+ node = node.parentElement;
342
+ if (!node || typeof node.querySelectorAll !== 'function') break;
343
+ const buttons = node.querySelectorAll('button[aria-haspopup="menu"], button[aria-haspopup="dialog"]');
344
+ for (const button of buttons) {
345
+ if (!seatEl.contains(button)) return button;
346
+ }
347
+ if (node.querySelectorAll('button').length > 10) break;
348
+ }
349
+ return null;
350
+ }
351
+
352
+ function codexSkinProbe() {
353
+ if (typeof document === 'undefined') return { present: false, ready: false };
354
+ let trigger = null;
355
+ for (const candidate of document.querySelectorAll('.cmes-trigger')) {
356
+ if (!candidate || (typeof candidate.closest === 'function' && candidate.closest('[data-mo-image-seat]'))) continue;
357
+ trigger = candidate;
358
+ break;
359
+ }
360
+ if (!trigger) return { present: false, ready: false };
361
+ let textReady = false;
362
+ for (const tag of document.querySelectorAll('style')) {
363
+ if (String(tag.textContent || '').includes('.cmes-popover')) { textReady = true; break; }
364
+ }
365
+ // Prefer probing the real external root: it proves the contract we rely on
366
+ // (classes and fixed positioning), not just that some style text exists.
367
+ const root = typeof trigger.closest === 'function' ? trigger.closest('.cmes-root') : null;
368
+ if (root && typeof root.querySelector === 'function') {
369
+ const popover = root.querySelector('.cmes-popover');
370
+ const page = root.querySelector('.cmes-page');
371
+ if (!popover || !page) return { present: true, ready: false };
372
+ let fixed = true;
373
+ try {
374
+ if (typeof window !== 'undefined' && typeof window.getComputedStyle === 'function') {
375
+ fixed = window.getComputedStyle(popover).position === 'fixed';
376
+ }
377
+ } catch (_error) { fixed = true; }
378
+ return { present: true, ready: fixed };
379
+ }
380
+ return { present: true, ready: textReady };
381
+ }
382
+
383
+ // 未知接管型皮肤没有公共协议:只采样它触发器的实际尺寸/字体/颜色,套。
384
+ // 我们的触发器上;弹层仍走原版材质。够用,但不承诺像素级一致。
385
+ const TRIGGER_STYLE_KEYS = [
386
+ 'height', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft',
387
+ 'gap', 'fontSize', 'lineHeight', 'color', 'borderRadius', 'maxWidth', 'fontFamily'
388
+ ];
389
+ function pickTriggerStyle(computed) {
390
+ if (!computed) return null;
391
+ const out = {};
392
+ let found = false;
393
+ for (const key of TRIGGER_STYLE_KEYS) {
394
+ const value = computed[key];
395
+ if (typeof value === 'string' && value) { out[key] = value; found = true; }
396
+ }
397
+ return found ? out : null;
398
+ }
399
+ function genericChatTriggerStyle() {
400
+ if (typeof document === 'undefined' || typeof window === 'undefined') return null;
401
+ if (typeof window.getComputedStyle !== 'function') return null;
402
+ const seat = document.querySelector('[data-mo-image-seat]');
403
+ const trigger = findChatTriggerNear(seat);
404
+ if (!trigger) return null;
405
+ try { return pickTriggerStyle(window.getComputedStyle(trigger)); } catch (_error) { return null; }
406
+ }
407
+
408
+ function detectSeatSkin() {
409
+ if (typeof document === 'undefined') return SEAT_SKIN.OFFICIAL;
410
+ const codex = codexSkinProbe();
411
+ if (codex.ready) return SEAT_SKIN.CODEX;
412
+ // A codex trigger exists but its CSS/DOM contract is incomplete: do not
413
+ // paint half-codex, and do not sample it as generic either.
414
+ if (codex.present) return SEAT_SKIN.OFFICIAL;
415
+ if (document.querySelector('[data-model-id]')) return SEAT_SKIN.OFFICIAL;
416
+ const seat = document.querySelector('[data-mo-image-seat]');
417
+ const chat = findChatTriggerNear(seat);
418
+ return detectSeatSkinFromMarkers({ generic: !!chat });
419
+ }
420
+
421
+ function seatSkinNow() {
422
+ return resolvedSeatSkin;
423
+ }
424
+
425
+ function refreshClassPrefixes() {
280
426
  let changed = false;
281
427
  const tags = collectStyleTags();
282
428
  for (const kind of Object.keys(CLASS_STYLE_SOURCES)) {
@@ -289,11 +435,166 @@ window.__ModuleLoader__.load({
289
435
  if (!changed) return false;
290
436
  MC = buildClassMap(SETTINGS_CLASS_LOCALS, resolvedClassPrefix.settings);
291
437
  MS = buildClassMap(MODEL_CLASS_LOCALS, resolvedClassPrefix.model);
438
+ return true;
439
+ }
440
+ function refreshSeatSkin() {
441
+ const skin = detectSeatSkin();
442
+ if (skin === resolvedSeatSkin) return false;
443
+ resolvedSeatSkin = skin;
444
+ return true;
445
+ }
446
+ /** 重新解析类名前缀与皮肤;变化时通知已挂载的组件重绘。*/
447
+ function refreshThemeClasses() {
448
+ const prefixesChanged = refreshClassPrefixes();
449
+ const skinChanged = refreshSeatSkin();
450
+ if (!prefixesChanged && !skinChanged) return false;
292
451
  themeClassRevision += 1;
293
452
  try { window.dispatchEvent(new Event('mo-image-theme')); } catch (_error) { /* ignore */ }
294
453
  return true;
295
454
  }
296
455
 
456
+ // ── Codex 皮肤的几何与粒子 ────────────────────────────────────────
457
+ // 几何取自 dsh-codex-model-effort-selector(MIT)的实测值:272×104 卡片。
458
+ // 30px 旋钮 2px 内缩轨道。这里只保留生图席需要的部分。
459
+ const CODEX_POPOVER_WIDTH = 272;
460
+ const CODEX_QUALITY_HEIGHT = 104;
461
+ const CODEX_MARGIN = 12;
462
+ // Mirrors the upstream CSS metrics (codex 1.1.2). Keep them in one place:
463
+ // when upstream changes a row height, these are the only numbers to revisit.
464
+ const CODEX_METRICS = {
465
+ pad: 20,
466
+ head: 36,
467
+ row: 41,
468
+ model: 39,
469
+ listMax: 252,
470
+ listPad: 4,
471
+ search: 40,
472
+ empty: 48,
473
+ section: 30
474
+ };
475
+
476
+ function codexPlacement(rect, viewport, width, margin) {
477
+ const pad = Number.isFinite(margin) ? margin : CODEX_MARGIN;
478
+ const viewWidth = viewport && Number.isFinite(viewport.width) ? viewport.width : 0;
479
+ const viewHeight = viewport && Number.isFinite(viewport.height) ? viewport.height : 0;
480
+ const boxWidth = Number.isFinite(width) ? width : CODEX_POPOVER_WIDTH;
481
+ const trigger = rect || { left: 0, top: 0, width: 0 };
482
+ const bottom = Math.max(pad, viewHeight - Number(trigger.top || 0) + 8);
483
+ const rawLeft = Number(trigger.left || 0) + Number(trigger.width || 0) - boxWidth;
484
+ const maxLeft = Math.max(pad, viewWidth - boxWidth - pad);
485
+ return {
486
+ left: Math.min(Math.max(rawLeft, pad), maxLeft),
487
+ bottom: bottom
488
+ };
489
+ }
490
+
491
+ // 星尘相位用黄金比低差异序列、高度用独立哈希,保证重渲染不跳变。
492
+ const CODEX_PHI = 0.6180339887498949;
493
+ function codexHash01(n) {
494
+ const x = Math.sin(n * 127.1 + 311.7) * 43758.5453;
495
+ return x - Math.floor(x);
496
+ }
497
+ function buildCodexSparkles(count) {
498
+ const out = [];
499
+ for (let i = 0; i < count; i += 1) {
500
+ const b = 0.5 + 0.5 * codexHash01(i * 7 + 3);
501
+ out.push({
502
+ key: i,
503
+ top: (8 + 84 * codexHash01(i * 13 + 5)).toFixed(1) + '%',
504
+ b: b.toFixed(2),
505
+ dur: (1.6 + 2.4 * codexHash01(i * 3 + 11)).toFixed(2) + 's',
506
+ delay: (-(i * CODEX_PHI % 1) * 4).toFixed(2) + 's'
507
+ });
508
+ }
509
+ return out;
510
+ }
511
+
512
+ // Codex 皮肤浅色/深色两套色板(MIT,dsh-codex-model-effort-selector)。
513
+ // 生图质量档复用它:蓝 紫,峰值档才点燃紫罗兰。
514
+ const CODEX_FILL = {
515
+ off: '#8a8a8f', minimal: '#4a8ef8', low: '#3a83f7', medium: '#4a72f2',
516
+ high: '#5f5ce8', xhigh: '#7b48e8', max: '#914ef6'
517
+ };
518
+ const CODEX_INK = {
519
+ off: '#707073', minimal: '#2b62bd', low: '#2f6fd0', medium: '#3a55b8',
520
+ high: '#4a3fc0', xhigh: '#6a35c8', max: '#8b46ee'
521
+ };
522
+ const CODEX_FILL_DARK = {
523
+ off: '#737378', minimal: '#3684ff', low: '#448dff', medium: '#6e90ff',
524
+ high: '#928fff', xhigh: '#b18dff', max: '#bd91ff'
525
+ };
526
+ const CODEX_INK_DARK = {
527
+ off: '#a9a9ae', minimal: '#73a9ff', low: '#76aafe', medium: '#8ba7ff',
528
+ high: '#a4a2ff', xhigh: '#bc9cff', max: '#c39bff'
529
+ };
530
+ function codexFillFor(value, dark) {
531
+ const bucket = qualityBucketOf(value);
532
+ if (bucket) return (dark ? CODEX_FILL_DARK : CODEX_FILL)[bucket];
533
+ return dark ? '#448dff' : '#3a83f7';
534
+ }
535
+ function codexInkFor(value, dark) {
536
+ const bucket = qualityBucketOf(value);
537
+ if (bucket) return (dark ? CODEX_INK_DARK : CODEX_INK)[bucket];
538
+ return dark ? '#76aafe' : '#2f6fd0';
539
+ }
540
+ function codexMixHex(a, b, t) {
541
+ const pa = [1, 3, 5].map((index) => parseInt(String(a).substr(index, 2), 16));
542
+ const pb = [1, 3, 5].map((index) => parseInt(String(b).substr(index, 2), 16));
543
+ const out = pa.map((value, index) => Math.round(value + (pb[index] - value) * t));
544
+ return '#' + out.map((value) => value.toString(16).padStart(2, '0')).join('');
545
+ }
546
+ function codexTrackFor(fill, dark) {
547
+ return codexMixHex(dark ? '#232324' : '#e8e7e8', fill, 0.22);
548
+ }
549
+
550
+ // 一次性抵达峰值档的粒子绽放;确定性哈希,重渲染不会重排。
551
+ function buildCodexBloom(count) {
552
+ const out = [];
553
+ for (let i = 0; i < count; i += 1) {
554
+ const side = i % 2 === 0 ? 1 : -1;
555
+ const t = codexHash01(i * 5 + 2);
556
+ const deg = side > 0 ? 108 + 56 * t : 180 + (72 - 56 * t);
557
+ const angle = deg * Math.PI / 180;
558
+ const near = 9 + 5 * codexHash01(i * 11 + 7);
559
+ const far = 0.72 + 0.55 * codexHash01(i * 17 + 3);
560
+ const rx = 34 + 12 * codexHash01(i * 23 + 13);
561
+ const ry = 20 + 9 * codexHash01(i * 29 + 19);
562
+ out.push({
563
+ key: i,
564
+ x0: (Math.cos(angle) * near).toFixed(1) + 'px',
565
+ y0: (Math.sin(angle) * near).toFixed(1) + 'px',
566
+ x1: (Math.cos(angle) * rx * far).toFixed(1) + 'px',
567
+ y1: (Math.sin(angle) * ry * far).toFixed(1) + 'px',
568
+ sz: (3.4 + 2.6 * codexHash01(i * 31 + 5)).toFixed(1) + 'px',
569
+ bmax: (0.70 + 0.30 * codexHash01(i * 37 + 23)).toFixed(2),
570
+ bd: (0.6 + 0.3 * codexHash01(i * 41 + 11)).toFixed(2) + 's',
571
+ bdel: (0.05 * codexHash01(i * 43 + 17)).toFixed(3) + 's'
572
+ });
573
+ }
574
+ return out;
575
+ }
576
+
577
+ // Fast 是纯视觉开关( codex 一样),按会话记住;存储不可用时只。
578
+ // 内存镜像,绝不能因为它把选择器弄坏。
579
+ const CODEX_FAST_PREFIX = 'dsh.mo-image.codex-fast.v1.';
580
+ const codexFastMemory = new Map();
581
+ function readCodexFast(sessionId) {
582
+ if (!sessionId) return false;
583
+ if (codexFastMemory.has(sessionId)) return codexFastMemory.get(sessionId);
584
+ try {
585
+ if (typeof localStorage === 'undefined') return false;
586
+ return localStorage.getItem(CODEX_FAST_PREFIX + sessionId) === '1';
587
+ } catch (_error) { return false; }
588
+ }
589
+ function writeCodexFast(sessionId, on) {
590
+ if (!sessionId) return;
591
+ codexFastMemory.set(sessionId, on);
592
+ try {
593
+ if (typeof localStorage === 'undefined') return;
594
+ localStorage.setItem(CODEX_FAST_PREFIX + sessionId, on ? '1' : '0');
595
+ } catch (_error) { /* storage disabled; the memory mirror still holds it */ }
596
+ }
597
+
297
598
  function useThemeClassRevision() {
298
599
  const [, setRevision] = React.useState(0);
299
600
  React.useEffect(() => {
@@ -343,6 +644,48 @@ window.__ModuleLoader__.load({
343
644
  return translatedOr(translate || fallbackTranslate, 'quality.' + wanted, hit ? hit.label : wanted);
344
645
  }
345
646
 
647
+ // ── 质量滑条(Codex 皮肤的「推理强度」位 ──────────────────────────
648
+ // 生图适配器下发的 options 已经是语义顺序(off max)。Auto 是模。
649
+ // 不是画质档,紧挨着 Off 放,避免它被当成最高档排到滑条最右端。
650
+ function orderedQualityLevels(options) {
651
+ const list = Array.isArray(options) ? options.slice() : [];
652
+ const autoAt = list.findIndex((item) => item && item.value === 'auto');
653
+ if (autoAt < 0) return list;
654
+ const auto = list.splice(autoAt, 1)[0];
655
+ const offAt = list.findIndex((item) => item && item.value === 'off');
656
+ list.splice(offAt >= 0 ? offAt + 1 : 0, 0, auto);
657
+ return list;
658
+ }
659
+ function qualityRailLevels(spec) {
660
+ if (!spec || !Array.isArray(spec.options)) return [];
661
+ return orderedQualityLevels(spec.options)
662
+ .map((item) => ({
663
+ value: String(item && item.value || '').trim().toLowerCase(),
664
+ label: String(item && item.label || '')
665
+ }))
666
+ .filter((item) => item.value);
667
+ }
668
+ // 复用 Codex 推理档的色相轴( 紫)与每档上限;auto/未知值返 null。
669
+ // fillFor 走兜底色,不冒充「Ultra」。
670
+ const QUALITY_BUCKET = {
671
+ off: 'off',
672
+ turbo: 'minimal',
673
+ low: 'low',
674
+ minimal: 'low',
675
+ standard: 'medium',
676
+ medium: 'medium',
677
+ default: 'medium',
678
+ high: 'high',
679
+ hd: 'xhigh',
680
+ quality: 'xhigh',
681
+ xhigh: 'xhigh',
682
+ max: 'max',
683
+ ultra: 'max'
684
+ };
685
+ function qualityBucketOf(value) {
686
+ return QUALITY_BUCKET[String(value || '').trim().toLowerCase()] || null;
687
+ }
688
+
346
689
  function clampSide(value, fallback) {
347
690
  const number = Number(value);
348
691
  if (!Number.isFinite(number) || number <= 0) return fallback;
@@ -382,6 +725,49 @@ window.__ModuleLoader__.load({
382
725
  return alias || id;
383
726
  }
384
727
 
728
+ // Both skins render the same seat; keep the store reads and writes here so
729
+ // official and codex can never drift apart on "no model" or quality fallback.
730
+ function deriveSeatView(store, translate, qualitySpecOverride) {
731
+ const safe = store || { providers: [], active: { providerId: '', model: '' }, defaults: normalizeDefaults(null) };
732
+ const providers = Array.isArray(safe.providers) ? safe.providers : [];
733
+ const defaults = safe.defaults || normalizeDefaults(null);
734
+ const active = activeImageConfig(safe);
735
+ const activeProvider = providers.find((provider) => provider.id === active.providerId) || providers[0] || null;
736
+ const hasAnyModel = providers.some((provider) => Array.isArray(provider.models) && provider.models.length > 0);
737
+ const activeModelName = hasAnyModel && active.model === 'auto'
738
+ ? translate('seat.auto')
739
+ : (hasAnyModel && active.model ? modelDisplayName(activeProvider, active.model) : '');
740
+ const qualitySpec = qualitySpecOverride !== undefined
741
+ ? qualitySpecOverride
742
+ : qualitySpecFor(active.providerId, active.model);
743
+ return {
744
+ defaults: defaults,
745
+ active: active,
746
+ activeProvider: activeProvider,
747
+ hasAnyModel: hasAnyModel,
748
+ activeModelName: activeModelName,
749
+ triggerLabel: activeModelName || translate('seat.fallback'),
750
+ qualitySpec: qualitySpec,
751
+ qualityValue: qualityValueFor(defaults.quality, qualitySpec),
752
+ qualityLabel: qualityLabelFor(defaults.quality, qualitySpec, translate)
753
+ };
754
+ }
755
+ function commitSeatDefaults(store, defaults, setStore, patch, translate) {
756
+ const next = writeImageStore({ ...store, defaults: { ...defaults, ...patch } }, translate);
757
+ setStore(next);
758
+ return next;
759
+ }
760
+ function commitSeatModel(store, defaults, setStore, providerId, model, translate) {
761
+ const targetSpec = qualitySpecFor(providerId, model);
762
+ const next = writeImageStore({
763
+ ...store,
764
+ active: { providerId: providerId, model: model },
765
+ defaults: { ...defaults, quality: targetSpec ? qualityValueFor(defaults.quality, targetSpec) : defaults.quality }
766
+ }, translate);
767
+ setStore(next);
768
+ return next;
769
+ }
770
+
385
771
  const normalizeCache = new WeakMap();
386
772
  const normalizedStores = new WeakSet();
387
773
 
@@ -412,9 +798,9 @@ window.__ModuleLoader__.load({
412
798
  if (typeof p.names[model] === 'string') names[model] = p.names[model];
413
799
  }
414
800
  }
415
- // 服务端才是 provider 字段的权威;这里保留未知字段,避免客户端白名单
416
- // 与 normalizeConfig 漂移(adapter/protocol 就曾因此丢失)。
417
- return {
801
+ // 服务端才 provider 字段的权威;这里保留未知字段,避免客户端白名。
802
+ // normalizeConfig 漂移(adapter/protocol 就曾因此丢失)。
803
+ return {
418
804
  ...p,
419
805
  id: id,
420
806
  name: String(p.name || ''),
@@ -557,6 +943,114 @@ window.__ModuleLoader__.load({
557
943
  return { store: store, setStore: setStore, error: error, setError: setError };
558
944
  }
559
945
 
946
+ /**
947
+ * 获取可用模型弹窗。版式照抄对话模型设置的选择模型弹窗:DSH 的 Modal
948
+ * (标题 + 说明 + 关闭钮 + 底栏)+ 搜索行 + 勾选列表 + 两个描边按钮。
949
+ * 只有拿不到这些原语时才退回插件自己的浮层,结构保持同一套类名。
950
+ */
951
+ function ModelFetchDialog(props) {
952
+ const t = props.t || fallbackTranslate;
953
+ const visible = props.visible || [];
954
+ const names = props.names || {};
955
+ const list = visible.length
956
+ ? h('ul', { className: MC.candidateList },
957
+ visible.map((id) => h('li', { className: MC.candidate, key: id },
958
+ h('label', { className: MC.candidateLabel },
959
+ h('input', {
960
+ type: 'checkbox', checked: props.isPicked(id),
961
+ onChange: () => props.onToggle(id)
962
+ }),
963
+ h('span', {
964
+ className: MC.candidateId,
965
+ title: typeof names[id] === 'string' && names[id] ? names[id] : id
966
+ }, id)
967
+ )
968
+ ))
969
+ )
970
+ : h('p', { className: MC.candidateEmpty, role: 'status' }, t('picker.noMatches'));
971
+ const toolbar = h('div', { className: MC.candidateToolbar },
972
+ h('input', {
973
+ ref: props.searchRef, className: MC.input + ' ' + MC.candidateSearch, type: 'search',
974
+ value: props.query, placeholder: t('picker.search'), 'aria-label': t('picker.search'),
975
+ onChange: (event) => props.onQuery(event.target.value)
976
+ }),
977
+ DshButton
978
+ ? h(DshButton, {
979
+ variant: 'ghost', size: 'sm', disabled: !visible.length, onClick: props.onToggleAll
980
+ }, props.allPicked ? t('picker.deselectAll') : t('picker.selectAll'))
981
+ : h('button', {
982
+ type: 'button', className: MC.linkButton, disabled: !visible.length, onClick: props.onToggleAll
983
+ }, props.allPicked ? t('picker.deselectAll') : t('picker.selectAll'))
984
+ );
985
+ const filtered = props.filteredCount > 0
986
+ ? h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap' } },
987
+ h('label', { style: { display: 'inline-flex', alignItems: 'center', gap: 6, fontSize: 12, color: 'var(--dsw-alias-label-secondary)' } },
988
+ h('input', {
989
+ type: 'checkbox', checked: !!props.showAll,
990
+ onChange: (event) => props.onShowAll(event.target.checked)
991
+ }),
992
+ t('picker.showAll')
993
+ ),
994
+ h('span', { className: MC.advancedHint, style: { margin: 0 } },
995
+ t('picker.filtered', { count: props.filteredCount })
996
+ )
997
+ )
998
+ : null;
999
+ const cancelButton = DshButton
1000
+ ? h(DshButton, { variant: 'outline', onClick: props.onClose }, t('form.cancel'))
1001
+ : h('button', { type: 'button', className: MC.secondaryButton, onClick: props.onClose }, t('form.cancel'));
1002
+ const adoptButton = DshButton
1003
+ ? h(DshButton, {
1004
+ variant: 'outline', disabled: !!props.emptiesList,
1005
+ title: props.emptiesList ? t('picker.keepOne') : undefined,
1006
+ onClick: props.onAdopt
1007
+ }, t('picker.adopt'))
1008
+ : h('button', {
1009
+ type: 'button', className: MC.primaryButton, disabled: !!props.emptiesList,
1010
+ title: props.emptiesList ? t('picker.keepOne') : undefined,
1011
+ onClick: props.onAdopt
1012
+ }, t('picker.adopt'));
1013
+ if (DshModal) {
1014
+ return h(DshModal, {
1015
+ open: !!props.open, onClose: props.onClose,
1016
+ title: t('picker.title'), closeLabel: t('picker.close'),
1017
+ description: t('picker.description'), className: MC.fetchDialog,
1018
+ footer: h(React.Fragment, null, cancelButton, adoptButton)
1019
+ }, h(React.Fragment, null, toolbar, filtered, list));
1020
+ }
1021
+ if (!props.open) return null;
1022
+ return createPortal(h('div', {
1023
+ style: {
1024
+ position: 'fixed', inset: 0, zIndex: 10000, padding: 16,
1025
+ display: 'flex', alignItems: 'center', justifyContent: 'center',
1026
+ background: 'rgba(0, 0, 0, 0.45)'
1027
+ },
1028
+ onMouseDown: (event) => { if (event.target === event.currentTarget) props.onClose(); }
1029
+ }, h('div', {
1030
+ role: 'dialog', 'aria-modal': 'true', 'aria-label': t('picker.title'), tabIndex: -1,
1031
+ onKeyDown: (event) => {
1032
+ if (event.key === 'Escape') { event.stopPropagation(); props.onClose(); }
1033
+ },
1034
+ style: {
1035
+ width: 'min(520px, 100%)', maxHeight: 'min(82vh, 760px)', overflow: 'hidden',
1036
+ display: 'flex', flexDirection: 'column', gap: 12, padding: '16px 18px',
1037
+ border: '0.5px solid var(--dsw-alias-border-l3)', borderRadius: 'var(--dsw-radius-xl)',
1038
+ background: 'var(--dsw-alias-bg-module-platform)', color: 'var(--dsw-alias-label-primary)',
1039
+ boxShadow: '0 18px 48px rgba(0, 0, 0, 0.28)'
1040
+ }
1041
+ },
1042
+ h('div', { style: { display: 'flex', alignItems: 'center', gap: 8 } },
1043
+ h('strong', { style: { fontSize: 15 } }, t('picker.title')),
1044
+ h('button', { type: 'button', className: MC.linkButton, style: { marginLeft: 'auto' }, onClick: props.onClose }, t('picker.close'))
1045
+ ),
1046
+ h('p', { className: MC.advancedHint, style: { margin: 0 } }, t('picker.description')),
1047
+ toolbar,
1048
+ filtered,
1049
+ list,
1050
+ h('div', { style: { display: 'flex', justifyContent: 'flex-end', gap: 8 } }, cancelButton, adoptButton)
1051
+ )), document.body);
1052
+ }
1053
+
560
1054
  function ImageProviderForm(props) {
561
1055
  useThemeClassRevision();
562
1056
  const t = props.t || fallbackTranslate;
@@ -573,8 +1067,10 @@ window.__ModuleLoader__.load({
573
1067
  protocol: props.provider.protocol || 'openai-images',
574
1068
  optionalKey: !!props.provider.optionalKey,
575
1069
  models: (props.provider.models || []).slice(),
576
- names: { ...(props.provider.names || {}) }
1070
+ names: { ...(props.provider.names || {}) },
1071
+ modelOptions: { ...(props.provider.modelOptions || {}) }
577
1072
  }));
1073
+ const [optionsFor, setOptionsFor] = React.useState('');
578
1074
  const [advanced, setAdvanced] = React.useState(false);
579
1075
  const [mode, setMode] = React.useState('catalog');
580
1076
  const [presetId, setPresetId] = React.useState('openai');
@@ -582,9 +1078,13 @@ window.__ModuleLoader__.load({
582
1078
  const [modelFetch, setModelFetch] = React.useState({ loading: false, error: '' });
583
1079
  const [candidates, setCandidates] = React.useState(null);
584
1080
  const [candidateQuery, setCandidateQuery] = React.useState('');
585
- const [picked, setPicked] = React.useState([]);
1081
+ // 勾选结果记成「相对默认勾选的翻转集」:已配置的模型默认勾选,取消即翻转。
1082
+ const [flipped, setFlipped] = React.useState(() => new Set());
586
1083
  const [showAllCandidates, setShowAllCandidates] = React.useState(false);
1084
+ const [dragFrom, setDragFrom] = React.useState(-1);
1085
+ const [dropAt, setDropAt] = React.useState(null);
587
1086
  const candidateSearchRef = React.useRef(null);
1087
+ const rowDragPreview = useModelRowDragPreview(MC.modelDragPreview);
588
1088
  const providerPresets = providerPresetsForUi();
589
1089
  const localPresets = localPresetsForUi();
590
1090
  const selectedPreset = providerPresets.find((item) => item.id === presetId) || providerPresets[0] || null;
@@ -596,7 +1096,7 @@ window.__ModuleLoader__.load({
596
1096
  return () => clearTimeout(timer);
597
1097
  }, [candidates]);
598
1098
  const addModel = () => {
599
- setDraft({ ...draft, models: draft.models.concat(''), names: { ...draft.names, '': '' } });
1099
+ setDraft({ ...draft, models: draft.models.concat('') });
600
1100
  };
601
1101
  const localPreset = localPresets.find((item) => item.id === localPresetId) || localPresets[0] || null;
602
1102
  const applyLocalPreset = (id) => {
@@ -616,8 +1116,8 @@ window.__ModuleLoader__.load({
616
1116
  names: {}
617
1117
  }));
618
1118
  };
619
- // 宿主 manifest 比设置页晚到时(例如首屏刚打开),补一次本地 preset 初始化。
620
- React.useEffect(() => {
1119
+ // 宿主 manifest 比设置页晚到时(例如首屏刚打开),补一次本 preset 初始化。
1120
+ React.useEffect(() => {
621
1121
  if (mode === 'local' && localPreset && !draft.adapter) applyLocalPreset(localPreset.id);
622
1122
  }, [mode, localPreset && localPreset.id, draft.adapter]);
623
1123
  const switchMode = (next) => {
@@ -646,8 +1146,8 @@ window.__ModuleLoader__.load({
646
1146
  }));
647
1147
  }
648
1148
  };
649
- // 新建表单默认带出第一个云端 preset(通常是 OpenAI),避免用户先看到空地址。
650
- React.useEffect(() => {
1149
+ // 新建表单默认带出第一个云 preset(通常 OpenAI),避免用户先看到空地址。
1150
+ React.useEffect(() => {
651
1151
  if (!isNew || mode !== 'catalog' || draft.baseUrl || !providerPresets.length) return;
652
1152
  const preset = providerPresets.find((item) => item.id === presetId) || providerPresets[0];
653
1153
  if (!preset) return;
@@ -667,7 +1167,7 @@ window.__ModuleLoader__.load({
667
1167
  const closeCandidates = () => {
668
1168
  setCandidates(null);
669
1169
  setCandidateQuery('');
670
- setPicked([]);
1170
+ setFlipped(new Set());
671
1171
  setShowAllCandidates(false);
672
1172
  };
673
1173
  const fetchModels = async () => {
@@ -691,51 +1191,74 @@ window.__ModuleLoader__.load({
691
1191
  const ids = Array.isArray(data.models) ? data.models : [];
692
1192
  const allModels = Array.isArray(data.allModels) ? data.allModels : ids;
693
1193
  if (!ids.length && !allModels.length) throw new Error(t('errors.noModels'));
694
- const initial = ids.length ? ids : allModels;
695
1194
  setCandidates({
696
1195
  models: ids,
697
1196
  allModels: allModels,
698
- filteredCount: Number(data.filteredCount) || 0
1197
+ filteredCount: Number(data.filteredCount) || 0,
1198
+ // 上游给了显示名就一起带回来,采纳时顺手填进「显示名称」。
1199
+ names: data.names && typeof data.names === 'object' ? data.names : {}
699
1200
  });
700
1201
  setShowAllCandidates(ids.length === 0 && allModels.length > 0);
701
- setPicked(initial.filter((id) => !draft.models.includes(id)));
1202
+ setFlipped(new Set());
702
1203
  setCandidateQuery('');
703
1204
  setModelFetch({ loading: false, error: '' });
704
1205
  } catch (error) {
705
1206
  setModelFetch({ loading: false, error: serverErrorText(t, error) });
706
1207
  }
707
1208
  };
1209
+ // 与对话模型设置的选择弹窗同一套语义:已配置的默认勾选,勾选结果就是新列表。
708
1210
  const candidateSource = candidates
709
1211
  ? (showAllCandidates ? candidates.allModels : candidates.models)
710
1212
  : [];
1213
+ const candidateNames = candidates ? candidates.names : {};
1214
+ const configuredIds = new Set(draft.models.filter((id) => typeof id === 'string' && id.length > 0));
1215
+ const pickedByDefault = (id) => configuredIds.size === 0 || configuredIds.has(id);
1216
+ const isPicked = (id) => pickedByDefault(id) !== flipped.has(id);
711
1217
  const normalizedCandidateQuery = candidateQuery.trim().toLowerCase();
712
1218
  const visibleCandidates = normalizedCandidateQuery
713
- ? candidateSource.filter((id) => id.toLowerCase().includes(normalizedCandidateQuery))
1219
+ ? candidateSource.filter((id) => {
1220
+ if (id.toLowerCase().includes(normalizedCandidateQuery)) return true;
1221
+ const name = candidateNames[id];
1222
+ return typeof name === 'string' && name.toLowerCase().includes(normalizedCandidateQuery);
1223
+ })
714
1224
  : candidateSource;
715
1225
  const allVisiblePicked = visibleCandidates.length > 0
716
- && visibleCandidates.every((id) => picked.includes(id));
1226
+ && visibleCandidates.every((id) => isPicked(id));
717
1227
  const toggleCandidate = (id) => {
718
- setPicked((current) => current.includes(id) ? current.filter((item) => item !== id) : current.concat(id));
1228
+ setFlipped((current) => {
1229
+ const next = new Set(current);
1230
+ if (!next.delete(id)) next.add(id);
1231
+ return next;
1232
+ });
719
1233
  };
720
1234
  const toggleVisibleCandidates = () => {
721
1235
  if (!visibleCandidates.length) return;
722
- setPicked((current) => {
723
- const visible = new Set(visibleCandidates);
724
- if (visibleCandidates.every((id) => current.includes(id))) return current.filter((id) => !visible.has(id));
1236
+ const target = !allVisiblePicked;
1237
+ setFlipped((current) => {
725
1238
  const next = new Set(current);
726
- for (const id of visibleCandidates) next.add(id);
727
- return Array.from(next);
1239
+ for (const id of visibleCandidates) {
1240
+ if (pickedByDefault(id) === target) next.delete(id); else next.add(id);
1241
+ }
1242
+ return next;
728
1243
  });
729
1244
  };
1245
+ const listedIds = new Set(candidateSource);
1246
+ const removedIndexes = new Set();
1247
+ draft.models.forEach((id, at) => { if (listedIds.has(id) && !isPicked(id)) removedIndexes.add(at); });
1248
+ const keptModels = draft.models.filter((_id, at) => !removedIndexes.has(at));
1249
+ const keptIds = new Set(keptModels);
1250
+ const addedModels = candidateSource.filter((id) => isPicked(id) && !keptIds.has(id));
1251
+ const emptiesModelList = draft.models.length > 0 && keptModels.length === 0 && addedModels.length === 0;
730
1252
  const adoptCandidates = () => {
731
- if (!picked.length) return;
732
- const models = draft.models.slice();
733
- const names = { ...draft.names };
734
- for (const id of picked) {
735
- if (!models.includes(id)) {
736
- models.push(id);
737
- names[id] = '';
738
- }
1253
+ if (emptiesModelList) return;
1254
+ const models = keptModels.concat(addedModels);
1255
+ const names = {};
1256
+ for (const id of models) {
1257
+ const existing = draft.names[id];
1258
+ const fetched = candidateNames[id];
1259
+ names[id] = typeof existing === 'string' && existing
1260
+ ? existing
1261
+ : (typeof fetched === 'string' ? fetched : '');
739
1262
  }
740
1263
  setDraft({ ...draft, models: models, names: names });
741
1264
  closeCandidates();
@@ -766,6 +1289,123 @@ window.__ModuleLoader__.load({
766
1289
  ? (props.provider.keySource === 'env' ? t('form.keyEnvSaved') : t('form.keySaved'))
767
1290
  : (props.provider.optionalKey ? t('form.keyLocalOptional') : t('form.keyEnter')));
768
1291
  const keyField = field(t('form.apiKey'), h('input', { className: MC.input, type: 'password', value: draft.key, onChange: (e) => setDraft({ ...draft, key: e.target.value }), placeholder: keyPlaceholder }));
1292
+ const modelNameOf = (id) => (typeof draft.names[id] === 'string' ? draft.names[id] : '');
1293
+ const updateModelId = (index, id) => {
1294
+ const models = draft.models.slice();
1295
+ const previous = models[index];
1296
+ models[index] = id;
1297
+ const names = { ...draft.names };
1298
+ const modelOptions = { ...draft.modelOptions };
1299
+ if (previous !== id) {
1300
+ names[id] = names[previous] || '';
1301
+ delete names[previous];
1302
+ if (modelOptions[previous]) {
1303
+ modelOptions[id] = modelOptions[previous];
1304
+ delete modelOptions[previous];
1305
+ }
1306
+ }
1307
+ setDraft({ ...draft, models: models, names: names, modelOptions: modelOptions });
1308
+ };
1309
+ const updateModelName = (index, name) => {
1310
+ setDraft({ ...draft, names: { ...draft.names, [draft.models[index]]: name } });
1311
+ };
1312
+ const removeModel = (index) => {
1313
+ const names = { ...draft.names };
1314
+ const modelOptions = { ...draft.modelOptions };
1315
+ delete names[draft.models[index]];
1316
+ delete modelOptions[draft.models[index]];
1317
+ setDraft({ ...draft, models: draft.models.filter((_model, at) => at !== index), names: names, modelOptions: modelOptions });
1318
+ };
1319
+ const modelWorkflowOf = (id) => {
1320
+ const entry = draft.modelOptions[id];
1321
+ return entry && typeof entry.workflow === 'string' ? entry.workflow : '';
1322
+ };
1323
+ const setModelWorkflow = (id, workflow) => {
1324
+ const modelOptions = { ...draft.modelOptions };
1325
+ const text = String(workflow || '');
1326
+ if (text.trim()) modelOptions[id] = { ...(modelOptions[id] || {}), workflow: text };
1327
+ else delete modelOptions[id];
1328
+ setDraft({ ...draft, modelOptions: modelOptions });
1329
+ };
1330
+ // 没有自己的 ComfyUI 工作流时,先插一个能跑 SD/SDXL 的骨架,改起来比重写快。
1331
+ const modelWorkflowTemplate = () => JSON.stringify({
1332
+ '1': { class_type: 'CheckpointLoaderSimple', inputs: { ckpt_name: '{{model}}' } },
1333
+ '2': { class_type: 'CLIPTextEncode', inputs: { clip: ['1', 1], text: '{{prompt}}' } },
1334
+ '3': { class_type: 'CLIPTextEncode', inputs: { clip: ['1', 1], text: '{{negative_prompt}}' } },
1335
+ '4': { class_type: 'EmptyLatentImage', inputs: { width: '{{width}}', height: '{{height}}', batch_size: 1 } },
1336
+ '5': {
1337
+ class_type: 'KSampler',
1338
+ inputs: {
1339
+ seed: '{{seed}}', steps: 20, cfg: 7, sampler_name: 'euler', scheduler: 'normal', denoise: 1,
1340
+ model: ['1', 0], positive: ['2', 0], negative: ['3', 0], latent_image: ['4', 0]
1341
+ }
1342
+ },
1343
+ '6': { class_type: 'VAEDecode', inputs: { samples: ['5', 0], vae: ['1', 2] } },
1344
+ '7': { class_type: 'SaveImage', inputs: { filename_prefix: 'dsh-mo-image', images: ['6', 0] } }
1345
+ }, null, 2);
1346
+ const moveModel = (from, to) => {
1347
+ if (from === to || from < 0 || to < 0 || to >= draft.models.length) return;
1348
+ const models = draft.models.slice();
1349
+ const moved = models.splice(from, 1)[0];
1350
+ models.splice(to, 0, moved);
1351
+ setDraft({ ...draft, models: models });
1352
+ };
1353
+ const endRowDrag = () => { setDragFrom(-1); setDropAt(null); };
1354
+ const rowHalf = (event) => {
1355
+ const rect = event.currentTarget.getBoundingClientRect();
1356
+ return event.clientY < rect.top + rect.height / 2 ? 'before' : 'after';
1357
+ };
1358
+ // 每格都是 DSH 设置页的 modelField:ID 与显示名称同一套输入框样式和列宽。
1359
+ const modelField = (field, index, id) => h('label', {
1360
+ className: MC.modelField + (field === 'name' ? ' ' + MC.modelName : '')
1361
+ },
1362
+ field === 'name'
1363
+ ? h('span', { className: MC.modelFieldLabel + ' ' + MC.modelNameLabel }, t('form.displayName'))
1364
+ : null,
1365
+ h('input', {
1366
+ className: MC.input, type: 'text',
1367
+ value: field === 'name' ? modelNameOf(id) : id,
1368
+ placeholder: field === 'name' ? t('form.displayName') : t('form.modelId'),
1369
+ 'aria-label': (field === 'name' ? t('form.displayName') : t('form.modelId')) + ' ' + (index + 1),
1370
+ // 与 DSH 设置页一致:聚焦显示名称时自动展开该行的模型选项(仅 ComfyUI)
1371
+ onFocus: field === 'name' && String(draft.adapter || '') === 'comfyui' && optionsFor !== id
1372
+ ? () => setOptionsFor(id) : undefined,
1373
+ onChange: (event) => {
1374
+ if (field === 'name') updateModelName(index, event.target.value);
1375
+ else updateModelId(index, event.target.value);
1376
+ }
1377
+ })
1378
+ );
1379
+ const modelDragHandle = (index) => {
1380
+ const button = h('button', {
1381
+ type: 'button',
1382
+ className: MC.iconButton + ' ' + MC.modelDragHandle,
1383
+ 'aria-label': t('form.reorderModel') + ' ' + (index + 1),
1384
+ 'aria-keyshortcuts': 'ArrowUp ArrowDown',
1385
+ 'aria-description': t('form.reorderModelHelp'),
1386
+ title: DshTooltip ? undefined : t('form.reorderModelHelp'),
1387
+ draggable: true,
1388
+ onDragStart: (event) => {
1389
+ if (event.dataTransfer) {
1390
+ event.dataTransfer.effectAllowed = 'move';
1391
+ try { event.dataTransfer.setData('application/x-mo-image-model-order', String(index)); } catch (_error) { /* ignore */ }
1392
+ }
1393
+ setDragFrom(index);
1394
+ try {
1395
+ const row = event.currentTarget.closest('[data-row-key]');
1396
+ if (row) rowDragPreview.start(event, row);
1397
+ } catch (_error) { /* 预览失败不影响拖动本身 */ }
1398
+ },
1399
+ onDragEnd: () => { rowDragPreview.clear(); endRowDrag(); },
1400
+ onKeyDown: (event) => {
1401
+ if (event.key !== 'ArrowUp' && event.key !== 'ArrowDown') return;
1402
+ event.preventDefault();
1403
+ event.stopPropagation();
1404
+ moveModel(index, index + (event.key === 'ArrowUp' ? -1 : 1));
1405
+ }
1406
+ }, IconDragHandle ? h(IconDragHandle, { size: 14 }) : '\u22ee');
1407
+ return DshTooltip ? h(DshTooltip, { label: t('form.reorderModelHelp'), portal: true }, button) : button;
1408
+ };
769
1409
  const modelDirectory = h('div', { className: MC.modelCatalog },
770
1410
  h('div', { className: MC.modelListHead, style: { display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: 8 } },
771
1411
  h('div', { className: MC.modelCatalogHeading },
@@ -779,129 +1419,124 @@ window.__ModuleLoader__.load({
779
1419
  onClick: fetchModels
780
1420
  }, modelFetch.loading ? t('form.fetching') : t('form.fetchModels')) : null
781
1421
  ),
782
- modelFetch.error ? h('p', { className: MC.advancedHint, style: { color: 'var(--dsw-alias-state-error-primary)', margin: 0 } }, modelFetch.error) : null,
1422
+ modelFetch.error ? h('p', { className: MC.error, role: 'alert' }, modelFetch.error) : null,
783
1423
  draft.models.length ? h('div', { className: MC.modelList },
784
- draft.models.map((model, index) => h('div', { className: MC.modelEntry, key: index },
785
- h('div', { className: MC.modelRow },
786
- h('input', {
787
- className: MC.input, value: model, placeholder: t('form.modelId'),
788
- onChange: (e) => {
789
- const next = draft.models.slice();
790
- const old = next[index];
791
- next[index] = e.target.value;
792
- const names = { ...draft.names };
793
- if (old !== e.target.value) {
794
- names[e.target.value] = names[old] || '';
795
- delete names[old];
1424
+ draft.models.map((model, index) => {
1425
+ const dragging = dragFrom === index;
1426
+ const target = !dragging && dragFrom >= 0 && dropAt && dropAt.index === index ? dropAt.half : null;
1427
+ // 自定义工作流只对 ComfyUI 部署器有意义,其它提供商(含云端)禁用该入口。
1428
+ const workflowSupported = String(draft.adapter || '') === 'comfyui';
1429
+ const optionsOpen = optionsFor === model && model !== '' && workflowSupported;
1430
+ return h('div', {
1431
+ className: MC.modelEntry,
1432
+ key: index,
1433
+ 'data-row-key': String(index),
1434
+ 'data-dragging': dragging || undefined,
1435
+ 'data-drop-target': target || undefined,
1436
+ onDragOver: (event) => {
1437
+ if (dragFrom < 0) return;
1438
+ event.preventDefault();
1439
+ if (event.dataTransfer) event.dataTransfer.dropEffect = 'move';
1440
+ const half = rowHalf(event);
1441
+ setDropAt((current) => (current && current.index === index && current.half === half ? current : { index: index, half: half }));
1442
+ },
1443
+ onDragLeave: (event) => {
1444
+ if (event.relatedTarget && event.currentTarget.contains(event.relatedTarget)) return;
1445
+ setDropAt((current) => (current && current.index === index ? null : current));
1446
+ },
1447
+ onDrop: (event) => {
1448
+ if (dragFrom < 0) return;
1449
+ event.preventDefault();
1450
+ const insertion = index + (rowHalf(event) === 'after' ? 1 : 0);
1451
+ moveModel(dragFrom, insertion > dragFrom ? insertion - 1 : insertion);
1452
+ endRowDrag();
1453
+ }
1454
+ },
1455
+ h('div', { className: MC.modelRow, 'data-expanded': optionsOpen || undefined },
1456
+ modelDragHandle(index),
1457
+ modelField('id', index, model),
1458
+ // 「模型选项」:和 DSH 设置页一致,是 ID 与删除之间的折叠箭头图标按钮
1459
+ h('button', {
1460
+ type: 'button',
1461
+ className: MC.iconButton,
1462
+ disabled: !workflowSupported,
1463
+ 'aria-label': t('form.modelOptions') + ' ' + (index + 1),
1464
+ 'aria-expanded': optionsOpen,
1465
+ title: workflowSupported ? t('form.modelOptions') : t('form.modelOptionsUnsupported'),
1466
+ onClick: (event) => {
1467
+ event.currentTarget.focus();
1468
+ setOptionsFor(optionsOpen ? '' : model);
796
1469
  }
797
- setDraft({ ...draft, models: next, names: names });
798
- }
799
- }),
800
- h('input', { className: MC.input, value: draft.names[model] || '', onChange: (e) => setDraft({ ...draft, names: { ...draft.names, [model]: e.target.value } }), placeholder: t('form.displayName') }),
801
- h('button', { type: 'button', className: MC.iconButton, disabled: true, title: t('form.modelSettings'), 'aria-label': t('form.modelSettings') },
802
- IconChevronRight ? h(IconChevronRight, {}) : '›'
803
- ),
804
- h('button', {
805
- type: 'button', className: MC.iconButton + ' ' + MC.iconButtonDanger,
806
- onClick: () => {
807
- const names = { ...draft.names };
808
- delete names[model];
809
- setDraft({ ...draft, models: draft.models.filter((_m, at) => at !== index), names: names });
810
- },
811
- title: t('form.deleteModel'), 'aria-label': t('form.deleteModel')
812
- }, IconTrash ? h(IconTrash, { size: 14 }) : '×')
813
- )
814
- ))
1470
+ }, optionsOpen
1471
+ ? (IconChevronDown ? h(IconChevronDown, {}) : '\u25be')
1472
+ : (IconChevronRight ? h(IconChevronRight, {}) : '\u25b8')),
1473
+ h('button', {
1474
+ type: 'button', className: MC.iconButton + ' ' + MC.iconButtonDanger,
1475
+ onClick: () => removeModel(index),
1476
+ title: t('form.deleteModel'), 'aria-label': t('form.deleteModel') + ' ' + (index + 1)
1477
+ }, IconTrash ? h(IconTrash, { size: 14 }) : '×'),
1478
+ modelField('name', index, model),
1479
+ optionsOpen ? h('div', { className: MC.modelAdvanced },
1480
+ h('p', { className: MC.advancedHint, style: { gridColumn: '1 / -1', margin: 0 } },
1481
+ t('form.modelOptionsHint')),
1482
+ h('label', { className: MC.modelField, style: { gridColumn: '1 / -1' } },
1483
+ h('span', { className: MC.modelFieldLabel }, t('form.modelWorkflow')),
1484
+ h('textarea', {
1485
+ className: MC.input,
1486
+ rows: 16,
1487
+ spellCheck: false,
1488
+ style: {
1489
+ fontFamily: 'var(--ds-font-family-code, ui-monospace, monospace)',
1490
+ fontSize: 13,
1491
+ minHeight: 320,
1492
+ resize: 'vertical'
1493
+ },
1494
+ value: modelWorkflowOf(model),
1495
+ placeholder: t('form.modelWorkflowPlaceholder'),
1496
+ onChange: (event) => setModelWorkflow(model, event.target.value)
1497
+ })
1498
+ ),
1499
+ h('p', { className: MC.advancedHint, style: { gridColumn: '1 / -1', margin: 0 } },
1500
+ t('form.modelWorkflowHelp')),
1501
+ h('div', { className: MC.rowActions, style: { gridColumn: '1 / -1' } },
1502
+ h('button', {
1503
+ type: 'button', className: MC.secondaryButton,
1504
+ onClick: () => setModelWorkflow(model, modelWorkflowTemplate())
1505
+ }, t('form.modelWorkflowSample')),
1506
+ modelWorkflowOf(model) ? h('button', {
1507
+ type: 'button', className: MC.dangerButton,
1508
+ onClick: () => setModelWorkflow(model, '')
1509
+ }, t('form.modelWorkflowClear')) : null
1510
+ )
1511
+ ) : null
1512
+ )
1513
+ );
1514
+ })
815
1515
  ) : h('div', { className: MC.modelEmpty }, t('form.modelEmpty')),
816
1516
  h('button', { type: 'button', className: MC.addModelButton, onClick: addModel },
817
1517
  IconPlus ? h(IconPlus, { size: 14 }) : null,
818
1518
  t('form.addModel')
819
1519
  )
820
1520
  );
821
- const modelPicker = candidates ? createPortal(h('div', {
822
- style: {
823
- position: 'fixed', inset: 0, zIndex: 10000, padding: 16,
824
- display: 'flex', alignItems: 'center', justifyContent: 'center',
825
- background: 'rgba(0, 0, 0, 0.45)'
826
- },
827
- onMouseDown: (event) => { if (event.target === event.currentTarget) closeCandidates(); }
828
- }, h('div', {
829
- role: 'dialog', 'aria-modal': 'true', 'aria-label': t('picker.title'), tabIndex: -1,
830
- onKeyDown: (event) => {
831
- if (event.key === 'Escape') { event.stopPropagation(); closeCandidates(); }
832
- },
833
- style: {
834
- width: 'min(560px, 100%)', maxHeight: 'min(82vh, 760px)', overflow: 'hidden',
835
- display: 'flex', flexDirection: 'column', gap: 12, padding: '16px 18px',
836
- border: '0.5px solid var(--dsw-alias-border-l3)', borderRadius: 'var(--dsw-radius-xl)',
837
- background: 'var(--dsw-alias-bg-module-platform)', color: 'var(--dsw-alias-label-primary)',
838
- boxShadow: '0 18px 48px rgba(0, 0, 0, 0.28)'
839
- }
840
- },
841
- h('div', { style: { display: 'flex', alignItems: 'center', gap: 8 } },
842
- h('strong', { style: { fontSize: 15 } }, t('picker.title')),
843
- h('button', { type: 'button', className: MC.linkButton, style: { marginLeft: 'auto' }, onClick: closeCandidates }, t('picker.close'))
844
- ),
845
- h('p', { className: MC.advancedHint, style: { margin: 0 } },
846
- t('picker.description')
847
- ),
848
- h('div', { style: { display: 'flex', alignItems: 'center', gap: 8 } },
849
- h('input', {
850
- ref: candidateSearchRef, className: MC.input, type: 'search',
851
- value: candidateQuery, placeholder: t('picker.search'), 'aria-label': t('picker.search'),
852
- style: { flex: 1 }, autoFocus: true,
853
- onChange: (event) => setCandidateQuery(event.target.value)
854
- }),
855
- h('button', {
856
- type: 'button', className: MC.linkButton,
857
- disabled: !visibleCandidates.length,
858
- onClick: toggleVisibleCandidates
859
- }, allVisiblePicked ? t('picker.deselectAll') : t('picker.selectAll'))
860
- ),
861
- candidates.filteredCount > 0 ? h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap' } },
862
- h('label', { style: { display: 'inline-flex', alignItems: 'center', gap: 6, fontSize: 12, color: 'var(--dsw-alias-label-secondary)' } },
863
- h('input', {
864
- type: 'checkbox', checked: showAllCandidates,
865
- onChange: (event) => setShowAllCandidates(event.target.checked)
866
- }),
867
- t('picker.showAll')
868
- ),
869
- h('span', { className: MC.advancedHint, style: { margin: 0 } },
870
- t('picker.filtered', { count: candidates.filteredCount })
871
- )
872
- ) : null,
873
- h('div', {
874
- role: 'list', 'aria-label': t('picker.listAria'),
875
- style: { minHeight: 120, maxHeight: 320, overflowY: 'auto', display: 'flex', flexDirection: 'column', gap: 2 }
876
- },
877
- visibleCandidates.length ? visibleCandidates.map((id) => h('label', {
878
- key: id,
879
- style: {
880
- display: 'flex', alignItems: 'center', gap: 8, padding: '6px 8px',
881
- borderRadius: 'var(--dsw-radius-md)', cursor: 'pointer', fontSize: 13
882
- }
883
- },
884
- h('input', {
885
- type: 'checkbox', checked: picked.includes(id),
886
- onChange: () => toggleCandidate(id)
887
- }),
888
- h('span', {
889
- title: id,
890
- style: {
891
- minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
892
- fontFamily: 'var(--ds-font-family-code)'
893
- }
894
- }, id)
895
- )) : h('p', { className: MC.modelEmpty, style: { margin: 'auto' } }, t('picker.noMatches'))
896
- ),
897
- h('div', { style: { display: 'flex', justifyContent: 'flex-end', gap: 8 } },
898
- h('button', { type: 'button', className: MC.secondaryButton, onClick: closeCandidates }, t('form.cancel')),
899
- h('button', {
900
- type: 'button', className: MC.primaryButton,
901
- disabled: !picked.length, onClick: adoptCandidates
902
- }, picked.length ? t('picker.adoptCount', { count: picked.length }) : t('picker.adopt'))
903
- )
904
- )), document.body) : null;
1521
+ const modelPicker = h(ModelFetchDialog, {
1522
+ open: !!candidates,
1523
+ t: t,
1524
+ query: candidateQuery,
1525
+ onQuery: setCandidateQuery,
1526
+ visible: visibleCandidates,
1527
+ names: candidateNames,
1528
+ filteredCount: candidates ? candidates.filteredCount : 0,
1529
+ showAll: showAllCandidates,
1530
+ onShowAll: setShowAllCandidates,
1531
+ allPicked: allVisiblePicked,
1532
+ isPicked: isPicked,
1533
+ onToggle: toggleCandidate,
1534
+ onToggleAll: toggleVisibleCandidates,
1535
+ emptiesList: emptiesModelList,
1536
+ onClose: closeCandidates,
1537
+ onAdopt: adoptCandidates,
1538
+ searchRef: candidateSearchRef
1539
+ });
905
1540
  const actions = h('div', { className: MC.editorActions },
906
1541
  h('button', { type: 'button', className: MC.secondaryButton, onClick: props.onClose }, t('form.cancel')),
907
1542
  h('button', { type: 'button', className: MC.primaryButton, onClick: () => props.onSave({ ...draft, key: draft.key.trim() }) }, t('form.save'))
@@ -1030,36 +1665,36 @@ window.__ModuleLoader__.load({
1030
1665
  const t = props.t || fallbackTranslate;
1031
1666
  const status = props.status || {};
1032
1667
  const busy = status.state === 'updating';
1033
- return h('div', {
1034
- style: { display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: 12 }
1035
- },
1036
- h('div', null,
1668
+ return h(React.Fragment, null,
1669
+ h('div', {
1670
+ style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12 }
1671
+ },
1037
1672
  h('h2', { className: MC.title }, t('section.title')),
1038
- h('p', { className: MC.intro }, t('section.intro'))
1673
+ busy || status.state === 'available'
1674
+ ? h('button', {
1675
+ type: 'button',
1676
+ className: MC.linkButton,
1677
+ 'data-mo-image-update': '',
1678
+ disabled: busy,
1679
+ onClick: props.onOpen,
1680
+ style: {
1681
+ flex: 'none',
1682
+ padding: '3px 10px',
1683
+ borderRadius: 999,
1684
+ border: '1px solid var(--dsw-alias-state-business-primary, #4d6bfe)',
1685
+ background: 'transparent',
1686
+ color: 'var(--dsw-alias-state-business-primary, #4d6bfe)',
1687
+ fontSize: 12,
1688
+ lineHeight: '18px',
1689
+ fontWeight: 500,
1690
+ cursor: busy ? 'default' : 'pointer',
1691
+ opacity: busy ? 0.6 : 1,
1692
+ whiteSpace: 'nowrap'
1693
+ }
1694
+ }, busy ? t('update.starting') : t('update.available'))
1695
+ : null
1039
1696
  ),
1040
- busy || status.state === 'available'
1041
- ? h('button', {
1042
- type: 'button',
1043
- className: MC.linkButton,
1044
- 'data-mo-image-update': '',
1045
- disabled: busy,
1046
- onClick: props.onOpen,
1047
- style: {
1048
- flex: 'none',
1049
- padding: '3px 10px',
1050
- borderRadius: 999,
1051
- border: '1px solid var(--dsw-alias-state-business-primary, #4d6bfe)',
1052
- background: 'transparent',
1053
- color: 'var(--dsw-alias-state-business-primary, #4d6bfe)',
1054
- fontSize: 12,
1055
- lineHeight: '18px',
1056
- fontWeight: 500,
1057
- cursor: busy ? 'default' : 'pointer',
1058
- opacity: busy ? 0.6 : 1,
1059
- whiteSpace: 'nowrap'
1060
- }
1061
- }, busy ? t('update.starting') : t('update.available'))
1062
- : null
1697
+ h('p', { className: MC.intro }, t('section.intro'))
1063
1698
  );
1064
1699
  }
1065
1700
 
@@ -1158,8 +1793,8 @@ window.__ModuleLoader__.load({
1158
1793
  const started = Date.now();
1159
1794
  const tick = async () => {
1160
1795
  if (!alive) return;
1161
- // 插件正在被换掉时这条路由会短暂 404/断连;拿不到就当「再等等」。
1162
- const status = await fetchUpdateStatus();
1796
+ // 插件正在被换掉时这条路由会短 404/断连;拿不到就当「再等等」。
1797
+ const status = await fetchUpdateStatus();
1163
1798
  if (!alive) return;
1164
1799
  if (status) {
1165
1800
  const text = updateToastFor(status, t);
@@ -1216,7 +1851,7 @@ window.__ModuleLoader__.load({
1216
1851
  if (!alive || !status) return;
1217
1852
  setUpdate(status);
1218
1853
  // 首次检查可能要跑十几秒(API 超时后还要试降级地址),多等几轮。
1219
- if ((status.state === 'checking' || !status.checkedAt) && attempt < 10) {
1854
+ if ((status.state === 'checking' || !status.checkedAt) && attempt < 10) {
1220
1855
  setTimeout(() => { if (alive) load(attempt + 1); }, 2000);
1221
1856
  }
1222
1857
  };
@@ -1270,12 +1905,14 @@ window.__ModuleLoader__.load({
1270
1905
  store.providers.map((provider) => {
1271
1906
  const ready = !!(provider.baseUrl && (provider.hasKey || provider.key || provider.optionalKey) && provider.models.length);
1272
1907
  const local = !!provider.optionalKey || ['a1111', 'comfyui', 'swarmui'].includes(String(provider.adapter || ''));
1908
+ // 内置提供商有名字有官网,只在自定义端点时才需要「自定义」标签。
1909
+ const tag = local ? t('tag.local') : (isBuiltinProvider(provider) ? '' : t('tag.custom'));
1273
1910
  const editing = edit && !edit.isNew && edit.provider.id === provider.id;
1274
1911
  return h('li', { className: MC.rowCard, key: provider.id },
1275
1912
  h('div', { className: MC.rowHead },
1276
1913
  h('span', { className: MC.rowIdentity },
1277
1914
  h('span', { className: MC.rowName }, provider.name || t('section.unnamedProvider')),
1278
- h('span', { className: MC.rowTag }, local ? t('tag.local') : t('tag.custom')),
1915
+ tag ? h('span', { className: MC.rowTag }, tag) : null,
1279
1916
  h('span', {
1280
1917
  className: MC.credentialDot + ' ' + (ready ? MC.credentialDotConfigured : MC.credentialDotMissing),
1281
1918
  title: ready ? t('status.ready') : (provider.optionalKey ? t('status.missingLocal') : t('status.missingCloud')),
@@ -1307,10 +1944,733 @@ window.__ModuleLoader__.load({
1307
1944
  );
1308
1945
  }
1309
1946
 
1947
+ /**
1948
+ * Codex skin for the image seat. It reuses the global cmes-* classes and the
1949
+ * DOM shape already injected by dsh-codex-model-effort-selector, so both
1950
+ * seats read as one skin. "Quality" takes the effort rail slot; size and
1951
+ * prompt optimization live in the gear "other settings" page.
1952
+ */
1953
+ function CodexImageSeat(props) {
1954
+ const t = props.t || fallbackTranslate;
1955
+ const store = props.store || { providers: [], active: { providerId: '', model: '' }, defaults: normalizeDefaults(null) };
1956
+ const setStore = typeof props.setStore === 'function' ? props.setStore : () => {};
1957
+ const seatView = deriveSeatView(store, t, props.qualitySpec);
1958
+ const defaults = seatView.defaults;
1959
+ const active = seatView.active;
1960
+ const activeProvider = seatView.activeProvider;
1961
+ const activeModelName = seatView.activeModelName;
1962
+ const triggerLabel = seatView.triggerLabel;
1963
+ const activeSpec = seatView.qualitySpec;
1964
+ const levels = qualityRailLevels(activeSpec);
1965
+
1966
+ function isDarkNow() {
1967
+ try {
1968
+ return typeof document !== 'undefined' && document.body != null
1969
+ && typeof document.body.hasAttribute === 'function'
1970
+ && document.body.hasAttribute('data-ds-dark-theme');
1971
+ } catch (_error) { return false; }
1972
+ }
1973
+ const [dark, setDark] = React.useState(isDarkNow());
1974
+ React.useEffect(() => {
1975
+ if (typeof MutationObserver === 'undefined' || typeof document === 'undefined' || !document.body) return undefined;
1976
+ const observer = new MutationObserver(() => setDark(isDarkNow()));
1977
+ observer.observe(document.body, { attributes: true, attributeFilter: ['data-ds-dark-theme'] });
1978
+ return () => observer.disconnect();
1979
+ }, []);
1980
+ const [open, setOpen] = React.useState(false);
1981
+ const [pane, setPane] = React.useState('quality');
1982
+ const [view, setView] = React.useState(1);
1983
+ const [subProvider, setSubProvider] = React.useState(null);
1984
+ const [query, setQuery] = React.useState('');
1985
+ const [highlight, setHighlight] = React.useState(0);
1986
+ const [preview, setPreview] = React.useState(null);
1987
+ const [dragging, setDragging] = React.useState(false);
1988
+ const [message, setMessage] = React.useState(false);
1989
+ const [bloom, setBloom] = React.useState(0);
1990
+ const [widthDraft, setWidthDraft] = React.useState('');
1991
+ const [heightDraft, setHeightDraft] = React.useState('');
1992
+ const [menuPos, setMenuPos] = React.useState(null);
1993
+ const [liveFraction, setLiveFraction] = React.useState(null);
1994
+ const [hoveredDot, setHoveredDot] = React.useState(-1);
1995
+ const [fast, setFastState] = React.useState(() => readCodexFast(props.sessionId));
1996
+ const setFast = (next) => {
1997
+ setFastState(next);
1998
+ writeCodexFast(props.sessionId, next);
1999
+ };
2000
+ React.useEffect(() => {
2001
+ setFastState(readCodexFast(props.sessionId));
2002
+ }, [props.sessionId]);
2003
+ const triggerRef = React.useRef(null);
2004
+ const popoverRef = React.useRef(null);
2005
+ const railRef = React.useRef(null);
2006
+ const searchRef = React.useRef(null);
2007
+ const messageTimer = React.useRef(0);
2008
+ const dragRef = React.useRef(null);
2009
+ const seenIndexRef = React.useRef(null);
2010
+
2011
+ const value = qualityValueFor(defaults.quality, activeSpec);
2012
+ const levelIndex = Math.max(0, levels.findIndex((level) => level.value === value));
2013
+ const displayed = preview !== null ? preview : value;
2014
+ const displayIndex = Math.max(0, levels.findIndex((level) => level.value === displayed));
2015
+ const fraction = dragging && liveFraction !== null
2016
+ ? liveFraction
2017
+ : (levels.length > 1 ? displayIndex / (levels.length - 1) : 0);
2018
+ // 动画和额度提示都跟「滑到最高档」走;Auto 不在最高档时不误报。
2019
+ const atTop = levels.length > 1 && displayIndex === levels.length - 1;
2020
+ const peak = atTop;
2021
+ const qualityLabel = levels.length ? qualityLabelFor(value, activeSpec, t) : '';
2022
+ const displayLabel = levels.length ? qualityLabelFor(displayed, activeSpec, t) : '';
2023
+ const sparkles = React.useMemo(() => buildCodexSparkles(22), []);
2024
+ const bloomMotes = React.useMemo(() => buildCodexBloom(18), []);
2025
+ const hasAnyModel = seatView.hasAnyModel;
2026
+ const selectedAuto = active.model === 'auto';
2027
+ const showAutoRow = hasAnyModel;
2028
+ const activeProviderForPage = subProvider && subProvider !== '__size'
2029
+ ? store.providers.find((provider) => provider.id === subProvider) || null
2030
+ : null;
2031
+ const isSettingsPage = subProvider === '__size';
2032
+
2033
+ const closeMenu = () => {
2034
+ setOpen(false);
2035
+ setPane('quality');
2036
+ setView(1);
2037
+ setSubProvider(null);
2038
+ setQuery('');
2039
+ setMessage(false);
2040
+ };
2041
+
2042
+ const saveDefaults = (patch) => commitSeatDefaults(store, defaults, setStore, patch, t);
2043
+ const isTopQuality = (value) => levels.length > 1
2044
+ && levels.findIndex((level) => level.value === value) === levels.length - 1;
2045
+ const flashPeakWarning = (nextValue, previousValue) => {
2046
+ const wasTop = isTopQuality(previousValue);
2047
+ const nowTop = isTopQuality(nextValue);
2048
+ if (messageTimer.current) { clearTimeout(messageTimer.current); messageTimer.current = 0; }
2049
+ if (nowTop && !wasTop) {
2050
+ setMessage(true);
2051
+ messageTimer.current = setTimeout(() => { messageTimer.current = 0; setMessage(false); }, 1800);
2052
+ } else if (!nowTop) {
2053
+ setMessage(false);
2054
+ }
2055
+ };
2056
+ const chooseQuality = (nextValue) => {
2057
+ const wanted = activeSpec ? qualityValueFor(nextValue, activeSpec) : nextValue;
2058
+ flashPeakWarning(wanted, value);
2059
+ saveDefaults({ quality: wanted });
2060
+ setPreview(null);
2061
+ };
2062
+ const chooseModel = (providerId, model) => {
2063
+ commitSeatModel(store, defaults, setStore, providerId, model, t);
2064
+ setPane('quality');
2065
+ setView(1);
2066
+ setSubProvider(null);
2067
+ setQuery('');
2068
+ setPreview(null);
2069
+ };
2070
+ const chooseAuto = () => {
2071
+ chooseModel(activeProvider ? activeProvider.id : '', 'auto');
2072
+ };
2073
+ const openProvider = (providerId) => {
2074
+ setSubProvider(providerId);
2075
+ setView(2);
2076
+ setQuery('');
2077
+ setHighlight(0);
2078
+ };
2079
+ const openSettings = () => {
2080
+ setPane('models');
2081
+ setSubProvider('__size');
2082
+ setView(2);
2083
+ setQuery('');
2084
+ };
2085
+ const goBack = () => {
2086
+ if (isSettingsPage) {
2087
+ setPane('quality');
2088
+ setView(1);
2089
+ setSubProvider(null);
2090
+ setQuery('');
2091
+ setHighlight(0);
2092
+ return;
2093
+ }
2094
+ setView(1);
2095
+ setSubProvider(null);
2096
+ setQuery('');
2097
+ setHighlight(0);
2098
+ };
2099
+
2100
+ // 弹层定位:贴住触发器右缘向上展开(生图席在输入区最右侧)。
2101
+ React.useLayoutEffect(() => {
2102
+ // 关闭时保留最后一次位置给退场动画用;清空会 .closed 的过渡在
2103
+ // left:0/bottom:40 的兜底位置播放,看起来就是左下角闪一下。
2104
+ if (!open) return undefined;
2105
+ const place = () => {
2106
+ const trigger = triggerRef.current;
2107
+ if (!trigger || typeof trigger.getBoundingClientRect !== 'function') return;
2108
+ setMenuPos(codexPlacement(
2109
+ trigger.getBoundingClientRect(),
2110
+ { width: window.innerWidth, height: window.innerHeight },
2111
+ CODEX_POPOVER_WIDTH,
2112
+ CODEX_MARGIN
2113
+ ));
2114
+ };
2115
+ place();
2116
+ window.addEventListener('scroll', place, true);
2117
+ window.addEventListener('resize', place);
2118
+ const observer = typeof ResizeObserver !== 'undefined'
2119
+ ? new ResizeObserver(() => place())
2120
+ : null;
2121
+ if (observer && triggerRef.current) observer.observe(triggerRef.current);
2122
+ return () => {
2123
+ window.removeEventListener('scroll', place, true);
2124
+ window.removeEventListener('resize', place);
2125
+ if (observer) observer.disconnect();
2126
+ };
2127
+ }, [open, pane]);
2128
+
2129
+ // 外部点击 / Escape 逐层退避。
2130
+ React.useEffect(() => {
2131
+ if (!open) return undefined;
2132
+ const onPointerDown = (event) => {
2133
+ const trigger = triggerRef.current;
2134
+ const popover = popoverRef.current;
2135
+ if (trigger && trigger.contains(event.target)) return;
2136
+ if (popover && popover.contains(event.target)) return;
2137
+ closeMenu();
2138
+ };
2139
+ const onKey = (event) => {
2140
+ if (event.key !== 'Escape') return;
2141
+ event.stopPropagation();
2142
+ event.preventDefault();
2143
+ if (pane === 'models' && view === 2) goBack();
2144
+ else if (pane === 'models') setPane('quality');
2145
+ else closeMenu();
2146
+ };
2147
+ document.addEventListener('mousedown', onPointerDown);
2148
+ document.addEventListener('keydown', onKey, true);
2149
+ return () => {
2150
+ document.removeEventListener('mousedown', onPointerDown);
2151
+ document.removeEventListener('keydown', onKey, true);
2152
+ };
2153
+ }, [open, pane, view, subProvider]);
2154
+
2155
+ React.useEffect(() => {
2156
+ if (!open || pane !== 'models' || view !== 2 || isSettingsPage) return undefined;
2157
+ const timer = setTimeout(() => {
2158
+ try { if (searchRef.current) searchRef.current.focus(); } catch (_error) { /* ignore */ }
2159
+ }, 40);
2160
+ return () => clearTimeout(timer);
2161
+ }, [open, pane, view, isSettingsPage]);
2162
+
2163
+ // 抵达峰值档时触发一次绽开;打开时本来就停在峰值不炸。
2164
+ React.useEffect(() => {
2165
+ if (!open || !levels.length) { seenIndexRef.current = null; return; }
2166
+ const previous = seenIndexRef.current;
2167
+ seenIndexRef.current = displayIndex;
2168
+ if (previous === null) return;
2169
+ if (displayIndex === levels.length - 1 && previous !== displayIndex) {
2170
+ setBloom((count) => count + 1);
2171
+ }
2172
+ }, [open, displayIndex, levels.length, displayed]);
2173
+
2174
+ React.useEffect(() => () => {
2175
+ if (messageTimer.current) clearTimeout(messageTimer.current);
2176
+ }, []);
2177
+
2178
+ const commitSide = (side, text) => {
2179
+ const digits = String(text || '').replace(/[^0-9]/g, '');
2180
+ const number = Number(digits);
2181
+ if (!Number.isFinite(number) || number < IMAGE_MIN_SIDE || number > IMAGE_MAX_SIDE) return;
2182
+ saveDefaults(side === 'width' ? { width: number } : { height: number });
2183
+ };
2184
+ const fractionAt = (clientX) => {
2185
+ const rail = railRef.current;
2186
+ if (!rail || typeof rail.getBoundingClientRect !== 'function') return 0;
2187
+ const box = rail.getBoundingClientRect();
2188
+ if (!box || box.width <= 30) return 0;
2189
+ return Math.max(0, Math.min(1, (clientX - box.left - 15) / (box.width - 30)));
2190
+ };
2191
+ const paintLive = (fractionValue) => {
2192
+ const rail = railRef.current;
2193
+ if (rail && rail.style && typeof rail.style.setProperty === 'function') {
2194
+ rail.style.setProperty('--cmes-pos', String(fractionValue));
2195
+ }
2196
+ };
2197
+ const snapTo = (index) => {
2198
+ const safe = Math.max(0, Math.min(levels.length - 1, index));
2199
+ paintLive(levels.length > 1 ? safe / (levels.length - 1) : 0);
2200
+ return safe;
2201
+ };
2202
+ const pointerDown = (event) => {
2203
+ if (!levels.length) return;
2204
+ if (event && event.button !== undefined && event.button !== 0) return;
2205
+ if (event && typeof event.preventDefault === 'function') event.preventDefault();
2206
+ try { if (railRef.current && railRef.current.focus) railRef.current.focus({ preventScroll: true }); } catch (_error) { /* ignore */ }
2207
+ const pointerId = event && event.pointerId !== undefined ? event.pointerId : 0;
2208
+ dragRef.current = { pointerId: pointerId };
2209
+ setDragging(true);
2210
+ const move = (moveEvent) => {
2211
+ if (!dragRef.current || (moveEvent.pointerId !== undefined && moveEvent.pointerId !== dragRef.current.pointerId)) return;
2212
+ const ratio = fractionAt(moveEvent.clientX);
2213
+ paintLive(ratio);
2214
+ setLiveFraction(ratio);
2215
+ const nearest = Math.round(ratio * (levels.length - 1));
2216
+ setPreview(levels[Math.max(0, Math.min(levels.length - 1, nearest))].value);
2217
+ };
2218
+ const finish = (upEvent) => {
2219
+ if (!dragRef.current) return;
2220
+ dragRef.current = null;
2221
+ document.removeEventListener('pointermove', move, true);
2222
+ document.removeEventListener('pointerup', finish, true);
2223
+ document.removeEventListener('pointercancel', cancel, true);
2224
+ setDragging(false);
2225
+ setLiveFraction(null);
2226
+ const index = upEvent && upEvent.clientX !== undefined
2227
+ ? Math.round(fractionAt(upEvent.clientX) * (levels.length - 1))
2228
+ : levelIndex;
2229
+ const safe = snapTo(index);
2230
+ const target = levels[safe];
2231
+ if (target) chooseQuality(target.value);
2232
+ else setPreview(null);
2233
+ };
2234
+ const cancel = () => {
2235
+ if (!dragRef.current) return;
2236
+ dragRef.current = null;
2237
+ document.removeEventListener('pointermove', move, true);
2238
+ document.removeEventListener('pointerup', finish, true);
2239
+ document.removeEventListener('pointercancel', cancel, true);
2240
+ setDragging(false);
2241
+ setLiveFraction(null);
2242
+ setPreview(null);
2243
+ snapTo(levelIndex);
2244
+ };
2245
+ document.addEventListener('pointermove', move, true);
2246
+ document.addEventListener('pointerup', finish, true);
2247
+ document.addEventListener('pointercancel', cancel, true);
2248
+ move(event);
2249
+ };
2250
+ const railKeyDown = (event) => {
2251
+ if (!levels.length) return;
2252
+ let next = displayIndex;
2253
+ if (event.key === 'ArrowRight' || event.key === 'ArrowUp') next += 1;
2254
+ else if (event.key === 'ArrowLeft' || event.key === 'ArrowDown') next -= 1;
2255
+ else if (event.key === 'Home') next = 0;
2256
+ else if (event.key === 'End') next = levels.length - 1;
2257
+ else return;
2258
+ event.preventDefault();
2259
+ const safe = snapTo(next);
2260
+ chooseQuality(levels[safe].value);
2261
+ };
2262
+
2263
+ const providerModels = activeProviderForPage
2264
+ ? activeProviderForPage.models.filter((model) => {
2265
+ const needle = query.trim().toLowerCase();
2266
+ if (!needle) return true;
2267
+ const display = modelDisplayName(activeProviderForPage, model).toLowerCase();
2268
+ if (model.toLowerCase().includes(needle) || display.includes(needle)) return true;
2269
+ let at = 0;
2270
+ for (const char of display) if (char === needle[at]) at += 1;
2271
+ return at === needle.length;
2272
+ })
2273
+ : [];
2274
+ const page2Rows = providerModels.length;
2275
+ const page1Rows = (showAutoRow ? 1 : 0) + store.providers.length;
2276
+ let desiredHeight = CODEX_QUALITY_HEIGHT;
2277
+ if (pane === 'models') {
2278
+ const M = CODEX_METRICS;
2279
+ desiredHeight = isSettingsPage
2280
+ ? M.pad + M.head + 2 * M.section + 4 * M.row + 2 * M.listPad
2281
+ : (view === 2
2282
+ ? M.pad + Math.max(44, M.head + M.search
2283
+ + Math.min(page2Rows * M.model + M.listPad, M.listMax)
2284
+ + (providerModels.length ? 0 : M.empty))
2285
+ : M.pad + Math.max(44, M.section + page1Rows * M.row
2286
+ + (store.providers.length ? 0 : M.empty)));
2287
+ }
2288
+ const roomAbove = menuPos ? Math.max(120, window.innerHeight - menuPos.bottom - CODEX_MARGIN) : desiredHeight;
2289
+ const popoverHeight = Math.min(desiredHeight, roomAbove);
2290
+
2291
+ const checkIcon = (on) => h('span', { className: 'cmes-ck' },
2292
+ on ? h('svg', {
2293
+ viewBox: '0 0 24 24', 'aria-hidden': true,
2294
+ fill: 'none', stroke: 'currentColor', strokeWidth: 1.7, strokeLinecap: 'round', strokeLinejoin: 'round'
2295
+ }, h('path', { d: 'm20 6-11 11-5-5' })) : null);
2296
+ const chevron = (cls) => h('svg', {
2297
+ className: cls, viewBox: '0 0 24 24', 'aria-hidden': true,
2298
+ fill: 'none', stroke: 'currentColor', strokeWidth: 1.7, strokeLinecap: 'round', strokeLinejoin: 'round'
2299
+ }, h('path', { d: 'm9 18 6-6-6-6' }));
2300
+ const backChevron = h('svg', {
2301
+ className: 'cmes-iconSmall', viewBox: '0 0 24 24', 'aria-hidden': true,
2302
+ fill: 'none', stroke: 'currentColor', strokeWidth: 1.7, strokeLinecap: 'round', strokeLinejoin: 'round'
2303
+ }, h('path', { d: 'm15 18-6-6 6-6' }));
2304
+ const downChevron = h('svg', {
2305
+ className: 'cmes-chev', viewBox: '0 0 24 24', 'aria-hidden': true,
2306
+ fill: 'none', stroke: 'currentColor', strokeWidth: 1.7, strokeLinecap: 'round', strokeLinejoin: 'round'
2307
+ }, h('path', { d: 'm6 9 6 6 6-6' }));
2308
+ const boltIcon = (cls, on) => h('svg', {
2309
+ className: cls, viewBox: '0 0 24 24', 'aria-hidden': true,
2310
+ fill: on ? 'currentColor' : 'none', stroke: 'currentColor',
2311
+ strokeWidth: on ? 0.7 : 1.5, strokeLinejoin: 'round',
2312
+ style: { width: 15, height: 17 }
2313
+ }, h('path', {
2314
+ d: 'M14.4 2Q16 .2 15.8 2.5L15.1 8.5H20.5Q22 8.5 21 9.8L10.7 21.7Q9 23.4 9.2 21.2L10 14.2H4.2Q2.6 14.2 3.6 12.9L14.4 2Z'
2315
+ }));
2316
+ // 其他设置工具用齿轮,避免和尺寸/全屏混淆。
2317
+ const sizeIcon = h('svg', {
2318
+ className: 'cmes-iconSmall', viewBox: '0 0 24 24', 'aria-hidden': true,
2319
+ fill: 'none', stroke: 'currentColor', strokeWidth: 1.6, strokeLinecap: 'round', strokeLinejoin: 'round'
2320
+ },
2321
+ h('circle', { cx: 12, cy: 12, r: 3 }),
2322
+ h('path', {
2323
+ d: 'M19.4 15a1.7 1.7 0 0 0 .34 1.88l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06A1.7 1.7 0 0 0 15 19.4a1.7 1.7 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.7 1.7 0 0 0 9 19.4a1.7 1.7 0 0 0-1.88.34l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.7 1.7 0 0 0 4.6 15a1.7 1.7 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.7 1.7 0 0 0 4.6 9a1.7 1.7 0 0 0-.34-1.88l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.7 1.7 0 0 0 9 4.6a1.7 1.7 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.7 1.7 0 0 0 1 1.51 1.7 1.7 0 0 0 1.88-.34l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.7 1.7 0 0 0 19.4 9a1.7 1.7 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.7 1.7 0 0 0-1.51 1z'
2324
+ }));
2325
+ const imageIcon = h('svg', {
2326
+ viewBox: '0 0 24 24', 'aria-hidden': true,
2327
+ fill: 'none', stroke: 'currentColor', strokeWidth: 1.6, strokeLinecap: 'round', strokeLinejoin: 'round',
2328
+ style: { width: 15, height: 15 }
2329
+ },
2330
+ h('rect', { x: 3, y: 4, width: 18, height: 16, rx: 2 }),
2331
+ h('circle', { cx: 8.2, cy: 9.2, r: 1.4 }),
2332
+ h('path', { d: 'M4 17l5-4.6 3.2 3 3.8-4.2L20 17' }));
2333
+
2334
+ const railColors = {
2335
+ '--cmes-fill': codexFillFor(displayed, dark),
2336
+ '--cmes-track': codexTrackFor(codexFillFor(displayed, dark), dark),
2337
+ '--cmes-ink': codexInkFor(displayed, dark),
2338
+ '--cmes-dot': 'var(--dsw-alias-label-caption,#b6b6b8)',
2339
+ '--cmes-mote': codexMixHex(codexFillFor(displayed, dark), '#ffffff', dark ? 0.30 : 0.42),
2340
+ '--cmes-pos': String(fraction)
2341
+ };
2342
+ const triggerStyle = { '--cmes-ink': codexInkFor(value, dark) };
2343
+
2344
+ const autoRow = h('button', {
2345
+ key: '__auto', type: 'button', className: 'cmes-row',
2346
+ 'aria-pressed': selectedAuto,
2347
+ onClick: chooseAuto,
2348
+ title: t('seat.modelAutoHint')
2349
+ },
2350
+ h('span', { className: 'cmes-rowName' }, t('seat.auto')),
2351
+ selectedAuto ? h('span', { className: 'cmes-rowDot', 'aria-hidden': true }) : null,
2352
+ null
2353
+ );
2354
+ const providerRows = store.providers.map((provider) => h('button', {
2355
+ key: provider.id, type: 'button', className: 'cmes-row',
2356
+ 'aria-expanded': view === 2 && subProvider === provider.id,
2357
+ onClick: () => openProvider(provider.id)
2358
+ },
2359
+ h('span', { className: 'cmes-rowName' }, provider.name || t('section.unnamedProvider')),
2360
+ !selectedAuto && store.active.providerId === provider.id
2361
+ ? h('span', { className: 'cmes-rowDot', 'aria-hidden': true })
2362
+ : null,
2363
+ chevron('cmes-rowChev')
2364
+ ));
2365
+ const page1RowsNode = h('div', { className: 'cmes-rows' },
2366
+ showAutoRow ? autoRow : null,
2367
+ providerRows,
2368
+ store.providers.length ? null : h('div', { className: 'cmes-empty' }, t('seat.empty'))
2369
+ );
2370
+ const modelRows = providerModels.map((model) => {
2371
+ const modelSpec = qualitySpecFor(activeProviderForPage.id, model);
2372
+ const count = qualityRailLevels(modelSpec).length;
2373
+ const selected = store.active.providerId === activeProviderForPage.id && store.active.model === model;
2374
+ return h('button', {
2375
+ key: model, type: 'button', role: 'menuitemradio', 'aria-checked': selected,
2376
+ className: 'cmes-model' + (selected ? ' sel' : '') + (count ? '' : ' na'),
2377
+ onClick: () => chooseModel(activeProviderForPage.id, model),
2378
+ title: modelDisplayName(activeProviderForPage, model)
2379
+ },
2380
+ h('span', { className: 'cmes-modelName' },
2381
+ h('span', null, modelDisplayName(activeProviderForPage, model)),
2382
+ h('span', { className: 'cmes-cnt' }, count ? t('seat.levelsCount', { count: count }) : t('seat.levelsNone'))
2383
+ ),
2384
+ checkIcon(selected)
2385
+ );
2386
+ });
2387
+ const settingsForm = h('div', { key: 'size-form', className: 'cmes-rows' },
2388
+ h('div', { className: 'cmes-sec' }, t('seat.sizeTitle')),
2389
+ h('div', { className: 'cmes-row', style: { cursor: 'default' } },
2390
+ h('span', { className: 'cmes-rowName' }, t('seat.sizeAutoValue')),
2391
+ h('input', {
2392
+ type: 'checkbox', checked: !!defaults.auto, 'aria-label': t('seat.sizeAutoAria'),
2393
+ style: { accentColor: 'var(--dsw-alias-state-business-primary, #3989f6)', width: 16, height: 16 },
2394
+ onChange: (event) => saveDefaults({ auto: event.target.checked })
2395
+ })
2396
+ ),
2397
+ h('div', { className: 'cmes-row', style: { cursor: 'default' } },
2398
+ h('span', { className: 'cmes-rowName' }, t('seat.width')),
2399
+ h('input', {
2400
+ type: 'text', inputMode: 'numeric', disabled: defaults.auto, 'aria-label': t('seat.width'),
2401
+ value: widthDraft || String(defaults.width),
2402
+ style: { width: 92, height: 26, borderRadius: 8, border: '1px solid var(--dsw-alias-border-l2)', background: 'var(--dsw-alias-bg-layer-1)', color: 'var(--dsw-alias-label-primary)', fontFamily: 'inherit', fontSize: 12, textAlign: 'right', padding: '0 8px', outline: 'none' },
2403
+ onBlur: () => setWidthDraft(''),
2404
+ onChange: (event) => {
2405
+ const text = String(event.target.value).replace(/[^0-9]/g, '');
2406
+ setWidthDraft(text);
2407
+ commitSide('width', text);
2408
+ }
2409
+ })
2410
+ ),
2411
+ h('div', { className: 'cmes-row', style: { cursor: 'default' } },
2412
+ h('span', { className: 'cmes-rowName' }, t('seat.height')),
2413
+ h('input', {
2414
+ type: 'text', inputMode: 'numeric', disabled: defaults.auto, 'aria-label': t('seat.height'),
2415
+ value: heightDraft || String(defaults.height),
2416
+ style: { width: 92, height: 26, borderRadius: 8, border: '1px solid var(--dsw-alias-border-l2)', background: 'var(--dsw-alias-bg-layer-1)', color: 'var(--dsw-alias-label-primary)', fontFamily: 'inherit', fontSize: 12, textAlign: 'right', padding: '0 8px', outline: 'none' },
2417
+ onBlur: () => setHeightDraft(''),
2418
+ onChange: (event) => {
2419
+ const text = String(event.target.value).replace(/[^0-9]/g, '');
2420
+ setHeightDraft(text);
2421
+ commitSide('height', text);
2422
+ }
2423
+ })
2424
+ ),
2425
+ h('div', { className: 'cmes-sec' }, t('seat.promptSection')),
2426
+ h('div', { className: 'cmes-row', style: { cursor: 'default' } },
2427
+ h('span', { className: 'cmes-rowName' }, t('seat.menuPromptOptimization')),
2428
+ h('input', {
2429
+ type: 'checkbox', checked: defaults.promptOptimization !== false,
2430
+ 'aria-label': t('seat.menuPromptOptimization'),
2431
+ style: { accentColor: 'var(--dsw-alias-state-business-primary, #3989f6)', width: 16, height: 16 },
2432
+ onChange: (event) => saveDefaults({ promptOptimization: event.target.checked })
2433
+ })
2434
+ )
2435
+ );
2436
+ const page2Body = isSettingsPage
2437
+ ? settingsForm
2438
+ : [
2439
+ h('label', { key: 'search', className: 'cmes-search' },
2440
+ h('svg', { viewBox: '0 0 24 24', 'aria-hidden': true, fill: 'none', stroke: 'currentColor', strokeWidth: 1.7, strokeLinecap: 'round', strokeLinejoin: 'round', style: { width: 13, height: 13, flex: 'none' } },
2441
+ h('path', { d: 'M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14ZM20 20l-4-4' })),
2442
+ h('input', {
2443
+ ref: searchRef, type: 'text', value: query,
2444
+ placeholder: t('seat.searchPlaceholder'), 'aria-label': t('seat.searchAria'),
2445
+ spellCheck: false,
2446
+ onChange: (event) => { setQuery(event.target.value); setHighlight(0); },
2447
+ onKeyDown: (event) => {
2448
+ if (!providerModels.length) return;
2449
+ if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
2450
+ event.preventDefault();
2451
+ const delta = event.key === 'ArrowDown' ? 1 : -1;
2452
+ setHighlight((current) => (current + delta + providerModels.length) % providerModels.length);
2453
+ } else if (event.key === 'Enter') {
2454
+ event.preventDefault();
2455
+ const model = providerModels[Math.max(0, Math.min(highlight, providerModels.length - 1))];
2456
+ if (model) chooseModel(activeProviderForPage.id, model);
2457
+ }
2458
+ }
2459
+ })
2460
+ ),
2461
+ h('div', {
2462
+ key: 'list', className: 'cmes-list',
2463
+ onKeyDown: (event) => {
2464
+ if (!providerModels.length) return;
2465
+ if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
2466
+ event.preventDefault();
2467
+ const delta = event.key === 'ArrowDown' ? 1 : -1;
2468
+ setHighlight((current) => (current + delta + providerModels.length) % providerModels.length);
2469
+ } else if (event.key === 'Enter') {
2470
+ event.preventDefault();
2471
+ const model = providerModels[Math.max(0, Math.min(highlight, providerModels.length - 1))];
2472
+ if (model) chooseModel(activeProviderForPage.id, model);
2473
+ }
2474
+ }
2475
+ },
2476
+ modelRows,
2477
+ modelRows.length ? null : h('div', { className: 'cmes-empty' }, t('seat.noMatches'))
2478
+ )
2479
+ ];
2480
+ const modelsPane = h('div', {
2481
+ className: 'cmes-pane cmes-models' + (pane === 'models' ? '' : ' hidden'),
2482
+ role: 'menu', 'aria-label': t('seat.menuModel'),
2483
+ inert: pane !== 'models' ? '' : undefined
2484
+ },
2485
+ h('div', { className: 'cmes-viewport' + (view === 2 ? ' view2' : '') },
2486
+ h('div', {
2487
+ className: 'cmes-page slot1',
2488
+ style: { transition: 'transform .3s ease' },
2489
+ inert: view === 2 ? '' : undefined
2490
+ },
2491
+ h('div', { className: 'cmes-sec' }, t('seat.menuModel')),
2492
+ page1RowsNode
2493
+ ),
2494
+ h('div', {
2495
+ className: 'cmes-page slot2',
2496
+ style: { transition: 'transform .3s ease' },
2497
+ inert: view === 2 ? undefined : ''
2498
+ },
2499
+ h('div', { className: 'cmes-head' },
2500
+ h('button', {
2501
+ type: 'button', className: 'cmes-back', 'aria-label': t('seat.back'), title: t('seat.back'),
2502
+ onClick: goBack
2503
+ }, backChevron),
2504
+ h('span', { className: 'cmes-title' },
2505
+ isSettingsPage ? t('seat.moreSettings') : (activeProviderForPage ? activeProviderForPage.name : t('seat.menuModel')))
2506
+ ),
2507
+ page2Body
2508
+ )
2509
+ )
2510
+ );
2511
+
2512
+ const qualityPane = h('div', {
2513
+ className: 'cmes-pane cmes-main' + (pane === 'quality' ? '' : ' hidden'),
2514
+ inert: pane !== 'quality' ? '' : undefined
2515
+ },
2516
+ h('button', {
2517
+ className: 'cmes-tool cmes-fast' + (fast ? ' active' : ''),
2518
+ 'aria-label': t('seat.fast'),
2519
+ 'aria-pressed': fast,
2520
+ onClick: () => setFast(!fast)
2521
+ }, boltIcon('', fast)),
2522
+ h('button', {
2523
+ className: 'cmes-modelLink', type: 'button',
2524
+ onClick: () => setPane('models'),
2525
+ 'aria-label': t('seat.choose'), title: activeModelName
2526
+ },
2527
+ h('span', { className: 'cmes-heading' }, displayLabel || t('seat.menuQuality'), chevron('cmes-iconSmall')),
2528
+ h('span', { className: 'cmes-modelName' }, activeModelName || t('seat.fallback'))
2529
+ ),
2530
+ h('div', { className: 'cmes-warning' }, h('span', null, t('seat.qualityWarning'))),
2531
+ h('button', {
2532
+ className: 'cmes-tool cmes-reset', type: 'button',
2533
+ 'aria-label': t('seat.moreSettings'), title: t('seat.moreSettings'),
2534
+ onClick: openSettings
2535
+ }, sizeIcon),
2536
+ levels.length ? h('div', {
2537
+ className: 'cmes-rail' + (dragging ? ' dragging' : ''),
2538
+ ref: railRef,
2539
+ style: railColors,
2540
+ role: 'slider', tabIndex: 0,
2541
+ 'aria-label': t('seat.menuQuality'),
2542
+ 'aria-valuemin': 0, 'aria-valuemax': levels.length - 1,
2543
+ 'aria-valuenow': displayIndex, 'aria-valuetext': displayLabel,
2544
+ onPointerDown: pointerDown,
2545
+ onPointerMove: (event) => {
2546
+ if (dragRef.current || levels.length < 2) return;
2547
+ const rail = railRef.current;
2548
+ if (!rail || typeof rail.getBoundingClientRect !== 'function') return;
2549
+ const box = rail.getBoundingClientRect();
2550
+ if (!box || box.width <= 30) return;
2551
+ const ratio = fractionAt(event.clientX);
2552
+ const nearest = Math.round(ratio * (levels.length - 1));
2553
+ const tick = nearest / (levels.length - 1);
2554
+ setHoveredDot(Math.abs(ratio - tick) * (box.width - 30) < 10 ? nearest : -1);
2555
+ },
2556
+ onPointerLeave: () => setHoveredDot(-1),
2557
+ onKeyDown: railKeyDown
2558
+ },
2559
+ h('div', { className: 'cmes-fill' }),
2560
+ levels.map((level, index) => h('i', {
2561
+ key: level.value,
2562
+ className: 'cmes-dot' + (index <= displayIndex ? ' passed' : '') + (hoveredDot === index ? ' hovered' : ''),
2563
+ style: { '--cmes-tick': levels.length > 1 ? index / (levels.length - 1) : 0 }
2564
+ })),
2565
+ h('div', { className: 'cmes-sparks' },
2566
+ sparkles.map((sparkle) => h('i', {
2567
+ key: sparkle.key, className: 'cmes-sp',
2568
+ style: { top: sparkle.top, '--b': sparkle.b, '--dur': sparkle.dur, '--delay': sparkle.delay }
2569
+ }))),
2570
+ bloom
2571
+ ? h('div', { key: 'bloom-' + bloom, className: 'cmes-bloom', 'aria-hidden': true },
2572
+ h('i', { className: 'cmes-halo' }),
2573
+ bloomMotes.map((mote) => h('i', {
2574
+ key: mote.key, className: 'cmes-bp',
2575
+ style: {
2576
+ '--x0': mote.x0, '--y0': mote.y0, '--x1': mote.x1, '--y1': mote.y1,
2577
+ '--sz': mote.sz, '--bmax': mote.bmax, '--bd': mote.bd, '--bdel': mote.bdel
2578
+ }
2579
+ })))
2580
+ : null,
2581
+ h('div', { className: 'cmes-knob' })
2582
+ ) : h('div', { className: 'cmes-noeffort' }, t('seat.qualityUnsupported'))
2583
+ );
2584
+
2585
+ const popoverClasses = [
2586
+ 'cmes-popover',
2587
+ open ? '' : ' closed',
2588
+ peak ? ' peak' : '',
2589
+ fast ? ' fast-mode' : '',
2590
+ message ? ' message' : ''
2591
+ ].filter(Boolean).join(' ');
2592
+ const popoverStyle = {
2593
+ '--cmes-height': popoverHeight + 'px',
2594
+ '--cmes-left': (menuPos ? menuPos.left : 0) + 'px',
2595
+ '--cmes-bottom': (menuPos ? menuPos.bottom : 40) + 'px',
2596
+ // codex 样式没到位( CSP/加载时序挡住)时也要保证它脱离文档流。
2597
+ // 否则整块弹层会把输入区顶上去、页面底部多出一大片空白。
2598
+ position: 'fixed',
2599
+ zIndex: 1100,
2600
+ left: (menuPos ? menuPos.left : 0) + 'px',
2601
+ bottom: (menuPos ? menuPos.bottom : 40) + 'px',
2602
+ width: CODEX_POPOVER_WIDTH + 'px',
2603
+ maxWidth: 'calc(100vw - 24px)',
2604
+ height: popoverHeight + 'px',
2605
+ overflow: 'hidden',
2606
+ background: 'var(--dsw-specific-menu, var(--dsw-alias-bg-layer-2, #fff))',
2607
+ borderRadius: 14,
2608
+ boxShadow: 'var(--dsw-elevation-panel, 0 18px 48px rgba(0,0,0,.18))',
2609
+ pointerEvents: open ? 'auto' : 'none',
2610
+ // 生图席在输入区最右侧,弹层贴右缘展开;Codex 默认 transform-origin
2611
+ // bottom left,这里改 bottom right,缩放才从贴边的一侧起。
2612
+ transformOrigin: 'bottom right',
2613
+ visibility: menuPos || !open ? undefined : 'hidden'
2614
+ };
2615
+ const portalNode = (node) => {
2616
+ if (!node) return null;
2617
+ if (typeof document === 'undefined' || !document.body) return node;
2618
+ // 固定定位的零尺寸容器:保 codex 的深色变量,又不占任何文档流。
2619
+ return createPortal(h('div', {
2620
+ className: 'cmes-root',
2621
+ style: {
2622
+ position: 'fixed', left: 0, top: 0, width: 0, height: 0,
2623
+ overflow: 'visible', pointerEvents: 'none',
2624
+ // position:fixed 会建立自己的 stacking context;z-index 必须放在
2625
+ // 这一层,否则弹层内部再高 z-index 也压不过输入区。
2626
+ zIndex: 2147482000
2627
+ }
2628
+ }, node), document.body);
2629
+ };
2630
+
2631
+ return h('div', { className: 'cmes-root', 'data-mo-image-seat': '' },
2632
+ h('button', {
2633
+ type: 'button', ref: triggerRef,
2634
+ className: 'cmes-trigger' + (fast ? ' fast' : ''),
2635
+ style: triggerStyle,
2636
+ 'aria-label': qualityLabel ? t('seat.triggerAriaQuality', { model: triggerLabel, quality: qualityLabel }) : t('seat.triggerAria', { model: triggerLabel }),
2637
+ 'aria-haspopup': 'dialog', 'aria-expanded': open,
2638
+ 'aria-controls': open ? 'mo-image-codex-popover' : undefined,
2639
+ onClick: () => {
2640
+ if (open) { closeMenu(); return; }
2641
+ // 先清掉旧位置,让 useLayoutEffect 在绘制前重新定位;关闭时。
2642
+ // 保留位置,避免退场动画跑到左下角。
2643
+ setMenuPos(null);
2644
+ setPane('quality');
2645
+ setOpen(true);
2646
+ }
2647
+ },
2648
+ fast ? boltIcon('cmes-bolt', true) : null,
2649
+ h('span', { className: 'cmes-compact' }, imageIcon),
2650
+ h('span', { className: 'cmes-caption' }, triggerLabel),
2651
+ qualityLabel ? h('span', { className: 'cmes-triggerEffort' }, qualityLabel) : null,
2652
+ downChevron
2653
+ ),
2654
+ // 弹层必须挂到 body:输入区里任何 transform/filter/backdrop-filter 都会
2655
+ // 把 position:fixed 变成相对包含块,位置和裁剪都会错。
2656
+ portalNode(h('section', {
2657
+ ref: popoverRef, id: 'mo-image-codex-popover', className: popoverClasses, role: 'dialog',
2658
+ 'data-mo-image-codex-popover': '',
2659
+ 'aria-label': pane === 'models' ? t('seat.menuModel') : t('seat.menuQuality'),
2660
+ 'aria-hidden': !open,
2661
+ inert: !open ? '' : undefined,
2662
+ style: popoverStyle
2663
+ },
2664
+ modelsPane,
2665
+ qualityPane
2666
+ ))
2667
+ );
2668
+ }
2669
+
1310
2670
  function ImageModelSeat(props) {
1311
2671
  // 子代理没有自己的对话模型选择器;生图选择器也沿用主对话配置。
1312
- // 这里按 session.origin 判断,子代理里不渲染右下角的生图模型 seat。
1313
- if (!props || typeof props.useSessions !== 'function') return h(ImageModelSeatInner, props);
2672
+ // 这里 session.origin 判断,子代理里不渲染右下角的生图模型 seat。
2673
+ if (!props || typeof props.useSessions !== 'function') return h(ImageModelSeatInner, props);
1314
2674
  return h(ImageModelSeatScoped, props);
1315
2675
  }
1316
2676
 
@@ -1326,8 +2686,21 @@ window.__ModuleLoader__.load({
1326
2686
  useThemeClassRevision();
1327
2687
  const t = (props && props.t) || fallbackTranslate;
1328
2688
  const imageStore = useImageStore({ t: t });
1329
- const store = imageStore.store;
1330
- const setStore = imageStore.setStore;
2689
+ if (seatSkinNow() === SEAT_SKIN.CODEX) {
2690
+ return h(CodexImageSeat, {
2691
+ t: t, store: imageStore.store, setStore: imageStore.setStore,
2692
+ sessionId: props && props.sessionId
2693
+ });
2694
+ }
2695
+ return h(OfficialImageSeat, {
2696
+ t: t, store: imageStore.store, setStore: imageStore.setStore
2697
+ });
2698
+ }
2699
+
2700
+ function OfficialImageSeat(props) {
2701
+ const t = props.t || fallbackTranslate;
2702
+ const store = props.store;
2703
+ const setStore = props.setStore;
1331
2704
  const [open, setOpen] = React.useState(false);
1332
2705
  const [panel, setPanel] = React.useState('home');
1333
2706
  const [query, setQuery] = React.useState('');
@@ -1450,23 +2823,14 @@ window.__ModuleLoader__.load({
1450
2823
  const selected = flat.findIndex((item) => item.providerId === store.active.providerId && item.model === store.active.model);
1451
2824
  setActiveIndex(selected >= 0 ? selected : (flat.length ? 0 : -1));
1452
2825
  }, [open, panel, query, store]);
1453
- const defaults = store.defaults || normalizeDefaults(null);
1454
- const active = activeImageConfig(store);
1455
- const qualitySpec = qualitySpecFor(active.providerId, active.model);
1456
- const qualityValue = qualityValueFor(defaults.quality, qualitySpec);
1457
- const qualityLabel = qualityLabelFor(defaults.quality, qualitySpec, t);
1458
- const saveDefaults = (patch) => {
1459
- const next = writeImageStore({ ...store, defaults: { ...defaults, ...patch } }, t);
1460
- setStore(next);
1461
- };
2826
+ const seatView = deriveSeatView(store, t);
2827
+ const {
2828
+ defaults, active, activeProvider, hasAnyModel,
2829
+ activeModelName, triggerLabel, qualitySpec, qualityValue, qualityLabel
2830
+ } = seatView;
2831
+ const saveDefaults = (patch) => commitSeatDefaults(store, defaults, setStore, patch, t);
1462
2832
  const choose = (providerId, model) => {
1463
- const targetSpec = qualitySpecFor(providerId, model);
1464
- const next = writeImageStore({
1465
- ...store,
1466
- active: { providerId: providerId, model: model },
1467
- defaults: { ...defaults, quality: targetSpec ? qualityValueFor(defaults.quality, targetSpec) : defaults.quality }
1468
- }, t);
1469
- setStore(next);
2833
+ commitSeatModel(store, defaults, setStore, providerId, model, t);
1470
2834
  closeMenu();
1471
2835
  };
1472
2836
  const visible = React.useMemo(() => {
@@ -1479,12 +2843,8 @@ window.__ModuleLoader__.load({
1479
2843
  })).filter((provider) => provider.models.length > 0);
1480
2844
  }, [store, query]);
1481
2845
  const needle = query.trim().toLowerCase();
1482
- const hasAnyModel = store.providers.some((provider) => Array.isArray(provider.models) && provider.models.length > 0);
1483
2846
  const emptyModelHint = hasAnyModel && needle ? t('seat.noMatches') : t('seat.empty');
1484
2847
  const autoVisible = hasAnyModel && (!needle || 'auto'.includes(needle));
1485
- const activeProvider = store.providers.find((provider) => provider.id === store.active.providerId) || store.providers[0];
1486
- const activeModelName = hasAnyModel && active.model === 'auto' ? t('seat.auto') : (hasAnyModel && active.model ? modelDisplayName(activeProvider, active.model) : '');
1487
- const triggerLabel = activeModelName || t('seat.fallback');
1488
2848
  let optionIndex = autoVisible ? 0 : -1;
1489
2849
  const Menu = DshMenuSurface || 'div';
1490
2850
  const Group = DshMenuGroup || 'div';
@@ -1503,7 +2863,7 @@ window.__ModuleLoader__.load({
1503
2863
  chevronRight
1504
2864
  );
1505
2865
  const homePanel = [
1506
- cellRow('model', t('seat.menuModel'), hasAnyModel ? (active.model === 'auto' ? t('seat.auto') : (active.model || t('seat.notSelected'))) : t('seat.notSelected'), () => setPanel('model'))
2866
+ cellRow('model', t('seat.menuModel'), activeModelName || t('seat.notSelected'), () => setPanel('model'))
1507
2867
  ];
1508
2868
  if (qualitySpec) homePanel.push(cellRow('quality', t('seat.menuQuality'), qualityLabel, () => setPanel('quality')));
1509
2869
  homePanel.push(
@@ -1511,8 +2871,8 @@ window.__ModuleLoader__.load({
1511
2871
  cellRow('promptOptimization', t('seat.menuPromptOptimization'), defaults.promptOptimization === false ? t('seat.off') : t('seat.on'), () => setPanel('promptOptimization'))
1512
2872
  );
1513
2873
  // 尺寸面板里的行是静态表单,不要 cell 的悬停高光;
1514
- // option + modelOption 这一组合在样式表里被排除在 hover 规则之外。
1515
- const plainRow = MS.option + ' ' + MS.modelOption;
2874
+ // option + modelOption 这一组合在样式表里被排除 hover 规则之外。
2875
+ const plainRow = MS.option + ' ' + MS.modelOption;
1516
2876
  const sideInput = (key, label, value, display, min, max, onCommit, draft, setDraft, placeholder) => h('div', { key: key, className: plainRow },
1517
2877
  h('span', { className: MS.cellLabel }, label),
1518
2878
  h('input', {
@@ -1548,7 +2908,7 @@ window.__ModuleLoader__.load({
1548
2908
  )
1549
2909
  ];
1550
2910
  // Auto 行固定在第一行(搜索框下面):只有它被选中时,对话模型才能挑模型。
1551
- const autoSelected = hasAnyModel && store.active.model === 'auto';
2911
+ const autoSelected = hasAnyModel && store.active.model === 'auto';
1552
2912
  const autoRow = autoVisible ? h('button', {
1553
2913
  key: '__auto', type: 'button', role: 'menuitemradio', 'aria-checked': autoSelected,
1554
2914
  className: MS.option + ' ' + MS.modelOption + (autoSelected ? ' ' + MS.selected : '') + (activeIndex === 0 ? ' ' + MS.optionActive : ''),
@@ -1610,7 +2970,7 @@ window.__ModuleLoader__.load({
1610
2970
  ];
1611
2971
  const qualityPanel = [
1612
2972
  h('div', { key: 'quality', className: MS.groups + ' scrollable', role: 'menu', 'aria-label': t('seat.menuQuality') },
1613
- (qualitySpec ? qualitySpec.options : []).map((level) => h('button', {
2973
+ qualityRailLevels(qualitySpec).map((level) => h('button', {
1614
2974
  key: level.value, type: 'button', role: 'menuitemradio',
1615
2975
  'aria-checked': qualityValue === level.value,
1616
2976
  className: MS.option + (qualityValue === level.value ? ' ' + MS.selected : ''),
@@ -1646,9 +3006,11 @@ window.__ModuleLoader__.load({
1646
3006
  : panel === 'size' ? sizePanel
1647
3007
  : panel === 'promptOptimization' ? promptOptimizationPanel
1648
3008
  : homePanel;
1649
- return h('div', { className: MS.root },
3009
+ const genericTriggerStyle = seatSkinNow() === SEAT_SKIN.GENERIC ? genericChatTriggerStyle() : null;
3010
+ return h('div', { className: MS.root, 'data-mo-image-seat': '' },
1650
3011
  h('button', {
1651
3012
  type: 'button', ref: triggerRef, className: MS.trigger,
3013
+ style: genericTriggerStyle || undefined,
1652
3014
  onClick: () => {
1653
3015
  if (open) { closeMenu(); return; }
1654
3016
  setPanel('home');
@@ -1736,8 +3098,18 @@ window.__ModuleLoader__.load({
1736
3098
  "form.fetching": "获取中…",
1737
3099
  "form.fetchModels": "获取可用模型",
1738
3100
  "form.modelId": "模型 ID",
1739
- "form.modelSettings": "模型设置",
3101
+ "form.reorderModel": "调整模型顺序",
3102
+ "form.reorderModelHelp": "拖动排序,或使用上下方向键调整顺序。",
1740
3103
  "form.deleteModel": "删除模型",
3104
+ "form.modelOptions": "模型选项",
3105
+ "form.modelOptionsHint": "给这个模型单独指定 ComfyUI 工作流。留空则按模型类型自动选择内置工作流。",
3106
+ "form.modelOptionsUnsupported": "自定义工作流仅在 ComfyUI 部署器下可用",
3107
+ "form.modelWorkflow": "自定义工作流(ComfyUI API 格式)",
3108
+ "form.modelWorkflowPlaceholder": "在 ComfyUI 里用「导出(API)」保存,把 JSON 粘到这里",
3109
+ "form.modelWorkflowHelp": "可用占位符:{{prompt}}、{{negative_prompt}}、{{width}}、{{height}}、{{seed}}、{{model}}、{{image}}(图生图时自动换成上传的参考图)",
3110
+ "form.modelOptionsDone": "收起",
3111
+ "form.modelWorkflowClear": "清除工作流",
3112
+ "form.modelWorkflowSample": "插入示例模板",
1741
3113
  "form.modelEmpty": "模型选择器中将不显示任何模型;请先在模型目录里添加模型 ID。",
1742
3114
  "form.addModel": "添加模型",
1743
3115
  "form.advanced": "自定义设置",
@@ -1754,18 +3126,17 @@ window.__ModuleLoader__.load({
1754
3126
  "form.localPresetsMissing": "宿主没有下发本地部署器列表,请刷新页面后重试。",
1755
3127
  "form.save": "保存",
1756
3128
  "form.cancel": "取消",
1757
- "picker.title": "获取可用模型",
3129
+ "picker.title": "选择模型",
1758
3130
  "picker.close": "关闭",
1759
- "picker.description": "选择要加入模型目录的模型;只有点“添加所选”才会写入当前草稿。",
3131
+ "picker.description": "以下是模型提供商的可用模型,勾选的模型即为模型列表。",
1760
3132
  "picker.search": "搜索模型",
1761
3133
  "picker.selectAll": "全选",
1762
3134
  "picker.deselectAll": "取消全选",
1763
3135
  "picker.showAll": "显示全部模型",
1764
3136
  "picker.filtered": "已过滤 {count} 个可能非生图的模型",
1765
- "picker.listAria": "可用模型",
1766
3137
  "picker.noMatches": "没有匹配的模型",
1767
- "picker.adopt": "添加所选",
1768
- "picker.adoptCount": "添加所选({count})",
3138
+ "picker.adopt": "更新列表",
3139
+ "picker.keepOne": "至少保留一个模型。",
1769
3140
  "seat.noMatches": "没有匹配的模型",
1770
3141
  "seat.empty": "还没有模型,去“设置 → 生图模型”添加",
1771
3142
  "seat.auto": "自动",
@@ -1774,6 +3145,7 @@ window.__ModuleLoader__.load({
1774
3145
  "seat.menuQuality": "质量",
1775
3146
  "seat.menuSize": "尺寸",
1776
3147
  "seat.menuPromptOptimization": "提示词优化",
3148
+ "seat.fast": "快速预览",
1777
3149
  "seat.notSelected": "未选择",
1778
3150
  "seat.on": "开",
1779
3151
  "seat.off": "关",
@@ -1790,6 +3162,15 @@ window.__ModuleLoader__.load({
1790
3162
  "seat.triggerAria": "生图模型:{model}",
1791
3163
  "seat.triggerAriaQuality": "生图模型:{model},质量 {quality}",
1792
3164
  "seat.settingsAria": "生图设置",
3165
+ "seat.moreSettings": "其他设置",
3166
+ "seat.promptSection": "提示词",
3167
+ "seat.qualityUnsupported": "此模型未提供质量档位",
3168
+ "seat.qualityWarning": "更快消耗使用额度",
3169
+ "seat.levelsCount": "{count} 档",
3170
+ "seat.levelsNone": "不支持",
3171
+ "seat.sizeTitle": "尺寸",
3172
+ "seat.back": "返回",
3173
+ "seat.modelAutoHint": "让模型自己挑一个",
1793
3174
  "errors.loadConfig": "读取生图配置失败:HTTP {status}",
1794
3175
  "errors.loadConfigDetail": "读取生图配置失败:{message}",
1795
3176
  "errors.saveConfig": "保存生图配置失败:HTTP {status}",
@@ -1842,11 +3223,11 @@ window.__ModuleLoader__.load({
1842
3223
  "localPreset.sd-server.urlHint": "只填服务根地址,末尾保留 /v1;插件会拼 /images/generations 和 /models。",
1843
3224
  "localPreset.sd-server.hint": "原生 OpenAI Images 接口,生成和 /images/edits 编辑都支持;模型名通常是 sd-cpp-local,可从 /v1/models 获取。",
1844
3225
  "localPreset.localai.urlHint": "只填服务根地址,末尾保留 /v1;插件会拼 /images/generations 和 /models。",
1845
- "localPreset.localai.hint": "OpenAI Images 兼容;模型名填 LocalAI 模型 YAML 里的 name,可从 /v1/models 获取。",
3226
+ "localPreset.localai.hint": "OpenAI Images 兼容,生成可用;模型名填 LocalAI 模型 YAML 里的 name,可从 /v1/models 获取。LocalAI 没有 /images/edits,图生图需要走「其他 OpenAI 兼容网关」。",
1846
3227
  "localPreset.a1111.urlHint": "只填服务根地址,不要带 /sdapi/v1;插件会拼 /sdapi/v1/txt2img、/img2img、/sd-models。",
1847
3228
  "localPreset.a1111.hint": "走 /sdapi/v1/txt2img 和 /sdapi/v1/img2img,模型列表来自 /sdapi/v1/sd-models;A1111 需要启动时加 --api。",
1848
- "localPreset.comfyui.urlHint": "只填服务根地址,不要带 /prompt;插件会拼 /prompt、/history、/view。",
1849
- "localPreset.comfyui.hint": "使用默认 SD/SDXL checkpoint 工作流;模型列表来自 /object_info。Flux/Qwen 等复杂工作流建议走 OpenAI 兼容网关。",
3229
+ "localPreset.comfyui.urlHint": "只填服务根地址,不要带 /prompt;插件会拼 /prompt、/upload/image、/history、/view。",
3230
+ "localPreset.comfyui.hint": "内置 SD/SDXL、FLUX.2 和 MOSS-Image 工作流,生成和参考图编辑都支持;其它架构(Qwen-Image、Z-Image 等)可在模型行的「模型选项」里粘贴自己的 ComfyUI 工作流,或改用 OpenAI 兼容网关。",
1850
3231
  "localPreset.swarmui.urlHint": "只填服务根地址,不要带 /API;插件会拼 /API/GetNewSession、/API/ListModels、/API/GenerateText2Image。",
1851
3232
  "localPreset.swarmui.hint": "走 /API/GenerateText2Image,模型列表来自 /API/ListModels;生成可用,原生编辑暂不支持。",
1852
3233
  "localPreset.openai-gateway.urlHint": "只填 OpenAI API 根地址(通常带 /v1);插件会拼 /images/generations 和 /models。",
@@ -1861,9 +3242,11 @@ window.__ModuleLoader__.load({
1861
3242
  "update.doneRestart": "更新已完成,重启 DSH 后生效",
1862
3243
  "update.done": "已更新到 {version}",
1863
3244
  "update.failed": "更新未完成,请重试",
3245
+ "update.failedRestored": "更新安装失败,已装回原来的版本",
3246
+ "update.failedBroken": "更新安装失败,原版本也没能装回,请在插件管理里重新安装",
1864
3247
  "update.unsupported": "当前环境不支持自助更新,请运行 {command}",
1865
3248
  "update.localDev": "本地开发安装,请自行 git pull",
1866
- "update.command": "dsh plugin add github:CM-Silence/dsh-mo-image#{tag}",
3249
+ "update.command": "dsh plugin add dsh-mo-image@{tag}",
1867
3250
  "update.viewRelease": "在 npm 查看",
1868
3251
  "update.noNotes": "暂无更新说明",
1869
3252
  },
@@ -1896,8 +3279,18 @@ window.__ModuleLoader__.load({
1896
3279
  "form.fetching": "Fetching…",
1897
3280
  "form.fetchModels": "Fetch available models",
1898
3281
  "form.modelId": "Model ID",
1899
- "form.modelSettings": "Model settings",
3282
+ "form.reorderModel": "Reorder model",
3283
+ "form.reorderModelHelp": "Drag to reorder, or use the up and down arrow keys.",
1900
3284
  "form.deleteModel": "Remove model",
3285
+ "form.modelOptions": "Model options",
3286
+ "form.modelOptionsHint": "Override the ComfyUI workflow for this model. Leave blank to use the builtin workflow picked from the model type.",
3287
+ "form.modelOptionsUnsupported": "Custom workflows are only available with the ComfyUI deployment",
3288
+ "form.modelWorkflow": "Custom workflow (ComfyUI API format)",
3289
+ "form.modelWorkflowPlaceholder": "In ComfyUI use Export (API), then paste the JSON here",
3290
+ "form.modelWorkflowHelp": "Placeholders: {{prompt}}, {{negative_prompt}}, {{width}}, {{height}}, {{seed}}, {{model}}, {{image}} (replaced by the uploaded reference on image edit)",
3291
+ "form.modelOptionsDone": "Done",
3292
+ "form.modelWorkflowClear": "Clear workflow",
3293
+ "form.modelWorkflowSample": "Insert sample template",
1901
3294
  "form.modelEmpty": "The model picker will be empty. Add at least one model ID to the catalog first.",
1902
3295
  "form.addModel": "Add model",
1903
3296
  "form.advanced": "Advanced settings",
@@ -1914,18 +3307,17 @@ window.__ModuleLoader__.load({
1914
3307
  "form.localPresetsMissing": "The host did not provide the local deployment list. Refresh the page and try again.",
1915
3308
  "form.save": "Save",
1916
3309
  "form.cancel": "Cancel",
1917
- "picker.title": "Fetch available models",
3310
+ "picker.title": "Choose models",
1918
3311
  "picker.close": "Close",
1919
- "picker.description": "Select the models to add to the catalog. Nothing is written to the draft until you choose “Add selected”.",
3312
+ "picker.description": "These are the models this provider has available. Checked models make up the list.",
1920
3313
  "picker.search": "Search models",
1921
3314
  "picker.selectAll": "Select all",
1922
- "picker.deselectAll": "Clear selection",
3315
+ "picker.deselectAll": "Deselect all",
1923
3316
  "picker.showAll": "Show all models",
1924
3317
  "picker.filtered": "Filtered as likely non-image: {count}",
1925
- "picker.listAria": "Available models",
1926
3318
  "picker.noMatches": "No matching models",
1927
- "picker.adopt": "Add selected",
1928
- "picker.adoptCount": "Add selected ({count})",
3319
+ "picker.adopt": "Update list",
3320
+ "picker.keepOne": "Keep at least one model checked.",
1929
3321
  "seat.noMatches": "No matching models",
1930
3322
  "seat.empty": "No models yet. Add one in Settings → Image models.",
1931
3323
  "seat.auto": "Auto",
@@ -1934,6 +3326,7 @@ window.__ModuleLoader__.load({
1934
3326
  "seat.menuQuality": "Quality",
1935
3327
  "seat.menuSize": "Size",
1936
3328
  "seat.menuPromptOptimization": "Prompt optimization",
3329
+ "seat.fast": "Fast preview",
1937
3330
  "seat.notSelected": "Not selected",
1938
3331
  "seat.on": "On",
1939
3332
  "seat.off": "Off",
@@ -1950,6 +3343,15 @@ window.__ModuleLoader__.load({
1950
3343
  "seat.triggerAria": "Image model: {model}",
1951
3344
  "seat.triggerAriaQuality": "Image model: {model}, quality {quality}",
1952
3345
  "seat.settingsAria": "Image settings",
3346
+ "seat.moreSettings": "More settings",
3347
+ "seat.promptSection": "Prompt",
3348
+ "seat.qualityUnsupported": "This model has no quality levels",
3349
+ "seat.qualityWarning": "Consumes usage quota faster",
3350
+ "seat.levelsCount": "{count} levels",
3351
+ "seat.levelsNone": "Unsupported",
3352
+ "seat.sizeTitle": "Size",
3353
+ "seat.back": "Back",
3354
+ "seat.modelAutoHint": "Let the model pick one",
1953
3355
  "errors.loadConfig": "Could not load image settings: HTTP {status}",
1954
3356
  "errors.loadConfigDetail": "Could not load image settings: {message}",
1955
3357
  "errors.saveConfig": "Could not save image settings: HTTP {status}",
@@ -2002,11 +3404,11 @@ window.__ModuleLoader__.load({
2002
3404
  "localPreset.sd-server.urlHint": "Enter the service root URL and keep the trailing /v1. The plugin appends /images/generations and /models.",
2003
3405
  "localPreset.sd-server.hint": "Native OpenAI Images API with both generation and /images/edits. The model is usually sd-cpp-local and can be listed from /v1/models.",
2004
3406
  "localPreset.localai.urlHint": "Enter the service root URL and keep the trailing /v1. The plugin appends /images/generations and /models.",
2005
- "localPreset.localai.hint": "OpenAI Images compatible. Use the name from the LocalAI model YAML; it can be listed from /v1/models.",
3407
+ "localPreset.localai.hint": "OpenAI Images compatible for generation; use the name from the LocalAI model YAML, listable from /v1/models. LocalAI has no /images/edits, so use an OpenAI-compatible gateway for image editing.",
2006
3408
  "localPreset.a1111.urlHint": "Enter the service root URL without /sdapi/v1. The plugin appends /sdapi/v1/txt2img, /img2img, and /sd-models.",
2007
3409
  "localPreset.a1111.hint": "Uses /sdapi/v1/txt2img and /sdapi/v1/img2img; the model list comes from /sdapi/v1/sd-models. Start A1111 with --api.",
2008
- "localPreset.comfyui.urlHint": "Enter the service root URL without /prompt. The plugin appends /prompt, /history, and /view.",
2009
- "localPreset.comfyui.hint": "Uses the default SD/SDXL checkpoint workflow; the model list comes from /object_info. For complex workflows such as Flux or Qwen, use an OpenAI-compatible gateway.",
3410
+ "localPreset.comfyui.urlHint": "Enter the service root URL without /prompt. The plugin appends /prompt, /upload/image, /history, and /view.",
3411
+ "localPreset.comfyui.hint": "Builtin workflows cover SD/SDXL, FLUX.2 and MOSS-Image for both generation and reference editing. For other architectures (Qwen-Image, Z-Image, …) paste your own ComfyUI workflow under \"Model options\" on the model row, or use an OpenAI-compatible gateway.",
2010
3412
  "localPreset.swarmui.urlHint": "Enter the service root URL without /API. The plugin appends /API/GetNewSession, /API/ListModels, and /API/GenerateText2Image.",
2011
3413
  "localPreset.swarmui.hint": "Uses /API/GenerateText2Image; the model list comes from /API/ListModels. Generation works; native editing is not supported yet.",
2012
3414
  "localPreset.openai-gateway.urlHint": "Enter the OpenAI API root URL (usually with /v1). The plugin appends /images/generations and /models.",
@@ -2021,9 +3423,11 @@ window.__ModuleLoader__.load({
2021
3423
  "update.doneRestart": "Update installed — restart DSH to apply",
2022
3424
  "update.done": "Updated to {version}",
2023
3425
  "update.failed": "Update did not finish — try again",
3426
+ "update.failedRestored": "The update failed — the previous version was restored",
3427
+ "update.failedBroken": "The update failed and the previous version was not restored — reinstall it from plugin management",
2024
3428
  "update.unsupported": "This environment cannot self-update; run {command}",
2025
3429
  "update.localDev": "Local development install — run git pull yourself",
2026
- "update.command": "dsh plugin add github:CM-Silence/dsh-mo-image#{tag}",
3430
+ "update.command": "dsh plugin add dsh-mo-image@{tag}",
2027
3431
  "update.viewRelease": "View on npm",
2028
3432
  "update.noNotes": "This release has no notes.",
2029
3433
  },
@@ -2056,8 +3460,18 @@ window.__ModuleLoader__.load({
2056
3460
  "form.fetching": "取得中…",
2057
3461
  "form.fetchModels": "利用可能なモデルを取得",
2058
3462
  "form.modelId": "モデル ID",
2059
- "form.modelSettings": "モデル設定",
3463
+ "form.reorderModel": "モデルの順序を変更",
3464
+ "form.reorderModelHelp": "ドラッグ、または上下の矢印キーで順序を変更できます。",
2060
3465
  "form.deleteModel": "モデルを削除",
3466
+ "form.modelOptions": "モデルオプション",
3467
+ "form.modelOptionsHint": "このモデル専用の ComfyUI ワークフローを指定します。空欄ならモデル種別に応じた組み込みワークフローを使います。",
3468
+ "form.modelOptionsUnsupported": "カスタムワークフローは ComfyUI デプロイ時のみ利用できます",
3469
+ "form.modelWorkflow": "カスタムワークフロー(ComfyUI API 形式)",
3470
+ "form.modelWorkflowPlaceholder": "ComfyUI で「エクスポート(API)」して JSON をここに貼り付け",
3471
+ "form.modelWorkflowHelp": "利用できるプレースホルダー:{{prompt}}、{{negative_prompt}}、{{width}}、{{height}}、{{seed}}、{{model}}、{{image}}(画像編集時はアップロードした参照画像に置き換わります)",
3472
+ "form.modelOptionsDone": "閉じる",
3473
+ "form.modelWorkflowClear": "ワークフローを消去",
3474
+ "form.modelWorkflowSample": "サンプルを挿入",
2061
3475
  "form.modelEmpty": "モデル選択には何も表示されません。先にモデルカタログへモデル ID を追加してください。",
2062
3476
  "form.addModel": "モデルを追加",
2063
3477
  "form.advanced": "詳細設定",
@@ -2074,18 +3488,17 @@ window.__ModuleLoader__.load({
2074
3488
  "form.localPresetsMissing": "ホストからローカルデプロイの一覧が届いていません。ページを再読み込みしてください。",
2075
3489
  "form.save": "保存",
2076
3490
  "form.cancel": "キャンセル",
2077
- "picker.title": "利用可能なモデルを取得",
3491
+ "picker.title": "モデルを選択",
2078
3492
  "picker.close": "閉じる",
2079
- "picker.description": "モデルカタログに追加するモデルを選択します。「選択項目を追加」を押すまで下書きには反映されません。",
3493
+ "picker.description": "プロバイダーが利用可能なモデルです。チェックしたモデルがリストになります。",
2080
3494
  "picker.search": "モデルを検索",
2081
3495
  "picker.selectAll": "すべて選択",
2082
3496
  "picker.deselectAll": "選択を解除",
2083
3497
  "picker.showAll": "すべてのモデルを表示",
2084
3498
  "picker.filtered": "画像生成向けではない可能性があるモデルを {count} 件除外しました",
2085
- "picker.listAria": "利用可能なモデル",
2086
3499
  "picker.noMatches": "一致するモデルがありません",
2087
- "picker.adopt": "選択項目を追加",
2088
- "picker.adoptCount": "選択項目を追加({count})",
3500
+ "picker.adopt": "リストを更新",
3501
+ "picker.keepOne": "少なくとも 1 つのモデルをチェックしたままにしてください。",
2089
3502
  "seat.noMatches": "一致するモデルがありません",
2090
3503
  "seat.empty": "モデルがまだありません。「設定 → 画像生成モデル」で追加してください。",
2091
3504
  "seat.auto": "自動",
@@ -2094,6 +3507,7 @@ window.__ModuleLoader__.load({
2094
3507
  "seat.menuQuality": "画質",
2095
3508
  "seat.menuSize": "サイズ",
2096
3509
  "seat.menuPromptOptimization": "プロンプト最適化",
3510
+ "seat.fast": "高速プレビュー",
2097
3511
  "seat.notSelected": "未選択",
2098
3512
  "seat.on": "オン",
2099
3513
  "seat.off": "オフ",
@@ -2110,6 +3524,15 @@ window.__ModuleLoader__.load({
2110
3524
  "seat.triggerAria": "画像生成モデル:{model}",
2111
3525
  "seat.triggerAriaQuality": "画像生成モデル:{model}、画質 {quality}",
2112
3526
  "seat.settingsAria": "画像生成設定",
3527
+ "seat.moreSettings": "その他の設定",
3528
+ "seat.promptSection": "プロンプト",
3529
+ "seat.qualityUnsupported": "このモデルには画質レベルがありません",
3530
+ "seat.qualityWarning": "使用量を早く消費します",
3531
+ "seat.levelsCount": "{count} 段階",
3532
+ "seat.levelsNone": "非対応",
3533
+ "seat.sizeTitle": "サイズ",
3534
+ "seat.back": "戻る",
3535
+ "seat.modelAutoHint": "モデルに任せる",
2113
3536
  "errors.loadConfig": "画像設定を読み込めませんでした:HTTP {status}",
2114
3537
  "errors.loadConfigDetail": "画像設定を読み込めませんでした:{message}",
2115
3538
  "errors.saveConfig": "画像設定を保存できませんでした:HTTP {status}",
@@ -2162,11 +3585,11 @@ window.__ModuleLoader__.load({
2162
3585
  "localPreset.sd-server.urlHint": "サービスのルート URL のみを入力し、末尾の /v1 は残してください。プラグインが /images/generations と /models を追加します。",
2163
3586
  "localPreset.sd-server.hint": "ネイティブな OpenAI Images API で、生成と /images/edits による編集の両方に対応します。モデル名は通常 sd-cpp-local で、/v1/models から取得できます。",
2164
3587
  "localPreset.localai.urlHint": "サービスのルート URL のみを入力し、末尾の /v1 は残してください。プラグインが /images/generations と /models を追加します。",
2165
- "localPreset.localai.hint": "OpenAI Images 互換です。LocalAI のモデル YAML にある name を指定してください。/v1/models から取得できます。",
3588
+ "localPreset.localai.hint": "生成は OpenAI Images 互換です。モデル名は LocalAI のモデル YAML にある name を指定し、/v1/models から取得できます。LocalAI には /images/edits がないため、画像編集は「その他の OpenAI 互換ゲートウェイ」を使用してください。",
2166
3589
  "localPreset.a1111.urlHint": "サービスのルート URL のみを入力し、/sdapi/v1 は含めないでください。プラグインが /sdapi/v1/txt2img、/img2img、/sd-models を追加します。",
2167
3590
  "localPreset.a1111.hint": "/sdapi/v1/txt2img と /sdapi/v1/img2img を使用し、モデル一覧は /sdapi/v1/sd-models から取得します。A1111 は --api 付きで起動してください。",
2168
- "localPreset.comfyui.urlHint": "サービスのルート URL のみを入力し、/prompt は含めないでください。プラグインが /prompt、/history、/view を追加します。",
2169
- "localPreset.comfyui.hint": "既定の SD/SDXL チェックポイントワークフローを使用し、モデル一覧は /object_info から取得します。Flux や Qwen などの複雑なワークフローには OpenAI 互換ゲートウェイをおすすめします。",
3591
+ "localPreset.comfyui.urlHint": "サービスのルート URL のみを入力し、/prompt は含めないでください。プラグインが /prompt、/upload/image、/history、/view を追加します。",
3592
+ "localPreset.comfyui.hint": "SD/SDXL、FLUX.2、MOSS-Image の組み込みワークフローで生成と参照画像編集に対応します。その他の構成(Qwen-Image、Z-Image など)は、モデル行の「モデルオプション」にご自身の ComfyUI ワークフローを貼り付けるか、OpenAI 互換ゲートウェイをご利用ください。",
2170
3593
  "localPreset.swarmui.urlHint": "サービスのルート URL のみを入力し、/API は含めないでください。プラグインが /API/GetNewSession、/API/ListModels、/API/GenerateText2Image を追加します。",
2171
3594
  "localPreset.swarmui.hint": "/API/GenerateText2Image を使用し、モデル一覧は /API/ListModels から取得します。生成は利用できますが、ネイティブ編集には未対応です。",
2172
3595
  "localPreset.openai-gateway.urlHint": "OpenAI API のルート URL(通常は /v1 付き)を入力してください。プラグインが /images/generations と /models を追加します。",
@@ -2181,9 +3604,11 @@ window.__ModuleLoader__.load({
2181
3604
  "update.doneRestart": "更新が完了しました。DSH を再起動すると有効になります",
2182
3605
  "update.done": "{version} に更新しました",
2183
3606
  "update.failed": "更新が完了しませんでした。もう一度お試しください",
3607
+ "update.failedRestored": "更新のインストールに失敗しました。元のバージョンに戻しました",
3608
+ "update.failedBroken": "更新のインストールに失敗し、元のバージョンにも戻せませんでした。プラグイン管理から再インストールしてください",
2184
3609
  "update.unsupported": "この環境では自動更新できません。{command} を実行してください",
2185
3610
  "update.localDev": "ローカル開発用のインストールです。git pull を実行してください",
2186
- "update.command": "dsh plugin add github:CM-Silence/dsh-mo-image#{tag}",
3611
+ "update.command": "dsh plugin add dsh-mo-image@{tag}",
2187
3612
  "update.viewRelease": "npm で見る",
2188
3613
  "update.noNotes": "このリリースには説明がありません。",
2189
3614
  },
@@ -2216,8 +3641,18 @@ window.__ModuleLoader__.load({
2216
3641
  "form.fetching": "Obteniendo…",
2217
3642
  "form.fetchModels": "Obtener modelos disponibles",
2218
3643
  "form.modelId": "ID del modelo",
2219
- "form.modelSettings": "Ajustes del modelo",
3644
+ "form.reorderModel": "Reordenar modelo",
3645
+ "form.reorderModelHelp": "Arrastre para reordenar o use las teclas de flecha hacia arriba y hacia abajo.",
2220
3646
  "form.deleteModel": "Eliminar modelo",
3647
+ "form.modelOptions": "Opciones del modelo",
3648
+ "form.modelOptionsHint": "Sobrescribe el flujo de trabajo de ComfyUI para este modelo. Déjalo vacío para usar el flujo integrado según el tipo de modelo.",
3649
+ "form.modelOptionsUnsupported": "Los flujos personalizados solo están disponibles con el despliegue ComfyUI",
3650
+ "form.modelWorkflow": "Flujo de trabajo personalizado (formato API de ComfyUI)",
3651
+ "form.modelWorkflowPlaceholder": "En ComfyUI usa Exportar (API) y pega el JSON aquí",
3652
+ "form.modelWorkflowHelp": "Marcadores: {{prompt}}, {{negative_prompt}}, {{width}}, {{height}}, {{seed}}, {{model}}, {{image}} (se sustituye por la referencia subida al editar)",
3653
+ "form.modelOptionsDone": "Listo",
3654
+ "form.modelWorkflowClear": "Borrar flujo de trabajo",
3655
+ "form.modelWorkflowSample": "Insertar plantilla de ejemplo",
2221
3656
  "form.modelEmpty": "El selector de modelos estará vacío. Añade primero al menos un ID de modelo al catálogo.",
2222
3657
  "form.addModel": "Añadir modelo",
2223
3658
  "form.advanced": "Ajustes avanzados",
@@ -2234,18 +3669,17 @@ window.__ModuleLoader__.load({
2234
3669
  "form.localPresetsMissing": "El host no envió la lista de despliegues locales. Recarga la página e inténtalo de nuevo.",
2235
3670
  "form.save": "Guardar",
2236
3671
  "form.cancel": "Cancelar",
2237
- "picker.title": "Obtener modelos disponibles",
3672
+ "picker.title": "Elegir modelos",
2238
3673
  "picker.close": "Cerrar",
2239
- "picker.description": "Selecciona los modelos que quieras añadir al catálogo. No se escribirá nada en el borrador hasta que elijas «Añadir seleccionados».",
3674
+ "picker.description": "Estos son los modelos que tiene disponibles este proveedor. Los modelos marcados componen la lista.",
2240
3675
  "picker.search": "Buscar modelos",
2241
3676
  "picker.selectAll": "Seleccionar todo",
2242
3677
  "picker.deselectAll": "Anular selección",
2243
3678
  "picker.showAll": "Mostrar todos los modelos",
2244
3679
  "picker.filtered": "Se han filtrado {count} modelos que probablemente no generan imágenes",
2245
- "picker.listAria": "Modelos disponibles",
2246
3680
  "picker.noMatches": "No hay modelos coincidentes",
2247
- "picker.adopt": "Añadir seleccionados",
2248
- "picker.adoptCount": "Añadir seleccionados ({count})",
3681
+ "picker.adopt": "Actualizar lista",
3682
+ "picker.keepOne": "Mantén al menos un modelo marcado.",
2249
3683
  "seat.noMatches": "No hay modelos coincidentes",
2250
3684
  "seat.empty": "Aún no hay modelos. Añade uno en Ajustes → Modelos de imagen.",
2251
3685
  "seat.auto": "Automático",
@@ -2254,6 +3688,7 @@ window.__ModuleLoader__.load({
2254
3688
  "seat.menuQuality": "Calidad",
2255
3689
  "seat.menuSize": "Tamaño",
2256
3690
  "seat.menuPromptOptimization": "Optimización de prompts",
3691
+ "seat.fast": "Vista rápida",
2257
3692
  "seat.notSelected": "Sin seleccionar",
2258
3693
  "seat.on": "Activado",
2259
3694
  "seat.off": "Desactivado",
@@ -2270,6 +3705,15 @@ window.__ModuleLoader__.load({
2270
3705
  "seat.triggerAria": "Modelo de imagen: {model}",
2271
3706
  "seat.triggerAriaQuality": "Modelo de imagen: {model}, calidad {quality}",
2272
3707
  "seat.settingsAria": "Ajustes de imagen",
3708
+ "seat.moreSettings": "Más ajustes",
3709
+ "seat.promptSection": "Prompt",
3710
+ "seat.qualityUnsupported": "Este modelo no ofrece niveles de calidad",
3711
+ "seat.qualityWarning": "Consume la cuota más rápido",
3712
+ "seat.levelsCount": "{count} niveles",
3713
+ "seat.levelsNone": "No compatible",
3714
+ "seat.sizeTitle": "Tamaño",
3715
+ "seat.back": "Volver",
3716
+ "seat.modelAutoHint": "Deja que el modelo elija",
2273
3717
  "errors.loadConfig": "No se pudo cargar la configuración de imagen: HTTP {status}",
2274
3718
  "errors.loadConfigDetail": "No se pudo cargar la configuración de imagen: {message}",
2275
3719
  "errors.saveConfig": "No se pudo guardar la configuración de imagen: HTTP {status}",
@@ -2322,11 +3766,11 @@ window.__ModuleLoader__.load({
2322
3766
  "localPreset.sd-server.urlHint": "Introduce solo la URL raíz del servicio y conserva /v1 al final. El plugin añade /images/generations y /models.",
2323
3767
  "localPreset.sd-server.hint": "API nativa de OpenAI Images; admite generación y edición con /images/edits. El modelo suele ser sd-cpp-local y se puede listar desde /v1/models.",
2324
3768
  "localPreset.localai.urlHint": "Introduce solo la URL raíz del servicio y conserva /v1 al final. El plugin añade /images/generations y /models.",
2325
- "localPreset.localai.hint": "Compatible con OpenAI Images. Usa el name del YAML de modelos de LocalAI; puedes listarlo desde /v1/models.",
3769
+ "localPreset.localai.hint": "Compatible con OpenAI Images para generar; usa el name del YAML de modelos de LocalAI, listable desde /v1/models. LocalAI no tiene /images/edits, así que para editar imágenes usa una pasarela compatible con OpenAI.",
2326
3770
  "localPreset.a1111.urlHint": "Introduce solo la URL raíz del servicio, sin /sdapi/v1. El plugin añade /sdapi/v1/txt2img, /img2img y /sd-models.",
2327
3771
  "localPreset.a1111.hint": "Usa /sdapi/v1/txt2img y /sdapi/v1/img2img; la lista de modelos viene de /sdapi/v1/sd-models. Inicia A1111 con --api.",
2328
- "localPreset.comfyui.urlHint": "Introduce solo la URL raíz del servicio, sin /prompt. El plugin añade /prompt, /history y /view.",
2329
- "localPreset.comfyui.hint": "Usa el flujo de trabajo predeterminado con checkpoint SD/SDXL; la lista de modelos viene de /object_info. Para flujos complejos como Flux o Qwen, usa una pasarela compatible con OpenAI.",
3772
+ "localPreset.comfyui.urlHint": "Introduce solo la URL raíz del servicio, sin /prompt. El plugin añade /prompt, /upload/image, /history y /view.",
3773
+ "localPreset.comfyui.hint": "Los flujos integrados cubren SD/SDXL, FLUX.2 y MOSS-Image, tanto para generar como para editar con referencia. Para otras arquitecturas (Qwen-Image, Z-Image…) pega tu flujo de ComfyUI en «Opciones del modelo» o usa una pasarela compatible con OpenAI.",
2330
3774
  "localPreset.swarmui.urlHint": "Introduce solo la URL raíz del servicio, sin /API. El plugin añade /API/GetNewSession, /API/ListModels y /API/GenerateText2Image.",
2331
3775
  "localPreset.swarmui.hint": "Usa /API/GenerateText2Image; la lista de modelos viene de /API/ListModels. La generación funciona; la edición nativa aún no es compatible.",
2332
3776
  "localPreset.openai-gateway.urlHint": "Introduce la URL raíz de la API de OpenAI (normalmente con /v1). El plugin añade /images/generations y /models.",
@@ -2341,9 +3785,11 @@ window.__ModuleLoader__.load({
2341
3785
  "update.doneRestart": "Actualización instalada. Reinicia DSH para aplicarla",
2342
3786
  "update.done": "Actualizado a {version}",
2343
3787
  "update.failed": "La actualización no terminó. Inténtalo de nuevo",
3788
+ "update.failedRestored": "La actualización falló; se restauró la versión anterior",
3789
+ "update.failedBroken": "La actualización falló y no se restauró la versión anterior; reinstálala desde la gestión de complementos",
2344
3790
  "update.unsupported": "Este entorno no admite la actualización automática; ejecuta {command}",
2345
3791
  "update.localDev": "Instalación de desarrollo local: ejecuta git pull",
2346
- "update.command": "dsh plugin add github:CM-Silence/dsh-mo-image#{tag}",
3792
+ "update.command": "dsh plugin add dsh-mo-image@{tag}",
2347
3793
  "update.viewRelease": "Ver en npm",
2348
3794
  "update.noNotes": "Esta versión no tiene notas.",
2349
3795
  },
@@ -2376,8 +3822,18 @@ window.__ModuleLoader__.load({
2376
3822
  "form.fetching": "Récupération…",
2377
3823
  "form.fetchModels": "Récupérer les modèles disponibles",
2378
3824
  "form.modelId": "ID du modèle",
2379
- "form.modelSettings": "Paramètres du modèle",
3825
+ "form.reorderModel": "Réorganiser le modèle",
3826
+ "form.reorderModelHelp": "Faites glisser pour réorganiser ou utilisez les touches fléchées haut et bas.",
2380
3827
  "form.deleteModel": "Supprimer le modèle",
3828
+ "form.modelOptions": "Options du modèle",
3829
+ "form.modelOptionsHint": "Remplace le workflow ComfyUI de ce modèle. Laissez vide pour utiliser le workflow intégré choisi selon le type de modèle.",
3830
+ "form.modelOptionsUnsupported": "Les workflows personnalisés ne sont disponibles qu’avec le déploiement ComfyUI",
3831
+ "form.modelWorkflow": "Workflow personnalisé (format API ComfyUI)",
3832
+ "form.modelWorkflowPlaceholder": "Dans ComfyUI, utilisez Exporter (API) puis collez le JSON ici",
3833
+ "form.modelWorkflowHelp": "Variables : {{prompt}}, {{negative_prompt}}, {{width}}, {{height}}, {{seed}}, {{model}}, {{image}} (remplacé par l'image de référence envoyée lors de l'édition)",
3834
+ "form.modelOptionsDone": "Terminé",
3835
+ "form.modelWorkflowClear": "Effacer le workflow",
3836
+ "form.modelWorkflowSample": "Insérer un modèle d’exemple",
2381
3837
  "form.modelEmpty": "Le sélecteur de modèles sera vide. Ajoutez d'abord au moins un ID de modèle au catalogue.",
2382
3838
  "form.addModel": "Ajouter un modèle",
2383
3839
  "form.advanced": "Paramètres avancés",
@@ -2394,18 +3850,17 @@ window.__ModuleLoader__.load({
2394
3850
  "form.localPresetsMissing": "L'hôte n'a pas fourni la liste des déploiements locaux. Rechargez la page et réessayez.",
2395
3851
  "form.save": "Enregistrer",
2396
3852
  "form.cancel": "Annuler",
2397
- "picker.title": "Récupérer les modèles disponibles",
3853
+ "picker.title": "Choisir les modèles",
2398
3854
  "picker.close": "Fermer",
2399
- "picker.description": "Sélectionnez les modèles à ajouter au catalogue. Rien n'est écrit dans le brouillon avant « Ajouter la sélection ».",
3855
+ "picker.description": "Voici les modèles disponibles chez ce fournisseur. Les modèles cochés constituent la liste.",
2400
3856
  "picker.search": "Rechercher des modèles",
2401
3857
  "picker.selectAll": "Tout sélectionner",
2402
3858
  "picker.deselectAll": "Tout désélectionner",
2403
3859
  "picker.showAll": "Afficher tous les modèles",
2404
3860
  "picker.filtered": "Modèles probablement non génératifs écartés : {count}",
2405
- "picker.listAria": "Modèles disponibles",
2406
3861
  "picker.noMatches": "Aucun modèle correspondant",
2407
- "picker.adopt": "Ajouter la sélection",
2408
- "picker.adoptCount": "Ajouter la sélection ({count})",
3862
+ "picker.adopt": "Mettre à jour la liste",
3863
+ "picker.keepOne": "Gardez au moins un modèle coché.",
2409
3864
  "seat.noMatches": "Aucun modèle correspondant",
2410
3865
  "seat.empty": "Aucun modèle pour l'instant. Ajoutez-en un dans Paramètres → Modèles d'image.",
2411
3866
  "seat.auto": "Automatique",
@@ -2414,6 +3869,7 @@ window.__ModuleLoader__.load({
2414
3869
  "seat.menuQuality": "Qualité",
2415
3870
  "seat.menuSize": "Taille",
2416
3871
  "seat.menuPromptOptimization": "Optimisation du prompt",
3872
+ "seat.fast": "Aperçu rapide",
2417
3873
  "seat.notSelected": "Non sélectionné",
2418
3874
  "seat.on": "Activé",
2419
3875
  "seat.off": "Désactivé",
@@ -2430,6 +3886,15 @@ window.__ModuleLoader__.load({
2430
3886
  "seat.triggerAria": "Modèle d'image : {model}",
2431
3887
  "seat.triggerAriaQuality": "Modèle d'image : {model}, qualité {quality}",
2432
3888
  "seat.settingsAria": "Paramètres d'image",
3889
+ "seat.moreSettings": "Autres réglages",
3890
+ "seat.promptSection": "Prompt",
3891
+ "seat.qualityUnsupported": "Ce modèle n'expose pas de niveaux de qualité",
3892
+ "seat.qualityWarning": "Consomme le quota plus vite",
3893
+ "seat.levelsCount": "{count} niveaux",
3894
+ "seat.levelsNone": "Non pris en charge",
3895
+ "seat.sizeTitle": "Taille",
3896
+ "seat.back": "Retour",
3897
+ "seat.modelAutoHint": "Laissez le modèle choisir",
2433
3898
  "errors.loadConfig": "Impossible de charger les paramètres d'image : HTTP {status}",
2434
3899
  "errors.loadConfigDetail": "Impossible de charger les paramètres d'image : {message}",
2435
3900
  "errors.saveConfig": "Impossible d'enregistrer les paramètres d'image : HTTP {status}",
@@ -2482,11 +3947,11 @@ window.__ModuleLoader__.load({
2482
3947
  "localPreset.sd-server.urlHint": "Indiquez uniquement l'URL racine du service, en conservant /v1 à la fin. Le plugin ajoute /images/generations et /models.",
2483
3948
  "localPreset.sd-server.hint": "API OpenAI Images native, compatible avec la génération et l'édition via /images/edits. Le modèle est généralement sd-cpp-local et peut être listé depuis /v1/models.",
2484
3949
  "localPreset.localai.urlHint": "Indiquez uniquement l'URL racine du service, en conservant /v1 à la fin. Le plugin ajoute /images/generations et /models.",
2485
- "localPreset.localai.hint": "Compatible OpenAI Images. Utilisez le name du YAML de modèles LocalAI ; il peut être listé depuis /v1/models.",
3950
+ "localPreset.localai.hint": "Compatible OpenAI Images pour la génération ; utilisez le name du YAML de modèles LocalAI, listable depuis /v1/models. LocalAI n'a pas /images/edits : pour l'édition, passez par une passerelle compatible OpenAI.",
2486
3951
  "localPreset.a1111.urlHint": "Indiquez uniquement l'URL racine du service, sans /sdapi/v1. Le plugin ajoute /sdapi/v1/txt2img, /img2img et /sd-models.",
2487
3952
  "localPreset.a1111.hint": "Utilise /sdapi/v1/txt2img et /sdapi/v1/img2img ; la liste des modèles provient de /sdapi/v1/sd-models. Lancez A1111 avec --api.",
2488
- "localPreset.comfyui.urlHint": "Indiquez uniquement l'URL racine du service, sans /prompt. Le plugin ajoute /prompt, /history et /view.",
2489
- "localPreset.comfyui.hint": "Utilise le workflow de checkpoint SD/SDXL par défaut ; la liste des modèles provient de /object_info. Pour les workflows complexes comme Flux ou Qwen, utilisez une passerelle compatible OpenAI.",
3953
+ "localPreset.comfyui.urlHint": "Indiquez uniquement l'URL racine du service, sans /prompt. Le plugin ajoute /prompt, /upload/image, /history et /view.",
3954
+ "localPreset.comfyui.hint": "Les workflows intégrés couvrent SD/SDXL, FLUX.2 et MOSS-Image, en génération comme en édition avec image de référence. Pour d'autres architectures (Qwen-Image, Z-Image…), collez votre propre workflow ComfyUI dans « Options du modèle » ou utilisez une passerelle compatible OpenAI.",
2490
3955
  "localPreset.swarmui.urlHint": "Indiquez uniquement l'URL racine du service, sans /API. Le plugin ajoute /API/GetNewSession, /API/ListModels et /API/GenerateText2Image.",
2491
3956
  "localPreset.swarmui.hint": "Utilise /API/GenerateText2Image ; la liste des modèles provient de /API/ListModels. La génération fonctionne ; l'édition native n'est pas encore prise en charge.",
2492
3957
  "localPreset.openai-gateway.urlHint": "Indiquez l'URL racine de l'API OpenAI (généralement avec /v1). Le plugin ajoute /images/generations et /models.",
@@ -2501,9 +3966,11 @@ window.__ModuleLoader__.load({
2501
3966
  "update.doneRestart": "Mise à jour installée — redémarrez DSH pour l'appliquer",
2502
3967
  "update.done": "Mis à jour vers {version}",
2503
3968
  "update.failed": "La mise à jour ne s'est pas terminée — réessayez",
3969
+ "update.failedRestored": "La mise à jour a échoué ; la version précédente a été restaurée",
3970
+ "update.failedBroken": "La mise à jour a échoué et la version précédente n'a pas été restaurée ; réinstallez le greffon depuis la gestion des plugins",
2504
3971
  "update.unsupported": "Cet environnement ne permet pas la mise à jour automatique ; exécutez {command}",
2505
3972
  "update.localDev": "Installation de développement local — lancez git pull",
2506
- "update.command": "dsh plugin add github:CM-Silence/dsh-mo-image#{tag}",
3973
+ "update.command": "dsh plugin add dsh-mo-image@{tag}",
2507
3974
  "update.viewRelease": "Voir sur npm",
2508
3975
  "update.noNotes": "Cette version n'a pas de notes.",
2509
3976
  },
@@ -2536,8 +4003,18 @@ window.__ModuleLoader__.load({
2536
4003
  "form.fetching": "Wird abgerufen…",
2537
4004
  "form.fetchModels": "Verfügbare Modelle abrufen",
2538
4005
  "form.modelId": "Modell-ID",
2539
- "form.modelSettings": "Modelleinstellungen",
4006
+ "form.reorderModel": "Modell neu anordnen",
4007
+ "form.reorderModelHelp": "Ziehen Sie, um die Reihenfolge neu anzuordnen, oder verwenden Sie die Aufwärts- und Abwärtspfeiltasten.",
2540
4008
  "form.deleteModel": "Modell entfernen",
4009
+ "form.modelOptions": "Modelloptionen",
4010
+ "form.modelOptionsHint": "Überschreibt den ComfyUI-Workflow für dieses Modell. Leer lassen, um den eingebauten Workflow passend zum Modelltyp zu nutzen.",
4011
+ "form.modelOptionsUnsupported": "Eigene Workflows gibt es nur bei der ComfyUI-Bereitstellung",
4012
+ "form.modelWorkflow": "Eigener Workflow (ComfyUI-API-Format)",
4013
+ "form.modelWorkflowPlaceholder": "In ComfyUI „Exportieren (API)\" nutzen und das JSON hier einfügen",
4014
+ "form.modelWorkflowHelp": "Platzhalter: {{prompt}}, {{negative_prompt}}, {{width}}, {{height}}, {{seed}}, {{model}}, {{image}} (wird beim Bearbeiten durch das hochgeladene Referenzbild ersetzt)",
4015
+ "form.modelOptionsDone": "Fertig",
4016
+ "form.modelWorkflowClear": "Workflow löschen",
4017
+ "form.modelWorkflowSample": "Beispiel einfügen",
2541
4018
  "form.modelEmpty": "Die Modellauswahl bleibt leer. Fügen Sie zuerst mindestens eine Modell-ID zum Katalog hinzu.",
2542
4019
  "form.addModel": "Modell hinzufügen",
2543
4020
  "form.advanced": "Erweiterte Einstellungen",
@@ -2554,18 +4031,17 @@ window.__ModuleLoader__.load({
2554
4031
  "form.localPresetsMissing": "Der Host hat die Liste lokaler Bereitstellungen nicht bereitgestellt. Laden Sie die Seite neu und versuchen Sie es erneut.",
2555
4032
  "form.save": "Speichern",
2556
4033
  "form.cancel": "Abbrechen",
2557
- "picker.title": "Verfügbare Modelle abrufen",
4034
+ "picker.title": "Modelle auswählen",
2558
4035
  "picker.close": "Schließen",
2559
- "picker.description": "Wählen Sie die Modelle aus, die dem Katalog hinzugefügt werden sollen. Erst mit „Auswahl hinzufügen“ wird der Entwurf geändert.",
4036
+ "picker.description": "Dies sind die vom Anbieter verfügbaren Modelle. Angehakte Modelle bilden die Liste.",
2560
4037
  "picker.search": "Modelle suchen",
2561
4038
  "picker.selectAll": "Alle auswählen",
2562
4039
  "picker.deselectAll": "Auswahl aufheben",
2563
4040
  "picker.showAll": "Alle Modelle anzeigen",
2564
4041
  "picker.filtered": "Als wahrscheinlich nicht bildgenerierend gefiltert: {count}",
2565
- "picker.listAria": "Verfügbare Modelle",
2566
4042
  "picker.noMatches": "Keine passenden Modelle",
2567
- "picker.adopt": "Auswahl hinzufügen",
2568
- "picker.adoptCount": "Auswahl hinzufügen ({count})",
4043
+ "picker.adopt": "Liste aktualisieren",
4044
+ "picker.keepOne": "Mindestens ein Modell muss angehakt bleiben.",
2569
4045
  "seat.noMatches": "Keine passenden Modelle",
2570
4046
  "seat.empty": "Noch keine Modelle. Fügen Sie eines unter Einstellungen → Bildmodelle hinzu.",
2571
4047
  "seat.auto": "Automatisch",
@@ -2574,6 +4050,7 @@ window.__ModuleLoader__.load({
2574
4050
  "seat.menuQuality": "Qualität",
2575
4051
  "seat.menuSize": "Größe",
2576
4052
  "seat.menuPromptOptimization": "Prompt-Optimierung",
4053
+ "seat.fast": "Schnellvorschau",
2577
4054
  "seat.notSelected": "Nicht ausgewählt",
2578
4055
  "seat.on": "Ein",
2579
4056
  "seat.off": "Aus",
@@ -2590,6 +4067,15 @@ window.__ModuleLoader__.load({
2590
4067
  "seat.triggerAria": "Bildmodell: {model}",
2591
4068
  "seat.triggerAriaQuality": "Bildmodell: {model}, Qualität {quality}",
2592
4069
  "seat.settingsAria": "Bildeinstellungen",
4070
+ "seat.moreSettings": "Weitere Einstellungen",
4071
+ "seat.promptSection": "Prompt",
4072
+ "seat.qualityUnsupported": "Dieses Modell bietet keine Qualitätsstufen",
4073
+ "seat.qualityWarning": "Verbraucht das Kontingent schneller",
4074
+ "seat.levelsCount": "{count} Stufen",
4075
+ "seat.levelsNone": "Nicht unterstützt",
4076
+ "seat.sizeTitle": "Größe",
4077
+ "seat.back": "Zurück",
4078
+ "seat.modelAutoHint": "Das Modell wählen lassen",
2593
4079
  "errors.loadConfig": "Bildeinstellungen konnten nicht geladen werden: HTTP {status}",
2594
4080
  "errors.loadConfigDetail": "Bildeinstellungen konnten nicht geladen werden: {message}",
2595
4081
  "errors.saveConfig": "Bildeinstellungen konnten nicht gespeichert werden: HTTP {status}",
@@ -2642,11 +4128,11 @@ window.__ModuleLoader__.load({
2642
4128
  "localPreset.sd-server.urlHint": "Geben Sie nur die Stamm-URL des Dienstes ein und behalten Sie das abschließende /v1 bei. Das Plugin ergänzt /images/generations und /models.",
2643
4129
  "localPreset.sd-server.hint": "Native OpenAI-Images-API mit Unterstützung für Generierung und Bearbeitung über /images/edits. Das Modell heißt meist sd-cpp-local und lässt sich über /v1/models auflisten.",
2644
4130
  "localPreset.localai.urlHint": "Geben Sie nur die Stamm-URL des Dienstes ein und behalten Sie das abschließende /v1 bei. Das Plugin ergänzt /images/generations und /models.",
2645
- "localPreset.localai.hint": "OpenAI-Images-kompatibel. Verwenden Sie den name aus der LocalAI-Modell-YAML; er lässt sich über /v1/models auflisten.",
4131
+ "localPreset.localai.hint": "OpenAI-Images-kompatibel für die Generierung; verwenden Sie den name aus der LocalAI-Modell-YAML, abrufbar über /v1/models. LocalAI hat kein /images/edits – nutzen Sie für Bildbearbeitung ein OpenAI-kompatibles Gateway.",
2646
4132
  "localPreset.a1111.urlHint": "Geben Sie nur die Stamm-URL des Dienstes ein, ohne /sdapi/v1. Das Plugin ergänzt /sdapi/v1/txt2img, /img2img und /sd-models.",
2647
4133
  "localPreset.a1111.hint": "Nutzt /sdapi/v1/txt2img und /sdapi/v1/img2img; die Modellliste stammt aus /sdapi/v1/sd-models. Starten Sie A1111 mit --api.",
2648
- "localPreset.comfyui.urlHint": "Geben Sie nur die Stamm-URL des Dienstes ein, ohne /prompt. Das Plugin ergänzt /prompt, /history und /view.",
2649
- "localPreset.comfyui.hint": "Nutzt den Standard-Workflow mit SD/SDXL-Checkpoint; die Modellliste stammt aus /object_info. Für komplexe Workflows wie Flux oder Qwen verwenden Sie ein OpenAI-kompatibles Gateway.",
4134
+ "localPreset.comfyui.urlHint": "Geben Sie nur die Stamm-URL des Dienstes ein, ohne /prompt. Das Plugin ergänzt /prompt, /upload/image, /history und /view.",
4135
+ "localPreset.comfyui.hint": "Eingebaute Workflows decken SD/SDXL, FLUX.2 und MOSS-Image ab – für Generierung und Bearbeitung mit Referenzbild. Für andere Architekturen (Qwen-Image, Z-Image …) den eigenen ComfyUI-Workflow unter „Modelloptionen\" einfügen oder ein OpenAI-kompatibles Gateway nutzen.",
2650
4136
  "localPreset.swarmui.urlHint": "Geben Sie nur die Stamm-URL des Dienstes ein, ohne /API. Das Plugin ergänzt /API/GetNewSession, /API/ListModels und /API/GenerateText2Image.",
2651
4137
  "localPreset.swarmui.hint": "Nutzt /API/GenerateText2Image; die Modellliste stammt aus /API/ListModels. Die Generierung funktioniert; native Bearbeitung wird noch nicht unterstützt.",
2652
4138
  "localPreset.openai-gateway.urlHint": "Geben Sie die Stamm-URL der OpenAI-API ein (meist mit /v1). Das Plugin ergänzt /images/generations und /models.",
@@ -2661,9 +4147,11 @@ window.__ModuleLoader__.load({
2661
4147
  "update.doneRestart": "Update installiert – DSH neu starten, um es anzuwenden",
2662
4148
  "update.done": "Auf {version} aktualisiert",
2663
4149
  "update.failed": "Das Update wurde nicht abgeschlossen – bitte erneut versuchen",
4150
+ "update.failedRestored": "Das Update ist fehlgeschlagen – die vorherige Version wurde wiederhergestellt",
4151
+ "update.failedBroken": "Das Update ist fehlgeschlagen und die vorherige Version wurde nicht wiederhergestellt – installieren Sie das Plugin über die Plugin-Verwaltung neu",
2664
4152
  "update.unsupported": "Diese Umgebung kann sich nicht selbst aktualisieren; führen Sie {command} aus",
2665
4153
  "update.localDev": "Lokale Entwicklungsinstallation – bitte selbst git pull ausführen",
2666
- "update.command": "dsh plugin add github:CM-Silence/dsh-mo-image#{tag}",
4154
+ "update.command": "dsh plugin add dsh-mo-image@{tag}",
2667
4155
  "update.viewRelease": "Auf npm ansehen",
2668
4156
  "update.noNotes": "Diese Version hat keine Hinweise.",
2669
4157
  },
@@ -2696,8 +4184,18 @@ window.__ModuleLoader__.load({
2696
4184
  "form.fetching": "Получение…",
2697
4185
  "form.fetchModels": "Получить доступные модели",
2698
4186
  "form.modelId": "ID модели",
2699
- "form.modelSettings": "Настройки модели",
4187
+ "form.reorderModel": "Изменить порядок модели",
4188
+ "form.reorderModelHelp": "Перетащите, чтобы изменить порядок, или используйте клавиши со стрелками вверх и вниз.",
2700
4189
  "form.deleteModel": "Удалить модель",
4190
+ "form.modelOptions": "Параметры модели",
4191
+ "form.modelOptionsHint": "Задаёт отдельный workflow ComfyUI для этой модели. Оставьте пустым, чтобы использовать встроенный workflow по типу модели.",
4192
+ "form.modelOptionsUnsupported": "Свои workflow доступны только при развёртывании ComfyUI",
4193
+ "form.modelWorkflow": "Свой workflow (формат API ComfyUI)",
4194
+ "form.modelWorkflowPlaceholder": "В ComfyUI выберите «Экспорт (API)» и вставьте JSON сюда",
4195
+ "form.modelWorkflowHelp": "Доступные подстановки: {{prompt}}, {{negative_prompt}}, {{width}}, {{height}}, {{seed}}, {{model}}, {{image}} (при редактировании подставляется загруженный референс)",
4196
+ "form.modelOptionsDone": "Готово",
4197
+ "form.modelWorkflowClear": "Очистить workflow",
4198
+ "form.modelWorkflowSample": "Вставить пример",
2701
4199
  "form.modelEmpty": "Выбор моделей будет пустым. Сначала добавьте хотя бы один ID модели в каталог.",
2702
4200
  "form.addModel": "Добавить модель",
2703
4201
  "form.advanced": "Дополнительные настройки",
@@ -2714,18 +4212,17 @@ window.__ModuleLoader__.load({
2714
4212
  "form.localPresetsMissing": "Хост не передал список локальных развёртываний. Обновите страницу и повторите попытку.",
2715
4213
  "form.save": "Сохранить",
2716
4214
  "form.cancel": "Отмена",
2717
- "picker.title": "Получить доступные модели",
4215
+ "picker.title": "Выберите модели",
2718
4216
  "picker.close": "Закрыть",
2719
- "picker.description": "Выберите модели для добавления в каталог. В черновик ничего не попадёт, пока вы не нажмёте «Добавить выбранные».",
4217
+ "picker.description": "Это модели, доступные у поставщика. Отмеченные модели составят список.",
2720
4218
  "picker.search": "Поиск моделей",
2721
4219
  "picker.selectAll": "Выбрать все",
2722
4220
  "picker.deselectAll": "Снять выбор",
2723
4221
  "picker.showAll": "Показать все модели",
2724
4222
  "picker.filtered": "Исключено как вероятно не-изображения: {count}",
2725
- "picker.listAria": "Доступные модели",
2726
4223
  "picker.noMatches": "Подходящих моделей нет",
2727
- "picker.adopt": "Добавить выбранные",
2728
- "picker.adoptCount": "Добавить выбранные ({count})",
4224
+ "picker.adopt": "Обновить список",
4225
+ "picker.keepOne": "Оставьте отмеченной хотя бы одну модель.",
2729
4226
  "seat.noMatches": "Подходящих моделей нет",
2730
4227
  "seat.empty": "Моделей пока нет. Добавьте их в «Настройки → Модели изображений».",
2731
4228
  "seat.auto": "Авто",
@@ -2734,6 +4231,7 @@ window.__ModuleLoader__.load({
2734
4231
  "seat.menuQuality": "Качество",
2735
4232
  "seat.menuSize": "Размер",
2736
4233
  "seat.menuPromptOptimization": "Оптимизация промпта",
4234
+ "seat.fast": "Быстрый просмотр",
2737
4235
  "seat.notSelected": "Не выбрано",
2738
4236
  "seat.on": "Вкл.",
2739
4237
  "seat.off": "Выкл.",
@@ -2750,6 +4248,15 @@ window.__ModuleLoader__.load({
2750
4248
  "seat.triggerAria": "Модель изображений: {model}",
2751
4249
  "seat.triggerAriaQuality": "Модель изображений: {model}, качество {quality}",
2752
4250
  "seat.settingsAria": "Настройки изображений",
4251
+ "seat.moreSettings": "Другие настройки",
4252
+ "seat.promptSection": "Промпт",
4253
+ "seat.qualityUnsupported": "У этой модели нет уровней качества",
4254
+ "seat.qualityWarning": "Быстрее расходует квоту",
4255
+ "seat.levelsCount": "{count} уровней",
4256
+ "seat.levelsNone": "Не поддерживается",
4257
+ "seat.sizeTitle": "Размер",
4258
+ "seat.back": "Назад",
4259
+ "seat.modelAutoHint": "Пусть модель выберет",
2753
4260
  "errors.loadConfig": "Не удалось загрузить настройки изображений: HTTP {status}",
2754
4261
  "errors.loadConfigDetail": "Не удалось загрузить настройки изображений: {message}",
2755
4262
  "errors.saveConfig": "Не удалось сохранить настройки изображений: HTTP {status}",
@@ -2802,11 +4309,11 @@ window.__ModuleLoader__.load({
2802
4309
  "localPreset.sd-server.urlHint": "Укажите только корневой URL службы, сохранив /v1 в конце. Плагин добавит /images/generations и /models.",
2803
4310
  "localPreset.sd-server.hint": "Нативный API OpenAI Images: поддерживает генерацию и редактирование через /images/edits. Модель обычно называется sd-cpp-local; список доступен в /v1/models.",
2804
4311
  "localPreset.localai.urlHint": "Укажите только корневой URL службы, сохранив /v1 в конце. Плагин добавит /images/generations и /models.",
2805
- "localPreset.localai.hint": "Совместимо с OpenAI Images. Укажите name из YAML-файла моделей LocalAI; список доступен в /v1/models.",
4312
+ "localPreset.localai.hint": "Совместимо с OpenAI Images для генерации; укажите name из YAML-файла моделей LocalAI, список доступен в /v1/models. В LocalAI нет /images/edits, поэтому для редактирования используйте шлюз, совместимый с OpenAI.",
2806
4313
  "localPreset.a1111.urlHint": "Укажите только корневой URL службы, без /sdapi/v1. Плагин добавит /sdapi/v1/txt2img, /img2img и /sd-models.",
2807
4314
  "localPreset.a1111.hint": "Использует /sdapi/v1/txt2img и /sdapi/v1/img2img; список моделей берётся из /sdapi/v1/sd-models. Запускайте A1111 с параметром --api.",
2808
- "localPreset.comfyui.urlHint": "Укажите только корневой URL службы, без /prompt. Плагин добавит /prompt, /history и /view.",
2809
- "localPreset.comfyui.hint": "Использует стандартный workflow с checkpoint SD/SDXL; список моделей берётся из /object_info. Для сложных workflow (Flux, Qwen и т. п.) используйте шлюз, совместимый с OpenAI.",
4315
+ "localPreset.comfyui.urlHint": "Укажите только корневой URL службы, без /prompt. Плагин добавит /prompt, /upload/image, /history и /view.",
4316
+ "localPreset.comfyui.hint": "Встроенные workflow покрывают SD/SDXL, FLUX.2 и MOSS-Image — и генерацию, и редактирование по референсу. Для других архитектур (Qwen-Image, Z-Image и т. п.) вставьте свой workflow ComfyUI в «Параметры модели» или используйте шлюз, совместимый с OpenAI.",
2810
4317
  "localPreset.swarmui.urlHint": "Укажите только корневой URL службы, без /API. Плагин добавит /API/GetNewSession, /API/ListModels и /API/GenerateText2Image.",
2811
4318
  "localPreset.swarmui.hint": "Использует /API/GenerateText2Image; список моделей берётся из /API/ListModels. Генерация работает, нативное редактирование пока не поддерживается.",
2812
4319
  "localPreset.openai-gateway.urlHint": "Укажите корневой URL API OpenAI (обычно с /v1). Плагин добавит /images/generations и /models.",
@@ -2821,9 +4328,11 @@ window.__ModuleLoader__.load({
2821
4328
  "update.doneRestart": "Обновление установлено — перезапустите DSH",
2822
4329
  "update.done": "Обновлено до {version}",
2823
4330
  "update.failed": "Обновление не завершено — повторите попытку",
4331
+ "update.failedRestored": "Обновление не удалось — прежняя версия восстановлена",
4332
+ "update.failedBroken": "Обновление не удалось, и прежняя версия не восстановлена — переустановите плагин в управлении плагинами",
2824
4333
  "update.unsupported": "Эта среда не поддерживает самообновление — выполните {command}",
2825
4334
  "update.localDev": "Локальная установка для разработки — выполните git pull",
2826
- "update.command": "dsh plugin add github:CM-Silence/dsh-mo-image#{tag}",
4335
+ "update.command": "dsh plugin add dsh-mo-image@{tag}",
2827
4336
  "update.viewRelease": "Открыть на npm",
2828
4337
  "update.noNotes": "В этом выпуске нет примечаний.",
2829
4338
  },
@@ -2856,8 +4365,18 @@ window.__ModuleLoader__.load({
2856
4365
  "form.fetching": "Obtendo…",
2857
4366
  "form.fetchModels": "Obter modelos disponíveis",
2858
4367
  "form.modelId": "ID do modelo",
2859
- "form.modelSettings": "Configurações do modelo",
4368
+ "form.reorderModel": "Reordenar modelo",
4369
+ "form.reorderModelHelp": "Arraste para reordenar ou use as teclas de seta para cima e para baixo.",
2860
4370
  "form.deleteModel": "Remover modelo",
4371
+ "form.modelOptions": "Opções do modelo",
4372
+ "form.modelOptionsHint": "Substitui o fluxo de trabalho do ComfyUI para este modelo. Deixe vazio para usar o fluxo integrado conforme o tipo do modelo.",
4373
+ "form.modelOptionsUnsupported": "Fluxos de trabalho personalizados só estão disponíveis na implantação ComfyUI",
4374
+ "form.modelWorkflow": "Fluxo de trabalho personalizado (formato API do ComfyUI)",
4375
+ "form.modelWorkflowPlaceholder": "No ComfyUI use Exportar (API) e cole o JSON aqui",
4376
+ "form.modelWorkflowHelp": "Marcadores: {{prompt}}, {{negative_prompt}}, {{width}}, {{height}}, {{seed}}, {{model}}, {{image}} (substituído pela referência enviada ao editar)",
4377
+ "form.modelOptionsDone": "Concluído",
4378
+ "form.modelWorkflowClear": "Limpar fluxo de trabalho",
4379
+ "form.modelWorkflowSample": "Inserir modelo de exemplo",
2861
4380
  "form.modelEmpty": "O seletor de modelos ficará vazio. Adicione pelo menos um ID de modelo ao catálogo primeiro.",
2862
4381
  "form.addModel": "Adicionar modelo",
2863
4382
  "form.advanced": "Configurações avançadas",
@@ -2874,18 +4393,17 @@ window.__ModuleLoader__.load({
2874
4393
  "form.localPresetsMissing": "O host não enviou a lista de implantações locais. Recarregue a página e tente novamente.",
2875
4394
  "form.save": "Salvar",
2876
4395
  "form.cancel": "Cancelar",
2877
- "picker.title": "Obter modelos disponíveis",
4396
+ "picker.title": "Escolher modelos",
2878
4397
  "picker.close": "Fechar",
2879
- "picker.description": "Selecione os modelos para adicionar ao catálogo. Nada é gravado no rascunho até você escolher “Adicionar selecionados”.",
4398
+ "picker.description": "Estes são os modelos disponíveis neste provedor. Os modelos marcados compõem a lista.",
2880
4399
  "picker.search": "Pesquisar modelos",
2881
4400
  "picker.selectAll": "Selecionar tudo",
2882
4401
  "picker.deselectAll": "Desmarcar tudo",
2883
4402
  "picker.showAll": "Mostrar todos os modelos",
2884
4403
  "picker.filtered": "Filtrados como prováveis não-imagens: {count}",
2885
- "picker.listAria": "Modelos disponíveis",
2886
4404
  "picker.noMatches": "Nenhum modelo correspondente",
2887
- "picker.adopt": "Adicionar selecionados",
2888
- "picker.adoptCount": "Adicionar selecionados ({count})",
4405
+ "picker.adopt": "Atualizar lista",
4406
+ "picker.keepOne": "Mantenha pelo menos um modelo marcado.",
2889
4407
  "seat.noMatches": "Nenhum modelo correspondente",
2890
4408
  "seat.empty": "Ainda não há modelos. Adicione um em Configurações → Modelos de imagem.",
2891
4409
  "seat.auto": "Automático",
@@ -2894,6 +4412,7 @@ window.__ModuleLoader__.load({
2894
4412
  "seat.menuQuality": "Qualidade",
2895
4413
  "seat.menuSize": "Tamanho",
2896
4414
  "seat.menuPromptOptimization": "Otimização de prompt",
4415
+ "seat.fast": "Prévia rápida",
2897
4416
  "seat.notSelected": "Não selecionado",
2898
4417
  "seat.on": "Ativado",
2899
4418
  "seat.off": "Desativado",
@@ -2910,6 +4429,15 @@ window.__ModuleLoader__.load({
2910
4429
  "seat.triggerAria": "Modelo de imagem: {model}",
2911
4430
  "seat.triggerAriaQuality": "Modelo de imagem: {model}, qualidade {quality}",
2912
4431
  "seat.settingsAria": "Configurações de imagem",
4432
+ "seat.moreSettings": "Mais ajustes",
4433
+ "seat.promptSection": "Prompt",
4434
+ "seat.qualityUnsupported": "Este modelo não oferece níveis de qualidade",
4435
+ "seat.qualityWarning": "Consome a cota mais rápido",
4436
+ "seat.levelsCount": "{count} níveis",
4437
+ "seat.levelsNone": "Não suportado",
4438
+ "seat.sizeTitle": "Tamanho",
4439
+ "seat.back": "Voltar",
4440
+ "seat.modelAutoHint": "Deixe o modelo escolher",
2913
4441
  "errors.loadConfig": "Não foi possível carregar as configurações de imagem: HTTP {status}",
2914
4442
  "errors.loadConfigDetail": "Não foi possível carregar as configurações de imagem: {message}",
2915
4443
  "errors.saveConfig": "Não foi possível salvar as configurações de imagem: HTTP {status}",
@@ -2962,11 +4490,11 @@ window.__ModuleLoader__.load({
2962
4490
  "localPreset.sd-server.urlHint": "Informe apenas a URL raiz do serviço e mantenha o /v1 no final. O plugin acrescenta /images/generations e /models.",
2963
4491
  "localPreset.sd-server.hint": "API nativa do OpenAI Images; oferece geração e edição com /images/edits. O modelo geralmente é sd-cpp-local e pode ser listado em /v1/models.",
2964
4492
  "localPreset.localai.urlHint": "Informe apenas a URL raiz do serviço e mantenha o /v1 no final. O plugin acrescenta /images/generations e /models.",
2965
- "localPreset.localai.hint": "Compatível com OpenAI Images. Use o name do YAML de modelos do LocalAI; ele pode ser listado em /v1/models.",
4493
+ "localPreset.localai.hint": "Compatível com OpenAI Images para gerar; use o name do YAML de modelos do LocalAI, listável em /v1/models. O LocalAI não tem /images/edits, então use um gateway compatível com OpenAI para editar imagens.",
2966
4494
  "localPreset.a1111.urlHint": "Informe apenas a URL raiz do serviço, sem /sdapi/v1. O plugin acrescenta /sdapi/v1/txt2img, /img2img e /sd-models.",
2967
4495
  "localPreset.a1111.hint": "Usa /sdapi/v1/txt2img e /sdapi/v1/img2img; a lista de modelos vem de /sdapi/v1/sd-models. Inicie o A1111 com --api.",
2968
- "localPreset.comfyui.urlHint": "Informe apenas a URL raiz do serviço, sem /prompt. O plugin acrescenta /prompt, /history e /view.",
2969
- "localPreset.comfyui.hint": "Usa o fluxo de trabalho padrão com checkpoint SD/SDXL; a lista de modelos vem de /object_info. Para fluxos complexos como Flux ou Qwen, use um gateway compatível com OpenAI.",
4496
+ "localPreset.comfyui.urlHint": "Informe apenas a URL raiz do serviço, sem /prompt. O plugin acrescenta /prompt, /upload/image, /history e /view.",
4497
+ "localPreset.comfyui.hint": "Os fluxos integrados cobrem SD/SDXL, FLUX.2 e MOSS-Image, tanto para gerar quanto para editar com referência. Para outras arquiteturas (Qwen-Image, Z-Image…), cole seu fluxo do ComfyUI em «Opções do modelo» ou use um gateway compatível com OpenAI.",
2970
4498
  "localPreset.swarmui.urlHint": "Informe apenas a URL raiz do serviço, sem /API. O plugin acrescenta /API/GetNewSession, /API/ListModels e /API/GenerateText2Image.",
2971
4499
  "localPreset.swarmui.hint": "Usa /API/GenerateText2Image; a lista de modelos vem de /API/ListModels. A geração funciona; a edição nativa ainda não é suportada.",
2972
4500
  "localPreset.openai-gateway.urlHint": "Informe a URL raiz da API OpenAI (normalmente com /v1). O plugin acrescenta /images/generations e /models.",
@@ -2981,9 +4509,11 @@ window.__ModuleLoader__.load({
2981
4509
  "update.doneRestart": "Atualização instalada — reinicie o DSH para aplicar",
2982
4510
  "update.done": "Atualizado para {version}",
2983
4511
  "update.failed": "A atualização não terminou — tente novamente",
4512
+ "update.failedRestored": "A atualização falhou — a versão anterior foi restaurada",
4513
+ "update.failedBroken": "A atualização falhou e a versão anterior não foi restaurada — reinstale pelo gerenciamento de plugins",
2984
4514
  "update.unsupported": "Este ambiente não permite atualização automática; execute {command}",
2985
4515
  "update.localDev": "Instalação de desenvolvimento local — execute git pull",
2986
- "update.command": "dsh plugin add github:CM-Silence/dsh-mo-image#{tag}",
4516
+ "update.command": "dsh plugin add dsh-mo-image@{tag}",
2987
4517
  "update.viewRelease": "Ver no npm",
2988
4518
  "update.noNotes": "Esta versão não tem notas.",
2989
4519
  },
@@ -3001,7 +4531,7 @@ window.__ModuleLoader__.load({
3001
4531
  refreshThemeClasses();
3002
4532
  // DSH 的客户端插件样式是异步注入的:启动后再补几次解析,并在新 <style>
3003
4533
  // 出现时重试,保证拿到的是当前页面真正在用的前缀。
3004
- ctx.effect(() => {
4534
+ ctx.effect(() => {
3005
4535
  let queued = 0;
3006
4536
  const schedule = () => {
3007
4537
  if (queued) return;
@@ -3010,7 +4540,11 @@ window.__ModuleLoader__.load({
3010
4540
  refreshThemeClasses();
3011
4541
  }, 50);
3012
4542
  };
3013
- const timers = [0, 120, 600, 1500].map((delay) => setTimeout(refreshThemeClasses, delay));
4543
+ const timers = [0, 120, 600, 1500, 3000].map((delay) => setTimeout(refreshThemeClasses, delay));
4544
+ const onFocus = () => refreshThemeClasses();
4545
+ const onVisible = () => { if (!document.hidden) refreshThemeClasses(); };
4546
+ if (typeof window.addEventListener === 'function') window.addEventListener('focus', onFocus);
4547
+ if (typeof document.addEventListener === 'function') document.addEventListener('visibilitychange', onVisible);
3014
4548
  const observer = typeof MutationObserver === 'undefined' ? null : new MutationObserver((records) => {
3015
4549
  for (const record of records) {
3016
4550
  for (const node of record.addedNodes) {
@@ -3026,6 +4560,8 @@ window.__ModuleLoader__.load({
3026
4560
  for (const timer of timers) clearTimeout(timer);
3027
4561
  if (queued) clearTimeout(queued);
3028
4562
  if (observer) observer.disconnect();
4563
+ if (typeof window.removeEventListener === 'function') window.removeEventListener('focus', onFocus);
4564
+ if (typeof document.removeEventListener === 'function') document.removeEventListener('visibilitychange', onVisible);
3029
4565
  };
3030
4566
  }, 'mo-image: theme classes');
3031
4567
  ctx.slots.inject('settings.section.icon', () => ctx.slots.register({
@@ -3084,7 +4620,11 @@ window.__ModuleLoader__.load({
3084
4620
  ? translate('update.done', { version: status.latest })
3085
4621
  : translate('update.doneRestart');
3086
4622
  }
3087
- if (state === 'failed') return translate('update.failed');
4623
+ if (state === 'failed') {
4624
+ if (status.error === 'update.failedRestored') return translate('update.failedRestored');
4625
+ if (status.error === 'update.failedBroken') return translate('update.failedBroken');
4626
+ return translate('update.failed');
4627
+ }
3088
4628
  if (state === 'updating') return translate('update.starting');
3089
4629
  return null;
3090
4630
  }
@@ -3155,7 +4695,18 @@ window.__ModuleLoader__.load({
3155
4695
  UpdateHeader: UpdateHeader,
3156
4696
  UpdateDialog: UpdateDialog,
3157
4697
  toastQueue: toastQueue,
3158
- postUpdateAction: postUpdateAction
4698
+ postUpdateAction: postUpdateAction,
4699
+ qualityRailLevels: qualityRailLevels,
4700
+ qualityBucketOf: qualityBucketOf,
4701
+ codexSkinProbe: codexSkinProbe,
4702
+ deriveSeatView: deriveSeatView,
4703
+ detectSeatSkinFromMarkers: detectSeatSkinFromMarkers,
4704
+ detectSeatSkin: detectSeatSkin,
4705
+ pickTriggerStyle: pickTriggerStyle,
4706
+ codexPlacement: codexPlacement,
4707
+ buildCodexSparkles: buildCodexSparkles,
4708
+ buildCodexBloom: buildCodexBloom,
4709
+ CodexImageSeat: CodexImageSeat
3159
4710
  };
3160
4711
  return { inject, apply, __test };
3161
4712
  }