dsh-background-by-model 0.5.4 → 0.5.5
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/CHANGELOG.md +7 -1
- package/CHANGELOG.zh.md +7 -1
- package/README.md +5 -9
- package/README.zh.md +5 -9
- package/lib/client.js +33 -18
- package/lib/client.js.map +1 -1
- package/package.json +1 -1
package/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["BG_MODES","clamp","clamp","Component","useState","createPortal","useRef","memo","useRef","useState","useCallback","useState","useRef","toHex","useRef","useState","useCallback","useState","useRef","useCallback","useState","useRef","useRef","useState","useRef"],"sources":["../src/client/runtime.ts","../src/client/i18n.ts","../src/schema.ts","../src/client/state.ts","../src/client/rpc.ts","../src/client/utils/color.ts","../src/client/components/ui.css.ts","../src/client/wallpaper.ts","../src/client/modelbg.ts","../src/client/components/icons.tsx","../src/client/components/ErrorBoundary.tsx","../src/client/components/Portal.tsx","../src/client/components/LiveSlider.tsx","../src/client/components/pages/InterfacePage.tsx","../src/client/utils/image.ts","../src/client/components/ColorWheel.tsx","../src/client/components/ColorInputs.tsx","../src/client/components/ColorPicker.tsx","../src/client/components/BgEditor.tsx","../src/client/components/pages/ModelBgPage.tsx","../src/client/components/pages/ProfilePage.tsx","../src/client/components/ThemeSection.tsx","../src/client/index.tsx"],"sourcesContent":["/**\r\n * Harness-version-agnostic access to the client runtime.\r\n *\r\n * Before dsh 0.1.2 the store primitive lived on the composite package\r\n * `@deepseek-ai/dsh-client-runtime` (the `/client` subpath). The new harness\r\n * split it into `@deepseek-ai/dsh-client-store`. Both specifiers are kept\r\n * external so they resolve against the host client-module table; a missing\r\n * table entry on one side throws (the \"missed the module table\" error) and is\r\n * caught, falling through to the other package. This lets one bundle load on\r\n * both the old npm release and the new source.\r\n *\r\n * The host's synchronous `require` is injected by the loader into the bundle\r\n * factory; tsdown keeps these two bare specifiers as external CJS requires so\r\n * they bind to that factory `require`.\r\n */\r\n\r\n/* eslint-disable @typescript-eslint/no-explicit-any */\r\n\r\ninterface StoreModule {\r\n defineStore: any\r\n}\r\n\r\nfunction resolveStore(): StoreModule {\r\n try {\r\n // New harness (dsh >= 0.1.2): dedicated store package after the runtime\r\n // was split. Missing here means the loader table has no such row → throw.\r\n return require('@deepseek-ai/dsh-client-store') as StoreModule\r\n } catch {\r\n /* fall through to the legacy composite runtime below */\r\n }\r\n // Legacy harness (npm release): composite runtime, /client subpath.\r\n return require('@deepseek-ai/dsh-client-runtime/client') as StoreModule\r\n}\r\n\r\nexport const defineStore: any = resolveStore().defineStore","export const NS = 'settings.anyBg'\r\n\r\nexport const zh: Record<string, string> = {\r\n nav: '模型背景', brandTag: '按模型换背景', close: '关闭',\r\n pageInterface: '界面', pageModelBg: '模型背景', pageProfile: '配置',\r\n descInterface: '为主界面的各个区域单独调节透明度与模糊,营造空间层次感。这里的设置对所有模型生效',\r\n descModelBg: '每条规则 = 一个匹配串 + 一套背景外观。切换模型时,从上往下找第一条匹配串出现在模型名里的规则;都没中就使用第 1 条',\r\n descProfile: '把当前全部规则连同图片导出备份,或从文件一键恢复',\r\n\r\n uiTitle: '主界面',\r\n uiOpacity: '透明度', uiBlur: '模糊度',\r\n uiOpacityBg: '主背景', uiOpacitySide: '左侧栏', uiOpacityCard: '卡片与菜单面板', uiOpacityInput: '输入框与控件',\r\n uiSop: '设置界面透明度', uiChatRegion: '对话文本框', uiTrajectory: '轨迹页',\r\n uiPreview: '右侧栏',\r\n\r\n // Only the diagnostics survive: the model/rule readout they used to sit under\r\n // is gone (the match tester at the top of the page answers the same question).\r\n statusUnknownHint: '检测不到时一律使用第 1 条可用规则;切换一次模型或稍等片刻会自动重试',\r\n statusSourceDefaultHint: '只读到宿主默认模型,它不是本会话当前选择的模型;本会话的模型选择可用后会自动纠正',\r\n statusNoteNoService: '仍未拿到会话服务(会话控制器晚于本插件加载),正在自动重试',\r\n statusNoteNoSession: '会话服务已就绪,但还没有当前会话 id',\r\n statusNoteNoProjection: '拿不到本会话的模型选择投影(binding / projections 不可用)',\r\n statusNoteEmptySelection: '本会话的模型选择投影还没有值(切一次模型即可写入)',\r\n\r\n rulesTitle: '规则列表',\r\n rulesHint: '从上到下即为优先级。规则 1 同时兼任兜底:所有匹配串都没命中时使用它',\r\n tryoutTitle: '匹配试跑',\r\n tryoutPlaceholder: '输入模型名,如 deepseek-flash',\r\n tryoutUseCurrent: '填入当前模型',\r\n tryoutHit: '命中规则',\r\n tryoutFallback: '无匹配 · 走兜底规则',\r\n tryoutNone: '没有可用规则(规则需要启用并有图片)',\r\n tryoutEmpty: '输入模型名即可试跑',\r\n autoExtract: '选图后自动取主题色',\r\n autoExtractHint: '只在规则还没有颜色时自动取色,绝不覆盖你手动选的颜色',\r\n ruleAdd: '新增规则',\r\n ruleFallbackBadge: '兜底',\r\n ruleMatchLabel: '匹配串',\r\n ruleMatchPlaceholder: '如 flash / glm(忽略大小写,留空则不参与匹配)',\r\n ruleEnabled: '启用',\r\n ruleUp: '上移', ruleDown: '下移', ruleRemove: '删除规则',\r\n ruleNoImage: '尚未选择图片',\r\n rulePickImage: '选择图片', ruleChangeImage: '更换图片',\r\n ruleFromUrl: '从网址', ruleUrlPlaceholder: '粘贴图片网址 https://…',\r\n ruleUrlApply: '应用', ruleUrlCancel: '取消', ruleUrlApplying: '加载中…',\r\n ruleUrlBadHttp: '仅支持 http/https 图片网址', ruleUrlFail: '获取图片失败',\r\n ruleImageRemove: '移除图片',\r\n ruleEmptyHint: '这条规则还没有图片,不会被匹配到,也不会作为兜底',\r\n ruleColor: '主题色',\r\n ruleColorNone: '系统主题',\r\n ruleColorNoneHint: '未设颜色时跟随系统主题:界面用宿主的配色,壁纸与各部位的透明度、模糊照旧生效',\r\n // Shown where a rule has NO color yet: pressing it picks a color, which is the\r\n // opposite of what the button above does, so it must not borrow that label.\r\n ruleColorPick: '自定义颜色',\r\n ruleColorPickHint: '优先从本图取色,取不到就用默认色',\r\n ruleColorExtract: '从本图提取',\r\n ruleLayout: '布局模式',\r\n ruleFraming: '取景',\r\n ruleFramingEdit: '编辑位置',\r\n ruleFramingLocked: '仅「适应」模式可编辑位置',\r\n ruleOpacity: '背景透明度',\r\n ruleBlur: '背景模糊',\r\n ruleBlurHint: '背景模糊作用于壁纸层;界面页里的模糊作用于界面各区域,两者互不影响',\r\n\r\n colorHint: '在色轮外圈选择色相,在内部方形中调整饱和度和明度;双击滑块可恢复默认值',\r\n swatchTitle: '灵感色板',\r\n hexCaption: '当前颜色',\r\n\r\n bgModeFit: '适应', bgModeFill: '填充', bgModeStretch: '拉伸', bgModeTile: '平铺', bgModeCenter: '居中',\r\n editorTitle: '背景编辑器', editorHint: '拖动移动画面,滚轮缩放大小',\r\n editorCommit: '确认', editorCancel: '取消', editorReset: '重置',\r\n\r\n extractColor: '从图片提取主题色', extracting: '取色中…',\r\n extractNoWp: '请先为该规则选择图片',\r\n extractDone: '已应用图片配色',\r\n extractFail: '未在这张图里找到鲜明的颜色,请换一张',\r\n eyedropper: '从图片取色',\r\n pickerTitle: '从图片取色',\r\n pickerHint: '移动鼠标预览颜色,点击图片选取为主题色',\r\n pickerClose: '关闭',\r\n\r\n crashTitle: '界面渲染出错',\r\n crashDesc: '设置面板遇到问题,点击下方按钮重置后重试',\r\n crashReset: '重置面板',\r\n\r\n exportTheme: '导出配置', importTheme: '导入配置',\r\n exportCardTitle: '导出配置',\r\n exportCardDesc: '把全部规则、每条规则的颜色/布局/透明度/模糊与图片打包为 dsh-background-by-model-theme.json',\r\n importCardTitle: '导入配置',\r\n importCardDesc: '从之前导出的 JSON 文件一键恢复全部规则(会覆盖当前规则与图片)',\r\n toastExportDone: '配置文件已开始下载',\r\n importDone: '已导入配置',\r\n importFail: '导入失败,文件格式不正确',\r\n footerTag: '按模型换背景插件',\r\n}\r\n\r\nexport const en: Record<string, string> = {\r\n nav: 'Model background', brandTag: 'Per-model wallpaper', close: 'Close',\r\n pageInterface: 'Interface', pageModelBg: 'Model background', pageProfile: 'Profile',\r\n descInterface: 'Tune opacity and blur per surface to build depth. These settings are global and apply to every model',\r\n descModelBg: 'Each rule is a match string plus one look. On a model switch the list is scanned top-down for the first match string contained in the model name; if nothing hits, rule 1 is used',\r\n descProfile: 'Back up every rule together with its image, or restore one from a file',\r\n\r\n uiTitle: 'Interface',\r\n uiOpacity: 'Opacity', uiBlur: 'Blur',\r\n uiOpacityBg: 'Main background', uiOpacitySide: 'Left panel', uiOpacityCard: 'Cards & menus', uiOpacityInput: 'Input & controls',\r\n uiSop: 'Settings interface opacity', uiChatRegion: 'Conversation text frame', uiTrajectory: 'Trajectory view',\r\n uiPreview: 'Right panel',\r\n\r\n // Only the diagnostics survive: the model/rule readout they used to sit under\r\n // is gone (the match tester at the top of the page answers the same question).\r\n statusUnknownHint: 'Without a detected model rule 1 is always used; switching the model once or waiting a moment retries automatically',\r\n statusSourceDefaultHint: 'Only the host-wide default model could be read — that is not necessarily this session\\'s selection. It self-corrects once this session\\'s model selection is available.',\r\n statusNoteNoService: 'The sessions service is not available yet (the session controller loads after this plugin); retrying automatically',\r\n statusNoteNoSession: 'The sessions service is up but reports no current session yet',\r\n statusNoteNoProjection: 'This session\\'s model-selection projection is unreachable (no binding / projections)',\r\n statusNoteEmptySelection: 'The model-selection projection exists but carries no value yet (selecting a model once writes it)',\r\n\r\n rulesTitle: 'Rules',\r\n rulesHint: 'Top to bottom is the priority. Rule 1 doubles as the fallback — it is used when no match string hits',\r\n tryoutTitle: 'Match test',\r\n tryoutPlaceholder: 'Type a model name, e.g. deepseek-flash',\r\n tryoutUseCurrent: 'Use current model',\r\n tryoutHit: 'matches rule',\r\n tryoutFallback: 'no match · fallback rule',\r\n tryoutNone: 'No usable rule (a rule needs to be enabled and have an image)',\r\n tryoutEmpty: 'Type a model name to test the list',\r\n autoExtract: 'Extract the theme color when an image is chosen',\r\n autoExtractHint: 'Only fills a rule that has no color yet — a color you picked is never overwritten',\r\n ruleAdd: 'Add rule',\r\n ruleFallbackBadge: 'fallback',\r\n ruleMatchLabel: 'Match',\r\n ruleMatchPlaceholder: 'e.g. flash / glm (case-insensitive, empty never matches)',\r\n ruleEnabled: 'Enabled',\r\n ruleUp: 'Move up', ruleDown: 'Move down', ruleRemove: 'Remove rule',\r\n ruleNoImage: 'No image yet',\r\n rulePickImage: 'Choose image', ruleChangeImage: 'Replace image',\r\n ruleFromUrl: 'From URL', ruleUrlPlaceholder: 'Paste an image URL https://…',\r\n ruleUrlApply: 'Apply', ruleUrlCancel: 'Cancel', ruleUrlApplying: 'Loading…',\r\n ruleUrlBadHttp: 'Only http/https image URLs are supported', ruleUrlFail: 'Could not fetch the image',\r\n ruleImageRemove: 'Remove image',\r\n ruleEmptyHint: 'This rule has no image — it can neither match nor serve as the fallback',\r\n ruleColor: 'Theme color',\r\n ruleColorNone: 'System theme',\r\n ruleColorNoneHint: 'Without a color this rule follows the system theme: the host palette paints the interface while the wallpaper and every opacity/blur slider keep working',\r\n // Shown where a rule has NO color yet: pressing it picks a color, which is the\r\n // opposite of what the button above does, so it must not borrow that label.\r\n ruleColorPick: 'Custom color',\r\n ruleColorPickHint: 'Extracts from this image when it can, otherwise uses a default color',\r\n ruleColorExtract: 'Extract from image',\r\n ruleLayout: 'Layout mode',\r\n ruleFraming: 'Framing',\r\n ruleFramingEdit: 'Edit position',\r\n ruleFramingLocked: 'Position editing is only available in Fit mode',\r\n ruleOpacity: 'Background opacity',\r\n ruleBlur: 'Background blur',\r\n ruleBlurHint: 'Background blur affects the wallpaper layer; the blur on the Interface page affects interface surfaces — they are independent',\r\n\r\n colorHint: 'Pick hue on the outer ring, adjust saturation & lightness in the square; double-click a slider to reset',\r\n swatchTitle: 'Quick swatches',\r\n hexCaption: 'Current color',\r\n\r\n bgModeFit: 'Fit', bgModeFill: 'Fill', bgModeStretch: 'Stretch', bgModeTile: 'Tile', bgModeCenter: 'Center',\r\n editorTitle: 'Background editor', editorHint: 'Drag to move, scroll to zoom',\r\n editorCommit: 'Confirm', editorCancel: 'Cancel', editorReset: 'Reset',\r\n\r\n extractColor: 'Extract from image', extracting: 'Extracting…',\r\n extractNoWp: 'Choose an image for this rule first',\r\n extractDone: 'Image colors applied',\r\n extractFail: 'No vivid color found in this image, try another',\r\n eyedropper: 'Eyedropper',\r\n pickerTitle: 'Pick from image',\r\n pickerHint: 'Hover to preview, click to pick as the theme color',\r\n pickerClose: 'Close',\r\n\r\n crashTitle: 'Section crashed',\r\n crashDesc: 'The panel hit an error. Reset below to recover.',\r\n crashReset: 'Reset panel',\r\n\r\n exportTheme: 'Export', importTheme: 'Import',\r\n exportCardTitle: 'Export profile',\r\n exportCardDesc: 'Bundle every rule — color, layout, opacity, blur — and its image into dsh-background-by-model-theme.json',\r\n importCardTitle: 'Import profile',\r\n importCardDesc: 'Restore every rule and image from a previously exported JSON file (replaces the current set)',\r\n toastExportDone: 'Export started',\r\n importDone: 'Profile imported',\r\n importFail: 'Import failed — invalid file',\r\n footerTag: 'Per-model wallpaper plugin',\r\n}\r\n","/**\n * The persisted configuration shape — declared exactly ONCE, for both halves.\n *\n * This shape used to be written out twice: the node half owns persistence and\n * sanitizes every write, the browser half owns the UI and its own reading of the\n * same file. A field added to only one side was silently dropped by the other\n * side's sanitizer — the matching slider stayed live in memory, `writeConfig`\n * wrote a config without it, and the next load fell back to the default.\n * `blurs.rightbar` / `rightbarOpacity` in 0.3.2 was exactly that bug, and the key\n * lists were duplicated 6 times across the two halves, so it was due to happen.\n *\n * The types, the key lists, the defaults and the pure normalizers therefore live\n * here and both halves import them: adding a field means editing this file, and\n * the two halves cannot disagree about the shape. The host additionally logs one\n * warning per unknown key while sanitizing a write (see `warnUnknownConfigKeys`\n * in `src/index.ts`), so a field that reaches the node half without being\n * declared here shows up in the host log instead of quietly disappearing.\n *\n * Nothing in this module may touch the DOM, Node or the Cordis context: it is\n * imported by the browser bundle and by the node half alike.\n */\n\n/** Placement state of one background image (zoom + fractional center + intrinsic size). */\nexport interface BgState { zoom: number; x: number; y: number; iw: number; ih: number }\n\nexport const DEFAULT_BG_STATE: BgState = { zoom: 1, x: 0, y: 0, iw: 0, ih: 0 }\n\n/** Adaptive placement of a background image. */\nexport type BgMode = 'fit' | 'fill' | 'stretch' | 'tile' | 'center'\n\n/** Every accepted `bgMode`, in UI order. */\nexport const BG_MODES: readonly BgMode[] = ['fit', 'fill', 'stretch', 'tile', 'center']\n\n/**\n * Main interface opacities (0..1), global (Interface page):\n * `bg` main background (`--dsw-alias-bg-base`)\n * `sidebar` sidebar (`--dsw-specific-sidebar-fill`)\n * `card` cards/panels (`--dsw-alias-bg-layer-1/2/3`, `--dsw-specific-menu`\n * and its 0.1.7 alias `--dsw-menu-surface-fill`)\n * `input` input/control surfaces (`--dsw-specific-input-major`)\n */\nexport const PART_OPACITY_KEYS = ['bg', 'sidebar', 'card', 'input'] as const\n\n/** Per-part main interface opacities (0..1), keyed BY the list above. */\nexport type PartOpacities = Record<(typeof PART_OPACITY_KEYS)[number], number>\n\nexport const DEFAULT_PART_OPACITIES: PartOpacities = { bg: 0.85, sidebar: 0.93, card: 1, input: 1 }\n\n/**\n * Interface blur (px, 0..60), global (Interface page):\n * `bg` main background (AppFrame grid)\n * `sidebar` sidebar column\n * `card` cards/panels (center + details columns, dialog option panels)\n * `settings` settings panel\n * `chat` conversation text region (message column of the chat view)\n * `trajectory` trajectory view surface\n * `rightbar` file-preview panel — the right sidebar a file click opens\n * `input` input/control surfaces ([data-composer-card], [data-cordis-panel])\n */\nexport const PART_BLUR_KEYS = ['bg', 'sidebar', 'card', 'settings', 'chat', 'trajectory', 'rightbar', 'input'] as const\n\n/** Per-part interface blur (px, 0..60), keyed BY the list above. */\nexport type PartBlurs = Record<(typeof PART_BLUR_KEYS)[number], number>\n\nexport const DEFAULT_PART_BLURS: PartBlurs = {\n bg: 0, sidebar: 0, card: 0, settings: 0, chat: 0, trajectory: 0, rightbar: 0, input: 0,\n}\n\n/**\n * One model rule: a match string plus everything the background needs while it\n * is the active rule. Every appearance field lives HERE rather than globally —\n * the settings UI edits a rule, and the render layer follows whichever rule the\n * current model selected.\n */\nexport interface BgRule {\n /** Stable id; also the render key. */\n id: string\n /**\n * Case-insensitive substring tested against the current model text (provider,\n * model id and display name joined with spaces). An EMPTY string never matches\n * on its own — that rule then only ever serves as the fallback.\n */\n match: string\n /** Image slot; the bytes live in `modelbg-<slot>` under the data dir. */\n slot: string\n /** Disabled rules are skipped by matching AND by the fallback pick. */\n enabled: boolean\n /** Saved HSL theme color of this rule; null = use the system theme. */\n color: [number, number, number] | null\n bgMode: BgMode\n /** Wallpaper layer opacity (0..1). */\n wallpaperOpacity: number\n /** Wallpaper layer blur (px, 0..60) — NOT the interface part blur. */\n blur: number\n /** Image framing (zoom + fractional center + intrinsic size). */\n bgState: BgState\n}\n\n/** The persisted plugin configuration. */\nexport interface ThemeConfig {\n /** Ordered rules: matching runs top→bottom, rule 1 doubles as the fallback. */\n rules: BgRule[]\n /** Global per-part opacities (Interface page). */\n opacities: PartOpacities\n /** Global per-part blur (Interface page). */\n blurs: PartBlurs\n /** Settings-panel opacity (0..1). */\n settingsOpacity: number\n /** Translucent tint over the conversation text region (0 = none, 1 = solid). */\n chatTextOpacity: number\n /** Translucent tint over the trajectory view surface (0 = none, 1 = solid). */\n trajectoryOpacity: number\n /**\n * Surface opacity of the file-preview panel (0..1). `null` = never touched, so\n * the panel keeps following `opacities.bg`: the panel's only surface IS\n * `--dsw-alias-bg-base`, which the main-background slider already re-emits, so\n * an untouched card must stay indistinguishable from the interface behind it.\n */\n rightbarOpacity: number | null\n /**\n * Extract a rule's theme color from its own image when the rule has none yet.\n * Only ever FILLS an empty color — a color the user picked or that an earlier\n * extraction produced is never overwritten, so this cannot fight the user.\n */\n autoExtract: boolean\n}\n\n/** 100% = untouched host surface; zero would blank the page by default. */\nexport const DEFAULT_SETTINGS_OPACITY = 1\nexport const DEFAULT_CHAT_TEXT_OPACITY = 0\n/** 100% = untouched host surface; zero would blank the page by default. */\nexport const DEFAULT_TRAJECTORY_OPACITY = 1\n/** `null` = the file-preview panel still follows the main background. */\nexport const DEFAULT_RIGHTBAR_OPACITY: number | null = null\n/** Picking an image should just work; the toggle is there for people who don't want it. */\nexport const DEFAULT_AUTO_EXTRACT = true\n\n/** A default config with independent nested objects (never hand out the shared ones). */\nexport function freshThemeConfig(): ThemeConfig {\n return {\n rules: [],\n opacities: { ...DEFAULT_PART_OPACITIES },\n blurs: { ...DEFAULT_PART_BLURS },\n settingsOpacity: DEFAULT_SETTINGS_OPACITY,\n chatTextOpacity: DEFAULT_CHAT_TEXT_OPACITY,\n trajectoryOpacity: DEFAULT_TRAJECTORY_OPACITY,\n rightbarOpacity: DEFAULT_RIGHTBAR_OPACITY,\n autoExtract: DEFAULT_AUTO_EXTRACT,\n }\n}\n\n// ── Sanitizers ─────────────────────────────────────────────────────────────\n// Pure coercions from a possibly-old / possibly-hand-edited JSON value into the\n// shape above. Both halves run THESE, so a clamp can never differ between what\n// the UI shows and what lands on disk.\n\n/** Slot names reach the filesystem, so they are strictly whitelisted. */\nexport const SLOT_RE = /^[A-Za-z0-9_-]{1,32}$/\n\nexport function clamp(n: unknown, lo: number, hi: number, def: number): number {\n return typeof n === 'number' && isFinite(n) ? Math.min(hi, Math.max(lo, n)) : def\n}\n\nexport const clamp01 = (n: unknown, def: number): number => clamp(n, 0, 1, def)\n\nexport function normalizeBgState(s: Partial<BgState> | undefined): BgState {\n const v = s ?? {}\n return {\n zoom: clamp(v.zoom, 0.1, 10, 1),\n x: typeof v.x === 'number' && isFinite(v.x) ? v.x : 0,\n y: typeof v.y === 'number' && isFinite(v.y) ? v.y : 0,\n iw: typeof v.iw === 'number' && v.iw > 0 ? v.iw : 0,\n ih: typeof v.ih === 'number' && v.ih > 0 ? v.ih : 0,\n }\n}\n\n/** One `[h, s, l]` triple, or null when the value is not a complete finite triple. */\nexport function normalizeHsl(raw: unknown): [number, number, number] | null {\n if (!Array.isArray(raw) || raw.length !== 3) return null\n if (!raw.every(n => typeof n === 'number' && isFinite(n))) return null\n return [clamp(raw[0], 0, 360, 220), clamp(raw[1], 0, 1, 0.55), clamp(raw[2], 0, 1, 0.25)]\n}\n\n/** Coerce one persisted rule, or null when it lacks a usable id/slot. */\nexport function normalizeRule(raw: unknown): BgRule | null {\n const r = (raw ?? {}) as Partial<BgRule>\n const id = typeof r.id === 'string' && r.id !== '' ? r.id : null\n const slot = typeof r.slot === 'string' && SLOT_RE.test(r.slot) ? r.slot : null\n if (id === null || slot === null) return null\n const mode: BgMode = BG_MODES.includes(r.bgMode as BgMode) ? (r.bgMode as BgMode) : 'fit'\n return {\n id,\n slot,\n match: typeof r.match === 'string' ? r.match : '',\n enabled: r.enabled !== false,\n color: normalizeHsl(r.color),\n bgMode: mode,\n wallpaperOpacity: clamp01(r.wallpaperOpacity, 1),\n blur: clamp(r.blur, 0, 60, 0),\n bgState: normalizeBgState(r.bgState as Partial<BgState> | undefined),\n }\n}\n\n/** Coerce an unknown persisted value into a valid ThemeConfig, falling back per-field. */\nexport function normalizeConfig(raw: unknown): ThemeConfig {\n const r = (raw ?? {}) as Partial<ThemeConfig>\n const rules = Array.isArray(r.rules)\n ? r.rules.map(normalizeRule).filter((x): x is BgRule => x !== null)\n : []\n const ops = (r.opacities ?? {}) as Partial<PartOpacities>\n const bl = (r.blurs ?? {}) as Partial<PartBlurs>\n const blurs = {} as PartBlurs\n for (const k of PART_BLUR_KEYS) {\n blurs[k] = clamp(bl[k], 0, 60, DEFAULT_PART_BLURS[k])\n }\n const opacities = {} as PartOpacities\n for (const k of PART_OPACITY_KEYS) {\n opacities[k] = clamp01(ops[k], DEFAULT_PART_OPACITIES[k])\n }\n return {\n rules,\n opacities,\n blurs,\n settingsOpacity: clamp01(r.settingsOpacity, DEFAULT_SETTINGS_OPACITY),\n chatTextOpacity: clamp01(r.chatTextOpacity, DEFAULT_CHAT_TEXT_OPACITY),\n trajectoryOpacity: clamp01(r.trajectoryOpacity, DEFAULT_TRAJECTORY_OPACITY),\n // Anything but a real number means \"not owned yet\" — including the absent\n // field of a config written before this option existed.\n rightbarOpacity: typeof r.rightbarOpacity === 'number' && isFinite(r.rightbarOpacity)\n ? clamp01(r.rightbarOpacity, 1)\n : DEFAULT_RIGHTBAR_OPACITY,\n // Only an explicit `false` turns it off, so a config written before this\n // option existed starts with the helpful default.\n autoExtract: r.autoExtract !== false,\n }\n}\n","import type { BgRule, BgState, BgMode, ThemeConfig, PartOpacities, PartBlurs } from './types'\n// The persisted shape, its key lists, its defaults and its sanitizers all live in\n// ../schema, shared verbatim with the node half — a field declared on one side\n// only used to be silently dropped by the other side's sanitizer.\nimport {\n DEFAULT_BG_STATE, DEFAULT_CHAT_TEXT_OPACITY, DEFAULT_PART_BLURS, DEFAULT_PART_OPACITIES,\n DEFAULT_SETTINGS_OPACITY, DEFAULT_TRAJECTORY_OPACITY, PART_BLUR_KEYS, PART_OPACITY_KEYS,\n clamp, clamp01, freshThemeConfig, normalizeConfig, normalizeRule,\n} from '../schema'\n\nexport { DEFAULT_BG_STATE, normalizeRule }\n\nconst PALETTE: Array<[number, number, number]> = [\n [356, 0.72, 0.55], [24, 0.78, 0.55], [44, 0.8, 0.55], [152, 0.62, 0.5],\n [174, 0.68, 0.48], [208, 0.72, 0.55], [252, 0.68, 0.6], [300, 0.64, 0.58],\n]\nexport { PALETTE }\n\n/** The defaults every accessor falls back to; the shape itself lives in ../schema. */\nexport const DEFAULT_CONFIG: ThemeConfig = freshThemeConfig()\n\n// In-memory mirror of the file-backed store; the UI reads and mutates this and\n// it is synced to disk via the RPC layer.\nexport let cfg: ThemeConfig = freshThemeConfig()\n\n// ── Image cache (slot → data URL) ──────────────────────────────────────────\n// Rule images are fetched lazily per slot; only the active rule's bytes are\n// needed to paint, the rest are loaded when their card is expanded.\n//\n// Two URLs are kept per slot: the DATA URL is what gets persisted and embedded\n// in an export, while the DISPLAY URL is an object URL derived from it. Painting\n// goes through the display URL because `background-image: url(data:…)` is\n// re-decoded on every assignment — a visible stall on every model switch for a\n// multi-megabyte wallpaper — whereas a blob URL is served from the browser's\n// memory cache after the first load.\nconst images = new Map<string, string>()\nconst displayUrls = new Map<string, string>()\n\nfunction revokeDisplay(slot: string): void {\n const url = displayUrls.get(slot)\n if (url === undefined) return\n displayUrls.delete(slot)\n // Deferred on purpose: the wallpaper layer may still be painting this URL\n // while the replacement fades in over it, and revoking it mid-fade would blank\n // the wallpaper behind the incoming image for a frame.\n window.setTimeout(() => {\n try { URL.revokeObjectURL(url) } catch { /* not a live object URL (e.g. fallback) */ }\n }, 2000)\n}\n\nexport function setImage(slot: string, url: string | null): void {\n revokeDisplay(slot)\n if (url === null) images.delete(slot)\n else images.set(slot, url)\n}\n/** Persisted data URL (RPC / export). Use `displayImageOf` to paint it. */\nexport function imageOf(slot: string): string | null { return images.get(slot) ?? null }\n\n/** Paintable URL for one slot, created on first use and cached; falls back to\n * the data URL when no object URL can be built. */\nexport function displayImageOf(slot: string): string | null {\n const cached = displayUrls.get(slot)\n if (cached !== undefined) return cached\n const data = images.get(slot)\n if (data === undefined) return null\n const made = toObjectUrl(data)\n if (made === null) return data\n displayUrls.set(slot, made)\n return made\n}\n\nfunction toObjectUrl(dataUrl: string): string | null {\n try {\n if (typeof URL === 'undefined' || typeof URL.createObjectURL !== 'function') return null\n const comma = dataUrl.indexOf(',')\n if (comma < 0) return null\n const meta = dataUrl.slice(0, comma)\n if (!/;base64$/i.test(meta)) return null\n const mime = meta.slice(5, -7) || 'image/jpeg'\n const bin = atob(dataUrl.slice(comma + 1))\n const bytes = new Uint8Array(bin.length)\n for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i)\n return URL.createObjectURL(new Blob([bytes], { type: mime }))\n } catch {\n return null\n }\n}\n\nexport function clearImages(): void {\n for (const slot of Array.from(displayUrls.keys())) revokeDisplay(slot)\n images.clear()\n}\n\n// ── Active rule (what the render layer follows) ────────────────────────────\nexport let activeRuleId: string | null = null\nexport let activeMatched = false\nexport let modelLabel = ''\n\nexport function setActive(ruleId: string | null, matched: boolean): void {\n activeRuleId = ruleId\n activeMatched = matched\n}\nexport function setModelLabel(label: string): void { modelLabel = label }\n\nexport function ruleById(id: string): BgRule | null {\n return cfg.rules.find(r => r.id === id) ?? null\n}\nexport function activeRule(): BgRule | null {\n return activeRuleId === null ? null : ruleById(activeRuleId)\n}\n\n// ── Rule factories / allocation ────────────────────────────────────────────\nexport function newRule(id: string, slot: string): BgRule {\n return {\n id, slot, match: '', enabled: true, color: null,\n bgMode: 'fit', wallpaperOpacity: 1, blur: 0,\n bgState: { ...DEFAULT_BG_STATE },\n }\n}\n\n/** First free image slot (`m1`, `m2`, …). */\nexport function nextSlot(): string {\n const taken = new Set(cfg.rules.map(r => r.slot))\n for (let i = 1; i < 1000; i++) {\n const slot = `m${i}`\n if (!taken.has(slot)) return slot\n }\n return `m${Date.now()}`\n}\n\n/** Unique rule id (independent from the slot so removals never renumber). */\nexport function nextRuleId(): string {\n const taken = new Set(cfg.rules.map(r => r.id))\n for (let i = 1; i < 10000; i++) {\n const id = `r${i}`\n if (!taken.has(id)) return id\n }\n return `r${Date.now()}`\n}\n\n// ── Accessors used by the render layer (they follow the ACTIVE rule) ───────\nexport function rHasColor(): boolean { return activeRule()?.color !== null && activeRule() !== null }\nexport function rColor(): [number, number, number] { return activeRule()?.color ?? [220, 0.55, 0.25] }\nexport function rBgMode(): BgMode { return activeRule()?.bgMode ?? 'fit' }\nexport function rWop(): number { return clamp01(activeRule()?.wallpaperOpacity, 1) }\nexport function rBl(): number { return clamp(activeRule()?.blur, 0, 60, 0) }\nexport function rBgState(): BgState { return activeRule()?.bgState ?? DEFAULT_BG_STATE }\n/** Paintable URL of the active rule's image, or null when it has none. */\nexport function rWp(): string | null {\n const rule = activeRule()\n return rule === null ? null : displayImageOf(rule.slot)\n}\nexport function rOps(): PartOpacities {\n const o = cfg.opacities ?? {}\n const out = {} as PartOpacities\n for (const k of PART_OPACITY_KEYS) {\n out[k] = clamp01(o[k], DEFAULT_PART_OPACITIES[k])\n }\n return out\n}\nexport function rBlurs(): PartBlurs {\n const b = cfg.blurs ?? {}\n const out = {} as PartBlurs\n for (const k of PART_BLUR_KEYS) {\n out[k] = clamp(b[k], 0, 60, DEFAULT_PART_BLURS[k])\n }\n return out\n}\nexport function rSop(): number { return clamp01(cfg.settingsOpacity, DEFAULT_SETTINGS_OPACITY) }\nexport function rChatTextOpacity(): number { return clamp01(cfg.chatTextOpacity, DEFAULT_CHAT_TEXT_OPACITY) }\nexport function rTrajectoryOpacity(): number { return clamp01(cfg.trajectoryOpacity, DEFAULT_TRAJECTORY_OPACITY) }\n/** Own opacity of the file-preview panel; while unowned it IS the main background's. */\nexport function rRightbarOpacity(): number {\n const own = cfg.rightbarOpacity\n return typeof own === 'number' && isFinite(own) ? clamp01(own, 1) : rOps().bg\n}\n\n// ── Normalization ──────────────────────────────────────────────────────────\n// The sanitizers are the shared ones from ../schema (the same code the node half\n// runs before writing to disk), so what the UI shows and what is persisted can\n// never be clamped differently.\n\n/** Move a possibly-absent partial config into the shape the UI reads. */\nexport function adoptConfig(raw: unknown): void {\n cfg = normalizeConfig(raw)\n // A rule that vanished (import/removal) must not stay active.\n if (activeRuleId !== null && !cfg.rules.some(r => r.id === activeRuleId)) {\n activeRuleId = null\n activeMatched = false\n }\n}\n\nexport function resetConfig(): void {\n cfg = freshThemeConfig()\n clearImages()\n activeRuleId = null\n activeMatched = false\n modelLabel = ''\n}\n","import type { FetchResult, RpcResultLike } from './types'\nimport { cfg } from './state'\n\nexport const RPC_CHANNEL = '/dsh-background-by-model'\nconst RPC_NS = 'dshBackgroundByModel'\nconst rpcEndpoint = (method: string): string => `${RPC_NS}/${method}`\n\nlet rpcCallFn: ((endpoint: string, payload: unknown) => Promise<RpcResultLike | undefined>) | null = null\n\nexport function initRpc(call: (endpoint: string, payload: unknown) => Promise<RpcResultLike | undefined>): void {\n rpcCallFn = call\n}\n\nasync function rpcCall(method: string, payload: unknown): Promise<unknown> {\n if (!rpcCallFn) return undefined\n try {\n const res = await rpcCallFn(rpcEndpoint(method), payload)\n if (res && res.ok === true) return res.value\n console.warn(`dsh-background-by-model: rpc \"${method}\" failed`, res?.error)\n return undefined\n } catch (e) {\n console.warn(`dsh-background-by-model: rpc \"${method}\" threw`, e)\n return undefined\n }\n}\n\n/** Raw call for the few places that need the host's error message. */\nasync function rpcRaw(method: string, payload: unknown): Promise<RpcResultLike | undefined> {\n if (!rpcCallFn) return undefined\n try {\n return await rpcCallFn(rpcEndpoint(method), payload)\n } catch {\n return undefined\n }\n}\n\n// Slider drags fire dozens of events per second; coalesce writes to a trailing\n// debounce and flush the last pending write on pagehide so a quick close never\n// loses it.\nconst SAVE_DEBOUNCE_MS = 250\nlet saveTimer: number | undefined\n\nexport function saveConfig(): void {\n if (saveTimer !== undefined) window.clearTimeout(saveTimer)\n saveTimer = window.setTimeout(() => {\n saveTimer = undefined\n void rpcCall('writeConfig', { config: cfg })\n }, SAVE_DEBOUNCE_MS)\n}\n\nexport function flushSave(): void {\n if (saveTimer === undefined) return\n window.clearTimeout(saveTimer)\n saveTimer = undefined\n void rpcCall('writeConfig', { config: cfg })\n}\n\n/** Persist the current config immediately (no debounce). */\nexport function persistConfig(): void {\n void rpcCall('writeConfig', { config: cfg })\n}\n\nexport interface Persisted { config: unknown; slots: string[] }\n\n/** Load the persisted config plus the list of stored image slots. */\nexport async function loadPersisted(): Promise<Persisted | null> {\n const data = await rpcCall('read', {})\n if (data === null || typeof data !== 'object') return null\n const d = data as { config?: unknown; slots?: unknown }\n const slots = Array.isArray(d.slots) ? d.slots.filter((s): s is string => typeof s === 'string') : []\n return { config: d.config, slots }\n}\n\n/** Read one rule image as a data URL (null when the slot is empty). */\nexport async function readImage(slot: string): Promise<string | null> {\n const data = await rpcCall('readImage', { slot })\n if (data === null || typeof data !== 'object') return null\n const url = (data as { dataUrl?: unknown }).dataUrl\n return typeof url === 'string' ? url : null\n}\n\n/** Persist (or clear) one rule image; one-shot, no debounce. */\nexport async function writeImage(slot: string, dataUrl: string | null): Promise<boolean> {\n const res = await rpcCall('writeImage', { slot, dataUrl })\n return res === true\n}\n\n/** Remove one rule image from disk. */\nexport async function deleteImage(slot: string): Promise<boolean> {\n const res = await rpcCall('deleteImage', { slot })\n return res === true\n}\n\n/** Download an image from a network URL into one slot, replacing its bytes. */\nexport async function fetchImageUrl(slot: string, url: string): Promise<FetchResult> {\n const res = await rpcRaw('fetchImageUrl', { slot, url })\n if (!res) return { ok: false, error: 'no response' }\n if (res.ok !== true) {\n const err = (res as { error?: { message?: string } }).error\n return { ok: false, error: err?.message ?? 'request failed' }\n }\n const v = res.value as FetchResult | undefined\n return v?.ok === true\n ? { ok: true, dataUrl: v.dataUrl ?? null }\n : { ok: false, error: v?.error ?? 'failed' }\n}\n\n/** Host default model — used only when the per-session services are absent. */\nexport async function readDefaultModel(): Promise<string | null> {\n const data = await rpcCall('defaultModel', {})\n if (data === null || typeof data !== 'object') return null\n const d = data as { provider?: unknown; model?: unknown }\n const parts = [d.provider, d.model].filter((s): s is string => typeof s === 'string' && s !== '')\n return parts.length > 0 ? parts.join(' ') : null\n}\n","import type { BgState, ColorPalette } from '../types'\r\n\r\n// The wheel works in HSV end to end; storage and genTokens expect HSL, so\r\n// setColor converts HSV → HSL at the boundary and sectionInject converts the\r\n// stored HSL → HSV for the initial wheel props. Conversions never stack.\r\n\r\nexport function hsvToHsl(h: number, s: number, v: number): [number, number, number] {\r\n const l = v * (1 - s / 2)\r\n const sl = l === 0 || l === 1 ? 0 : (v - l) / Math.min(l, 1 - l)\r\n return [h, sl, l]\r\n}\r\n\r\nexport function hslToHsv(h: number, s: number, l: number): [number, number, number] {\r\n const v = l + s * Math.min(l, 1 - l)\r\n const sv = v === 0 ? 0 : 2 * (1 - l / v)\r\n return [h, sv, v]\r\n}\r\n\r\nlet tokensCacheKey = ''\r\nlet tokensCache: { colorScheme: 'light' | 'dark'; tokens: Record<string, string> } | null = null\r\n\r\n/**\r\n * Memoized token generation: the same (hue, sat, lit) input always yields the\r\n * same token set, and applyWp / applyCustomTokens / applySettingsOverrides call\r\n * this repeatedly (slider drags, viewport re-applies), so cache the last result\r\n * and skip the 30+ hsl() string builds when nothing changed.\r\n */\r\nexport function genTokens(hue: number, sat: number, lit: number): { colorScheme: 'light' | 'dark'; tokens: Record<string, string> } {\r\n const key = `${hue}|${sat}|${lit}`\r\n if (tokensCacheKey === key && tokensCache) return tokensCache\r\n tokensCacheKey = key\r\n tokensCache = buildTokens(hue, sat, lit)\r\n return tokensCache\r\n}\r\n\r\nfunction buildTokens(hue: number, sat: number, lit: number): { colorScheme: 'light' | 'dark'; tokens: Record<string, string> } {\r\n const dark = lit < 0.55\r\n const h = (d: number) => ((hue + d) % 360 + 360) % 360\r\n const s = (d: number) => Math.max(0, Math.min(1, sat + d))\r\n const l = (d: number) => Math.max(0, Math.min(1, lit + d))\r\n const hsl = (hh: number, ss: number, ll: number) => `hsl(${Math.round(hh)},${Math.round(ss * 100)}%,${Math.round(ll * 100)}%)`\r\n const rgba = (hh: number, ss: number, ll: number, a: number) =>\r\n `hsla(${Math.round(hh)},${Math.round(ss * 100)}%,${Math.round(ll * 100)}%,${a})`\r\n // Ink for anything painted ON the brand fill. One verdict feeds both\r\n // spellings of it: brand-text (which the host defines but never uses) and\r\n // label-primary-foreground, which the HOST's own primary buttons label\r\n // themselves with on --dsw-alias-button-primary-fill — the same color as\r\n // --dsw-alias-brand-primary below. It has to flip with the fill: the dark\r\n // branch deliberately keeps that fill at 50%+ lightness, so a hard-coded white\r\n // label is white on white. The host's own dark scheme is only readable because\r\n // it flips brand-primary AND label-primary-foreground together.\r\n const onBrand = l(0.2) > 0.6 ? '#000' : '#fff'\r\n\r\n if (dark) {\r\n // dsh 0.1.7 splits the menu surface in two: the shared MenuSurface material\r\n // paints `--dsw-menu-surface-fill`, and every other overlay paints\r\n // `--dsw-specific-menu`, which the host aliases to the former\r\n // (`--dsw-specific-menu: var(--dsw-menu-surface-fill)`). Both are generated\r\n // from this one expression so the plugin's override of either can never let\r\n // the pair drift apart — see OPACITY_VARS in wallpaper.ts.\r\n const menuFill = hsl(h(0), s(0), l(0.08))\r\n return {\r\n colorScheme: 'dark',\r\n tokens: {\r\n '--dsw-alias-bg-base': hsl(h(0), s(0), l(-0.04)),\r\n '--dsw-alias-bg-layer-1': hsl(h(0), s(0), l(0.02)),\r\n '--dsw-alias-bg-layer-2': hsl(h(0), s(0), l(0.07)),\r\n '--dsw-alias-bg-layer-3': hsl(h(0), s(-0.05), l(0.12)),\r\n '--dsw-alias-bg-overlay': hsl(h(0), s(-0.05), l(0.12)),\r\n '--dsw-alias-bg-module-platform': hsl(h(0), s(0), l(0.05)),\r\n '--dsw-alias-bg-multi-select': hsl(h(0), s(0), l(0.1)),\r\n '--dsw-alias-bg-skeleton': 'rgba(255,255,255,0.08)',\r\n '--dsw-alias-border-l1': rgba(h(0), s(-0.1), l(0.18), 0.12),\r\n '--dsw-alias-border-l2': rgba(h(0), s(-0.1), l(0.22), 0.22),\r\n '--dsw-alias-border-l3': 'rgba(255,255,255,0.16)',\r\n '--dsw-alias-border-l4': 'rgba(255,255,255,0.2)',\r\n '--dsw-alias-border-inverted': 'rgba(255,255,255,0.06)',\r\n '--dsw-alias-label-primary': hsl(0, 0, 1),\r\n '--dsw-alias-label-secondary': 'rgba(255,255,255,0.85)',\r\n '--dsw-alias-label-tertiary': 'rgba(255,255,255,0.7)',\r\n // Placeholder/dim hint — deliberately weaker than the text tiers so a\r\n // placeholder reads as a hint, never as real input.\r\n '--dsw-alias-label-caption': 'rgba(255,255,255,0.5)',\r\n '--dsw-alias-label-dimmed': 'rgba(255,255,255,0.35)',\r\n '--dsw-alias-label-quaternary': 'rgba(255,255,255,0.25)',\r\n '--dsw-alias-label-primary-dimmed': 'rgba(255,255,255,0.92)',\r\n '--dsw-alias-label-primary-foreground': onBrand,\r\n // Inverted label sits on a light brand/contrast/badge surface in dark\r\n // mode, so it must be dark ink, not white.\r\n '--dsw-alias-label-primary-inverted': hsl(h(0), s(0.08), Math.min(l(0.06), 0.16)),\r\n '--dsw-alias-label-primary-bluish': hsl(0, 0, 1),\r\n '--dsw-alias-brand-primary': hsl(h(0), s(0.1), Math.max(l(0.2), 0.5)),\r\n '--dsw-alias-brand-text': onBrand,\r\n '--dsw-alias-button-primary-fill': hsl(h(0), s(0.1), Math.max(l(0.2), 0.5)),\r\n '--dsw-alias-button-primary-hover': hsl(h(0), s(0.1), Math.max(l(0.28), 0.58)),\r\n '--dsw-alias-button-primary-dimmed': hsl(h(0), s(0), l(0.07)),\r\n '--dsw-alias-button-elevated-fill': hsl(h(0), s(0), l(0.04)),\r\n '--dsw-alias-button-floating-fill': hsl(h(0), s(0), l(0.02)),\r\n '--dsw-alias-button-floating-hover': hsl(h(0), s(0), l(0.1)),\r\n '--dsw-alias-button-tool-bar-fill': 'rgba(255,255,255,0.08)',\r\n '--dsw-alias-button-tool-bar-hover': 'rgba(255,255,255,0.12)',\r\n '--dsw-alias-button-ghost-active-fill': hsl(h(0), s(0), l(0.06)),\r\n '--dsw-alias-button-ghost-active-border': 'rgba(255,255,255,0.16)',\r\n '--dsw-alias-button-ghost-active-hover': hsl(h(0), s(0), l(0.09)),\r\n '--dsw-alias-button-info-fill': '#679efe',\r\n '--dsw-alias-button-info-hover': '#4176e6',\r\n '--dsw-alias-button-contrast-fill': hsl(0, 0, 1),\r\n '--dsw-alias-interactive-bg-hover': rgba(h(0), s(0), Math.max(l(0.15), 0.4), 0.12),\r\n '--dsw-alias-interactive-bg-hover-solid': rgba(h(0), s(0), Math.max(l(0.15), 0.4), 0.16),\r\n '--dsw-alias-interactive-bg-hover-accent': 'rgba(255,255,255,0.24)',\r\n '--dsw-alias-interactive-bg-hover-danger': 'rgba(242,90,90,0.15)',\r\n '--dsw-alias-interactive-bg-active': rgba(h(0), s(0), Math.max(l(0.15), 0.4), 0.2),\r\n '--dsw-alias-markdown-code-block': hsl(h(0), s(0), l(-0.06)),\r\n '--dsw-alias-markdown-code-block-banner': hsl(h(0), s(0), l(-0.02)),\r\n '--dsw-alias-markdown-inline-code': hsl(h(0), s(0), l(0.04)),\r\n '--dsw-alias-markdown-placeholder': hsl(h(0), s(0), l(-0.02)),\r\n '--dsw-alias-markdown-tag': hsl(h(0), s(0), l(0.05)),\r\n '--dsw-alias-markdown-citation': hsl(h(0), s(0), l(0.06)),\r\n '--dsw-alias-markdown-code-segment-selected': hsl(h(0), s(0), l(0.05)),\r\n '--dsw-alias-markdown-code-segment-unselected': hsl(h(0), s(0), l(-0.05)),\r\n '--dsw-alias-state-error-primary': '#ff5c72',\r\n '--dsw-alias-state-error-secondary': '#ff8aa0',\r\n '--dsw-alias-state-success-primary': '#3ddc84',\r\n '--dsw-alias-state-success-secondary': '#69eea4',\r\n // Badge tertiary tokens are the static dark surfaces the UI draws\r\n // over (trajectory tool/context badges, connection pill, plan chip):\r\n // aligning them with the native dark 800/900 steps keeps light fix label\r\n // text readable instead of tint-same-as-background (issue #9).\r\n '--dsw-alias-state-success-tertiary': '#233c2c',\r\n '--dsw-alias-state-warn-primary': '#ffb347',\r\n '--dsw-alias-state-warn-secondary': '#ffc980',\r\n '--dsw-alias-state-warn-tertiary': '#27241f',\r\n '--dsw-alias-state-warn-label': '#dd8629',\r\n '--dsw-alias-state-business-primary': '#679efe',\r\n '--dsw-alias-state-business-tertiary': '#34415b',\r\n '--dsw-specific-sidebar-fill': hsl(h(0), s(0), l(-0.06)),\r\n '--dsw-specific-sidebar-nav-item-active': hsl(h(0), s(0), l(0.04)),\r\n '--dsw-specific-sidebar-nav-item-hover': hsl(h(0), s(0), l(0)),\r\n '--dsw-specific-input-major': hsl(h(0), s(0), l(0.02)),\r\n '--dsw-specific-menu': menuFill,\r\n '--dsw-menu-surface-fill': menuFill,\r\n '--dsw-specific-bubble': hsl(h(0), s(0), l(0.03)),\r\n '--dsw-specific-bubble-highlight': hsl(h(0), s(0), l(0.08)),\r\n '--dsw-specific-selector': hsl(h(0), s(0), l(0.05)),\r\n '--dsw-specific-login-input': hsl(h(0), s(0), l(0.03)),\r\n '--dsw-specific-tip': hsl(h(0), s(0), l(0.05)),\r\n '--dsw-alias-toast-bg': hsl(h(0), s(0), l(0.08)),\r\n '--dsw-alias-tooltip-bg': hsl(h(0), s(0), l(0.08)),\r\n '--dsw-alias-scrollbar-bg-l1': hsl(h(0), s(-0.05), l(0.12)),\r\n '--dsw-alias-scrollbar-bg-l2': hsl(h(0), s(-0.05), l(0.16)),\r\n '--dsw-alias-scrollbar-hover-l1': hsl(h(0), s(-0.05), l(0.22)),\r\n '--dsw-alias-scrollbar-hover-l2': hsl(h(0), s(-0.05), l(0.22)),\r\n },\r\n }\r\n }\r\n // Same one-expression contract as the dark branch above.\r\n const menuFill = hsl(h(0), s(-0.12), l(0.15))\r\n return {\r\n colorScheme: 'light',\r\n tokens: {\r\n '--dsw-alias-bg-base': hsl(h(0), s(-0.08), l(0.03)),\r\n '--dsw-alias-bg-layer-1': hsl(h(0), s(-0.12), l(0.07)),\r\n '--dsw-alias-bg-layer-2': hsl(h(0), s(-0.1), l(-0.03)),\r\n '--dsw-alias-bg-layer-3': hsl(h(0), s(-0.08), l(-0.09)),\r\n '--dsw-alias-bg-overlay': hsl(h(0), s(-0.12), l(0.08)),\r\n '--dsw-alias-border-l1': rgba(h(0), s(-0.15), l(-0.35), 0.18),\r\n '--dsw-alias-border-l2': rgba(h(0), s(-0.15), l(-0.35), 0.3),\r\n '--dsw-alias-label-primary': hsl(0, 0, 0),\r\n '--dsw-alias-label-secondary': 'rgba(0,0,0,0.85)',\r\n '--dsw-alias-label-tertiary': 'rgba(0,0,0,0.7)',\r\n // Placeholder/dim hint — deliberately weaker than the text tiers so a\r\n // placeholder reads as a hint, never as real input.\r\n '--dsw-alias-label-caption': 'rgba(0,0,0,0.5)',\r\n '--dsw-alias-label-dimmed': 'rgba(0,0,0,0.35)',\r\n '--dsw-alias-label-quaternary': 'rgba(0,0,0,0.25)',\r\n // Mirror of the dark branch: this branch always paints its brand fill dark\r\n // (45% lightness or less), so the ink ON it is white. Re-emitted rather\r\n // than inherited so the plugin's own palette owns the pair — the plugin's\r\n // settings UI paints every primary button/chip/tile label from this token.\r\n '--dsw-alias-label-primary-inverted': '#fff',\r\n '--dsw-alias-brand-primary': hsl(h(0), s(0.05), Math.min(l(-0.18), 0.45)),\r\n '--dsw-alias-brand-text': '#fff',\r\n '--dsw-alias-button-primary-hover': hsl(h(0), s(0.05), Math.min(l(-0.12), 0.5)),\r\n '--dsw-alias-button-primary-dimmed': hsl(h(0), s(-0.1), l(-0.03)),\r\n '--dsw-alias-button-elevated-fill': hsl(h(0), s(-0.1), l(0.1)),\r\n '--dsw-alias-button-floating-hover': hsl(h(0), s(-0.1), l(0.16)),\r\n '--dsw-alias-interactive-bg-hover': rgba(h(0), s(0), l(-0.3), 0.08),\r\n '--dsw-alias-interactive-bg-active': rgba(h(0), s(0), l(-0.3), 0.14),\r\n '--dsw-alias-markdown-code-block': hsl(h(0), s(-0.1), l(-0.03)),\r\n '--dsw-alias-markdown-inline-code': hsl(h(0), s(-0.08), l(0.04)),\r\n '--dsw-specific-sidebar-fill': hsl(h(0), s(-0.1), l(-0.03)),\r\n '--dsw-specific-sidebar-nav-item-active': hsl(h(0), s(-0.08), l(0.05)),\r\n '--dsw-specific-sidebar-nav-item-hover': hsl(h(0), s(-0.12), l(0)),\r\n '--dsw-specific-input-major': hsl(h(0), s(-0.12), l(0.1)),\r\n '--dsw-specific-menu': menuFill,\r\n '--dsw-menu-surface-fill': menuFill,\r\n '--dsw-alias-scrollbar-bg-l1': hsl(h(0), s(-0.1), l(-0.08)),\r\n '--dsw-alias-scrollbar-bg-l2': hsl(h(0), s(-0.08), l(-0.12)),\r\n '--dsw-alias-scrollbar-hover-l1': hsl(h(0), s(-0.08), l(-0.16)),\r\n '--dsw-alias-scrollbar-hover-l2': hsl(h(0), s(-0.08), l(-0.16)),\r\n },\r\n }\r\n}\r\n\r\nexport function toRgba(c: string, a: number): string {\r\n const hx = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(c.trim())\r\n if (hx) { let d = hx[1]!; if (d.length === 3) d = d.split('').map(x => x + x).join(''); const n = parseInt(d, 16); return `rgba(${(n >> 16) & 255},${(n >> 8) & 255},${n & 255},${a})` }\r\n const rgb = /^rgba?\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)(?:\\s*,\\s*([\\d.]+))?\\s*\\)$/i.exec(c.trim())\r\n if (rgb) return `rgba(${rgb[1]},${rgb[2]},${rgb[3]},${a})`\r\n const hsl = /^hsla?\\(\\s*([\\d.]+)\\s*,\\s*([\\d.]+)%\\s*,\\s*([\\d.]+)%/i.exec(c.trim())\r\n if (hsl) return `hsla(${hsl[1]},${hsl[2]}%,${hsl[3]}%,${a})`\r\n return c.trim()\r\n}\r\n\r\nexport function rgbToHsl(r: number, g: number, b: number): [number, number, number] {\r\n const rn = r / 255, gn = g / 255, bn = b / 255\r\n const max = Math.max(rn, gn, bn), min = Math.min(rn, gn, bn)\r\n const l = (max + min) / 2\r\n if (max === min) return [0, 0, l]\r\n const d = max - min\r\n const s = l > 0.5 ? d / (2 - max - min) : d / (max + min)\r\n let h: number\r\n if (max === rn) h = ((gn - bn) / d) % 6\r\n else if (max === gn) h = (bn - rn) / d + 2\r\n else h = (rn - gn) / d + 4\r\n h *= 60\r\n if (h < 0) h += 360\r\n return [h, s, l]\r\n}\r\n\r\n// Wallpaper color extraction: decode the cached data URL → crop the visible\r\n// (framed) region → downsample to a 64×64 canvas → quantize pixels into 4-bit\r\n// RGB buckets → discard near-gray / near-black / near-white pixels → pick the\r\n// most populous vivid bucket (count × saturation bias) → average its members →\r\n// RGB→HSL → clamp lightness into a band that keeps the light/dark scheme\r\n// decision unambiguous. Purely client-side and memory-bounded.\r\n\r\nconst EXTRACT_SIDE = 64\r\n\r\ninterface Bucket { count: number; r: number; g: number; b: number; s: number }\r\n\r\nfunction bucketsToHsl(b: Bucket): [number, number, number] {\r\n return rgbToHsl(b.r / b.count, b.g / b.count, b.b / b.count)\r\n}\r\n\r\nfunction extractWallpaperPalette(dataUrl: string, bgState: BgState): Promise<ColorPalette | null> {\r\n return new Promise(resolve => {\r\n const img = new Image()\r\n img.onerror = () => resolve(null)\r\n img.onload = () => {\r\n try {\r\n const iw = img.naturalWidth || img.width\r\n const ih = img.naturalHeight || img.height\r\n const bg = bgState\r\n let sx = 0, sy = 0, sw = iw, sh = ih\r\n if (bg.iw === iw && bg.ih === ih && bg.iw > 0) {\r\n const fit = Math.min(window.innerWidth / iw, window.innerHeight / ih)\r\n const w = iw * fit * bg.zoom\r\n const h = ih * fit * bg.zoom\r\n sx = Math.max(0, bg.x * window.innerWidth - w / 2)\r\n sy = Math.max(0, bg.y * window.innerHeight - h / 2)\r\n sw = Math.min(iw - sx, w)\r\n sh = Math.min(ih - sy, h)\r\n if (sw <= 0 || sh <= 0) { sx = 0; sy = 0; sw = iw; sh = ih }\r\n }\r\n const c = document.createElement('canvas')\r\n c.width = EXTRACT_SIDE; c.height = EXTRACT_SIDE\r\n const g = c.getContext('2d', { willReadFrequently: true })!\r\n g.drawImage(img, sx, sy, sw, sh, 0, 0, EXTRACT_SIDE, EXTRACT_SIDE)\r\n const px = g.getImageData(0, 0, EXTRACT_SIDE, EXTRACT_SIDE).data\r\n const counts = new Uint32Array(4096)\r\n const sums = new Float64Array(4096 * 3)\r\n let totalLum = 0\r\n let sampled = 0\r\n for (let i = 0; i < px.length; i += 4) {\r\n const r = px[i], gg = px[i + 1], b = px[i + 2]\r\n const max = Math.max(r, gg, b), min = Math.min(r, gg, b)\r\n const v = max / 255\r\n const s = max === 0 ? 0 : (max - min) / max\r\n // Include all non-extreme pixels in luminance; only vivid pixels in\r\n // palette buckets so we don't theme around gray/black/white.\r\n // Rec.709 luma — the measure a display reads as brightness, and the one\r\n // the light/dark band below is decided with. The HSV value used here\r\n // before counts every saturated pixel as bright (pure blue: v = 1.0,\r\n // luma = 0.072), which pushed dark saturated wallpapers into the light\r\n // band and built a light palette over a dark picture.\r\n totalLum += (0.2126 * r + 0.7152 * gg + 0.0722 * b) / 255\r\n sampled++\r\n if (s < 0.08 || v < 0.12 || v > 0.97) continue\r\n const key = ((r >> 4) << 8) | ((gg >> 4) << 4) | (b >> 4)\r\n counts[key]++\r\n sums[key * 3] += r; sums[key * 3 + 1] += gg; sums[key * 3 + 2] += b\r\n }\r\n const buckets: Bucket[] = []\r\n for (let k = 0; k < 4096; k++) {\r\n if (counts[k] === 0) continue\r\n buckets.push({\r\n count: counts[k],\r\n r: sums[k * 3],\r\n g: sums[k * 3 + 1],\r\n b: sums[k * 3 + 2],\r\n s: (Math.max(sums[k * 3], sums[k * 3 + 1], sums[k * 3 + 2]) - Math.min(sums[k * 3], sums[k * 3 + 1], sums[k * 3 + 2])) / Math.max(sums[k * 3], sums[k * 3 + 1], sums[k * 3 + 2]) || 0,\r\n })\r\n }\r\n if (buckets.length === 0) { resolve(null); return }\r\n // Sort by vivid-weighted count.\r\n buckets.sort((a, b) => b.count * (0.5 + b.s) - a.count * (0.5 + a.s))\r\n const primary = bucketsToHsl(buckets[0]!)\r\n const primaryHue = primary[0]\r\n // Secondary: next bucket that is reasonably separated from primary.\r\n let secondary = primary\r\n for (const b of buckets.slice(1)) {\r\n const [h] = bucketsToHsl(b)\r\n const sep = Math.abs(((h - primaryHue + 540) % 360) - 180)\r\n if (sep > 30) { secondary = bucketsToHsl(b); break }\r\n }\r\n // Tertiary: complementary-ish hue based on primary if no good secondary.\r\n let tertiary: [number, number, number] = [((primaryHue + 180) % 360), Math.min(0.7, primary[1]), Math.min(0.7, primary[2])]\r\n for (const b of buckets.slice(1)) {\r\n const [h] = bucketsToHsl(b)\r\n const sep = Math.abs(((h - primaryHue + 540) % 360) - 180)\r\n if (sep > 90 && sep < 150) { tertiary = bucketsToHsl(b); break }\r\n }\r\n // Surface: neutralized primary (very low saturation).\r\n const surface: [number, number, number] = [primaryHue, Math.min(0.06, primary[1] * 0.3), primary[2]]\r\n // Auto light/dark: use the average luminance of the whole image so a\r\n // bright wallpaper naturally drives a light scheme and vice-versa.\r\n const luminance = sampled > 0 ? totalLum / sampled : primary[2]\r\n // Snap primary lightness out of the ambiguous middle band.\r\n const autoDark = luminance < 0.5\r\n const lc = autoDark ? Math.min(0.44, Math.max(0.2, primary[2])) : Math.max(0.6, Math.min(0.82, primary[2]))\r\n primary[2] = lc\r\n resolve({\r\n primary: [primary[0], Math.min(0.9, Math.max(0.15, primary[1])), primary[2]],\r\n secondary: [secondary[0], Math.min(0.85, Math.max(0.2, secondary[1])), Math.min(0.75, Math.max(0.35, secondary[2]))],\r\n tertiary: [tertiary[0], Math.min(0.8, Math.max(0.2, tertiary[1])), Math.min(0.7, Math.max(0.35, tertiary[2]))],\r\n surface,\r\n luminance,\r\n })\r\n } catch {\r\n resolve(null)\r\n }\r\n }\r\n img.src = dataUrl\r\n })\r\n}\r\n\r\n/** Backward-compatible single-color extraction: returns the primary HSL. */\r\nexport async function extractWallpaperColor(dataUrl: string, bgState: BgState): Promise<[number, number, number] | null> {\r\n const palette = await extractWallpaperPalette(dataUrl, bgState)\r\n return palette ? palette.primary : null\r\n}\r\n\r\n// One-shot frame brightness analysis: called only when a generated background\r\n// is switched (from its captured snapshot), never from the animation loop.\r\n// Decode the frame, downsample to a 32×32 canvas, average Rec.709 luma.\r\n// Dark frame → light fonts, light frame → dark fonts.\r\n\r\nconst ANALYZE_SIDE = 32\r\n\r\n/** Analyze a captured frame's average luminance. Resolves true when the frame\r\n * reads dark (use white fonts), false when light (use black fonts), or null\r\n * when the frame cannot be decoded. */\r\nexport function analyzeFrameDark(dataUrl: string): Promise<boolean | null> {\r\n return new Promise(resolve => {\r\n const img = new Image()\r\n img.onerror = () => resolve(null)\r\n img.onload = () => {\r\n try {\r\n const c = document.createElement('canvas')\r\n c.width = ANALYZE_SIDE; c.height = ANALYZE_SIDE\r\n const g = c.getContext('2d', { willReadFrequently: true })!\r\n g.drawImage(img, 0, 0, ANALYZE_SIDE, ANALYZE_SIDE)\r\n const px = g.getImageData(0, 0, ANALYZE_SIDE, ANALYZE_SIDE).data\r\n let lum = 0\r\n const count = px.length / 4\r\n for (let i = 0; i < px.length; i += 4) {\r\n lum += 0.2126 * px[i]! + 0.7152 * px[i + 1]! + 0.0722 * px[i + 2]!\r\n }\r\n resolve(lum / count / 255 < 0.5)\r\n } catch {\r\n resolve(null)\r\n }\r\n }\r\n img.src = dataUrl\r\n })\r\n}\r\n\r\n/** HSL (h 0-360, s/l 0-1) → RGB (0-255 integers). */\r\nexport function hslToRgb(h: number, s: number, l: number): [number, number, number] {\r\n const c = (1 - Math.abs(2 * l - 1)) * s\r\n const hp = h / 60\r\n const x = c * (1 - Math.abs((hp % 2) - 1))\r\n let r = 0, g = 0, b = 0\r\n if (hp < 1) { r = c; g = x }\r\n else if (hp < 2) { r = x; g = c }\r\n else if (hp < 3) { g = c; b = x }\r\n else if (hp < 4) { g = x; b = c }\r\n else if (hp < 5) { r = x; b = c }\r\n else { r = c; b = x }\r\n const m = l - c / 2\r\n return [Math.round((r + m) * 255), Math.round((g + m) * 255), Math.round((b + m) * 255)]\r\n}\r\n","/**\r\n * dsh-background-by-model — settings UI design system.\r\n *\r\n * The section is styled entirely through these scoped classes instead of the\r\n * host's inline-style approach: animations (page transitions, staggered\r\n * reveals, the rotating orb ring) and pseudo-element effects cannot be\r\n * expressed as React inline styles. Every color reads the host's\r\n * --dsw-alias-* tokens so the panel follows the user's custom theme color and\r\n * light/dark scheme automatically; `color-mix` tints carry a plain-token\r\n * fallback first for older engines.\r\n */\r\nexport const NAV_ITEM_H = 38\r\nexport const NAV_GAP = 4\r\n\r\nexport const UI_CSS = `\r\n/* The section is rendered INLINE inside the host settings dialog's content\r\n * column: the host provides the modal chrome (backdrop, centering, closing).\r\n * These classes style only the embedded shell; transient fixed layers (toast,\r\n * color picker, background editor) escape through Portals on <html>. */\r\n.dab-root{position:relative;color:var(--dsw-alias-label-primary);animation:dab-fade-in .35s ease both;container-type:inline-size;display:flex;flex-direction:column;align-items:center;width:100%;min-width:0;--dab-mono:ui-monospace,\"Cascadia Mono\",\"SF Mono\",Consolas,\"Courier New\",monospace}\r\n.dab-root *,.dab-root *::before,.dab-root *::after{box-sizing:border-box}\r\n.dab-root button{font-family:inherit}\r\n\r\n/* ── shell: nav rail + page body ─────────────────────────────────────────── */\r\n.dab-shell{display:grid;grid-template-columns:158px minmax(0,1fr);gap:26px;align-items:start;padding-bottom:8px;width:100%;max-width:980px;margin:0 auto}\r\n.dab-nav{position:sticky;top:0;display:flex;flex-direction:column;gap:18px}\r\n.dab-brand{display:flex;align-items:center;gap:10px;padding:2px 6px}\r\n.dab-brand-tile{width:30px;height:30px;flex:none;border-radius:9px;display:grid;place-items:center;color:var(--dsw-alias-label-primary-inverted);background:var(--dsw-alias-brand-primary);box-shadow:0 4px 14px -4px var(--dsw-alias-brand-primary)}\r\n.dab-brand-name{font-size:13px;font-weight:650;letter-spacing:.01em;line-height:1.25}\r\n.dab-brand-tag{font-size:9px;letter-spacing:.16em;font-weight:600;color:var(--dsw-alias-label-quaternary,var(--dsw-alias-label-tertiary));text-transform:uppercase}\r\n.dab-nav-list{position:relative;display:flex;flex-direction:column;gap:${NAV_GAP}px}\r\n.dab-nav-ind{position:absolute;left:0;right:0;top:0;height:${NAV_ITEM_H}px;border-radius:11px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 13%,transparent);border-color:color-mix(in srgb,var(--dsw-alias-brand-primary) 25%,transparent);transition:transform .38s cubic-bezier(.22,1,.36,1)}\r\n.dab-nav-item{position:relative;z-index:1;display:flex;align-items:center;gap:10px;height:${NAV_ITEM_H}px;padding:0 12px;border:0;background:none;border-radius:11px;color:var(--dsw-alias-label-tertiary);font-size:13px;cursor:pointer;text-align:left;transition:color .22s ease}\r\n.dab-nav-item:hover{color:var(--dsw-alias-label-primary)}\r\n.dab-nav-item.is-active{color:var(--dsw-alias-brand-primary);font-weight:600}\r\n.dab-nav-item svg{flex:none;transition:transform .3s cubic-bezier(.34,1.56,.64,1)}\r\n.dab-nav-item:hover svg{transform:scale(1.14) rotate(-5deg)}\r\n\r\n/* ── page chrome ─────────────────────────────────────────────────────────── */\r\n.dab-page{animation:dab-page-in .4s cubic-bezier(.22,1,.36,1) both;min-width:0;display:flex;flex-direction:column;gap:13px}\r\n.dab-head{margin:2px 0 5px}\r\n.dab-overline{font-size:10.5px;font-weight:700;letter-spacing:.18em;text-transform:uppercase;color:var(--dsw-alias-brand-primary);opacity:.9}\r\n.dab-h1{margin:4px 0 0;font-size:21px;font-weight:700;letter-spacing:-.01em}\r\n.dab-desc{margin:6px 0 0;font-size:12.5px;line-height:1.55;color:var(--dsw-alias-label-tertiary);max-width:56ch}\r\n.dab-card{background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);border-radius:16px;padding:18px}\r\n.dab-card-hover{transition:transform .28s ease,box-shadow .28s ease,border-color .28s ease}\r\n.dab-card-hover:hover{transform:translateY(-2px);box-shadow:0 10px 28px -12px rgba(0,0,0,.28)}\r\n.dab-rise{animation:dab-rise-in .55s cubic-bezier(.22,1,.36,1) both;animation-delay:calc(var(--d,0) * 62ms)}\r\n\r\n/* ── accent hero (color orb) ─────────────────────────────────────────────── */\r\n.dab-hero-accent{display:flex;align-items:center;gap:24px;flex-wrap:wrap}\r\n.dab-orb-wrap{position:relative;width:118px;height:118px;flex:none}\r\n.dab-orb{position:absolute;inset:11px;border-radius:50%;background:radial-gradient(circle at 32% 28%,rgba(255,255,255,.5),rgba(255,255,255,0) 44%),var(--c,#888);box-shadow:0 16px 36px -10px var(--c-soft,transparent),inset 0 -10px 20px rgba(0,0,0,.16);animation:dab-orb-in .7s cubic-bezier(.22,1,.36,1) both}\r\n.dab-orb-ring{position:absolute;inset:0;border-radius:50%;background:conic-gradient(from 0deg,transparent 0 30%,var(--c,#888) 46%,transparent 62%,transparent 76%,var(--c,#888) 90%,transparent 100%);-webkit-mask:radial-gradient(farthest-side,transparent calc(100% - 3.5px),#000 calc(100% - 2.5px));mask:radial-gradient(farthest-side,transparent calc(100% - 3.5px),#000 calc(100% - 2.5px));animation:dab-spin 7s linear infinite;opacity:.9}\r\n.dab-hex-caption{font-size:11px;color:var(--dsw-alias-label-tertiary);letter-spacing:.04em}\r\n.dab-hex{font-family:var(--dab-mono);font-size:24px;font-weight:600;letter-spacing:.02em;line-height:1.2;margin-top:2px}\r\n.dab-hsl-row{display:flex;gap:16px;margin-top:7px;font-family:var(--dab-mono);font-size:11px;color:var(--dsw-alias-label-tertiary)}\r\n.dab-hsl-row b{font-weight:600;color:var(--dsw-alias-label-secondary,var(--dsw-alias-label-tertiary))}\r\n\r\n/* ── swatches ────────────────────────────────────────────────────────────── */\r\n.dab-swatch-title{font-size:12px;font-weight:600;margin-bottom:10px;color:var(--dsw-alias-label-secondary,var(--dsw-alias-label-tertiary))}\r\n.dab-swatches{display:flex;flex-wrap:wrap;gap:9px}\r\n.dab-swatch{width:25px;height:25px;border-radius:50%;border:0;padding:0;cursor:pointer;box-shadow:inset 0 0 0 1px rgba(0,0,0,.1);transition:transform .22s cubic-bezier(.34,1.56,.64,1),box-shadow .22s ease}\r\n.dab-swatch:hover{transform:scale(1.2)}\r\n.dab-swatch.is-on{box-shadow:0 0 0 2px var(--dsw-alias-bg-layer-1),0 0 0 4px var(--dsw-alias-brand-primary)}\r\n\r\n/* ── wheel card ──────────────────────────────────────────────────────────── */\r\n.dab-wheel-card{position:relative;display:flex;align-items:center;justify-content:center;gap:28px;flex-wrap:wrap;padding:24px 18px}\r\n.dab-wheel-glow{position:absolute;width:230px;height:230px;border-radius:50%;filter:blur(48px);opacity:.2;background:var(--c,#888);pointer-events:none;transition:background .4s ease}\r\n.dab-wheel{position:relative;cursor:crosshair;border-radius:50%;box-shadow:0 12px 32px -14px rgba(0,0,0,.4)}\r\n.dab-hint{font-size:11.5px;line-height:1.55;color:var(--dsw-alias-label-tertiary);padding:0 4px}\r\n\r\n/* ── precise color inputs ────────────────────────────────────────────────── */\r\n.dab-inputs{display:flex;flex-direction:column;gap:10px;min-width:172px}\r\n.dab-field{display:flex;align-items:center;gap:8px}\r\n.dab-field-label{width:14px;text-align:center;font-family:var(--dab-mono);font-size:11px;font-weight:600;color:var(--dsw-alias-label-tertiary)}\r\n.dab-num{flex:1;min-width:0;height:30px;padding:0 10px;border-radius:9px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font-family:var(--dab-mono);font-size:12px;outline:none;transition:border-color .2s,box-shadow .2s}\r\n.dab-num:focus{border-color:var(--dsw-alias-brand-primary);box-shadow:0 0 0 3px color-mix(in srgb,var(--dsw-alias-brand-primary) 18%,transparent)}\r\n.dab-num::-webkit-outer-spin-button,.dab-num::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}\r\n.dab-num{-moz-appearance:textfield;appearance:textfield}\r\n.dab-urlinput{flex:1;min-width:180px;height:34px;padding:0 12px;border-radius:10px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font-size:12.5px;outline:none;transition:border-color .2s}\r\n.dab-urlinput::placeholder{color:var(--dsw-alias-label-quaternary)}\r\n.dab-urlinput:focus{border-color:var(--dsw-alias-brand-primary);box-shadow:0 0 0 3px color-mix(in srgb,var(--dsw-alias-brand-primary) 18%,transparent)}\r\n.dab-swatch-lg{height:38px;border-radius:10px;border:1px solid var(--dsw-alias-border-l2);box-shadow:inset 0 0 14px rgba(0,0,0,.1);transition:transform .3s ease}\r\n.dab-swatch-lg:hover{transform:scale(1.02)}\r\n\r\n/* ── buttons & chips ─────────────────────────────────────────────────────── */\r\n/* Text/icon painted ON --dsw-alias-brand-primary reads\r\n * --dsw-alias-label-primary-inverted, never --dsw-alias-brand-text. The host's\r\n * brand-primary is a CONTRAST ink, not a hue: black in its light scheme and\r\n * near-white (#f9fafb) in its dark one, with brand-text equal to it in BOTH\r\n * (and unused by the host's own CSS). Following the system theme therefore made\r\n * every brand-filled control a filled box with an invisible label — a white\r\n * primary button and a white active chip on a dark dialog. It was only ever\r\n * readable while the plugin owned the palette and generated its own brand pair.\r\n * label-primary-inverted is the host's answer for ink on a brand/contrast fill\r\n * (its sidebar build badge paints exactly this pair) and it flips with the\r\n * scheme: #fff on the light scheme's black fill, #353638 on the dark scheme's\r\n * white one. */\r\n.dab-btn{display:inline-flex;align-items:center;justify-content:center;gap:7px;height:34px;padding:0 14px;border-radius:10px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-button-elevated-fill);color:var(--dsw-alias-label-primary);font-size:12.5px;font-weight:550;cursor:pointer;transition:transform .18s ease,box-shadow .18s ease,border-color .18s ease,opacity .18s ease,background .18s ease}\r\n.dab-btn:hover:not(:disabled){transform:translateY(-1px);box-shadow:0 5px 14px -6px rgba(0,0,0,.32)}\r\n.dab-btn:active:not(:disabled){transform:translateY(0) scale(.97);box-shadow:none}\r\n.dab-btn:disabled{opacity:.5;cursor:not-allowed}\r\n.dab-btn-primary{background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary-inverted);border-color:transparent}\r\n.dab-btn-danger{color:var(--dsw-alias-state-error-primary)}\r\n.dab-btn-ghost{background:transparent;border-color:transparent;color:var(--dsw-alias-label-secondary,var(--dsw-alias-label-tertiary))}\r\n.dab-btn-ghost:hover:not(:disabled){background:var(--dsw-alias-bg-layer-2);box-shadow:none}\r\n.dab-btn:focus-visible,.dab-nav-item:focus-visible,.dab-seg-item:focus-visible,.dab-swatch:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}\r\n.dab-chip-row{display:flex;flex-wrap:wrap;gap:8px}\r\n.dab-chip{height:30px;padding:0 14px;border-radius:99px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-secondary,var(--dsw-alias-label-tertiary));font-size:12px;cursor:pointer;display:inline-flex;align-items:center;gap:6px;transition:all .22s ease}\r\n.dab-chip:hover{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary)}\r\n.dab-chip.is-active{background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary-inverted);border-color:transparent}\r\n\r\n/* ── sliders ─────────────────────────────────────────────────────────────── */\r\n.dab-slider-block{display:flex;flex-direction:column;gap:6px}\r\n.dab-slider-block + .dab-slider-block{margin-top:13px}\r\n.dab-slider-label{font-size:12px;font-weight:550;color:var(--dsw-alias-label-secondary,var(--dsw-alias-label-tertiary))}\r\n.dab-slider-val{font-family:var(--dab-mono);font-size:11px;color:var(--dsw-alias-label-tertiary);min-width:44px;text-align:right}\r\n.dab-slider{-webkit-appearance:none;appearance:none;flex:1;min-width:0;height:4px;border-radius:99px;outline:none;cursor:pointer;margin:5px 0;background:linear-gradient(to right,var(--dsw-alias-brand-primary) calc(var(--pct,50) * 1%),var(--dsw-alias-border-l2) calc(var(--pct,50) * 1%));transition:height .15s ease}\r\n.dab-slider:hover{height:5px}\r\n.dab-slider::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:15px;height:15px;border-radius:50%;background:var(--dsw-alias-button-elevated-fill,#fff);border:2px solid var(--dsw-alias-brand-primary);box-shadow:0 1px 5px rgba(0,0,0,.28);transition:transform .16s cubic-bezier(.34,1.56,.64,1)}\r\n.dab-slider:hover::-webkit-slider-thumb,.dab-slider:focus-visible::-webkit-slider-thumb{transform:scale(1.22)}\r\n.dab-slider:active::-webkit-slider-thumb{transform:scale(1.34)}\r\n.dab-slider::-moz-range-thumb{width:13px;height:13px;border-radius:50%;background:var(--dsw-alias-button-elevated-fill,#fff);border:2px solid var(--dsw-alias-brand-primary)}\r\n\r\n/* ── interface part cards ────────────────────────────────────────────────── */\r\n.dab-grid-parts{display:grid;grid-template-columns:repeat(auto-fill,minmax(256px,1fr));gap:13px}\r\n.dab-part-head{display:flex;align-items:center;gap:11px;margin-bottom:14px}\r\n.dab-part-ico{width:32px;height:32px;flex:none;border-radius:10px;display:grid;place-items:center;color:var(--dsw-alias-brand-primary);background:var(--dsw-alias-bg-layer-2);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 12%,transparent)}\r\n.dab-part-name{font-size:13.5px;font-weight:600}\r\n.dab-part-badge{margin-left:auto;font-family:var(--dab-mono);font-size:11px;color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-layer-2);border-radius:99px;padding:3px 9px}\r\n\r\n/* ── segmented control ───────────────────────────────────────────────────── */\r\n.dab-seg{position:relative;display:inline-flex;padding:3px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:11px}\r\n.dab-seg-thumb{position:absolute;top:3px;bottom:3px;left:3px;width:var(--w,96px);border-radius:8px;background:var(--dsw-alias-button-elevated-fill);box-shadow:0 2px 8px -2px rgba(0,0,0,.28);transition:transform .32s cubic-bezier(.22,1,.36,1)}\r\n.dab-seg-item{position:relative;z-index:1;display:inline-flex;align-items:center;justify-content:center;gap:6px;width:var(--w,96px);height:30px;border:0;background:none;border-radius:8px;color:var(--dsw-alias-label-tertiary);font-size:12.5px;cursor:pointer;transition:color .25s ease}\r\n.dab-seg-item.is-active{color:var(--dsw-alias-label-primary);font-weight:600}\r\n\r\n/* ── toggle switch ───────────────────────────────────────────────────────── */\r\n.dab-toggle{position:relative;width:42px;height:24px;flex:none;border-radius:99px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);cursor:pointer;padding:0;transition:background .28s ease,border-color .28s ease}\r\n.dab-toggle-knob{position:absolute;top:2.5px;left:2.5px;width:17px;height:17px;border-radius:50%;background:var(--dsw-alias-label-secondary,#999);box-shadow:0 1px 3px rgba(0,0,0,.3);transition:transform .28s cubic-bezier(.22,1,.36,1),background .28s ease}\r\n.dab-toggle.is-on{background:var(--dsw-alias-brand-primary);border-color:var(--dsw-alias-brand-primary)}\r\n.dab-toggle.is-on .dab-toggle-knob{transform:translateX(18px);background:var(--dsw-alias-label-primary-inverted)}\r\n\r\n/* ── background preview hero ─────────────────────────────────────────────── */\r\n.dab-hero{position:relative;border-radius:16px;overflow:hidden;aspect-ratio:16/9;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2)}\r\n.dab-hero-img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;transition:transform .5s cubic-bezier(.22,1,.36,1)}\r\n.dab-hero:hover .dab-hero-img{transform:scale(1.03)}\r\n.dab-hero-empty{position:absolute;inset:6px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;color:var(--dsw-alias-label-tertiary);font-size:12.5px;border:1.5px dashed var(--dsw-alias-border-l2);border-radius:12px;cursor:pointer;background:transparent;transition:border-color .25s,color .25s,background .25s;width:auto;height:auto}\r\n.dab-hero-empty:hover{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}\r\n.dab-hero-empty.is-over{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 8%,transparent)}\r\n.dab-hero-badge{position:absolute;top:10px;left:10px;display:inline-flex;align-items:center;gap:5px;height:24px;padding:0 11px;border-radius:99px;background:rgba(0,0,0,.45);color:#fff;font-size:11px;backdrop-filter:blur(6px);pointer-events:none}\r\n.dab-hero-veil{position:absolute;left:0;right:0;bottom:0;padding:34px 12px 12px;display:flex;align-items:flex-end;justify-content:flex-end;gap:8px;background:linear-gradient(to top,rgba(0,0,0,.55),rgba(0,0,0,0));opacity:0;transform:translateY(6px);transition:opacity .3s ease,transform .3s ease}\r\n.dab-hero:hover .dab-hero-veil{opacity:1;transform:none}\r\n.dab-hero-veil .dab-btn{background:rgba(255,255,255,.94);color:#14161a;border-color:transparent;height:30px;font-size:12px}\r\n.dab-hero-veil .dab-btn-danger{color:#dc2626}\r\n\r\n/* ── profile page ────────────────────────────────────────────────────────── */\r\n.dab-profile-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(238px,1fr));gap:13px}\r\n.dab-profile-ico{width:38px;height:38px;border-radius:11px;display:grid;place-items:center;margin-bottom:13px;color:var(--dsw-alias-brand-primary);background:var(--dsw-alias-bg-layer-2);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 12%,transparent)}\r\n.dab-profile-title{font-size:14px;font-weight:650}\r\n.dab-profile-desc{font-size:12px;color:var(--dsw-alias-label-tertiary);line-height:1.55;margin:5px 0 15px}\r\n.dab-footer{margin-top:6px;padding:14px 4px 0;border-top:1px solid var(--dsw-alias-border-l2);display:flex;align-items:center;justify-content:space-between;font-size:11px;color:var(--dsw-alias-label-tertiary)}\r\n.dab-footer-mono{font-family:var(--dab-mono);letter-spacing:.02em}\r\n\r\n/* ── toast ───────────────────────────────────────────────────────────────── */\r\n.dab-toast{position:fixed;left:50%;bottom:30px;transform:translateX(-50%);display:flex;align-items:center;gap:8px;height:38px;padding:0 16px;border-radius:99px;background:var(--dsw-alias-bg-layer-3,var(--dsw-alias-bg-layer-2));border:1px solid var(--dsw-alias-border-l2);box-shadow:0 10px 30px -8px rgba(0,0,0,.38);font-size:12.5px;z-index:10001;animation:dab-toast-in .32s cubic-bezier(.22,1,.36,1) both}\r\n.dab-toast-ok{color:var(--dsw-alias-brand-primary);display:grid;place-items:center}\r\n.dab-toast-err{color:var(--dsw-alias-state-error-primary);display:grid;place-items:center}\r\n\r\n/* ── modals (editor / eyedropper / crash) ────────────────────────────────── */\r\n/* Pin to the viewport explicitly with vw/vh so ancestor padding/margins on\r\n * body cannot shift or clip the overlay; keep it above host sidebar chrome.\r\n * pointer-events:auto re-enables interaction: these overlays render inside a\r\n * Portal root that is pointer-events:none so it never blocks the page alone. */\r\n.dab-overlay{position:fixed;left:0;top:0;width:100vw;height:100vh;z-index:999999;background:rgba(8,10,14,.62);backdrop-filter:blur(8px);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;animation:dab-fade-in .25s ease both;pointer-events:auto}\r\n.dab-overlay-title{color:#fff;font-size:15px;font-weight:600}\r\n.dab-overlay-hint{color:rgba(255,255,255,.62);font-size:12px}\r\n.dab-modal-card{animation:dab-zoom-in .3s cubic-bezier(.22,1,.36,1) both;max-width:calc(100vw - 40px);max-height:calc(100vh - 120px);overflow:auto}\r\n.dab-overlay .dab-btn{background:rgba(255,255,255,.94);color:#14161a;border-color:transparent}\r\n.dab-overlay .dab-btn-primary{background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary-inverted)}\r\n.dab-crash{display:flex;flex-direction:column;gap:10px;align-items:center;padding:28px 18px;border:1px solid var(--dsw-alias-border-l2);border-radius:16px}\r\n.dab-crash-title{font-size:15px;font-weight:650}\r\n.dab-crash-desc{font-size:12px;color:var(--dsw-alias-label-tertiary);text-align:center;line-height:1.5}\r\n\r\n/* ── model rules ─────────────────────────────────────────────────────────── */\r\n.dab-rules{display:flex;flex-direction:column;gap:12px}\r\n.dab-rule{background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);border-radius:16px;padding:14px;transition:border-color .25s,box-shadow .25s,opacity .25s}\r\n.dab-rule.is-active{border-color:var(--dsw-alias-brand-primary);box-shadow:0 0 0 3px color-mix(in srgb,var(--dsw-alias-brand-primary) 16%,transparent)}\r\n.dab-rule.is-off{opacity:.55}\r\n.dab-rule-head{display:flex;align-items:center;gap:9px;flex-wrap:wrap}\r\n.dab-rule-num{font-family:var(--dab-mono);font-size:11px;font-weight:700;color:var(--dsw-alias-label-tertiary);min-width:16px}\r\n.dab-rule-badge{font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:var(--dsw-alias-brand-primary);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 14%,transparent);border-radius:99px;padding:2px 8px}\r\n.dab-rule-match{flex:1;min-width:150px;height:32px;padding:0 11px;border-radius:9px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font-family:var(--dab-mono);font-size:12.5px;outline:none;transition:border-color .2s,box-shadow .2s}\r\n.dab-rule-match::placeholder{color:var(--dsw-alias-label-quaternary)}\r\n.dab-rule-match:focus{border-color:var(--dsw-alias-brand-primary);box-shadow:0 0 0 3px color-mix(in srgb,var(--dsw-alias-brand-primary) 18%,transparent)}\r\n.dab-icon-btn{width:28px;height:28px;flex:none;display:grid;place-items:center;border-radius:8px;border:1px solid var(--dsw-alias-border-l2);background:transparent;color:var(--dsw-alias-label-tertiary);cursor:pointer;transition:color .2s,border-color .2s,background .2s}\r\n.dab-icon-btn:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-brand-primary)}\r\n.dab-icon-btn:disabled{opacity:.35;cursor:not-allowed}\r\n.dab-icon-btn-danger:hover:not(:disabled){color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-primary)}\r\n.dab-rule-body{margin-top:13px;display:flex;flex-direction:column;gap:13px}\r\n.dab-rule-thumb{position:relative;border-radius:12px;overflow:hidden;aspect-ratio:16/9;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);cursor:pointer}\r\n.dab-rule-thumb img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}\r\n.dab-rule-thumb-empty{position:absolute;inset:5px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;border:1.5px dashed var(--dsw-alias-border-l2);border-radius:9px;color:var(--dsw-alias-label-tertiary);font-size:12px;text-align:center;padding:0 10px}\r\n.dab-rule-thumb.is-over .dab-rule-thumb-empty{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}\r\n.dab-rule-cols{display:grid;grid-template-columns:minmax(0,1.15fr) minmax(0,1fr);gap:18px;align-items:start}\r\n.dab-rule-section-title{font-size:12px;font-weight:600;margin-bottom:9px;color:var(--dsw-alias-label-secondary,var(--dsw-alias-label-tertiary))}\r\n@container (max-width:760px){.dab-rule-cols{grid-template-columns:1fr}}\r\n\r\n/* ── host self-check ─────────────────────────────────────────────────────── */\r\n.dab-verdict{display:flex;flex-direction:column;gap:14px;position:relative;overflow:hidden}\r\n.dab-verdict::after{content:'';position:absolute;inset:0;pointer-events:none;opacity:.5;background:linear-gradient(120deg,transparent 55%,color-mix(in srgb,var(--dab-verdict-tone,transparent) 26%,transparent))}\r\n.dab-verdict-ok{--dab-verdict-tone:var(--dsw-alias-state-success-primary,var(--dsw-alias-brand-primary));border-color:color-mix(in srgb,var(--dsw-alias-state-success-primary,var(--dsw-alias-brand-primary)) 38%,var(--dsw-alias-border-l2))}\r\n.dab-verdict-partial,.dab-verdict-broken{--dab-verdict-tone:var(--dsw-alias-state-error-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 40%,var(--dsw-alias-border-l2))}\r\n.dab-verdict-unknown{--dab-verdict-tone:var(--dsw-alias-label-tertiary)}\r\n.dab-verdict-head{display:flex;align-items:center;gap:13px;flex-wrap:wrap}\r\n.dab-verdict-ico{width:34px;height:34px;flex:none;border-radius:11px;display:grid;place-items:center;color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-layer-2)}\r\n.dab-verdict-ico-ok{color:var(--dsw-alias-state-success-primary,var(--dsw-alias-brand-primary));background:color-mix(in srgb,var(--dsw-alias-state-success-primary,var(--dsw-alias-brand-primary)) 14%,transparent)}\r\n.dab-verdict-ico-partial,.dab-verdict-ico-broken{color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 14%,transparent)}\r\n.dab-verdict-text{flex:1;min-width:170px}\r\n.dab-verdict-title{font-size:14.5px;font-weight:650}\r\n.dab-verdict-sub{margin-top:4px;font-size:12px;color:var(--dsw-alias-label-tertiary)}\r\n.dab-verdict-actions{display:flex;gap:8px;flex-wrap:wrap;margin-left:auto}\r\n.dab-facts{display:flex;flex-wrap:wrap;gap:8px;position:relative;z-index:1}\r\n.dab-fact{display:inline-flex;align-items:center;gap:7px;height:27px;padding:0 11px;border-radius:99px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);max-width:100%}\r\n.dab-fact.is-bad{border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 45%,transparent);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent)}\r\n.dab-fact-k{font-size:10.5px;font-weight:650;letter-spacing:.06em;text-transform:uppercase;color:var(--dsw-alias-label-tertiary);white-space:nowrap}\r\n.dab-fact-v{font-family:var(--dab-mono);font-size:11.5px;color:var(--dsw-alias-label-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:32ch}\r\n.dab-check-group-title{display:flex;align-items:center;gap:9px;font-size:12.5px;font-weight:650;margin-bottom:11px}\r\n.dab-check-group-count{margin-left:auto;font-family:var(--dab-mono);font-size:11px;font-weight:500;color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-layer-2);border-radius:99px;padding:3px 9px}\r\n.dab-checks{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px}\r\n.dab-check{display:flex;gap:10px;padding:9px 10px;border-radius:11px;transition:background .2s ease}\r\n.dab-check:hover{background:var(--dsw-alias-bg-layer-2)}\r\n.dab-check-ico{width:19px;height:19px;flex:none;margin-top:1px;border-radius:50%;display:grid;place-items:center;color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-layer-2)}\r\n.dab-check-ico-pass{color:var(--dsw-alias-state-success-primary,var(--dsw-alias-brand-primary));background:color-mix(in srgb,var(--dsw-alias-state-success-primary,var(--dsw-alias-brand-primary)) 15%,transparent)}\r\n.dab-check-ico-fail{color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 15%,transparent)}\r\n.dab-check-dot{width:5px;height:5px;border-radius:50%;background:currentColor;opacity:.65}\r\n.dab-check-body{min-width:0;flex:1;display:flex;flex-direction:column;gap:3px}\r\n.dab-check-head{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap}\r\n.dab-check-label{font-size:12.5px;font-weight:600}\r\n.dab-check-status{font-size:10px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;padding:1px 7px;border-radius:99px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-tertiary)}\r\n.dab-check-status-pass{color:var(--dsw-alias-state-success-primary,var(--dsw-alias-brand-primary));background:color-mix(in srgb,var(--dsw-alias-state-success-primary,var(--dsw-alias-brand-primary)) 14%,transparent)}\r\n.dab-check-status-fail{color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 14%,transparent)}\r\n.dab-check-target{font-family:var(--dab-mono);font-size:10.5px;color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-layer-2);border-radius:6px;padding:1px 6px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\r\n.dab-check-detail{font-family:var(--dab-mono);font-size:11px;color:var(--dsw-alias-label-tertiary);line-height:1.5;overflow-wrap:anywhere}\r\n.dab-check-reason{display:flex;flex-direction:column;gap:5px;font-size:12px;line-height:1.55;color:var(--dsw-alias-label-secondary,var(--dsw-alias-label-tertiary))}\r\n.dab-check-symptom{color:var(--dsw-alias-state-error-primary)}\r\n.dab-check-where{display:flex;gap:7px;align-items:baseline;flex-wrap:wrap;font-size:11px;color:var(--dsw-alias-label-tertiary)}\r\n.dab-check-where code{font-family:var(--dab-mono);font-size:10.5px;overflow-wrap:anywhere}\r\n.dab-check-note{margin:12px 0 0;font-size:11.5px;line-height:1.55;color:var(--dsw-alias-label-tertiary);position:relative;z-index:1}\r\n\r\n/* ── keyframes ───────────────────────────────────────────────────────────── */\r\n@keyframes dab-fade-in{from{opacity:0}to{opacity:1}}\r\n@keyframes dab-page-in{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}\r\n@keyframes dab-rise-in{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}\r\n@keyframes dab-orb-in{from{opacity:0;transform:scale(.82)}to{opacity:1;transform:none}}\r\n@keyframes dab-spin{to{transform:rotate(360deg)}}\r\n@keyframes dab-rotate{to{transform:rotate(360deg)}}\r\n@keyframes dab-toast-in{from{opacity:0;transform:translate(-50%,10px)}to{opacity:1;transform:translate(-50%,0)}}\r\n@keyframes dab-zoom-in{from{opacity:0;transform:scale(.94) translateY(8px)}to{opacity:1;transform:none}}\r\n@keyframes dab-flow{to{background-position:300% 50%}}\r\n\r\n/* ── responsive & motion preferences ─────────────────────────────────────── */\r\n@container (max-width:620px){\r\n .dab-shell{grid-template-columns:1fr;gap:14px}\r\n .dab-nav{position:static;flex-direction:row;align-items:center;justify-content:space-between;gap:10px}\r\n .dab-nav-list{flex-direction:row;overflow-x:auto;scrollbar-width:none}\r\n .dab-nav-list::-webkit-scrollbar{display:none}\r\n .dab-nav-ind{display:none}\r\n .dab-nav-item{flex:none;padding:0 10px}\r\n .dab-nav-item.is-active{background:var(--dsw-alias-bg-layer-2)}\r\n .dab-types{grid-template-columns:1fr}\r\n .dab-verdict-actions{margin-left:0;width:100%}\r\n .dab-verdict-actions .dab-btn{flex:1}\r\n}\r\n@container (min-width:621px){\r\n .dab-shell{grid-template-columns:158px minmax(0,1fr);gap:26px}\r\n}\r\n@media (prefers-reduced-motion:reduce){\r\n .dab-root *,.dab-root *::before,.dab-root *::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}\r\n}\r\n`\r\n\r\nconst CSS_ID = 'dab-ui-css'\r\n\r\n/**\r\n * The attribute that marks a `<style>` element as OURS.\r\n *\r\n * The host's own CSS modules also set `data-plugin` on their `<style>` elements\r\n * (every one of them), so `data-plugin` cannot distinguish this plugin's sheets\r\n * from the host's — and the host-contract probe has to make exactly that\r\n * distinction: a token this plugin re-emits must never be allowed to make a\r\n * *host* check pass. This attribute is the honest marker, and it is set on every\r\n * stylesheet this plugin injects.\r\n */\r\nexport const OWN_SHEET_ATTR = 'data-dab-side'\r\n\r\n/** Mark a stylesheet this plugin injected, so the host probe can tell it apart. */\r\nexport function markOwnSheet(el: HTMLStyleElement): HTMLStyleElement {\r\n el.setAttribute(OWN_SHEET_ATTR, 'own')\r\n return el\r\n}\r\n\r\n/** Inject the design-system stylesheet once per document (HMR-safe). */\r\nexport function ensureUiCss(): void {\r\n if (typeof document === 'undefined') return\r\n let el = document.getElementById(CSS_ID) as HTMLStyleElement | null\r\n if (!el) {\r\n el = document.createElement('style')\r\n el.id = CSS_ID\r\n markOwnSheet(el)\r\n document.head.appendChild(el)\r\n }\r\n if (el.textContent !== UI_CSS) el.textContent = UI_CSS\r\n}\r\n","import { rWp, rBgState, rBl, rWop, rOps, rSop, rColor, rHasColor, rBlurs, rBgMode, rChatTextOpacity, rTrajectoryOpacity, rRightbarOpacity } from './state'\r\nimport type { PartOpacities, PartBlurs } from './types'\r\nimport { genTokens, toRgba } from './utils/color'\r\nimport { markOwnSheet } from './components/ui.css'\r\n\r\n/**\r\n * `data-ds-dark-theme` value the plugin writes while it forces its own dark\r\n * palette. The host treats the attribute as a boolean (`toggleAttribute`), so a\r\n * plugin-specific value still matches every `body[data-ds-dark-theme]` rule\r\n * while staying distinguishable from the host's own write — which is what lets\r\n * `releaseOwnScheme` hand the flag back without clobbering the host's scheme.\r\n */\r\nexport const OWN_SCHEME = 'dsh-background-by-model'\r\nconst DARK_ATTR = 'data-ds-dark-theme'\r\n\r\n/**\r\n * Marker on <html> while the plugin owns a palette. The dialog/trajectory rules\r\n * below redirect NO-fallback tokens (`--dsw-alias-bg-layer-*`) to plugin-owned\r\n * variables, so they may only match while those variables are actually written:\r\n * without the gate a palette-less state would leave them reading a\r\n * guaranteed-invalid value (transparent panels) instead of handing the surface\r\n * back to the host untouched.\r\n */\r\nconst THEMED_ATTR = 'data-dab-themed'\r\n\r\nlet wpEl: HTMLDivElement | null = null\r\nlet appliedTokenNames: string[] = []\r\nlet tokenStyleEl: HTMLStyleElement | null = null\r\n\r\nfunction ensureTokenStyle(): HTMLStyleElement {\r\n if (tokenStyleEl?.isConnected) return tokenStyleEl\r\n tokenStyleEl = document.createElement('style')\r\n tokenStyleEl.dataset.plugin = 'dsh-background-by-model-tokens'\r\n markOwnSheet(tokenStyleEl)\r\n document.head.appendChild(tokenStyleEl)\r\n return tokenStyleEl\r\n}\r\n\r\nfunction clearCustomTokens(): void {\r\n if (tokenStyleEl) tokenStyleEl.textContent = ''\r\n for (const name of appliedTokenNames) document.body.style.removeProperty(name)\r\n appliedTokenNames = []\r\n // Whatever follows must repaint from scratch: the fingerprints that guard the\r\n // token rule and the part opacities describe a stylesheet that no longer exists.\r\n baseTokenKey = ''\r\n lastBgKey = ''\r\n}\r\n\r\n/** Drop every surface the plugin owns: the variables the scoped\r\n * dialog/trajectory rules read, and the inline backgrounds written onto the\r\n * AppFrame columns. Used when no palette is available and at teardown — without\r\n * it the last color's surfaces outlive the color that produced them. */\r\nfunction clearOwnedSurfaces(): void {\r\n discoverParts()\r\n const root = document.documentElement\r\n for (const name of OWNED_SURFACE_VARS) root.style.removeProperty(name)\r\n for (const el of [frameEl, centerEl, detailsEl]) el?.style.removeProperty('background')\r\n}\r\n\r\n// Solid surface tokens grouped by which interface-opacity slider owns them.\r\n// Every member is re-emitted with per-part alpha so surfaces over the wallpaper\r\n// (composer input, elevated buttons, menu panels) can go translucent — not just\r\n// the layered bg/sidebar tokens. The two menu fills are owned by the card slider\r\n// and must always travel together: --dsw-specific-menu is what overlays paint\r\n// (dropdowns, slash-trigger menu, popovers around the dialog) and\r\n// --dsw-menu-surface-fill is what the shared MenuSurface material paints, which\r\n// dsh 0.1.7 aliases the former to. Re-emitting only one of them leaves a menu\r\n// panel on one fill and its sticky group headings on the other — the solid band\r\n// across the model selector's provider rows. The Cordis panel shares\r\n// --dsw-specific-menu but is re-scoped to the input slider via INPUT_BLUR_RULE.\r\nconst OPACITY_TOKEN_GROUPS: Array<{ part: keyof PartOpacities; names: string[] }> = [\r\n { part: 'bg', names: ['--dsw-alias-bg-base'] },\r\n { part: 'sidebar', names: ['--dsw-specific-sidebar-fill'] },\r\n { part: 'card', names: ['--dsw-alias-bg-layer-1', '--dsw-alias-bg-layer-2', '--dsw-alias-bg-layer-3', '--dsw-specific-menu', '--dsw-menu-surface-fill'] },\r\n { part: 'input', names: ['--dsw-specific-input-major'] },\r\n]\r\n\r\n// Plugin-owned variables the opacity-bearing tokens read from. They live as\r\n// inline custom props on <html>, so a slider drag rewrites only those few values\r\n// instead of re-parsing/re-matching the whole body token rule on every tick —\r\n// the difference is critical when a large wallpaper sits under the interface.\r\nconst OPACITY_VARS: Record<string, string> = {\r\n '--dsw-alias-bg-base': '--dsh-any-op-bg',\r\n '--dsw-specific-sidebar-fill': '--dsh-any-op-sidebar',\r\n '--dsw-alias-bg-layer-1': '--dsh-any-op-card-1',\r\n '--dsw-alias-bg-layer-2': '--dsh-any-op-card-2',\r\n '--dsw-alias-bg-layer-3': '--dsh-any-op-card-3',\r\n '--dsw-specific-input-major': '--dsh-any-op-input',\r\n // The MenuSurface material under a menu panel and the overlay fill its sticky\r\n // headings paint are the same value on a 0.1.7 host, so they read the same\r\n // plugin-owned variable — one slider, one alpha, no seam between them.\r\n '--dsw-specific-menu': '--dsh-any-op-menu',\r\n '--dsw-menu-surface-fill': '--dsh-any-op-menu',\r\n}\r\n\r\n// Fingerprint of the non-alpha token base (palette source + color pick +\r\n// scheme verdict). The static body rule is only rebuilt when it changes; a drag\r\n// never touches it.\r\nlet baseTokenKey = ''\r\n\r\n// ── Palette source ────────────────────────────────────────────────────────────\r\n// Every surface is painted from ONE palette at a time:\r\n// * a rule WITH a color → the plugin's generated token set;\r\n// * a rule WITHOUT a color → the host's own alias tokens, read back out of the\r\n// live cascade, so \"follow the system theme\" keeps the wallpaper showing and\r\n// the Interface-page sliders working instead of dropping every surface back\r\n// to the host as an opaque plate.\r\n// Both feed the same writers (the body token rule, the per-part alpha variables,\r\n// the dialog/trajectory scoping), so there is never a state where one surface is\r\n// painted from one palette and another from the other one.\r\nconst HOST_SURFACE_TOKENS: string[] = Object.keys(OPACITY_VARS)\r\n\r\n/** Plugin-owned variables the scoped dialog/trajectory rules read. */\r\nconst SETTINGS_SURFACE_VARS = [\r\n '--dsh-any-bg-settings-surface',\r\n '--dsh-any-bg-settings-layer-1',\r\n '--dsh-any-bg-settings-layer-2',\r\n '--dsh-any-bg-settings-layer-3',\r\n]\r\nconst TRAJECTORY_SURFACE_VARS = [\r\n '--dsh-any-traj-layer-1',\r\n '--dsh-any-traj-layer-2',\r\n '--dsh-any-traj-layer-3',\r\n]\r\nconst OWNED_SURFACE_VARS = [...SETTINGS_SURFACE_VARS, ...TRAJECTORY_SURFACE_VARS]\r\n\r\ninterface Palette {\r\n /** True while the palette is the plugin's own (the rule carries a color). */\r\n own: boolean\r\n tokens: Record<string, string>\r\n}\r\n\r\nlet hostProbe: HTMLElement | null = null\r\n\r\n/** Resolve any color the engine understands (hex, rgb()/hsl(), a var() chain,\r\n * color-mix(), …) to its USED value: only a used color can be re-emitted with\r\n * an alpha. Returns null when the engine rejects the value. */\r\nfunction resolveCssColor(raw: string): string | null {\r\n const value = raw.trim()\r\n if (value === '') return null\r\n if (hostProbe === null) {\r\n hostProbe = document.createElement('span')\r\n hostProbe.setAttribute('aria-hidden', 'true')\r\n hostProbe.style.cssText = 'position:absolute;width:0;height:0;pointer-events:none'\r\n }\r\n if (!hostProbe.isConnected) document.body.appendChild(hostProbe)\r\n // Reset first: a rejected value must not be mistaken for the previous one.\r\n hostProbe.style.color = ''\r\n hostProbe.style.color = value\r\n if (hostProbe.style.color === '') return null\r\n return getComputedStyle(hostProbe).color || null\r\n}\r\n\r\n/** Read the host's own surface colors out of the live cascade. */\r\nfunction readHostPalette(): Palette | null {\r\n const sheet = tokenStyleEl\r\n // Our token rule re-emits the very names being asked for, so it has to be\r\n // muted while reading or the readback would return the palette we are leaving.\r\n // No paint can happen in between: the flag is set and cleared in one task.\r\n const muted = sheet !== null && sheet.isConnected && !sheet.disabled\r\n if (muted) sheet!.disabled = true\r\n try {\r\n const computed = getComputedStyle(document.body)\r\n const tokens: Record<string, string> = {}\r\n for (const name of HOST_SURFACE_TOKENS) {\r\n const used = resolveCssColor(computed.getPropertyValue(name))\r\n if (used !== null) tokens[name] = used\r\n }\r\n // Without a base surface there is no palette to paint from: the caller hands\r\n // every surface back to the host instead.\r\n return tokens['--dsw-alias-bg-base'] === undefined ? null : { own: false, tokens }\r\n } finally {\r\n if (muted) sheet!.disabled = false\r\n }\r\n}\r\n\r\n// The readback costs a style recalculation and applyWp runs on every viewport\r\n// frame, so the last result is reused briefly. The theme-reset watch drops it on\r\n// any scheme change; the TTL covers a host palette rewritten without one.\r\nlet hostPaletteCache: { at: number; palette: Palette | null } | null = null\r\nconst HOST_PALETTE_TTL_MS = 1000\r\n\r\nexport function invalidateHostPalette(): void { hostPaletteCache = null }\r\n\r\nfunction hostPalette(): Palette | null {\r\n const now = Date.now()\r\n if (hostPaletteCache !== null && now - hostPaletteCache.at < HOST_PALETTE_TTL_MS) return hostPaletteCache.palette\r\n const read = readHostPalette()\r\n hostPaletteCache = { at: now, palette: read }\r\n return read\r\n}\r\n\r\n/** The palette every surface is currently painted from. */\r\nfunction palette(): Palette | null {\r\n if (!rHasColor()) return hostPalette()\r\n const [h, s, l] = rColor()\r\n return { own: true, tokens: genTokens(h, s, l).tokens }\r\n}\r\n\r\n/** A resolved color with a new alpha. The plugin's own tokens are `hsl()` and\r\n * the host's alias tokens resolve to hex, both of which `toRgba` parses; a host\r\n * publishing an already-composited value (`color(…)`, `oklab(…)`, …) cannot be\r\n * parsed there, and emitting it unchanged would paint an OPAQUE surface — the\r\n * one outcome the transparent-surface design must never fall back to. Those go\r\n * through `color-mix` instead. */\r\nfunction withAlpha(color: string, alpha: number): string {\r\n const converted = toRgba(color, alpha)\r\n if (/^(rgb|hsl)a?\\(/i.test(converted)) return converted\r\n const pct = Math.round(Math.max(0, Math.min(1, alpha)) * 100)\r\n return `color-mix(in srgb, ${color} ${pct}%, transparent)`\r\n}\r\n\r\n/**\r\n * The color scheme the HOST's own preference resolves to, pushed in by the\r\n * browser half (the theme service knows it, custom themes included). `null`\r\n * means \"unknown\", which is the only case where the plugin falls back to the\r\n * preference the host's boot script published and to the OS query itself.\r\n */\r\nlet hostSchemeDark: boolean | null = null\r\n\r\nexport function setHostScheme(dark: boolean | null): void { hostSchemeDark = dark }\r\n\r\nfunction resolveHostDark(): boolean {\r\n if (typeof hostSchemeDark === 'boolean') return hostSchemeDark\r\n // The host's boot script publishes the preference it resolved\r\n // (`html[data-ds-theme-source]`) before any plugin runs.\r\n const source = document.documentElement.dataset.dsThemeSource\r\n if (source === 'dark') return true\r\n if (source === 'light') return false\r\n try { return window.matchMedia('(prefers-color-scheme: dark)').matches } catch { return false }\r\n}\r\n\r\n/**\r\n * Keep `data-ds-dark-theme` in the HOST's own form (a boolean attribute) while\r\n * the plugin does not own a palette.\r\n *\r\n * The plugin overwrites that flag whenever it owns a palette — including\r\n * REMOVING it to force a light one — and the host only re-projects the flag on a\r\n * theme change. So a flag the plugin dropped can stick: the host keeps painting\r\n * its light palette on a dark system, the readback then hands those light\r\n * surfaces back to the plugin, and the interface stays light until some\r\n * unrelated event happens to re-run an apply. Restoring the flag from the\r\n * resolved scheme closes that hole, and the write is skipped when it already\r\n * matches so this never churns the theme observer.\r\n */\r\nexport function adoptHostScheme(): void {\r\n const dark = resolveHostDark()\r\n const current = document.body.getAttribute(DARK_ATTR)\r\n if (dark) {\r\n if (current !== '') document.body.setAttribute(DARK_ATTR, '')\r\n } else if (current !== null) {\r\n document.body.removeAttribute(DARK_ATTR)\r\n }\r\n}\r\n\r\n/** Re-read the host palette and repaint from it when it moved. Called while a\r\n * color-less rule is active (the host can re-project its palette at any time,\r\n * with no event of ours to hang a repaint on). */\r\nexport function refreshSystemTheme(): void {\r\n adoptHostScheme()\r\n invalidateHostPalette()\r\n applyCustomTokens(rOps())\r\n}\r\n\r\n// Coalesce slider-driven token updates to one rAF: a single drag fires several\r\n// input events per frame, and every full re-apply repaints expensive regions\r\n// over a large wallpaper. Batching keeps at most one update per frame.\r\nlet pendingOps: PartOpacities | null = null\r\nlet tokensRaf: number | null = null\r\n\r\nexport function applyCustomTokens(ops: PartOpacities): void {\r\n pendingOps = ops\r\n if (tokensRaf !== null) return\r\n tokensRaf = requestAnimationFrame(() => {\r\n tokensRaf = null\r\n if (pendingOps === null) return\r\n const o = pendingOps\r\n pendingOps = null\r\n applyCustomTokensNow(o)\r\n })\r\n}\r\n\r\n// Only the main-bg slider retints the center/details columns; keys on\r\n// baseTokenKey + ops.bg so a sidebar/card/input drag never rewrites them.\r\nlet lastBgKey = ''\r\n\r\nfunction applyCustomTokensNow(ops: PartOpacities): void {\r\n const src = palette()\r\n if (src === null) {\r\n // Nothing to paint from: drop the token rule too, then hand every\r\n // plugin-owned surface — and the scheme flag — back to the host rather than\r\n // leaving the previous palette's values in place.\r\n clearCustomTokens()\r\n clearOwnedSurfaces()\r\n adoptHostScheme()\r\n return\r\n }\r\n const { own, tokens } = src\r\n const [h, s, l] = rColor()\r\n try {\r\n const forceDark = own && l < 0.55\r\n // The fingerprint carries the source, so switching between the two palettes\r\n // always rewrites the rule, even when the numbers happen to coincide.\r\n const key = own\r\n ? `own:${h}|${s}|${l}`\r\n : `host:${HOST_SURFACE_TOKENS.map(n => tokens[n] ?? '').join('|')}`\r\n if (key !== baseTokenKey) {\r\n // Drive the base-palette switch with a plugin-specific value so the\r\n // gradient rule never matches a host dark-mode flag; color-scheme makes\r\n // native controls (select popups) follow the forced palette. Both ride the\r\n // stylesheet (not inline styles) so the host presenter clearing body\r\n // inline styles on boot can't drop them, and the !important rule survives\r\n // that clearing too.\r\n if (own) {\r\n if (forceDark) document.body.setAttribute(DARK_ATTR, OWN_SCHEME)\r\n else document.body.removeAttribute(DARK_ATTR)\r\n } else {\r\n adoptHostScheme()\r\n }\r\n const decls: string[] = own ? [`color-scheme:${forceDark ? 'dark' : 'light'}`] : []\r\n for (const [name, value] of Object.entries(tokens)) {\r\n const opVar = OPACITY_VARS[name]\r\n decls.push(`${name}:${opVar !== undefined ? `var(${opVar})` : value}!important`)\r\n }\r\n ensureTokenStyle().textContent = `body{${decls.join(';')}}`\r\n if (own) {\r\n // Drop inline tokens left by earlier builds so the stylesheet is the single source of truth.\r\n for (const name of appliedTokenNames) document.body.style.removeProperty(name)\r\n appliedTokenNames = Object.keys(tokens)\r\n }\r\n // Recorded only once the rule is in: a write that threw must be retried by\r\n // the next apply instead of being skipped by this fingerprint forever.\r\n baseTokenKey = key\r\n }\r\n // Cheap per-drag update: only the surface alpha vars move on <html>.\r\n const root = document.documentElement\r\n for (const g of OPACITY_TOKEN_GROUPS) {\r\n for (const name of g.names) {\r\n root.style.setProperty(OPACITY_VARS[name], withAlpha(tokens[name] ?? '#000', ops[g.part]))\r\n }\r\n }\r\n // The Cordis panel keeps its own input-slider alpha (see INPUT_BLUR_RULE).\r\n root.style.setProperty('--dsh-any-op-menu-cordis', withAlpha(tokens['--dsw-specific-menu'] ?? '#000', ops.input))\r\n const bgKey = `${baseTokenKey}|${ops.bg}`\r\n if (bgKey !== lastBgKey) { lastBgKey = bgKey; applyPartOpacities(ops) }\r\n } catch {\r\n // ignore\r\n }\r\n}\r\n\r\n// ── Settings panel opacity ─────────────────────────────────────────────────────\r\n// The settings modal is the only aria-modal dialog identifying itself with\r\n// aria-labelledby, so this selector scopes translucency to the settings panel.\r\n// The surface (--dsw-alias-bg-layer-2) is re-emitted with an alpha through a\r\n// plugin-owned variable so the panel keeps its color while fading.\r\n\r\nconst SETTINGS_PANEL_SEL = '[role=\"dialog\"][aria-modal=\"true\"][aria-labelledby]'\r\nexport const SETTINGS_STYLE_RULE =\r\n `${SETTINGS_PANEL_SEL}{` +\r\n `background:var(--dsh-any-bg-settings-surface,var(--dsw-alias-bg-layer-2));` +\r\n `backdrop-filter:var(--dsh-any-blur-settings,none);` +\r\n `}` +\r\n // Re-scope the dialog's layer tokens to plugin-owned variables so every\r\n // surface inside the dialog follows the settings opacity slider only. Gated on\r\n // the plugin owning a palette (see THEMED_ATTR): these three declarations have\r\n // no host fallback, so they may only be live while `applySettingsOverrides`\r\n // writes the variables they read.\r\n `html[${THEMED_ATTR}] ${SETTINGS_PANEL_SEL}{` +\r\n `--dsw-alias-bg-layer-1:var(--dsh-any-bg-settings-layer-1);` +\r\n `--dsw-alias-bg-layer-2:var(--dsh-any-bg-settings-layer-2);` +\r\n `--dsw-alias-bg-layer-3:var(--dsh-any-bg-settings-layer-3)}` +\r\n // Option-panel blur inside the dialog, owned by the card blur slider.\r\n `${SETTINGS_PANEL_SEL} .dab-card{backdrop-filter:var(--dsh-any-blur-card-panels,none);-webkit-backdrop-filter:var(--dsh-any-blur-card-panels,none)}`\r\n\r\n// Input/control surface blur. The composer card and the Cordis panel expose\r\n// stable host data attributes ([data-composer-card], [data-cordis-panel]), so\r\n// the backdrop is attached via a stylesheet rule rather than element discovery.\r\n// The Cordis panel shares the --dsw-specific-menu token with the dialog's\r\n// option boxes, but it stays owned by the input slider — the re-scope below\r\n// keeps it there now that the menu token itself follows the card slider. Note\r\n// the input slider must NOT drive the button-elevated-fill /\r\n// button-floating-hover tokens: the settings panel's own controls (slider\r\n// thumbs, .dab-btn, segmented thumb) are painted from those same tokens, so\r\n// tinting them would bleach the panel's own UI.\r\nexport const INPUT_BLUR_RULE =\r\n '[data-composer-card],[data-cordis-panel]{' +\r\n '-webkit-backdrop-filter:var(--dsh-any-input-blur,none);' +\r\n 'backdrop-filter:var(--dsh-any-input-blur,none)}' +\r\n '[data-cordis-panel]{--dsw-specific-menu:var(--dsh-any-op-menu-cordis)!important}'\r\n\r\nfunction applyInputBlur(px: number): void {\r\n if (px > 0) document.documentElement.style.setProperty('--dsh-any-input-blur', `blur(${px}px)`)\r\n else document.documentElement.style.removeProperty('--dsh-any-input-blur')\r\n}\r\n\r\n// Placeholder/hint text inside the composer and the plugin's own input\r\n// surfaces: rendered with the weak caption token (distinct from real input)\r\n// plus italic, so an empty box is never mistaken for typed content.\r\nexport const PLACEHOLDER_RULE =\r\n '[data-composer-card] textarea::placeholder,' +\r\n '[data-composer-card] input::placeholder,' +\r\n '[data-composer-card] [contenteditable]::placeholder,' +\r\n '[data-cordis-panel] input::placeholder,' +\r\n '[data-cordis-panel] textarea::placeholder,' +\r\n '.dab-input::placeholder,' +\r\n '.dab-input textarea::placeholder,' +\r\n '.dab-input input::placeholder' +\r\n '{color:var(--dsh-any-placeholder,var(--dsw-alias-label-caption,#8a8f98))!important;font-style:italic;opacity:.85}'\r\n\r\nexport function applySettingsOverrides(op: number): void {\r\n // Follows whichever palette is in force: the rule's own tokens, or the host's\r\n // own surfaces while the rule follows the system theme. A token the palette\r\n // does not carry has its variable REMOVED — leaving the previous color's value\r\n // behind is exactly the stale surface this used to show.\r\n const tokens = palette()?.tokens ?? {}\r\n const root = document.documentElement\r\n const write = (name: string, token: string): void => {\r\n const value = tokens[token]\r\n if (value === undefined) root.style.removeProperty(name)\r\n else root.style.setProperty(name, withAlpha(value, op))\r\n }\r\n // Always written explicitly (including 100%) — removing them would make\r\n // SETTINGS_STYLE_RULE fall back to the body layer tokens that\r\n // applyCustomTokens rewrites with the homepage card alpha.\r\n write('--dsh-any-bg-settings-surface', '--dsw-alias-bg-layer-2')\r\n // Dialog-scoped layer overrides consumed by SETTINGS_STYLE_RULE; opacity\r\n // follows the settings slider only (the card slider reaches panels via blur).\r\n write('--dsh-any-bg-settings-layer-1', '--dsw-alias-bg-layer-1')\r\n write('--dsh-any-bg-settings-layer-2', '--dsw-alias-bg-layer-2')\r\n write('--dsh-any-bg-settings-layer-3', '--dsw-alias-bg-layer-3')\r\n}\r\n\r\n// ── Trajectory view opacity ──────────────────────────────────────────────\r\n// The trajectory view's own panels fully cover the root, so retinting only the\r\n// root background is invisible. Re-scope the view root's layer tokens to\r\n// plugin-owned variables so every surface follows the trajectory slider.\r\nexport const TRAJECTORY_STYLE_RULE =\r\n // Gated like the settings re-scope: see THEMED_ATTR.\r\n `html[${THEMED_ATTR}] [data-conversation-composer-overlay]{` +\r\n // No fallback inside var(): a self-referential fallback would be a cycle.\r\n '--dsw-alias-bg-layer-1:var(--dsh-any-traj-layer-1);' +\r\n '--dsw-alias-bg-layer-2:var(--dsh-any-traj-layer-2);' +\r\n '--dsw-alias-bg-layer-3:var(--dsh-any-traj-layer-3)}'\r\n\r\nexport function applyTrajectoryOverrides(op: number): void {\r\n // Always written explicitly so the view stays owned by this slider at 100%,\r\n // and removed per token the palette lacks (see applySettingsOverrides).\r\n const tokens = palette()?.tokens ?? {}\r\n const root = document.documentElement\r\n const write = (name: string, token: string): void => {\r\n const value = tokens[token]\r\n if (value === undefined) root.style.removeProperty(name)\r\n else root.style.setProperty(name, withAlpha(value, op))\r\n }\r\n write('--dsh-any-traj-layer-1', '--dsw-alias-bg-layer-1')\r\n write('--dsh-any-traj-layer-2', '--dsw-alias-bg-layer-2')\r\n write('--dsh-any-traj-layer-3', '--dsw-alias-bg-layer-3')\r\n}\r\n\r\n// ── File-preview panel (right sidebar) ────────────────────────────────────\r\n// Clicking a file opens the host's right panel, whose visible surface is painted\r\n// from `background: var(--dsw-alias-bg-base)` — the exact token the\r\n// main-background slider re-emits with its own alpha. The panel was therefore a\r\n// second, unnamed copy of the main background with no control of its own; this\r\n// card takes it over, on whichever element the host paints that surface.\r\n//\r\n// dsh 0.1.7 moved the paint off the panel: the container lost its background and\r\n// became the slide / fullscreen viewport, and it stays mounted at its full width\r\n// for the whole session — collapsing it only slides the dock out (`transform` +\r\n// `visibility`, never `display`). A surface (plus a backdrop-filter) written on\r\n// that container therefore covers the empty right half of the frame even with\r\n// the panel closed, which is the permanent frosted plate 0.1.7 shows. The dock's\r\n// own tab hosts are what the host paints now, so the card follows them:\r\n//\r\n// 0.1.7+ the dock's tab hosts — `[data-dockkit-content]` (and the\r\n// `[data-dockkit-empty]` seat of an empty pane), painted by the host\r\n// from the same token and hidden with `visibility`, so the card rides\r\n// the host's own open/close and slide transitions for free. Floating\r\n// panes are excluded exactly as the host excludes them.\r\n// older the panel itself, which used to carry that background on its hashed\r\n// class. `:has()` keeps the two apart, so the alpha is never painted\r\n// twice over on a 0.1.7 host.\r\n//\r\n// The selectors use data attributes (not the hashed CSS-module classes) and\r\n// `!important` outranks the host's class rule. The `var()` fallback keeps the\r\n// host's own value until a rule with a color supplies one, so a color-less rule\r\n// changes nothing here.\r\n//\r\n// backdrop-filter stays on the container — that is where this card has always\r\n// put it, and it keeps the panel to a single filter pass — but only while the\r\n// panel is open: an always-on filter is what turned the collapsed panel into a\r\n// plate.\r\nexport const RIGHTBAR_STYLE_RULE =\r\n 'div[data-sidebar-right-panel]:not(:has([data-dockkit-content],[data-dockkit-empty]))[data-sidebar-right-open],' +\r\n 'div[data-sidebar-right-panel] [data-dockkit-content]:not([data-dockkit-float]),' +\r\n 'div[data-sidebar-right-panel] [data-dockkit-empty]{' +\r\n 'background:var(--dsh-any-bg-rightbar,var(--dsw-alias-bg-base))!important}' +\r\n 'div[data-sidebar-right-panel][data-sidebar-right-open]{' +\r\n '-webkit-backdrop-filter:var(--dsh-any-blur-rightbar,none);' +\r\n 'backdrop-filter:var(--dsh-any-blur-rightbar,none)}'\r\n\r\n/** Paint the file-preview panel's surface from its own slider. */\r\nexport function applyRightbarOverrides(op: number): void {\r\n const root = document.documentElement\r\n // The panel is painted from the palette in force like every other surface;\r\n // only when there is no palette at all (a host publishing none of the tokens\r\n // we re-emit) does it keep the host's own --dsw-alias-bg-base.\r\n const base = palette()?.tokens['--dsw-alias-bg-base']\r\n if (base === undefined) { root.style.removeProperty('--dsh-any-bg-rightbar'); return }\r\n root.style.setProperty('--dsh-any-bg-rightbar', withAlpha(base, op))\r\n}\r\n\r\n/** Extra backdrop frost for the file-preview panel (0 = no frost of its own). */\r\nfunction applyRightbarBlur(px: number): void {\r\n if (px > 0) document.documentElement.style.setProperty('--dsh-any-blur-rightbar', `blur(${px}px)`)\r\n else document.documentElement.style.removeProperty('--dsh-any-blur-rightbar')\r\n}\r\n\r\n// ── Per-part interface blur ───────────────────────────────────────────────────\r\n// The AppFrame columns use hashed CSS-module classes, so parts are located\r\n// structurally: the shell overlay carries a stable data attribute and the\r\n// sidebar/center/details columns are its three preceding siblings.\r\n//\r\n// backdrop-filter must NEVER go directly on a host part: it turns the element\r\n// into a containing block for fixed-positioned descendants, which would trap\r\n// the host's settings dialog inside the column. Each blurred part carries an\r\n// isolated ::before underlay holding the backdrop-filter instead.\r\nlet frameEl: HTMLElement | null = null\r\nlet sidebarEl: HTMLElement | null = null\r\nlet centerEl: HTMLElement | null = null\r\nlet detailsEl: HTMLElement | null = null\r\n\r\nconst PART_BLUR_CLASS = 'dab-part-blur'\r\nconst PART_UNDERLAY_CLASS = 'dab-part-underlay'\r\nconst PART_BLUR_RULE =\r\n `${PART_BLUR_CLASS}{isolation:isolate}` +\r\n `.${PART_UNDERLAY_CLASS}{position:absolute;inset:0;z-index:-1;pointer-events:none;border-radius:inherit;` +\r\n `backdrop-filter:var(--dsh-any-part-blur,none);-webkit-backdrop-filter:var(--dsh-any-part-blur,none)}`\r\n\r\nlet partBlurStyleEl: HTMLStyleElement | null = null\r\n\r\nfunction ensurePartBlurStyle(): void {\r\n if (partBlurStyleEl?.isConnected) return\r\n partBlurStyleEl = document.createElement('style')\r\n partBlurStyleEl.dataset.plugin = 'dsh-background-by-model-parts'\r\n markOwnSheet(partBlurStyleEl)\r\n partBlurStyleEl.textContent = PART_BLUR_RULE\r\n document.head.appendChild(partBlurStyleEl)\r\n}\r\n\r\nfunction discoverParts(): void {\r\n const overlay = document.querySelector<HTMLElement>('[data-shell-overlay]')\r\n if (overlay === null) return\r\n const frame = overlay.parentElement\r\n if (frame === null) return\r\n frameEl = frame\r\n const idx = Array.from(frame.children).indexOf(overlay)\r\n sidebarEl = (frame.children[idx - 3] as HTMLElement | undefined) ?? null\r\n centerEl = (frame.children[idx - 2] as HTMLElement | undefined) ?? null\r\n detailsEl = (frame.children[idx - 1] as HTMLElement | undefined) ?? null\r\n}\r\n\r\nfunction setBlur(el: HTMLElement | null, px: number): void {\r\n if (el === null) return\r\n const underlay = el.querySelector<HTMLDivElement>(`:scope > .${PART_UNDERLAY_CLASS}`)\r\n if (px > 0) {\r\n ensurePartBlurStyle()\r\n // The underlay is position:absolute and needs a positioned host: static\r\n // columns get relative (a layout no-op for flex items) that is restored on\r\n // clear; parts the host already positions keep their own scheme.\r\n if (!el.classList.contains(PART_BLUR_CLASS) && getComputedStyle(el).position === 'static') {\r\n el.style.position = 'relative'\r\n el.setAttribute('data-dab-pos-patched', '1')\r\n }\r\n el.classList.add(PART_BLUR_CLASS)\r\n if (underlay === null) {\r\n const node = document.createElement('div')\r\n node.className = PART_UNDERLAY_CLASS\r\n el.prepend(node)\r\n }\r\n el.style.setProperty('--dsh-any-part-blur', `blur(${px}px)`)\r\n } else {\r\n el.classList.remove(PART_BLUR_CLASS)\r\n el.style.removeProperty('--dsh-any-part-blur')\r\n underlay?.remove()\r\n if (el.getAttribute('data-dab-pos-patched') === '1') {\r\n el.style.removeProperty('position')\r\n el.removeAttribute('data-dab-pos-patched')\r\n }\r\n }\r\n}\r\n\r\nfunction applySettingsBlur(px: number): void {\r\n if (px > 0) document.documentElement.style.setProperty('--dsh-any-blur-settings', `blur(${px}px)`)\r\n else document.documentElement.style.removeProperty('--dsh-any-blur-settings')\r\n}\r\n\r\n/** Apply the main-background opacity to the center/details columns instead of\r\n * the frame. The frame's translucent bg-base sits UNDER the sidebar, so\r\n * reducing the main-bg opacity stacked a second alpha onto the sidebar; moving\r\n * the alpha onto the columns keeps the sidebar owned by its own slider. */\r\nfunction applyPartOpacities(ops: PartOpacities): void {\r\n discoverParts()\r\n if (frameEl === null) return\r\n const base = palette()?.tokens['--dsw-alias-bg-base']\r\n if (base === undefined) {\r\n // No palette to paint from: hand the columns back to the host instead of\r\n // leaving the last color's inline background on them.\r\n for (const el of [frameEl, centerEl, detailsEl]) el?.style.removeProperty('background')\r\n return\r\n }\r\n frameEl.style.background = 'transparent'\r\n if (centerEl !== null) centerEl.style.background = withAlpha(base, ops.bg)\r\n if (detailsEl !== null) detailsEl.style.background = withAlpha(base, ops.bg)\r\n}\r\n\r\n/** Blur of the option panels inside the settings dialog (.dab-card), owned by\r\n * the \"dialog option panel\" (card) blur slider. Written as a plugin-owned\r\n * variable consumed by SETTINGS_STYLE_RULE — deliberately NOT applied to the\r\n * homepage center/details columns, which this slider must never touch. */\r\nfunction applyCardPanelsBlur(px: number): void {\r\n if (px > 0) document.documentElement.style.setProperty('--dsh-any-blur-card-panels', `blur(${px}px)`)\r\n else document.documentElement.style.removeProperty('--dsh-any-blur-card-panels')\r\n}\r\n\r\n/** Apply per-part interface blur to the AppFrame columns + settings panel. */\r\nexport function applyPartBlurs(blurs: PartBlurs): void {\r\n discoverParts()\r\n // The bg blur frosts the wallpaper behind the main content columns (center +\r\n // details); the frame itself stays unblurred so the sidebar is never\r\n // double-frosted by both the bg and sidebar sliders.\r\n setBlur(frameEl, 0)\r\n setBlur(sidebarEl, blurs.sidebar)\r\n setBlur(centerEl, blurs.bg)\r\n setBlur(detailsEl, blurs.bg)\r\n applyCardPanelsBlur(blurs.card)\r\n applySettingsBlur(blurs.settings)\r\n applyInputBlur(blurs.input)\r\n applyRightbarBlur(blurs.rightbar)\r\n applyViewCards()\r\n}\r\n\r\n/** Live per-part blur update during slider drag (no full re-apply). */\r\nexport function setPartBlur(part: keyof PartBlurs, v: number): void {\r\n if (part === 'settings') { applySettingsBlur(v); return }\r\n if (part === 'card') { applyCardPanelsBlur(v); return }\r\n if (part === 'input') { applyInputBlur(v); return }\r\n if (part === 'rightbar') { applyRightbarBlur(v); return }\r\n if (part === 'chat' || part === 'trajectory') { applyViewCards(); return }\r\n discoverParts()\r\n if (part === 'bg') { setBlur(centerEl, v); setBlur(detailsEl, v) }\r\n else setBlur(sidebarEl, v)\r\n}\r\n\r\n// ── Conversation view treatments ────────────────────────────────────\r\n// The chat message column is styled as a real card (layer-1 surface + border +\r\n// 16px radius + 18px padding); the trajectory view gets NO card decoration —\r\n// its own panels fully cover the view root, so its opacity slider re-scopes the\r\n// layer tokens inside the view and its blur frosts the backdrop through the\r\n// standard root underlay.\r\n//\r\n// Host structure (deepseek-harness ui-conversation / ui-trajectory):\r\n// ConversationRoot\r\n// header — title + tabs, OUTSIDE the scrollport\r\n// [data-conversation-scroll] — the single scrollport\r\n// [data-chat-flow] ← chat column (flow content, NOT scrollable)\r\n// [data-conversation-composer-overlay] ← trajectory view root\r\n// [data-composer-seat] — sticky composer, a sibling\r\n// Cards are ALWAYS styled once their host exists — sliders at zero only turn\r\n// surface/border transparent, so the layout never reflows and the view cannot\r\n// jump when a slider leaves zero. Removal happens only at plugin teardown.\r\ninterface ViewCardSpec {\r\n sel: string\r\n mark: string\r\n /** Dataset key prefix holding the stashed pre-card inline values. */\r\n prev: string\r\n opacity: () => number\r\n blur: () => number\r\n /** Generic heuristic fallback (chat card only, hosts without the marker). */\r\n fallback?: boolean\r\n /** No card decoration — surfaces follow scoped layer tokens; only the blur\r\n * underlay is attached to the host element. */\r\n plain?: boolean\r\n}\r\n\r\nconst VIEW_CARDS: ViewCardSpec[] = [\r\n { sel: '[data-chat-flow]', mark: 'data-dab-chat-card', prev: 'dabChatPrev', opacity: rChatTextOpacity, blur: () => rBlurs().chat, fallback: true },\r\n { sel: '[data-conversation-composer-overlay]', mark: 'data-dab-traj-card', prev: 'dabTrajPrev', opacity: rTrajectoryOpacity, blur: () => rBlurs().trajectory, plain: true },\r\n]\r\n\r\nconst viewTargets: Array<HTMLElement | null> = VIEW_CARDS.map(() => null)\r\n\r\nfunction isScrollableY(el: HTMLElement): boolean {\r\n const oy = getComputedStyle(el).overflowY\r\n // 'overlay' covers Chromium's non-standard overflow value.\r\n return oy === 'auto' || oy === 'scroll' || oy === 'overlay'\r\n}\r\n\r\n/** Whether the subtree hosts the chat input (textarea / contenteditable /\r\n * textbox role) — used to keep the card off the input row. */\r\nfunction containsChatEditor(el: HTMLElement): boolean {\r\n return el.querySelector('textarea,[contenteditable=\"true\"],[contenteditable=\"\"],[contenteditable=\"plaintext-only\"],[role=\"textbox\"]') !== null\r\n}\r\n\r\n/** Walk down from a coarse candidate toward the actual message column. */\r\nfunction refineMessageColumn(start: HTMLElement): HTMLElement {\r\n let cur = start\r\n for (let depth = 0; depth < 10; depth++) {\r\n if (isScrollableY(cur)) break\r\n const kids = Array.from(cur.children).filter((k): k is HTMLElement => k instanceof HTMLElement)\r\n if (kids.length === 0) break\r\n const tallest = kids.reduce((a, b) => (b.clientHeight > a.clientHeight ? b : a))\r\n if (containsChatEditor(cur)) {\r\n const candidates = kids.filter(k => !containsChatEditor(k) && k.clientHeight >= cur.clientHeight * 0.4)\r\n if (candidates.length === 0) break\r\n cur = candidates.reduce((a, b) => (b.clientHeight > a.clientHeight ? b : a))\r\n continue\r\n }\r\n if (kids.length > 1 && tallest.clientHeight >= cur.clientHeight * 0.85) { cur = tallest; continue }\r\n break\r\n }\r\n return cur\r\n}\r\n\r\nfunction discoverViewTarget(idx: number, spec: ViewCardSpec): HTMLElement | null {\r\n if (centerEl === null || !document.body.contains(centerEl)) { viewTargets[idx] = null; return null }\r\n // The host marker always wins over a cached fallback (the view may not be\r\n // mounted yet when the plugin applies early).\r\n const marked = centerEl.querySelector<HTMLElement>(spec.sel)\r\n const cached = viewTargets[idx]\r\n if (marked !== null) {\r\n if (cached !== null && cached !== marked) { setBlur(cached, 0); restoreCardHost(cached, spec.mark, spec.prev, spec.plain === true) }\r\n viewTargets[idx] = marked\r\n return marked\r\n }\r\n if (cached !== null && centerEl.contains(cached)) return cached\r\n viewTargets[idx] = null\r\n if (spec.fallback !== true) return null\r\n // On the harness, an absent [data-chat-flow] just means the chat view is not\r\n // mounted (hero phase, trajectory tab) — settling on the whole scrollport\r\n // there would wrap the entire page in the card.\r\n if (centerEl.querySelector('[data-conversation-scroll]') !== null) return null\r\n // Marker-less hosts keep their layout until a slider moves.\r\n if (spec.opacity() <= 0 && spec.blur() <= 0) return null\r\n let best: HTMLElement | null = null\r\n let bestArea = 0\r\n for (const el of Array.from(centerEl.querySelectorAll<HTMLElement>('*'))) {\r\n if (!isScrollableY(el)) continue\r\n if (el.clientHeight < centerEl.clientHeight * 0.35) continue\r\n const area = el.clientWidth * el.clientHeight\r\n if (area > bestArea) { bestArea = area; best = el }\r\n }\r\n if (best === null) {\r\n for (const el of Array.from(centerEl.children)) {\r\n if (!(el instanceof HTMLElement)) continue\r\n if (el.clientHeight < centerEl.clientHeight * 0.5) continue\r\n if (el.clientHeight > (best?.clientHeight ?? 0)) best = el\r\n }\r\n }\r\n const refined = best !== null ? refineMessageColumn(best) : null\r\n viewTargets[idx] = refined\r\n return refined\r\n}\r\n\r\n/** Stash the host's own inline values so teardown restores them exactly. */\r\nfunction stashCardPrev(el: HTMLElement, prev: string, plain: boolean): void {\r\n const ds = el.dataset as Record<string, string | undefined>\r\n ds[prev + 'Bg'] = el.style.getPropertyValue('background')\r\n if (plain) return\r\n ds[prev + 'Border'] = el.style.getPropertyValue('border')\r\n ds[prev + 'Radius'] = el.style.getPropertyValue('border-radius')\r\n ds[prev + 'Padding'] = el.style.getPropertyValue('padding')\r\n}\r\n\r\n/** Undo the inline styling, restoring the host's previous inline values. */\r\nfunction restoreCardHost(el: HTMLElement, mark: string, prev: string, plain: boolean): void {\r\n if (!el.hasAttribute(mark)) return\r\n const ds = el.dataset as Record<string, string | undefined>\r\n const restore = (prop: string, v: string | undefined): void => {\r\n if (v !== undefined && v !== '') el.style.setProperty(prop, v)\r\n else el.style.removeProperty(prop)\r\n }\r\n restore('background', ds[prev + 'Bg'])\r\n if (!plain) {\r\n restore('border', ds[prev + 'Border'])\r\n restore('border-radius', ds[prev + 'Radius'])\r\n restore('padding', ds[prev + 'Padding'])\r\n delete ds[prev + 'Border']; delete ds[prev + 'Radius']; delete ds[prev + 'Padding']\r\n }\r\n delete ds[prev + 'Bg']\r\n el.removeAttribute(mark)\r\n}\r\n\r\n/** Teardown only: strip every view treatment and hand the hosts back untouched. */\r\nfunction removeViewCards(): void {\r\n VIEW_CARDS.forEach((spec, i) => {\r\n const el = viewTargets[i]\r\n if (el !== null) { setBlur(el, 0); restoreCardHost(el, spec.mark, spec.prev, spec.plain === true) }\r\n viewTargets[i] = null\r\n })\r\n}\r\n\r\n// ── Wide markdown tables ──────────────────────────────────────────────────────\r\n// DSH intentionally lets `.md-table-wide` bleed outside the text column. That\r\n// bleed only becomes visible once the chat surface gains a visible border, i.e.\r\n// when the chat region opacity or blur is non-zero. Under that same condition,\r\n// pull the table back inside the column and let it scroll horizontally.\r\nconst TABLE_FIX_RULE = [\r\n '.md-table-wide {',\r\n ' --dsh-table-spare: 0px !important;',\r\n ' --dsh-table-lead: 0px !important;',\r\n ' box-sizing: border-box !important;',\r\n ' width: 100% !important;',\r\n ' max-width: 100% !important;',\r\n ' margin-left: 0 !important;',\r\n ' padding-left: 0 !important;',\r\n ' padding-bottom: 0 !important;',\r\n ' overflow-x: auto !important;',\r\n '}',\r\n].join('\\n')\r\nlet tableFixStyleEl: HTMLStyleElement | null = null\r\n\r\n/** Toggle the wide-table clamp according to the chat region's opacity & blur. */\r\nfunction syncTableFix(): void {\r\n const needed = rChatTextOpacity() > 0 || rBlurs().chat > 0\r\n if (!needed) {\r\n if (tableFixStyleEl !== null) { tableFixStyleEl.remove(); tableFixStyleEl = null }\r\n return\r\n }\r\n if (tableFixStyleEl === null) {\r\n tableFixStyleEl = document.createElement('style')\r\n tableFixStyleEl.dataset.plugin = 'dsh-background-by-model-table-fix'\r\n markOwnSheet(tableFixStyleEl)\r\n tableFixStyleEl.textContent = TABLE_FIX_RULE\r\n }\r\n if (!tableFixStyleEl.isConnected) document.head.appendChild(tableFixStyleEl)\r\n}\r\n\r\n/** Re-derive the conversation view cards from the current config. */\r\nexport function applyViewCards(): void {\r\n discoverParts()\r\n if (centerEl === null) return\r\n // The chat card is tinted from the palette in force, so a color-less rule gets\r\n // the host's own surface instead of the seed color's fallback tint.\r\n const surface = palette()?.tokens['--dsw-alias-bg-layer-1']\r\n VIEW_CARDS.forEach((spec, i) => {\r\n const target = discoverViewTarget(i, spec)\r\n if (target === null) return\r\n const plain = spec.plain === true\r\n const opacity = spec.opacity()\r\n const blurPx = spec.blur()\r\n if (!plain) {\r\n if (!target.hasAttribute(spec.mark)) stashCardPrev(target, spec.prev, false)\r\n // Mirrors .dab-card (layer-1 background, border, 16px radius, 18px\r\n // padding), written inline so it wins over host stylesheets; the opacity\r\n // slider drives surface alpha and fades the border with it.\r\n const borderAlpha = opacity > 0 ? Math.min(1, opacity * 1.5) : (blurPx > 0 ? 0.35 : 0)\r\n target.style.background = surface !== undefined ? withAlpha(surface, opacity) : 'transparent'\r\n target.style.border = surface !== undefined ? `1px solid ${withAlpha(surface, borderAlpha)}` : '1px solid transparent'\r\n target.style.borderRadius = '16px'\r\n target.style.padding = '18px'\r\n }\r\n // Plain views write no inline styles — only the blur underlay is hosted here.\r\n target.setAttribute(spec.mark, '1')\r\n setBlur(target, blurPx)\r\n })\r\n syncTableFix()\r\n}\r\n\r\nlet partsObserver: MutationObserver | null = null\r\n\r\n/** Watch for the AppFrame mounting so persisted blurs land even when the shell\r\n * renders after this plugin's apply. */\r\nexport function watchParts(): void {\r\n if (partsObserver !== null || typeof MutationObserver === 'undefined') return\r\n partsObserver = new MutationObserver(() => {\r\n if (frameEl !== null && sidebarEl !== null && centerEl !== null && detailsEl !== null && document.body.contains(frameEl)\r\n // Keep re-applying while any card host is absent or was swapped by the host.\r\n && viewTargets.every(el => el !== null && document.body.contains(el))) return\r\n applyPartBlurs(rBlurs())\r\n applyPartOpacities(rOps())\r\n })\r\n partsObserver.observe(document.body, { childList: true, subtree: true })\r\n}\r\n\r\nexport function stopWatchingParts(): void {\r\n partsObserver?.disconnect()\r\n partsObserver = null\r\n}\r\n\r\n// ── Theme-reset watchdog ──────────────────────────────────────────────────\r\n// The host re-asserts its own :root/body scheme rules on mount, on settings\r\n// adoption and after the plugin's startup assertion, toggling the\r\n// `data-ds-dark-theme` attribute off / to a host value — which would paint a\r\n// frame of light surfaces. Watch that flag and, whenever the plugin's own\r\n// value disappears, re-set it and re-emit the token stylesheet within the same\r\n// frame.\r\nlet themeObserver: MutationObserver | null = null\r\nlet themeRaf = 0\r\n\r\nfunction reassertScheme(): void {\r\n const [, , l] = rColor()\r\n if (l < 0.55) document.body.setAttribute(DARK_ATTR, OWN_SCHEME)\r\n else document.body.removeAttribute(DARK_ATTR)\r\n applyCustomTokens(rOps())\r\n}\r\n\r\n/** Re-assert the plugin's forced scheme whenever the host strips it, so a\r\n * refresh / cold-load / set-change never flashes a light frame. Also the point\r\n * where a host-side scheme flip is noticed while a color-less rule runs: that\r\n * rule paints from the host palette, so the readback is dropped and the\r\n * surfaces are re-emitted from the new one. */\r\nexport function watchThemeResets(): () => void {\r\n if (themeObserver !== null || typeof MutationObserver === 'undefined') return () => undefined\r\n themeObserver = new MutationObserver(() => {\r\n invalidateHostPalette()\r\n if (document.body.getAttribute(DARK_ATTR) === OWN_SCHEME) return\r\n if (!rHasColor()) {\r\n // Nothing to re-assert, but the host's own surfaces just changed under us.\r\n applyCustomTokens(rOps())\r\n return\r\n }\r\n if (themeRaf !== 0) return\r\n themeRaf = requestAnimationFrame(() => {\r\n themeRaf = 0\r\n if (document.body.getAttribute(DARK_ATTR) === OWN_SCHEME) return\r\n reassertScheme()\r\n })\r\n })\r\n themeObserver.observe(document.body, { attributes: true, attributeFilter: [DARK_ATTR] })\r\n themeObserver.observe(document.documentElement, { attributes: true, attributeFilter: [DARK_ATTR] })\r\n return () => {\r\n themeObserver?.disconnect()\r\n themeObserver = null\r\n }\r\n}\r\n\r\n// ── Wallpaper layer: two stacked layers, cross-faded on a rule switch ───────\r\n// The incoming image fades in ON TOP of the outgoing one at full opacity.\r\n// Fading the old one out at the same time would drop the composite below full\r\n// alpha at the midpoint — both images half transparent — and the interface\r\n// behind would flash through.\r\n//\r\n// A layer addresses its image by OBJECT URL (see displayImageOf in state):\r\n// assigning a `url(data:…)` background re-decodes the photo on every switch,\r\n// which is where a large wallpaper's stall comes from, while a blob URL is\r\n// served from the browser's memory cache after the first load.\r\nconst FADE_MS = 320\r\n\r\ninterface WpLayer {\r\n el: HTMLDivElement\r\n /** Display URL of the image painted on this layer; null when empty. */\r\n url: string | null\r\n}\r\n\r\nlet layers: [WpLayer, WpLayer] | null = null\r\n/** Index of the layer the user is looking at. */\r\nlet front = 0\r\n/** Index of the layer fading in right now, if any. */\r\nlet pending: 0 | 1 | null = null\r\nlet fadeTimer: number | null = null\r\n\r\nfunction createLayer(): WpLayer {\r\n const el = document.createElement('div')\r\n el.dataset.dabWpLayer = ''\r\n el.style.cssText = 'position:absolute;inset:0;opacity:0;background-repeat:no-repeat;background-position:center;'\r\n return { el, url: null }\r\n}\r\n\r\nfunction ensureWpContainer(): void {\r\n if (wpEl !== null && layers !== null && document.body.contains(wpEl)) return\r\n if (fadeTimer !== null) { window.clearTimeout(fadeTimer); fadeTimer = null }\r\n const a = createLayer()\r\n const b = createLayer()\r\n wpEl = document.createElement('div')\r\n wpEl.dataset.dabWp = ''\r\n wpEl.style.cssText = 'position:fixed;inset:0;z-index:-1;pointer-events:none;overflow:hidden;'\r\n wpEl.append(a.el, b.el)\r\n layers = [a, b]\r\n front = 0\r\n pending = null\r\n document.body.prepend(wpEl)\r\n}\r\n\r\n/** Drop the whole wallpaper layer (no rule carries an image). */\r\nfunction dropWpContainer(): void {\r\n if (fadeTimer !== null) { window.clearTimeout(fadeTimer); fadeTimer = null }\r\n pending = null\r\n front = 0\r\n layers = null\r\n wpEl?.remove()\r\n wpEl = null\r\n}\r\n\r\n/** Release one layer's image — the layer is fully covered when this is called. */\r\nfunction clearLayer(l: WpLayer): void {\r\n if (l.url === null) return\r\n l.url = null\r\n l.el.style.backgroundImage = ''\r\n l.el.style.backgroundSize = ''\r\n l.el.style.backgroundPosition = ''\r\n}\r\n\r\n/** Intrinsic-size cache for the center mode (native pixels of the current image). */\r\nlet imgNat: { url: string; w: number; h: number } | null = null\r\nfunction imageNatSize(url: string, cb: (w: number, h: number) => void): void {\r\n if (imgNat !== null && imgNat.url === url) { cb(imgNat.w, imgNat.h); return }\r\n const img = new Image()\r\n img.onload = () => {\r\n imgNat = { url, w: img.naturalWidth, h: img.naturalHeight }\r\n cb(img.naturalWidth, img.naturalHeight)\r\n }\r\n img.onerror = () => cb(0, 0)\r\n img.src = url\r\n}\r\n\r\n/** Paint one layer's image and its placement. The placement always follows the\r\n * ACTIVE rule: the incoming layer is painted right after a switch, and a\r\n * repaint of the same URL (framing edit, viewport resize) must use the rule's\r\n * current framing. */\r\nfunction paintLayer(l: WpLayer, url: string): void {\r\n const el = l.el\r\n l.url = url\r\n const bg = rBgState()\r\n const mode = rBgMode()\r\n const next = `url(\"${url}\")`\r\n // Skip re-setting the same URL — a redundant assignment can flash the layer\r\n // blank for a frame while it is re-resolved.\r\n if (el.style.backgroundImage !== next) {\r\n el.style.backgroundImage = next\r\n }\r\n if (mode === 'fit') {\r\n el.style.backgroundRepeat = 'no-repeat'\r\n if (bg.iw > 0) {\r\n // Contain-fit at zoom with the image center pinned to the committed\r\n // fractional viewport point, so the framed region survives viewport changes.\r\n const fit = Math.min(window.innerWidth / bg.iw, window.innerHeight / bg.ih)\r\n const w = bg.iw * fit * bg.zoom\r\n const h = bg.ih * fit * bg.zoom\r\n el.style.backgroundSize = `${w}px ${h}px`\r\n el.style.backgroundPosition = `${bg.x * window.innerWidth - w / 2}px ${bg.y * window.innerHeight - h / 2}px`\r\n } else {\r\n // Fresh image: match the editor's initial centered contain view.\r\n el.style.backgroundSize = 'contain'\r\n el.style.backgroundPosition = 'center'\r\n }\r\n } else if (mode === 'fill') {\r\n el.style.backgroundRepeat = 'no-repeat'\r\n el.style.backgroundSize = 'cover'\r\n el.style.backgroundPosition = 'center'\r\n } else if (mode === 'stretch') {\r\n el.style.backgroundRepeat = 'no-repeat'\r\n el.style.backgroundSize = '100% 100%'\r\n el.style.backgroundPosition = 'center'\r\n } else if (mode === 'tile') {\r\n el.style.backgroundRepeat = 'repeat'\r\n // background-size:auto resolves the intrinsic size per tile.\r\n el.style.backgroundSize = 'auto'\r\n el.style.backgroundPosition = '0px 0px'\r\n } else {\r\n // Center: native size, centered. The intrinsic size needs an async decode;\r\n // 'contain' keeps a sensible frame until it lands.\r\n el.style.backgroundRepeat = 'no-repeat'\r\n el.style.backgroundSize = 'contain'\r\n el.style.backgroundPosition = 'center'\r\n imageNatSize(url, (w, h) => {\r\n if (l.url !== url || el.style.backgroundImage !== next || rBgMode() !== 'center') return\r\n if (w > 0 && h > 0) {\r\n el.style.backgroundSize = `${w}px ${h}px`\r\n el.style.backgroundPosition = 'center'\r\n }\r\n })\r\n }\r\n}\r\n\r\n/** Whether a switch should animate: nothing to fade from, an invisible\r\n * wallpaper and a reduced-motion preference all switch instantly. */\r\nfunction canFade(from: WpLayer): boolean {\r\n if (from.url === null) return false\r\n if (rWop() <= 0.01) return false\r\n const mm = typeof window.matchMedia === 'function' ? window.matchMedia('(prefers-reduced-motion: reduce)') : null\r\n return mm === null || !mm.matches\r\n}\r\n\r\n/** End an in-flight fade: promote the incoming layer, free the one under it. */\r\nfunction finishFade(idx: 0 | 1): void {\r\n if (layers === null || pending !== idx) return\r\n if (fadeTimer !== null) { window.clearTimeout(fadeTimer); fadeTimer = null }\r\n pending = null\r\n front = idx\r\n const el = layers[idx].el\r\n // Re-asserted so a fade whose frames never ran (background tab) still ends on\r\n // the visible image.\r\n el.style.opacity = '1'\r\n el.style.willChange = ''\r\n // Covered from here on: drop its bytes so a second full-resolution image is\r\n // never left decoded behind the visible one.\r\n clearLayer(layers[idx === 0 ? 1 : 0])\r\n}\r\n\r\n/** Land an in-flight fade on its end state at once (another switch arrived). */\r\nfunction settleFade(): void {\r\n if (layers === null || pending === null) return\r\n const idx = pending\r\n if (fadeTimer !== null) { window.clearTimeout(fadeTimer); fadeTimer = null }\r\n pending = null\r\n front = idx\r\n const el = layers[idx].el\r\n el.style.transition = 'none'\r\n el.style.opacity = '1'\r\n el.style.willChange = ''\r\n clearLayer(layers[idx === 0 ? 1 : 0])\r\n}\r\n\r\n/** Abandon an in-flight fade: the layer it was leaving holds the wanted image. */\r\nfunction cancelFade(): void {\r\n if (layers === null || pending === null) return\r\n const idx = pending\r\n if (fadeTimer !== null) { window.clearTimeout(fadeTimer); fadeTimer = null }\r\n pending = null\r\n const el = layers[idx].el\r\n el.style.transition = 'none'\r\n el.style.opacity = '0'\r\n el.style.willChange = ''\r\n clearLayer(layers[idx])\r\n}\r\n\r\n/** Show `url` on the wallpaper layer, cross-fading from what it paints now. */\r\nfunction applyImageWp(url: string): void {\r\n ensureWpContainer()\r\n const ls = layers!\r\n if (pending !== null) {\r\n // A → B → A inside one fade: keep whichever layer already paints the wanted\r\n // image instead of queueing a third one.\r\n if (ls[pending].url === url) { paintLayer(ls[pending], url); applyWpEffects(); return }\r\n if (ls[front].url === url) { cancelFade(); paintLayer(ls[front], url); applyWpEffects(); return }\r\n settleFade()\r\n }\r\n if (ls[front].url === url) { paintLayer(ls[front], url); applyWpEffects(); return }\r\n const from = ls[front]\r\n const idx: 0 | 1 = front === 0 ? 1 : 0\r\n const target = ls[idx]\r\n const el = target.el\r\n // Rewind the incoming layer before its bytes land, so a stale image from an\r\n // earlier switch can never flash through while the new one rasterizes.\r\n el.style.transition = 'none'\r\n el.style.opacity = '0'\r\n el.style.zIndex = '1'\r\n from.el.style.zIndex = '0'\r\n paintLayer(target, url)\r\n applyWpEffects()\r\n if (!canFade(from)) {\r\n el.style.opacity = '1'\r\n front = idx\r\n clearLayer(from)\r\n return\r\n }\r\n // will-change promotes the layer in this frame, so the fade itself is a pure\r\n // compositor animation that survives the main-thread work a switch triggers\r\n // (theme re-registration, token rewrite, settings-panel re-render).\r\n el.style.willChange = 'opacity'\r\n pending = idx\r\n requestAnimationFrame(() => {\r\n if (pending !== idx || layers === null) return\r\n el.style.transition = `opacity ${FADE_MS}ms ease`\r\n el.style.opacity = '1'\r\n })\r\n fadeTimer = window.setTimeout(() => finishFade(idx), FADE_MS + 160)\r\n}\r\n\r\nfunction applyWpEffects(): void {\r\n if (wpEl === null || layers === null) return\r\n wpEl.style.opacity = String(rWop())\r\n // The blur sits on each LAYER rather than on the container: with the filter on\r\n // the parent, every frame of an opacity fade would re-run a full-screen blur\r\n // instead of just re-compositing the blurred surface.\r\n const blur = rBl()\r\n const filter = blur > 0 ? `blur(${blur}px)` : ''\r\n layers[0].el.style.filter = filter\r\n layers[1].el.style.filter = filter\r\n}\r\n\r\n/** Repaint the wallpaper layer, the token palette and every interface part from\r\n * the ACTIVE rule. This is the single entry point a rule switch goes through. */\r\nexport function applyWp(): void {\r\n const url = rWp()\r\n if (url) {\r\n applyImageWp(url)\r\n } else if (wpEl !== null) {\r\n // No background: tear down the layer but keep tokens/blur intact.\r\n dropWpContainer()\r\n }\r\n // A rule without a saved color follows the system theme: the plugin owns no\r\n // color of its own, so the surfaces come from the host's palette (see\r\n // `palette`) with the user's opacities applied — the wallpaper keeps showing\r\n // and the Interface sliders keep doing something, which is what \"follow the\r\n // system theme\" is expected to mean. THREE things have to be true before the\r\n // readback, or it answers with the wrong palette:\r\n // 1. our own body rule is out of the way (it re-emits the tokens being read);\r\n // 2. the scheme flag is the host's own again (we force/remove it while we own\r\n // a palette, and the host only re-projects on a theme change);\r\n // 3. the cached palette is dropped once, on the way in.\r\n if (!rHasColor() && !baseTokenKey.startsWith('host:')) {\r\n clearCustomTokens()\r\n invalidateHostPalette()\r\n }\r\n if (!rHasColor()) adoptHostScheme()\r\n const src = palette()\r\n // Marker for the no-fallback re-scope rules: they may only be live while the\r\n // variables they read are written (see THEMED_ATTR).\r\n document.documentElement.toggleAttribute(THEMED_ATTR, src !== null)\r\n if (src === null) {\r\n // No palette at all (a host publishing none of the surfaces we re-emit):\r\n // give every surface back to the host untouched instead of leaving ours.\r\n clearCustomTokens()\r\n clearOwnedSurfaces()\r\n }\r\n applyCustomTokens(rOps())\r\n applySettingsOverrides(rSop())\r\n applyTrajectoryOverrides(rTrajectoryOpacity())\r\n applyRightbarOverrides(rRightbarOpacity())\r\n applyPartBlurs(rBlurs())\r\n}\r\n\r\nexport function teardownWp(): void {\r\n dropWpContainer()\r\n clearCustomTokens()\r\n tokenStyleEl?.remove(); tokenStyleEl = null\r\n removeViewCards()\r\n document.documentElement.removeAttribute(THEMED_ATTR)\r\n document.body.style.removeProperty('color-scheme')\r\n // Every plugin-owned surface, including the AppFrame columns' inline\r\n // backgrounds and the palette readback that described them; the scheme flag is\r\n // handed back in the host's own form.\r\n clearOwnedSurfaces()\r\n adoptHostScheme()\r\n invalidateHostPalette()\r\n document.documentElement.style.removeProperty('--dsh-any-blur-settings')\r\n document.documentElement.style.removeProperty('--dsh-any-blur-card-panels')\r\n document.documentElement.style.removeProperty('--dsh-any-input-blur')\r\n document.documentElement.style.removeProperty('--dsh-any-bg-rightbar')\r\n document.documentElement.style.removeProperty('--dsh-any-blur-rightbar')\r\n for (const v of Object.values(OPACITY_VARS)) document.documentElement.style.removeProperty(v)\r\n if (tokensRaf !== null) { cancelAnimationFrame(tokensRaf); tokensRaf = null }\r\n pendingOps = null\r\n tableFixStyleEl?.remove(); tableFixStyleEl = null\r\n setBlur(frameEl, 0); setBlur(sidebarEl, 0); setBlur(centerEl, 0); setBlur(detailsEl, 0)\r\n stopWatchingParts()\r\n}\r\n\r\n/** Live wallpaper-opacity updates during slider drag (no full re-apply). */\r\nexport function setWpOpacity(v: number): void {\r\n if (wpEl) wpEl.style.opacity = String(v)\r\n}\r\n\r\n/** Live wallpaper-blur updates during slider drag (no full re-apply). */\r\nexport function setWpBlur(v: number): void {\r\n if (layers === null) return\r\n const filter = v > 0 ? `blur(${v}px)` : ''\r\n layers[0].el.style.filter = filter\r\n layers[1].el.style.filter = filter\r\n}\r\n","/**\n * Model → rule resolution.\n *\n * Two halves:\n * 1. `matchRule` — a pure function over the ordered rule list.\n * 2. `watchModel` — reports the current model whenever the session's durable\n * model selection changes.\n *\n * Sources, in the order they are consulted:\n *\n * a. **Which session is current** (`resolveMainSessionId` below) — the model is\n * read per session, so this hop answers before any other can. 0.1.7 moved it:\n * `sessions.list` stopped carrying a single `current` id, and the main view's\n * session is published by the `uiSession` service and marked by the list row\n * retained by `mainView`.\n * b. **The session's own durable model selection** —\n * `ctx.sessions.binding(id).session.projections.faceOf('modelSelection')`,\n * the same `{ lastUsed, next }` value the composer model seat and the\n * /model popup read. This is the authoritative per-session answer.\n * c. **`ctx.modelDirectories`** — the shared per-session directory\n * (ui-model-selection). It adds the provider-group catalog, so it is the\n * only source that can supply a display name, but it lives in that plugin's\n * own scope on some builds and is then invisible from here, hence optional.\n * d. **The host default model** — resolved by the CALLER as a last resort\n * (see index.tsx). It is a global default, NOT this session's selection, so\n * it is reported as `default` and the settings page says so.\n *\n * TIMING is load-bearing. `sessions` is published by the api-session-controller\n * client plugin, which this deployment loads AFTER this plugin's client bundle,\n * so `ctx.get('sessions')` is normally still undefined when `apply()` runs.\n * Giving up there — returning a no-op disposer — left the model pinned to the\n * host default for the whole session with nothing to retry it. The service is\n * now polled for until it appears, and `uiSession` (which can mount even later)\n * is picked up by the same poll because the session id is re-resolved on every\n * tick. Every hop reports a `note` when it cannot answer, so the settings page\n * can name the failing one instead of silently showing a value that is not this\n * session's model.\n */\nimport type {\n BgRule, Ctx, ModelDirectoryLike, ModelDirectoryResolverLike, ModelSelectionProjectionLike,\n ObservableFaceLike, SessionListSnapshotLike, SessionsServiceLike, UiSessionLike,\n} from './types'\n\n/** Rules that can actually paint: enabled and carrying an image slot. */\nfunction usable(rules: readonly BgRule[]): BgRule[] {\n return rules.filter(r => r.enabled && r.slot !== '')\n}\n\n/**\n * Resolve the rule for one model text.\n *\n * Top→bottom, first case-insensitive substring hit wins; an empty `match` never\n * hits on its own. When nothing hits, the FIRST usable rule is the fallback\n * (rule 1 deliberately doubles as both a matcher and the fallback).\n */\nexport function matchRule(\n rules: readonly BgRule[],\n modelText: string,\n): { rule: BgRule | null; matched: boolean } {\n const list = usable(rules)\n if (list.length === 0) return { rule: null, matched: false }\n const hay = modelText.toLowerCase()\n if (hay.trim() !== '') {\n for (const rule of list) {\n const needle = rule.match.trim().toLowerCase()\n if (needle === '') continue\n if (hay.includes(needle)) return { rule, matched: true }\n }\n }\n return { rule: list[0]!, matched: false }\n}\n\n/** Human-readable label of the model text an active rule matched against. */\nexport function modelLabelOf(text: string): string {\n const parts = text.split(/\\s+/).filter(p => p !== '')\n // The display name (last token, when the catalog provided one) reads best.\n return parts.length > 0 ? parts[parts.length - 1]! : ''\n}\n\n/** Look the current model's display name up in the shared catalog. */\nfunction displayNameOf(state: {\n groups?: ReadonlyArray<{ id?: string; models?: ReadonlyArray<{ id?: string; name?: string }> }>\n} | undefined, provider: string, model: string): string {\n if (model === '' || !Array.isArray(state?.groups)) return ''\n for (const group of state!.groups!) {\n if (group.id !== provider) continue\n for (const entry of group.models ?? []) {\n if (entry.id === model) return typeof entry.name === 'string' ? entry.name : ''\n }\n }\n return ''\n}\n\n/** Where the reported model text came from. */\nexport type ModelSource = 'session' | 'default'\n\n/**\n * Which hop could not answer when no per-session model was found. Surfaced in\n * the settings readout: without it, a broken hop is indistinguishable from\n * \"this session really is on the host default\".\n */\nexport type ModelNote = '' | 'no-service' | 'no-session' | 'no-projection' | 'empty-selection'\n\n/** How often to look for the sessions service that mounts after this plugin. */\nconst ATTACH_RETRY_MS = 400\n/** Stop looking after this many tries (~2 minutes). */\nconst ATTACH_RETRY_LIMIT = 300\n/** Safety re-read of every source, so a missed notification cannot pin a stale model. */\nconst POLL_MS = 1500\n\n/** One selection out of a `modelSelection` projection value. */\nfunction selectionOf(value: ModelSelectionProjectionLike | undefined): { provider: string; model: string } | null {\n const pick = value?.next ?? value?.lastUsed ?? null\n if (pick === null || typeof pick !== 'object') return null\n const provider = typeof pick.provider === 'string' ? pick.provider : ''\n const model = typeof pick.model === 'string' ? pick.model : ''\n if (provider === '' && model === '') return null\n return { provider, model }\n}\n\n/** A non-empty string id, or null. */\nfunction asId(value: unknown): string | null {\n return typeof value === 'string' && value !== '' ? value : null\n}\n\n/**\n * The id of the session the main view is showing.\n *\n * The model is read per session, so this hop has to answer before any of the\n * others can. 0.1.7 moved the answer: `sessions.list` stopped publishing a single\n * `current` id in favour of a row table (`ids` / `byId` / `phase`), and the main\n * view's session is now whatever holds a `mainView` retention — the same row the\n * host's own `uiSession.current` binding source is built from. Reading only\n * `list.current` therefore finds nothing on 0.1.7, and a plugin with no session\n * id can only ever fall back to rule 1: the background stops following the model.\n *\n * The hops are tried in order of authority and every one is optional, so this\n * answers on both host generations — and while `uiSession` is still mounting.\n */\nexport function resolveMainSessionId(\n uiCurrent: { key?: string } | undefined,\n snapshot: SessionListSnapshotLike | undefined,\n): string | null {\n // 0.1.7: the host's own answer, already resolved from list + retention.\n const fromUiSession = asId(uiCurrent?.key)\n if (fromUiSession !== null) return fromUiSession\n // ≤0.1.6: the list published the current id directly.\n const legacy = asId(snapshot?.current)\n if (legacy !== null) return legacy\n // 0.1.7 without `uiSession` yet: derive it from the retention the host uses.\n const byId = snapshot?.byId\n if (byId !== undefined && byId !== null) {\n for (const row of Object.values(byId)) {\n if ((row?.retainedBy?.mainView ?? 0) > 0) {\n const id = asId(row?.id)\n if (id !== null) return id\n }\n }\n }\n return null\n}\n\n/** Read `uiSession.current` (if that service is on this host) and resolve. */\nfunction mainSessionId(ctx: Ctx, list: ObservableFaceLike<SessionListSnapshotLike> | null): string | null {\n let uiCurrent: { key?: string } | undefined\n try {\n const ui = ctx.get('uiSession') as UiSessionLike | undefined\n uiCurrent = ui?.current?.getSnapshot?.()\n } catch {\n // Service absent (or not mounted yet) — the list retention below still answers.\n }\n return resolveMainSessionId(uiCurrent, list?.getSnapshot())\n}\n\n/**\n * Watch the current session's model selection.\n *\n * @param ctx - client root context.\n * @param onChange - called with the match text (provider + id + display name),\n * the best available label, which source answered, and — when nothing could be\n * read — the hop that failed.\n * @returns disposer.\n */\nexport function watchModel(\n ctx: Ctx,\n onChange: (text: string, label: string, source: ModelSource, note: ModelNote) => void,\n): () => void {\n let service: SessionsServiceLike | null = null\n let list: ObservableFaceLike<SessionListSnapshotLike> | null = null\n let offList: (() => void) | null = null\n let sessionId: string | null = null\n let directory: ModelDirectoryLike | null = null\n let offDirectory: (() => void) | null = null\n /** The session's own `modelSelection` projection face. */\n let projected: ObservableFaceLike<ModelSelectionProjectionLike> | null = null\n let offProjected: (() => void) | null = null\n let lastKey = '\\u0000'\n let poll: number | null = null\n let retry: number | null = null\n let retries = 0\n\n const release = (): void => {\n if (offDirectory !== null) { offDirectory(); offDirectory = null }\n if (offProjected !== null) { offProjected(); offProjected = null }\n directory = null\n projected = null\n }\n\n /** Bind the session's own durable model selection (the authoritative source). */\n const bindProjection = (id: string): void => {\n const svc = service\n if (svc === null) return\n try {\n let binding = typeof svc.binding === 'function' ? svc.binding(id) : undefined\n if (binding === undefined && typeof svc.scope === 'function') {\n // Materialize the scope, then resolve again: a session that is merely\n // listed has no binding yet.\n svc.scope(id)\n binding = typeof svc.binding === 'function' ? svc.binding(id) : undefined\n }\n const face = binding?.session?.projections?.faceOf?.('modelSelection')\n if (face === undefined || typeof face.subscribe !== 'function' || typeof face.getSnapshot !== 'function') return\n projected = face\n offProjected = face.subscribe(() => { emit(false) })\n } catch {\n projected = null\n offProjected = null\n }\n }\n\n const note = (): ModelNote => {\n if (service === null) return 'no-service'\n if (sessionId === null) return 'no-session'\n if (projected === null && directory === null) return 'no-projection'\n return 'empty-selection'\n }\n\n const emit = (force: boolean): void => {\n const state = directory?.store.getSnapshot()\n const fromDirectory = state?.current ?? null\n const sel = fromDirectory !== null\n ? { provider: fromDirectory.provider ?? '', model: fromDirectory.model ?? '' }\n : (() => {\n try { return selectionOf(projected?.getSnapshot()) } catch { return null }\n })()\n const provider = sel?.provider ?? ''\n const model = sel?.model ?? ''\n const name = displayNameOf(state, provider, model)\n const text = [provider, model, name].filter(p => p !== '').join(' ').trim()\n const noteValue: ModelNote = text === '' ? note() : ''\n const key = `${text}\\u0001${name}\\u0001${noteValue}`\n if (!force && key === lastKey) return\n lastKey = key\n onChange(text, name !== '' ? name : (model !== '' ? model : provider), 'session', noteValue)\n }\n\n const bind = (): void => {\n const id = mainSessionId(ctx, list)\n // Already bound to this session and holding at least one live source: only\n // refresh the value. A missing source keeps retrying on the poll below.\n if (id === sessionId && (directory !== null || projected !== null)) { emit(false); return }\n release()\n sessionId = id\n if (id !== null) {\n bindProjection(id)\n if (directory === null) {\n const directories = ctx.get('modelDirectories') as ModelDirectoryResolverLike | undefined\n if (directories !== undefined && typeof directories.directoryFor === 'function') {\n try {\n directory = directories.directoryFor(id)\n offDirectory = directory.store.subscribe(() => { emit(false) })\n // The advisory catalog (display names) loads lazily; a failure only\n // costs us the pretty name, never the match.\n const pending = directory.load?.()\n if (pending !== undefined && pending !== null && typeof (pending as Promise<unknown>).catch === 'function') {\n void (pending as Promise<unknown>).catch(() => undefined)\n }\n } catch {\n directory = null\n offDirectory = null\n }\n }\n }\n }\n // Forced: the sources may have appeared without the text changing (the host\n // default was showing and the session now agrees with it), and the settings\n // page must be able to correct its badge and its note.\n emit(true)\n }\n\n const stopRetry = (): void => {\n if (retry === null) return\n window.clearInterval(retry)\n retry = null\n }\n\n const tick = (): void => {\n if (list === null) return\n if (mainSessionId(ctx, list) !== sessionId || (directory === null && projected === null)) bind()\n else emit(false)\n }\n\n /**\n * Look the sessions service up. It arrives after this plugin's bundle on this\n * deployment, so the first attempt usually fails — which is exactly why this\n * is a retry loop rather than a one-shot lookup.\n */\n const attach = (): boolean => {\n const svc = ctx.get('sessions') as SessionsServiceLike | undefined\n if (svc === undefined || svc === null) return false\n const face = svc.list\n if (face === undefined || typeof face.subscribe !== 'function' || typeof face.getSnapshot !== 'function') return false\n service = svc\n list = face\n offList = face.subscribe(bind)\n if (poll === null) poll = window.setInterval(tick, POLL_MS)\n bind()\n return true\n }\n\n if (!attach()) {\n retry = window.setInterval(() => {\n retries++\n if (attach() || retries >= ATTACH_RETRY_LIMIT) stopRetry()\n }, ATTACH_RETRY_MS)\n }\n\n return () => {\n stopRetry()\n if (poll !== null) { window.clearInterval(poll); poll = null }\n if (offList !== null) { offList(); offList = null }\n service = null\n list = null\n release()\n }\n}\n","import type { ReactNode } from 'react'\r\n\r\n/** Sun glyph, migrated from @deepseek-ai/dsh-client-ui-primitives IconLightOutline16. */\r\nexport const SUN_PATHS = '<path d=\"M11.3496 8C11.3496 6.14985 9.85015 4.65039 8 4.65039C6.14985 4.65039 4.65039 6.14985 4.65039 8C4.65039 9.85015 6.14985 11.3496 8 11.3496C9.85015 11.3496 11.3496 9.85015 11.3496 8ZM12.6504 8C12.6504 10.5681 10.5681 12.6504 8 12.6504C5.43188 12.6504 3.34961 10.5681 3.34961 8C3.34961 5.43188 5.43188 3.34961 8 3.34961C10.5681 3.34961 12.6504 5.43188 12.6504 8Z\" fill=\"currentColor\"/><path d=\"M8.65039 0.5V2.5H7.34961V0.5H8.65039Z\" fill=\"currentColor\"/><path d=\"M8.65039 13.5V15.5H7.34961V13.5H8.65039Z\" fill=\"currentColor\"/><path d=\"M3.15808 2.24035L4.57229 3.65456L3.6525 4.57435L2.23829 3.16014L3.15808 2.24035Z\" fill=\"currentColor\"/><path d=\"M12.3505 11.4327L13.7647 12.8469L12.8449 13.7667L11.4307 12.3525L12.3505 11.4327Z\" fill=\"currentColor\"/><path d=\"M2.24537 12.8469L3.65958 11.4327L4.57937 12.3525L3.16516 13.7667L2.24537 12.8469Z\" fill=\"currentColor\"/><path d=\"M11.4377 3.65455L12.852 2.24033L13.7718 3.16012L12.3575 4.57434L11.4377 3.65455Z\" fill=\"currentColor\"/><path d=\"M0.5 7.35461H2.5V8.6554H0.5L0.5 7.35461Z\" fill=\"currentColor\"/><path d=\"M13.5 7.35461H15.5V8.6554H13.5V8.6554Z\" fill=\"currentColor\"/>'\r\n\r\nexport function SunIcon({ size = 16, className }: { size?: number; className?: string }) {\r\n return (\r\n <svg width={size} height={size} className={className} viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" dangerouslySetInnerHTML={{ __html: SUN_PATHS }} />\r\n )\r\n}\r\n\r\nfunction Glyph({ children, size = 16, className }: { children: ReactNode; size?: number; className?: string }) {\r\n return (\r\n <svg width={size} height={size} className={className} viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth={1.5} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\r\n {children}\r\n </svg>\r\n )\r\n}\r\n\r\nexport const DropletIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M8 1.9c2.4 2.8 4.3 5 4.3 7.1a4.3 4.3 0 1 1-8.6 0C3.7 6.9 5.6 4.7 8 1.9z\" /></Glyph>\r\n)\r\n\r\nexport const LayersIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M8 2.2 13.2 5 8 7.8 2.8 5 8 2.2z\" /><path d=\"M2.8 8.2 8 11l5.2-2.8\" /><path d=\"M2.8 11.2 8 14l5.2-2.8\" /></Glyph>\r\n)\r\n\r\nexport const PhotoIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><rect x=\"2\" y=\"3.2\" width=\"12\" height=\"9.6\" rx=\"2\" /><circle cx=\"5.7\" cy=\"6.3\" r=\"0.9\" /><path d=\"M14 10.4l-2.8-2.8-4.8 4.8\" /></Glyph>\r\n)\r\n\r\nexport const VideoIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><rect x=\"1.5\" y=\"4.2\" width=\"8.8\" height=\"7.6\" rx=\"2\" /><path d=\"M10.3 6.9l4.2-2.4v7l-4.2-2.4\" /></Glyph>\r\n)\r\n\r\nexport const TextIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M3 4.2h10M3 8h10M3 11.8h6.5\" /></Glyph>\r\n)\r\n\r\nexport const TrajectoryIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M2.5 3.2h11M2.5 6.6h11M2.5 10h11\" /><circle cx=\"4.4\" cy=\"3.2\" r=\"1.1\" /><circle cx=\"8\" cy=\"6.6\" r=\"1.1\" /><circle cx=\"11.4\" cy=\"10\" r=\"1.1\" /></Glyph>\r\n)\r\n\r\nexport const SlidersIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M2.5 4.5h4.9M11.6 4.5h1.9M2.5 11.5h1.9M8.6 11.5h4.9\" /><circle cx=\"9.5\" cy=\"4.5\" r=\"1.7\" /><circle cx=\"5.5\" cy=\"11.5\" r=\"1.7\" /></Glyph>\r\n)\r\n\r\nexport const SparkleIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M7.2 1.8l1.2 3.1 3.1 1.2-3.1 1.2-1.2 3.1-1.2-3.1L2.9 6.1 6 4.9l1.2-3.1z\" /><path d=\"M12 10.5l.5 1.2 1.2.5-1.2.5-.5 1.2-.5-1.2-1.2-.5 1.2-.5.5-1.2z\" /></Glyph>\r\n)\r\n\r\nexport const RefreshIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M13.2 8A5.2 5.2 0 1 1 11.5 4.2\" /><path d=\"M13.4 1.8v2.9h-2.9\" /></Glyph>\r\n)\r\n\r\nexport const DownloadIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M8 2.2v8\" /><path d=\"M4.6 7l3.4 3.4L11.4 7\" /><path d=\"M2.8 13.8h10.4\" /></Glyph>\r\n)\r\n\r\nexport const UploadIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M8 10.4V2.6\" /><path d=\"M4.6 5.8L8 2.4l3.4 3.4\" /><path d=\"M2.8 13.8h10.4\" /></Glyph>\r\n)\r\n\r\nexport const LinkIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M6.6 9.4 9.4 6.6\" /><path d=\"M5.9 11.1l-1.4 1.4a2.6 2.6 0 0 1-3.7-3.7L3.5 6.8\" /><path d=\"M10.1 4.9l1.4-1.4a2.6 2.6 0 0 1 3.7 3.7l-2.1 2.1\" /></Glyph>\r\n)\r\n\r\nexport const LockIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><rect x=\"3.6\" y=\"7.2\" width=\"8.8\" height=\"6\" rx=\"1.4\" /><path d=\"M5.6 7.2V5.4a2.4 2.4 0 0 1 4.8 0v1.8\" /></Glyph>\r\n)\r\n\r\nexport const TrashIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M2.8 4.4h10.4\" /><path d=\"M6.4 4.4V2.9h3.2v1.5\" /><path d=\"M4.4 4.4l.5 8.6h6.2l.5-8.6\" /></Glyph>\r\n)\r\n\r\nexport const EditIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M9.5 4l2.5 2.5\" /><path d=\"M3 13l.8-3L10 3.8 12.2 6 6 12.2 3 13z\" /></Glyph>\r\n)\r\n\r\nexport const PipetteIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><circle cx=\"8\" cy=\"8\" r=\"4.2\" /><path d=\"M8 1.6v2.6M8 11.8v2.6M1.6 8h2.6M11.8 8h2.6\" /></Glyph>\r\n)\r\n\r\nexport const CheckIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M3.2 8.6l3 3L12.8 5\" /></Glyph>\r\n)\r\n\r\nexport const AlertIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M8 2.6l5.4 9.8H2.6L8 2.6z\" /><path d=\"M8 6.8v2.4M8 11.4v.01\" /></Glyph>\r\n)\r\n\r\nexport const CopyIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><rect x=\"5.4\" y=\"5.4\" width=\"7.6\" height=\"7.6\" rx=\"1.6\" /><path d=\"M10.6 5.4V4.2a1.6 1.6 0 0 0-1.6-1.6H4.2a1.6 1.6 0 0 0-1.6 1.6v4.8a1.6 1.6 0 0 0 1.6 1.6h1.2\" /></Glyph>\r\n)\r\n\r\nexport const CanvasIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><rect x=\"2.2\" y=\"2.2\" width=\"11.6\" height=\"11.6\" rx=\"2\" /></Glyph>\r\n)\r\n\r\nexport const SidebarIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><rect x=\"2.2\" y=\"2.2\" width=\"11.6\" height=\"11.6\" rx=\"2\" /><path d=\"M6.6 2.2v11.6\" /></Glyph>\r\n)\r\n\r\n/** Mirror of SidebarIcon: the file-preview panel docked to the right edge. */\r\nexport const PreviewIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><rect x=\"2.2\" y=\"2.2\" width=\"11.6\" height=\"11.6\" rx=\"2\" /><path d=\"M9.4 2.2v11.6\" /><path d=\"M11 5.6h1.2M11 8h1.2\" /></Glyph>\r\n)\r\n\r\nexport const ChatIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M13.4 4.4v4.4a2 2 0 0 1-2 2H6.2l-3.6 3V4.4a2 2 0 0 1 2-2h6.8a2 2 0 0 1 2 2z\" /></Glyph>\r\n)\r\n\r\nexport const GearIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><circle cx=\"8\" cy=\"8\" r=\"2.1\" /><path d=\"M8 1.7v1.8M8 12.5v1.8M1.7 8h1.8M12.5 8h1.8M3.6 3.6l1.3 1.3M11.1 11.1l1.3 1.3M12.4 3.6l-1.3 1.3M4.9 11.1l-1.3 1.3\" /></Glyph>\r\n)\r\n\r\nexport const InputIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><rect x=\"2.2\" y=\"4\" width=\"11.6\" height=\"8\" rx=\"2\" /><path d=\"M8 6.6v2M7 8h2\" /></Glyph>\r\n)\r\n\r\n","import { Component, type ReactNode } from 'react'\r\n\r\ninterface Props {\r\n t: (key: string) => string\r\n onReset?: () => void\r\n children: ReactNode\r\n}\r\n\r\ninterface State {\r\n error: Error | null\r\n}\r\n\r\n/**\r\n * Catches render errors from the theme section subtree (wheel, sliders, editor)\r\n * so a single bad state can never take down the whole settings panel. Shows a\r\n * compact fallback with a reset button; the reset re-renders the section with\r\n * the current saved config, which is enough to recover from most transient\r\n * failures (corrupt transient UI state, stale image decode, etc.).\r\n */\r\nexport class ErrorBoundary extends Component<Props, State> {\r\n override state: State = { error: null }\r\n\r\n static getDerivedStateFromError(error: Error): State {\r\n return { error }\r\n }\r\n\r\n override componentDidCatch(error: Error, info: { componentStack?: string | null }): void {\r\n console.error('dsh-background-by-model: section render crashed', error, info.componentStack)\r\n }\r\n\r\n private reset = (): void => {\r\n this.setState({ error: null })\r\n this.props.onReset?.()\r\n }\r\n\r\n override render() {\r\n if (this.state.error) {\r\n return (\r\n <div className=\"dab-crash\">\r\n <div className=\"dab-crash-title\">{this.props.t('crashTitle')}</div>\r\n <div className=\"dab-crash-desc\">{this.props.t('crashDesc')}</div>\r\n <button type=\"button\" className=\"dab-btn\" onClick={this.reset}>{this.props.t('crashReset')}</button>\r\n </div>\r\n )\r\n }\r\n return this.props.children\r\n }\r\n}\r\n","import { useEffect, useState } from 'react'\r\nimport type { ReactNode } from 'react'\r\nimport { createPortal } from 'react-dom'\r\n\r\n/**\r\n * Render children into a fixed root attached to document.documentElement.\r\n *\r\n * The host's sidebar is often implemented by translating the body or a wrapper\r\n * (margin-left / transform). A fixed element portaled to body would still be\r\n * captured by that transformed ancestor and shift with the sidebar. Attaching\r\n * the portal root directly to <html> escapes body-level transforms so the\r\n * overlay is always painted relative to the viewport and centered correctly.\r\n */\r\nexport function Portal({ children }: { children: ReactNode }) {\r\n const [target, setTarget] = useState<HTMLElement | null>(null)\r\n useEffect(() => {\r\n const el = document.createElement('div')\r\n el.dataset.dabPortal = '1'\r\n el.style.cssText = 'position:fixed;inset:0;pointer-events:none;z-index:999999'\r\n document.documentElement.appendChild(el)\r\n setTarget(el)\r\n return () => { el.remove() }\r\n }, [])\r\n return target ? createPortal(children, target) : null\r\n}\r\n","import { useEffect, useRef } from 'react'\r\nimport type { CSSProperties } from 'react'\r\n\r\n/**\r\n * Zero-lag slider: the thumb and value label update through DOM refs while\r\n * dragging (onInput) so the caller can mutate the live UI directly without a\r\n * React re-render; onChange commits the settled value. Double-click resets to\r\n * the canonical default. The track fill is a gradient driven by the --pct\r\n * custom property, updated imperatively alongside the thumb.\r\n */\r\nexport function LiveSlider({ min, max, step, def, fmt, label, onInput, onChange }: {\r\n min: number; max: number; step: number; def: number\r\n fmt: (v: number) => string; label?: string; onInput?: (v: number) => void; onChange: (v: number) => void\r\n}) {\r\n const inputRef = useRef<HTMLInputElement>(null)\r\n const valRef = useRef<HTMLSpanElement>(null)\r\n\r\n const paint = (el: HTMLInputElement, v: number): void => {\r\n el.style.setProperty('--pct', String(((v - min) / (max - min)) * 100))\r\n }\r\n\r\n // Controlled sync: keep the knob and label aligned with the canonical prop\r\n // so external updates (presets, regeneration, imports) never leave it stale.\r\n useEffect(() => {\r\n if (inputRef.current) {\r\n inputRef.current.value = String(def)\r\n paint(inputRef.current, def)\r\n }\r\n if (valRef.current) valRef.current.textContent = fmt(def)\r\n }, [def, fmt, min, max])\r\n\r\n const apply = (v: number): void => {\r\n if (inputRef.current) {\r\n inputRef.current.value = String(v)\r\n paint(inputRef.current, v)\r\n }\r\n if (valRef.current) valRef.current.textContent = fmt(v)\r\n onInput?.(v)\r\n onChange(v)\r\n }\r\n\r\n return (\r\n <div className=\"dab-slider-block\">\r\n {label ? <span className=\"dab-slider-label\">{label}</span> : null}\r\n <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>\r\n <input\r\n ref={inputRef} type=\"range\" className=\"dab-slider\"\r\n style={{ '--pct': ((def - min) / (max - min)) * 100 } as CSSProperties}\r\n min={min} max={max} step={step} defaultValue={def}\r\n title={label ? `${label} · ${fmt(def)}` : fmt(def)}\r\n onDoubleClick={() => apply(def)}\r\n onInput={e => {\r\n const el = e.target as HTMLInputElement\r\n const v = Number(el.value)\r\n paint(el, v)\r\n onInput?.(v)\r\n if (valRef.current) valRef.current.textContent = fmt(v)\r\n }}\r\n onChange={e => onChange(Number((e.target as HTMLInputElement).value))} />\r\n <span ref={valRef} className=\"dab-slider-val\">{fmt(def)}</span>\r\n </div>\r\n </div>\r\n )\r\n}\r\n","import type { CSSProperties, ComponentType } from 'react'\r\nimport type { ThemeSectionProps, PartOpacities, PartBlurs } from '../../types'\r\nimport { cfg, rOps, rSop, rBlurs, rChatTextOpacity, rTrajectoryOpacity, rRightbarOpacity } from '../../state'\r\nimport { saveConfig } from '../../rpc'\r\nimport { applyCustomTokens, applySettingsOverrides, setPartBlur, applyViewCards, applyTrajectoryOverrides, applyRightbarOverrides } from '../../wallpaper'\r\nimport { LiveSlider } from '../LiveSlider'\r\nimport { CanvasIcon, SidebarIcon, ChatIcon, GearIcon, TextIcon, TrajectoryIcon, PreviewIcon, InputIcon } from '../icons'\r\n\r\ninterface PartDef {\r\n labelKey: string\r\n Icon: ComponentType<{ size?: number }>\r\n /** Homepage part key; absent for the settings-panel part. */\r\n opKey?: keyof PartOpacities\r\n isSettings?: boolean\r\n /** Conversation text region: tint opacity + blur over the message column. */\r\n isChat?: boolean\r\n /** Trajectory view: tint opacity + blur over the whole view surface. */\r\n isTrajectory?: boolean\r\n /** File-preview panel: the right sidebar a file click opens. */\r\n isRightbar?: boolean\r\n}\r\n\r\nconst PARTS: PartDef[] = [\r\n { opKey: 'bg', labelKey: 'uiOpacityBg', Icon: CanvasIcon },\r\n { opKey: 'sidebar', labelKey: 'uiOpacitySide', Icon: SidebarIcon },\r\n { isRightbar: true, labelKey: 'uiPreview', Icon: PreviewIcon },\r\n { opKey: 'card', labelKey: 'uiOpacityCard', Icon: ChatIcon },\r\n { opKey: 'input', labelKey: 'uiOpacityInput', Icon: InputIcon },\r\n { isSettings: true, labelKey: 'uiSop', Icon: GearIcon },\r\n { isChat: true, labelKey: 'uiChatRegion', Icon: TextIcon },\r\n { isTrajectory: true, labelKey: 'uiTrajectory', Icon: TrajectoryIcon },\r\n]\r\n\r\nexport function InterfacePage({ p }: { p: ThemeSectionProps }) {\r\n const { t, setOps, setBlurs, setSop, setRightbarOpacity } = p\r\n\r\n return (\r\n <>\r\n <header className=\"dab-head dab-rise\" style={{ '--d': 0 } as CSSProperties}>\r\n <div className=\"dab-overline\">Surfaces</div>\r\n <h2 className=\"dab-h1\">{t('uiTitle')}</h2>\r\n <p className=\"dab-desc\">{t('descInterface')}</p>\r\n </header>\r\n\r\n <div className=\"dab-grid-parts\">\r\n {PARTS.map((part, i) => {\r\n const { labelKey, Icon, isSettings, isChat, isTrajectory, isRightbar } = part\r\n const opKey = part.opKey\r\n // Homepage parts (bg/sidebar/card/input) bind to their own part only;\r\n // the settings panel (isSettings) binds exclusively to the 'settings'\r\n // part (--dsh-any-blur-settings / --dsh-any-bg-settings-surface) and\r\n // must never fall back to a homepage part key — otherwise the dialog\r\n // panel would track the homepage center/card blur and the home-page\r\n // opacities. The chat region (isChat) and the trajectory view\r\n // (isTrajectory) own their own blur keys plus their own tint\r\n // opacities, and the file-preview panel (isRightbar) owns the right\r\n // column's backdrop through the same deal. Every homepage opKey is\r\n // also a PartBlurs key (input included), so the shared blur slider\r\n // dereferences it directly.\r\n const blurKey: keyof PartBlurs = isChat\r\n ? 'chat'\r\n : isTrajectory\r\n ? 'trajectory'\r\n : isRightbar\r\n ? 'rightbar'\r\n : isSettings ? 'settings' : opKey!\r\n const opacity = isChat\r\n ? rChatTextOpacity()\r\n : isTrajectory\r\n ? rTrajectoryOpacity()\r\n : isRightbar ? rRightbarOpacity() : isSettings ? rSop() : rOps()[opKey!]\r\n return (\r\n <section key={blurKey} className=\"dab-card dab-card-hover dab-rise\" style={{ '--d': i + 1 } as CSSProperties}>\r\n <div className=\"dab-part-head\">\r\n <div className=\"dab-part-ico\"><Icon size={16} /></div>\r\n <div className=\"dab-part-name\">{t(labelKey)}</div>\r\n <span className=\"dab-part-badge\">{Math.round(opacity * 100)}%</span>\r\n </div>\r\n\r\n <LiveSlider label={t('uiOpacity')} min={0} max={100} step={1} def={Math.round(opacity * 100)}\r\n fmt={v => `${v}%`}\r\n onInput={v => {\r\n const op = v / 100\r\n if (isChat) {\r\n cfg.chatTextOpacity = op\r\n applyViewCards()\r\n } else if (isTrajectory) {\r\n cfg.trajectoryOpacity = op\r\n applyTrajectoryOverrides(op)\r\n } else if (isRightbar) {\r\n // First drag is what detaches the panel from the main\r\n // background; from then on the card owns it.\r\n cfg.rightbarOpacity = op\r\n applyRightbarOverrides(op)\r\n } else if (isSettings) {\r\n cfg.settingsOpacity = op\r\n applySettingsOverrides(op)\r\n } else {\r\n const ops = { ...rOps() }\r\n ops[opKey!] = op\r\n cfg.opacities = ops\r\n applyCustomTokens(ops)\r\n }\r\n saveConfig()\r\n }}\r\n onChange={v => {\r\n const op = v / 100\r\n if (isChat) {\r\n cfg.chatTextOpacity = op\r\n applyViewCards()\r\n saveConfig()\r\n } else if (isTrajectory) {\r\n cfg.trajectoryOpacity = op\r\n applyTrajectoryOverrides(op)\r\n saveConfig()\r\n } else if (isRightbar) {\r\n setRightbarOpacity(op)\r\n } else if (isSettings) {\r\n setSop(op)\r\n } else {\r\n const ops = { ...rOps() }\r\n ops[opKey!] = op\r\n setOps(ops)\r\n }\r\n }} />\r\n\r\n <LiveSlider label={t('uiBlur')} min={0} max={60} step={1} def={rBlurs()[blurKey]}\r\n fmt={v => `${v}px`}\r\n onInput={v => {\r\n const blurs = { ...rBlurs() }\r\n blurs[blurKey] = v\r\n cfg.blurs = blurs\r\n setPartBlur(blurKey, v)\r\n saveConfig()\r\n }}\r\n onChange={v => {\r\n const blurs = { ...rBlurs() }\r\n blurs[blurKey] = v\r\n setBlurs(blurs)\r\n }} />\r\n </section>\r\n )\r\n })}\r\n </div>\r\n </>\r\n )\r\n}\r\n","/**\r\n * Read a chosen image file as a data URL WITHOUT re-encoding: the original\r\n * pixels are kept as-is (no canvas downscale / JPEG re-compression), so the\r\n * wallpaper is stored and displayed at full fidelity. The tradeoff is a larger\r\n * payload over the RPC channel and on disk for big images.\r\n */\r\nexport function readImg(file: File, cb: (url: string | null) => void): void {\r\n const r = new FileReader()\r\n r.onerror = () => cb(null)\r\n r.onload = () => cb(r.result as string)\r\n r.readAsDataURL(file)\r\n}\r\n","import { useRef, useState, useEffect, useCallback, memo } from 'react'\r\n\r\nconst WHEEL_SIZE = 220\r\nconst CX = WHEEL_SIZE / 2\r\nconst RING_OUTER = 106\r\nconst RING_INNER = 82\r\n// Square inscribed in the ring's inner circle: half-side = RING_INNER / √2,\r\n// so the four corners sit exactly on the inner edge of the hue ring. The\r\n// exact (un-rounded) value keeps the corners tangent to the ring — a rounded\r\n// half-side would push the diagonals past the ring's inner boundary.\r\nconst SQ_HALF = RING_INNER / Math.SQRT2\r\n\r\n/** Static hue ring cached once across all wheels. */\r\nlet ringCache: HTMLCanvasElement | null = null\r\nfunction getRingCache(): HTMLCanvasElement {\r\n if (ringCache) return ringCache\r\n const cvs = document.createElement('canvas')\r\n cvs.width = WHEEL_SIZE; cvs.height = WHEEL_SIZE\r\n const c = cvs.getContext('2d')!\r\n // Instead of 360 separate arc paths, use a single conic gradient clipped to\r\n // the ring. This removes per-frame path overhead and anti-aliasing gaps.\r\n const g = c.createConicGradient(0, CX, CX)\r\n for (let i = 0; i <= 360; i++) g.addColorStop(i / 360, `hsl(${i},100%,50%)`)\r\n c.beginPath()\r\n c.arc(CX, CX, RING_OUTER, 0, Math.PI * 2)\r\n c.arc(CX, CX, RING_INNER, 0, Math.PI * 2, true)\r\n c.fillStyle = g\r\n c.fill()\r\n ringCache = cvs\r\n return ringCache\r\n}\r\n\r\nfunction drawMarkers(ctx: CanvasRenderingContext2D, hue: number, sat: number, lit: number): void {\r\n // Hue marker on ring. Canvas math angles (0 = +x / \"3 o'clock\", positive =\r\n // toward +y) directly match the conic-gradient hue distribution drawn in\r\n // getRingCache (colorStop i/360 → hsl(i)), so NO extra ±90° shift is applied.\r\n // A shift would rotate the picker's indication 90° away from the rendered\r\n // gradient (e.g. picking the top of the wheel would report red while the\r\n // pixels there are blue). hue 0 sits at the right edge, +90° at the bottom.\r\n const hRad = hue * Math.PI / 180\r\n const hR = (RING_OUTER + RING_INNER) / 2\r\n const hmx = CX + Math.cos(hRad) * hR\r\n const hmy = CX + Math.sin(hRad) * hR\r\n ctx.beginPath(); ctx.arc(hmx, hmy, 8, 0, Math.PI * 2)\r\n ctx.fillStyle = 'rgba(0,0,0,0.25)'; ctx.fill()\r\n ctx.beginPath(); ctx.arc(hmx, hmy, 6.5, 0, Math.PI * 2)\r\n ctx.strokeStyle = '#fff'; ctx.lineWidth = 2; ctx.stroke()\r\n\r\n // SL marker (HSV coordinates)\r\n const gx = CX - SQ_HALF, gy = CX - SQ_HALF, sz = SQ_HALF * 2\r\n const smx = gx + sat * sz\r\n const smy = gy + (1 - lit) * sz\r\n ctx.beginPath(); ctx.arc(smx, smy, 7, 0, Math.PI * 2)\r\n ctx.fillStyle = 'rgba(0,0,0,0.25)'; ctx.fill()\r\n ctx.beginPath(); ctx.arc(smx, smy, 5.5, 0, Math.PI * 2)\r\n ctx.strokeStyle = '#fff'; ctx.lineWidth = 2; ctx.stroke()\r\n ctx.beginPath(); ctx.arc(smx, smy, 3.5, 0, Math.PI * 2)\r\n ctx.strokeStyle = '#000'; ctx.lineWidth = 1; ctx.stroke()\r\n}\r\n\r\nfunction drawSquare(c: CanvasRenderingContext2D, hue: number): void {\r\n const gx = CX - SQ_HALF, gy = CX - SQ_HALF, sz = SQ_HALF * 2\r\n c.clearRect(gx - 1, gy - 1, sz + 2, sz + 2)\r\n c.fillStyle = '#fff'; c.fillRect(gx, gy, sz, sz)\r\n const gh = c.createLinearGradient(gx, 0, gx + sz, 0)\r\n gh.addColorStop(0, 'rgba(255,255,255,1)'); gh.addColorStop(1, `hsl(${hue},100%,50%)`)\r\n c.fillStyle = gh; c.fillRect(gx, gy, sz, sz)\r\n const gv = c.createLinearGradient(0, gy, 0, gy + sz)\r\n gv.addColorStop(0, 'rgba(0,0,0,0)'); gv.addColorStop(1, 'rgba(0,0,0,1)')\r\n c.fillStyle = gv; c.fillRect(gx, gy, sz, sz)\r\n}\r\n\r\nfunction hitTest(x: number, y: number): 'ring' | 'square' | null {\r\n if (Math.abs(x - CX) <= SQ_HALF && Math.abs(y - CX) <= SQ_HALF) return 'square'\r\n const dx = x - CX, dy = y - CX\r\n const dist = Math.sqrt(dx * dx + dy * dy)\r\n if (dist >= RING_INNER - 4 && dist <= RING_OUTER + 4) return 'ring'\r\n return null\r\n}\r\n\r\nfunction pickHue(x: number, y: number): number {\r\n // Inverse of drawMarkers: no ±90° shift, matching the conic gradient exactly.\r\n let angle = Math.atan2(y - CX, x - CX) * 180 / Math.PI\r\n if (angle < 0) angle += 360\r\n return angle\r\n}\r\n\r\nfunction pickSL(x: number, y: number): [number, number] {\r\n const gx = CX - SQ_HALF, gy = CX - SQ_HALF, sz = SQ_HALF * 2\r\n return [\r\n Math.max(0, Math.min(1, (x - gx) / sz)),\r\n Math.max(0.02, Math.min(0.98, 1 - (y - gy) / sz)),\r\n ]\r\n}\r\n\r\nexport const ColorWheel = memo(function ColorWheel({ hue, sat, lit, onChange }: {\r\n hue: number; sat: number; lit: number\r\n onChange: (h: number, s: number, l: number) => void\r\n}) {\r\n const cvsRef = useRef<HTMLCanvasElement>(null)\r\n const [col, setCol] = useState({ hue, sat, lit })\r\n const colRef = useRef(col)\r\n colRef.current = col\r\n\r\n // Adopt external changes (e.g. section remount after theme restore).\r\n useEffect(() => {\r\n setCol(c => (c.hue === hue && c.sat === sat && c.lit === lit ? c : { hue, sat, lit }))\r\n }, [hue, sat, lit])\r\n\r\n // Redraw only what changed. The static ring is copied from cache; the square\r\n // only redraws when hue changes; markers redraw on every value change.\r\n useEffect(() => {\r\n const cvs = cvsRef.current\r\n if (!cvs) return\r\n const ctx = cvs.getContext('2d')!\r\n ctx.clearRect(0, 0, WHEEL_SIZE, WHEEL_SIZE)\r\n // Draw the square first, then the ring on top: the ring's opaque pixels\r\n // cover the square's four corners (which are tangent to the ring's inner\r\n // edge), so the corners no longer visually overlap the hue ring.\r\n drawSquare(ctx, col.hue)\r\n ctx.drawImage(getRingCache(), 0, 0)\r\n drawMarkers(ctx, col.hue, col.sat, col.lit)\r\n }, [col])\r\n\r\n // Batch pointer updates in a single rAF so rapid mousemove events do not\r\n // trigger a React state flush + onChange on every pixel.\r\n const pendingRef = useRef<{ h: number; s: number; l: number } | null>(null)\r\n const rafRef = useRef<number | null>(null)\r\n const flushPending = useCallback(() => {\r\n rafRef.current = null\r\n const p = pendingRef.current\r\n if (!p) return\r\n pendingRef.current = null\r\n setCol({ hue: p.h, sat: p.s, lit: p.l })\r\n onChange(p.h, p.s, p.l)\r\n }, [onChange])\r\n\r\n const schedule = useCallback((h: number, s: number, l: number) => {\r\n pendingRef.current = { h, s, l }\r\n if (rafRef.current === null) rafRef.current = requestAnimationFrame(flushPending)\r\n }, [flushPending])\r\n\r\n const onDown = useCallback((e: React.MouseEvent<HTMLCanvasElement>) => {\r\n const r = cvsRef.current!.getBoundingClientRect()\r\n const x = e.clientX - r.left, y = e.clientY - r.top\r\n const region = hitTest(x, y)\r\n if (!region) return\r\n if (region === 'ring') {\r\n schedule(pickHue(x, y), colRef.current.sat, colRef.current.lit)\r\n } else {\r\n const [s, l] = pickSL(x, y)\r\n schedule(colRef.current.hue, s, l)\r\n }\r\n const onMove = (ev: MouseEvent) => {\r\n const rr = cvsRef.current!.getBoundingClientRect()\r\n const mx = ev.clientX - rr.left, my = ev.clientY - rr.top\r\n if (region === 'ring') {\r\n const d = Math.sqrt((mx - CX) ** 2 + (my - CX) ** 2)\r\n if (d >= RING_INNER - 10 && d <= RING_OUTER + 10) schedule(pickHue(mx, my), colRef.current.sat, colRef.current.lit)\r\n } else {\r\n const [s, l] = pickSL(mx, my)\r\n schedule(colRef.current.hue, s, l)\r\n }\r\n }\r\n const onUp = () => { document.removeEventListener('mousemove', onMove); document.removeEventListener('mouseup', onUp) }\r\n document.addEventListener('mousemove', onMove); document.addEventListener('mouseup', onUp)\r\n }, [schedule])\r\n\r\n return <canvas ref={cvsRef} width={WHEEL_SIZE} height={WHEEL_SIZE} className=\"dab-wheel\" onMouseDown={onDown} />\r\n})\r\n","import { useState, useEffect, useRef } from 'react'\r\nimport type { CSSProperties } from 'react'\r\nimport { hsvToHsl, hslToRgb, rgbToHsl, hslToHsv } from '../utils/color'\r\n\r\ntype Mode = 'hsl' | 'rgb'\r\n\r\nconst SEG_W = 66\r\n\r\nfunction clamp(v: number, min: number, max: number): number {\r\n return Math.min(max, Math.max(min, v))\r\n}\r\n\r\n/**\r\n * A single numeric field that edits one color channel. Keeps its own text\r\n * while focused so typing never gets clobbered by the parent re-rendering the\r\n * canonical value; commits every valid keystroke live and re-normalizes on\r\n * blur. The value prop only pushes back in when the field is not focused\r\n * (wheel drags, wallpaper extraction, mode switches).\r\n */\r\nfunction NumField({ label, value, min, max, step, onChange }: {\r\n label: string; value: number; min: number; max: number; step: number\r\n onChange: (v: number) => void\r\n}) {\r\n const [text, setText] = useState(String(value))\r\n const focused = useRef(false)\r\n\r\n useEffect(() => {\r\n if (!focused.current) setText(String(value))\r\n }, [value])\r\n\r\n return (\r\n <label className=\"dab-field\">\r\n <span className=\"dab-field-label\">{label}</span>\r\n <input\r\n type=\"number\"\r\n min={min} max={max} step={step}\r\n value={text}\r\n className=\"dab-num\"\r\n onFocus={() => { focused.current = true }}\r\n onBlur={() => { focused.current = false; setText(String(value)) }}\r\n onChange={e => {\r\n setText(e.target.value)\r\n const v = Number(e.target.value)\r\n if (Number.isFinite(v)) onChange(clamp(v, min, max))\r\n }}\r\n />\r\n </label>\r\n )\r\n}\r\n\r\n/**\r\n * Precise color entry next to the wheel: a HSL/RGB segmented toggle plus three\r\n * numeric channel fields and a live swatch. The wheel is HSV end-to-end, so\r\n * this panel converts at the boundary — HSL fields map straight onto the\r\n * stored HSL, RGB fields round-trip through rgbToHsl — and both emit HSV via\r\n * the same onChange the wheel uses, keeping one canonical color.\r\n */\r\nexport function ColorInputs({ hue, sat, lit, onChange }: {\r\n hue: number; sat: number; lit: number\r\n onChange: (h: number, s: number, l: number) => void\r\n}) {\r\n const [mode, setMode] = useState<Mode>('hsl')\r\n const [h, s, l] = hsvToHsl(hue, sat, lit)\r\n const [r, g, b] = hslToRgb(h, s, l)\r\n\r\n const setHsl = (nh: number, ns: number, nl: number) => onChange(...hslToHsv(nh, ns, nl))\r\n const setRgb = (nr: number, ng: number, nb: number) => {\r\n const [nh, ns, nl] = rgbToHsl(nr, ng, nb)\r\n onChange(...hslToHsv(nh, ns, nl))\r\n }\r\n\r\n return (\r\n <div className=\"dab-inputs\">\r\n <div className=\"dab-seg\" style={{ '--w': `${SEG_W}px` } as CSSProperties}>\r\n <div className=\"dab-seg-thumb\" style={{ transform: `translateX(${mode === 'hsl' ? 0 : SEG_W}px)` }} />\r\n <button type=\"button\" className={`dab-seg-item${mode === 'hsl' ? ' is-active' : ''}`} onClick={() => setMode('hsl')}>HSL</button>\r\n <button type=\"button\" className={`dab-seg-item${mode === 'rgb' ? ' is-active' : ''}`} onClick={() => setMode('rgb')}>RGB</button>\r\n </div>\r\n <div style={{ display: 'flex', flexDirection: 'column', gap: 7 }}>\r\n {mode === 'hsl' ? (\r\n <>\r\n <NumField label=\"H\" value={Math.round(h)} min={0} max={360} step={1} onChange={v => setHsl(v, s, l)} />\r\n <NumField label=\"S\" value={Math.round(s * 100)} min={0} max={100} step={1} onChange={v => setHsl(h, v / 100, l)} />\r\n <NumField label=\"L\" value={Math.round(l * 100)} min={0} max={100} step={1} onChange={v => setHsl(h, s, v / 100)} />\r\n </>\r\n ) : (\r\n <>\r\n <NumField label=\"R\" value={r} min={0} max={255} step={1} onChange={v => setRgb(v, g, b)} />\r\n <NumField label=\"G\" value={g} min={0} max={255} step={1} onChange={v => setRgb(r, v, b)} />\r\n <NumField label=\"B\" value={b} min={0} max={255} step={1} onChange={v => setRgb(r, g, v)} />\r\n </>\r\n )}\r\n </div>\r\n <div className=\"dab-swatch-lg\" style={{ background: `hsl(${Math.round(h)} ${Math.round(s * 100)}% ${Math.round(l * 100)}%)` }} />\r\n </div>\r\n )\r\n}\r\n","import { useRef, useState, useEffect, useCallback } from 'react'\r\nimport { rgbToHsl, hslToHsv } from '../utils/color'\r\nimport { Portal } from './Portal'\r\n\r\nconst MAG_SIZE = 96\r\nconst MAG_ZOOM = 8\r\n\r\nfunction toHex(rgb: [number, number, number]): string {\r\n return '#' + rgb.map(v => v.toString(16).padStart(2, '0')).join('')\r\n}\r\n\r\n/**\r\n * Eyedropper modal: shows the wallpaper full-bleed (no drag/zoom) and lets the\r\n * user click any pixel to adopt it as the theme color. A magnifier circle\r\n * follows the cursor so small details can be picked precisely. The wallpaper\r\n * is a data URL, so sampling is CORS-free: draw it once to an offscreen-sized\r\n * canvas and read pixels via getImageData.\r\n */\r\nexport function ColorPicker({ url, t, onPick, onClose }: {\r\n url: string\r\n t: (key: string) => string\r\n onPick: (hsv: [number, number, number]) => void\r\n onClose: () => void\r\n}) {\r\n const canvasRef = useRef<HTMLCanvasElement>(null)\r\n const magRef = useRef<HTMLCanvasElement>(null)\r\n const imgRef = useRef<HTMLImageElement | null>(null)\r\n const [ready, setReady] = useState(false)\r\n const [hover, setHover] = useState<{ rgb: [number, number, number] } | null>(null)\r\n const [mag, setMag] = useState<{ x: number; y: number } | null>(null)\r\n\r\n useEffect(() => {\r\n const img = new Image()\r\n img.onload = () => { imgRef.current = img; setReady(true) }\r\n img.src = url\r\n }, [url])\r\n\r\n useEffect(() => {\r\n if (!ready || !canvasRef.current || !imgRef.current) return\r\n const canvas = canvasRef.current\r\n canvas.width = imgRef.current.naturalWidth\r\n canvas.height = imgRef.current.naturalHeight\r\n const ctx = canvas.getContext('2d')\r\n if (ctx) ctx.drawImage(imgRef.current, 0, 0)\r\n }, [ready])\r\n\r\n const sampleAt = useCallback((clientX: number, clientY: number) => {\r\n const canvas = canvasRef.current\r\n if (!canvas) return null\r\n const rect = canvas.getBoundingClientRect()\r\n if (rect.width === 0 || rect.height === 0) return null\r\n const ctx = canvas.getContext('2d')\r\n if (!ctx) return null\r\n const sx = Math.round((clientX - rect.left) * (canvas.width / rect.width))\r\n const sy = Math.round((clientY - rect.top) * (canvas.height / rect.height))\r\n if (sx < 0 || sy < 0 || sx >= canvas.width || sy >= canvas.height) return null\r\n const d = ctx.getImageData(sx, sy, 1, 1).data\r\n return { sx, sy, rgb: [d[0], d[1], d[2]] as [number, number, number] }\r\n }, [])\r\n\r\n const drawMagnifier = useCallback((sx: number, sy: number) => {\r\n const mag = magRef.current\r\n const src = canvasRef.current\r\n if (!mag || !src) return\r\n const ctx = mag.getContext('2d')\r\n if (!ctx) return\r\n const half = MAG_SIZE / MAG_ZOOM / 2\r\n ctx.clearRect(0, 0, MAG_SIZE, MAG_SIZE)\r\n ctx.drawImage(src, sx - half, sy - half, half * 2, half * 2, 0, 0, MAG_SIZE, MAG_SIZE)\r\n ctx.strokeStyle = 'rgba(255,255,255,0.85)'\r\n ctx.lineWidth = 1\r\n ctx.beginPath()\r\n ctx.moveTo(MAG_SIZE / 2, 0); ctx.lineTo(MAG_SIZE / 2, MAG_SIZE)\r\n ctx.moveTo(0, MAG_SIZE / 2); ctx.lineTo(MAG_SIZE, MAG_SIZE / 2)\r\n ctx.stroke()\r\n }, [])\r\n\r\n const onMove = (e: React.MouseEvent) => {\r\n const s = sampleAt(e.clientX, e.clientY)\r\n if (!s) { setHover(null); setMag(null); return }\r\n setHover({ rgb: s.rgb })\r\n drawMagnifier(s.sx, s.sy)\r\n const off = 28\r\n let x = e.clientX + off\r\n let y = e.clientY + off\r\n if (x + MAG_SIZE > window.innerWidth) x = e.clientX - off - MAG_SIZE\r\n if (y + MAG_SIZE > window.innerHeight) y = e.clientY - off - MAG_SIZE\r\n setMag({ x, y })\r\n }\r\n\r\n const onClick = (e: React.MouseEvent) => {\r\n const s = sampleAt(e.clientX, e.clientY)\r\n if (!s) return\r\n const [h, sl, l] = rgbToHsl(s.rgb[0], s.rgb[1], s.rgb[2])\r\n onPick(hslToHsv(h, sl, l))\r\n }\r\n\r\n return (\r\n <Portal>\r\n <div className=\"dab-overlay\">\r\n <div className=\"dab-overlay-title\">{t('pickerTitle')}</div>\r\n <div className=\"dab-overlay-hint\">{t('pickerHint')}</div>\r\n <div className=\"dab-modal-card\" style={{\r\n maxWidth: 'min(90vw, 720px)', maxHeight: '60vh', overflow: 'hidden',\r\n borderRadius: 12, border: '2px solid rgba(255,255,255,0.3)', background: '#000', cursor: 'crosshair',\r\n }}>\r\n <canvas ref={canvasRef} style={{ display: 'block', maxWidth: '100%', maxHeight: '60vh', objectFit: 'contain' }}\r\n onMouseMove={onMove}\r\n onMouseLeave={() => { setHover(null); setMag(null) }}\r\n onClick={onClick} />\r\n </div>\r\n <div style={{ display: 'flex', alignItems: 'center', gap: 10, minWidth: 260 }}>\r\n <div style={{ width: 28, height: 28, borderRadius: 8, border: '1px solid rgba(255,255,255,0.4)', background: hover ? toHex(hover.rgb) : 'transparent' }} />\r\n <div style={{ color: '#fff', fontSize: 13, fontFamily: 'var(--dab-mono, monospace)' }}>{hover ? `${toHex(hover.rgb)} · rgb(${hover.rgb.join(', ')})` : '—'}</div>\r\n </div>\r\n <div style={{ display: 'flex', gap: 10 }}>\r\n <button type=\"button\" className=\"dab-btn\" onClick={onClose}>{t('pickerClose')}</button>\r\n </div>\r\n <canvas ref={magRef} width={MAG_SIZE} height={MAG_SIZE}\r\n style={{\r\n position: 'fixed', width: MAG_SIZE, height: MAG_SIZE, borderRadius: '50%',\r\n border: '2px solid rgba(255,255,255,0.7)', boxShadow: '0 4px 16px rgba(0,0,0,0.5)',\r\n zIndex: 10000, background: '#000', pointerEvents: 'none', transition: 'opacity 0.08s',\r\n left: mag?.x ?? 0, top: mag?.y ?? 0, opacity: mag ? 1 : 0,\r\n }} />\r\n </div>\r\n </Portal>\r\n )\r\n}\r\n","import { useRef, useState, useEffect, useCallback } from 'react'\nimport type { BgState } from '../types'\nimport { Portal } from './Portal'\n\n/**\n * Framing editor for one rule's image.\n *\n * The placement state is passed IN rather than read from a global slot: every\n * rule owns its own framing, and editing rule B must never touch rule A.\n */\nexport function BgEditor({ url, state, t, onClose, onCommit }: {\n url: string\n /** The rule's own framing. */\n state: BgState\n t: (key: string) => string; onClose: () => void\n onCommit: (zoom: number, x: number, y: number, iw: number, ih: number) => void\n}) {\n const pw = Math.min(window.innerWidth * 0.75, 860)\n const ph = Math.round(pw * window.innerHeight / window.innerWidth)\n const saved = state\n const [zoom, setZoom] = useState(saved.iw > 0 ? saved.zoom : 1)\n const [pos, setPos] = useState(saved.iw > 0 ? { x: saved.x * pw, y: saved.y * ph } : { x: 0, y: 0 })\n const [imgSize, setImgSize] = useState({ w: 0, h: 0 })\n const containerRef = useRef<HTMLDivElement>(null)\n const imgRef = useRef<HTMLImageElement>(null)\n const dragRef = useRef({ active: false, sx: 0, sy: 0, spx: 0, spy: 0 })\n\n useEffect(() => {\n const img = new Image()\n img.onload = () => {\n const scale = Math.min(pw / img.width, ph / img.height)\n const w = img.width * scale, h = img.height * scale\n setImgSize({ w, h })\n const s = state\n if (s.iw > 0 && s.iw === img.width && s.ih === img.height) {\n setZoom(s.zoom)\n // Saved x, y are CENTER fractions of the preview: the image center\n // lands at (x·pw, y·ph), so the top-left comes from subtracting half\n // the displayed (zoom-scaled) image size.\n setPos({ x: s.x * pw - w * s.zoom / 2, y: s.y * ph - h * s.zoom / 2 })\n } else {\n setZoom(1)\n setPos({ x: (pw - w) / 2, y: (ph - h) / 2 })\n }\n }\n img.src = url\n }, [url, state, pw, ph])\n\n const onDown = useCallback((e: React.MouseEvent) => {\n e.preventDefault()\n dragRef.current = { active: true, sx: e.clientX, sy: e.clientY, spx: pos.x, spy: pos.y }\n const onMove = (ev: MouseEvent) => {\n if (!dragRef.current.active) return\n setPos({ x: dragRef.current.spx + ev.clientX - dragRef.current.sx, y: dragRef.current.spy + ev.clientY - dragRef.current.sy })\n }\n const onUp = () => { dragRef.current.active = false; document.removeEventListener('mousemove', onMove); document.removeEventListener('mouseup', onUp) }\n document.addEventListener('mousemove', onMove); document.addEventListener('mouseup', onUp)\n }, [pos])\n\n const onWheelCb = useCallback((e: WheelEvent) => {\n e.preventDefault()\n const el = containerRef.current\n if (!el) return\n const rect = el.getBoundingClientRect()\n // Anchor the zoom at the preview center so the mouse position never\n // steers where the image grows/shrinks — the current view stays centered.\n const mx = rect.width / 2, my = rect.height / 2\n // 3% per wheel step (0.97 zoom-out / 1.03 zoom-in).\n const factor = e.deltaY > 0 ? 0.97 : 1.03\n const nz = Math.max(0.1, Math.min(10, zoom * factor))\n const nx = mx - (mx - pos.x) * (nz / zoom)\n const ny = my - (my - pos.y) * (nz / zoom)\n setZoom(nz); setPos({ x: nx, y: ny })\n }, [zoom, pos])\n\n useEffect(() => {\n const el = containerRef.current\n if (!el) return\n el.addEventListener('wheel', onWheelCb, { passive: false })\n return () => el.removeEventListener('wheel', onWheelCb)\n }, [onWheelCb])\n\n const resetView = useCallback(() => {\n if (imgSize.w === 0) return\n setZoom(1); setPos({ x: (pw - imgSize.w) / 2, y: (ph - imgSize.h) / 2 })\n }, [pw, ph, imgSize])\n\n return (\n <Portal>\n <div className=\"dab-overlay\" onClick={e => { if (e.target === e.currentTarget) onClose() }}>\n <div className=\"dab-overlay-title\">{t('editorTitle')}</div>\n <div ref={containerRef} className=\"dab-modal-card\" style={{\n position: 'relative', overflow: 'hidden', border: '2px solid rgba(255,255,255,0.3)',\n borderRadius: 12, background: '#000', cursor: 'grab', width: pw, height: ph,\n }} onMouseDown={onDown}>\n <img ref={imgRef} src={url} alt=\"\" draggable={false} style={{\n position: 'absolute', transformOrigin: '0 0', pointerEvents: 'none',\n width: imgSize.w, height: imgSize.h,\n transform: `translate(${pos.x}px,${pos.y}px) scale(${zoom})`,\n }} />\n </div>\n <div className=\"dab-overlay-hint\">{t('editorHint')}</div>\n <div style={{ display: 'flex', gap: 10 }}>\n <button type=\"button\" className=\"dab-btn\" onClick={resetView}>{t('editorReset')}</button>\n <button type=\"button\" className=\"dab-btn\" onClick={onClose}>{t('editorCancel')}</button>\n <button type=\"button\" className=\"dab-btn\" onClick={() => onCommit(zoom, (pos.x + imgSize.w * zoom / 2) / pw, (pos.y + imgSize.h * zoom / 2) / ph, imgRef.current?.naturalWidth ?? 0, imgRef.current?.naturalHeight ?? 0)}>{t('editorCommit')}</button>\n </div>\n </div>\n </Portal>\n )\n}\n","import { useEffect, useRef, useState } from 'react'\nimport type { CSSProperties } from 'react'\nimport type { BgMode, BgRule, ThemeSectionProps, ThemeStoreState } from '../../types'\nimport { cfg, PALETTE } from '../../state'\nimport { matchRule } from '../../modelbg'\nimport { readImg } from '../../utils/image'\nimport { hslToHsv, hsvToHsl, hslToRgb } from '../../utils/color'\nimport { ColorWheel } from '../ColorWheel'\nimport { ColorInputs } from '../ColorInputs'\nimport { ColorPicker } from '../ColorPicker'\nimport { BgEditor } from '../BgEditor'\nimport { LiveSlider } from '../LiveSlider'\nimport { DropletIcon, EditIcon, LinkIcon, PipetteIcon, SparkleIcon, TrashIcon, UploadIcon } from '../icons'\n\nconst BG_MODES: Array<{ mode: BgMode; key: string }> = [\n { mode: 'fit', key: 'bgModeFit' },\n { mode: 'fill', key: 'bgModeFill' },\n { mode: 'stretch', key: 'bgModeStretch' },\n { mode: 'tile', key: 'bgModeTile' },\n { mode: 'center', key: 'bgModeCenter' },\n]\n\n/** Seed color a rule starts from when the user picks one for the first time. */\nconst SEED_COLOR: [number, number, number] = [220, 0.55, 0.25]\n\n/**\n * Failing-hop codes the model watcher can report, mapped to their copy. Only\n * these are rendered: `waiting` and `fallback` already have their own hints.\n */\nconst MODEL_NOTE_KEYS: Record<string, string | undefined> = {\n 'no-service': 'statusNoteNoService',\n 'no-session': 'statusNoteNoSession',\n 'no-projection': 'statusNoteNoProjection',\n 'empty-selection': 'statusNoteEmptySelection',\n}\n\nfunction toHex(rgb: [number, number, number]): string {\n return '#' + rgb.map(v => Math.round(v).toString(16).padStart(2, '0')).join('')\n}\n\nexport function ModelBgPage({ p, notify }: { p: ThemeSectionProps; notify: (msg: string, ok?: boolean) => void }) {\n const { t, useStore } = p\n const store = useStore((s: ThemeStoreState) => s)\n const rules = cfg.rules\n\n // Match tester: the field follows the detected model until the user types\n // their own text, so the card is useful the moment it is looked at and never\n // fights the watcher once it is not. It replaced the old \"active now\" readout —\n // the same question (\"what does this model resolve to?\") one step earlier, and\n // it does not go stale between switches.\n const [text, setText] = useState('')\n const [touched, setTouched] = useState(false)\n useEffect(() => { if (!touched) setText(store.model) }, [store.model, touched])\n const probe = text.trim()\n const result = ((): string | null => {\n if (probe === '') return null\n const hit = matchRule(rules, probe)\n const rule = hit.rule\n if (rule === null) return null\n const n = rules.findIndex(r => r.id === rule.id) + 1\n return `${hit.matched ? t('tryoutHit') : t('tryoutFallback')} ${n}`\n })()\n\n return (\n <>\n <header className=\"dab-head dab-rise\" style={{ '--d': 0 } as CSSProperties}>\n <div className=\"dab-overline\">Rules</div>\n <h2 className=\"dab-h1\">{t('pageModelBg')}</h2>\n <p className=\"dab-desc\">{t('descModelBg')}</p>\n </header>\n\n <section className=\"dab-card dab-rise\" style={{ '--d': 1 } as CSSProperties}>\n <div className=\"dab-swatch-title\">{t('tryoutTitle')}</div>\n <div style={{ marginTop: 10, display: 'flex', flexWrap: 'wrap', gap: 8, alignItems: 'center' }}>\n <input\n type=\"text\" className=\"dab-urlinput\" value={text}\n placeholder={t('tryoutPlaceholder')}\n onChange={e => { setTouched(true); setText(e.target.value) }} />\n {store.model !== '' ? (\n <button type=\"button\" className=\"dab-btn\" onClick={() => { setTouched(true); setText(store.model) }}>\n {t('tryoutUseCurrent')}\n </button>\n ) : null}\n </div>\n <p className=\"dab-hint\" style={{ marginTop: 9 }}>\n {probe === '' ? t('tryoutEmpty') : result === null ? t('tryoutNone') : result}\n </p>\n {/* Why the pre-filled value is what it is: without these, a host default\n passed off as this session's model, or a sessions service that simply\n is not up yet, is indistinguishable from a correct read. */}\n {store.model === '' ? <p className=\"dab-hint\" style={{ marginTop: 6 }}>{t('statusUnknownHint')}</p> : null}\n {store.model !== '' && store.modelSource === 'default'\n ? <p className=\"dab-hint\" style={{ marginTop: 6 }}>{t('statusSourceDefaultHint')}</p>\n : null}\n {MODEL_NOTE_KEYS[store.modelNote] !== undefined\n ? <p className=\"dab-hint\" style={{ marginTop: 6 }}>{t(MODEL_NOTE_KEYS[store.modelNote]!)}</p>\n : null}\n </section>\n\n <section className=\"dab-rise\" style={{ '--d': 2 } as CSSProperties}>\n <div className=\"dab-swatch-title\">{t('rulesTitle')}</div>\n <p className=\"dab-hint\" style={{ marginBottom: 11 }}>{t('rulesHint')}</p>\n\n {/* Picking an image should just theme the rule; this is the off switch\n for people who want the color to be their own choice every time. */}\n <div className=\"dab-chip-row\" style={{ marginBottom: 12, alignItems: 'center' }}>\n <button type=\"button\" className={`dab-toggle${cfg.autoExtract ? ' is-on' : ''}`}\n role=\"switch\" aria-checked={cfg.autoExtract} title={t('autoExtract')}\n onClick={() => p.setAutoExtract(!cfg.autoExtract)}>\n <span className=\"dab-toggle-knob\" />\n </button>\n <span className=\"dab-hint\">{t('autoExtract')}</span>\n </div>\n <p className=\"dab-hint\" style={{ marginBottom: 11 }}>{t('autoExtractHint')}</p>\n\n <div className=\"dab-rules\">\n {rules.map((rule, i) => (\n <RuleCard\n key={rule.id} p={p} rule={rule} index={i} total={rules.length}\n active={rule.id === store.activeRuleId} notify={notify} />\n ))}\n </div>\n\n <button type=\"button\" className=\"dab-btn dab-btn-primary\" style={{ marginTop: 12 }} onClick={() => { p.addRule() }}>\n + {t('ruleAdd')}\n </button>\n </section>\n </>\n )\n}\n\nfunction RuleCard({ p, rule, index, total, active, notify }: {\n p: ThemeSectionProps\n rule: BgRule\n index: number\n total: number\n active: boolean\n notify: (msg: string, ok?: boolean) => void\n}) {\n const { t } = p\n // The active rule opens by default so the panel shows the live one first.\n const [open, setOpen] = useState(active)\n const [dragOver, setDragOver] = useState(false)\n const [urlOpen, setUrlOpen] = useState(false)\n const [urlVal, setUrlVal] = useState('')\n const [urlBusy, setUrlBusy] = useState(false)\n const [urlErr, setUrlErr] = useState<string | null>(null)\n const [editorOpen, setEditorOpen] = useState(false)\n const [pickerOpen, setPickerOpen] = useState(false)\n const [extracting, setExtracting] = useState(false)\n const fileRef = useRef<HTMLInputElement>(null)\n\n const url = p.imageOf(rule.slot)\n const [h, s, l] = rule.color ?? SEED_COLOR\n const wheel = hslToHsv(h, s, l)\n\n const onColor = (nh: number, ns: number, nl: number): void => {\n const [sh, ss, sl] = hsvToHsl(nh, ns, nl)\n p.setRule(rule.id, { color: [sh, ss, sl] })\n }\n\n const onFile = (f: File): void => {\n readImg(f, d => { if (d !== null) p.setRuleImage(rule.id, d) })\n }\n\n const onDrop = (e: React.DragEvent): void => {\n e.preventDefault()\n setDragOver(false)\n const f = e.dataTransfer.files?.[0]\n if (f && f.type.startsWith('image/')) onFile(f)\n }\n\n const applyUrl = async (): Promise<void> => {\n const u = urlVal.trim()\n if (!/^https?:\\/\\//i.test(u)) { setUrlErr(t('ruleUrlBadHttp')); return }\n setUrlBusy(true)\n setUrlErr(null)\n const res = await p.setRuleImageFromUrl(rule.id, u)\n setUrlBusy(false)\n if (res.ok) {\n setUrlOpen(false)\n setUrlVal('')\n } else {\n setUrlErr(res.error === 'invalid url' || res.error === 'unsupported scheme'\n ? t('ruleUrlBadHttp')\n : (res.error ?? t('ruleUrlFail')))\n }\n }\n\n const onExtract = async (): Promise<void> => {\n if (url === null || extracting) return\n setExtracting(true)\n try {\n const ok = await p.extractColor(rule.id)\n notify(ok ? t('extractDone') : t('extractFail'), ok)\n } catch {\n notify(t('extractFail'), false)\n } finally {\n setExtracting(false)\n }\n }\n\n /**\n * Leaving \"follow the system theme\" must not hand the user a color that has\n * nothing to do with the wallpaper they just picked, so this tries the image\n * first and only falls back to the seed. (`extractColor` is the same pass the\n * extract button runs and returns false when nothing vivid was found.)\n */\n const onPickColor = async (): Promise<void> => {\n if (url !== null) {\n setExtracting(true)\n try {\n if (await p.extractColor(rule.id)) return\n } catch {\n // fall through to the seed\n } finally {\n setExtracting(false)\n }\n }\n p.setRule(rule.id, { color: SEED_COLOR })\n }\n\n const cls = `dab-rule${active ? ' is-active' : ''}${rule.enabled ? '' : ' is-off'}`\n\n return (\n <section className={cls}>\n <div className=\"dab-rule-head\">\n <button type=\"button\" className=\"dab-icon-btn\" onClick={() => setOpen(o => !o)}\n title={open ? 'Collapse' : 'Expand'} aria-expanded={open}>\n {open ? '▾' : '▸'}\n </button>\n <span className=\"dab-rule-num\">{index + 1}</span>\n {index === 0 ? <span className=\"dab-rule-badge\">{t('ruleFallbackBadge')}</span> : null}\n <input\n className=\"dab-rule-match\" value={rule.match}\n placeholder={t('ruleMatchPlaceholder')}\n onChange={e => p.setRule(rule.id, { match: e.target.value })} />\n <button type=\"button\" className={`dab-toggle${rule.enabled ? ' is-on' : ''}`}\n role=\"switch\" aria-checked={rule.enabled} title={t('ruleEnabled')}\n onClick={() => p.setRule(rule.id, { enabled: !rule.enabled })}>\n <span className=\"dab-toggle-knob\" />\n </button>\n <button type=\"button\" className=\"dab-icon-btn\" disabled={index === 0}\n title={t('ruleUp')} onClick={() => p.moveRule(rule.id, -1)}>↑</button>\n <button type=\"button\" className=\"dab-icon-btn\" disabled={index === total - 1}\n title={t('ruleDown')} onClick={() => p.moveRule(rule.id, 1)}>↓</button>\n <button type=\"button\" className=\"dab-icon-btn dab-icon-btn-danger\"\n title={t('ruleRemove')} onClick={() => p.removeRule(rule.id)}>\n <TrashIcon size={13} />\n </button>\n </div>\n\n {open ? (\n <div className=\"dab-rule-body\">\n <div className=\"dab-rule-cols\">\n {/* ── image + layout ─────────────────────────────────────────── */}\n <div>\n <div\n className={`dab-rule-thumb${dragOver ? ' is-over' : ''}`}\n onClick={() => fileRef.current?.click()}\n onDragOver={e => { e.preventDefault(); setDragOver(true) }}\n onDragLeave={() => setDragOver(false)}\n onDrop={onDrop}>\n {url !== null\n ? <img src={url} alt=\"\" draggable={false} />\n : (\n <div className=\"dab-rule-thumb-empty\">\n <UploadIcon size={18} />\n <span>{t('ruleNoImage')}</span>\n </div>\n )}\n </div>\n\n <div className=\"dab-chip-row\" style={{ marginTop: 10 }}>\n <button type=\"button\" className=\"dab-btn\" onClick={() => fileRef.current?.click()}>\n <UploadIcon size={13} />{url === null ? t('rulePickImage') : t('ruleChangeImage')}\n </button>\n <button type=\"button\" className=\"dab-btn dab-btn-ghost\" onClick={() => setUrlOpen(o => !o)}>\n <LinkIcon size={13} />{t('ruleFromUrl')}\n </button>\n {url !== null && rule.bgMode === 'fit' ? (\n <button type=\"button\" className=\"dab-btn\" onClick={() => setEditorOpen(true)}>\n <EditIcon size={13} />{t('ruleFramingEdit')}\n </button>\n ) : null}\n {url !== null ? (\n <button type=\"button\" className=\"dab-btn dab-btn-ghost dab-btn-danger\"\n onClick={() => p.setRuleImage(rule.id, null)}>\n <TrashIcon size={13} />{t('ruleImageRemove')}\n </button>\n ) : null}\n </div>\n\n {urlOpen ? (\n <div style={{ marginTop: 10, display: 'flex', flexWrap: 'wrap', gap: 8, alignItems: 'center' }}>\n <input\n type=\"text\" className=\"dab-urlinput\" value={urlVal}\n placeholder={t('ruleUrlPlaceholder')} autoFocus\n onChange={e => setUrlVal(e.target.value)}\n onKeyDown={e => { if (e.key === 'Enter') { e.preventDefault(); void applyUrl() } }} />\n <button type=\"button\" className=\"dab-btn dab-btn-primary\" disabled={urlBusy} onClick={() => void applyUrl()}>\n {urlBusy ? t('ruleUrlApplying') : t('ruleUrlApply')}\n </button>\n <button type=\"button\" className=\"dab-btn\"\n onClick={() => { setUrlOpen(false); setUrlVal(''); setUrlErr(null) }}>\n {t('ruleUrlCancel')}\n </button>\n </div>\n ) : null}\n {urlErr !== null ? (\n <p style={{ marginTop: 8, color: 'var(--dsw-alias-state-error-primary)', fontSize: 12 }}>{urlErr}</p>\n ) : null}\n {url === null ? <p className=\"dab-hint\" style={{ marginTop: 8 }}>{t('ruleEmptyHint')}</p> : null}\n\n <div style={{ marginTop: 14 }}>\n <div className=\"dab-rule-section-title\">{t('ruleLayout')}</div>\n <div className=\"dab-chip-row\">\n {BG_MODES.map(m => (\n <button key={m.mode} type=\"button\"\n className={`dab-chip${rule.bgMode === m.mode ? ' is-active' : ''}`}\n onClick={() => p.setRule(rule.id, { bgMode: m.mode })}>\n {t(m.key)}\n </button>\n ))}\n </div>\n </div>\n </div>\n\n {/* ── color + wallpaper effects ──────────────────────────────── */}\n <div>\n <div className=\"dab-rule-section-title\">{t('ruleColor')}</div>\n {rule.color === null ? (\n <>\n <div className=\"dab-chip-row\">\n {/* This button LEAVES the system-theme state, so it says so:\n the \"系统主题\" label belongs to the clearing button below. */}\n <button type=\"button\" className=\"dab-btn\" disabled={extracting} onClick={() => void onPickColor()}>\n <DropletIcon size={14} />{extracting ? t('extracting') : t('ruleColorPick')}\n </button>\n <button type=\"button\" className=\"dab-btn\" disabled={url === null || extracting} onClick={() => void onExtract()}>\n <SparkleIcon size={14} />{extracting ? t('extracting') : t('ruleColorExtract')}\n </button>\n </div>\n <p className=\"dab-hint\" style={{ marginTop: 8 }}>{t('ruleColorNoneHint')}</p>\n <p className=\"dab-hint\" style={{ marginTop: 6 }}>{t('ruleColorPickHint')}</p>\n </>\n ) : (\n <>\n <div style={{ display: 'flex', gap: 16, alignItems: 'center', flexWrap: 'wrap' }}>\n <ColorWheel hue={wheel[0]} sat={wheel[1]} lit={wheel[2]} onChange={onColor} />\n <div className=\"dab-inputs\">\n <div className=\"dab-hex-caption\">{toHex(hslToRgb(h, s, l)).toUpperCase()}</div>\n <ColorInputs hue={wheel[0]} sat={wheel[1]} lit={wheel[2]} onChange={onColor} />\n </div>\n </div>\n <div className=\"dab-chip-row\" style={{ marginTop: 12 }}>\n <button type=\"button\" className=\"dab-btn\" disabled={url === null || extracting} onClick={() => void onExtract()}>\n <SparkleIcon size={13} />{extracting ? t('extracting') : t('ruleColorExtract')}\n </button>\n <button type=\"button\" className=\"dab-btn\" disabled={url === null} onClick={() => setPickerOpen(true)}>\n <PipetteIcon size={13} />{t('eyedropper')}\n </button>\n <button type=\"button\" className=\"dab-btn dab-btn-ghost\" onClick={() => p.setRule(rule.id, { color: null })}>\n {t('ruleColorNone')}\n </button>\n </div>\n <div className=\"dab-swatches\" style={{ marginTop: 12 }}>\n {PALETTE.map(([sh, ss, sl], i) => (\n <button\n key={i} type=\"button\" className=\"dab-swatch\"\n style={{ background: `hsl(${sh} ${Math.round(ss * 100)}% ${Math.round(sl * 100)}%)` }}\n title={toHex(hslToRgb(sh, ss, sl)).toUpperCase()}\n onClick={() => p.setRule(rule.id, { color: [sh, ss, sl] })} />\n ))}\n </div>\n </>\n )}\n\n <div style={{ marginTop: 16 }}>\n <LiveSlider\n label={t('ruleOpacity')} min={0} max={100} step={1}\n def={Math.round(rule.wallpaperOpacity * 100)} fmt={v => `${v}%`}\n onChange={v => p.setRule(rule.id, { wallpaperOpacity: v / 100 })} />\n <LiveSlider\n label={t('ruleBlur')} min={0} max={60} step={1}\n def={rule.blur} fmt={v => `${v}px`}\n onChange={v => p.setRule(rule.id, { blur: v })} />\n <p className=\"dab-hint\" style={{ marginTop: 10 }}>{t('ruleBlurHint')}</p>\n </div>\n </div>\n </div>\n </div>\n ) : null}\n\n <input ref={fileRef} type=\"file\" accept=\"image/*\" style={{ display: 'none' }} onChange={e => {\n const f = e.target.files?.[0]\n if (!f) return\n onFile(f)\n e.target.value = ''\n }} />\n\n {editorOpen && url !== null ? (\n <BgEditor\n url={url} state={rule.bgState} t={t} onClose={() => setEditorOpen(false)}\n onCommit={(z, x, y, iw, ih) => {\n p.setRule(rule.id, { bgState: { zoom: z, x, y, iw, ih } })\n setEditorOpen(false)\n }} />\n ) : null}\n\n {pickerOpen && url !== null ? (\n <ColorPicker url={url} t={t} onClose={() => setPickerOpen(false)}\n onPick={hsv => { onColor(hsv[0], hsv[1], hsv[2]); setPickerOpen(false) }} />\n ) : null}\n </section>\n )\n}\n","import { useRef } from 'react'\r\nimport type { CSSProperties } from 'react'\r\nimport type { ThemeSectionProps } from '../../types'\r\nimport { DownloadIcon, UploadIcon } from '../icons'\r\n\r\nexport function ProfilePage({ p, notify }: { p: ThemeSectionProps; notify: (msg: string, ok?: boolean) => void }) {\r\n const { t, exportTheme, importTheme } = p\r\n const importRef = useRef<HTMLInputElement>(null)\r\n\r\n const onImport = async (file: File) => {\r\n try {\r\n const ok = await importTheme(file)\r\n notify(ok ? t('importDone') : t('importFail'), ok)\r\n } catch {\r\n notify(t('importFail'), false)\r\n }\r\n }\r\n\r\n return (\r\n <>\r\n <header className=\"dab-head dab-rise\" style={{ '--d': 0 } as CSSProperties}>\r\n <div className=\"dab-overline\">Profile</div>\r\n <h2 className=\"dab-h1\">{t('pageProfile')}</h2>\r\n <p className=\"dab-desc\">{t('descProfile')}</p>\r\n </header>\r\n\r\n <div className=\"dab-profile-grid\">\r\n <section className=\"dab-card dab-card-hover dab-rise\" style={{ '--d': 1 } as CSSProperties}>\r\n <div className=\"dab-profile-ico\"><DownloadIcon size={17} /></div>\r\n <div className=\"dab-profile-title\">{t('exportCardTitle')}</div>\r\n <div className=\"dab-profile-desc\">{t('exportCardDesc')}</div>\r\n <button type=\"button\" className=\"dab-btn dab-btn-primary\" onClick={() => { exportTheme(); notify(t('toastExportDone')) }}>\r\n <DownloadIcon size={14} />{t('exportTheme')}\r\n </button>\r\n </section>\r\n\r\n <section className=\"dab-card dab-card-hover dab-rise\" style={{ '--d': 2 } as CSSProperties}>\r\n <div className=\"dab-profile-ico\"><UploadIcon size={17} /></div>\r\n <div className=\"dab-profile-title\">{t('importCardTitle')}</div>\r\n <div className=\"dab-profile-desc\">{t('importCardDesc')}</div>\r\n <button type=\"button\" className=\"dab-btn\" onClick={() => importRef.current?.click()}>\r\n <UploadIcon size={14} />{t('importTheme')}\r\n </button>\r\n <input ref={importRef} type=\"file\" accept=\"application/json,.json\" style={{ display: 'none' }} onChange={e => {\r\n const f = e.target.files?.[0]; if (!f) return\r\n void onImport(f); e.target.value = ''\r\n }} />\r\n </section>\r\n </div>\r\n\r\n <footer className=\"dab-footer dab-rise\" style={{ '--d': 3 } as CSSProperties}>\r\n <span className=\"dab-footer-mono\">dsh-background-by-model</span>\r\n <span>{t('footerTag')}</span>\r\n </footer>\r\n </>\r\n )\r\n}\r\n","/**\n * dsh-background-by-model — settings section shell.\n *\n * The host renders this section only while the settings dialog is open and the\n * section is the active nav entry, so mounting IS being visible. The section is\n * rendered INLINE inside the host settings dialog's content column (the host\n * provides the modal chrome); the shell is a left nav rail + page body. Only\n * the transient toast escapes through a Portal (the shell's container-type\n * containment would otherwise capture its fixed positioning).\n */\nimport { useEffect, useRef, useState } from 'react'\nimport type { ThemeSectionProps } from '../types'\nimport { ensureUiCss, NAV_ITEM_H, NAV_GAP } from './ui.css'\nimport { SunIcon, LayersIcon, PhotoIcon, SlidersIcon, AlertIcon, CheckIcon } from './icons'\nimport { ErrorBoundary } from './ErrorBoundary'\nimport { Portal } from './Portal'\nimport { InterfacePage } from './pages/InterfacePage'\nimport { ModelBgPage } from './pages/ModelBgPage'\nimport { ProfilePage } from './pages/ProfilePage'\n\nexport function ThemeSection(props: ThemeSectionProps) {\n ensureUiCss()\n const { t } = props\n const [page, setPage] = useState(0)\n const [toast, setToast] = useState<{ msg: string; ok: boolean } | null>(null)\n const toastTimer = useRef<number | undefined>(undefined)\n\n useEffect(() => () => window.clearTimeout(toastTimer.current), [])\n\n const notify = (msg: string, ok = true): void => {\n setToast({ msg, ok })\n window.clearTimeout(toastTimer.current)\n toastTimer.current = window.setTimeout(() => setToast(null), 2600)\n }\n\n const pages = [\n { label: t('pageInterface'), Icon: LayersIcon, node: <InterfacePage p={props} /> },\n { label: t('pageModelBg'), Icon: PhotoIcon, node: <ModelBgPage p={props} notify={notify} /> },\n { label: t('pageProfile'), Icon: SlidersIcon, node: <ProfilePage p={props} notify={notify} /> },\n ]\n\n return (\n <ErrorBoundary t={t}>\n <div className=\"dab-root\">\n <div className=\"dab-shell\">\n <nav className=\"dab-nav\">\n <div className=\"dab-brand\">\n <div className=\"dab-brand-tile\"><SunIcon size={15} /></div>\n <div>\n <div className=\"dab-brand-name\">{t('nav')}</div>\n <div className=\"dab-brand-tag\">{t('brandTag')}</div>\n </div>\n </div>\n <div className=\"dab-nav-list\">\n <div className=\"dab-nav-ind\" style={{ transform: `translateY(${page * (NAV_ITEM_H + NAV_GAP)}px)` }} />\n {pages.map((pg, i) => (\n <button\n key={pg.label} type=\"button\"\n className={`dab-nav-item${i === page ? ' is-active' : ''}`}\n onClick={() => setPage(i)}>\n <pg.Icon size={16} />\n <span>{pg.label}</span>\n </button>\n ))}\n </div>\n </nav>\n\n <div className=\"dab-page\" key={page}>\n {pages[page].node}\n </div>\n </div>\n </div>\n\n {toast ? (\n <Portal>\n <div className=\"dab-toast\" role=\"status\">\n <span className={toast.ok ? 'dab-toast-ok' : 'dab-toast-err'}>\n {toast.ok ? <CheckIcon size={14} /> : <AlertIcon size={14} />}\n </span>\n <span>{toast.msg}</span>\n </div>\n </Portal>\n ) : null}\n </ErrorBoundary>\n )\n}\n","/**\n * dsh-background-by-model — browser half entry.\n *\n * Wires the plugin lifecycle: rule resolution against the current model,\n * wallpaper layer, theme skin, viewport watch, i18n, settings-section injection,\n * boot restore and watchdogs. The heavy lifting lives in the sibling modules\n * (state / modelbg / rpc / wallpaper / components).\n */\nimport { defineStore } from './runtime'\nimport type {\n Ctx, RpcResultLike, ThemeSectionProps, PartOpacities, PartBlurs, BgRule, FetchResult, ModelFacts,\n} from './types'\nimport { NS, zh, en } from './i18n'\nimport {\n cfg, adoptConfig, imageOf, displayImageOf, setImage, newRule, nextSlot, nextRuleId, ruleById,\n normalizeRule, setActive, setModelLabel, activeRuleId, activeMatched, modelLabel, rWp, rRightbarOpacity,\n} from './state'\nimport {\n RPC_CHANNEL, initRpc, saveConfig, flushSave, persistConfig, loadPersisted,\n readImage, writeImage, deleteImage, fetchImageUrl, readDefaultModel,\n} from './rpc'\nimport {\n applyWp, teardownWp, applySettingsOverrides, applyRightbarOverrides, SETTINGS_STYLE_RULE, TRAJECTORY_STYLE_RULE,\n RIGHTBAR_STYLE_RULE, INPUT_BLUR_RULE, PLACEHOLDER_RULE, OWN_SCHEME, setHostScheme, refreshSystemTheme,\n watchParts, watchThemeResets,\n} from './wallpaper'\nimport { genTokens, extractWallpaperColor } from './utils/color'\nimport { matchRule, watchModel } from './modelbg'\nimport { ThemeSection } from './components/ThemeSection'\nimport { markOwnSheet } from './components/ui.css'\nimport { SUN_PATHS } from './components/icons'\n\nexport const name = 'dsh-background-by-model'\nexport const inject = ['slots', 'locale', 'theme', 'connection']\n\nconst CUSTOM_ID = 'custom-color'\n\nexport function apply(ctx: Ctx): void {\n // Bind the dedicated `/dsh-background-by-model` RPC caller so the persistence\n // module can reach the node half's file-backed store.\n initRpc((endpoint, payload) =>\n ctx.connection.rpc.call(RPC_CHANNEL, endpoint, payload).then((res: any) => res as RpcResultLike | undefined)\n )\n\n // ── 1. Custom theme skin, driven by the ACTIVE rule's color ────────────────\n let customDispose: (() => void) | null = null\n // Trailing debounce for the theme-skin switch (see applyActive): a color drag\n // would otherwise dispose + re-register + re-activate the host theme on every\n // pointer move.\n let skinTimer: number | null = null\n const registerCustom = (h: number, s: number, l: number): void => {\n customDispose?.()\n try {\n const { colorScheme, tokens } = genTokens(h, s, l)\n customDispose = ctx.theme.register({ id: CUSTOM_ID, colorScheme, tokens })\n } catch {\n // A live registration from an earlier HMR apply pass cannot be torn down\n // here; keep it and activate it below. Without this the duplicate-id\n // throw would abort apply and skip the wallpaper/opacity restore.\n customDispose = null\n }\n // Only activate the custom theme if it is actually registered.\n if (ctx.theme.getTheme().themes.some(t => t.id === CUSTOM_ID)) {\n ctx.theme.setTheme(CUSTOM_ID)\n }\n }\n /** A rule without a saved color means \"follow the system theme\". */\n const dropCustom = (): void => {\n customDispose?.()\n customDispose = null\n try {\n if (ctx.theme.getTheme().preference === CUSTOM_ID) ctx.theme.setTheme('system')\n } catch {\n // A host build without a `system` preference keeps its own choice.\n }\n }\n ctx.effect(() => () => {\n if (skinTimer !== null) window.clearTimeout(skinTimer)\n customDispose?.()\n }, 'dsh-background-by-model: skin dispose')\n\n // ── 2. Gradient CSS (for custom dark themes) + static rules ────────────────\n const styleEl = document.createElement('style')\n styleEl.dataset.plugin = 'dsh-background-by-model'\n markOwnSheet(styleEl)\n // The gradient only applies while applyCustomTokens marks the body with the\n // plugin's own dark-mode value, avoiding matches against the host's attribute.\n styleEl.textContent = `body[data-ds-dark-theme=\"${OWN_SCHEME}\"]::before{content:'';position:fixed;inset:0;z-index:-1;pointer-events:none;background:radial-gradient(ellipse 80% 60% at 50% 0%,rgba(255,255,255,0.03) 0%,transparent 60%)}${SETTINGS_STYLE_RULE}${TRAJECTORY_STYLE_RULE}${RIGHTBAR_STYLE_RULE}${INPUT_BLUR_RULE}` + PLACEHOLDER_RULE\n document.head.appendChild(styleEl)\n ctx.effect(() => () => { styleEl?.parentNode?.removeChild(styleEl) }, 'dsh-background-by-model: gradient')\n\n // ── 3. State store ────────────────────────────────────────────────────────\n let rev = 0\n let rulesRev = 0\n let modelText = ''\n let modelSource: 'session' | 'default' = 'default'\n // Why no per-session model is available yet ('waiting' until the sessions\n // service mounts, then the failing hop, then 'fallback'). Shown by the status\n // readout so a dead hop is never mistaken for a real model.\n let modelNote = 'waiting'\n // Text + source last acted on, so the watch's forced re-emits (and the 1.5 s\n // safety poll) cannot re-run the whole apply while nothing changed.\n let modelKey = '\\u0000'\n const store = defineStore({\n init: () => ({\n url: null as string | null,\n rev: -1,\n rulesRev: -1,\n model: '',\n modelSource: 'session' as 'session' | 'default',\n modelNote: 'waiting',\n activeRuleId: null as string | null,\n matched: false,\n }),\n actions: {\n sync: (d: any, url: string | null, r: number, rr: number, model: string, source: 'session' | 'default', note: string, id: string | null, matched: boolean) => {\n if (r > d.rev) { d.url = url; d.rev = r }\n if (rr > d.rulesRev) d.rulesRev = rr\n d.model = model\n d.modelSource = source\n d.modelNote = note\n d.activeRuleId = id\n d.matched = matched\n },\n },\n })\n let bound: { sync: (...a: any[]) => void } | null = null\n const sync = (): void => {\n rev++\n bound?.sync(rWp(), rev, rulesRev, modelLabel !== '' ? modelLabel : modelText, modelSource, modelNote, activeRuleId, activeMatched)\n }\n\n /**\n * Publish the scheme the host's own preference resolves to. The theme service\n * is the only place that knows it (a custom active theme included); the\n * wallpaper layer needs it to hand `data-ds-dark-theme` back in the host's own\n * form while a color-less rule follows that theme, instead of leaving the flag\n * off — which pins the host to its LIGHT palette on a dark system.\n */\n const syncHostScheme = (): void => {\n try {\n setHostScheme(ctx.theme.getTheme().active.colorScheme === 'dark')\n } catch {\n // A host build without a resolvable snapshot: let the wallpaper layer fall\n // back to the preference the boot script published.\n setHostScheme(null)\n }\n }\n\n /** Resolve the active rule for the current model and repaint everything. */\n const applyActive = (): void => {\n const { rule, matched } = matchRule(cfg.rules, modelText)\n setActive(rule === null ? null : rule.id, matched)\n const color = rule === null ? null : rule.color\n if (skinTimer !== null) window.clearTimeout(skinTimer)\n if (color === null) {\n // Hand the palette back BEFORE the apply below. The theme service's\n // snapshot is what tells the wallpaper layer which scheme the host itself\n // resolves to, and while our custom skin is still active that snapshot\n // reports OUR scheme — the readback would then capture the host's light\n // palette on a dark system and keep painting it (the interface only\n // recovered when some later slider drag happened to re-run an apply).\n // Dropping the skin is idempotent, so it needs none of the debouncing a\n // color drag does.\n skinTimer = null\n dropCustom()\n } else {\n // The skin is a host-visible switch (dispose + register + activate) and is\n // batched; the wallpaper and tokens below land immediately either way.\n skinTimer = window.setTimeout(() => {\n skinTimer = null\n registerCustom(color[0], color[1], color[2])\n }, 60)\n }\n syncHostScheme()\n applyWp()\n sync()\n }\n\n // ── 4. First paint + the AppFrame watch ───────────────────────────────────\n syncHostScheme()\n applyWp()\n sync()\n watchParts()\n\n // ── 5. Model watch ────────────────────────────────────────────────────────\n // The session's own durable model selection is the authority; the host default\n // is only a last resort, and the settings page labels it as such.\n const offModel = watchModel(ctx, (text, label, source, note) => {\n const key = `${text}\\u0001${source}\\u0001${note}`\n if (key === modelKey) return\n const textChanged = text !== modelText\n modelKey = key\n modelText = text\n modelSource = source\n modelNote = note\n setModelLabel(label !== '' ? label : text)\n // A note-only change (e.g. still waiting for the sessions service) must\n // refresh the readout without repainting the whole interface.\n if (textChanged) applyActive()\n else sync()\n })\n ctx.effect(() => () => offModel(), 'dsh-background-by-model: model watch')\n // A trimmed client (or one whose session is not materialized yet) leaves the\n // per-session sources empty; the host's default model is a coarse but honest\n // stand-in, tagged so the UI never claims it is this session's selection.\n void (async () => {\n if (modelText !== '') return\n const fallback = await readDefaultModel()\n if (fallback !== null && modelText === '') {\n modelKey = `${fallback}\\u0001default\\u0001fallback`\n modelText = fallback\n modelSource = 'default'\n modelNote = 'fallback'\n setModelLabel(fallback)\n applyActive()\n }\n })()\n\n // ── 6. Boot restore ───────────────────────────────────────────────────────\n void (async () => {\n const persisted = await loadPersisted()\n if (persisted !== null) {\n adoptConfig(persisted.config)\n const slots = Array.from(new Set([...persisted.slots, ...cfg.rules.map(r => r.slot)]))\n // The active rule's bytes paint first; the remaining slots stream in after\n // so a large multi-rule setup never delays the first frame.\n const priority = matchRule(cfg.rules, modelText).rule\n const first = priority === null ? null : priority.slot\n const order = first === null ? slots : [first, ...slots.filter(s => s !== first)]\n for (const slot of order) {\n if (imageOf(slot) !== null) continue\n const url = await readImage(slot)\n if (url !== null) setImage(slot, url)\n if (slot === first) applyActive()\n }\n }\n applyActive()\n })()\n\n ctx.effect(() => () => { teardownWp() }, 'dsh-background-by-model: wp cleanup')\n\n ctx.effect(() => ctx.on('theme/change', () => {\n // The custom theme's preference lives in memory, so a host adoption can\n // silently reset it; re-assert it while the active rule has a color. Guard\n // on registry presence — registerCustom disposes the old skin first, so\n // during that transient the registry lacks CUSTOM_ID.\n // The resolved scheme is read first: an OS flip while the preference is\n // `system` arrives exactly here, and a color-less rule has to follow it.\n syncHostScheme()\n if (activeRuleColor() !== null) {\n const snapshot = ctx.theme.getTheme()\n if (snapshot.preference !== CUSTOM_ID && snapshot.themes.some(t => t.id === CUSTOM_ID)) {\n ctx.theme.setTheme(CUSTOM_ID)\n }\n }\n applyWp()\n }), 'dsh-background-by-model: theme change')\n\n // Wallpaper placement is computed in absolute viewport pixels, so watch the\n // viewport itself: a fixed inset:0 sentinel's box always equals the viewport,\n // so a ResizeObserver on it catches any viewport change (window resize,\n // monitor moves, panel splitters, zoom); a resolution media query catches\n // DPI-only moves. Re-applies are coalesced to one per animation frame.\n let frame = 0\n const applySoon = (): void => {\n if (frame !== 0) return\n frame = requestAnimationFrame(() => { frame = 0; applyWp() })\n }\n const sentinel = document.createElement('div')\n sentinel.style.cssText = 'position:fixed;inset:0;pointer-events:none;visibility:hidden'\n document.body.append(sentinel)\n const viewportObserver = new ResizeObserver(applySoon)\n viewportObserver.observe(sentinel)\n const dprQuery = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`)\n dprQuery.addEventListener('change', applySoon)\n ctx.effect(() => () => {\n viewportObserver.disconnect()\n dprQuery.removeEventListener('change', applySoon)\n sentinel.remove()\n }, 'dsh-background-by-model: viewport watch')\n\n // ── 7. Locale ─────────────────────────────────────────────────────────────\n ctx.effect(() => ctx.locale.register(NS, { zh, en }) as any, 'dsh-background-by-model: i18n')\n\n /**\n * The automatic half of \"extract from image\": fill a rule's theme color from\n * the picture it just received, but only while the rule has no color at all —\n * a color the user picked (or a previous extraction produced) is never\n * overwritten, so this cannot fight a deliberate choice.\n *\n * The decode is asynchronous, so the \"still empty?\" question is asked AGAIN on\n * arrival: a color chosen while it ran must win over the one being computed.\n */\n const maybeAutoExtract = async (id: string): Promise<void> => {\n if (!cfg.autoExtract) return\n const rule = ruleById(id)\n if (rule === null || rule.color !== null) return\n const url = displayImageOf(rule.slot)\n if (url === null) return\n let hsl: [number, number, number] | null = null\n try { hsl = await extractWallpaperColor(url, rule.bgState) } catch { hsl = null }\n if (hsl === null) return\n const current = ruleById(id)\n if (current === null || current.color !== null) return\n current.color = hsl\n rulesRev++\n saveConfig()\n if (id === activeRuleId) applyActive()\n else sync()\n }\n\n // ── 8. Section injection ──────────────────────────────────────────────────\n // The section's props are built ONCE by the slot host, so anything that changes\n // at runtime rides the store; the two exceptions are the context (needed by the\n // host self-check probe) and the language (read at build time, refreshed when\n // the section is rebuilt).\n const activeLang = (): 'zh' | 'en' => {\n try {\n const snapshot = ctx.locale.getSnapshot()\n return typeof snapshot?.active === 'string' && snapshot.active.toLowerCase().startsWith('zh') ? 'zh' : 'en'\n } catch {\n return 'en'\n }\n }\n /** The model-resolution facts the host self-check reports, read on demand. */\n const readModelFacts = (): ModelFacts => {\n const rule = activeRuleId === null ? null : ruleById(activeRuleId)\n return {\n text: modelText,\n source: modelSource,\n note: modelNote,\n rule: rule === null ? '' : (rule.match !== '' ? rule.match : rule.id),\n matched: activeMatched,\n }\n }\n const sectionInject = (actions: { sync: (...a: any[]) => void }): Omit<ThemeSectionProps, 'useStore'> => {\n bound = actions\n sync()\n return {\n t: ctx.locale.bind(NS),\n ctx,\n lang: activeLang(),\n readModelFacts,\n imageOf: (slot: string) => displayImageOf(slot),\n addRule: (): string => {\n const rule = newRule(nextRuleId(), nextSlot())\n cfg.rules.push(rule)\n rulesRev++\n persistConfig()\n applyActive()\n return rule.id\n },\n removeRule: (id: string): void => {\n const idx = cfg.rules.findIndex(r => r.id === id)\n if (idx < 0) return\n const [rule] = cfg.rules.splice(idx, 1)\n if (rule !== undefined && !cfg.rules.some(r => r.slot === rule.slot)) {\n setImage(rule.slot, null)\n void deleteImage(rule.slot)\n }\n rulesRev++\n persistConfig()\n applyActive()\n },\n moveRule: (id: string, dir: -1 | 1): void => {\n const idx = cfg.rules.findIndex(r => r.id === id)\n const to = idx + dir\n if (idx < 0 || to < 0 || to >= cfg.rules.length) return\n const [rule] = cfg.rules.splice(idx, 1)\n cfg.rules.splice(to, 0, rule!)\n rulesRev++\n persistConfig()\n applyActive()\n },\n setRule: (id: string, patch: Partial<BgRule>): void => {\n const rule = ruleById(id)\n if (rule === null) return\n Object.assign(rule, patch)\n const normalized = normalizeRule(rule)\n if (normalized !== null) Object.assign(rule, normalized)\n rulesRev++\n // Text/color/slider edits arrive per keystroke and per pointer move, so\n // the write is coalesced; structural edits below stay immediate.\n saveConfig()\n if (id === activeRuleId) applyActive()\n else sync()\n },\n setRuleImage: (id: string, dataUrl: string | null): void => {\n const rule = ruleById(id)\n if (rule === null) return\n setImage(rule.slot, dataUrl)\n void (dataUrl === null ? deleteImage(rule.slot) : writeImage(rule.slot, dataUrl))\n if (id === activeRuleId) applyActive()\n else sync()\n // A rule that has never been themed should simply come out themed; an\n // explicit color (or a cleared one the user set on purpose) is left be.\n if (dataUrl !== null) void maybeAutoExtract(id)\n },\n setRuleImageFromUrl: async (id: string, url: string): Promise<FetchResult> => {\n const rule = ruleById(id)\n if (rule === null) return { ok: false, error: 'unknown rule' }\n const res = await fetchImageUrl(rule.slot, url)\n if (res.ok) {\n setImage(rule.slot, res.dataUrl ?? null)\n if (id === activeRuleId) applyActive()\n else sync()\n void maybeAutoExtract(id)\n }\n return res\n },\n extractColor: async (id: string): Promise<boolean> => {\n const rule = ruleById(id)\n if (rule === null) return false\n const url = displayImageOf(rule.slot)\n if (url === null) return false\n const hsl = await extractWallpaperColor(url, rule.bgState)\n if (hsl === null) return false\n rule.color = hsl\n rulesRev++\n saveConfig()\n if (id === activeRuleId) applyActive()\n else sync()\n return true\n },\n setOps: (ops: PartOpacities): void => { cfg.opacities = ops; applyWp(); sync(); saveConfig() },\n setBlurs: (blurs: PartBlurs): void => { cfg.blurs = blurs; applyWp(); sync(); saveConfig() },\n setSop: (v: number): void => { cfg.settingsOpacity = v; applySettingsOverrides(v); saveConfig() },\n // The file-preview panel owns its surface from the first drag on; a null\n // hands it back to the main-background slider.\n setRightbarOpacity: (v: number | null): void => {\n cfg.rightbarOpacity = v\n applyRightbarOverrides(rRightbarOpacity())\n saveConfig()\n },\n setAutoExtract: (v: boolean): void => { cfg.autoExtract = v; saveConfig(); sync() },\n // Download every rule plus its image as one JSON file.\n exportTheme: (): void => {\n const images: Record<string, string> = {}\n for (const rule of cfg.rules) {\n const url = imageOf(rule.slot)\n if (url !== null) images[rule.slot] = url\n }\n const payload = {\n version: 3,\n exportedAt: new Date().toISOString(),\n config: cfg,\n images,\n }\n const blob = new Blob([JSON.stringify(payload, null, 2)], { type: 'application/json' })\n const url = URL.createObjectURL(blob)\n const a = document.createElement('a')\n a.href = url\n a.download = 'dsh-background-by-model-theme.json'\n a.click()\n URL.revokeObjectURL(url)\n },\n // Import: replaces the whole rule set and every rule image.\n importTheme: async (file: File): Promise<boolean> => {\n try {\n const data: unknown = JSON.parse(await file.text())\n if (!data || typeof data !== 'object') return false\n const d = data as { version?: number; config?: unknown; images?: unknown }\n if (typeof d.config !== 'object' || d.config === null) return false\n adoptConfig(d.config)\n const incoming = (d.images ?? {}) as Record<string, unknown>\n const keep = new Set<string>()\n for (const rule of cfg.rules) {\n keep.add(rule.slot)\n const raw = incoming[rule.slot]\n if (typeof raw === 'string' && /^data:image\\//.test(raw)) {\n setImage(rule.slot, raw)\n void writeImage(rule.slot, raw)\n } else {\n setImage(rule.slot, null)\n void deleteImage(rule.slot)\n }\n }\n // Slots the imported config no longer references are released.\n for (const slot of Object.keys(incoming)) {\n if (!keep.has(slot) && /^[A-Za-z0-9_-]{1,32}$/.test(slot)) void deleteImage(slot)\n }\n persistConfig()\n applyActive()\n return true\n } catch {\n return false\n }\n },\n }\n }\n ctx.slots.inject('settings.section', () => ctx.slots.register({\n name: 'settings.section', id: 'dsh-background-by-model', order: 35,\n label: () => ctx.locale.bind(NS)('nav'),\n locale: NS, store, inject: sectionInject,\n }, ThemeSection as any))\n\n // ── 9. Settings-nav icon ──────────────────────────────────────────────────\n // The harness derives the nav glyph from the section id (unknown ids fall back\n // to the settings gear) with no plugin hook, so patch the mounted nav cell in\n // place — find the cell whose label matches this section's nav text and swap\n // its svg for the sun glyph.\n const navLabel = (): string => ctx.locale.bind(NS)('nav')\n const applyNavIcon = (): void => {\n const panel = document.querySelector<HTMLElement>('[role=\"dialog\"][aria-modal=\"true\"][aria-labelledby]')\n const nav = panel?.querySelector('nav')\n if (!nav) return\n const target = navLabel()\n for (const cell of Array.from(nav.querySelectorAll('button'))) {\n const label = cell.querySelector('span')\n if (label && label.textContent?.trim() === target) {\n const svg = cell.querySelector('svg')\n if (svg && svg.dataset.dshAnyIcon !== '1') {\n const sun = document.createElementNS('http://www.w3.org/2000/svg', 'svg')\n sun.setAttribute('width', '16')\n sun.setAttribute('height', '16')\n sun.setAttribute('viewBox', '0 0 16 16')\n sun.setAttribute('fill', 'none')\n sun.setAttribute('xmlns', 'http://www.w3.org/2000/svg')\n sun.dataset.dshAnyIcon = '1'\n sun.innerHTML = SUN_PATHS\n svg.replaceWith(sun)\n }\n return\n }\n }\n }\n let navIconObserver: MutationObserver | null = null\n const watchNavIcon = (): void => {\n if (navIconObserver !== null || typeof MutationObserver === 'undefined') return\n navIconObserver = new MutationObserver(records => {\n // React only when the settings panel (or its nav) is (re)created, so\n // chat-content mutations don't trigger a scan.\n const relevant = records.some(r => {\n for (const n of r.addedNodes) {\n if (n.nodeType !== 1) continue\n const el = n as Element\n if (el.matches?.('[role=\"dialog\"][aria-modal=\"true\"][aria-labelledby]') || el.querySelector?.('[role=\"dialog\"][aria-modal=\"true\"][aria-labelledby]')) return true\n }\n return false\n })\n if (relevant) applyNavIcon()\n })\n navIconObserver.observe(document.body, { childList: true, subtree: true })\n applyNavIcon()\n }\n watchNavIcon()\n ctx.effect(() => () => { navIconObserver?.disconnect(); navIconObserver = null }, 'dsh-background-by-model: nav icon watch')\n\n // ── 10. Deferred boot restore ─────────────────────────────────────────────\n // The theme service and the host settings scope settle asynchronously after\n // this apply, so the synchronous restore can be observed mid-flight — a late\n // host adoption resets the preference, or the presenter re-applies over our\n // overrides. Re-running the restore a few ticks later guarantees the saved\n // records land.\n const restoreSaved = (): void => {\n syncHostScheme()\n const color = activeRuleColor()\n if (color !== null) {\n const snapshot = ctx.theme.getTheme()\n if (!snapshot.themes.some(t => t.id === CUSTOM_ID)) {\n // Theme missing (host adoption dropped it): re-register + activate.\n registerCustom(color[0], color[1], color[2])\n } else if (snapshot.preference !== CUSTOM_ID) {\n // Theme present but inactive: just re-assert the preference. Calling\n // registerCustom here would dispose + re-create the skin, flashing the\n // interface back to the system theme for a frame on every boot.\n ctx.theme.setTheme(CUSTOM_ID)\n }\n }\n applyWp()\n }\n const restoreTimers = [300, 1500].map(delay => window.setTimeout(restoreSaved, delay))\n ctx.effect(() => () => { restoreTimers.forEach(id => window.clearTimeout(id)) }, 'dsh-background-by-model: boot restore')\n\n // ── 11. Theme watchdog ────────────────────────────────────────────────────\n // The theme service keeps only built-in preferences in memory, so ANY\n // host-scope adoption can silently drop the custom theme — reverting the label\n // colors and the inner surfaces to the system palette. While the active rule\n // carries a color, re-register and re-assert on a slow interval.\n //\n // A color-less rule needs the same slow re-check for the opposite reason: it\n // paints from the HOST palette, which the host can re-project (or which the\n // scheme flag can fall behind) with no event of ours to hang a repaint on.\n // Without this, such a rule keeps whatever palette it read first — the light\n // one, if the read happened while the plugin's own light palette was still\n // forcing the flag off — until an unrelated apply happens to run.\n const watchdogId = window.setInterval(() => {\n syncHostScheme()\n const color = activeRuleColor()\n if (color === null) {\n refreshSystemTheme()\n return\n }\n const snapshot = ctx.theme.getTheme()\n let changed = false\n if (!snapshot.themes.some(t => t.id === CUSTOM_ID)) {\n registerCustom(color[0], color[1], color[2])\n changed = true\n } else if (snapshot.preference !== CUSTOM_ID) {\n ctx.theme.setTheme(CUSTOM_ID)\n changed = true\n }\n if (changed) applyWp()\n }, 1000)\n ctx.effect(() => () => { window.clearInterval(watchdogId) }, 'dsh-background-by-model: theme watchdog')\n\n // ── 12. Theme-reset watchdog ──────────────────────────────────────────────\n const disposeThemeResets = watchThemeResets()\n ctx.effect(() => () => { disposeThemeResets() }, 'dsh-background-by-model: theme resets watch')\n\n // ── 13. Flush pending writes on page hide ─────────────────────────────────\n const onPageHide = (): void => flushSave()\n window.addEventListener('pagehide', onPageHide)\n ctx.effect(() => () => window.removeEventListener('pagehide', onPageHide), 'dsh-background-by-model: pagehide flush')\n}\n\n/** Color of the currently active rule, or null when it uses the system theme. */\nfunction activeRuleColor(): [number, number, number] | null {\n if (activeRuleId === null) return null\n const rule = ruleById(activeRuleId)\n return rule === null ? null : rule.color\n}\n"],"mappings":";;;;;;;;;;EAsBA,SAAS,eAA4B;GACnC,IAAI;IAGF,OAAO,QAAQ,+BAA+B;GAChD,QAAQ,CAER;GAEA,OAAO,QAAQ,wCAAwC;EACzD;EAEA,MAAa,cAAmB,aAAa,CAAC,CAAC;;;EClC/C,MAAa,KAAK;EAElB,MAAa,KAA6B;GACxC,KAAK;GAAQ,UAAU;GAAU,OAAO;GACxC,eAAe;GAAM,aAAa;GAAQ,aAAa;GACvD,eAAe;GACf,aAAa;GACb,aAAa;GAEb,SAAS;GACT,WAAW;GAAO,QAAQ;GAC1B,aAAa;GAAO,eAAe;GAAO,eAAe;GAAW,gBAAgB;GACpF,OAAO;GAAW,cAAc;GAAS,cAAc;GACvD,WAAW;GAIX,mBAAmB;GACnB,yBAAyB;GACzB,qBAAqB;GACrB,qBAAqB;GACrB,wBAAwB;GACxB,0BAA0B;GAE1B,YAAY;GACZ,WAAW;GACX,aAAa;GACb,mBAAmB;GACnB,kBAAkB;GAClB,WAAW;GACX,gBAAgB;GAChB,YAAY;GACZ,aAAa;GACb,aAAa;GACb,iBAAiB;GACjB,SAAS;GACT,mBAAmB;GACnB,gBAAgB;GAChB,sBAAsB;GACtB,aAAa;GACb,QAAQ;GAAM,UAAU;GAAM,YAAY;GAC1C,aAAa;GACb,eAAe;GAAQ,iBAAiB;GACxC,aAAa;GAAO,oBAAoB;GACxC,cAAc;GAAM,eAAe;GAAM,iBAAiB;GAC1D,gBAAgB;GAAuB,aAAa;GACpD,iBAAiB;GACjB,eAAe;GACf,WAAW;GACX,eAAe;GACf,mBAAmB;GAGnB,eAAe;GACf,mBAAmB;GACnB,kBAAkB;GAClB,YAAY;GACZ,aAAa;GACb,iBAAiB;GACjB,mBAAmB;GACnB,aAAa;GACb,UAAU;GACV,cAAc;GAEd,WAAW;GACX,aAAa;GACb,YAAY;GAEZ,WAAW;GAAM,YAAY;GA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AAG,GAAI;GACP,IAAI,mBAAmB;IAAE,OAAO,cAAc,UAAU;GAAE,GAAG,yCAAyC;GAGtG,MAAM,qBAAqB,iBAAiB;GAC5C,IAAI,mBAAmB;IAAE,mBAAmB;GAAE,GAAG,6CAA6C;GAG9F,MAAM,mBAAyB,UAAU;GACzC,OAAO,iBAAiB,YAAY,UAAU;GAC9C,IAAI,mBAAmB,OAAO,oBAAoB,YAAY,UAAU,GAAG,yCAAyC;EACtH;;EAGA,SAAS,kBAAmD;GAC1D,IAAI,iBAAiB,MAAM,OAAO;GAClC,MAAM,OAAO,SAAS,YAAY;GAClC,OAAO,SAAS,OAAO,OAAO,KAAK;EACrC"}
|
|
1
|
+
{"version":3,"file":"client.js","names":["BG_MODES","clamp","clamp","Component","useState","createPortal","useRef","memo","useRef","useState","useCallback","toHex","useState","useRef","toHex","useRef","useState","useCallback","useState","useRef","useCallback","useState","useRef","useRef","useState","useRef"],"sources":["../src/client/runtime.ts","../src/client/i18n.ts","../src/schema.ts","../src/client/state.ts","../src/client/rpc.ts","../src/client/utils/color.ts","../src/client/components/ui.css.ts","../src/client/wallpaper.ts","../src/client/modelbg.ts","../src/client/components/icons.tsx","../src/client/components/ErrorBoundary.tsx","../src/client/components/Portal.tsx","../src/client/components/LiveSlider.tsx","../src/client/components/pages/InterfacePage.tsx","../src/client/utils/image.ts","../src/client/components/ColorWheel.tsx","../src/client/components/ColorInputs.tsx","../src/client/components/ColorPicker.tsx","../src/client/components/BgEditor.tsx","../src/client/components/pages/ModelBgPage.tsx","../src/client/components/pages/ProfilePage.tsx","../src/client/components/ThemeSection.tsx","../src/client/index.tsx"],"sourcesContent":["/**\r\n * Harness-version-agnostic access to the client runtime.\r\n *\r\n * Before dsh 0.1.2 the store primitive lived on the composite package\r\n * `@deepseek-ai/dsh-client-runtime` (the `/client` subpath). The new harness\r\n * split it into `@deepseek-ai/dsh-client-store`. Both specifiers are kept\r\n * external so they resolve against the host client-module table; a missing\r\n * table entry on one side throws (the \"missed the module table\" error) and is\r\n * caught, falling through to the other package. This lets one bundle load on\r\n * both the old npm release and the new source.\r\n *\r\n * The host's synchronous `require` is injected by the loader into the bundle\r\n * factory; tsdown keeps these two bare specifiers as external CJS requires so\r\n * they bind to that factory `require`.\r\n */\r\n\r\n/* eslint-disable @typescript-eslint/no-explicit-any */\r\n\r\ninterface StoreModule {\r\n defineStore: any\r\n}\r\n\r\nfunction resolveStore(): StoreModule {\r\n try {\r\n // New harness (dsh >= 0.1.2): dedicated store package after the runtime\r\n // was split. Missing here means the loader table has no such row → throw.\r\n return require('@deepseek-ai/dsh-client-store') as StoreModule\r\n } catch {\r\n /* fall through to the legacy composite runtime below */\r\n }\r\n // Legacy harness (npm release): composite runtime, /client subpath.\r\n return require('@deepseek-ai/dsh-client-runtime/client') as StoreModule\r\n}\r\n\r\nexport const defineStore: any = resolveStore().defineStore","export const NS = 'settings.anyBg'\r\n\r\nexport const zh: Record<string, string> = {\r\n nav: '模型背景', brandTag: '按模型换背景', close: '关闭',\r\n pageInterface: '界面', pageModelBg: '模型背景', pageProfile: '配置',\r\n descInterface: '为主界面的各个区域单独调节透明度与模糊,营造空间层次感。这里的设置对所有模型生效',\r\n descModelBg: '每条规则 = 一个匹配串 + 一套背景外观。切换模型时,从上往下找第一条匹配串出现在模型名里的规则;都没中就使用第 1 条',\r\n descProfile: '把当前全部规则连同图片导出备份,或从文件一键恢复',\r\n\r\n uiTitle: '主界面',\r\n uiOpacity: '透明度', uiBlur: '模糊度',\r\n uiOpacityBg: '主背景', uiOpacitySide: '左侧栏', uiOpacityCard: '卡片与菜单面板', uiOpacityInput: '输入框与控件',\r\n uiSop: '设置界面透明度', uiChatRegion: '对话文本框', uiTrajectory: '轨迹页',\r\n uiPreview: '右侧栏',\r\n\r\n // Only the diagnostics survive: the model/rule readout they used to sit under\r\n // is gone (the match tester at the top of the page answers the same question).\r\n statusUnknownHint: '检测不到时一律使用第 1 条可用规则;切换一次模型或稍等片刻会自动重试',\r\n statusSourceDefaultHint: '只读到宿主默认模型,它不是本会话当前选择的模型;本会话的模型选择可用后会自动纠正',\r\n statusNoteNoService: '仍未拿到会话服务(会话控制器晚于本插件加载),正在自动重试',\r\n statusNoteNoSession: '会话服务已就绪,但还没有当前会话 id',\r\n statusNoteNoProjection: '拿不到本会话的模型选择投影(binding / projections 不可用)',\r\n statusNoteEmptySelection: '本会话的模型选择投影还没有值(切一次模型即可写入)',\r\n\r\n rulesTitle: '规则列表',\r\n rulesHint: '从上到下即为优先级。规则 1 同时兼任兜底:所有匹配串都没命中时使用它',\r\n tryoutTitle: '匹配试跑',\r\n tryoutPlaceholder: '输入模型名,如 deepseek-flash',\r\n tryoutUseCurrent: '填入当前模型',\r\n tryoutHit: '命中规则',\r\n tryoutFallback: '无匹配 · 走兜底规则',\r\n tryoutNone: '没有可用规则(规则需要启用并有图片)',\r\n tryoutEmpty: '输入模型名即可试跑',\r\n autoExtract: '选图后自动取主题色',\r\n autoExtractHint: '只在规则还没有颜色时自动取色,绝不覆盖你手动选的颜色',\r\n ruleAdd: '新增规则',\r\n ruleFallbackBadge: '兜底',\r\n ruleMatchLabel: '匹配串',\r\n ruleMatchPlaceholder: '如 flash / glm(忽略大小写,留空则不参与匹配)',\r\n ruleEnabled: '启用',\r\n ruleUp: '上移', ruleDown: '下移', ruleRemove: '删除规则',\r\n ruleNoImage: '尚未选择图片',\r\n rulePickImage: '选择图片', ruleChangeImage: '更换图片',\r\n ruleFromUrl: '从网址', ruleUrlPlaceholder: '粘贴图片网址 https://…',\r\n ruleUrlApply: '应用', ruleUrlCancel: '取消', ruleUrlApplying: '加载中…',\r\n ruleUrlBadHttp: '仅支持 http/https 图片网址', ruleUrlFail: '获取图片失败',\r\n ruleImageRemove: '移除图片',\r\n ruleEmptyHint: '这条规则还没有图片,不会被匹配到,也不会作为兜底',\r\n ruleColor: '主题色',\r\n ruleColorNone: '跟随系统主题',\r\n ruleColorNoneHint: '未设颜色时跟随系统主题:界面用宿主的配色,壁纸与各部位的透明度、模糊照旧生效',\r\n // Shown where a rule has NO color yet: pressing it picks a color, which is the\r\n // opposite of what the button above does, so it must not borrow that label.\r\n ruleColorPick: '自定义颜色',\r\n ruleColorPickHint: '优先从本图取色,取不到就用默认色',\r\n ruleColorExtract: '从本图提取',\r\n ruleLayout: '布局模式',\r\n ruleFraming: '取景',\r\n ruleFramingEdit: '编辑位置',\r\n ruleFramingLocked: '仅「适应」模式可编辑位置',\r\n ruleOpacity: '背景透明度',\r\n ruleBlur: '背景模糊',\r\n ruleBlurHint: '背景模糊作用于壁纸层;界面页里的模糊作用于界面各区域,两者互不影响',\r\n\r\n colorHint: '在色轮外圈选择色相,在内部方形中调整饱和度和明度;双击滑块可恢复默认值',\r\n swatchTitle: '灵感色板',\r\n hexCaption: '当前颜色',\r\n\r\n bgModeFit: '适应', bgModeFill: '填充', bgModeStretch: '拉伸', bgModeTile: '平铺', bgModeCenter: '居中',\r\n editorTitle: '背景编辑器', editorHint: '拖动移动画面,滚轮缩放大小',\r\n editorCommit: '确认', editorCancel: '取消', editorReset: '重置',\r\n\r\n extractColor: '从图片提取主题色', extracting: '取色中…',\r\n extractNoWp: '请先为该规则选择图片',\r\n extractDone: '已应用图片配色',\r\n extractFail: '未在这张图里找到鲜明的颜色,请换一张',\r\n eyedropper: '从图片取色',\r\n pickerTitle: '从图片取色',\r\n pickerHint: '移动鼠标预览颜色,点击图片选取为主题色',\r\n pickerClose: '关闭',\r\n\r\n crashTitle: '界面渲染出错',\r\n crashDesc: '设置面板遇到问题,点击下方按钮重置后重试',\r\n crashReset: '重置面板',\r\n\r\n exportTheme: '导出配置', importTheme: '导入配置',\r\n exportCardTitle: '导出配置',\r\n exportCardDesc: '把全部规则、每条规则的颜色/布局/透明度/模糊与图片打包为 dsh-background-by-model-theme.json',\r\n importCardTitle: '导入配置',\r\n importCardDesc: '从之前导出的 JSON 文件一键恢复全部规则(会覆盖当前规则与图片)',\r\n toastExportDone: '配置文件已开始下载',\r\n importDone: '已导入配置',\r\n importFail: '导入失败,文件格式不正确',\r\n footerTag: '按模型换背景插件',\r\n}\r\n\r\nexport const en: Record<string, string> = {\r\n nav: 'Model background', brandTag: 'Per-model wallpaper', close: 'Close',\r\n pageInterface: 'Interface', pageModelBg: 'Model background', pageProfile: 'Profile',\r\n descInterface: 'Tune opacity and blur per surface to build depth. These settings are global and apply to every model',\r\n descModelBg: 'Each rule is a match string plus one look. On a model switch the list is scanned top-down for the first match string contained in the model name; if nothing hits, rule 1 is used',\r\n descProfile: 'Back up every rule together with its image, or restore one from a file',\r\n\r\n uiTitle: 'Interface',\r\n uiOpacity: 'Opacity', uiBlur: 'Blur',\r\n uiOpacityBg: 'Main background', uiOpacitySide: 'Left panel', uiOpacityCard: 'Cards & menus', uiOpacityInput: 'Input & controls',\r\n uiSop: 'Settings interface opacity', uiChatRegion: 'Conversation text frame', uiTrajectory: 'Trajectory view',\r\n uiPreview: 'Right panel',\r\n\r\n // Only the diagnostics survive: the model/rule readout they used to sit under\r\n // is gone (the match tester at the top of the page answers the same question).\r\n statusUnknownHint: 'Without a detected model rule 1 is always used; switching the model once or waiting a moment retries automatically',\r\n statusSourceDefaultHint: 'Only the host-wide default model could be read — that is not necessarily this session\\'s selection. It self-corrects once this session\\'s model selection is available.',\r\n statusNoteNoService: 'The sessions service is not available yet (the session controller loads after this plugin); retrying automatically',\r\n statusNoteNoSession: 'The sessions service is up but reports no current session yet',\r\n statusNoteNoProjection: 'This session\\'s model-selection projection is unreachable (no binding / projections)',\r\n statusNoteEmptySelection: 'The model-selection projection exists but carries no value yet (selecting a model once writes it)',\r\n\r\n rulesTitle: 'Rules',\r\n rulesHint: 'Top to bottom is the priority. Rule 1 doubles as the fallback — it is used when no match string hits',\r\n tryoutTitle: 'Match test',\r\n tryoutPlaceholder: 'Type a model name, e.g. deepseek-flash',\r\n tryoutUseCurrent: 'Use current model',\r\n tryoutHit: 'matches rule',\r\n tryoutFallback: 'no match · fallback rule',\r\n tryoutNone: 'No usable rule (a rule needs to be enabled and have an image)',\r\n tryoutEmpty: 'Type a model name to test the list',\r\n autoExtract: 'Extract the theme color when an image is chosen',\r\n autoExtractHint: 'Only fills a rule that has no color yet — a color you picked is never overwritten',\r\n ruleAdd: 'Add rule',\r\n ruleFallbackBadge: 'fallback',\r\n ruleMatchLabel: 'Match',\r\n ruleMatchPlaceholder: 'e.g. flash / glm (case-insensitive, empty never matches)',\r\n ruleEnabled: 'Enabled',\r\n ruleUp: 'Move up', ruleDown: 'Move down', ruleRemove: 'Remove rule',\r\n ruleNoImage: 'No image yet',\r\n rulePickImage: 'Choose image', ruleChangeImage: 'Replace image',\r\n ruleFromUrl: 'From URL', ruleUrlPlaceholder: 'Paste an image URL https://…',\r\n ruleUrlApply: 'Apply', ruleUrlCancel: 'Cancel', ruleUrlApplying: 'Loading…',\r\n ruleUrlBadHttp: 'Only http/https image URLs are supported', ruleUrlFail: 'Could not fetch the image',\r\n ruleImageRemove: 'Remove image',\r\n ruleEmptyHint: 'This rule has no image — it can neither match nor serve as the fallback',\r\n ruleColor: 'Theme color',\r\n ruleColorNone: 'Follow system theme',\r\n ruleColorNoneHint: 'Without a color this rule follows the system theme: the host palette paints the interface while the wallpaper and every opacity/blur slider keep working',\r\n // Shown where a rule has NO color yet: pressing it picks a color, which is the\r\n // opposite of what the button above does, so it must not borrow that label.\r\n ruleColorPick: 'Custom color',\r\n ruleColorPickHint: 'Extracts from this image when it can, otherwise uses a default color',\r\n ruleColorExtract: 'Extract from image',\r\n ruleLayout: 'Layout mode',\r\n ruleFraming: 'Framing',\r\n ruleFramingEdit: 'Edit position',\r\n ruleFramingLocked: 'Position editing is only available in Fit mode',\r\n ruleOpacity: 'Background opacity',\r\n ruleBlur: 'Background blur',\r\n ruleBlurHint: 'Background blur affects the wallpaper layer; the blur on the Interface page affects interface surfaces — they are independent',\r\n\r\n colorHint: 'Pick hue on the outer ring, adjust saturation & lightness in the square; double-click a slider to reset',\r\n swatchTitle: 'Quick swatches',\r\n hexCaption: 'Current color',\r\n\r\n bgModeFit: 'Fit', bgModeFill: 'Fill', bgModeStretch: 'Stretch', bgModeTile: 'Tile', bgModeCenter: 'Center',\r\n editorTitle: 'Background editor', editorHint: 'Drag to move, scroll to zoom',\r\n editorCommit: 'Confirm', editorCancel: 'Cancel', editorReset: 'Reset',\r\n\r\n extractColor: 'Extract from image', extracting: 'Extracting…',\r\n extractNoWp: 'Choose an image for this rule first',\r\n extractDone: 'Image colors applied',\r\n extractFail: 'No vivid color found in this image, try another',\r\n eyedropper: 'Eyedropper',\r\n pickerTitle: 'Pick from image',\r\n pickerHint: 'Hover to preview, click to pick as the theme color',\r\n pickerClose: 'Close',\r\n\r\n crashTitle: 'Section crashed',\r\n crashDesc: 'The panel hit an error. Reset below to recover.',\r\n crashReset: 'Reset panel',\r\n\r\n exportTheme: 'Export', importTheme: 'Import',\r\n exportCardTitle: 'Export profile',\r\n exportCardDesc: 'Bundle every rule — color, layout, opacity, blur — and its image into dsh-background-by-model-theme.json',\r\n importCardTitle: 'Import profile',\r\n importCardDesc: 'Restore every rule and image from a previously exported JSON file (replaces the current set)',\r\n toastExportDone: 'Export started',\r\n importDone: 'Profile imported',\r\n importFail: 'Import failed — invalid file',\r\n footerTag: 'Per-model wallpaper plugin',\r\n}\r\n","/**\n * The persisted configuration shape — declared exactly ONCE, for both halves.\n *\n * This shape used to be written out twice: the node half owns persistence and\n * sanitizes every write, the browser half owns the UI and its own reading of the\n * same file. A field added to only one side was silently dropped by the other\n * side's sanitizer — the matching slider stayed live in memory, `writeConfig`\n * wrote a config without it, and the next load fell back to the default.\n * `blurs.rightbar` / `rightbarOpacity` in 0.3.2 was exactly that bug, and the key\n * lists were duplicated 6 times across the two halves, so it was due to happen.\n *\n * The types, the key lists, the defaults and the pure normalizers therefore live\n * here and both halves import them: adding a field means editing this file, and\n * the two halves cannot disagree about the shape. The host additionally logs one\n * warning per unknown key while sanitizing a write (see `warnUnknownConfigKeys`\n * in `src/index.ts`), so a field that reaches the node half without being\n * declared here shows up in the host log instead of quietly disappearing.\n *\n * Nothing in this module may touch the DOM, Node or the Cordis context: it is\n * imported by the browser bundle and by the node half alike.\n */\n\n/** Placement state of one background image (zoom + fractional center + intrinsic size). */\nexport interface BgState { zoom: number; x: number; y: number; iw: number; ih: number }\n\nexport const DEFAULT_BG_STATE: BgState = { zoom: 1, x: 0, y: 0, iw: 0, ih: 0 }\n\n/** Adaptive placement of a background image. */\nexport type BgMode = 'fit' | 'fill' | 'stretch' | 'tile' | 'center'\n\n/** Every accepted `bgMode`, in UI order. */\nexport const BG_MODES: readonly BgMode[] = ['fit', 'fill', 'stretch', 'tile', 'center']\n\n/**\n * Main interface opacities (0..1), global (Interface page):\n * `bg` main background (`--dsw-alias-bg-base`)\n * `sidebar` sidebar (`--dsw-specific-sidebar-fill`)\n * `card` cards/panels (`--dsw-alias-bg-layer-1/2/3`, `--dsw-specific-menu`\n * and its 0.1.7 alias `--dsw-menu-surface-fill`)\n * `input` input/control surfaces (`--dsw-specific-input-major`)\n */\nexport const PART_OPACITY_KEYS = ['bg', 'sidebar', 'card', 'input'] as const\n\n/** Per-part main interface opacities (0..1), keyed BY the list above. */\nexport type PartOpacities = Record<(typeof PART_OPACITY_KEYS)[number], number>\n\nexport const DEFAULT_PART_OPACITIES: PartOpacities = { bg: 0.85, sidebar: 0.93, card: 1, input: 1 }\n\n/**\n * Interface blur (px, 0..60), global (Interface page):\n * `bg` main background (AppFrame grid)\n * `sidebar` sidebar column\n * `card` cards/panels (center + details columns, dialog option panels)\n * `settings` settings panel\n * `chat` conversation text region (message column of the chat view)\n * `trajectory` trajectory view surface\n * `rightbar` file-preview panel — the right sidebar a file click opens\n * `input` input/control surfaces ([data-composer-card], [data-cordis-panel])\n */\nexport const PART_BLUR_KEYS = ['bg', 'sidebar', 'card', 'settings', 'chat', 'trajectory', 'rightbar', 'input'] as const\n\n/** Per-part interface blur (px, 0..60), keyed BY the list above. */\nexport type PartBlurs = Record<(typeof PART_BLUR_KEYS)[number], number>\n\nexport const DEFAULT_PART_BLURS: PartBlurs = {\n bg: 0, sidebar: 0, card: 0, settings: 0, chat: 0, trajectory: 0, rightbar: 0, input: 0,\n}\n\n/**\n * One model rule: a match string plus everything the background needs while it\n * is the active rule. Every appearance field lives HERE rather than globally —\n * the settings UI edits a rule, and the render layer follows whichever rule the\n * current model selected.\n */\nexport interface BgRule {\n /** Stable id; also the render key. */\n id: string\n /**\n * Case-insensitive substring tested against the current model text (provider,\n * model id and display name joined with spaces). An EMPTY string never matches\n * on its own — that rule then only ever serves as the fallback.\n */\n match: string\n /** Image slot; the bytes live in `modelbg-<slot>` under the data dir. */\n slot: string\n /** Disabled rules are skipped by matching AND by the fallback pick. */\n enabled: boolean\n /** Saved HSL theme color of this rule; null = use the system theme. */\n color: [number, number, number] | null\n bgMode: BgMode\n /** Wallpaper layer opacity (0..1). */\n wallpaperOpacity: number\n /** Wallpaper layer blur (px, 0..60) — NOT the interface part blur. */\n blur: number\n /** Image framing (zoom + fractional center + intrinsic size). */\n bgState: BgState\n}\n\n/** The persisted plugin configuration. */\nexport interface ThemeConfig {\n /** Ordered rules: matching runs top→bottom, rule 1 doubles as the fallback. */\n rules: BgRule[]\n /** Global per-part opacities (Interface page). */\n opacities: PartOpacities\n /** Global per-part blur (Interface page). */\n blurs: PartBlurs\n /** Settings-panel opacity (0..1). */\n settingsOpacity: number\n /** Translucent tint over the conversation text region (0 = none, 1 = solid). */\n chatTextOpacity: number\n /** Translucent tint over the trajectory view surface (0 = none, 1 = solid). */\n trajectoryOpacity: number\n /**\n * Surface opacity of the file-preview panel (0..1). `null` = never touched, so\n * the panel keeps following `opacities.bg`: the panel's only surface IS\n * `--dsw-alias-bg-base`, which the main-background slider already re-emits, so\n * an untouched card must stay indistinguishable from the interface behind it.\n */\n rightbarOpacity: number | null\n /**\n * Extract a rule's theme color from its own image when the rule has none yet.\n * Only ever FILLS an empty color — a color the user picked or that an earlier\n * extraction produced is never overwritten, so this cannot fight the user.\n */\n autoExtract: boolean\n}\n\n/** 100% = untouched host surface; zero would blank the page by default. */\nexport const DEFAULT_SETTINGS_OPACITY = 1\nexport const DEFAULT_CHAT_TEXT_OPACITY = 0\n/** 100% = untouched host surface; zero would blank the page by default. */\nexport const DEFAULT_TRAJECTORY_OPACITY = 1\n/** `null` = the file-preview panel still follows the main background. */\nexport const DEFAULT_RIGHTBAR_OPACITY: number | null = null\n/** Picking an image should just work; the toggle is there for people who don't want it. */\nexport const DEFAULT_AUTO_EXTRACT = true\n\n/** A default config with independent nested objects (never hand out the shared ones). */\nexport function freshThemeConfig(): ThemeConfig {\n return {\n rules: [],\n opacities: { ...DEFAULT_PART_OPACITIES },\n blurs: { ...DEFAULT_PART_BLURS },\n settingsOpacity: DEFAULT_SETTINGS_OPACITY,\n chatTextOpacity: DEFAULT_CHAT_TEXT_OPACITY,\n trajectoryOpacity: DEFAULT_TRAJECTORY_OPACITY,\n rightbarOpacity: DEFAULT_RIGHTBAR_OPACITY,\n autoExtract: DEFAULT_AUTO_EXTRACT,\n }\n}\n\n// ── Sanitizers ─────────────────────────────────────────────────────────────\n// Pure coercions from a possibly-old / possibly-hand-edited JSON value into the\n// shape above. Both halves run THESE, so a clamp can never differ between what\n// the UI shows and what lands on disk.\n\n/** Slot names reach the filesystem, so they are strictly whitelisted. */\nexport const SLOT_RE = /^[A-Za-z0-9_-]{1,32}$/\n\nexport function clamp(n: unknown, lo: number, hi: number, def: number): number {\n return typeof n === 'number' && isFinite(n) ? Math.min(hi, Math.max(lo, n)) : def\n}\n\nexport const clamp01 = (n: unknown, def: number): number => clamp(n, 0, 1, def)\n\nexport function normalizeBgState(s: Partial<BgState> | undefined): BgState {\n const v = s ?? {}\n return {\n zoom: clamp(v.zoom, 0.1, 10, 1),\n x: typeof v.x === 'number' && isFinite(v.x) ? v.x : 0,\n y: typeof v.y === 'number' && isFinite(v.y) ? v.y : 0,\n iw: typeof v.iw === 'number' && v.iw > 0 ? v.iw : 0,\n ih: typeof v.ih === 'number' && v.ih > 0 ? v.ih : 0,\n }\n}\n\n/** One `[h, s, l]` triple, or null when the value is not a complete finite triple. */\nexport function normalizeHsl(raw: unknown): [number, number, number] | null {\n if (!Array.isArray(raw) || raw.length !== 3) return null\n if (!raw.every(n => typeof n === 'number' && isFinite(n))) return null\n return [clamp(raw[0], 0, 360, 220), clamp(raw[1], 0, 1, 0.55), clamp(raw[2], 0, 1, 0.25)]\n}\n\n/** Coerce one persisted rule, or null when it lacks a usable id/slot. */\nexport function normalizeRule(raw: unknown): BgRule | null {\n const r = (raw ?? {}) as Partial<BgRule>\n const id = typeof r.id === 'string' && r.id !== '' ? r.id : null\n const slot = typeof r.slot === 'string' && SLOT_RE.test(r.slot) ? r.slot : null\n if (id === null || slot === null) return null\n const mode: BgMode = BG_MODES.includes(r.bgMode as BgMode) ? (r.bgMode as BgMode) : 'fit'\n return {\n id,\n slot,\n match: typeof r.match === 'string' ? r.match : '',\n enabled: r.enabled !== false,\n color: normalizeHsl(r.color),\n bgMode: mode,\n wallpaperOpacity: clamp01(r.wallpaperOpacity, 1),\n blur: clamp(r.blur, 0, 60, 0),\n bgState: normalizeBgState(r.bgState as Partial<BgState> | undefined),\n }\n}\n\n/** Coerce an unknown persisted value into a valid ThemeConfig, falling back per-field. */\nexport function normalizeConfig(raw: unknown): ThemeConfig {\n const r = (raw ?? {}) as Partial<ThemeConfig>\n const rules = Array.isArray(r.rules)\n ? r.rules.map(normalizeRule).filter((x): x is BgRule => x !== null)\n : []\n const ops = (r.opacities ?? {}) as Partial<PartOpacities>\n const bl = (r.blurs ?? {}) as Partial<PartBlurs>\n const blurs = {} as PartBlurs\n for (const k of PART_BLUR_KEYS) {\n blurs[k] = clamp(bl[k], 0, 60, DEFAULT_PART_BLURS[k])\n }\n const opacities = {} as PartOpacities\n for (const k of PART_OPACITY_KEYS) {\n opacities[k] = clamp01(ops[k], DEFAULT_PART_OPACITIES[k])\n }\n return {\n rules,\n opacities,\n blurs,\n settingsOpacity: clamp01(r.settingsOpacity, DEFAULT_SETTINGS_OPACITY),\n chatTextOpacity: clamp01(r.chatTextOpacity, DEFAULT_CHAT_TEXT_OPACITY),\n trajectoryOpacity: clamp01(r.trajectoryOpacity, DEFAULT_TRAJECTORY_OPACITY),\n // Anything but a real number means \"not owned yet\" — including the absent\n // field of a config written before this option existed.\n rightbarOpacity: typeof r.rightbarOpacity === 'number' && isFinite(r.rightbarOpacity)\n ? clamp01(r.rightbarOpacity, 1)\n : DEFAULT_RIGHTBAR_OPACITY,\n // Only an explicit `false` turns it off, so a config written before this\n // option existed starts with the helpful default.\n autoExtract: r.autoExtract !== false,\n }\n}\n","import type { BgRule, BgState, BgMode, ThemeConfig, PartOpacities, PartBlurs } from './types'\n// The persisted shape, its key lists, its defaults and its sanitizers all live in\n// ../schema, shared verbatim with the node half — a field declared on one side\n// only used to be silently dropped by the other side's sanitizer.\nimport {\n DEFAULT_BG_STATE, DEFAULT_CHAT_TEXT_OPACITY, DEFAULT_PART_BLURS, DEFAULT_PART_OPACITIES,\n DEFAULT_SETTINGS_OPACITY, DEFAULT_TRAJECTORY_OPACITY, PART_BLUR_KEYS, PART_OPACITY_KEYS,\n clamp, clamp01, freshThemeConfig, normalizeConfig, normalizeRule,\n} from '../schema'\n\nexport { DEFAULT_BG_STATE, normalizeRule }\n\nconst PALETTE: Array<[number, number, number]> = [\n [356, 0.72, 0.55], [24, 0.78, 0.55], [44, 0.8, 0.55], [152, 0.62, 0.5],\n [174, 0.68, 0.48], [208, 0.72, 0.55], [252, 0.68, 0.6], [300, 0.64, 0.58],\n]\nexport { PALETTE }\n\n/** The defaults every accessor falls back to; the shape itself lives in ../schema. */\nexport const DEFAULT_CONFIG: ThemeConfig = freshThemeConfig()\n\n// In-memory mirror of the file-backed store; the UI reads and mutates this and\n// it is synced to disk via the RPC layer.\nexport let cfg: ThemeConfig = freshThemeConfig()\n\n// ── Image cache (slot → data URL) ──────────────────────────────────────────\n// Rule images are fetched lazily per slot; only the active rule's bytes are\n// needed to paint, the rest are loaded when their card is expanded.\n//\n// Two URLs are kept per slot: the DATA URL is what gets persisted and embedded\n// in an export, while the DISPLAY URL is an object URL derived from it. Painting\n// goes through the display URL because `background-image: url(data:…)` is\n// re-decoded on every assignment — a visible stall on every model switch for a\n// multi-megabyte wallpaper — whereas a blob URL is served from the browser's\n// memory cache after the first load.\nconst images = new Map<string, string>()\nconst displayUrls = new Map<string, string>()\n\nfunction revokeDisplay(slot: string): void {\n const url = displayUrls.get(slot)\n if (url === undefined) return\n displayUrls.delete(slot)\n // Deferred on purpose: the wallpaper layer may still be painting this URL\n // while the replacement fades in over it, and revoking it mid-fade would blank\n // the wallpaper behind the incoming image for a frame.\n window.setTimeout(() => {\n try { URL.revokeObjectURL(url) } catch { /* not a live object URL (e.g. fallback) */ }\n }, 2000)\n}\n\nexport function setImage(slot: string, url: string | null): void {\n revokeDisplay(slot)\n if (url === null) images.delete(slot)\n else images.set(slot, url)\n}\n/** Persisted data URL (RPC / export). Use `displayImageOf` to paint it. */\nexport function imageOf(slot: string): string | null { return images.get(slot) ?? null }\n\n/** Paintable URL for one slot, created on first use and cached; falls back to\n * the data URL when no object URL can be built. */\nexport function displayImageOf(slot: string): string | null {\n const cached = displayUrls.get(slot)\n if (cached !== undefined) return cached\n const data = images.get(slot)\n if (data === undefined) return null\n const made = toObjectUrl(data)\n if (made === null) return data\n displayUrls.set(slot, made)\n return made\n}\n\nfunction toObjectUrl(dataUrl: string): string | null {\n try {\n if (typeof URL === 'undefined' || typeof URL.createObjectURL !== 'function') return null\n const comma = dataUrl.indexOf(',')\n if (comma < 0) return null\n const meta = dataUrl.slice(0, comma)\n if (!/;base64$/i.test(meta)) return null\n const mime = meta.slice(5, -7) || 'image/jpeg'\n const bin = atob(dataUrl.slice(comma + 1))\n const bytes = new Uint8Array(bin.length)\n for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i)\n return URL.createObjectURL(new Blob([bytes], { type: mime }))\n } catch {\n return null\n }\n}\n\nexport function clearImages(): void {\n for (const slot of Array.from(displayUrls.keys())) revokeDisplay(slot)\n images.clear()\n}\n\n// ── Active rule (what the render layer follows) ────────────────────────────\nexport let activeRuleId: string | null = null\nexport let activeMatched = false\nexport let modelLabel = ''\n\nexport function setActive(ruleId: string | null, matched: boolean): void {\n activeRuleId = ruleId\n activeMatched = matched\n}\nexport function setModelLabel(label: string): void { modelLabel = label }\n\nexport function ruleById(id: string): BgRule | null {\n return cfg.rules.find(r => r.id === id) ?? null\n}\nexport function activeRule(): BgRule | null {\n return activeRuleId === null ? null : ruleById(activeRuleId)\n}\n\n// ── Rule factories / allocation ────────────────────────────────────────────\nexport function newRule(id: string, slot: string): BgRule {\n return {\n id, slot, match: '', enabled: true, color: null,\n bgMode: 'fit', wallpaperOpacity: 1, blur: 0,\n bgState: { ...DEFAULT_BG_STATE },\n }\n}\n\n/** First free image slot (`m1`, `m2`, …). */\nexport function nextSlot(): string {\n const taken = new Set(cfg.rules.map(r => r.slot))\n for (let i = 1; i < 1000; i++) {\n const slot = `m${i}`\n if (!taken.has(slot)) return slot\n }\n return `m${Date.now()}`\n}\n\n/** Unique rule id (independent from the slot so removals never renumber). */\nexport function nextRuleId(): string {\n const taken = new Set(cfg.rules.map(r => r.id))\n for (let i = 1; i < 10000; i++) {\n const id = `r${i}`\n if (!taken.has(id)) return id\n }\n return `r${Date.now()}`\n}\n\n// ── Accessors used by the render layer (they follow the ACTIVE rule) ───────\nexport function rHasColor(): boolean { return activeRule()?.color !== null && activeRule() !== null }\nexport function rColor(): [number, number, number] { return activeRule()?.color ?? [220, 0.55, 0.25] }\nexport function rBgMode(): BgMode { return activeRule()?.bgMode ?? 'fit' }\nexport function rWop(): number { return clamp01(activeRule()?.wallpaperOpacity, 1) }\nexport function rBl(): number { return clamp(activeRule()?.blur, 0, 60, 0) }\nexport function rBgState(): BgState { return activeRule()?.bgState ?? DEFAULT_BG_STATE }\n/** Paintable URL of the active rule's image, or null when it has none. */\nexport function rWp(): string | null {\n const rule = activeRule()\n return rule === null ? null : displayImageOf(rule.slot)\n}\nexport function rOps(): PartOpacities {\n const o = cfg.opacities ?? {}\n const out = {} as PartOpacities\n for (const k of PART_OPACITY_KEYS) {\n out[k] = clamp01(o[k], DEFAULT_PART_OPACITIES[k])\n }\n return out\n}\nexport function rBlurs(): PartBlurs {\n const b = cfg.blurs ?? {}\n const out = {} as PartBlurs\n for (const k of PART_BLUR_KEYS) {\n out[k] = clamp(b[k], 0, 60, DEFAULT_PART_BLURS[k])\n }\n return out\n}\nexport function rSop(): number { return clamp01(cfg.settingsOpacity, DEFAULT_SETTINGS_OPACITY) }\nexport function rChatTextOpacity(): number { return clamp01(cfg.chatTextOpacity, DEFAULT_CHAT_TEXT_OPACITY) }\nexport function rTrajectoryOpacity(): number { return clamp01(cfg.trajectoryOpacity, DEFAULT_TRAJECTORY_OPACITY) }\n/** Own opacity of the file-preview panel; while unowned it IS the main background's. */\nexport function rRightbarOpacity(): number {\n const own = cfg.rightbarOpacity\n return typeof own === 'number' && isFinite(own) ? clamp01(own, 1) : rOps().bg\n}\n\n// ── Normalization ──────────────────────────────────────────────────────────\n// The sanitizers are the shared ones from ../schema (the same code the node half\n// runs before writing to disk), so what the UI shows and what is persisted can\n// never be clamped differently.\n\n/** Move a possibly-absent partial config into the shape the UI reads. */\nexport function adoptConfig(raw: unknown): void {\n cfg = normalizeConfig(raw)\n // A rule that vanished (import/removal) must not stay active.\n if (activeRuleId !== null && !cfg.rules.some(r => r.id === activeRuleId)) {\n activeRuleId = null\n activeMatched = false\n }\n}\n\nexport function resetConfig(): void {\n cfg = freshThemeConfig()\n clearImages()\n activeRuleId = null\n activeMatched = false\n modelLabel = ''\n}\n","import type { FetchResult, RpcResultLike } from './types'\nimport { cfg } from './state'\n\nexport const RPC_CHANNEL = '/dsh-background-by-model'\nconst RPC_NS = 'dshBackgroundByModel'\nconst rpcEndpoint = (method: string): string => `${RPC_NS}/${method}`\n\nlet rpcCallFn: ((endpoint: string, payload: unknown) => Promise<RpcResultLike | undefined>) | null = null\n\nexport function initRpc(call: (endpoint: string, payload: unknown) => Promise<RpcResultLike | undefined>): void {\n rpcCallFn = call\n}\n\nasync function rpcCall(method: string, payload: unknown): Promise<unknown> {\n if (!rpcCallFn) return undefined\n try {\n const res = await rpcCallFn(rpcEndpoint(method), payload)\n if (res && res.ok === true) return res.value\n console.warn(`dsh-background-by-model: rpc \"${method}\" failed`, res?.error)\n return undefined\n } catch (e) {\n console.warn(`dsh-background-by-model: rpc \"${method}\" threw`, e)\n return undefined\n }\n}\n\n/** Raw call for the few places that need the host's error message. */\nasync function rpcRaw(method: string, payload: unknown): Promise<RpcResultLike | undefined> {\n if (!rpcCallFn) return undefined\n try {\n return await rpcCallFn(rpcEndpoint(method), payload)\n } catch {\n return undefined\n }\n}\n\n// Slider drags fire dozens of events per second; coalesce writes to a trailing\n// debounce and flush the last pending write on pagehide so a quick close never\n// loses it.\nconst SAVE_DEBOUNCE_MS = 250\nlet saveTimer: number | undefined\n\nexport function saveConfig(): void {\n if (saveTimer !== undefined) window.clearTimeout(saveTimer)\n saveTimer = window.setTimeout(() => {\n saveTimer = undefined\n void rpcCall('writeConfig', { config: cfg })\n }, SAVE_DEBOUNCE_MS)\n}\n\nexport function flushSave(): void {\n if (saveTimer === undefined) return\n window.clearTimeout(saveTimer)\n saveTimer = undefined\n void rpcCall('writeConfig', { config: cfg })\n}\n\n/** Persist the current config immediately (no debounce). */\nexport function persistConfig(): void {\n void rpcCall('writeConfig', { config: cfg })\n}\n\nexport interface Persisted { config: unknown; slots: string[] }\n\n/** Load the persisted config plus the list of stored image slots. */\nexport async function loadPersisted(): Promise<Persisted | null> {\n const data = await rpcCall('read', {})\n if (data === null || typeof data !== 'object') return null\n const d = data as { config?: unknown; slots?: unknown }\n const slots = Array.isArray(d.slots) ? d.slots.filter((s): s is string => typeof s === 'string') : []\n return { config: d.config, slots }\n}\n\n/** Read one rule image as a data URL (null when the slot is empty). */\nexport async function readImage(slot: string): Promise<string | null> {\n const data = await rpcCall('readImage', { slot })\n if (data === null || typeof data !== 'object') return null\n const url = (data as { dataUrl?: unknown }).dataUrl\n return typeof url === 'string' ? url : null\n}\n\n/** Persist (or clear) one rule image; one-shot, no debounce. */\nexport async function writeImage(slot: string, dataUrl: string | null): Promise<boolean> {\n const res = await rpcCall('writeImage', { slot, dataUrl })\n return res === true\n}\n\n/** Remove one rule image from disk. */\nexport async function deleteImage(slot: string): Promise<boolean> {\n const res = await rpcCall('deleteImage', { slot })\n return res === true\n}\n\n/** Download an image from a network URL into one slot, replacing its bytes. */\nexport async function fetchImageUrl(slot: string, url: string): Promise<FetchResult> {\n const res = await rpcRaw('fetchImageUrl', { slot, url })\n if (!res) return { ok: false, error: 'no response' }\n if (res.ok !== true) {\n const err = (res as { error?: { message?: string } }).error\n return { ok: false, error: err?.message ?? 'request failed' }\n }\n const v = res.value as FetchResult | undefined\n return v?.ok === true\n ? { ok: true, dataUrl: v.dataUrl ?? null }\n : { ok: false, error: v?.error ?? 'failed' }\n}\n\n/** Host default model — used only when the per-session services are absent. */\nexport async function readDefaultModel(): Promise<string | null> {\n const data = await rpcCall('defaultModel', {})\n if (data === null || typeof data !== 'object') return null\n const d = data as { provider?: unknown; model?: unknown }\n const parts = [d.provider, d.model].filter((s): s is string => typeof s === 'string' && s !== '')\n return parts.length > 0 ? parts.join(' ') : null\n}\n","import type { BgState, ColorPalette } from '../types'\r\n\r\n// The wheel works in HSV end to end; storage and genTokens expect HSL, so\r\n// setColor converts HSV → HSL at the boundary and sectionInject converts the\r\n// stored HSL → HSV for the initial wheel props. Conversions never stack.\r\n\r\nexport function hsvToHsl(h: number, s: number, v: number): [number, number, number] {\r\n const l = v * (1 - s / 2)\r\n const sl = l === 0 || l === 1 ? 0 : (v - l) / Math.min(l, 1 - l)\r\n return [h, sl, l]\r\n}\r\n\r\nexport function hslToHsv(h: number, s: number, l: number): [number, number, number] {\r\n const v = l + s * Math.min(l, 1 - l)\r\n const sv = v === 0 ? 0 : 2 * (1 - l / v)\r\n return [h, sv, v]\r\n}\r\n\r\nlet tokensCacheKey = ''\r\nlet tokensCache: { colorScheme: 'light' | 'dark'; tokens: Record<string, string> } | null = null\r\n\r\n/**\r\n * Memoized token generation: the same (hue, sat, lit) input always yields the\r\n * same token set, and applyWp / applyCustomTokens / applySettingsOverrides call\r\n * this repeatedly (slider drags, viewport re-applies), so cache the last result\r\n * and skip the 30+ hsl() string builds when nothing changed.\r\n */\r\nexport function genTokens(hue: number, sat: number, lit: number): { colorScheme: 'light' | 'dark'; tokens: Record<string, string> } {\r\n const key = `${hue}|${sat}|${lit}`\r\n if (tokensCacheKey === key && tokensCache) return tokensCache\r\n tokensCacheKey = key\r\n tokensCache = buildTokens(hue, sat, lit)\r\n return tokensCache\r\n}\r\n\r\nfunction buildTokens(hue: number, sat: number, lit: number): { colorScheme: 'light' | 'dark'; tokens: Record<string, string> } {\r\n const dark = lit < 0.55\r\n const h = (d: number) => ((hue + d) % 360 + 360) % 360\r\n const s = (d: number) => Math.max(0, Math.min(1, sat + d))\r\n const l = (d: number) => Math.max(0, Math.min(1, lit + d))\r\n const hsl = (hh: number, ss: number, ll: number) => `hsl(${Math.round(hh)},${Math.round(ss * 100)}%,${Math.round(ll * 100)}%)`\r\n const rgba = (hh: number, ss: number, ll: number, a: number) =>\r\n `hsla(${Math.round(hh)},${Math.round(ss * 100)}%,${Math.round(ll * 100)}%,${a})`\r\n // Ink for anything painted ON the brand fill. One verdict feeds both\r\n // spellings of it: brand-text (which the host defines but never uses) and\r\n // label-primary-foreground, which the HOST's own primary buttons label\r\n // themselves with on --dsw-alias-button-primary-fill — the same color as\r\n // --dsw-alias-brand-primary below. It has to flip with the fill: the dark\r\n // branch deliberately keeps that fill at 50%+ lightness, so a hard-coded white\r\n // label is white on white. The host's own dark scheme is only readable because\r\n // it flips brand-primary AND label-primary-foreground together.\r\n const onBrand = l(0.2) > 0.6 ? '#000' : '#fff'\r\n\r\n if (dark) {\r\n // dsh 0.1.7 splits the menu surface in two: the shared MenuSurface material\r\n // paints `--dsw-menu-surface-fill`, and every other overlay paints\r\n // `--dsw-specific-menu`, which the host aliases to the former\r\n // (`--dsw-specific-menu: var(--dsw-menu-surface-fill)`). Both are generated\r\n // from this one expression so the plugin's override of either can never let\r\n // the pair drift apart — see OPACITY_VARS in wallpaper.ts.\r\n const menuFill = hsl(h(0), s(0), l(0.08))\r\n return {\r\n colorScheme: 'dark',\r\n tokens: {\r\n '--dsw-alias-bg-base': hsl(h(0), s(0), l(-0.04)),\r\n '--dsw-alias-bg-layer-1': hsl(h(0), s(0), l(0.02)),\r\n '--dsw-alias-bg-layer-2': hsl(h(0), s(0), l(0.07)),\r\n '--dsw-alias-bg-layer-3': hsl(h(0), s(-0.05), l(0.12)),\r\n '--dsw-alias-bg-overlay': hsl(h(0), s(-0.05), l(0.12)),\r\n '--dsw-alias-bg-module-platform': hsl(h(0), s(0), l(0.05)),\r\n '--dsw-alias-bg-multi-select': hsl(h(0), s(0), l(0.1)),\r\n '--dsw-alias-bg-skeleton': 'rgba(255,255,255,0.08)',\r\n '--dsw-alias-border-l1': rgba(h(0), s(-0.1), l(0.18), 0.12),\r\n '--dsw-alias-border-l2': rgba(h(0), s(-0.1), l(0.22), 0.22),\r\n '--dsw-alias-border-l3': 'rgba(255,255,255,0.16)',\r\n '--dsw-alias-border-l4': 'rgba(255,255,255,0.2)',\r\n '--dsw-alias-border-inverted': 'rgba(255,255,255,0.06)',\r\n '--dsw-alias-label-primary': hsl(0, 0, 1),\r\n '--dsw-alias-label-secondary': 'rgba(255,255,255,0.85)',\r\n '--dsw-alias-label-tertiary': 'rgba(255,255,255,0.7)',\r\n // Placeholder/dim hint — deliberately weaker than the text tiers so a\r\n // placeholder reads as a hint, never as real input.\r\n '--dsw-alias-label-caption': 'rgba(255,255,255,0.5)',\r\n '--dsw-alias-label-dimmed': 'rgba(255,255,255,0.35)',\r\n '--dsw-alias-label-quaternary': 'rgba(255,255,255,0.25)',\r\n '--dsw-alias-label-primary-dimmed': 'rgba(255,255,255,0.92)',\r\n '--dsw-alias-label-primary-foreground': onBrand,\r\n // Inverted label sits on a light brand/contrast/badge surface in dark\r\n // mode, so it must be dark ink, not white.\r\n '--dsw-alias-label-primary-inverted': hsl(h(0), s(0.08), Math.min(l(0.06), 0.16)),\r\n '--dsw-alias-label-primary-bluish': hsl(0, 0, 1),\r\n '--dsw-alias-brand-primary': hsl(h(0), s(0.1), Math.max(l(0.2), 0.5)),\r\n '--dsw-alias-brand-text': onBrand,\r\n '--dsw-alias-button-primary-fill': hsl(h(0), s(0.1), Math.max(l(0.2), 0.5)),\r\n '--dsw-alias-button-primary-hover': hsl(h(0), s(0.1), Math.max(l(0.28), 0.58)),\r\n '--dsw-alias-button-primary-dimmed': hsl(h(0), s(0), l(0.07)),\r\n '--dsw-alias-button-elevated-fill': hsl(h(0), s(0), l(0.04)),\r\n '--dsw-alias-button-floating-fill': hsl(h(0), s(0), l(0.02)),\r\n '--dsw-alias-button-floating-hover': hsl(h(0), s(0), l(0.1)),\r\n '--dsw-alias-button-tool-bar-fill': 'rgba(255,255,255,0.08)',\r\n '--dsw-alias-button-tool-bar-hover': 'rgba(255,255,255,0.12)',\r\n '--dsw-alias-button-ghost-active-fill': hsl(h(0), s(0), l(0.06)),\r\n '--dsw-alias-button-ghost-active-border': 'rgba(255,255,255,0.16)',\r\n '--dsw-alias-button-ghost-active-hover': hsl(h(0), s(0), l(0.09)),\r\n '--dsw-alias-button-info-fill': '#679efe',\r\n '--dsw-alias-button-info-hover': '#4176e6',\r\n '--dsw-alias-button-contrast-fill': hsl(0, 0, 1),\r\n '--dsw-alias-interactive-bg-hover': rgba(h(0), s(0), Math.max(l(0.15), 0.4), 0.12),\r\n '--dsw-alias-interactive-bg-hover-solid': rgba(h(0), s(0), Math.max(l(0.15), 0.4), 0.16),\r\n '--dsw-alias-interactive-bg-hover-accent': 'rgba(255,255,255,0.24)',\r\n '--dsw-alias-interactive-bg-hover-danger': 'rgba(242,90,90,0.15)',\r\n '--dsw-alias-interactive-bg-active': rgba(h(0), s(0), Math.max(l(0.15), 0.4), 0.2),\r\n '--dsw-alias-markdown-code-block': hsl(h(0), s(0), l(-0.06)),\r\n '--dsw-alias-markdown-code-block-banner': hsl(h(0), s(0), l(-0.02)),\r\n '--dsw-alias-markdown-inline-code': hsl(h(0), s(0), l(0.04)),\r\n '--dsw-alias-markdown-placeholder': hsl(h(0), s(0), l(-0.02)),\r\n '--dsw-alias-markdown-tag': hsl(h(0), s(0), l(0.05)),\r\n '--dsw-alias-markdown-citation': hsl(h(0), s(0), l(0.06)),\r\n '--dsw-alias-markdown-code-segment-selected': hsl(h(0), s(0), l(0.05)),\r\n '--dsw-alias-markdown-code-segment-unselected': hsl(h(0), s(0), l(-0.05)),\r\n '--dsw-alias-state-error-primary': '#ff5c72',\r\n '--dsw-alias-state-error-secondary': '#ff8aa0',\r\n '--dsw-alias-state-success-primary': '#3ddc84',\r\n '--dsw-alias-state-success-secondary': '#69eea4',\r\n // Badge tertiary tokens are the static dark surfaces the UI draws\r\n // over (trajectory tool/context badges, connection pill, plan chip):\r\n // aligning them with the native dark 800/900 steps keeps light fix label\r\n // text readable instead of tint-same-as-background (issue #9).\r\n '--dsw-alias-state-success-tertiary': '#233c2c',\r\n '--dsw-alias-state-warn-primary': '#ffb347',\r\n '--dsw-alias-state-warn-secondary': '#ffc980',\r\n '--dsw-alias-state-warn-tertiary': '#27241f',\r\n '--dsw-alias-state-warn-label': '#dd8629',\r\n '--dsw-alias-state-business-primary': '#679efe',\r\n '--dsw-alias-state-business-tertiary': '#34415b',\r\n '--dsw-specific-sidebar-fill': hsl(h(0), s(0), l(-0.06)),\r\n '--dsw-specific-sidebar-nav-item-active': hsl(h(0), s(0), l(0.04)),\r\n '--dsw-specific-sidebar-nav-item-hover': hsl(h(0), s(0), l(0)),\r\n '--dsw-specific-input-major': hsl(h(0), s(0), l(0.02)),\r\n '--dsw-specific-menu': menuFill,\r\n '--dsw-menu-surface-fill': menuFill,\r\n '--dsw-specific-bubble': hsl(h(0), s(0), l(0.03)),\r\n '--dsw-specific-bubble-highlight': hsl(h(0), s(0), l(0.08)),\r\n '--dsw-specific-selector': hsl(h(0), s(0), l(0.05)),\r\n '--dsw-specific-login-input': hsl(h(0), s(0), l(0.03)),\r\n '--dsw-specific-tip': hsl(h(0), s(0), l(0.05)),\r\n '--dsw-alias-toast-bg': hsl(h(0), s(0), l(0.08)),\r\n '--dsw-alias-tooltip-bg': hsl(h(0), s(0), l(0.08)),\r\n '--dsw-alias-scrollbar-bg-l1': hsl(h(0), s(-0.05), l(0.12)),\r\n '--dsw-alias-scrollbar-bg-l2': hsl(h(0), s(-0.05), l(0.16)),\r\n '--dsw-alias-scrollbar-hover-l1': hsl(h(0), s(-0.05), l(0.22)),\r\n '--dsw-alias-scrollbar-hover-l2': hsl(h(0), s(-0.05), l(0.22)),\r\n },\r\n }\r\n }\r\n // Same one-expression contract as the dark branch above.\r\n const menuFill = hsl(h(0), s(-0.12), l(0.15))\r\n return {\r\n colorScheme: 'light',\r\n tokens: {\r\n '--dsw-alias-bg-base': hsl(h(0), s(-0.08), l(0.03)),\r\n '--dsw-alias-bg-layer-1': hsl(h(0), s(-0.12), l(0.07)),\r\n '--dsw-alias-bg-layer-2': hsl(h(0), s(-0.1), l(-0.03)),\r\n '--dsw-alias-bg-layer-3': hsl(h(0), s(-0.08), l(-0.09)),\r\n '--dsw-alias-bg-overlay': hsl(h(0), s(-0.12), l(0.08)),\r\n '--dsw-alias-border-l1': rgba(h(0), s(-0.15), l(-0.35), 0.18),\r\n '--dsw-alias-border-l2': rgba(h(0), s(-0.15), l(-0.35), 0.3),\r\n '--dsw-alias-label-primary': hsl(0, 0, 0),\r\n '--dsw-alias-label-secondary': 'rgba(0,0,0,0.85)',\r\n '--dsw-alias-label-tertiary': 'rgba(0,0,0,0.7)',\r\n // Placeholder/dim hint — deliberately weaker than the text tiers so a\r\n // placeholder reads as a hint, never as real input.\r\n '--dsw-alias-label-caption': 'rgba(0,0,0,0.5)',\r\n '--dsw-alias-label-dimmed': 'rgba(0,0,0,0.35)',\r\n '--dsw-alias-label-quaternary': 'rgba(0,0,0,0.25)',\r\n // Mirror of the dark branch: this branch always paints its brand fill dark\r\n // (45% lightness or less), so the ink ON it is white. Re-emitted rather\r\n // than inherited so the plugin's own palette owns the pair — the plugin's\r\n // settings UI paints every primary button/chip/tile label from this token.\r\n '--dsw-alias-label-primary-inverted': '#fff',\r\n '--dsw-alias-brand-primary': hsl(h(0), s(0.05), Math.min(l(-0.18), 0.45)),\r\n '--dsw-alias-brand-text': '#fff',\r\n '--dsw-alias-button-primary-hover': hsl(h(0), s(0.05), Math.min(l(-0.12), 0.5)),\r\n '--dsw-alias-button-primary-dimmed': hsl(h(0), s(-0.1), l(-0.03)),\r\n '--dsw-alias-button-elevated-fill': hsl(h(0), s(-0.1), l(0.1)),\r\n '--dsw-alias-button-floating-hover': hsl(h(0), s(-0.1), l(0.16)),\r\n '--dsw-alias-interactive-bg-hover': rgba(h(0), s(0), l(-0.3), 0.08),\r\n '--dsw-alias-interactive-bg-active': rgba(h(0), s(0), l(-0.3), 0.14),\r\n '--dsw-alias-markdown-code-block': hsl(h(0), s(-0.1), l(-0.03)),\r\n '--dsw-alias-markdown-inline-code': hsl(h(0), s(-0.08), l(0.04)),\r\n '--dsw-specific-sidebar-fill': hsl(h(0), s(-0.1), l(-0.03)),\r\n '--dsw-specific-sidebar-nav-item-active': hsl(h(0), s(-0.08), l(0.05)),\r\n '--dsw-specific-sidebar-nav-item-hover': hsl(h(0), s(-0.12), l(0)),\r\n '--dsw-specific-input-major': hsl(h(0), s(-0.12), l(0.1)),\r\n '--dsw-specific-menu': menuFill,\r\n '--dsw-menu-surface-fill': menuFill,\r\n '--dsw-alias-scrollbar-bg-l1': hsl(h(0), s(-0.1), l(-0.08)),\r\n '--dsw-alias-scrollbar-bg-l2': hsl(h(0), s(-0.08), l(-0.12)),\r\n '--dsw-alias-scrollbar-hover-l1': hsl(h(0), s(-0.08), l(-0.16)),\r\n '--dsw-alias-scrollbar-hover-l2': hsl(h(0), s(-0.08), l(-0.16)),\r\n },\r\n }\r\n}\r\n\r\nexport function toRgba(c: string, a: number): string {\r\n const hx = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(c.trim())\r\n if (hx) { let d = hx[1]!; if (d.length === 3) d = d.split('').map(x => x + x).join(''); const n = parseInt(d, 16); return `rgba(${(n >> 16) & 255},${(n >> 8) & 255},${n & 255},${a})` }\r\n const rgb = /^rgba?\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)(?:\\s*,\\s*([\\d.]+))?\\s*\\)$/i.exec(c.trim())\r\n if (rgb) return `rgba(${rgb[1]},${rgb[2]},${rgb[3]},${a})`\r\n const hsl = /^hsla?\\(\\s*([\\d.]+)\\s*,\\s*([\\d.]+)%\\s*,\\s*([\\d.]+)%/i.exec(c.trim())\r\n if (hsl) return `hsla(${hsl[1]},${hsl[2]}%,${hsl[3]}%,${a})`\r\n return c.trim()\r\n}\r\n\r\nexport function rgbToHsl(r: number, g: number, b: number): [number, number, number] {\r\n const rn = r / 255, gn = g / 255, bn = b / 255\r\n const max = Math.max(rn, gn, bn), min = Math.min(rn, gn, bn)\r\n const l = (max + min) / 2\r\n if (max === min) return [0, 0, l]\r\n const d = max - min\r\n const s = l > 0.5 ? d / (2 - max - min) : d / (max + min)\r\n let h: number\r\n if (max === rn) h = ((gn - bn) / d) % 6\r\n else if (max === gn) h = (bn - rn) / d + 2\r\n else h = (rn - gn) / d + 4\r\n h *= 60\r\n if (h < 0) h += 360\r\n return [h, s, l]\r\n}\r\n\r\n// Wallpaper color extraction: decode the cached data URL → crop the visible\r\n// (framed) region → downsample to a 64×64 canvas → quantize pixels into 4-bit\r\n// RGB buckets → discard near-gray / near-black / near-white pixels → pick the\r\n// most populous vivid bucket (count × saturation bias) → average its members →\r\n// RGB→HSL → clamp lightness into a band that keeps the light/dark scheme\r\n// decision unambiguous. Purely client-side and memory-bounded.\r\n\r\nconst EXTRACT_SIDE = 64\r\n\r\ninterface Bucket { count: number; r: number; g: number; b: number; s: number }\r\n\r\nfunction bucketsToHsl(b: Bucket): [number, number, number] {\r\n return rgbToHsl(b.r / b.count, b.g / b.count, b.b / b.count)\r\n}\r\n\r\nfunction extractWallpaperPalette(dataUrl: string, bgState: BgState): Promise<ColorPalette | null> {\r\n return new Promise(resolve => {\r\n const img = new Image()\r\n img.onerror = () => resolve(null)\r\n img.onload = () => {\r\n try {\r\n const iw = img.naturalWidth || img.width\r\n const ih = img.naturalHeight || img.height\r\n const bg = bgState\r\n let sx = 0, sy = 0, sw = iw, sh = ih\r\n if (bg.iw === iw && bg.ih === ih && bg.iw > 0) {\r\n const fit = Math.min(window.innerWidth / iw, window.innerHeight / ih)\r\n const w = iw * fit * bg.zoom\r\n const h = ih * fit * bg.zoom\r\n sx = Math.max(0, bg.x * window.innerWidth - w / 2)\r\n sy = Math.max(0, bg.y * window.innerHeight - h / 2)\r\n sw = Math.min(iw - sx, w)\r\n sh = Math.min(ih - sy, h)\r\n if (sw <= 0 || sh <= 0) { sx = 0; sy = 0; sw = iw; sh = ih }\r\n }\r\n const c = document.createElement('canvas')\r\n c.width = EXTRACT_SIDE; c.height = EXTRACT_SIDE\r\n const g = c.getContext('2d', { willReadFrequently: true })!\r\n g.drawImage(img, sx, sy, sw, sh, 0, 0, EXTRACT_SIDE, EXTRACT_SIDE)\r\n const px = g.getImageData(0, 0, EXTRACT_SIDE, EXTRACT_SIDE).data\r\n const counts = new Uint32Array(4096)\r\n const sums = new Float64Array(4096 * 3)\r\n let totalLum = 0\r\n let sampled = 0\r\n for (let i = 0; i < px.length; i += 4) {\r\n const r = px[i], gg = px[i + 1], b = px[i + 2]\r\n const max = Math.max(r, gg, b), min = Math.min(r, gg, b)\r\n const v = max / 255\r\n const s = max === 0 ? 0 : (max - min) / max\r\n // Include all non-extreme pixels in luminance; only vivid pixels in\r\n // palette buckets so we don't theme around gray/black/white.\r\n // Rec.709 luma — the measure a display reads as brightness, and the one\r\n // the light/dark band below is decided with. The HSV value used here\r\n // before counts every saturated pixel as bright (pure blue: v = 1.0,\r\n // luma = 0.072), which pushed dark saturated wallpapers into the light\r\n // band and built a light palette over a dark picture.\r\n totalLum += (0.2126 * r + 0.7152 * gg + 0.0722 * b) / 255\r\n sampled++\r\n if (s < 0.08 || v < 0.12 || v > 0.97) continue\r\n const key = ((r >> 4) << 8) | ((gg >> 4) << 4) | (b >> 4)\r\n counts[key]++\r\n sums[key * 3] += r; sums[key * 3 + 1] += gg; sums[key * 3 + 2] += b\r\n }\r\n const buckets: Bucket[] = []\r\n for (let k = 0; k < 4096; k++) {\r\n if (counts[k] === 0) continue\r\n buckets.push({\r\n count: counts[k],\r\n r: sums[k * 3],\r\n g: sums[k * 3 + 1],\r\n b: sums[k * 3 + 2],\r\n s: (Math.max(sums[k * 3], sums[k * 3 + 1], sums[k * 3 + 2]) - Math.min(sums[k * 3], sums[k * 3 + 1], sums[k * 3 + 2])) / Math.max(sums[k * 3], sums[k * 3 + 1], sums[k * 3 + 2]) || 0,\r\n })\r\n }\r\n if (buckets.length === 0) { resolve(null); return }\r\n // Sort by vivid-weighted count.\r\n buckets.sort((a, b) => b.count * (0.5 + b.s) - a.count * (0.5 + a.s))\r\n const primary = bucketsToHsl(buckets[0]!)\r\n const primaryHue = primary[0]\r\n // Secondary: next bucket that is reasonably separated from primary.\r\n let secondary = primary\r\n for (const b of buckets.slice(1)) {\r\n const [h] = bucketsToHsl(b)\r\n const sep = Math.abs(((h - primaryHue + 540) % 360) - 180)\r\n if (sep > 30) { secondary = bucketsToHsl(b); break }\r\n }\r\n // Tertiary: complementary-ish hue based on primary if no good secondary.\r\n let tertiary: [number, number, number] = [((primaryHue + 180) % 360), Math.min(0.7, primary[1]), Math.min(0.7, primary[2])]\r\n for (const b of buckets.slice(1)) {\r\n const [h] = bucketsToHsl(b)\r\n const sep = Math.abs(((h - primaryHue + 540) % 360) - 180)\r\n if (sep > 90 && sep < 150) { tertiary = bucketsToHsl(b); break }\r\n }\r\n // Surface: neutralized primary (very low saturation).\r\n const surface: [number, number, number] = [primaryHue, Math.min(0.06, primary[1] * 0.3), primary[2]]\r\n // Auto light/dark: use the average luminance of the whole image so a\r\n // bright wallpaper naturally drives a light scheme and vice-versa.\r\n const luminance = sampled > 0 ? totalLum / sampled : primary[2]\r\n // Snap primary lightness out of the ambiguous middle band.\r\n const autoDark = luminance < 0.5\r\n const lc = autoDark ? Math.min(0.44, Math.max(0.2, primary[2])) : Math.max(0.6, Math.min(0.82, primary[2]))\r\n primary[2] = lc\r\n resolve({\r\n primary: [primary[0], Math.min(0.9, Math.max(0.15, primary[1])), primary[2]],\r\n secondary: [secondary[0], Math.min(0.85, Math.max(0.2, secondary[1])), Math.min(0.75, Math.max(0.35, secondary[2]))],\r\n tertiary: [tertiary[0], Math.min(0.8, Math.max(0.2, tertiary[1])), Math.min(0.7, Math.max(0.35, tertiary[2]))],\r\n surface,\r\n luminance,\r\n })\r\n } catch {\r\n resolve(null)\r\n }\r\n }\r\n img.src = dataUrl\r\n })\r\n}\r\n\r\n/** Backward-compatible single-color extraction: returns the primary HSL. */\r\nexport async function extractWallpaperColor(dataUrl: string, bgState: BgState): Promise<[number, number, number] | null> {\r\n const palette = await extractWallpaperPalette(dataUrl, bgState)\r\n return palette ? palette.primary : null\r\n}\r\n\r\n// One-shot frame brightness analysis: called only when a generated background\r\n// is switched (from its captured snapshot), never from the animation loop.\r\n// Decode the frame, downsample to a 32×32 canvas, average Rec.709 luma.\r\n// Dark frame → light fonts, light frame → dark fonts.\r\n\r\nconst ANALYZE_SIDE = 32\r\n\r\n/** Analyze a captured frame's average luminance. Resolves true when the frame\r\n * reads dark (use white fonts), false when light (use black fonts), or null\r\n * when the frame cannot be decoded. */\r\nexport function analyzeFrameDark(dataUrl: string): Promise<boolean | null> {\r\n return new Promise(resolve => {\r\n const img = new Image()\r\n img.onerror = () => resolve(null)\r\n img.onload = () => {\r\n try {\r\n const c = document.createElement('canvas')\r\n c.width = ANALYZE_SIDE; c.height = ANALYZE_SIDE\r\n const g = c.getContext('2d', { willReadFrequently: true })!\r\n g.drawImage(img, 0, 0, ANALYZE_SIDE, ANALYZE_SIDE)\r\n const px = g.getImageData(0, 0, ANALYZE_SIDE, ANALYZE_SIDE).data\r\n let lum = 0\r\n const count = px.length / 4\r\n for (let i = 0; i < px.length; i += 4) {\r\n lum += 0.2126 * px[i]! + 0.7152 * px[i + 1]! + 0.0722 * px[i + 2]!\r\n }\r\n resolve(lum / count / 255 < 0.5)\r\n } catch {\r\n resolve(null)\r\n }\r\n }\r\n img.src = dataUrl\r\n })\r\n}\r\n\r\n/** HSL (h 0-360, s/l 0-1) → RGB (0-255 integers). */\r\nexport function hslToRgb(h: number, s: number, l: number): [number, number, number] {\r\n const c = (1 - Math.abs(2 * l - 1)) * s\r\n const hp = h / 60\r\n const x = c * (1 - Math.abs((hp % 2) - 1))\r\n let r = 0, g = 0, b = 0\r\n if (hp < 1) { r = c; g = x }\r\n else if (hp < 2) { r = x; g = c }\r\n else if (hp < 3) { g = c; b = x }\r\n else if (hp < 4) { g = x; b = c }\r\n else if (hp < 5) { r = x; b = c }\r\n else { r = c; b = x }\r\n const m = l - c / 2\r\n return [Math.round((r + m) * 255), Math.round((g + m) * 255), Math.round((b + m) * 255)]\r\n}\r\n","/**\r\n * dsh-background-by-model — settings UI design system.\r\n *\r\n * The section is styled entirely through these scoped classes instead of the\r\n * host's inline-style approach: animations (page transitions, staggered\r\n * reveals, the rotating orb ring) and pseudo-element effects cannot be\r\n * expressed as React inline styles. Every color reads the host's\r\n * --dsw-alias-* tokens so the panel follows the user's custom theme color and\r\n * light/dark scheme automatically; `color-mix` tints carry a plain-token\r\n * fallback first for older engines.\r\n */\r\nexport const NAV_ITEM_H = 38\r\nexport const NAV_GAP = 4\r\n\r\nexport const UI_CSS = `\r\n/* The section is rendered INLINE inside the host settings dialog's content\r\n * column: the host provides the modal chrome (backdrop, centering, closing).\r\n * These classes style only the embedded shell; transient fixed layers (toast,\r\n * color picker, background editor) escape through Portals on <html>. */\r\n.dab-root{position:relative;color:var(--dsw-alias-label-primary);animation:dab-fade-in .35s ease both;container-type:inline-size;display:flex;flex-direction:column;align-items:center;width:100%;min-width:0;--dab-mono:ui-monospace,\"Cascadia Mono\",\"SF Mono\",Consolas,\"Courier New\",monospace}\r\n.dab-root *,.dab-root *::before,.dab-root *::after{box-sizing:border-box}\r\n.dab-root button{font-family:inherit}\r\n\r\n/* ── shell: nav rail + page body ─────────────────────────────────────────── */\r\n.dab-shell{display:grid;grid-template-columns:158px minmax(0,1fr);gap:26px;align-items:start;padding-bottom:8px;width:100%;max-width:980px;margin:0 auto}\r\n.dab-nav{position:sticky;top:0;display:flex;flex-direction:column;gap:18px}\r\n.dab-brand{display:flex;align-items:center;gap:10px;padding:2px 6px}\r\n.dab-brand-tile{width:30px;height:30px;flex:none;border-radius:9px;display:grid;place-items:center;color:var(--dsw-alias-label-primary-inverted);background:var(--dsw-alias-brand-primary);box-shadow:0 4px 14px -4px var(--dsw-alias-brand-primary)}\r\n.dab-brand-name{font-size:13px;font-weight:650;letter-spacing:.01em;line-height:1.25}\r\n.dab-brand-tag{font-size:9px;letter-spacing:.16em;font-weight:600;color:var(--dsw-alias-label-quaternary,var(--dsw-alias-label-tertiary));text-transform:uppercase}\r\n.dab-nav-list{position:relative;display:flex;flex-direction:column;gap:${NAV_GAP}px}\r\n.dab-nav-ind{position:absolute;left:0;right:0;top:0;height:${NAV_ITEM_H}px;border-radius:11px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 13%,transparent);border-color:color-mix(in srgb,var(--dsw-alias-brand-primary) 25%,transparent);transition:transform .38s cubic-bezier(.22,1,.36,1)}\r\n.dab-nav-item{position:relative;z-index:1;display:flex;align-items:center;gap:10px;height:${NAV_ITEM_H}px;padding:0 12px;border:0;background:none;border-radius:11px;color:var(--dsw-alias-label-tertiary);font-size:13px;cursor:pointer;text-align:left;transition:color .22s ease}\r\n.dab-nav-item:hover{color:var(--dsw-alias-label-primary)}\r\n.dab-nav-item.is-active{color:var(--dsw-alias-brand-primary);font-weight:600}\r\n.dab-nav-item svg{flex:none;transition:transform .3s cubic-bezier(.34,1.56,.64,1)}\r\n.dab-nav-item:hover svg{transform:scale(1.14) rotate(-5deg)}\r\n\r\n/* ── page chrome ─────────────────────────────────────────────────────────── */\r\n.dab-page{animation:dab-page-in .4s cubic-bezier(.22,1,.36,1) both;min-width:0;display:flex;flex-direction:column;gap:13px}\r\n.dab-head{margin:2px 0 5px}\r\n.dab-overline{font-size:10.5px;font-weight:700;letter-spacing:.18em;text-transform:uppercase;color:var(--dsw-alias-brand-primary);opacity:.9}\r\n.dab-h1{margin:4px 0 0;font-size:21px;font-weight:700;letter-spacing:-.01em}\r\n.dab-desc{margin:6px 0 0;font-size:12.5px;line-height:1.55;color:var(--dsw-alias-label-tertiary);max-width:56ch}\r\n.dab-card{background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);border-radius:16px;padding:18px}\r\n.dab-card-hover{transition:transform .28s ease,box-shadow .28s ease,border-color .28s ease}\r\n.dab-card-hover:hover{transform:translateY(-2px);box-shadow:0 10px 28px -12px rgba(0,0,0,.28)}\r\n.dab-rise{animation:dab-rise-in .55s cubic-bezier(.22,1,.36,1) both;animation-delay:calc(var(--d,0) * 62ms)}\r\n\r\n/* ── accent hero (color orb) ─────────────────────────────────────────────── */\r\n.dab-hero-accent{display:flex;align-items:center;gap:24px;flex-wrap:wrap}\r\n.dab-orb-wrap{position:relative;width:118px;height:118px;flex:none}\r\n.dab-orb{position:absolute;inset:11px;border-radius:50%;background:radial-gradient(circle at 32% 28%,rgba(255,255,255,.5),rgba(255,255,255,0) 44%),var(--c,#888);box-shadow:0 16px 36px -10px var(--c-soft,transparent),inset 0 -10px 20px rgba(0,0,0,.16);animation:dab-orb-in .7s cubic-bezier(.22,1,.36,1) both}\r\n.dab-orb-ring{position:absolute;inset:0;border-radius:50%;background:conic-gradient(from 0deg,transparent 0 30%,var(--c,#888) 46%,transparent 62%,transparent 76%,var(--c,#888) 90%,transparent 100%);-webkit-mask:radial-gradient(farthest-side,transparent calc(100% - 3.5px),#000 calc(100% - 2.5px));mask:radial-gradient(farthest-side,transparent calc(100% - 3.5px),#000 calc(100% - 2.5px));animation:dab-spin 7s linear infinite;opacity:.9}\r\n.dab-hex{font-family:var(--dab-mono);font-size:24px;font-weight:600;letter-spacing:.02em;line-height:1.2;margin-top:2px}\r\n.dab-hsl-row{display:flex;gap:16px;margin-top:7px;font-family:var(--dab-mono);font-size:11px;color:var(--dsw-alias-label-tertiary)}\r\n.dab-hsl-row b{font-weight:600;color:var(--dsw-alias-label-secondary,var(--dsw-alias-label-tertiary))}\r\n\r\n/* ── swatches ────────────────────────────────────────────────────────────── */\r\n.dab-swatch-title{font-size:12px;font-weight:600;margin-bottom:10px;color:var(--dsw-alias-label-secondary,var(--dsw-alias-label-tertiary))}\r\n.dab-swatches{display:flex;flex-wrap:wrap;gap:9px}\r\n.dab-swatch{width:25px;height:25px;border-radius:50%;border:0;padding:0;cursor:pointer;box-shadow:inset 0 0 0 1px rgba(0,0,0,.1);transition:transform .22s cubic-bezier(.34,1.56,.64,1),box-shadow .22s ease}\r\n.dab-swatch:hover{transform:scale(1.2)}\r\n.dab-swatch.is-on{box-shadow:0 0 0 2px var(--dsw-alias-bg-layer-1),0 0 0 4px var(--dsw-alias-brand-primary)}\r\n\r\n/* ── wheel card ──────────────────────────────────────────────────────────── */\r\n.dab-wheel-card{position:relative;display:flex;align-items:center;justify-content:center;gap:28px;flex-wrap:wrap;padding:24px 18px}\r\n.dab-wheel-glow{position:absolute;width:230px;height:230px;border-radius:50%;filter:blur(48px);opacity:.2;background:var(--c,#888);pointer-events:none;transition:background .4s ease}\r\n.dab-wheel{position:relative;cursor:crosshair;border-radius:50%;box-shadow:0 12px 32px -14px rgba(0,0,0,.4)}\r\n.dab-hint{font-size:11.5px;line-height:1.55;color:var(--dsw-alias-label-tertiary);padding:0 4px}\r\n\r\n/* ── precise color inputs ────────────────────────────────────────────────── */\r\n.dab-inputs{display:flex;flex-direction:column;gap:10px;min-width:172px}\r\n.dab-field{display:flex;align-items:center;gap:8px}\r\n.dab-field-label{width:14px;text-align:center;font-family:var(--dab-mono);font-size:11px;font-weight:600;color:var(--dsw-alias-label-tertiary)}\r\n.dab-num{flex:1;min-width:0;height:30px;padding:0 10px;border-radius:9px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font-family:var(--dab-mono);font-size:12px;outline:none;transition:border-color .2s,box-shadow .2s}\r\n.dab-num:focus{border-color:var(--dsw-alias-brand-primary);box-shadow:0 0 0 3px color-mix(in srgb,var(--dsw-alias-brand-primary) 18%,transparent)}\r\n.dab-num::-webkit-outer-spin-button,.dab-num::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}\r\n.dab-num{-moz-appearance:textfield;appearance:textfield}\r\n.dab-urlinput{flex:1;min-width:180px;height:34px;padding:0 12px;border-radius:10px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font-size:12.5px;outline:none;transition:border-color .2s}\r\n.dab-urlinput::placeholder{color:var(--dsw-alias-label-quaternary)}\r\n.dab-urlinput:focus{border-color:var(--dsw-alias-brand-primary);box-shadow:0 0 0 3px color-mix(in srgb,var(--dsw-alias-brand-primary) 18%,transparent)}\r\n/* Prints the current hex on the color itself. Without the value this was an\r\n * empty bordered rectangle sitting in the same column as the H/S/L number\r\n * fields, which made it read as one more — blank — text input; nothing is ever\r\n * typed here, so nothing may look typable. The hover scale went with that\r\n * reading: it advertised an interaction this field does not have. */\r\n.dab-swatch-lg{display:flex;align-items:center;justify-content:center;height:38px;border-radius:10px;border:1px solid var(--dsw-alias-border-l2);box-shadow:inset 0 0 14px rgba(0,0,0,.1);font-family:var(--dab-mono);font-size:12.5px;font-weight:600;letter-spacing:.06em;user-select:all}\r\n\r\n/* ── buttons & chips ─────────────────────────────────────────────────────── */\r\n/* Text/icon painted ON --dsw-alias-brand-primary reads\r\n * --dsw-alias-label-primary-inverted, never --dsw-alias-brand-text. The host's\r\n * brand-primary is a CONTRAST ink, not a hue: black in its light scheme and\r\n * near-white (#f9fafb) in its dark one, with brand-text equal to it in BOTH\r\n * (and unused by the host's own CSS). Following the system theme therefore made\r\n * every brand-filled control a filled box with an invisible label — a white\r\n * primary button and a white active chip on a dark dialog. It was only ever\r\n * readable while the plugin owned the palette and generated its own brand pair.\r\n * label-primary-inverted is the host's answer for ink on a brand/contrast fill\r\n * (its sidebar build badge paints exactly this pair) and it flips with the\r\n * scheme: #fff on the light scheme's black fill, #353638 on the dark scheme's\r\n * white one. */\r\n.dab-btn{display:inline-flex;align-items:center;justify-content:center;gap:7px;height:34px;padding:0 14px;border-radius:10px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-button-elevated-fill);color:var(--dsw-alias-label-primary);font-size:12.5px;font-weight:550;cursor:pointer;transition:transform .18s ease,box-shadow .18s ease,border-color .18s ease,opacity .18s ease,background .18s ease}\r\n.dab-btn:hover:not(:disabled){transform:translateY(-1px);box-shadow:0 5px 14px -6px rgba(0,0,0,.32)}\r\n.dab-btn:active:not(:disabled){transform:translateY(0) scale(.97);box-shadow:none}\r\n.dab-btn:disabled{opacity:.5;cursor:not-allowed}\r\n.dab-btn-primary{background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary-inverted);border-color:transparent}\r\n.dab-btn-danger{color:var(--dsw-alias-state-error-primary)}\r\n.dab-btn-ghost{background:transparent;border-color:transparent;color:var(--dsw-alias-label-secondary,var(--dsw-alias-label-tertiary))}\r\n.dab-btn-ghost:hover:not(:disabled){background:var(--dsw-alias-bg-layer-2);box-shadow:none}\r\n.dab-btn:focus-visible,.dab-nav-item:focus-visible,.dab-seg-item:focus-visible,.dab-swatch:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}\r\n.dab-chip-row{display:flex;flex-wrap:wrap;gap:8px}\r\n.dab-chip{height:30px;padding:0 14px;border-radius:99px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-secondary,var(--dsw-alias-label-tertiary));font-size:12px;cursor:pointer;display:inline-flex;align-items:center;gap:6px;transition:all .22s ease}\r\n.dab-chip:hover{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary)}\r\n.dab-chip.is-active{background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary-inverted);border-color:transparent}\r\n\r\n/* ── sliders ─────────────────────────────────────────────────────────────── */\r\n.dab-slider-block{display:flex;flex-direction:column;gap:6px}\r\n.dab-slider-block + .dab-slider-block{margin-top:13px}\r\n.dab-slider-label{font-size:12px;font-weight:550;color:var(--dsw-alias-label-secondary,var(--dsw-alias-label-tertiary))}\r\n.dab-slider-val{font-family:var(--dab-mono);font-size:11px;color:var(--dsw-alias-label-tertiary);min-width:44px;text-align:right}\r\n.dab-slider{-webkit-appearance:none;appearance:none;flex:1;min-width:0;height:4px;border-radius:99px;outline:none;cursor:pointer;margin:5px 0;background:linear-gradient(to right,var(--dsw-alias-brand-primary) calc(var(--pct,50) * 1%),var(--dsw-alias-border-l2) calc(var(--pct,50) * 1%));transition:height .15s ease}\r\n.dab-slider:hover{height:5px}\r\n.dab-slider::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:15px;height:15px;border-radius:50%;background:var(--dsw-alias-button-elevated-fill,#fff);border:2px solid var(--dsw-alias-brand-primary);box-shadow:0 1px 5px rgba(0,0,0,.28);transition:transform .16s cubic-bezier(.34,1.56,.64,1)}\r\n.dab-slider:hover::-webkit-slider-thumb,.dab-slider:focus-visible::-webkit-slider-thumb{transform:scale(1.22)}\r\n.dab-slider:active::-webkit-slider-thumb{transform:scale(1.34)}\r\n.dab-slider::-moz-range-thumb{width:13px;height:13px;border-radius:50%;background:var(--dsw-alias-button-elevated-fill,#fff);border:2px solid var(--dsw-alias-brand-primary)}\r\n\r\n/* ── interface part cards ────────────────────────────────────────────────── */\r\n.dab-grid-parts{display:grid;grid-template-columns:repeat(auto-fill,minmax(256px,1fr));gap:13px}\r\n.dab-part-head{display:flex;align-items:center;gap:11px;margin-bottom:14px}\r\n.dab-part-ico{width:32px;height:32px;flex:none;border-radius:10px;display:grid;place-items:center;color:var(--dsw-alias-brand-primary);background:var(--dsw-alias-bg-layer-2);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 12%,transparent)}\r\n.dab-part-name{font-size:13.5px;font-weight:600}\r\n.dab-part-badge{margin-left:auto;font-family:var(--dab-mono);font-size:11px;color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-layer-2);border-radius:99px;padding:3px 9px}\r\n\r\n/* ── segmented control ───────────────────────────────────────────────────── */\r\n.dab-seg{position:relative;display:inline-flex;padding:3px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:11px}\r\n.dab-seg-thumb{position:absolute;top:3px;bottom:3px;left:3px;width:var(--w,96px);border-radius:8px;background:var(--dsw-alias-button-elevated-fill);box-shadow:0 2px 8px -2px rgba(0,0,0,.28);transition:transform .32s cubic-bezier(.22,1,.36,1)}\r\n.dab-seg-item{position:relative;z-index:1;display:inline-flex;align-items:center;justify-content:center;gap:6px;width:var(--w,96px);height:30px;border:0;background:none;border-radius:8px;color:var(--dsw-alias-label-tertiary);font-size:12.5px;cursor:pointer;transition:color .25s ease}\r\n.dab-seg-item.is-active{color:var(--dsw-alias-label-primary);font-weight:600}\r\n\r\n/* ── toggle switch ───────────────────────────────────────────────────────── */\r\n.dab-toggle{position:relative;width:42px;height:24px;flex:none;border-radius:99px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);cursor:pointer;padding:0;transition:background .28s ease,border-color .28s ease}\r\n.dab-toggle-knob{position:absolute;top:2.5px;left:2.5px;width:17px;height:17px;border-radius:50%;background:var(--dsw-alias-label-secondary,#999);box-shadow:0 1px 3px rgba(0,0,0,.3);transition:transform .28s cubic-bezier(.22,1,.36,1),background .28s ease}\r\n.dab-toggle.is-on{background:var(--dsw-alias-brand-primary);border-color:var(--dsw-alias-brand-primary)}\r\n.dab-toggle.is-on .dab-toggle-knob{transform:translateX(18px);background:var(--dsw-alias-label-primary-inverted)}\r\n\r\n/* ── background preview hero ─────────────────────────────────────────────── */\r\n.dab-hero{position:relative;border-radius:16px;overflow:hidden;aspect-ratio:16/9;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2)}\r\n.dab-hero-img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;transition:transform .5s cubic-bezier(.22,1,.36,1)}\r\n.dab-hero:hover .dab-hero-img{transform:scale(1.03)}\r\n.dab-hero-empty{position:absolute;inset:6px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;color:var(--dsw-alias-label-tertiary);font-size:12.5px;border:1.5px dashed var(--dsw-alias-border-l2);border-radius:12px;cursor:pointer;background:transparent;transition:border-color .25s,color .25s,background .25s;width:auto;height:auto}\r\n.dab-hero-empty:hover{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}\r\n.dab-hero-empty.is-over{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 8%,transparent)}\r\n.dab-hero-badge{position:absolute;top:10px;left:10px;display:inline-flex;align-items:center;gap:5px;height:24px;padding:0 11px;border-radius:99px;background:rgba(0,0,0,.45);color:#fff;font-size:11px;backdrop-filter:blur(6px);pointer-events:none}\r\n.dab-hero-veil{position:absolute;left:0;right:0;bottom:0;padding:34px 12px 12px;display:flex;align-items:flex-end;justify-content:flex-end;gap:8px;background:linear-gradient(to top,rgba(0,0,0,.55),rgba(0,0,0,0));opacity:0;transform:translateY(6px);transition:opacity .3s ease,transform .3s ease}\r\n.dab-hero:hover .dab-hero-veil{opacity:1;transform:none}\r\n.dab-hero-veil .dab-btn{background:rgba(255,255,255,.94);color:#14161a;border-color:transparent;height:30px;font-size:12px}\r\n.dab-hero-veil .dab-btn-danger{color:#dc2626}\r\n\r\n/* ── profile page ────────────────────────────────────────────────────────── */\r\n.dab-profile-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(238px,1fr));gap:13px}\r\n.dab-profile-ico{width:38px;height:38px;border-radius:11px;display:grid;place-items:center;margin-bottom:13px;color:var(--dsw-alias-brand-primary);background:var(--dsw-alias-bg-layer-2);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 12%,transparent)}\r\n.dab-profile-title{font-size:14px;font-weight:650}\r\n.dab-profile-desc{font-size:12px;color:var(--dsw-alias-label-tertiary);line-height:1.55;margin:5px 0 15px}\r\n.dab-footer{margin-top:6px;padding:14px 4px 0;border-top:1px solid var(--dsw-alias-border-l2);display:flex;align-items:center;justify-content:space-between;font-size:11px;color:var(--dsw-alias-label-tertiary)}\r\n.dab-footer-mono{font-family:var(--dab-mono);letter-spacing:.02em}\r\n\r\n/* ── toast ───────────────────────────────────────────────────────────────── */\r\n.dab-toast{position:fixed;left:50%;bottom:30px;transform:translateX(-50%);display:flex;align-items:center;gap:8px;height:38px;padding:0 16px;border-radius:99px;background:var(--dsw-alias-bg-layer-3,var(--dsw-alias-bg-layer-2));border:1px solid var(--dsw-alias-border-l2);box-shadow:0 10px 30px -8px rgba(0,0,0,.38);font-size:12.5px;z-index:10001;animation:dab-toast-in .32s cubic-bezier(.22,1,.36,1) both}\r\n.dab-toast-ok{color:var(--dsw-alias-brand-primary);display:grid;place-items:center}\r\n.dab-toast-err{color:var(--dsw-alias-state-error-primary);display:grid;place-items:center}\r\n\r\n/* ── modals (editor / eyedropper / crash) ────────────────────────────────── */\r\n/* Pin to the viewport explicitly with vw/vh so ancestor padding/margins on\r\n * body cannot shift or clip the overlay; keep it above host sidebar chrome.\r\n * pointer-events:auto re-enables interaction: these overlays render inside a\r\n * Portal root that is pointer-events:none so it never blocks the page alone. */\r\n.dab-overlay{position:fixed;left:0;top:0;width:100vw;height:100vh;z-index:999999;background:rgba(8,10,14,.62);backdrop-filter:blur(8px);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;animation:dab-fade-in .25s ease both;pointer-events:auto}\r\n.dab-overlay-title{color:#fff;font-size:15px;font-weight:600}\r\n.dab-overlay-hint{color:rgba(255,255,255,.62);font-size:12px}\r\n.dab-modal-card{animation:dab-zoom-in .3s cubic-bezier(.22,1,.36,1) both;max-width:calc(100vw - 40px);max-height:calc(100vh - 120px);overflow:auto}\r\n.dab-overlay .dab-btn{background:rgba(255,255,255,.94);color:#14161a;border-color:transparent}\r\n.dab-overlay .dab-btn-primary{background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary-inverted)}\r\n.dab-crash{display:flex;flex-direction:column;gap:10px;align-items:center;padding:28px 18px;border:1px solid var(--dsw-alias-border-l2);border-radius:16px}\r\n.dab-crash-title{font-size:15px;font-weight:650}\r\n.dab-crash-desc{font-size:12px;color:var(--dsw-alias-label-tertiary);text-align:center;line-height:1.5}\r\n\r\n/* ── model rules ─────────────────────────────────────────────────────────── */\r\n.dab-rules{display:flex;flex-direction:column;gap:12px}\r\n.dab-rule{background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);border-radius:16px;padding:14px;transition:border-color .25s,box-shadow .25s,opacity .25s}\r\n.dab-rule.is-active{border-color:var(--dsw-alias-brand-primary);box-shadow:0 0 0 3px color-mix(in srgb,var(--dsw-alias-brand-primary) 16%,transparent)}\r\n.dab-rule.is-off{opacity:.55}\r\n.dab-rule-head{display:flex;align-items:center;gap:9px;flex-wrap:wrap}\r\n.dab-rule-num{font-family:var(--dab-mono);font-size:11px;font-weight:700;color:var(--dsw-alias-label-tertiary);min-width:16px}\r\n.dab-rule-badge{font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:var(--dsw-alias-brand-primary);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 14%,transparent);border-radius:99px;padding:2px 8px}\r\n.dab-rule-match{flex:1;min-width:150px;height:32px;padding:0 11px;border-radius:9px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font-family:var(--dab-mono);font-size:12.5px;outline:none;transition:border-color .2s,box-shadow .2s}\r\n.dab-rule-match::placeholder{color:var(--dsw-alias-label-quaternary)}\r\n.dab-rule-match:focus{border-color:var(--dsw-alias-brand-primary);box-shadow:0 0 0 3px color-mix(in srgb,var(--dsw-alias-brand-primary) 18%,transparent)}\r\n.dab-icon-btn{width:28px;height:28px;flex:none;display:grid;place-items:center;border-radius:8px;border:1px solid var(--dsw-alias-border-l2);background:transparent;color:var(--dsw-alias-label-tertiary);cursor:pointer;transition:color .2s,border-color .2s,background .2s}\r\n.dab-icon-btn:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-brand-primary)}\r\n.dab-icon-btn:disabled{opacity:.35;cursor:not-allowed}\r\n.dab-icon-btn-danger:hover:not(:disabled){color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-primary)}\r\n.dab-rule-body{margin-top:13px;display:flex;flex-direction:column;gap:13px}\r\n.dab-rule-thumb{position:relative;border-radius:12px;overflow:hidden;aspect-ratio:16/9;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);cursor:pointer}\r\n.dab-rule-thumb img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}\r\n.dab-rule-thumb-empty{position:absolute;inset:5px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;border:1.5px dashed var(--dsw-alias-border-l2);border-radius:9px;color:var(--dsw-alias-label-tertiary);font-size:12px;text-align:center;padding:0 10px}\r\n.dab-rule-thumb.is-over .dab-rule-thumb-empty{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}\r\n.dab-rule-cols{display:grid;grid-template-columns:minmax(0,1.15fr) minmax(0,1fr);gap:18px;align-items:start}\r\n.dab-rule-section-title{font-size:12px;font-weight:600;margin-bottom:9px;color:var(--dsw-alias-label-secondary,var(--dsw-alias-label-tertiary))}\r\n@container (max-width:760px){.dab-rule-cols{grid-template-columns:1fr}}\r\n\r\n/* ── host self-check ─────────────────────────────────────────────────────── */\r\n.dab-verdict{display:flex;flex-direction:column;gap:14px;position:relative;overflow:hidden}\r\n.dab-verdict::after{content:'';position:absolute;inset:0;pointer-events:none;opacity:.5;background:linear-gradient(120deg,transparent 55%,color-mix(in srgb,var(--dab-verdict-tone,transparent) 26%,transparent))}\r\n.dab-verdict-ok{--dab-verdict-tone:var(--dsw-alias-state-success-primary,var(--dsw-alias-brand-primary));border-color:color-mix(in srgb,var(--dsw-alias-state-success-primary,var(--dsw-alias-brand-primary)) 38%,var(--dsw-alias-border-l2))}\r\n.dab-verdict-partial,.dab-verdict-broken{--dab-verdict-tone:var(--dsw-alias-state-error-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 40%,var(--dsw-alias-border-l2))}\r\n.dab-verdict-unknown{--dab-verdict-tone:var(--dsw-alias-label-tertiary)}\r\n.dab-verdict-head{display:flex;align-items:center;gap:13px;flex-wrap:wrap}\r\n.dab-verdict-ico{width:34px;height:34px;flex:none;border-radius:11px;display:grid;place-items:center;color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-layer-2)}\r\n.dab-verdict-ico-ok{color:var(--dsw-alias-state-success-primary,var(--dsw-alias-brand-primary));background:color-mix(in srgb,var(--dsw-alias-state-success-primary,var(--dsw-alias-brand-primary)) 14%,transparent)}\r\n.dab-verdict-ico-partial,.dab-verdict-ico-broken{color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 14%,transparent)}\r\n.dab-verdict-text{flex:1;min-width:170px}\r\n.dab-verdict-title{font-size:14.5px;font-weight:650}\r\n.dab-verdict-sub{margin-top:4px;font-size:12px;color:var(--dsw-alias-label-tertiary)}\r\n.dab-verdict-actions{display:flex;gap:8px;flex-wrap:wrap;margin-left:auto}\r\n.dab-facts{display:flex;flex-wrap:wrap;gap:8px;position:relative;z-index:1}\r\n.dab-fact{display:inline-flex;align-items:center;gap:7px;height:27px;padding:0 11px;border-radius:99px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);max-width:100%}\r\n.dab-fact.is-bad{border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 45%,transparent);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent)}\r\n.dab-fact-k{font-size:10.5px;font-weight:650;letter-spacing:.06em;text-transform:uppercase;color:var(--dsw-alias-label-tertiary);white-space:nowrap}\r\n.dab-fact-v{font-family:var(--dab-mono);font-size:11.5px;color:var(--dsw-alias-label-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:32ch}\r\n.dab-check-group-title{display:flex;align-items:center;gap:9px;font-size:12.5px;font-weight:650;margin-bottom:11px}\r\n.dab-check-group-count{margin-left:auto;font-family:var(--dab-mono);font-size:11px;font-weight:500;color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-layer-2);border-radius:99px;padding:3px 9px}\r\n.dab-checks{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px}\r\n.dab-check{display:flex;gap:10px;padding:9px 10px;border-radius:11px;transition:background .2s ease}\r\n.dab-check:hover{background:var(--dsw-alias-bg-layer-2)}\r\n.dab-check-ico{width:19px;height:19px;flex:none;margin-top:1px;border-radius:50%;display:grid;place-items:center;color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-layer-2)}\r\n.dab-check-ico-pass{color:var(--dsw-alias-state-success-primary,var(--dsw-alias-brand-primary));background:color-mix(in srgb,var(--dsw-alias-state-success-primary,var(--dsw-alias-brand-primary)) 15%,transparent)}\r\n.dab-check-ico-fail{color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 15%,transparent)}\r\n.dab-check-dot{width:5px;height:5px;border-radius:50%;background:currentColor;opacity:.65}\r\n.dab-check-body{min-width:0;flex:1;display:flex;flex-direction:column;gap:3px}\r\n.dab-check-head{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap}\r\n.dab-check-label{font-size:12.5px;font-weight:600}\r\n.dab-check-status{font-size:10px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;padding:1px 7px;border-radius:99px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-tertiary)}\r\n.dab-check-status-pass{color:var(--dsw-alias-state-success-primary,var(--dsw-alias-brand-primary));background:color-mix(in srgb,var(--dsw-alias-state-success-primary,var(--dsw-alias-brand-primary)) 14%,transparent)}\r\n.dab-check-status-fail{color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 14%,transparent)}\r\n.dab-check-target{font-family:var(--dab-mono);font-size:10.5px;color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-layer-2);border-radius:6px;padding:1px 6px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\r\n.dab-check-detail{font-family:var(--dab-mono);font-size:11px;color:var(--dsw-alias-label-tertiary);line-height:1.5;overflow-wrap:anywhere}\r\n.dab-check-reason{display:flex;flex-direction:column;gap:5px;font-size:12px;line-height:1.55;color:var(--dsw-alias-label-secondary,var(--dsw-alias-label-tertiary))}\r\n.dab-check-symptom{color:var(--dsw-alias-state-error-primary)}\r\n.dab-check-where{display:flex;gap:7px;align-items:baseline;flex-wrap:wrap;font-size:11px;color:var(--dsw-alias-label-tertiary)}\r\n.dab-check-where code{font-family:var(--dab-mono);font-size:10.5px;overflow-wrap:anywhere}\r\n.dab-check-note{margin:12px 0 0;font-size:11.5px;line-height:1.55;color:var(--dsw-alias-label-tertiary);position:relative;z-index:1}\r\n\r\n/* ── keyframes ───────────────────────────────────────────────────────────── */\r\n@keyframes dab-fade-in{from{opacity:0}to{opacity:1}}\r\n@keyframes dab-page-in{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}\r\n@keyframes dab-rise-in{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}\r\n@keyframes dab-orb-in{from{opacity:0;transform:scale(.82)}to{opacity:1;transform:none}}\r\n@keyframes dab-spin{to{transform:rotate(360deg)}}\r\n@keyframes dab-rotate{to{transform:rotate(360deg)}}\r\n@keyframes dab-toast-in{from{opacity:0;transform:translate(-50%,10px)}to{opacity:1;transform:translate(-50%,0)}}\r\n@keyframes dab-zoom-in{from{opacity:0;transform:scale(.94) translateY(8px)}to{opacity:1;transform:none}}\r\n@keyframes dab-flow{to{background-position:300% 50%}}\r\n\r\n/* ── responsive & motion preferences ─────────────────────────────────────── */\r\n@container (max-width:620px){\r\n .dab-shell{grid-template-columns:1fr;gap:14px}\r\n .dab-nav{position:static;flex-direction:row;align-items:center;justify-content:space-between;gap:10px}\r\n .dab-nav-list{flex-direction:row;overflow-x:auto;scrollbar-width:none}\r\n .dab-nav-list::-webkit-scrollbar{display:none}\r\n .dab-nav-ind{display:none}\r\n .dab-nav-item{flex:none;padding:0 10px}\r\n .dab-nav-item.is-active{background:var(--dsw-alias-bg-layer-2)}\r\n .dab-types{grid-template-columns:1fr}\r\n .dab-verdict-actions{margin-left:0;width:100%}\r\n .dab-verdict-actions .dab-btn{flex:1}\r\n}\r\n@container (min-width:621px){\r\n .dab-shell{grid-template-columns:158px minmax(0,1fr);gap:26px}\r\n}\r\n@media (prefers-reduced-motion:reduce){\r\n .dab-root *,.dab-root *::before,.dab-root *::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}\r\n}\r\n`\r\n\r\nconst CSS_ID = 'dab-ui-css'\r\n\r\n/**\r\n * The attribute that marks a `<style>` element as OURS.\r\n *\r\n * The host's own CSS modules also set `data-plugin` on their `<style>` elements\r\n * (every one of them), so `data-plugin` cannot distinguish this plugin's sheets\r\n * from the host's — and the host-contract probe has to make exactly that\r\n * distinction: a token this plugin re-emits must never be allowed to make a\r\n * *host* check pass. This attribute is the honest marker, and it is set on every\r\n * stylesheet this plugin injects.\r\n */\r\nexport const OWN_SHEET_ATTR = 'data-dab-side'\r\n\r\n/** Mark a stylesheet this plugin injected, so the host probe can tell it apart. */\r\nexport function markOwnSheet(el: HTMLStyleElement): HTMLStyleElement {\r\n el.setAttribute(OWN_SHEET_ATTR, 'own')\r\n return el\r\n}\r\n\r\n/** Inject the design-system stylesheet once per document (HMR-safe). */\r\nexport function ensureUiCss(): void {\r\n if (typeof document === 'undefined') return\r\n let el = document.getElementById(CSS_ID) as HTMLStyleElement | null\r\n if (!el) {\r\n el = document.createElement('style')\r\n el.id = CSS_ID\r\n markOwnSheet(el)\r\n document.head.appendChild(el)\r\n }\r\n if (el.textContent !== UI_CSS) el.textContent = UI_CSS\r\n}\r\n","import { rWp, rBgState, rBl, rWop, rOps, rSop, rColor, rHasColor, rBlurs, rBgMode, rChatTextOpacity, rTrajectoryOpacity, rRightbarOpacity } from './state'\r\nimport type { PartOpacities, PartBlurs } from './types'\r\nimport { genTokens, toRgba } from './utils/color'\r\nimport { markOwnSheet } from './components/ui.css'\r\n\r\n/**\r\n * `data-ds-dark-theme` value the plugin writes while it forces its own dark\r\n * palette. The host treats the attribute as a boolean (`toggleAttribute`), so a\r\n * plugin-specific value still matches every `body[data-ds-dark-theme]` rule\r\n * while staying distinguishable from the host's own write — which is what lets\r\n * `releaseOwnScheme` hand the flag back without clobbering the host's scheme.\r\n */\r\nexport const OWN_SCHEME = 'dsh-background-by-model'\r\nconst DARK_ATTR = 'data-ds-dark-theme'\r\n\r\n/**\r\n * Marker on <html> while the plugin owns a palette. The dialog/trajectory rules\r\n * below redirect NO-fallback tokens (`--dsw-alias-bg-layer-*`) to plugin-owned\r\n * variables, so they may only match while those variables are actually written:\r\n * without the gate a palette-less state would leave them reading a\r\n * guaranteed-invalid value (transparent panels) instead of handing the surface\r\n * back to the host untouched.\r\n */\r\nconst THEMED_ATTR = 'data-dab-themed'\r\n\r\nlet wpEl: HTMLDivElement | null = null\r\nlet appliedTokenNames: string[] = []\r\nlet tokenStyleEl: HTMLStyleElement | null = null\r\n\r\nfunction ensureTokenStyle(): HTMLStyleElement {\r\n if (tokenStyleEl?.isConnected) return tokenStyleEl\r\n tokenStyleEl = document.createElement('style')\r\n tokenStyleEl.dataset.plugin = 'dsh-background-by-model-tokens'\r\n markOwnSheet(tokenStyleEl)\r\n document.head.appendChild(tokenStyleEl)\r\n return tokenStyleEl\r\n}\r\n\r\nfunction clearCustomTokens(): void {\r\n if (tokenStyleEl) tokenStyleEl.textContent = ''\r\n for (const name of appliedTokenNames) document.body.style.removeProperty(name)\r\n appliedTokenNames = []\r\n // Whatever follows must repaint from scratch: the fingerprints that guard the\r\n // token rule and the part opacities describe a stylesheet that no longer exists.\r\n baseTokenKey = ''\r\n lastBgKey = ''\r\n}\r\n\r\n/** Drop every surface the plugin owns: the variables the scoped\r\n * dialog/trajectory rules read, and the inline backgrounds written onto the\r\n * AppFrame columns. Used when no palette is available and at teardown — without\r\n * it the last color's surfaces outlive the color that produced them. */\r\nfunction clearOwnedSurfaces(): void {\r\n discoverParts()\r\n const root = document.documentElement\r\n for (const name of OWNED_SURFACE_VARS) root.style.removeProperty(name)\r\n for (const el of [frameEl, centerEl, detailsEl]) el?.style.removeProperty('background')\r\n}\r\n\r\n// Solid surface tokens grouped by which interface-opacity slider owns them.\r\n// Every member is re-emitted with per-part alpha so surfaces over the wallpaper\r\n// (composer input, elevated buttons, menu panels) can go translucent — not just\r\n// the layered bg/sidebar tokens. The two menu fills are owned by the card slider\r\n// and must always travel together: --dsw-specific-menu is what overlays paint\r\n// (dropdowns, slash-trigger menu, popovers around the dialog) and\r\n// --dsw-menu-surface-fill is what the shared MenuSurface material paints, which\r\n// dsh 0.1.7 aliases the former to. Re-emitting only one of them leaves a menu\r\n// panel on one fill and its sticky group headings on the other — the solid band\r\n// across the model selector's provider rows. The Cordis panel shares\r\n// --dsw-specific-menu but is re-scoped to the input slider via INPUT_BLUR_RULE.\r\nconst OPACITY_TOKEN_GROUPS: Array<{ part: keyof PartOpacities; names: string[] }> = [\r\n { part: 'bg', names: ['--dsw-alias-bg-base'] },\r\n { part: 'sidebar', names: ['--dsw-specific-sidebar-fill'] },\r\n { part: 'card', names: ['--dsw-alias-bg-layer-1', '--dsw-alias-bg-layer-2', '--dsw-alias-bg-layer-3', '--dsw-specific-menu', '--dsw-menu-surface-fill'] },\r\n { part: 'input', names: ['--dsw-specific-input-major'] },\r\n]\r\n\r\n// Plugin-owned variables the opacity-bearing tokens read from. They live as\r\n// inline custom props on <html>, so a slider drag rewrites only those few values\r\n// instead of re-parsing/re-matching the whole body token rule on every tick —\r\n// the difference is critical when a large wallpaper sits under the interface.\r\nconst OPACITY_VARS: Record<string, string> = {\r\n '--dsw-alias-bg-base': '--dsh-any-op-bg',\r\n '--dsw-specific-sidebar-fill': '--dsh-any-op-sidebar',\r\n '--dsw-alias-bg-layer-1': '--dsh-any-op-card-1',\r\n '--dsw-alias-bg-layer-2': '--dsh-any-op-card-2',\r\n '--dsw-alias-bg-layer-3': '--dsh-any-op-card-3',\r\n '--dsw-specific-input-major': '--dsh-any-op-input',\r\n // The MenuSurface material under a menu panel and the overlay fill its sticky\r\n // headings paint are the same value on a 0.1.7 host, so they read the same\r\n // plugin-owned variable — one slider, one alpha, no seam between them.\r\n '--dsw-specific-menu': '--dsh-any-op-menu',\r\n '--dsw-menu-surface-fill': '--dsh-any-op-menu',\r\n}\r\n\r\n// Fingerprint of the non-alpha token base (palette source + color pick +\r\n// scheme verdict). The static body rule is only rebuilt when it changes; a drag\r\n// never touches it.\r\nlet baseTokenKey = ''\r\n\r\n// ── Palette source ────────────────────────────────────────────────────────────\r\n// Every surface is painted from ONE palette at a time:\r\n// * a rule WITH a color → the plugin's generated token set;\r\n// * a rule WITHOUT a color → the host's own alias tokens, read back out of the\r\n// live cascade, so \"follow the system theme\" keeps the wallpaper showing and\r\n// the Interface-page sliders working instead of dropping every surface back\r\n// to the host as an opaque plate.\r\n// Both feed the same writers (the body token rule, the per-part alpha variables,\r\n// the dialog/trajectory scoping), so there is never a state where one surface is\r\n// painted from one palette and another from the other one.\r\nconst HOST_SURFACE_TOKENS: string[] = Object.keys(OPACITY_VARS)\r\n\r\n/** Plugin-owned variables the scoped dialog/trajectory rules read. */\r\nconst SETTINGS_SURFACE_VARS = [\r\n '--dsh-any-bg-settings-surface',\r\n '--dsh-any-bg-settings-layer-1',\r\n '--dsh-any-bg-settings-layer-2',\r\n '--dsh-any-bg-settings-layer-3',\r\n]\r\nconst TRAJECTORY_SURFACE_VARS = [\r\n '--dsh-any-traj-layer-1',\r\n '--dsh-any-traj-layer-2',\r\n '--dsh-any-traj-layer-3',\r\n]\r\nconst OWNED_SURFACE_VARS = [...SETTINGS_SURFACE_VARS, ...TRAJECTORY_SURFACE_VARS]\r\n\r\ninterface Palette {\r\n /** True while the palette is the plugin's own (the rule carries a color). */\r\n own: boolean\r\n tokens: Record<string, string>\r\n}\r\n\r\nlet hostProbe: HTMLElement | null = null\r\n\r\n/** Resolve any color the engine understands (hex, rgb()/hsl(), a var() chain,\r\n * color-mix(), …) to its USED value: only a used color can be re-emitted with\r\n * an alpha. Returns null when the engine rejects the value. */\r\nfunction resolveCssColor(raw: string): string | null {\r\n const value = raw.trim()\r\n if (value === '') return null\r\n if (hostProbe === null) {\r\n hostProbe = document.createElement('span')\r\n hostProbe.setAttribute('aria-hidden', 'true')\r\n hostProbe.style.cssText = 'position:absolute;width:0;height:0;pointer-events:none'\r\n }\r\n if (!hostProbe.isConnected) document.body.appendChild(hostProbe)\r\n // Reset first: a rejected value must not be mistaken for the previous one.\r\n hostProbe.style.color = ''\r\n hostProbe.style.color = value\r\n if (hostProbe.style.color === '') return null\r\n return getComputedStyle(hostProbe).color || null\r\n}\r\n\r\n/** Read the host's own surface colors out of the live cascade. */\r\nfunction readHostPalette(): Palette | null {\r\n const sheet = tokenStyleEl\r\n // Our token rule re-emits the very names being asked for, so it has to be\r\n // muted while reading or the readback would return the palette we are leaving.\r\n // No paint can happen in between: the flag is set and cleared in one task.\r\n const muted = sheet !== null && sheet.isConnected && !sheet.disabled\r\n if (muted) sheet!.disabled = true\r\n try {\r\n const computed = getComputedStyle(document.body)\r\n const tokens: Record<string, string> = {}\r\n for (const name of HOST_SURFACE_TOKENS) {\r\n const used = resolveCssColor(computed.getPropertyValue(name))\r\n if (used !== null) tokens[name] = used\r\n }\r\n // Without a base surface there is no palette to paint from: the caller hands\r\n // every surface back to the host instead.\r\n return tokens['--dsw-alias-bg-base'] === undefined ? null : { own: false, tokens }\r\n } finally {\r\n if (muted) sheet!.disabled = false\r\n }\r\n}\r\n\r\n// The readback costs a style recalculation and applyWp runs on every viewport\r\n// frame, so the last result is reused briefly. The theme-reset watch drops it on\r\n// any scheme change; the TTL covers a host palette rewritten without one.\r\nlet hostPaletteCache: { at: number; palette: Palette | null } | null = null\r\nconst HOST_PALETTE_TTL_MS = 1000\r\n\r\nexport function invalidateHostPalette(): void { hostPaletteCache = null }\r\n\r\nfunction hostPalette(): Palette | null {\r\n const now = Date.now()\r\n if (hostPaletteCache !== null && now - hostPaletteCache.at < HOST_PALETTE_TTL_MS) return hostPaletteCache.palette\r\n const read = readHostPalette()\r\n hostPaletteCache = { at: now, palette: read }\r\n return read\r\n}\r\n\r\n/** The palette every surface is currently painted from. */\r\nfunction palette(): Palette | null {\r\n if (!rHasColor()) return hostPalette()\r\n const [h, s, l] = rColor()\r\n return { own: true, tokens: genTokens(h, s, l).tokens }\r\n}\r\n\r\n/** A resolved color with a new alpha. The plugin's own tokens are `hsl()` and\r\n * the host's alias tokens resolve to hex, both of which `toRgba` parses; a host\r\n * publishing an already-composited value (`color(…)`, `oklab(…)`, …) cannot be\r\n * parsed there, and emitting it unchanged would paint an OPAQUE surface — the\r\n * one outcome the transparent-surface design must never fall back to. Those go\r\n * through `color-mix` instead. */\r\nfunction withAlpha(color: string, alpha: number): string {\r\n const converted = toRgba(color, alpha)\r\n if (/^(rgb|hsl)a?\\(/i.test(converted)) return converted\r\n const pct = Math.round(Math.max(0, Math.min(1, alpha)) * 100)\r\n return `color-mix(in srgb, ${color} ${pct}%, transparent)`\r\n}\r\n\r\n/**\r\n * The color scheme the HOST's own preference resolves to, pushed in by the\r\n * browser half (the theme service knows it, custom themes included). `null`\r\n * means \"unknown\", which is the only case where the plugin falls back to the\r\n * preference the host's boot script published and to the OS query itself.\r\n */\r\nlet hostSchemeDark: boolean | null = null\r\n\r\nexport function setHostScheme(dark: boolean | null): void { hostSchemeDark = dark }\r\n\r\nfunction resolveHostDark(): boolean {\r\n if (typeof hostSchemeDark === 'boolean') return hostSchemeDark\r\n // The host's boot script publishes the preference it resolved\r\n // (`html[data-ds-theme-source]`) before any plugin runs.\r\n const source = document.documentElement.dataset.dsThemeSource\r\n if (source === 'dark') return true\r\n if (source === 'light') return false\r\n try { return window.matchMedia('(prefers-color-scheme: dark)').matches } catch { return false }\r\n}\r\n\r\n/**\r\n * Keep `data-ds-dark-theme` in the HOST's own form (a boolean attribute) while\r\n * the plugin does not own a palette.\r\n *\r\n * The plugin overwrites that flag whenever it owns a palette — including\r\n * REMOVING it to force a light one — and the host only re-projects the flag on a\r\n * theme change. So a flag the plugin dropped can stick: the host keeps painting\r\n * its light palette on a dark system, the readback then hands those light\r\n * surfaces back to the plugin, and the interface stays light until some\r\n * unrelated event happens to re-run an apply. Restoring the flag from the\r\n * resolved scheme closes that hole, and the write is skipped when it already\r\n * matches so this never churns the theme observer.\r\n */\r\nexport function adoptHostScheme(): void {\r\n const dark = resolveHostDark()\r\n const current = document.body.getAttribute(DARK_ATTR)\r\n if (dark) {\r\n if (current !== '') document.body.setAttribute(DARK_ATTR, '')\r\n } else if (current !== null) {\r\n document.body.removeAttribute(DARK_ATTR)\r\n }\r\n}\r\n\r\n/** Re-read the host palette and repaint from it when it moved. Called while a\r\n * color-less rule is active (the host can re-project its palette at any time,\r\n * with no event of ours to hang a repaint on). */\r\nexport function refreshSystemTheme(): void {\r\n adoptHostScheme()\r\n invalidateHostPalette()\r\n applyCustomTokens(rOps())\r\n}\r\n\r\n// Coalesce slider-driven token updates to one rAF: a single drag fires several\r\n// input events per frame, and every full re-apply repaints expensive regions\r\n// over a large wallpaper. Batching keeps at most one update per frame.\r\nlet pendingOps: PartOpacities | null = null\r\nlet tokensRaf: number | null = null\r\n\r\nexport function applyCustomTokens(ops: PartOpacities): void {\r\n pendingOps = ops\r\n if (tokensRaf !== null) return\r\n tokensRaf = requestAnimationFrame(() => {\r\n tokensRaf = null\r\n if (pendingOps === null) return\r\n const o = pendingOps\r\n pendingOps = null\r\n applyCustomTokensNow(o)\r\n })\r\n}\r\n\r\n// Only the main-bg slider retints the center/details columns; keys on\r\n// baseTokenKey + ops.bg so a sidebar/card/input drag never rewrites them.\r\nlet lastBgKey = ''\r\n\r\nfunction applyCustomTokensNow(ops: PartOpacities): void {\r\n const src = palette()\r\n if (src === null) {\r\n // Nothing to paint from: drop the token rule too, then hand every\r\n // plugin-owned surface — and the scheme flag — back to the host rather than\r\n // leaving the previous palette's values in place.\r\n clearCustomTokens()\r\n clearOwnedSurfaces()\r\n adoptHostScheme()\r\n return\r\n }\r\n const { own, tokens } = src\r\n const [h, s, l] = rColor()\r\n try {\r\n const forceDark = own && l < 0.55\r\n // The fingerprint carries the source, so switching between the two palettes\r\n // always rewrites the rule, even when the numbers happen to coincide.\r\n const key = own\r\n ? `own:${h}|${s}|${l}`\r\n : `host:${HOST_SURFACE_TOKENS.map(n => tokens[n] ?? '').join('|')}`\r\n if (key !== baseTokenKey) {\r\n // Drive the base-palette switch with a plugin-specific value so the\r\n // gradient rule never matches a host dark-mode flag; color-scheme makes\r\n // native controls (select popups) follow the forced palette. Both ride the\r\n // stylesheet (not inline styles) so the host presenter clearing body\r\n // inline styles on boot can't drop them, and the !important rule survives\r\n // that clearing too.\r\n if (own) {\r\n if (forceDark) document.body.setAttribute(DARK_ATTR, OWN_SCHEME)\r\n else document.body.removeAttribute(DARK_ATTR)\r\n } else {\r\n adoptHostScheme()\r\n }\r\n const decls: string[] = own ? [`color-scheme:${forceDark ? 'dark' : 'light'}`] : []\r\n for (const [name, value] of Object.entries(tokens)) {\r\n const opVar = OPACITY_VARS[name]\r\n decls.push(`${name}:${opVar !== undefined ? `var(${opVar})` : value}!important`)\r\n }\r\n ensureTokenStyle().textContent = `body{${decls.join(';')}}`\r\n if (own) {\r\n // Drop inline tokens left by earlier builds so the stylesheet is the single source of truth.\r\n for (const name of appliedTokenNames) document.body.style.removeProperty(name)\r\n appliedTokenNames = Object.keys(tokens)\r\n }\r\n // Recorded only once the rule is in: a write that threw must be retried by\r\n // the next apply instead of being skipped by this fingerprint forever.\r\n baseTokenKey = key\r\n }\r\n // Cheap per-drag update: only the surface alpha vars move on <html>.\r\n const root = document.documentElement\r\n for (const g of OPACITY_TOKEN_GROUPS) {\r\n for (const name of g.names) {\r\n root.style.setProperty(OPACITY_VARS[name], withAlpha(tokens[name] ?? '#000', ops[g.part]))\r\n }\r\n }\r\n // The Cordis panel keeps its own input-slider alpha (see INPUT_BLUR_RULE).\r\n root.style.setProperty('--dsh-any-op-menu-cordis', withAlpha(tokens['--dsw-specific-menu'] ?? '#000', ops.input))\r\n const bgKey = `${baseTokenKey}|${ops.bg}`\r\n if (bgKey !== lastBgKey) { lastBgKey = bgKey; applyPartOpacities(ops) }\r\n } catch {\r\n // ignore\r\n }\r\n}\r\n\r\n// ── Settings panel opacity ─────────────────────────────────────────────────────\r\n// The settings modal is the only aria-modal dialog identifying itself with\r\n// aria-labelledby, so this selector scopes translucency to the settings panel.\r\n// The surface (--dsw-alias-bg-layer-2) is re-emitted with an alpha through a\r\n// plugin-owned variable so the panel keeps its color while fading.\r\n\r\nconst SETTINGS_PANEL_SEL = '[role=\"dialog\"][aria-modal=\"true\"][aria-labelledby]'\r\nexport const SETTINGS_STYLE_RULE =\r\n `${SETTINGS_PANEL_SEL}{` +\r\n `background:var(--dsh-any-bg-settings-surface,var(--dsw-alias-bg-layer-2));` +\r\n `backdrop-filter:var(--dsh-any-blur-settings,none);` +\r\n `}` +\r\n // Re-scope the dialog's layer tokens to plugin-owned variables so every\r\n // surface inside the dialog follows the settings opacity slider only. Gated on\r\n // the plugin owning a palette (see THEMED_ATTR): these three declarations have\r\n // no host fallback, so they may only be live while `applySettingsOverrides`\r\n // writes the variables they read.\r\n `html[${THEMED_ATTR}] ${SETTINGS_PANEL_SEL}{` +\r\n `--dsw-alias-bg-layer-1:var(--dsh-any-bg-settings-layer-1);` +\r\n `--dsw-alias-bg-layer-2:var(--dsh-any-bg-settings-layer-2);` +\r\n `--dsw-alias-bg-layer-3:var(--dsh-any-bg-settings-layer-3)}` +\r\n // Option-panel blur inside the dialog, owned by the card blur slider.\r\n `${SETTINGS_PANEL_SEL} .dab-card{backdrop-filter:var(--dsh-any-blur-card-panels,none);-webkit-backdrop-filter:var(--dsh-any-blur-card-panels,none)}`\r\n\r\n// Input/control surface blur. The composer card and the Cordis panel expose\r\n// stable host data attributes ([data-composer-card], [data-cordis-panel]), so\r\n// the backdrop is attached via a stylesheet rule rather than element discovery.\r\n// The Cordis panel shares the --dsw-specific-menu token with the dialog's\r\n// option boxes, but it stays owned by the input slider — the re-scope below\r\n// keeps it there now that the menu token itself follows the card slider. Note\r\n// the input slider must NOT drive the button-elevated-fill /\r\n// button-floating-hover tokens: the settings panel's own controls (slider\r\n// thumbs, .dab-btn, segmented thumb) are painted from those same tokens, so\r\n// tinting them would bleach the panel's own UI.\r\nexport const INPUT_BLUR_RULE =\r\n '[data-composer-card],[data-cordis-panel]{' +\r\n '-webkit-backdrop-filter:var(--dsh-any-input-blur,none);' +\r\n 'backdrop-filter:var(--dsh-any-input-blur,none)}' +\r\n '[data-cordis-panel]{--dsw-specific-menu:var(--dsh-any-op-menu-cordis)!important}'\r\n\r\nfunction applyInputBlur(px: number): void {\r\n if (px > 0) document.documentElement.style.setProperty('--dsh-any-input-blur', `blur(${px}px)`)\r\n else document.documentElement.style.removeProperty('--dsh-any-input-blur')\r\n}\r\n\r\n// Placeholder/hint text inside the composer and the plugin's own input\r\n// surfaces: rendered with the weak caption token (distinct from real input)\r\n// plus italic, so an empty box is never mistaken for typed content.\r\nexport const PLACEHOLDER_RULE =\r\n '[data-composer-card] textarea::placeholder,' +\r\n '[data-composer-card] input::placeholder,' +\r\n '[data-composer-card] [contenteditable]::placeholder,' +\r\n '[data-cordis-panel] input::placeholder,' +\r\n '[data-cordis-panel] textarea::placeholder,' +\r\n '.dab-input::placeholder,' +\r\n '.dab-input textarea::placeholder,' +\r\n '.dab-input input::placeholder' +\r\n '{color:var(--dsh-any-placeholder,var(--dsw-alias-label-caption,#8a8f98))!important;font-style:italic;opacity:.85}'\r\n\r\nexport function applySettingsOverrides(op: number): void {\r\n // Follows whichever palette is in force: the rule's own tokens, or the host's\r\n // own surfaces while the rule follows the system theme. A token the palette\r\n // does not carry has its variable REMOVED — leaving the previous color's value\r\n // behind is exactly the stale surface this used to show.\r\n const tokens = palette()?.tokens ?? {}\r\n const root = document.documentElement\r\n const write = (name: string, token: string): void => {\r\n const value = tokens[token]\r\n if (value === undefined) root.style.removeProperty(name)\r\n else root.style.setProperty(name, withAlpha(value, op))\r\n }\r\n // Always written explicitly (including 100%) — removing them would make\r\n // SETTINGS_STYLE_RULE fall back to the body layer tokens that\r\n // applyCustomTokens rewrites with the homepage card alpha.\r\n write('--dsh-any-bg-settings-surface', '--dsw-alias-bg-layer-2')\r\n // Dialog-scoped layer overrides consumed by SETTINGS_STYLE_RULE; opacity\r\n // follows the settings slider only (the card slider reaches panels via blur).\r\n write('--dsh-any-bg-settings-layer-1', '--dsw-alias-bg-layer-1')\r\n write('--dsh-any-bg-settings-layer-2', '--dsw-alias-bg-layer-2')\r\n write('--dsh-any-bg-settings-layer-3', '--dsw-alias-bg-layer-3')\r\n}\r\n\r\n// ── Trajectory view opacity ──────────────────────────────────────────────\r\n// The trajectory view's own panels fully cover the root, so retinting only the\r\n// root background is invisible. Re-scope the view root's layer tokens to\r\n// plugin-owned variables so every surface follows the trajectory slider.\r\nexport const TRAJECTORY_STYLE_RULE =\r\n // Gated like the settings re-scope: see THEMED_ATTR.\r\n `html[${THEMED_ATTR}] [data-conversation-composer-overlay]{` +\r\n // No fallback inside var(): a self-referential fallback would be a cycle.\r\n '--dsw-alias-bg-layer-1:var(--dsh-any-traj-layer-1);' +\r\n '--dsw-alias-bg-layer-2:var(--dsh-any-traj-layer-2);' +\r\n '--dsw-alias-bg-layer-3:var(--dsh-any-traj-layer-3)}'\r\n\r\nexport function applyTrajectoryOverrides(op: number): void {\r\n // Always written explicitly so the view stays owned by this slider at 100%,\r\n // and removed per token the palette lacks (see applySettingsOverrides).\r\n const tokens = palette()?.tokens ?? {}\r\n const root = document.documentElement\r\n const write = (name: string, token: string): void => {\r\n const value = tokens[token]\r\n if (value === undefined) root.style.removeProperty(name)\r\n else root.style.setProperty(name, withAlpha(value, op))\r\n }\r\n write('--dsh-any-traj-layer-1', '--dsw-alias-bg-layer-1')\r\n write('--dsh-any-traj-layer-2', '--dsw-alias-bg-layer-2')\r\n write('--dsh-any-traj-layer-3', '--dsw-alias-bg-layer-3')\r\n}\r\n\r\n// ── File-preview panel (right sidebar) ────────────────────────────────────\r\n// Clicking a file opens the host's right panel, whose visible surface is painted\r\n// from `background: var(--dsw-alias-bg-base)` — the exact token the\r\n// main-background slider re-emits with its own alpha. The panel was therefore a\r\n// second, unnamed copy of the main background with no control of its own; this\r\n// card takes it over, on whichever element the host paints that surface.\r\n//\r\n// dsh 0.1.7 moved the paint off the panel: the container lost its background and\r\n// became the slide / fullscreen viewport, and it stays mounted at its full width\r\n// for the whole session — collapsing it only slides the dock out (`transform` +\r\n// `visibility`, never `display`). A surface (plus a backdrop-filter) written on\r\n// that container therefore covers the empty right half of the frame even with\r\n// the panel closed, which is the permanent frosted plate 0.1.7 shows. The dock's\r\n// own tab hosts are what the host paints now, so the card follows them:\r\n//\r\n// 0.1.7+ the dock's tab hosts — `[data-dockkit-content]` (and the\r\n// `[data-dockkit-empty]` seat of an empty pane), painted by the host\r\n// from the same token and hidden with `visibility`, so the card rides\r\n// the host's own open/close and slide transitions for free. Floating\r\n// panes are excluded exactly as the host excludes them.\r\n// older the panel itself, which used to carry that background on its hashed\r\n// class. `:has()` keeps the two apart, so the alpha is never painted\r\n// twice over on a 0.1.7 host.\r\n//\r\n// The selectors use data attributes (not the hashed CSS-module classes) and\r\n// `!important` outranks the host's class rule. The `var()` fallback keeps the\r\n// host's own value until a rule with a color supplies one, so a color-less rule\r\n// changes nothing here.\r\n//\r\n// backdrop-filter stays on the container — that is where this card has always\r\n// put it, and it keeps the panel to a single filter pass — but only while the\r\n// panel is open: an always-on filter is what turned the collapsed panel into a\r\n// plate.\r\nexport const RIGHTBAR_STYLE_RULE =\r\n 'div[data-sidebar-right-panel]:not(:has([data-dockkit-content],[data-dockkit-empty]))[data-sidebar-right-open],' +\r\n 'div[data-sidebar-right-panel] [data-dockkit-content]:not([data-dockkit-float]),' +\r\n 'div[data-sidebar-right-panel] [data-dockkit-empty]{' +\r\n 'background:var(--dsh-any-bg-rightbar,var(--dsw-alias-bg-base))!important}' +\r\n 'div[data-sidebar-right-panel][data-sidebar-right-open]{' +\r\n '-webkit-backdrop-filter:var(--dsh-any-blur-rightbar,none);' +\r\n 'backdrop-filter:var(--dsh-any-blur-rightbar,none)}'\r\n\r\n/** Paint the file-preview panel's surface from its own slider. */\r\nexport function applyRightbarOverrides(op: number): void {\r\n const root = document.documentElement\r\n // The panel is painted from the palette in force like every other surface;\r\n // only when there is no palette at all (a host publishing none of the tokens\r\n // we re-emit) does it keep the host's own --dsw-alias-bg-base.\r\n const base = palette()?.tokens['--dsw-alias-bg-base']\r\n if (base === undefined) { root.style.removeProperty('--dsh-any-bg-rightbar'); return }\r\n root.style.setProperty('--dsh-any-bg-rightbar', withAlpha(base, op))\r\n}\r\n\r\n/** Extra backdrop frost for the file-preview panel (0 = no frost of its own). */\r\nfunction applyRightbarBlur(px: number): void {\r\n if (px > 0) document.documentElement.style.setProperty('--dsh-any-blur-rightbar', `blur(${px}px)`)\r\n else document.documentElement.style.removeProperty('--dsh-any-blur-rightbar')\r\n}\r\n\r\n// ── Per-part interface blur ───────────────────────────────────────────────────\r\n// The AppFrame columns use hashed CSS-module classes, so parts are located\r\n// structurally: the shell overlay carries a stable data attribute and the\r\n// sidebar/center/details columns are its three preceding siblings.\r\n//\r\n// backdrop-filter must NEVER go directly on a host part: it turns the element\r\n// into a containing block for fixed-positioned descendants, which would trap\r\n// the host's settings dialog inside the column. Each blurred part carries an\r\n// isolated ::before underlay holding the backdrop-filter instead.\r\nlet frameEl: HTMLElement | null = null\r\nlet sidebarEl: HTMLElement | null = null\r\nlet centerEl: HTMLElement | null = null\r\nlet detailsEl: HTMLElement | null = null\r\n\r\nconst PART_BLUR_CLASS = 'dab-part-blur'\r\nconst PART_UNDERLAY_CLASS = 'dab-part-underlay'\r\nconst PART_BLUR_RULE =\r\n `${PART_BLUR_CLASS}{isolation:isolate}` +\r\n `.${PART_UNDERLAY_CLASS}{position:absolute;inset:0;z-index:-1;pointer-events:none;border-radius:inherit;` +\r\n `backdrop-filter:var(--dsh-any-part-blur,none);-webkit-backdrop-filter:var(--dsh-any-part-blur,none)}`\r\n\r\nlet partBlurStyleEl: HTMLStyleElement | null = null\r\n\r\nfunction ensurePartBlurStyle(): void {\r\n if (partBlurStyleEl?.isConnected) return\r\n partBlurStyleEl = document.createElement('style')\r\n partBlurStyleEl.dataset.plugin = 'dsh-background-by-model-parts'\r\n markOwnSheet(partBlurStyleEl)\r\n partBlurStyleEl.textContent = PART_BLUR_RULE\r\n document.head.appendChild(partBlurStyleEl)\r\n}\r\n\r\nfunction discoverParts(): void {\r\n const overlay = document.querySelector<HTMLElement>('[data-shell-overlay]')\r\n if (overlay === null) return\r\n const frame = overlay.parentElement\r\n if (frame === null) return\r\n frameEl = frame\r\n const idx = Array.from(frame.children).indexOf(overlay)\r\n sidebarEl = (frame.children[idx - 3] as HTMLElement | undefined) ?? null\r\n centerEl = (frame.children[idx - 2] as HTMLElement | undefined) ?? null\r\n detailsEl = (frame.children[idx - 1] as HTMLElement | undefined) ?? null\r\n}\r\n\r\nfunction setBlur(el: HTMLElement | null, px: number): void {\r\n if (el === null) return\r\n const underlay = el.querySelector<HTMLDivElement>(`:scope > .${PART_UNDERLAY_CLASS}`)\r\n if (px > 0) {\r\n ensurePartBlurStyle()\r\n // The underlay is position:absolute and needs a positioned host: static\r\n // columns get relative (a layout no-op for flex items) that is restored on\r\n // clear; parts the host already positions keep their own scheme.\r\n if (!el.classList.contains(PART_BLUR_CLASS) && getComputedStyle(el).position === 'static') {\r\n el.style.position = 'relative'\r\n el.setAttribute('data-dab-pos-patched', '1')\r\n }\r\n el.classList.add(PART_BLUR_CLASS)\r\n if (underlay === null) {\r\n const node = document.createElement('div')\r\n node.className = PART_UNDERLAY_CLASS\r\n el.prepend(node)\r\n }\r\n el.style.setProperty('--dsh-any-part-blur', `blur(${px}px)`)\r\n } else {\r\n el.classList.remove(PART_BLUR_CLASS)\r\n el.style.removeProperty('--dsh-any-part-blur')\r\n underlay?.remove()\r\n if (el.getAttribute('data-dab-pos-patched') === '1') {\r\n el.style.removeProperty('position')\r\n el.removeAttribute('data-dab-pos-patched')\r\n }\r\n }\r\n}\r\n\r\nfunction applySettingsBlur(px: number): void {\r\n if (px > 0) document.documentElement.style.setProperty('--dsh-any-blur-settings', `blur(${px}px)`)\r\n else document.documentElement.style.removeProperty('--dsh-any-blur-settings')\r\n}\r\n\r\n/** Apply the main-background opacity to the center/details columns instead of\r\n * the frame. The frame's translucent bg-base sits UNDER the sidebar, so\r\n * reducing the main-bg opacity stacked a second alpha onto the sidebar; moving\r\n * the alpha onto the columns keeps the sidebar owned by its own slider. */\r\nfunction applyPartOpacities(ops: PartOpacities): void {\r\n discoverParts()\r\n if (frameEl === null) return\r\n const base = palette()?.tokens['--dsw-alias-bg-base']\r\n if (base === undefined) {\r\n // No palette to paint from: hand the columns back to the host instead of\r\n // leaving the last color's inline background on them.\r\n for (const el of [frameEl, centerEl, detailsEl]) el?.style.removeProperty('background')\r\n return\r\n }\r\n frameEl.style.background = 'transparent'\r\n if (centerEl !== null) centerEl.style.background = withAlpha(base, ops.bg)\r\n if (detailsEl !== null) detailsEl.style.background = withAlpha(base, ops.bg)\r\n}\r\n\r\n/** Blur of the option panels inside the settings dialog (.dab-card), owned by\r\n * the \"dialog option panel\" (card) blur slider. Written as a plugin-owned\r\n * variable consumed by SETTINGS_STYLE_RULE — deliberately NOT applied to the\r\n * homepage center/details columns, which this slider must never touch. */\r\nfunction applyCardPanelsBlur(px: number): void {\r\n if (px > 0) document.documentElement.style.setProperty('--dsh-any-blur-card-panels', `blur(${px}px)`)\r\n else document.documentElement.style.removeProperty('--dsh-any-blur-card-panels')\r\n}\r\n\r\n/** Apply per-part interface blur to the AppFrame columns + settings panel. */\r\nexport function applyPartBlurs(blurs: PartBlurs): void {\r\n discoverParts()\r\n // The bg blur frosts the wallpaper behind the main content columns (center +\r\n // details); the frame itself stays unblurred so the sidebar is never\r\n // double-frosted by both the bg and sidebar sliders.\r\n setBlur(frameEl, 0)\r\n setBlur(sidebarEl, blurs.sidebar)\r\n setBlur(centerEl, blurs.bg)\r\n setBlur(detailsEl, blurs.bg)\r\n applyCardPanelsBlur(blurs.card)\r\n applySettingsBlur(blurs.settings)\r\n applyInputBlur(blurs.input)\r\n applyRightbarBlur(blurs.rightbar)\r\n applyViewCards()\r\n}\r\n\r\n/** Live per-part blur update during slider drag (no full re-apply). */\r\nexport function setPartBlur(part: keyof PartBlurs, v: number): void {\r\n if (part === 'settings') { applySettingsBlur(v); return }\r\n if (part === 'card') { applyCardPanelsBlur(v); return }\r\n if (part === 'input') { applyInputBlur(v); return }\r\n if (part === 'rightbar') { applyRightbarBlur(v); return }\r\n if (part === 'chat' || part === 'trajectory') { applyViewCards(); return }\r\n discoverParts()\r\n if (part === 'bg') { setBlur(centerEl, v); setBlur(detailsEl, v) }\r\n else setBlur(sidebarEl, v)\r\n}\r\n\r\n// ── Conversation view treatments ────────────────────────────────────\r\n// The chat message column is styled as a real card (layer-1 surface + border +\r\n// 16px radius + 18px padding); the trajectory view gets NO card decoration —\r\n// its own panels fully cover the view root, so its opacity slider re-scopes the\r\n// layer tokens inside the view and its blur frosts the backdrop through the\r\n// standard root underlay.\r\n//\r\n// Host structure (deepseek-harness ui-conversation / ui-trajectory):\r\n// ConversationRoot\r\n// header — title + tabs, OUTSIDE the scrollport\r\n// [data-conversation-scroll] — the single scrollport\r\n// [data-chat-flow] ← chat column (flow content, NOT scrollable)\r\n// [data-conversation-composer-overlay] ← trajectory view root\r\n// [data-composer-seat] — sticky composer, a sibling\r\n// Cards are ALWAYS styled once their host exists — sliders at zero only turn\r\n// surface/border transparent, so the layout never reflows and the view cannot\r\n// jump when a slider leaves zero. Removal happens only at plugin teardown.\r\ninterface ViewCardSpec {\r\n sel: string\r\n mark: string\r\n /** Dataset key prefix holding the stashed pre-card inline values. */\r\n prev: string\r\n opacity: () => number\r\n blur: () => number\r\n /** Generic heuristic fallback (chat card only, hosts without the marker). */\r\n fallback?: boolean\r\n /** No card decoration — surfaces follow scoped layer tokens; only the blur\r\n * underlay is attached to the host element. */\r\n plain?: boolean\r\n}\r\n\r\nconst VIEW_CARDS: ViewCardSpec[] = [\r\n { sel: '[data-chat-flow]', mark: 'data-dab-chat-card', prev: 'dabChatPrev', opacity: rChatTextOpacity, blur: () => rBlurs().chat, fallback: true },\r\n { sel: '[data-conversation-composer-overlay]', mark: 'data-dab-traj-card', prev: 'dabTrajPrev', opacity: rTrajectoryOpacity, blur: () => rBlurs().trajectory, plain: true },\r\n]\r\n\r\nconst viewTargets: Array<HTMLElement | null> = VIEW_CARDS.map(() => null)\r\n\r\nfunction isScrollableY(el: HTMLElement): boolean {\r\n const oy = getComputedStyle(el).overflowY\r\n // 'overlay' covers Chromium's non-standard overflow value.\r\n return oy === 'auto' || oy === 'scroll' || oy === 'overlay'\r\n}\r\n\r\n/** Whether the subtree hosts the chat input (textarea / contenteditable /\r\n * textbox role) — used to keep the card off the input row. */\r\nfunction containsChatEditor(el: HTMLElement): boolean {\r\n return el.querySelector('textarea,[contenteditable=\"true\"],[contenteditable=\"\"],[contenteditable=\"plaintext-only\"],[role=\"textbox\"]') !== null\r\n}\r\n\r\n/** Walk down from a coarse candidate toward the actual message column. */\r\nfunction refineMessageColumn(start: HTMLElement): HTMLElement {\r\n let cur = start\r\n for (let depth = 0; depth < 10; depth++) {\r\n if (isScrollableY(cur)) break\r\n const kids = Array.from(cur.children).filter((k): k is HTMLElement => k instanceof HTMLElement)\r\n if (kids.length === 0) break\r\n const tallest = kids.reduce((a, b) => (b.clientHeight > a.clientHeight ? b : a))\r\n if (containsChatEditor(cur)) {\r\n const candidates = kids.filter(k => !containsChatEditor(k) && k.clientHeight >= cur.clientHeight * 0.4)\r\n if (candidates.length === 0) break\r\n cur = candidates.reduce((a, b) => (b.clientHeight > a.clientHeight ? b : a))\r\n continue\r\n }\r\n if (kids.length > 1 && tallest.clientHeight >= cur.clientHeight * 0.85) { cur = tallest; continue }\r\n break\r\n }\r\n return cur\r\n}\r\n\r\nfunction discoverViewTarget(idx: number, spec: ViewCardSpec): HTMLElement | null {\r\n if (centerEl === null || !document.body.contains(centerEl)) { viewTargets[idx] = null; return null }\r\n // The host marker always wins over a cached fallback (the view may not be\r\n // mounted yet when the plugin applies early).\r\n const marked = centerEl.querySelector<HTMLElement>(spec.sel)\r\n const cached = viewTargets[idx]\r\n if (marked !== null) {\r\n if (cached !== null && cached !== marked) { setBlur(cached, 0); restoreCardHost(cached, spec.mark, spec.prev, spec.plain === true) }\r\n viewTargets[idx] = marked\r\n return marked\r\n }\r\n if (cached !== null && centerEl.contains(cached)) return cached\r\n viewTargets[idx] = null\r\n if (spec.fallback !== true) return null\r\n // On the harness, an absent [data-chat-flow] just means the chat view is not\r\n // mounted (hero phase, trajectory tab) — settling on the whole scrollport\r\n // there would wrap the entire page in the card.\r\n if (centerEl.querySelector('[data-conversation-scroll]') !== null) return null\r\n // Marker-less hosts keep their layout until a slider moves.\r\n if (spec.opacity() <= 0 && spec.blur() <= 0) return null\r\n let best: HTMLElement | null = null\r\n let bestArea = 0\r\n for (const el of Array.from(centerEl.querySelectorAll<HTMLElement>('*'))) {\r\n if (!isScrollableY(el)) continue\r\n if (el.clientHeight < centerEl.clientHeight * 0.35) continue\r\n const area = el.clientWidth * el.clientHeight\r\n if (area > bestArea) { bestArea = area; best = el }\r\n }\r\n if (best === null) {\r\n for (const el of Array.from(centerEl.children)) {\r\n if (!(el instanceof HTMLElement)) continue\r\n if (el.clientHeight < centerEl.clientHeight * 0.5) continue\r\n if (el.clientHeight > (best?.clientHeight ?? 0)) best = el\r\n }\r\n }\r\n const refined = best !== null ? refineMessageColumn(best) : null\r\n viewTargets[idx] = refined\r\n return refined\r\n}\r\n\r\n/** Stash the host's own inline values so teardown restores them exactly. */\r\nfunction stashCardPrev(el: HTMLElement, prev: string, plain: boolean): void {\r\n const ds = el.dataset as Record<string, string | undefined>\r\n ds[prev + 'Bg'] = el.style.getPropertyValue('background')\r\n if (plain) return\r\n ds[prev + 'Border'] = el.style.getPropertyValue('border')\r\n ds[prev + 'Radius'] = el.style.getPropertyValue('border-radius')\r\n ds[prev + 'Padding'] = el.style.getPropertyValue('padding')\r\n}\r\n\r\n/** Undo the inline styling, restoring the host's previous inline values. */\r\nfunction restoreCardHost(el: HTMLElement, mark: string, prev: string, plain: boolean): void {\r\n if (!el.hasAttribute(mark)) return\r\n const ds = el.dataset as Record<string, string | undefined>\r\n const restore = (prop: string, v: string | undefined): void => {\r\n if (v !== undefined && v !== '') el.style.setProperty(prop, v)\r\n else el.style.removeProperty(prop)\r\n }\r\n restore('background', ds[prev + 'Bg'])\r\n if (!plain) {\r\n restore('border', ds[prev + 'Border'])\r\n restore('border-radius', ds[prev + 'Radius'])\r\n restore('padding', ds[prev + 'Padding'])\r\n delete ds[prev + 'Border']; delete ds[prev + 'Radius']; delete ds[prev + 'Padding']\r\n }\r\n delete ds[prev + 'Bg']\r\n el.removeAttribute(mark)\r\n}\r\n\r\n/** Teardown only: strip every view treatment and hand the hosts back untouched. */\r\nfunction removeViewCards(): void {\r\n VIEW_CARDS.forEach((spec, i) => {\r\n const el = viewTargets[i]\r\n if (el !== null) { setBlur(el, 0); restoreCardHost(el, spec.mark, spec.prev, spec.plain === true) }\r\n viewTargets[i] = null\r\n })\r\n}\r\n\r\n// ── Wide markdown tables ──────────────────────────────────────────────────────\r\n// DSH intentionally lets `.md-table-wide` bleed outside the text column. That\r\n// bleed only becomes visible once the chat surface gains a visible border, i.e.\r\n// when the chat region opacity or blur is non-zero. Under that same condition,\r\n// pull the table back inside the column and let it scroll horizontally.\r\nconst TABLE_FIX_RULE = [\r\n '.md-table-wide {',\r\n ' --dsh-table-spare: 0px !important;',\r\n ' --dsh-table-lead: 0px !important;',\r\n ' box-sizing: border-box !important;',\r\n ' width: 100% !important;',\r\n ' max-width: 100% !important;',\r\n ' margin-left: 0 !important;',\r\n ' padding-left: 0 !important;',\r\n ' padding-bottom: 0 !important;',\r\n ' overflow-x: auto !important;',\r\n '}',\r\n].join('\\n')\r\nlet tableFixStyleEl: HTMLStyleElement | null = null\r\n\r\n/** Toggle the wide-table clamp according to the chat region's opacity & blur. */\r\nfunction syncTableFix(): void {\r\n const needed = rChatTextOpacity() > 0 || rBlurs().chat > 0\r\n if (!needed) {\r\n if (tableFixStyleEl !== null) { tableFixStyleEl.remove(); tableFixStyleEl = null }\r\n return\r\n }\r\n if (tableFixStyleEl === null) {\r\n tableFixStyleEl = document.createElement('style')\r\n tableFixStyleEl.dataset.plugin = 'dsh-background-by-model-table-fix'\r\n markOwnSheet(tableFixStyleEl)\r\n tableFixStyleEl.textContent = TABLE_FIX_RULE\r\n }\r\n if (!tableFixStyleEl.isConnected) document.head.appendChild(tableFixStyleEl)\r\n}\r\n\r\n/** Re-derive the conversation view cards from the current config. */\r\nexport function applyViewCards(): void {\r\n discoverParts()\r\n if (centerEl === null) return\r\n // The chat card is tinted from the palette in force, so a color-less rule gets\r\n // the host's own surface instead of the seed color's fallback tint.\r\n const surface = palette()?.tokens['--dsw-alias-bg-layer-1']\r\n VIEW_CARDS.forEach((spec, i) => {\r\n const target = discoverViewTarget(i, spec)\r\n if (target === null) return\r\n const plain = spec.plain === true\r\n const opacity = spec.opacity()\r\n const blurPx = spec.blur()\r\n if (!plain) {\r\n if (!target.hasAttribute(spec.mark)) stashCardPrev(target, spec.prev, false)\r\n // Mirrors .dab-card (layer-1 background, border, 16px radius, 18px\r\n // padding), written inline so it wins over host stylesheets; the opacity\r\n // slider drives surface alpha and fades the border with it.\r\n const borderAlpha = opacity > 0 ? Math.min(1, opacity * 1.5) : (blurPx > 0 ? 0.35 : 0)\r\n target.style.background = surface !== undefined ? withAlpha(surface, opacity) : 'transparent'\r\n target.style.border = surface !== undefined ? `1px solid ${withAlpha(surface, borderAlpha)}` : '1px solid transparent'\r\n target.style.borderRadius = '16px'\r\n target.style.padding = '18px'\r\n }\r\n // Plain views write no inline styles — only the blur underlay is hosted here.\r\n target.setAttribute(spec.mark, '1')\r\n setBlur(target, blurPx)\r\n })\r\n syncTableFix()\r\n}\r\n\r\nlet partsObserver: MutationObserver | null = null\r\n\r\n/** Watch for the AppFrame mounting so persisted blurs land even when the shell\r\n * renders after this plugin's apply. */\r\nexport function watchParts(): void {\r\n if (partsObserver !== null || typeof MutationObserver === 'undefined') return\r\n partsObserver = new MutationObserver(() => {\r\n if (frameEl !== null && sidebarEl !== null && centerEl !== null && detailsEl !== null && document.body.contains(frameEl)\r\n // Keep re-applying while any card host is absent or was swapped by the host.\r\n && viewTargets.every(el => el !== null && document.body.contains(el))) return\r\n applyPartBlurs(rBlurs())\r\n applyPartOpacities(rOps())\r\n })\r\n partsObserver.observe(document.body, { childList: true, subtree: true })\r\n}\r\n\r\nexport function stopWatchingParts(): void {\r\n partsObserver?.disconnect()\r\n partsObserver = null\r\n}\r\n\r\n// ── Theme-reset watchdog ──────────────────────────────────────────────────\r\n// The host re-asserts its own :root/body scheme rules on mount, on settings\r\n// adoption and after the plugin's startup assertion, toggling the\r\n// `data-ds-dark-theme` attribute off / to a host value — which would paint a\r\n// frame of light surfaces. Watch that flag and, whenever the plugin's own\r\n// value disappears, re-set it and re-emit the token stylesheet within the same\r\n// frame.\r\nlet themeObserver: MutationObserver | null = null\r\nlet themeRaf = 0\r\n\r\nfunction reassertScheme(): void {\r\n const [, , l] = rColor()\r\n if (l < 0.55) document.body.setAttribute(DARK_ATTR, OWN_SCHEME)\r\n else document.body.removeAttribute(DARK_ATTR)\r\n applyCustomTokens(rOps())\r\n}\r\n\r\n/** Re-assert the plugin's forced scheme whenever the host strips it, so a\r\n * refresh / cold-load / set-change never flashes a light frame. Also the point\r\n * where a host-side scheme flip is noticed while a color-less rule runs: that\r\n * rule paints from the host palette, so the readback is dropped and the\r\n * surfaces are re-emitted from the new one. */\r\nexport function watchThemeResets(): () => void {\r\n if (themeObserver !== null || typeof MutationObserver === 'undefined') return () => undefined\r\n themeObserver = new MutationObserver(() => {\r\n invalidateHostPalette()\r\n if (document.body.getAttribute(DARK_ATTR) === OWN_SCHEME) return\r\n if (!rHasColor()) {\r\n // Nothing to re-assert, but the host's own surfaces just changed under us.\r\n applyCustomTokens(rOps())\r\n return\r\n }\r\n if (themeRaf !== 0) return\r\n themeRaf = requestAnimationFrame(() => {\r\n themeRaf = 0\r\n if (document.body.getAttribute(DARK_ATTR) === OWN_SCHEME) return\r\n reassertScheme()\r\n })\r\n })\r\n themeObserver.observe(document.body, { attributes: true, attributeFilter: [DARK_ATTR] })\r\n themeObserver.observe(document.documentElement, { attributes: true, attributeFilter: [DARK_ATTR] })\r\n return () => {\r\n themeObserver?.disconnect()\r\n themeObserver = null\r\n }\r\n}\r\n\r\n// ── Wallpaper layer: two stacked layers, cross-faded on a rule switch ───────\r\n// The incoming image fades in ON TOP of the outgoing one at full opacity.\r\n// Fading the old one out at the same time would drop the composite below full\r\n// alpha at the midpoint — both images half transparent — and the interface\r\n// behind would flash through.\r\n//\r\n// A layer addresses its image by OBJECT URL (see displayImageOf in state):\r\n// assigning a `url(data:…)` background re-decodes the photo on every switch,\r\n// which is where a large wallpaper's stall comes from, while a blob URL is\r\n// served from the browser's memory cache after the first load.\r\nconst FADE_MS = 320\r\n\r\ninterface WpLayer {\r\n el: HTMLDivElement\r\n /** Display URL of the image painted on this layer; null when empty. */\r\n url: string | null\r\n}\r\n\r\nlet layers: [WpLayer, WpLayer] | null = null\r\n/** Index of the layer the user is looking at. */\r\nlet front = 0\r\n/** Index of the layer fading in right now, if any. */\r\nlet pending: 0 | 1 | null = null\r\nlet fadeTimer: number | null = null\r\n\r\nfunction createLayer(): WpLayer {\r\n const el = document.createElement('div')\r\n el.dataset.dabWpLayer = ''\r\n el.style.cssText = 'position:absolute;inset:0;opacity:0;background-repeat:no-repeat;background-position:center;'\r\n return { el, url: null }\r\n}\r\n\r\nfunction ensureWpContainer(): void {\r\n if (wpEl !== null && layers !== null && document.body.contains(wpEl)) return\r\n if (fadeTimer !== null) { window.clearTimeout(fadeTimer); fadeTimer = null }\r\n const a = createLayer()\r\n const b = createLayer()\r\n wpEl = document.createElement('div')\r\n wpEl.dataset.dabWp = ''\r\n wpEl.style.cssText = 'position:fixed;inset:0;z-index:-1;pointer-events:none;overflow:hidden;'\r\n wpEl.append(a.el, b.el)\r\n layers = [a, b]\r\n front = 0\r\n pending = null\r\n document.body.prepend(wpEl)\r\n}\r\n\r\n/** Drop the whole wallpaper layer (no rule carries an image). */\r\nfunction dropWpContainer(): void {\r\n if (fadeTimer !== null) { window.clearTimeout(fadeTimer); fadeTimer = null }\r\n pending = null\r\n front = 0\r\n layers = null\r\n wpEl?.remove()\r\n wpEl = null\r\n}\r\n\r\n/** Release one layer's image — the layer is fully covered when this is called. */\r\nfunction clearLayer(l: WpLayer): void {\r\n if (l.url === null) return\r\n l.url = null\r\n l.el.style.backgroundImage = ''\r\n l.el.style.backgroundSize = ''\r\n l.el.style.backgroundPosition = ''\r\n}\r\n\r\n/** Intrinsic-size cache for the center mode (native pixels of the current image). */\r\nlet imgNat: { url: string; w: number; h: number } | null = null\r\nfunction imageNatSize(url: string, cb: (w: number, h: number) => void): void {\r\n if (imgNat !== null && imgNat.url === url) { cb(imgNat.w, imgNat.h); return }\r\n const img = new Image()\r\n img.onload = () => {\r\n imgNat = { url, w: img.naturalWidth, h: img.naturalHeight }\r\n cb(img.naturalWidth, img.naturalHeight)\r\n }\r\n img.onerror = () => cb(0, 0)\r\n img.src = url\r\n}\r\n\r\n/** Paint one layer's image and its placement. The placement always follows the\r\n * ACTIVE rule: the incoming layer is painted right after a switch, and a\r\n * repaint of the same URL (framing edit, viewport resize) must use the rule's\r\n * current framing. */\r\nfunction paintLayer(l: WpLayer, url: string): void {\r\n const el = l.el\r\n l.url = url\r\n const bg = rBgState()\r\n const mode = rBgMode()\r\n const next = `url(\"${url}\")`\r\n // Skip re-setting the same URL — a redundant assignment can flash the layer\r\n // blank for a frame while it is re-resolved.\r\n if (el.style.backgroundImage !== next) {\r\n el.style.backgroundImage = next\r\n }\r\n if (mode === 'fit') {\r\n el.style.backgroundRepeat = 'no-repeat'\r\n if (bg.iw > 0) {\r\n // Contain-fit at zoom with the image center pinned to the committed\r\n // fractional viewport point, so the framed region survives viewport changes.\r\n const fit = Math.min(window.innerWidth / bg.iw, window.innerHeight / bg.ih)\r\n const w = bg.iw * fit * bg.zoom\r\n const h = bg.ih * fit * bg.zoom\r\n el.style.backgroundSize = `${w}px ${h}px`\r\n el.style.backgroundPosition = `${bg.x * window.innerWidth - w / 2}px ${bg.y * window.innerHeight - h / 2}px`\r\n } else {\r\n // Fresh image: match the editor's initial centered contain view.\r\n el.style.backgroundSize = 'contain'\r\n el.style.backgroundPosition = 'center'\r\n }\r\n } else if (mode === 'fill') {\r\n el.style.backgroundRepeat = 'no-repeat'\r\n el.style.backgroundSize = 'cover'\r\n el.style.backgroundPosition = 'center'\r\n } else if (mode === 'stretch') {\r\n el.style.backgroundRepeat = 'no-repeat'\r\n el.style.backgroundSize = '100% 100%'\r\n el.style.backgroundPosition = 'center'\r\n } else if (mode === 'tile') {\r\n el.style.backgroundRepeat = 'repeat'\r\n // background-size:auto resolves the intrinsic size per tile.\r\n el.style.backgroundSize = 'auto'\r\n el.style.backgroundPosition = '0px 0px'\r\n } else {\r\n // Center: native size, centered. The intrinsic size needs an async decode;\r\n // 'contain' keeps a sensible frame until it lands.\r\n el.style.backgroundRepeat = 'no-repeat'\r\n el.style.backgroundSize = 'contain'\r\n el.style.backgroundPosition = 'center'\r\n imageNatSize(url, (w, h) => {\r\n if (l.url !== url || el.style.backgroundImage !== next || rBgMode() !== 'center') return\r\n if (w > 0 && h > 0) {\r\n el.style.backgroundSize = `${w}px ${h}px`\r\n el.style.backgroundPosition = 'center'\r\n }\r\n })\r\n }\r\n}\r\n\r\n/** Whether a switch should animate: nothing to fade from, an invisible\r\n * wallpaper and a reduced-motion preference all switch instantly. */\r\nfunction canFade(from: WpLayer): boolean {\r\n if (from.url === null) return false\r\n if (rWop() <= 0.01) return false\r\n const mm = typeof window.matchMedia === 'function' ? window.matchMedia('(prefers-reduced-motion: reduce)') : null\r\n return mm === null || !mm.matches\r\n}\r\n\r\n/** End an in-flight fade: promote the incoming layer, free the one under it. */\r\nfunction finishFade(idx: 0 | 1): void {\r\n if (layers === null || pending !== idx) return\r\n if (fadeTimer !== null) { window.clearTimeout(fadeTimer); fadeTimer = null }\r\n pending = null\r\n front = idx\r\n const el = layers[idx].el\r\n // Re-asserted so a fade whose frames never ran (background tab) still ends on\r\n // the visible image.\r\n el.style.opacity = '1'\r\n el.style.willChange = ''\r\n // Covered from here on: drop its bytes so a second full-resolution image is\r\n // never left decoded behind the visible one.\r\n clearLayer(layers[idx === 0 ? 1 : 0])\r\n}\r\n\r\n/** Land an in-flight fade on its end state at once (another switch arrived). */\r\nfunction settleFade(): void {\r\n if (layers === null || pending === null) return\r\n const idx = pending\r\n if (fadeTimer !== null) { window.clearTimeout(fadeTimer); fadeTimer = null }\r\n pending = null\r\n front = idx\r\n const el = layers[idx].el\r\n el.style.transition = 'none'\r\n el.style.opacity = '1'\r\n el.style.willChange = ''\r\n clearLayer(layers[idx === 0 ? 1 : 0])\r\n}\r\n\r\n/** Abandon an in-flight fade: the layer it was leaving holds the wanted image. */\r\nfunction cancelFade(): void {\r\n if (layers === null || pending === null) return\r\n const idx = pending\r\n if (fadeTimer !== null) { window.clearTimeout(fadeTimer); fadeTimer = null }\r\n pending = null\r\n const el = layers[idx].el\r\n el.style.transition = 'none'\r\n el.style.opacity = '0'\r\n el.style.willChange = ''\r\n clearLayer(layers[idx])\r\n}\r\n\r\n/** Show `url` on the wallpaper layer, cross-fading from what it paints now. */\r\nfunction applyImageWp(url: string): void {\r\n ensureWpContainer()\r\n const ls = layers!\r\n if (pending !== null) {\r\n // A → B → A inside one fade: keep whichever layer already paints the wanted\r\n // image instead of queueing a third one.\r\n if (ls[pending].url === url) { paintLayer(ls[pending], url); applyWpEffects(); return }\r\n if (ls[front].url === url) { cancelFade(); paintLayer(ls[front], url); applyWpEffects(); return }\r\n settleFade()\r\n }\r\n if (ls[front].url === url) { paintLayer(ls[front], url); applyWpEffects(); return }\r\n const from = ls[front]\r\n const idx: 0 | 1 = front === 0 ? 1 : 0\r\n const target = ls[idx]\r\n const el = target.el\r\n // Rewind the incoming layer before its bytes land, so a stale image from an\r\n // earlier switch can never flash through while the new one rasterizes.\r\n el.style.transition = 'none'\r\n el.style.opacity = '0'\r\n el.style.zIndex = '1'\r\n from.el.style.zIndex = '0'\r\n paintLayer(target, url)\r\n applyWpEffects()\r\n if (!canFade(from)) {\r\n el.style.opacity = '1'\r\n front = idx\r\n clearLayer(from)\r\n return\r\n }\r\n // will-change promotes the layer in this frame, so the fade itself is a pure\r\n // compositor animation that survives the main-thread work a switch triggers\r\n // (theme re-registration, token rewrite, settings-panel re-render).\r\n el.style.willChange = 'opacity'\r\n pending = idx\r\n requestAnimationFrame(() => {\r\n if (pending !== idx || layers === null) return\r\n el.style.transition = `opacity ${FADE_MS}ms ease`\r\n el.style.opacity = '1'\r\n })\r\n fadeTimer = window.setTimeout(() => finishFade(idx), FADE_MS + 160)\r\n}\r\n\r\nfunction applyWpEffects(): void {\r\n if (wpEl === null || layers === null) return\r\n wpEl.style.opacity = String(rWop())\r\n // The blur sits on each LAYER rather than on the container: with the filter on\r\n // the parent, every frame of an opacity fade would re-run a full-screen blur\r\n // instead of just re-compositing the blurred surface.\r\n const blur = rBl()\r\n const filter = blur > 0 ? `blur(${blur}px)` : ''\r\n layers[0].el.style.filter = filter\r\n layers[1].el.style.filter = filter\r\n}\r\n\r\n/** Repaint the wallpaper layer, the token palette and every interface part from\r\n * the ACTIVE rule. This is the single entry point a rule switch goes through. */\r\nexport function applyWp(): void {\r\n const url = rWp()\r\n if (url) {\r\n applyImageWp(url)\r\n } else if (wpEl !== null) {\r\n // No background: tear down the layer but keep tokens/blur intact.\r\n dropWpContainer()\r\n }\r\n // A rule without a saved color follows the system theme: the plugin owns no\r\n // color of its own, so the surfaces come from the host's palette (see\r\n // `palette`) with the user's opacities applied — the wallpaper keeps showing\r\n // and the Interface sliders keep doing something, which is what \"follow the\r\n // system theme\" is expected to mean. THREE things have to be true before the\r\n // readback, or it answers with the wrong palette:\r\n // 1. our own body rule is out of the way (it re-emits the tokens being read);\r\n // 2. the scheme flag is the host's own again (we force/remove it while we own\r\n // a palette, and the host only re-projects on a theme change);\r\n // 3. the cached palette is dropped once, on the way in.\r\n if (!rHasColor() && !baseTokenKey.startsWith('host:')) {\r\n clearCustomTokens()\r\n invalidateHostPalette()\r\n }\r\n if (!rHasColor()) adoptHostScheme()\r\n const src = palette()\r\n // Marker for the no-fallback re-scope rules: they may only be live while the\r\n // variables they read are written (see THEMED_ATTR).\r\n document.documentElement.toggleAttribute(THEMED_ATTR, src !== null)\r\n if (src === null) {\r\n // No palette at all (a host publishing none of the surfaces we re-emit):\r\n // give every surface back to the host untouched instead of leaving ours.\r\n clearCustomTokens()\r\n clearOwnedSurfaces()\r\n }\r\n applyCustomTokens(rOps())\r\n applySettingsOverrides(rSop())\r\n applyTrajectoryOverrides(rTrajectoryOpacity())\r\n applyRightbarOverrides(rRightbarOpacity())\r\n applyPartBlurs(rBlurs())\r\n}\r\n\r\nexport function teardownWp(): void {\r\n dropWpContainer()\r\n clearCustomTokens()\r\n tokenStyleEl?.remove(); tokenStyleEl = null\r\n removeViewCards()\r\n document.documentElement.removeAttribute(THEMED_ATTR)\r\n document.body.style.removeProperty('color-scheme')\r\n // Every plugin-owned surface, including the AppFrame columns' inline\r\n // backgrounds and the palette readback that described them; the scheme flag is\r\n // handed back in the host's own form.\r\n clearOwnedSurfaces()\r\n adoptHostScheme()\r\n invalidateHostPalette()\r\n document.documentElement.style.removeProperty('--dsh-any-blur-settings')\r\n document.documentElement.style.removeProperty('--dsh-any-blur-card-panels')\r\n document.documentElement.style.removeProperty('--dsh-any-input-blur')\r\n document.documentElement.style.removeProperty('--dsh-any-bg-rightbar')\r\n document.documentElement.style.removeProperty('--dsh-any-blur-rightbar')\r\n for (const v of Object.values(OPACITY_VARS)) document.documentElement.style.removeProperty(v)\r\n if (tokensRaf !== null) { cancelAnimationFrame(tokensRaf); tokensRaf = null }\r\n pendingOps = null\r\n tableFixStyleEl?.remove(); tableFixStyleEl = null\r\n setBlur(frameEl, 0); setBlur(sidebarEl, 0); setBlur(centerEl, 0); setBlur(detailsEl, 0)\r\n stopWatchingParts()\r\n}\r\n\r\n/** Live wallpaper-opacity updates during slider drag (no full re-apply). */\r\nexport function setWpOpacity(v: number): void {\r\n if (wpEl) wpEl.style.opacity = String(v)\r\n}\r\n\r\n/** Live wallpaper-blur updates during slider drag (no full re-apply). */\r\nexport function setWpBlur(v: number): void {\r\n if (layers === null) return\r\n const filter = v > 0 ? `blur(${v}px)` : ''\r\n layers[0].el.style.filter = filter\r\n layers[1].el.style.filter = filter\r\n}\r\n","/**\n * Model → rule resolution.\n *\n * Two halves:\n * 1. `matchRule` — a pure function over the ordered rule list.\n * 2. `watchModel` — reports the current model whenever the session's durable\n * model selection changes.\n *\n * Sources, in the order they are consulted:\n *\n * a. **Which session is current** (`resolveMainSessionId` below) — the model is\n * read per session, so this hop answers before any other can. 0.1.7 moved it:\n * `sessions.list` stopped carrying a single `current` id, and the main view's\n * session is published by the `uiSession` service and marked by the list row\n * retained by `mainView`.\n * b. **The session's own durable model selection** —\n * `ctx.sessions.binding(id).session.projections.faceOf('modelSelection')`,\n * the same `{ lastUsed, next }` value the composer model seat and the\n * /model popup read. This is the authoritative per-session answer.\n * c. **`ctx.modelDirectories`** — the shared per-session directory\n * (ui-model-selection). It adds the provider-group catalog, so it is the\n * only source that can supply a display name, but it lives in that plugin's\n * own scope on some builds and is then invisible from here, hence optional.\n * d. **The host default model** — resolved by the CALLER as a last resort\n * (see index.tsx). It is a global default, NOT this session's selection, so\n * it is reported as `default` and the settings page says so.\n *\n * TIMING is load-bearing. `sessions` is published by the api-session-controller\n * client plugin, which this deployment loads AFTER this plugin's client bundle,\n * so `ctx.get('sessions')` is normally still undefined when `apply()` runs.\n * Giving up there — returning a no-op disposer — left the model pinned to the\n * host default for the whole session with nothing to retry it. The service is\n * now polled for until it appears, and `uiSession` (which can mount even later)\n * is picked up by the same poll because the session id is re-resolved on every\n * tick. Every hop reports a `note` when it cannot answer, so the settings page\n * can name the failing one instead of silently showing a value that is not this\n * session's model.\n */\nimport type {\n BgRule, Ctx, ModelDirectoryLike, ModelDirectoryResolverLike, ModelSelectionProjectionLike,\n ObservableFaceLike, SessionListSnapshotLike, SessionsServiceLike, UiSessionLike,\n} from './types'\n\n/** Rules that can actually paint: enabled and carrying an image slot. */\nfunction usable(rules: readonly BgRule[]): BgRule[] {\n return rules.filter(r => r.enabled && r.slot !== '')\n}\n\n/**\n * Resolve the rule for one model text.\n *\n * Top→bottom, first case-insensitive substring hit wins; an empty `match` never\n * hits on its own. When nothing hits, the FIRST usable rule is the fallback\n * (rule 1 deliberately doubles as both a matcher and the fallback).\n */\nexport function matchRule(\n rules: readonly BgRule[],\n modelText: string,\n): { rule: BgRule | null; matched: boolean } {\n const list = usable(rules)\n if (list.length === 0) return { rule: null, matched: false }\n const hay = modelText.toLowerCase()\n if (hay.trim() !== '') {\n for (const rule of list) {\n const needle = rule.match.trim().toLowerCase()\n if (needle === '') continue\n if (hay.includes(needle)) return { rule, matched: true }\n }\n }\n return { rule: list[0]!, matched: false }\n}\n\n/** Human-readable label of the model text an active rule matched against. */\nexport function modelLabelOf(text: string): string {\n const parts = text.split(/\\s+/).filter(p => p !== '')\n // The display name (last token, when the catalog provided one) reads best.\n return parts.length > 0 ? parts[parts.length - 1]! : ''\n}\n\n/** Look the current model's display name up in the shared catalog. */\nfunction displayNameOf(state: {\n groups?: ReadonlyArray<{ id?: string; models?: ReadonlyArray<{ id?: string; name?: string }> }>\n} | undefined, provider: string, model: string): string {\n if (model === '' || !Array.isArray(state?.groups)) return ''\n for (const group of state!.groups!) {\n if (group.id !== provider) continue\n for (const entry of group.models ?? []) {\n if (entry.id === model) return typeof entry.name === 'string' ? entry.name : ''\n }\n }\n return ''\n}\n\n/** Where the reported model text came from. */\nexport type ModelSource = 'session' | 'default'\n\n/**\n * Which hop could not answer when no per-session model was found. Surfaced in\n * the settings readout: without it, a broken hop is indistinguishable from\n * \"this session really is on the host default\".\n */\nexport type ModelNote = '' | 'no-service' | 'no-session' | 'no-projection' | 'empty-selection'\n\n/** How often to look for the sessions service that mounts after this plugin. */\nconst ATTACH_RETRY_MS = 400\n/** Stop looking after this many tries (~2 minutes). */\nconst ATTACH_RETRY_LIMIT = 300\n/** Safety re-read of every source, so a missed notification cannot pin a stale model. */\nconst POLL_MS = 1500\n\n/** One selection out of a `modelSelection` projection value. */\nfunction selectionOf(value: ModelSelectionProjectionLike | undefined): { provider: string; model: string } | null {\n const pick = value?.next ?? value?.lastUsed ?? null\n if (pick === null || typeof pick !== 'object') return null\n const provider = typeof pick.provider === 'string' ? pick.provider : ''\n const model = typeof pick.model === 'string' ? pick.model : ''\n if (provider === '' && model === '') return null\n return { provider, model }\n}\n\n/** A non-empty string id, or null. */\nfunction asId(value: unknown): string | null {\n return typeof value === 'string' && value !== '' ? value : null\n}\n\n/**\n * The id of the session the main view is showing.\n *\n * The model is read per session, so this hop has to answer before any of the\n * others can. 0.1.7 moved the answer: `sessions.list` stopped publishing a single\n * `current` id in favour of a row table (`ids` / `byId` / `phase`), and the main\n * view's session is now whatever holds a `mainView` retention — the same row the\n * host's own `uiSession.current` binding source is built from. Reading only\n * `list.current` therefore finds nothing on 0.1.7, and a plugin with no session\n * id can only ever fall back to rule 1: the background stops following the model.\n *\n * The hops are tried in order of authority and every one is optional, so this\n * answers on both host generations — and while `uiSession` is still mounting.\n */\nexport function resolveMainSessionId(\n uiCurrent: { key?: string } | undefined,\n snapshot: SessionListSnapshotLike | undefined,\n): string | null {\n // 0.1.7: the host's own answer, already resolved from list + retention.\n const fromUiSession = asId(uiCurrent?.key)\n if (fromUiSession !== null) return fromUiSession\n // ≤0.1.6: the list published the current id directly.\n const legacy = asId(snapshot?.current)\n if (legacy !== null) return legacy\n // 0.1.7 without `uiSession` yet: derive it from the retention the host uses.\n const byId = snapshot?.byId\n if (byId !== undefined && byId !== null) {\n for (const row of Object.values(byId)) {\n if ((row?.retainedBy?.mainView ?? 0) > 0) {\n const id = asId(row?.id)\n if (id !== null) return id\n }\n }\n }\n return null\n}\n\n/** Read `uiSession.current` (if that service is on this host) and resolve. */\nfunction mainSessionId(ctx: Ctx, list: ObservableFaceLike<SessionListSnapshotLike> | null): string | null {\n let uiCurrent: { key?: string } | undefined\n try {\n const ui = ctx.get('uiSession') as UiSessionLike | undefined\n uiCurrent = ui?.current?.getSnapshot?.()\n } catch {\n // Service absent (or not mounted yet) — the list retention below still answers.\n }\n return resolveMainSessionId(uiCurrent, list?.getSnapshot())\n}\n\n/**\n * Watch the current session's model selection.\n *\n * @param ctx - client root context.\n * @param onChange - called with the match text (provider + id + display name),\n * the best available label, which source answered, and — when nothing could be\n * read — the hop that failed.\n * @returns disposer.\n */\nexport function watchModel(\n ctx: Ctx,\n onChange: (text: string, label: string, source: ModelSource, note: ModelNote) => void,\n): () => void {\n let service: SessionsServiceLike | null = null\n let list: ObservableFaceLike<SessionListSnapshotLike> | null = null\n let offList: (() => void) | null = null\n let sessionId: string | null = null\n let directory: ModelDirectoryLike | null = null\n let offDirectory: (() => void) | null = null\n /** The session's own `modelSelection` projection face. */\n let projected: ObservableFaceLike<ModelSelectionProjectionLike> | null = null\n let offProjected: (() => void) | null = null\n let lastKey = '\\u0000'\n let poll: number | null = null\n let retry: number | null = null\n let retries = 0\n\n const release = (): void => {\n if (offDirectory !== null) { offDirectory(); offDirectory = null }\n if (offProjected !== null) { offProjected(); offProjected = null }\n directory = null\n projected = null\n }\n\n /** Bind the session's own durable model selection (the authoritative source). */\n const bindProjection = (id: string): void => {\n const svc = service\n if (svc === null) return\n try {\n let binding = typeof svc.binding === 'function' ? svc.binding(id) : undefined\n if (binding === undefined && typeof svc.scope === 'function') {\n // Materialize the scope, then resolve again: a session that is merely\n // listed has no binding yet.\n svc.scope(id)\n binding = typeof svc.binding === 'function' ? svc.binding(id) : undefined\n }\n const face = binding?.session?.projections?.faceOf?.('modelSelection')\n if (face === undefined || typeof face.subscribe !== 'function' || typeof face.getSnapshot !== 'function') return\n projected = face\n offProjected = face.subscribe(() => { emit(false) })\n } catch {\n projected = null\n offProjected = null\n }\n }\n\n const note = (): ModelNote => {\n if (service === null) return 'no-service'\n if (sessionId === null) return 'no-session'\n if (projected === null && directory === null) return 'no-projection'\n return 'empty-selection'\n }\n\n const emit = (force: boolean): void => {\n const state = directory?.store.getSnapshot()\n const fromDirectory = state?.current ?? null\n const sel = fromDirectory !== null\n ? { provider: fromDirectory.provider ?? '', model: fromDirectory.model ?? '' }\n : (() => {\n try { return selectionOf(projected?.getSnapshot()) } catch { return null }\n })()\n const provider = sel?.provider ?? ''\n const model = sel?.model ?? ''\n const name = displayNameOf(state, provider, model)\n const text = [provider, model, name].filter(p => p !== '').join(' ').trim()\n const noteValue: ModelNote = text === '' ? note() : ''\n const key = `${text}\\u0001${name}\\u0001${noteValue}`\n if (!force && key === lastKey) return\n lastKey = key\n onChange(text, name !== '' ? name : (model !== '' ? model : provider), 'session', noteValue)\n }\n\n const bind = (): void => {\n const id = mainSessionId(ctx, list)\n // Already bound to this session and holding at least one live source: only\n // refresh the value. A missing source keeps retrying on the poll below.\n if (id === sessionId && (directory !== null || projected !== null)) { emit(false); return }\n release()\n sessionId = id\n if (id !== null) {\n bindProjection(id)\n if (directory === null) {\n const directories = ctx.get('modelDirectories') as ModelDirectoryResolverLike | undefined\n if (directories !== undefined && typeof directories.directoryFor === 'function') {\n try {\n directory = directories.directoryFor(id)\n offDirectory = directory.store.subscribe(() => { emit(false) })\n // The advisory catalog (display names) loads lazily; a failure only\n // costs us the pretty name, never the match.\n const pending = directory.load?.()\n if (pending !== undefined && pending !== null && typeof (pending as Promise<unknown>).catch === 'function') {\n void (pending as Promise<unknown>).catch(() => undefined)\n }\n } catch {\n directory = null\n offDirectory = null\n }\n }\n }\n }\n // Forced: the sources may have appeared without the text changing (the host\n // default was showing and the session now agrees with it), and the settings\n // page must be able to correct its badge and its note.\n emit(true)\n }\n\n const stopRetry = (): void => {\n if (retry === null) return\n window.clearInterval(retry)\n retry = null\n }\n\n const tick = (): void => {\n if (list === null) return\n if (mainSessionId(ctx, list) !== sessionId || (directory === null && projected === null)) bind()\n else emit(false)\n }\n\n /**\n * Look the sessions service up. It arrives after this plugin's bundle on this\n * deployment, so the first attempt usually fails — which is exactly why this\n * is a retry loop rather than a one-shot lookup.\n */\n const attach = (): boolean => {\n const svc = ctx.get('sessions') as SessionsServiceLike | undefined\n if (svc === undefined || svc === null) return false\n const face = svc.list\n if (face === undefined || typeof face.subscribe !== 'function' || typeof face.getSnapshot !== 'function') return false\n service = svc\n list = face\n offList = face.subscribe(bind)\n if (poll === null) poll = window.setInterval(tick, POLL_MS)\n bind()\n return true\n }\n\n if (!attach()) {\n retry = window.setInterval(() => {\n retries++\n if (attach() || retries >= ATTACH_RETRY_LIMIT) stopRetry()\n }, ATTACH_RETRY_MS)\n }\n\n return () => {\n stopRetry()\n if (poll !== null) { window.clearInterval(poll); poll = null }\n if (offList !== null) { offList(); offList = null }\n service = null\n list = null\n release()\n }\n}\n","import type { ReactNode } from 'react'\r\n\r\n/** Sun glyph, migrated from @deepseek-ai/dsh-client-ui-primitives IconLightOutline16. */\r\nexport const SUN_PATHS = '<path d=\"M11.3496 8C11.3496 6.14985 9.85015 4.65039 8 4.65039C6.14985 4.65039 4.65039 6.14985 4.65039 8C4.65039 9.85015 6.14985 11.3496 8 11.3496C9.85015 11.3496 11.3496 9.85015 11.3496 8ZM12.6504 8C12.6504 10.5681 10.5681 12.6504 8 12.6504C5.43188 12.6504 3.34961 10.5681 3.34961 8C3.34961 5.43188 5.43188 3.34961 8 3.34961C10.5681 3.34961 12.6504 5.43188 12.6504 8Z\" fill=\"currentColor\"/><path d=\"M8.65039 0.5V2.5H7.34961V0.5H8.65039Z\" fill=\"currentColor\"/><path d=\"M8.65039 13.5V15.5H7.34961V13.5H8.65039Z\" fill=\"currentColor\"/><path d=\"M3.15808 2.24035L4.57229 3.65456L3.6525 4.57435L2.23829 3.16014L3.15808 2.24035Z\" fill=\"currentColor\"/><path d=\"M12.3505 11.4327L13.7647 12.8469L12.8449 13.7667L11.4307 12.3525L12.3505 11.4327Z\" fill=\"currentColor\"/><path d=\"M2.24537 12.8469L3.65958 11.4327L4.57937 12.3525L3.16516 13.7667L2.24537 12.8469Z\" fill=\"currentColor\"/><path d=\"M11.4377 3.65455L12.852 2.24033L13.7718 3.16012L12.3575 4.57434L11.4377 3.65455Z\" fill=\"currentColor\"/><path d=\"M0.5 7.35461H2.5V8.6554H0.5L0.5 7.35461Z\" fill=\"currentColor\"/><path d=\"M13.5 7.35461H15.5V8.6554H13.5V8.6554Z\" fill=\"currentColor\"/>'\r\n\r\nexport function SunIcon({ size = 16, className }: { size?: number; className?: string }) {\r\n return (\r\n <svg width={size} height={size} className={className} viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" dangerouslySetInnerHTML={{ __html: SUN_PATHS }} />\r\n )\r\n}\r\n\r\nfunction Glyph({ children, size = 16, className }: { children: ReactNode; size?: number; className?: string }) {\r\n return (\r\n <svg width={size} height={size} className={className} viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth={1.5} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\r\n {children}\r\n </svg>\r\n )\r\n}\r\n\r\nexport const DropletIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M8 1.9c2.4 2.8 4.3 5 4.3 7.1a4.3 4.3 0 1 1-8.6 0C3.7 6.9 5.6 4.7 8 1.9z\" /></Glyph>\r\n)\r\n\r\nexport const LayersIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M8 2.2 13.2 5 8 7.8 2.8 5 8 2.2z\" /><path d=\"M2.8 8.2 8 11l5.2-2.8\" /><path d=\"M2.8 11.2 8 14l5.2-2.8\" /></Glyph>\r\n)\r\n\r\nexport const PhotoIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><rect x=\"2\" y=\"3.2\" width=\"12\" height=\"9.6\" rx=\"2\" /><circle cx=\"5.7\" cy=\"6.3\" r=\"0.9\" /><path d=\"M14 10.4l-2.8-2.8-4.8 4.8\" /></Glyph>\r\n)\r\n\r\nexport const VideoIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><rect x=\"1.5\" y=\"4.2\" width=\"8.8\" height=\"7.6\" rx=\"2\" /><path d=\"M10.3 6.9l4.2-2.4v7l-4.2-2.4\" /></Glyph>\r\n)\r\n\r\nexport const TextIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M3 4.2h10M3 8h10M3 11.8h6.5\" /></Glyph>\r\n)\r\n\r\nexport const TrajectoryIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M2.5 3.2h11M2.5 6.6h11M2.5 10h11\" /><circle cx=\"4.4\" cy=\"3.2\" r=\"1.1\" /><circle cx=\"8\" cy=\"6.6\" r=\"1.1\" /><circle cx=\"11.4\" cy=\"10\" r=\"1.1\" /></Glyph>\r\n)\r\n\r\nexport const SlidersIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M2.5 4.5h4.9M11.6 4.5h1.9M2.5 11.5h1.9M8.6 11.5h4.9\" /><circle cx=\"9.5\" cy=\"4.5\" r=\"1.7\" /><circle cx=\"5.5\" cy=\"11.5\" r=\"1.7\" /></Glyph>\r\n)\r\n\r\nexport const SparkleIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M7.2 1.8l1.2 3.1 3.1 1.2-3.1 1.2-1.2 3.1-1.2-3.1L2.9 6.1 6 4.9l1.2-3.1z\" /><path d=\"M12 10.5l.5 1.2 1.2.5-1.2.5-.5 1.2-.5-1.2-1.2-.5 1.2-.5.5-1.2z\" /></Glyph>\r\n)\r\n\r\nexport const RefreshIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M13.2 8A5.2 5.2 0 1 1 11.5 4.2\" /><path d=\"M13.4 1.8v2.9h-2.9\" /></Glyph>\r\n)\r\n\r\nexport const DownloadIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M8 2.2v8\" /><path d=\"M4.6 7l3.4 3.4L11.4 7\" /><path d=\"M2.8 13.8h10.4\" /></Glyph>\r\n)\r\n\r\nexport const UploadIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M8 10.4V2.6\" /><path d=\"M4.6 5.8L8 2.4l3.4 3.4\" /><path d=\"M2.8 13.8h10.4\" /></Glyph>\r\n)\r\n\r\nexport const LinkIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M6.6 9.4 9.4 6.6\" /><path d=\"M5.9 11.1l-1.4 1.4a2.6 2.6 0 0 1-3.7-3.7L3.5 6.8\" /><path d=\"M10.1 4.9l1.4-1.4a2.6 2.6 0 0 1 3.7 3.7l-2.1 2.1\" /></Glyph>\r\n)\r\n\r\nexport const LockIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><rect x=\"3.6\" y=\"7.2\" width=\"8.8\" height=\"6\" rx=\"1.4\" /><path d=\"M5.6 7.2V5.4a2.4 2.4 0 0 1 4.8 0v1.8\" /></Glyph>\r\n)\r\n\r\nexport const TrashIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M2.8 4.4h10.4\" /><path d=\"M6.4 4.4V2.9h3.2v1.5\" /><path d=\"M4.4 4.4l.5 8.6h6.2l.5-8.6\" /></Glyph>\r\n)\r\n\r\nexport const EditIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M9.5 4l2.5 2.5\" /><path d=\"M3 13l.8-3L10 3.8 12.2 6 6 12.2 3 13z\" /></Glyph>\r\n)\r\n\r\nexport const PipetteIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><circle cx=\"8\" cy=\"8\" r=\"4.2\" /><path d=\"M8 1.6v2.6M8 11.8v2.6M1.6 8h2.6M11.8 8h2.6\" /></Glyph>\r\n)\r\n\r\nexport const CheckIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M3.2 8.6l3 3L12.8 5\" /></Glyph>\r\n)\r\n\r\nexport const AlertIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M8 2.6l5.4 9.8H2.6L8 2.6z\" /><path d=\"M8 6.8v2.4M8 11.4v.01\" /></Glyph>\r\n)\r\n\r\nexport const CopyIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><rect x=\"5.4\" y=\"5.4\" width=\"7.6\" height=\"7.6\" rx=\"1.6\" /><path d=\"M10.6 5.4V4.2a1.6 1.6 0 0 0-1.6-1.6H4.2a1.6 1.6 0 0 0-1.6 1.6v4.8a1.6 1.6 0 0 0 1.6 1.6h1.2\" /></Glyph>\r\n)\r\n\r\nexport const CanvasIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><rect x=\"2.2\" y=\"2.2\" width=\"11.6\" height=\"11.6\" rx=\"2\" /></Glyph>\r\n)\r\n\r\nexport const SidebarIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><rect x=\"2.2\" y=\"2.2\" width=\"11.6\" height=\"11.6\" rx=\"2\" /><path d=\"M6.6 2.2v11.6\" /></Glyph>\r\n)\r\n\r\n/** Mirror of SidebarIcon: the file-preview panel docked to the right edge. */\r\nexport const PreviewIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><rect x=\"2.2\" y=\"2.2\" width=\"11.6\" height=\"11.6\" rx=\"2\" /><path d=\"M9.4 2.2v11.6\" /><path d=\"M11 5.6h1.2M11 8h1.2\" /></Glyph>\r\n)\r\n\r\nexport const ChatIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><path d=\"M13.4 4.4v4.4a2 2 0 0 1-2 2H6.2l-3.6 3V4.4a2 2 0 0 1 2-2h6.8a2 2 0 0 1 2 2z\" /></Glyph>\r\n)\r\n\r\nexport const GearIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><circle cx=\"8\" cy=\"8\" r=\"2.1\" /><path d=\"M8 1.7v1.8M8 12.5v1.8M1.7 8h1.8M12.5 8h1.8M3.6 3.6l1.3 1.3M11.1 11.1l1.3 1.3M12.4 3.6l-1.3 1.3M4.9 11.1l-1.3 1.3\" /></Glyph>\r\n)\r\n\r\nexport const InputIcon = ({ size, className }: { size?: number; className?: string }) => (\r\n <Glyph size={size} className={className}><rect x=\"2.2\" y=\"4\" width=\"11.6\" height=\"8\" rx=\"2\" /><path d=\"M8 6.6v2M7 8h2\" /></Glyph>\r\n)\r\n\r\n","import { Component, type ReactNode } from 'react'\r\n\r\ninterface Props {\r\n t: (key: string) => string\r\n onReset?: () => void\r\n children: ReactNode\r\n}\r\n\r\ninterface State {\r\n error: Error | null\r\n}\r\n\r\n/**\r\n * Catches render errors from the theme section subtree (wheel, sliders, editor)\r\n * so a single bad state can never take down the whole settings panel. Shows a\r\n * compact fallback with a reset button; the reset re-renders the section with\r\n * the current saved config, which is enough to recover from most transient\r\n * failures (corrupt transient UI state, stale image decode, etc.).\r\n */\r\nexport class ErrorBoundary extends Component<Props, State> {\r\n override state: State = { error: null }\r\n\r\n static getDerivedStateFromError(error: Error): State {\r\n return { error }\r\n }\r\n\r\n override componentDidCatch(error: Error, info: { componentStack?: string | null }): void {\r\n console.error('dsh-background-by-model: section render crashed', error, info.componentStack)\r\n }\r\n\r\n private reset = (): void => {\r\n this.setState({ error: null })\r\n this.props.onReset?.()\r\n }\r\n\r\n override render() {\r\n if (this.state.error) {\r\n return (\r\n <div className=\"dab-crash\">\r\n <div className=\"dab-crash-title\">{this.props.t('crashTitle')}</div>\r\n <div className=\"dab-crash-desc\">{this.props.t('crashDesc')}</div>\r\n <button type=\"button\" className=\"dab-btn\" onClick={this.reset}>{this.props.t('crashReset')}</button>\r\n </div>\r\n )\r\n }\r\n return this.props.children\r\n }\r\n}\r\n","import { useEffect, useState } from 'react'\r\nimport type { ReactNode } from 'react'\r\nimport { createPortal } from 'react-dom'\r\n\r\n/**\r\n * Render children into a fixed root attached to document.documentElement.\r\n *\r\n * The host's sidebar is often implemented by translating the body or a wrapper\r\n * (margin-left / transform). A fixed element portaled to body would still be\r\n * captured by that transformed ancestor and shift with the sidebar. Attaching\r\n * the portal root directly to <html> escapes body-level transforms so the\r\n * overlay is always painted relative to the viewport and centered correctly.\r\n */\r\nexport function Portal({ children }: { children: ReactNode }) {\r\n const [target, setTarget] = useState<HTMLElement | null>(null)\r\n useEffect(() => {\r\n const el = document.createElement('div')\r\n el.dataset.dabPortal = '1'\r\n el.style.cssText = 'position:fixed;inset:0;pointer-events:none;z-index:999999'\r\n document.documentElement.appendChild(el)\r\n setTarget(el)\r\n return () => { el.remove() }\r\n }, [])\r\n return target ? createPortal(children, target) : null\r\n}\r\n","import { useEffect, useRef } from 'react'\r\nimport type { CSSProperties } from 'react'\r\n\r\n/**\r\n * Zero-lag slider: the thumb and value label update through DOM refs while\r\n * dragging (onInput) so the caller can mutate the live UI directly without a\r\n * React re-render; onChange commits the settled value. Double-click resets to\r\n * the canonical default. The track fill is a gradient driven by the --pct\r\n * custom property, updated imperatively alongside the thumb.\r\n */\r\nexport function LiveSlider({ min, max, step, def, fmt, label, onInput, onChange }: {\r\n min: number; max: number; step: number; def: number\r\n fmt: (v: number) => string; label?: string; onInput?: (v: number) => void; onChange: (v: number) => void\r\n}) {\r\n const inputRef = useRef<HTMLInputElement>(null)\r\n const valRef = useRef<HTMLSpanElement>(null)\r\n\r\n const paint = (el: HTMLInputElement, v: number): void => {\r\n el.style.setProperty('--pct', String(((v - min) / (max - min)) * 100))\r\n }\r\n\r\n // Controlled sync: keep the knob and label aligned with the canonical prop\r\n // so external updates (presets, regeneration, imports) never leave it stale.\r\n useEffect(() => {\r\n if (inputRef.current) {\r\n inputRef.current.value = String(def)\r\n paint(inputRef.current, def)\r\n }\r\n if (valRef.current) valRef.current.textContent = fmt(def)\r\n }, [def, fmt, min, max])\r\n\r\n const apply = (v: number): void => {\r\n if (inputRef.current) {\r\n inputRef.current.value = String(v)\r\n paint(inputRef.current, v)\r\n }\r\n if (valRef.current) valRef.current.textContent = fmt(v)\r\n onInput?.(v)\r\n onChange(v)\r\n }\r\n\r\n return (\r\n <div className=\"dab-slider-block\">\r\n {label ? <span className=\"dab-slider-label\">{label}</span> : null}\r\n <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>\r\n <input\r\n ref={inputRef} type=\"range\" className=\"dab-slider\"\r\n style={{ '--pct': ((def - min) / (max - min)) * 100 } as CSSProperties}\r\n min={min} max={max} step={step} defaultValue={def}\r\n title={label ? `${label} · ${fmt(def)}` : fmt(def)}\r\n onDoubleClick={() => apply(def)}\r\n onInput={e => {\r\n const el = e.target as HTMLInputElement\r\n const v = Number(el.value)\r\n paint(el, v)\r\n onInput?.(v)\r\n if (valRef.current) valRef.current.textContent = fmt(v)\r\n }}\r\n onChange={e => onChange(Number((e.target as HTMLInputElement).value))} />\r\n <span ref={valRef} className=\"dab-slider-val\">{fmt(def)}</span>\r\n </div>\r\n </div>\r\n )\r\n}\r\n","import type { CSSProperties, ComponentType } from 'react'\r\nimport type { ThemeSectionProps, PartOpacities, PartBlurs } from '../../types'\r\nimport { cfg, rOps, rSop, rBlurs, rChatTextOpacity, rTrajectoryOpacity, rRightbarOpacity } from '../../state'\r\nimport { saveConfig } from '../../rpc'\r\nimport { applyCustomTokens, applySettingsOverrides, setPartBlur, applyViewCards, applyTrajectoryOverrides, applyRightbarOverrides } from '../../wallpaper'\r\nimport { LiveSlider } from '../LiveSlider'\r\nimport { CanvasIcon, SidebarIcon, ChatIcon, GearIcon, TextIcon, TrajectoryIcon, PreviewIcon, InputIcon } from '../icons'\r\n\r\ninterface PartDef {\r\n labelKey: string\r\n Icon: ComponentType<{ size?: number }>\r\n /** Homepage part key; absent for the settings-panel part. */\r\n opKey?: keyof PartOpacities\r\n isSettings?: boolean\r\n /** Conversation text region: tint opacity + blur over the message column. */\r\n isChat?: boolean\r\n /** Trajectory view: tint opacity + blur over the whole view surface. */\r\n isTrajectory?: boolean\r\n /** File-preview panel: the right sidebar a file click opens. */\r\n isRightbar?: boolean\r\n}\r\n\r\nconst PARTS: PartDef[] = [\r\n { opKey: 'bg', labelKey: 'uiOpacityBg', Icon: CanvasIcon },\r\n { opKey: 'sidebar', labelKey: 'uiOpacitySide', Icon: SidebarIcon },\r\n { isRightbar: true, labelKey: 'uiPreview', Icon: PreviewIcon },\r\n { opKey: 'card', labelKey: 'uiOpacityCard', Icon: ChatIcon },\r\n { opKey: 'input', labelKey: 'uiOpacityInput', Icon: InputIcon },\r\n { isSettings: true, labelKey: 'uiSop', Icon: GearIcon },\r\n { isChat: true, labelKey: 'uiChatRegion', Icon: TextIcon },\r\n { isTrajectory: true, labelKey: 'uiTrajectory', Icon: TrajectoryIcon },\r\n]\r\n\r\nexport function InterfacePage({ p }: { p: ThemeSectionProps }) {\r\n const { t, setOps, setBlurs, setSop, setRightbarOpacity } = p\r\n\r\n return (\r\n <>\r\n <header className=\"dab-head dab-rise\" style={{ '--d': 0 } as CSSProperties}>\r\n <div className=\"dab-overline\">Surfaces</div>\r\n <h2 className=\"dab-h1\">{t('uiTitle')}</h2>\r\n <p className=\"dab-desc\">{t('descInterface')}</p>\r\n </header>\r\n\r\n <div className=\"dab-grid-parts\">\r\n {PARTS.map((part, i) => {\r\n const { labelKey, Icon, isSettings, isChat, isTrajectory, isRightbar } = part\r\n const opKey = part.opKey\r\n // Homepage parts (bg/sidebar/card/input) bind to their own part only;\r\n // the settings panel (isSettings) binds exclusively to the 'settings'\r\n // part (--dsh-any-blur-settings / --dsh-any-bg-settings-surface) and\r\n // must never fall back to a homepage part key — otherwise the dialog\r\n // panel would track the homepage center/card blur and the home-page\r\n // opacities. The chat region (isChat) and the trajectory view\r\n // (isTrajectory) own their own blur keys plus their own tint\r\n // opacities, and the file-preview panel (isRightbar) owns the right\r\n // column's backdrop through the same deal. Every homepage opKey is\r\n // also a PartBlurs key (input included), so the shared blur slider\r\n // dereferences it directly.\r\n const blurKey: keyof PartBlurs = isChat\r\n ? 'chat'\r\n : isTrajectory\r\n ? 'trajectory'\r\n : isRightbar\r\n ? 'rightbar'\r\n : isSettings ? 'settings' : opKey!\r\n const opacity = isChat\r\n ? rChatTextOpacity()\r\n : isTrajectory\r\n ? rTrajectoryOpacity()\r\n : isRightbar ? rRightbarOpacity() : isSettings ? rSop() : rOps()[opKey!]\r\n return (\r\n <section key={blurKey} className=\"dab-card dab-card-hover dab-rise\" style={{ '--d': i + 1 } as CSSProperties}>\r\n <div className=\"dab-part-head\">\r\n <div className=\"dab-part-ico\"><Icon size={16} /></div>\r\n <div className=\"dab-part-name\">{t(labelKey)}</div>\r\n <span className=\"dab-part-badge\">{Math.round(opacity * 100)}%</span>\r\n </div>\r\n\r\n <LiveSlider label={t('uiOpacity')} min={0} max={100} step={1} def={Math.round(opacity * 100)}\r\n fmt={v => `${v}%`}\r\n onInput={v => {\r\n const op = v / 100\r\n if (isChat) {\r\n cfg.chatTextOpacity = op\r\n applyViewCards()\r\n } else if (isTrajectory) {\r\n cfg.trajectoryOpacity = op\r\n applyTrajectoryOverrides(op)\r\n } else if (isRightbar) {\r\n // First drag is what detaches the panel from the main\r\n // background; from then on the card owns it.\r\n cfg.rightbarOpacity = op\r\n applyRightbarOverrides(op)\r\n } else if (isSettings) {\r\n cfg.settingsOpacity = op\r\n applySettingsOverrides(op)\r\n } else {\r\n const ops = { ...rOps() }\r\n ops[opKey!] = op\r\n cfg.opacities = ops\r\n applyCustomTokens(ops)\r\n }\r\n saveConfig()\r\n }}\r\n onChange={v => {\r\n const op = v / 100\r\n if (isChat) {\r\n cfg.chatTextOpacity = op\r\n applyViewCards()\r\n saveConfig()\r\n } else if (isTrajectory) {\r\n cfg.trajectoryOpacity = op\r\n applyTrajectoryOverrides(op)\r\n saveConfig()\r\n } else if (isRightbar) {\r\n setRightbarOpacity(op)\r\n } else if (isSettings) {\r\n setSop(op)\r\n } else {\r\n const ops = { ...rOps() }\r\n ops[opKey!] = op\r\n setOps(ops)\r\n }\r\n }} />\r\n\r\n <LiveSlider label={t('uiBlur')} min={0} max={60} step={1} def={rBlurs()[blurKey]}\r\n fmt={v => `${v}px`}\r\n onInput={v => {\r\n const blurs = { ...rBlurs() }\r\n blurs[blurKey] = v\r\n cfg.blurs = blurs\r\n setPartBlur(blurKey, v)\r\n saveConfig()\r\n }}\r\n onChange={v => {\r\n const blurs = { ...rBlurs() }\r\n blurs[blurKey] = v\r\n setBlurs(blurs)\r\n }} />\r\n </section>\r\n )\r\n })}\r\n </div>\r\n </>\r\n )\r\n}\r\n","/**\r\n * Read a chosen image file as a data URL WITHOUT re-encoding: the original\r\n * pixels are kept as-is (no canvas downscale / JPEG re-compression), so the\r\n * wallpaper is stored and displayed at full fidelity. The tradeoff is a larger\r\n * payload over the RPC channel and on disk for big images.\r\n */\r\nexport function readImg(file: File, cb: (url: string | null) => void): void {\r\n const r = new FileReader()\r\n r.onerror = () => cb(null)\r\n r.onload = () => cb(r.result as string)\r\n r.readAsDataURL(file)\r\n}\r\n","import { useRef, useState, useEffect, useCallback, memo } from 'react'\r\n\r\nconst WHEEL_SIZE = 220\r\nconst CX = WHEEL_SIZE / 2\r\nconst RING_OUTER = 106\r\nconst RING_INNER = 82\r\n// Square inscribed in the ring's inner circle: half-side = RING_INNER / √2,\r\n// so the four corners sit exactly on the inner edge of the hue ring. The\r\n// exact (un-rounded) value keeps the corners tangent to the ring — a rounded\r\n// half-side would push the diagonals past the ring's inner boundary.\r\nconst SQ_HALF = RING_INNER / Math.SQRT2\r\n\r\n/** Static hue ring cached once across all wheels. */\r\nlet ringCache: HTMLCanvasElement | null = null\r\nfunction getRingCache(): HTMLCanvasElement {\r\n if (ringCache) return ringCache\r\n const cvs = document.createElement('canvas')\r\n cvs.width = WHEEL_SIZE; cvs.height = WHEEL_SIZE\r\n const c = cvs.getContext('2d')!\r\n // Instead of 360 separate arc paths, use a single conic gradient clipped to\r\n // the ring. This removes per-frame path overhead and anti-aliasing gaps.\r\n const g = c.createConicGradient(0, CX, CX)\r\n for (let i = 0; i <= 360; i++) g.addColorStop(i / 360, `hsl(${i},100%,50%)`)\r\n c.beginPath()\r\n c.arc(CX, CX, RING_OUTER, 0, Math.PI * 2)\r\n c.arc(CX, CX, RING_INNER, 0, Math.PI * 2, true)\r\n c.fillStyle = g\r\n c.fill()\r\n ringCache = cvs\r\n return ringCache\r\n}\r\n\r\nfunction drawMarkers(ctx: CanvasRenderingContext2D, hue: number, sat: number, lit: number): void {\r\n // Hue marker on ring. Canvas math angles (0 = +x / \"3 o'clock\", positive =\r\n // toward +y) directly match the conic-gradient hue distribution drawn in\r\n // getRingCache (colorStop i/360 → hsl(i)), so NO extra ±90° shift is applied.\r\n // A shift would rotate the picker's indication 90° away from the rendered\r\n // gradient (e.g. picking the top of the wheel would report red while the\r\n // pixels there are blue). hue 0 sits at the right edge, +90° at the bottom.\r\n const hRad = hue * Math.PI / 180\r\n const hR = (RING_OUTER + RING_INNER) / 2\r\n const hmx = CX + Math.cos(hRad) * hR\r\n const hmy = CX + Math.sin(hRad) * hR\r\n ctx.beginPath(); ctx.arc(hmx, hmy, 8, 0, Math.PI * 2)\r\n ctx.fillStyle = 'rgba(0,0,0,0.25)'; ctx.fill()\r\n ctx.beginPath(); ctx.arc(hmx, hmy, 6.5, 0, Math.PI * 2)\r\n ctx.strokeStyle = '#fff'; ctx.lineWidth = 2; ctx.stroke()\r\n\r\n // SL marker (HSV coordinates)\r\n const gx = CX - SQ_HALF, gy = CX - SQ_HALF, sz = SQ_HALF * 2\r\n const smx = gx + sat * sz\r\n const smy = gy + (1 - lit) * sz\r\n ctx.beginPath(); ctx.arc(smx, smy, 7, 0, Math.PI * 2)\r\n ctx.fillStyle = 'rgba(0,0,0,0.25)'; ctx.fill()\r\n ctx.beginPath(); ctx.arc(smx, smy, 5.5, 0, Math.PI * 2)\r\n ctx.strokeStyle = '#fff'; ctx.lineWidth = 2; ctx.stroke()\r\n ctx.beginPath(); ctx.arc(smx, smy, 3.5, 0, Math.PI * 2)\r\n ctx.strokeStyle = '#000'; ctx.lineWidth = 1; ctx.stroke()\r\n}\r\n\r\nfunction drawSquare(c: CanvasRenderingContext2D, hue: number): void {\r\n const gx = CX - SQ_HALF, gy = CX - SQ_HALF, sz = SQ_HALF * 2\r\n c.clearRect(gx - 1, gy - 1, sz + 2, sz + 2)\r\n c.fillStyle = '#fff'; c.fillRect(gx, gy, sz, sz)\r\n const gh = c.createLinearGradient(gx, 0, gx + sz, 0)\r\n gh.addColorStop(0, 'rgba(255,255,255,1)'); gh.addColorStop(1, `hsl(${hue},100%,50%)`)\r\n c.fillStyle = gh; c.fillRect(gx, gy, sz, sz)\r\n const gv = c.createLinearGradient(0, gy, 0, gy + sz)\r\n gv.addColorStop(0, 'rgba(0,0,0,0)'); gv.addColorStop(1, 'rgba(0,0,0,1)')\r\n c.fillStyle = gv; c.fillRect(gx, gy, sz, sz)\r\n}\r\n\r\nfunction hitTest(x: number, y: number): 'ring' | 'square' | null {\r\n if (Math.abs(x - CX) <= SQ_HALF && Math.abs(y - CX) <= SQ_HALF) return 'square'\r\n const dx = x - CX, dy = y - CX\r\n const dist = Math.sqrt(dx * dx + dy * dy)\r\n if (dist >= RING_INNER - 4 && dist <= RING_OUTER + 4) return 'ring'\r\n return null\r\n}\r\n\r\nfunction pickHue(x: number, y: number): number {\r\n // Inverse of drawMarkers: no ±90° shift, matching the conic gradient exactly.\r\n let angle = Math.atan2(y - CX, x - CX) * 180 / Math.PI\r\n if (angle < 0) angle += 360\r\n return angle\r\n}\r\n\r\nfunction pickSL(x: number, y: number): [number, number] {\r\n const gx = CX - SQ_HALF, gy = CX - SQ_HALF, sz = SQ_HALF * 2\r\n return [\r\n Math.max(0, Math.min(1, (x - gx) / sz)),\r\n Math.max(0.02, Math.min(0.98, 1 - (y - gy) / sz)),\r\n ]\r\n}\r\n\r\nexport const ColorWheel = memo(function ColorWheel({ hue, sat, lit, onChange }: {\r\n hue: number; sat: number; lit: number\r\n onChange: (h: number, s: number, l: number) => void\r\n}) {\r\n const cvsRef = useRef<HTMLCanvasElement>(null)\r\n const [col, setCol] = useState({ hue, sat, lit })\r\n const colRef = useRef(col)\r\n colRef.current = col\r\n\r\n // Adopt external changes (e.g. section remount after theme restore).\r\n useEffect(() => {\r\n setCol(c => (c.hue === hue && c.sat === sat && c.lit === lit ? c : { hue, sat, lit }))\r\n }, [hue, sat, lit])\r\n\r\n // Redraw only what changed. The static ring is copied from cache; the square\r\n // only redraws when hue changes; markers redraw on every value change.\r\n useEffect(() => {\r\n const cvs = cvsRef.current\r\n if (!cvs) return\r\n const ctx = cvs.getContext('2d')!\r\n ctx.clearRect(0, 0, WHEEL_SIZE, WHEEL_SIZE)\r\n // Draw the square first, then the ring on top: the ring's opaque pixels\r\n // cover the square's four corners (which are tangent to the ring's inner\r\n // edge), so the corners no longer visually overlap the hue ring.\r\n drawSquare(ctx, col.hue)\r\n ctx.drawImage(getRingCache(), 0, 0)\r\n drawMarkers(ctx, col.hue, col.sat, col.lit)\r\n }, [col])\r\n\r\n // Batch pointer updates in a single rAF so rapid mousemove events do not\r\n // trigger a React state flush + onChange on every pixel.\r\n const pendingRef = useRef<{ h: number; s: number; l: number } | null>(null)\r\n const rafRef = useRef<number | null>(null)\r\n const flushPending = useCallback(() => {\r\n rafRef.current = null\r\n const p = pendingRef.current\r\n if (!p) return\r\n pendingRef.current = null\r\n setCol({ hue: p.h, sat: p.s, lit: p.l })\r\n onChange(p.h, p.s, p.l)\r\n }, [onChange])\r\n\r\n const schedule = useCallback((h: number, s: number, l: number) => {\r\n pendingRef.current = { h, s, l }\r\n if (rafRef.current === null) rafRef.current = requestAnimationFrame(flushPending)\r\n }, [flushPending])\r\n\r\n const onDown = useCallback((e: React.MouseEvent<HTMLCanvasElement>) => {\r\n const r = cvsRef.current!.getBoundingClientRect()\r\n const x = e.clientX - r.left, y = e.clientY - r.top\r\n const region = hitTest(x, y)\r\n if (!region) return\r\n if (region === 'ring') {\r\n schedule(pickHue(x, y), colRef.current.sat, colRef.current.lit)\r\n } else {\r\n const [s, l] = pickSL(x, y)\r\n schedule(colRef.current.hue, s, l)\r\n }\r\n const onMove = (ev: MouseEvent) => {\r\n const rr = cvsRef.current!.getBoundingClientRect()\r\n const mx = ev.clientX - rr.left, my = ev.clientY - rr.top\r\n if (region === 'ring') {\r\n const d = Math.sqrt((mx - CX) ** 2 + (my - CX) ** 2)\r\n if (d >= RING_INNER - 10 && d <= RING_OUTER + 10) schedule(pickHue(mx, my), colRef.current.sat, colRef.current.lit)\r\n } else {\r\n const [s, l] = pickSL(mx, my)\r\n schedule(colRef.current.hue, s, l)\r\n }\r\n }\r\n const onUp = () => { document.removeEventListener('mousemove', onMove); document.removeEventListener('mouseup', onUp) }\r\n document.addEventListener('mousemove', onMove); document.addEventListener('mouseup', onUp)\r\n }, [schedule])\r\n\r\n return <canvas ref={cvsRef} width={WHEEL_SIZE} height={WHEEL_SIZE} className=\"dab-wheel\" onMouseDown={onDown} />\r\n})\r\n","import { useState, useEffect, useRef } from 'react'\r\nimport type { CSSProperties } from 'react'\r\nimport { hsvToHsl, hslToRgb, rgbToHsl, hslToHsv } from '../utils/color'\r\n\r\ntype Mode = 'hsl' | 'rgb'\r\n\r\nconst SEG_W = 66\r\n\r\nfunction clamp(v: number, min: number, max: number): number {\r\n return Math.min(max, Math.max(min, v))\r\n}\r\n\r\n/** '#rrggbb' for a 0-255 RGB triple, in the caller's case. */\r\nfunction toHex(rgb: [number, number, number]): string {\r\n return '#' + rgb.map(v => Math.round(v).toString(16).padStart(2, '0')).join('')\r\n}\r\n\r\n/**\r\n * A single numeric field that edits one color channel. Keeps its own text\r\n * while focused so typing never gets clobbered by the parent re-rendering the\r\n * canonical value; commits every valid keystroke live and re-normalizes on\r\n * blur. The value prop only pushes back in when the field is not focused\r\n * (wheel drags, wallpaper extraction, mode switches).\r\n */\r\nfunction NumField({ label, value, min, max, step, onChange }: {\r\n label: string; value: number; min: number; max: number; step: number\r\n onChange: (v: number) => void\r\n}) {\r\n const [text, setText] = useState(String(value))\r\n const focused = useRef(false)\r\n\r\n useEffect(() => {\r\n if (!focused.current) setText(String(value))\r\n }, [value])\r\n\r\n return (\r\n <label className=\"dab-field\">\r\n <span className=\"dab-field-label\">{label}</span>\r\n <input\r\n type=\"number\"\r\n min={min} max={max} step={step}\r\n value={text}\r\n className=\"dab-num\"\r\n onFocus={() => { focused.current = true }}\r\n onBlur={() => { focused.current = false; setText(String(value)) }}\r\n onChange={e => {\r\n setText(e.target.value)\r\n const v = Number(e.target.value)\r\n if (Number.isFinite(v)) onChange(clamp(v, min, max))\r\n }}\r\n />\r\n </label>\r\n )\r\n}\r\n\r\n/**\r\n * Precise color entry next to the wheel: a HSL/RGB segmented toggle plus three\r\n * numeric channel fields and a live preview field that prints its own hex. The\r\n * wheel is HSV end-to-end, so this panel converts at the boundary — HSL fields\r\n * map straight onto the stored HSL, RGB fields round-trip through rgbToHsl —\r\n * and both emit HSV via the same onChange the wheel uses, keeping one canonical\r\n * color.\r\n */\r\nexport function ColorInputs({ hue, sat, lit, onChange }: {\r\n hue: number; sat: number; lit: number\r\n onChange: (h: number, s: number, l: number) => void\r\n}) {\r\n const [mode, setMode] = useState<Mode>('hsl')\r\n const [h, s, l] = hsvToHsl(hue, sat, lit)\r\n const [r, g, b] = hslToRgb(h, s, l)\r\n const hex = toHex([r, g, b]).toUpperCase()\r\n // Ink for the hex printed ON the preview field. Rec.709 luma is the\r\n // brightness measure the wallpaper extractor already uses, so the two agree:\r\n // a light color gets dark ink and a dark one light ink, and the value never\r\n // disappears into its own fill.\r\n const ink = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255 > 0.55 ? 'rgba(0,0,0,.78)' : 'rgba(255,255,255,.92)'\r\n\r\n const setHsl = (nh: number, ns: number, nl: number) => onChange(...hslToHsv(nh, ns, nl))\r\n const setRgb = (nr: number, ng: number, nb: number) => {\r\n const [nh, ns, nl] = rgbToHsl(nr, ng, nb)\r\n onChange(...hslToHsv(nh, ns, nl))\r\n }\r\n\r\n return (\r\n <div className=\"dab-inputs\">\r\n <div className=\"dab-seg\" style={{ '--w': `${SEG_W}px` } as CSSProperties}>\r\n <div className=\"dab-seg-thumb\" style={{ transform: `translateX(${mode === 'hsl' ? 0 : SEG_W}px)` }} />\r\n <button type=\"button\" className={`dab-seg-item${mode === 'hsl' ? ' is-active' : ''}`} onClick={() => setMode('hsl')}>HSL</button>\r\n <button type=\"button\" className={`dab-seg-item${mode === 'rgb' ? ' is-active' : ''}`} onClick={() => setMode('rgb')}>RGB</button>\r\n </div>\r\n <div style={{ display: 'flex', flexDirection: 'column', gap: 7 }}>\r\n {mode === 'hsl' ? (\r\n <>\r\n <NumField label=\"H\" value={Math.round(h)} min={0} max={360} step={1} onChange={v => setHsl(v, s, l)} />\r\n <NumField label=\"S\" value={Math.round(s * 100)} min={0} max={100} step={1} onChange={v => setHsl(h, v / 100, l)} />\r\n <NumField label=\"L\" value={Math.round(l * 100)} min={0} max={100} step={1} onChange={v => setHsl(h, s, v / 100)} />\r\n </>\r\n ) : (\r\n <>\r\n <NumField label=\"R\" value={r} min={0} max={255} step={1} onChange={v => setRgb(v, g, b)} />\r\n <NumField label=\"G\" value={g} min={0} max={255} step={1} onChange={v => setRgb(r, v, b)} />\r\n <NumField label=\"B\" value={b} min={0} max={255} step={1} onChange={v => setRgb(r, g, v)} />\r\n </>\r\n )}\r\n </div>\r\n {/* Prints its own value. An empty colored rectangle sitting in the same\r\n column as the H/S/L fields reads as one more text input — and there is\r\n nothing to type into it, so the value it is showing has to be visible\r\n on it. Without the hex this was the one control in the panel that\r\n looked editable and was not. */}\r\n <div\r\n className=\"dab-swatch-lg\"\r\n style={{ background: `hsl(${Math.round(h)} ${Math.round(s * 100)}% ${Math.round(l * 100)}%)`, color: ink }}>\r\n {hex}\r\n </div>\r\n </div>\r\n )\r\n}\r\n","import { useRef, useState, useEffect, useCallback } from 'react'\r\nimport { rgbToHsl, hslToHsv } from '../utils/color'\r\nimport { Portal } from './Portal'\r\n\r\nconst MAG_SIZE = 96\r\nconst MAG_ZOOM = 8\r\n\r\nfunction toHex(rgb: [number, number, number]): string {\r\n return '#' + rgb.map(v => v.toString(16).padStart(2, '0')).join('')\r\n}\r\n\r\n/**\r\n * Eyedropper modal: shows the wallpaper full-bleed (no drag/zoom) and lets the\r\n * user click any pixel to adopt it as the theme color. A magnifier circle\r\n * follows the cursor so small details can be picked precisely. The wallpaper\r\n * is a data URL, so sampling is CORS-free: draw it once to an offscreen-sized\r\n * canvas and read pixels via getImageData.\r\n */\r\nexport function ColorPicker({ url, t, onPick, onClose }: {\r\n url: string\r\n t: (key: string) => string\r\n onPick: (hsv: [number, number, number]) => void\r\n onClose: () => void\r\n}) {\r\n const canvasRef = useRef<HTMLCanvasElement>(null)\r\n const magRef = useRef<HTMLCanvasElement>(null)\r\n const imgRef = useRef<HTMLImageElement | null>(null)\r\n const [ready, setReady] = useState(false)\r\n const [hover, setHover] = useState<{ rgb: [number, number, number] } | null>(null)\r\n const [mag, setMag] = useState<{ x: number; y: number } | null>(null)\r\n\r\n useEffect(() => {\r\n const img = new Image()\r\n img.onload = () => { imgRef.current = img; setReady(true) }\r\n img.src = url\r\n }, [url])\r\n\r\n useEffect(() => {\r\n if (!ready || !canvasRef.current || !imgRef.current) return\r\n const canvas = canvasRef.current\r\n canvas.width = imgRef.current.naturalWidth\r\n canvas.height = imgRef.current.naturalHeight\r\n const ctx = canvas.getContext('2d')\r\n if (ctx) ctx.drawImage(imgRef.current, 0, 0)\r\n }, [ready])\r\n\r\n const sampleAt = useCallback((clientX: number, clientY: number) => {\r\n const canvas = canvasRef.current\r\n if (!canvas) return null\r\n const rect = canvas.getBoundingClientRect()\r\n if (rect.width === 0 || rect.height === 0) return null\r\n const ctx = canvas.getContext('2d')\r\n if (!ctx) return null\r\n const sx = Math.round((clientX - rect.left) * (canvas.width / rect.width))\r\n const sy = Math.round((clientY - rect.top) * (canvas.height / rect.height))\r\n if (sx < 0 || sy < 0 || sx >= canvas.width || sy >= canvas.height) return null\r\n const d = ctx.getImageData(sx, sy, 1, 1).data\r\n return { sx, sy, rgb: [d[0], d[1], d[2]] as [number, number, number] }\r\n }, [])\r\n\r\n const drawMagnifier = useCallback((sx: number, sy: number) => {\r\n const mag = magRef.current\r\n const src = canvasRef.current\r\n if (!mag || !src) return\r\n const ctx = mag.getContext('2d')\r\n if (!ctx) return\r\n const half = MAG_SIZE / MAG_ZOOM / 2\r\n ctx.clearRect(0, 0, MAG_SIZE, MAG_SIZE)\r\n ctx.drawImage(src, sx - half, sy - half, half * 2, half * 2, 0, 0, MAG_SIZE, MAG_SIZE)\r\n ctx.strokeStyle = 'rgba(255,255,255,0.85)'\r\n ctx.lineWidth = 1\r\n ctx.beginPath()\r\n ctx.moveTo(MAG_SIZE / 2, 0); ctx.lineTo(MAG_SIZE / 2, MAG_SIZE)\r\n ctx.moveTo(0, MAG_SIZE / 2); ctx.lineTo(MAG_SIZE, MAG_SIZE / 2)\r\n ctx.stroke()\r\n }, [])\r\n\r\n const onMove = (e: React.MouseEvent) => {\r\n const s = sampleAt(e.clientX, e.clientY)\r\n if (!s) { setHover(null); setMag(null); return }\r\n setHover({ rgb: s.rgb })\r\n drawMagnifier(s.sx, s.sy)\r\n const off = 28\r\n let x = e.clientX + off\r\n let y = e.clientY + off\r\n if (x + MAG_SIZE > window.innerWidth) x = e.clientX - off - MAG_SIZE\r\n if (y + MAG_SIZE > window.innerHeight) y = e.clientY - off - MAG_SIZE\r\n setMag({ x, y })\r\n }\r\n\r\n const onClick = (e: React.MouseEvent) => {\r\n const s = sampleAt(e.clientX, e.clientY)\r\n if (!s) return\r\n const [h, sl, l] = rgbToHsl(s.rgb[0], s.rgb[1], s.rgb[2])\r\n onPick(hslToHsv(h, sl, l))\r\n }\r\n\r\n return (\r\n <Portal>\r\n <div className=\"dab-overlay\">\r\n <div className=\"dab-overlay-title\">{t('pickerTitle')}</div>\r\n <div className=\"dab-overlay-hint\">{t('pickerHint')}</div>\r\n <div className=\"dab-modal-card\" style={{\r\n maxWidth: 'min(90vw, 720px)', maxHeight: '60vh', overflow: 'hidden',\r\n borderRadius: 12, border: '2px solid rgba(255,255,255,0.3)', background: '#000', cursor: 'crosshair',\r\n }}>\r\n <canvas ref={canvasRef} style={{ display: 'block', maxWidth: '100%', maxHeight: '60vh', objectFit: 'contain' }}\r\n onMouseMove={onMove}\r\n onMouseLeave={() => { setHover(null); setMag(null) }}\r\n onClick={onClick} />\r\n </div>\r\n <div style={{ display: 'flex', alignItems: 'center', gap: 10, minWidth: 260 }}>\r\n <div style={{ width: 28, height: 28, borderRadius: 8, border: '1px solid rgba(255,255,255,0.4)', background: hover ? toHex(hover.rgb) : 'transparent' }} />\r\n <div style={{ color: '#fff', fontSize: 13, fontFamily: 'var(--dab-mono, monospace)' }}>{hover ? `${toHex(hover.rgb)} · rgb(${hover.rgb.join(', ')})` : '—'}</div>\r\n </div>\r\n <div style={{ display: 'flex', gap: 10 }}>\r\n <button type=\"button\" className=\"dab-btn\" onClick={onClose}>{t('pickerClose')}</button>\r\n </div>\r\n <canvas ref={magRef} width={MAG_SIZE} height={MAG_SIZE}\r\n style={{\r\n position: 'fixed', width: MAG_SIZE, height: MAG_SIZE, borderRadius: '50%',\r\n border: '2px solid rgba(255,255,255,0.7)', boxShadow: '0 4px 16px rgba(0,0,0,0.5)',\r\n zIndex: 10000, background: '#000', pointerEvents: 'none', transition: 'opacity 0.08s',\r\n left: mag?.x ?? 0, top: mag?.y ?? 0, opacity: mag ? 1 : 0,\r\n }} />\r\n </div>\r\n </Portal>\r\n )\r\n}\r\n","import { useRef, useState, useEffect, useCallback } from 'react'\nimport type { BgState } from '../types'\nimport { Portal } from './Portal'\n\n/**\n * Framing editor for one rule's image.\n *\n * The placement state is passed IN rather than read from a global slot: every\n * rule owns its own framing, and editing rule B must never touch rule A.\n */\nexport function BgEditor({ url, state, t, onClose, onCommit }: {\n url: string\n /** The rule's own framing. */\n state: BgState\n t: (key: string) => string; onClose: () => void\n onCommit: (zoom: number, x: number, y: number, iw: number, ih: number) => void\n}) {\n const pw = Math.min(window.innerWidth * 0.75, 860)\n const ph = Math.round(pw * window.innerHeight / window.innerWidth)\n const saved = state\n const [zoom, setZoom] = useState(saved.iw > 0 ? saved.zoom : 1)\n const [pos, setPos] = useState(saved.iw > 0 ? { x: saved.x * pw, y: saved.y * ph } : { x: 0, y: 0 })\n const [imgSize, setImgSize] = useState({ w: 0, h: 0 })\n const containerRef = useRef<HTMLDivElement>(null)\n const imgRef = useRef<HTMLImageElement>(null)\n const dragRef = useRef({ active: false, sx: 0, sy: 0, spx: 0, spy: 0 })\n\n useEffect(() => {\n const img = new Image()\n img.onload = () => {\n const scale = Math.min(pw / img.width, ph / img.height)\n const w = img.width * scale, h = img.height * scale\n setImgSize({ w, h })\n const s = state\n if (s.iw > 0 && s.iw === img.width && s.ih === img.height) {\n setZoom(s.zoom)\n // Saved x, y are CENTER fractions of the preview: the image center\n // lands at (x·pw, y·ph), so the top-left comes from subtracting half\n // the displayed (zoom-scaled) image size.\n setPos({ x: s.x * pw - w * s.zoom / 2, y: s.y * ph - h * s.zoom / 2 })\n } else {\n setZoom(1)\n setPos({ x: (pw - w) / 2, y: (ph - h) / 2 })\n }\n }\n img.src = url\n }, [url, state, pw, ph])\n\n const onDown = useCallback((e: React.MouseEvent) => {\n e.preventDefault()\n dragRef.current = { active: true, sx: e.clientX, sy: e.clientY, spx: pos.x, spy: pos.y }\n const onMove = (ev: MouseEvent) => {\n if (!dragRef.current.active) return\n setPos({ x: dragRef.current.spx + ev.clientX - dragRef.current.sx, y: dragRef.current.spy + ev.clientY - dragRef.current.sy })\n }\n const onUp = () => { dragRef.current.active = false; document.removeEventListener('mousemove', onMove); document.removeEventListener('mouseup', onUp) }\n document.addEventListener('mousemove', onMove); document.addEventListener('mouseup', onUp)\n }, [pos])\n\n const onWheelCb = useCallback((e: WheelEvent) => {\n e.preventDefault()\n const el = containerRef.current\n if (!el) return\n const rect = el.getBoundingClientRect()\n // Anchor the zoom at the preview center so the mouse position never\n // steers where the image grows/shrinks — the current view stays centered.\n const mx = rect.width / 2, my = rect.height / 2\n // 3% per wheel step (0.97 zoom-out / 1.03 zoom-in).\n const factor = e.deltaY > 0 ? 0.97 : 1.03\n const nz = Math.max(0.1, Math.min(10, zoom * factor))\n const nx = mx - (mx - pos.x) * (nz / zoom)\n const ny = my - (my - pos.y) * (nz / zoom)\n setZoom(nz); setPos({ x: nx, y: ny })\n }, [zoom, pos])\n\n useEffect(() => {\n const el = containerRef.current\n if (!el) return\n el.addEventListener('wheel', onWheelCb, { passive: false })\n return () => el.removeEventListener('wheel', onWheelCb)\n }, [onWheelCb])\n\n const resetView = useCallback(() => {\n if (imgSize.w === 0) return\n setZoom(1); setPos({ x: (pw - imgSize.w) / 2, y: (ph - imgSize.h) / 2 })\n }, [pw, ph, imgSize])\n\n return (\n <Portal>\n <div className=\"dab-overlay\" onClick={e => { if (e.target === e.currentTarget) onClose() }}>\n <div className=\"dab-overlay-title\">{t('editorTitle')}</div>\n <div ref={containerRef} className=\"dab-modal-card\" style={{\n position: 'relative', overflow: 'hidden', border: '2px solid rgba(255,255,255,0.3)',\n borderRadius: 12, background: '#000', cursor: 'grab', width: pw, height: ph,\n }} onMouseDown={onDown}>\n <img ref={imgRef} src={url} alt=\"\" draggable={false} style={{\n position: 'absolute', transformOrigin: '0 0', pointerEvents: 'none',\n width: imgSize.w, height: imgSize.h,\n transform: `translate(${pos.x}px,${pos.y}px) scale(${zoom})`,\n }} />\n </div>\n <div className=\"dab-overlay-hint\">{t('editorHint')}</div>\n <div style={{ display: 'flex', gap: 10 }}>\n <button type=\"button\" className=\"dab-btn\" onClick={resetView}>{t('editorReset')}</button>\n <button type=\"button\" className=\"dab-btn\" onClick={onClose}>{t('editorCancel')}</button>\n <button type=\"button\" className=\"dab-btn\" onClick={() => onCommit(zoom, (pos.x + imgSize.w * zoom / 2) / pw, (pos.y + imgSize.h * zoom / 2) / ph, imgRef.current?.naturalWidth ?? 0, imgRef.current?.naturalHeight ?? 0)}>{t('editorCommit')}</button>\n </div>\n </div>\n </Portal>\n )\n}\n","import { useEffect, useRef, useState } from 'react'\nimport type { CSSProperties } from 'react'\nimport type { BgMode, BgRule, ThemeSectionProps, ThemeStoreState } from '../../types'\nimport { cfg, PALETTE } from '../../state'\nimport { matchRule } from '../../modelbg'\nimport { readImg } from '../../utils/image'\nimport { hslToHsv, hsvToHsl, hslToRgb } from '../../utils/color'\nimport { ColorWheel } from '../ColorWheel'\nimport { ColorInputs } from '../ColorInputs'\nimport { ColorPicker } from '../ColorPicker'\nimport { BgEditor } from '../BgEditor'\nimport { LiveSlider } from '../LiveSlider'\nimport { DropletIcon, EditIcon, LinkIcon, PipetteIcon, SparkleIcon, SunIcon, TrashIcon, UploadIcon } from '../icons'\n\nconst BG_MODES: Array<{ mode: BgMode; key: string }> = [\n { mode: 'fit', key: 'bgModeFit' },\n { mode: 'fill', key: 'bgModeFill' },\n { mode: 'stretch', key: 'bgModeStretch' },\n { mode: 'tile', key: 'bgModeTile' },\n { mode: 'center', key: 'bgModeCenter' },\n]\n\n/** Seed color a rule starts from when the user picks one for the first time. */\nconst SEED_COLOR: [number, number, number] = [220, 0.55, 0.25]\n\n/**\n * Failing-hop codes the model watcher can report, mapped to their copy. Only\n * these are rendered: `waiting` and `fallback` already have their own hints.\n */\nconst MODEL_NOTE_KEYS: Record<string, string | undefined> = {\n 'no-service': 'statusNoteNoService',\n 'no-session': 'statusNoteNoSession',\n 'no-projection': 'statusNoteNoProjection',\n 'empty-selection': 'statusNoteEmptySelection',\n}\n\nfunction toHex(rgb: [number, number, number]): string {\n return '#' + rgb.map(v => Math.round(v).toString(16).padStart(2, '0')).join('')\n}\n\nexport function ModelBgPage({ p, notify }: { p: ThemeSectionProps; notify: (msg: string, ok?: boolean) => void }) {\n const { t, useStore } = p\n const store = useStore((s: ThemeStoreState) => s)\n const rules = cfg.rules\n\n // Match tester: the field follows the detected model until the user types\n // their own text, so the card is useful the moment it is looked at and never\n // fights the watcher once it is not. It replaced the old \"active now\" readout —\n // the same question (\"what does this model resolve to?\") one step earlier, and\n // it does not go stale between switches.\n const [text, setText] = useState('')\n const [touched, setTouched] = useState(false)\n useEffect(() => { if (!touched) setText(store.model) }, [store.model, touched])\n const probe = text.trim()\n const result = ((): string | null => {\n if (probe === '') return null\n const hit = matchRule(rules, probe)\n const rule = hit.rule\n if (rule === null) return null\n const n = rules.findIndex(r => r.id === rule.id) + 1\n return `${hit.matched ? t('tryoutHit') : t('tryoutFallback')} ${n}`\n })()\n\n return (\n <>\n <header className=\"dab-head dab-rise\" style={{ '--d': 0 } as CSSProperties}>\n <div className=\"dab-overline\">Rules</div>\n <h2 className=\"dab-h1\">{t('pageModelBg')}</h2>\n <p className=\"dab-desc\">{t('descModelBg')}</p>\n </header>\n\n <section className=\"dab-card dab-rise\" style={{ '--d': 1 } as CSSProperties}>\n <div className=\"dab-swatch-title\">{t('tryoutTitle')}</div>\n <div style={{ marginTop: 10, display: 'flex', flexWrap: 'wrap', gap: 8, alignItems: 'center' }}>\n <input\n type=\"text\" className=\"dab-urlinput\" value={text}\n placeholder={t('tryoutPlaceholder')}\n onChange={e => { setTouched(true); setText(e.target.value) }} />\n {store.model !== '' ? (\n <button type=\"button\" className=\"dab-btn\" onClick={() => { setTouched(true); setText(store.model) }}>\n {t('tryoutUseCurrent')}\n </button>\n ) : null}\n </div>\n <p className=\"dab-hint\" style={{ marginTop: 9 }}>\n {probe === '' ? t('tryoutEmpty') : result === null ? t('tryoutNone') : result}\n </p>\n {/* Why the pre-filled value is what it is: without these, a host default\n passed off as this session's model, or a sessions service that simply\n is not up yet, is indistinguishable from a correct read. */}\n {store.model === '' ? <p className=\"dab-hint\" style={{ marginTop: 6 }}>{t('statusUnknownHint')}</p> : null}\n {store.model !== '' && store.modelSource === 'default'\n ? <p className=\"dab-hint\" style={{ marginTop: 6 }}>{t('statusSourceDefaultHint')}</p>\n : null}\n {MODEL_NOTE_KEYS[store.modelNote] !== undefined\n ? <p className=\"dab-hint\" style={{ marginTop: 6 }}>{t(MODEL_NOTE_KEYS[store.modelNote]!)}</p>\n : null}\n </section>\n\n <section className=\"dab-rise\" style={{ '--d': 2 } as CSSProperties}>\n <div className=\"dab-swatch-title\">{t('rulesTitle')}</div>\n <p className=\"dab-hint\" style={{ marginBottom: 11 }}>{t('rulesHint')}</p>\n\n {/* Picking an image should just theme the rule; this is the off switch\n for people who want the color to be their own choice every time. */}\n <div className=\"dab-chip-row\" style={{ marginBottom: 12, alignItems: 'center' }}>\n <button type=\"button\" className={`dab-toggle${cfg.autoExtract ? ' is-on' : ''}`}\n role=\"switch\" aria-checked={cfg.autoExtract} title={t('autoExtract')}\n onClick={() => p.setAutoExtract(!cfg.autoExtract)}>\n <span className=\"dab-toggle-knob\" />\n </button>\n <span className=\"dab-hint\">{t('autoExtract')}</span>\n </div>\n <p className=\"dab-hint\" style={{ marginBottom: 11 }}>{t('autoExtractHint')}</p>\n\n <div className=\"dab-rules\">\n {rules.map((rule, i) => (\n <RuleCard\n key={rule.id} p={p} rule={rule} index={i} total={rules.length}\n active={rule.id === store.activeRuleId} notify={notify} />\n ))}\n </div>\n\n <button type=\"button\" className=\"dab-btn dab-btn-primary\" style={{ marginTop: 12 }} onClick={() => { p.addRule() }}>\n + {t('ruleAdd')}\n </button>\n </section>\n </>\n )\n}\n\nfunction RuleCard({ p, rule, index, total, active, notify }: {\n p: ThemeSectionProps\n rule: BgRule\n index: number\n total: number\n active: boolean\n notify: (msg: string, ok?: boolean) => void\n}) {\n const { t } = p\n // The active rule opens by default so the panel shows the live one first.\n const [open, setOpen] = useState(active)\n const [dragOver, setDragOver] = useState(false)\n const [urlOpen, setUrlOpen] = useState(false)\n const [urlVal, setUrlVal] = useState('')\n const [urlBusy, setUrlBusy] = useState(false)\n const [urlErr, setUrlErr] = useState<string | null>(null)\n const [editorOpen, setEditorOpen] = useState(false)\n const [pickerOpen, setPickerOpen] = useState(false)\n const [extracting, setExtracting] = useState(false)\n const fileRef = useRef<HTMLInputElement>(null)\n\n const url = p.imageOf(rule.slot)\n const [h, s, l] = rule.color ?? SEED_COLOR\n const wheel = hslToHsv(h, s, l)\n\n const onColor = (nh: number, ns: number, nl: number): void => {\n const [sh, ss, sl] = hsvToHsl(nh, ns, nl)\n p.setRule(rule.id, { color: [sh, ss, sl] })\n }\n\n const onFile = (f: File): void => {\n readImg(f, d => { if (d !== null) p.setRuleImage(rule.id, d) })\n }\n\n const onDrop = (e: React.DragEvent): void => {\n e.preventDefault()\n setDragOver(false)\n const f = e.dataTransfer.files?.[0]\n if (f && f.type.startsWith('image/')) onFile(f)\n }\n\n const applyUrl = async (): Promise<void> => {\n const u = urlVal.trim()\n if (!/^https?:\\/\\//i.test(u)) { setUrlErr(t('ruleUrlBadHttp')); return }\n setUrlBusy(true)\n setUrlErr(null)\n const res = await p.setRuleImageFromUrl(rule.id, u)\n setUrlBusy(false)\n if (res.ok) {\n setUrlOpen(false)\n setUrlVal('')\n } else {\n setUrlErr(res.error === 'invalid url' || res.error === 'unsupported scheme'\n ? t('ruleUrlBadHttp')\n : (res.error ?? t('ruleUrlFail')))\n }\n }\n\n const onExtract = async (): Promise<void> => {\n if (url === null || extracting) return\n setExtracting(true)\n try {\n const ok = await p.extractColor(rule.id)\n notify(ok ? t('extractDone') : t('extractFail'), ok)\n } catch {\n notify(t('extractFail'), false)\n } finally {\n setExtracting(false)\n }\n }\n\n /**\n * Leaving \"follow the system theme\" must not hand the user a color that has\n * nothing to do with the wallpaper they just picked, so this tries the image\n * first and only falls back to the seed. (`extractColor` is the same pass the\n * extract button runs and returns false when nothing vivid was found.)\n */\n const onPickColor = async (): Promise<void> => {\n if (url !== null) {\n setExtracting(true)\n try {\n if (await p.extractColor(rule.id)) return\n } catch {\n // fall through to the seed\n } finally {\n setExtracting(false)\n }\n }\n p.setRule(rule.id, { color: SEED_COLOR })\n }\n\n const cls = `dab-rule${active ? ' is-active' : ''}${rule.enabled ? '' : ' is-off'}`\n\n return (\n <section className={cls}>\n <div className=\"dab-rule-head\">\n <button type=\"button\" className=\"dab-icon-btn\" onClick={() => setOpen(o => !o)}\n title={open ? 'Collapse' : 'Expand'} aria-expanded={open}>\n {open ? '▾' : '▸'}\n </button>\n <span className=\"dab-rule-num\">{index + 1}</span>\n {index === 0 ? <span className=\"dab-rule-badge\">{t('ruleFallbackBadge')}</span> : null}\n <input\n className=\"dab-rule-match\" value={rule.match}\n placeholder={t('ruleMatchPlaceholder')}\n onChange={e => p.setRule(rule.id, { match: e.target.value })} />\n <button type=\"button\" className={`dab-toggle${rule.enabled ? ' is-on' : ''}`}\n role=\"switch\" aria-checked={rule.enabled} title={t('ruleEnabled')}\n onClick={() => p.setRule(rule.id, { enabled: !rule.enabled })}>\n <span className=\"dab-toggle-knob\" />\n </button>\n <button type=\"button\" className=\"dab-icon-btn\" disabled={index === 0}\n title={t('ruleUp')} onClick={() => p.moveRule(rule.id, -1)}>↑</button>\n <button type=\"button\" className=\"dab-icon-btn\" disabled={index === total - 1}\n title={t('ruleDown')} onClick={() => p.moveRule(rule.id, 1)}>↓</button>\n <button type=\"button\" className=\"dab-icon-btn dab-icon-btn-danger\"\n title={t('ruleRemove')} onClick={() => p.removeRule(rule.id)}>\n <TrashIcon size={13} />\n </button>\n </div>\n\n {open ? (\n <div className=\"dab-rule-body\">\n <div className=\"dab-rule-cols\">\n {/* ── image + layout ─────────────────────────────────────────── */}\n <div>\n <div\n className={`dab-rule-thumb${dragOver ? ' is-over' : ''}`}\n onClick={() => fileRef.current?.click()}\n onDragOver={e => { e.preventDefault(); setDragOver(true) }}\n onDragLeave={() => setDragOver(false)}\n onDrop={onDrop}>\n {url !== null\n ? <img src={url} alt=\"\" draggable={false} />\n : (\n <div className=\"dab-rule-thumb-empty\">\n <UploadIcon size={18} />\n <span>{t('ruleNoImage')}</span>\n </div>\n )}\n </div>\n\n <div className=\"dab-chip-row\" style={{ marginTop: 10 }}>\n <button type=\"button\" className=\"dab-btn\" onClick={() => fileRef.current?.click()}>\n <UploadIcon size={13} />{url === null ? t('rulePickImage') : t('ruleChangeImage')}\n </button>\n <button type=\"button\" className=\"dab-btn dab-btn-ghost\" onClick={() => setUrlOpen(o => !o)}>\n <LinkIcon size={13} />{t('ruleFromUrl')}\n </button>\n {url !== null && rule.bgMode === 'fit' ? (\n <button type=\"button\" className=\"dab-btn\" onClick={() => setEditorOpen(true)}>\n <EditIcon size={13} />{t('ruleFramingEdit')}\n </button>\n ) : null}\n {url !== null ? (\n <button type=\"button\" className=\"dab-btn dab-btn-ghost dab-btn-danger\"\n onClick={() => p.setRuleImage(rule.id, null)}>\n <TrashIcon size={13} />{t('ruleImageRemove')}\n </button>\n ) : null}\n </div>\n\n {urlOpen ? (\n <div style={{ marginTop: 10, display: 'flex', flexWrap: 'wrap', gap: 8, alignItems: 'center' }}>\n <input\n type=\"text\" className=\"dab-urlinput\" value={urlVal}\n placeholder={t('ruleUrlPlaceholder')} autoFocus\n onChange={e => setUrlVal(e.target.value)}\n onKeyDown={e => { if (e.key === 'Enter') { e.preventDefault(); void applyUrl() } }} />\n <button type=\"button\" className=\"dab-btn dab-btn-primary\" disabled={urlBusy} onClick={() => void applyUrl()}>\n {urlBusy ? t('ruleUrlApplying') : t('ruleUrlApply')}\n </button>\n <button type=\"button\" className=\"dab-btn\"\n onClick={() => { setUrlOpen(false); setUrlVal(''); setUrlErr(null) }}>\n {t('ruleUrlCancel')}\n </button>\n </div>\n ) : null}\n {urlErr !== null ? (\n <p style={{ marginTop: 8, color: 'var(--dsw-alias-state-error-primary)', fontSize: 12 }}>{urlErr}</p>\n ) : null}\n {url === null ? <p className=\"dab-hint\" style={{ marginTop: 8 }}>{t('ruleEmptyHint')}</p> : null}\n\n <div style={{ marginTop: 14 }}>\n <div className=\"dab-rule-section-title\">{t('ruleLayout')}</div>\n <div className=\"dab-chip-row\">\n {BG_MODES.map(m => (\n <button key={m.mode} type=\"button\"\n className={`dab-chip${rule.bgMode === m.mode ? ' is-active' : ''}`}\n onClick={() => p.setRule(rule.id, { bgMode: m.mode })}>\n {t(m.key)}\n </button>\n ))}\n </div>\n </div>\n </div>\n\n {/* ── color + wallpaper effects ──────────────────────────────── */}\n <div>\n <div className=\"dab-rule-section-title\">{t('ruleColor')}</div>\n {rule.color === null ? (\n <>\n <div className=\"dab-chip-row\">\n {/* This button LEAVES the system-theme state, so it says so:\n the \"系统主题\" label belongs to the clearing button below. */}\n <button type=\"button\" className=\"dab-btn\" disabled={extracting} onClick={() => void onPickColor()}>\n <DropletIcon size={14} />{extracting ? t('extracting') : t('ruleColorPick')}\n </button>\n <button type=\"button\" className=\"dab-btn\" disabled={url === null || extracting} onClick={() => void onExtract()}>\n <SparkleIcon size={14} />{extracting ? t('extracting') : t('ruleColorExtract')}\n </button>\n </div>\n <p className=\"dab-hint\" style={{ marginTop: 8 }}>{t('ruleColorNoneHint')}</p>\n <p className=\"dab-hint\" style={{ marginTop: 6 }}>{t('ruleColorPickHint')}</p>\n </>\n ) : (\n <>\n <div style={{ display: 'flex', gap: 16, alignItems: 'center', flexWrap: 'wrap' }}>\n <ColorWheel hue={wheel[0]} sat={wheel[1]} lit={wheel[2]} onChange={onColor} />\n {/* No hex caption above the toggle any more: the preview\n field inside ColorInputs prints that same value on the\n color itself, where it also explains what the field is. */}\n <div className=\"dab-inputs\">\n <ColorInputs hue={wheel[0]} sat={wheel[1]} lit={wheel[2]} onChange={onColor} />\n </div>\n </div>\n <div className=\"dab-chip-row\" style={{ marginTop: 12 }}>\n <button type=\"button\" className=\"dab-btn\" disabled={url === null || extracting} onClick={() => void onExtract()}>\n <SparkleIcon size={13} />{extracting ? t('extracting') : t('ruleColorExtract')}\n </button>\n <button type=\"button\" className=\"dab-btn\" disabled={url === null} onClick={() => setPickerOpen(true)}>\n <PipetteIcon size={13} />{t('eyedropper')}\n </button>\n {/* Leaves the rule's custom color and hands the interface\n back to the host palette. Carries the sun because that\n is the host's own appearance glyph, and reads as the\n action it performs rather than the state it lands in —\n as a bare \"系统主题\" it looked like the label of whatever\n control sat beside it. */}\n <button type=\"button\" className=\"dab-btn dab-btn-ghost\" onClick={() => p.setRule(rule.id, { color: null })}>\n <SunIcon size={13} />{t('ruleColorNone')}\n </button>\n </div>\n <div className=\"dab-swatches\" style={{ marginTop: 12 }}>\n {PALETTE.map(([sh, ss, sl], i) => (\n <button\n key={i} type=\"button\" className=\"dab-swatch\"\n style={{ background: `hsl(${sh} ${Math.round(ss * 100)}% ${Math.round(sl * 100)}%)` }}\n title={toHex(hslToRgb(sh, ss, sl)).toUpperCase()}\n onClick={() => p.setRule(rule.id, { color: [sh, ss, sl] })} />\n ))}\n </div>\n </>\n )}\n\n <div style={{ marginTop: 16 }}>\n <LiveSlider\n label={t('ruleOpacity')} min={0} max={100} step={1}\n def={Math.round(rule.wallpaperOpacity * 100)} fmt={v => `${v}%`}\n onChange={v => p.setRule(rule.id, { wallpaperOpacity: v / 100 })} />\n <LiveSlider\n label={t('ruleBlur')} min={0} max={60} step={1}\n def={rule.blur} fmt={v => `${v}px`}\n onChange={v => p.setRule(rule.id, { blur: v })} />\n <p className=\"dab-hint\" style={{ marginTop: 10 }}>{t('ruleBlurHint')}</p>\n </div>\n </div>\n </div>\n </div>\n ) : null}\n\n <input ref={fileRef} type=\"file\" accept=\"image/*\" style={{ display: 'none' }} onChange={e => {\n const f = e.target.files?.[0]\n if (!f) return\n onFile(f)\n e.target.value = ''\n }} />\n\n {editorOpen && url !== null ? (\n <BgEditor\n url={url} state={rule.bgState} t={t} onClose={() => setEditorOpen(false)}\n onCommit={(z, x, y, iw, ih) => {\n p.setRule(rule.id, { bgState: { zoom: z, x, y, iw, ih } })\n setEditorOpen(false)\n }} />\n ) : null}\n\n {pickerOpen && url !== null ? (\n <ColorPicker url={url} t={t} onClose={() => setPickerOpen(false)}\n onPick={hsv => { onColor(hsv[0], hsv[1], hsv[2]); setPickerOpen(false) }} />\n ) : null}\n </section>\n )\n}\n","import { useRef } from 'react'\r\nimport type { CSSProperties } from 'react'\r\nimport type { ThemeSectionProps } from '../../types'\r\nimport { DownloadIcon, UploadIcon } from '../icons'\r\n\r\nexport function ProfilePage({ p, notify }: { p: ThemeSectionProps; notify: (msg: string, ok?: boolean) => void }) {\r\n const { t, exportTheme, importTheme } = p\r\n const importRef = useRef<HTMLInputElement>(null)\r\n\r\n const onImport = async (file: File) => {\r\n try {\r\n const ok = await importTheme(file)\r\n notify(ok ? t('importDone') : t('importFail'), ok)\r\n } catch {\r\n notify(t('importFail'), false)\r\n }\r\n }\r\n\r\n return (\r\n <>\r\n <header className=\"dab-head dab-rise\" style={{ '--d': 0 } as CSSProperties}>\r\n <div className=\"dab-overline\">Profile</div>\r\n <h2 className=\"dab-h1\">{t('pageProfile')}</h2>\r\n <p className=\"dab-desc\">{t('descProfile')}</p>\r\n </header>\r\n\r\n <div className=\"dab-profile-grid\">\r\n <section className=\"dab-card dab-card-hover dab-rise\" style={{ '--d': 1 } as CSSProperties}>\r\n <div className=\"dab-profile-ico\"><DownloadIcon size={17} /></div>\r\n <div className=\"dab-profile-title\">{t('exportCardTitle')}</div>\r\n <div className=\"dab-profile-desc\">{t('exportCardDesc')}</div>\r\n <button type=\"button\" className=\"dab-btn dab-btn-primary\" onClick={() => { exportTheme(); notify(t('toastExportDone')) }}>\r\n <DownloadIcon size={14} />{t('exportTheme')}\r\n </button>\r\n </section>\r\n\r\n <section className=\"dab-card dab-card-hover dab-rise\" style={{ '--d': 2 } as CSSProperties}>\r\n <div className=\"dab-profile-ico\"><UploadIcon size={17} /></div>\r\n <div className=\"dab-profile-title\">{t('importCardTitle')}</div>\r\n <div className=\"dab-profile-desc\">{t('importCardDesc')}</div>\r\n <button type=\"button\" className=\"dab-btn\" onClick={() => importRef.current?.click()}>\r\n <UploadIcon size={14} />{t('importTheme')}\r\n </button>\r\n <input ref={importRef} type=\"file\" accept=\"application/json,.json\" style={{ display: 'none' }} onChange={e => {\r\n const f = e.target.files?.[0]; if (!f) return\r\n void onImport(f); e.target.value = ''\r\n }} />\r\n </section>\r\n </div>\r\n\r\n <footer className=\"dab-footer dab-rise\" style={{ '--d': 3 } as CSSProperties}>\r\n <span className=\"dab-footer-mono\">dsh-background-by-model</span>\r\n <span>{t('footerTag')}</span>\r\n </footer>\r\n </>\r\n )\r\n}\r\n","/**\n * dsh-background-by-model — settings section shell.\n *\n * The host renders this section only while the settings dialog is open and the\n * section is the active nav entry, so mounting IS being visible. The section is\n * rendered INLINE inside the host settings dialog's content column (the host\n * provides the modal chrome); the shell is a left nav rail + page body. Only\n * the transient toast escapes through a Portal (the shell's container-type\n * containment would otherwise capture its fixed positioning).\n */\nimport { useEffect, useRef, useState } from 'react'\nimport type { ThemeSectionProps } from '../types'\nimport { ensureUiCss, NAV_ITEM_H, NAV_GAP } from './ui.css'\nimport { SunIcon, LayersIcon, PhotoIcon, SlidersIcon, AlertIcon, CheckIcon } from './icons'\nimport { ErrorBoundary } from './ErrorBoundary'\nimport { Portal } from './Portal'\nimport { InterfacePage } from './pages/InterfacePage'\nimport { ModelBgPage } from './pages/ModelBgPage'\nimport { ProfilePage } from './pages/ProfilePage'\n\nexport function ThemeSection(props: ThemeSectionProps) {\n ensureUiCss()\n const { t } = props\n const [page, setPage] = useState(0)\n const [toast, setToast] = useState<{ msg: string; ok: boolean } | null>(null)\n const toastTimer = useRef<number | undefined>(undefined)\n\n useEffect(() => () => window.clearTimeout(toastTimer.current), [])\n\n const notify = (msg: string, ok = true): void => {\n setToast({ msg, ok })\n window.clearTimeout(toastTimer.current)\n toastTimer.current = window.setTimeout(() => setToast(null), 2600)\n }\n\n const pages = [\n { label: t('pageInterface'), Icon: LayersIcon, node: <InterfacePage p={props} /> },\n { label: t('pageModelBg'), Icon: PhotoIcon, node: <ModelBgPage p={props} notify={notify} /> },\n { label: t('pageProfile'), Icon: SlidersIcon, node: <ProfilePage p={props} notify={notify} /> },\n ]\n\n return (\n <ErrorBoundary t={t}>\n <div className=\"dab-root\">\n <div className=\"dab-shell\">\n <nav className=\"dab-nav\">\n <div className=\"dab-brand\">\n <div className=\"dab-brand-tile\"><SunIcon size={15} /></div>\n <div>\n <div className=\"dab-brand-name\">{t('nav')}</div>\n <div className=\"dab-brand-tag\">{t('brandTag')}</div>\n </div>\n </div>\n <div className=\"dab-nav-list\">\n <div className=\"dab-nav-ind\" style={{ transform: `translateY(${page * (NAV_ITEM_H + NAV_GAP)}px)` }} />\n {pages.map((pg, i) => (\n <button\n key={pg.label} type=\"button\"\n className={`dab-nav-item${i === page ? ' is-active' : ''}`}\n onClick={() => setPage(i)}>\n <pg.Icon size={16} />\n <span>{pg.label}</span>\n </button>\n ))}\n </div>\n </nav>\n\n <div className=\"dab-page\" key={page}>\n {pages[page].node}\n </div>\n </div>\n </div>\n\n {toast ? (\n <Portal>\n <div className=\"dab-toast\" role=\"status\">\n <span className={toast.ok ? 'dab-toast-ok' : 'dab-toast-err'}>\n {toast.ok ? <CheckIcon size={14} /> : <AlertIcon size={14} />}\n </span>\n <span>{toast.msg}</span>\n </div>\n </Portal>\n ) : null}\n </ErrorBoundary>\n )\n}\n","/**\n * dsh-background-by-model — browser half entry.\n *\n * Wires the plugin lifecycle: rule resolution against the current model,\n * wallpaper layer, theme skin, viewport watch, i18n, settings-section injection,\n * boot restore and watchdogs. The heavy lifting lives in the sibling modules\n * (state / modelbg / rpc / wallpaper / components).\n */\nimport { defineStore } from './runtime'\nimport type {\n Ctx, RpcResultLike, ThemeSectionProps, PartOpacities, PartBlurs, BgRule, FetchResult, ModelFacts,\n} from './types'\nimport { NS, zh, en } from './i18n'\nimport {\n cfg, adoptConfig, imageOf, displayImageOf, setImage, newRule, nextSlot, nextRuleId, ruleById,\n normalizeRule, setActive, setModelLabel, activeRuleId, activeMatched, modelLabel, rWp, rRightbarOpacity,\n} from './state'\nimport {\n RPC_CHANNEL, initRpc, saveConfig, flushSave, persistConfig, loadPersisted,\n readImage, writeImage, deleteImage, fetchImageUrl, readDefaultModel,\n} from './rpc'\nimport {\n applyWp, teardownWp, applySettingsOverrides, applyRightbarOverrides, SETTINGS_STYLE_RULE, TRAJECTORY_STYLE_RULE,\n RIGHTBAR_STYLE_RULE, INPUT_BLUR_RULE, PLACEHOLDER_RULE, OWN_SCHEME, setHostScheme, refreshSystemTheme,\n watchParts, watchThemeResets,\n} from './wallpaper'\nimport { genTokens, extractWallpaperColor } from './utils/color'\nimport { matchRule, watchModel } from './modelbg'\nimport { ThemeSection } from './components/ThemeSection'\nimport { markOwnSheet } from './components/ui.css'\nimport { SUN_PATHS } from './components/icons'\n\nexport const name = 'dsh-background-by-model'\nexport const inject = ['slots', 'locale', 'theme', 'connection']\n\nconst CUSTOM_ID = 'custom-color'\n\nexport function apply(ctx: Ctx): void {\n // Bind the dedicated `/dsh-background-by-model` RPC caller so the persistence\n // module can reach the node half's file-backed store.\n initRpc((endpoint, payload) =>\n ctx.connection.rpc.call(RPC_CHANNEL, endpoint, payload).then((res: any) => res as RpcResultLike | undefined)\n )\n\n // ── 1. Custom theme skin, driven by the ACTIVE rule's color ────────────────\n let customDispose: (() => void) | null = null\n // Trailing debounce for the theme-skin switch (see applyActive): a color drag\n // would otherwise dispose + re-register + re-activate the host theme on every\n // pointer move.\n let skinTimer: number | null = null\n const registerCustom = (h: number, s: number, l: number): void => {\n customDispose?.()\n try {\n const { colorScheme, tokens } = genTokens(h, s, l)\n customDispose = ctx.theme.register({ id: CUSTOM_ID, colorScheme, tokens })\n } catch {\n // A live registration from an earlier HMR apply pass cannot be torn down\n // here; keep it and activate it below. Without this the duplicate-id\n // throw would abort apply and skip the wallpaper/opacity restore.\n customDispose = null\n }\n // Only activate the custom theme if it is actually registered.\n if (ctx.theme.getTheme().themes.some(t => t.id === CUSTOM_ID)) {\n ctx.theme.setTheme(CUSTOM_ID)\n }\n }\n /** A rule without a saved color means \"follow the system theme\". */\n const dropCustom = (): void => {\n customDispose?.()\n customDispose = null\n try {\n if (ctx.theme.getTheme().preference === CUSTOM_ID) ctx.theme.setTheme('system')\n } catch {\n // A host build without a `system` preference keeps its own choice.\n }\n }\n ctx.effect(() => () => {\n if (skinTimer !== null) window.clearTimeout(skinTimer)\n customDispose?.()\n }, 'dsh-background-by-model: skin dispose')\n\n // ── 2. Gradient CSS (for custom dark themes) + static rules ────────────────\n const styleEl = document.createElement('style')\n styleEl.dataset.plugin = 'dsh-background-by-model'\n markOwnSheet(styleEl)\n // The gradient only applies while applyCustomTokens marks the body with the\n // plugin's own dark-mode value, avoiding matches against the host's attribute.\n styleEl.textContent = `body[data-ds-dark-theme=\"${OWN_SCHEME}\"]::before{content:'';position:fixed;inset:0;z-index:-1;pointer-events:none;background:radial-gradient(ellipse 80% 60% at 50% 0%,rgba(255,255,255,0.03) 0%,transparent 60%)}${SETTINGS_STYLE_RULE}${TRAJECTORY_STYLE_RULE}${RIGHTBAR_STYLE_RULE}${INPUT_BLUR_RULE}` + PLACEHOLDER_RULE\n document.head.appendChild(styleEl)\n ctx.effect(() => () => { styleEl?.parentNode?.removeChild(styleEl) }, 'dsh-background-by-model: gradient')\n\n // ── 3. State store ────────────────────────────────────────────────────────\n let rev = 0\n let rulesRev = 0\n let modelText = ''\n let modelSource: 'session' | 'default' = 'default'\n // Why no per-session model is available yet ('waiting' until the sessions\n // service mounts, then the failing hop, then 'fallback'). Shown by the status\n // readout so a dead hop is never mistaken for a real model.\n let modelNote = 'waiting'\n // Text + source last acted on, so the watch's forced re-emits (and the 1.5 s\n // safety poll) cannot re-run the whole apply while nothing changed.\n let modelKey = '\\u0000'\n const store = defineStore({\n init: () => ({\n url: null as string | null,\n rev: -1,\n rulesRev: -1,\n model: '',\n modelSource: 'session' as 'session' | 'default',\n modelNote: 'waiting',\n activeRuleId: null as string | null,\n matched: false,\n }),\n actions: {\n sync: (d: any, url: string | null, r: number, rr: number, model: string, source: 'session' | 'default', note: string, id: string | null, matched: boolean) => {\n if (r > d.rev) { d.url = url; d.rev = r }\n if (rr > d.rulesRev) d.rulesRev = rr\n d.model = model\n d.modelSource = source\n d.modelNote = note\n d.activeRuleId = id\n d.matched = matched\n },\n },\n })\n let bound: { sync: (...a: any[]) => void } | null = null\n const sync = (): void => {\n rev++\n bound?.sync(rWp(), rev, rulesRev, modelLabel !== '' ? modelLabel : modelText, modelSource, modelNote, activeRuleId, activeMatched)\n }\n\n /**\n * Publish the scheme the host's own preference resolves to. The theme service\n * is the only place that knows it (a custom active theme included); the\n * wallpaper layer needs it to hand `data-ds-dark-theme` back in the host's own\n * form while a color-less rule follows that theme, instead of leaving the flag\n * off — which pins the host to its LIGHT palette on a dark system.\n */\n const syncHostScheme = (): void => {\n try {\n setHostScheme(ctx.theme.getTheme().active.colorScheme === 'dark')\n } catch {\n // A host build without a resolvable snapshot: let the wallpaper layer fall\n // back to the preference the boot script published.\n setHostScheme(null)\n }\n }\n\n /** Resolve the active rule for the current model and repaint everything. */\n const applyActive = (): void => {\n const { rule, matched } = matchRule(cfg.rules, modelText)\n setActive(rule === null ? null : rule.id, matched)\n const color = rule === null ? null : rule.color\n if (skinTimer !== null) window.clearTimeout(skinTimer)\n if (color === null) {\n // Hand the palette back BEFORE the apply below. The theme service's\n // snapshot is what tells the wallpaper layer which scheme the host itself\n // resolves to, and while our custom skin is still active that snapshot\n // reports OUR scheme — the readback would then capture the host's light\n // palette on a dark system and keep painting it (the interface only\n // recovered when some later slider drag happened to re-run an apply).\n // Dropping the skin is idempotent, so it needs none of the debouncing a\n // color drag does.\n skinTimer = null\n dropCustom()\n } else {\n // The skin is a host-visible switch (dispose + register + activate) and is\n // batched; the wallpaper and tokens below land immediately either way.\n skinTimer = window.setTimeout(() => {\n skinTimer = null\n registerCustom(color[0], color[1], color[2])\n }, 60)\n }\n syncHostScheme()\n applyWp()\n sync()\n }\n\n // ── 4. First paint + the AppFrame watch ───────────────────────────────────\n syncHostScheme()\n applyWp()\n sync()\n watchParts()\n\n // ── 5. Model watch ────────────────────────────────────────────────────────\n // The session's own durable model selection is the authority; the host default\n // is only a last resort, and the settings page labels it as such.\n const offModel = watchModel(ctx, (text, label, source, note) => {\n const key = `${text}\\u0001${source}\\u0001${note}`\n if (key === modelKey) return\n const textChanged = text !== modelText\n modelKey = key\n modelText = text\n modelSource = source\n modelNote = note\n setModelLabel(label !== '' ? label : text)\n // A note-only change (e.g. still waiting for the sessions service) must\n // refresh the readout without repainting the whole interface.\n if (textChanged) applyActive()\n else sync()\n })\n ctx.effect(() => () => offModel(), 'dsh-background-by-model: model watch')\n // A trimmed client (or one whose session is not materialized yet) leaves the\n // per-session sources empty; the host's default model is a coarse but honest\n // stand-in, tagged so the UI never claims it is this session's selection.\n void (async () => {\n if (modelText !== '') return\n const fallback = await readDefaultModel()\n if (fallback !== null && modelText === '') {\n modelKey = `${fallback}\\u0001default\\u0001fallback`\n modelText = fallback\n modelSource = 'default'\n modelNote = 'fallback'\n setModelLabel(fallback)\n applyActive()\n }\n })()\n\n // ── 6. Boot restore ───────────────────────────────────────────────────────\n void (async () => {\n const persisted = await loadPersisted()\n if (persisted !== null) {\n adoptConfig(persisted.config)\n const slots = Array.from(new Set([...persisted.slots, ...cfg.rules.map(r => r.slot)]))\n // The active rule's bytes paint first; the remaining slots stream in after\n // so a large multi-rule setup never delays the first frame.\n const priority = matchRule(cfg.rules, modelText).rule\n const first = priority === null ? null : priority.slot\n const order = first === null ? slots : [first, ...slots.filter(s => s !== first)]\n for (const slot of order) {\n if (imageOf(slot) !== null) continue\n const url = await readImage(slot)\n if (url !== null) setImage(slot, url)\n if (slot === first) applyActive()\n }\n }\n applyActive()\n })()\n\n ctx.effect(() => () => { teardownWp() }, 'dsh-background-by-model: wp cleanup')\n\n ctx.effect(() => ctx.on('theme/change', () => {\n // The custom theme's preference lives in memory, so a host adoption can\n // silently reset it; re-assert it while the active rule has a color. Guard\n // on registry presence — registerCustom disposes the old skin first, so\n // during that transient the registry lacks CUSTOM_ID.\n // The resolved scheme is read first: an OS flip while the preference is\n // `system` arrives exactly here, and a color-less rule has to follow it.\n syncHostScheme()\n if (activeRuleColor() !== null) {\n const snapshot = ctx.theme.getTheme()\n if (snapshot.preference !== CUSTOM_ID && snapshot.themes.some(t => t.id === CUSTOM_ID)) {\n ctx.theme.setTheme(CUSTOM_ID)\n }\n }\n applyWp()\n }), 'dsh-background-by-model: theme change')\n\n // Wallpaper placement is computed in absolute viewport pixels, so watch the\n // viewport itself: a fixed inset:0 sentinel's box always equals the viewport,\n // so a ResizeObserver on it catches any viewport change (window resize,\n // monitor moves, panel splitters, zoom); a resolution media query catches\n // DPI-only moves. Re-applies are coalesced to one per animation frame.\n let frame = 0\n const applySoon = (): void => {\n if (frame !== 0) return\n frame = requestAnimationFrame(() => { frame = 0; applyWp() })\n }\n const sentinel = document.createElement('div')\n sentinel.style.cssText = 'position:fixed;inset:0;pointer-events:none;visibility:hidden'\n document.body.append(sentinel)\n const viewportObserver = new ResizeObserver(applySoon)\n viewportObserver.observe(sentinel)\n const dprQuery = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`)\n dprQuery.addEventListener('change', applySoon)\n ctx.effect(() => () => {\n viewportObserver.disconnect()\n dprQuery.removeEventListener('change', applySoon)\n sentinel.remove()\n }, 'dsh-background-by-model: viewport watch')\n\n // ── 7. Locale ─────────────────────────────────────────────────────────────\n ctx.effect(() => ctx.locale.register(NS, { zh, en }) as any, 'dsh-background-by-model: i18n')\n\n /**\n * The automatic half of \"extract from image\": fill a rule's theme color from\n * the picture it just received, but only while the rule has no color at all —\n * a color the user picked (or a previous extraction produced) is never\n * overwritten, so this cannot fight a deliberate choice.\n *\n * The decode is asynchronous, so the \"still empty?\" question is asked AGAIN on\n * arrival: a color chosen while it ran must win over the one being computed.\n */\n const maybeAutoExtract = async (id: string): Promise<void> => {\n if (!cfg.autoExtract) return\n const rule = ruleById(id)\n if (rule === null || rule.color !== null) return\n const url = displayImageOf(rule.slot)\n if (url === null) return\n let hsl: [number, number, number] | null = null\n try { hsl = await extractWallpaperColor(url, rule.bgState) } catch { hsl = null }\n if (hsl === null) return\n const current = ruleById(id)\n if (current === null || current.color !== null) return\n current.color = hsl\n rulesRev++\n saveConfig()\n if (id === activeRuleId) applyActive()\n else sync()\n }\n\n // ── 8. Section injection ──────────────────────────────────────────────────\n // The section's props are built ONCE by the slot host, so anything that changes\n // at runtime rides the store; the two exceptions are the context (needed by the\n // host self-check probe) and the language (read at build time, refreshed when\n // the section is rebuilt).\n const activeLang = (): 'zh' | 'en' => {\n try {\n const snapshot = ctx.locale.getSnapshot()\n return typeof snapshot?.active === 'string' && snapshot.active.toLowerCase().startsWith('zh') ? 'zh' : 'en'\n } catch {\n return 'en'\n }\n }\n /** The model-resolution facts the host self-check reports, read on demand. */\n const readModelFacts = (): ModelFacts => {\n const rule = activeRuleId === null ? null : ruleById(activeRuleId)\n return {\n text: modelText,\n source: modelSource,\n note: modelNote,\n rule: rule === null ? '' : (rule.match !== '' ? rule.match : rule.id),\n matched: activeMatched,\n }\n }\n const sectionInject = (actions: { sync: (...a: any[]) => void }): Omit<ThemeSectionProps, 'useStore'> => {\n bound = actions\n sync()\n return {\n t: ctx.locale.bind(NS),\n ctx,\n lang: activeLang(),\n readModelFacts,\n imageOf: (slot: string) => displayImageOf(slot),\n addRule: (): string => {\n const rule = newRule(nextRuleId(), nextSlot())\n cfg.rules.push(rule)\n rulesRev++\n persistConfig()\n applyActive()\n return rule.id\n },\n removeRule: (id: string): void => {\n const idx = cfg.rules.findIndex(r => r.id === id)\n if (idx < 0) return\n const [rule] = cfg.rules.splice(idx, 1)\n if (rule !== undefined && !cfg.rules.some(r => r.slot === rule.slot)) {\n setImage(rule.slot, null)\n void deleteImage(rule.slot)\n }\n rulesRev++\n persistConfig()\n applyActive()\n },\n moveRule: (id: string, dir: -1 | 1): void => {\n const idx = cfg.rules.findIndex(r => r.id === id)\n const to = idx + dir\n if (idx < 0 || to < 0 || to >= cfg.rules.length) return\n const [rule] = cfg.rules.splice(idx, 1)\n cfg.rules.splice(to, 0, rule!)\n rulesRev++\n persistConfig()\n applyActive()\n },\n setRule: (id: string, patch: Partial<BgRule>): void => {\n const rule = ruleById(id)\n if (rule === null) return\n Object.assign(rule, patch)\n const normalized = normalizeRule(rule)\n if (normalized !== null) Object.assign(rule, normalized)\n rulesRev++\n // Text/color/slider edits arrive per keystroke and per pointer move, so\n // the write is coalesced; structural edits below stay immediate.\n saveConfig()\n if (id === activeRuleId) applyActive()\n else sync()\n },\n setRuleImage: (id: string, dataUrl: string | null): void => {\n const rule = ruleById(id)\n if (rule === null) return\n setImage(rule.slot, dataUrl)\n void (dataUrl === null ? deleteImage(rule.slot) : writeImage(rule.slot, dataUrl))\n if (id === activeRuleId) applyActive()\n else sync()\n // A rule that has never been themed should simply come out themed; an\n // explicit color (or a cleared one the user set on purpose) is left be.\n if (dataUrl !== null) void maybeAutoExtract(id)\n },\n setRuleImageFromUrl: async (id: string, url: string): Promise<FetchResult> => {\n const rule = ruleById(id)\n if (rule === null) return { ok: false, error: 'unknown rule' }\n const res = await fetchImageUrl(rule.slot, url)\n if (res.ok) {\n setImage(rule.slot, res.dataUrl ?? null)\n if (id === activeRuleId) applyActive()\n else sync()\n void maybeAutoExtract(id)\n }\n return res\n },\n extractColor: async (id: string): Promise<boolean> => {\n const rule = ruleById(id)\n if (rule === null) return false\n const url = displayImageOf(rule.slot)\n if (url === null) return false\n const hsl = await extractWallpaperColor(url, rule.bgState)\n if (hsl === null) return false\n rule.color = hsl\n rulesRev++\n saveConfig()\n if (id === activeRuleId) applyActive()\n else sync()\n return true\n },\n setOps: (ops: PartOpacities): void => { cfg.opacities = ops; applyWp(); sync(); saveConfig() },\n setBlurs: (blurs: PartBlurs): void => { cfg.blurs = blurs; applyWp(); sync(); saveConfig() },\n setSop: (v: number): void => { cfg.settingsOpacity = v; applySettingsOverrides(v); saveConfig() },\n // The file-preview panel owns its surface from the first drag on; a null\n // hands it back to the main-background slider.\n setRightbarOpacity: (v: number | null): void => {\n cfg.rightbarOpacity = v\n applyRightbarOverrides(rRightbarOpacity())\n saveConfig()\n },\n setAutoExtract: (v: boolean): void => { cfg.autoExtract = v; saveConfig(); sync() },\n // Download every rule plus its image as one JSON file.\n exportTheme: (): void => {\n const images: Record<string, string> = {}\n for (const rule of cfg.rules) {\n const url = imageOf(rule.slot)\n if (url !== null) images[rule.slot] = url\n }\n const payload = {\n version: 3,\n exportedAt: new Date().toISOString(),\n config: cfg,\n images,\n }\n const blob = new Blob([JSON.stringify(payload, null, 2)], { type: 'application/json' })\n const url = URL.createObjectURL(blob)\n const a = document.createElement('a')\n a.href = url\n a.download = 'dsh-background-by-model-theme.json'\n a.click()\n URL.revokeObjectURL(url)\n },\n // Import: replaces the whole rule set and every rule image.\n importTheme: async (file: File): Promise<boolean> => {\n try {\n const data: unknown = JSON.parse(await file.text())\n if (!data || typeof data !== 'object') return false\n const d = data as { version?: number; config?: unknown; images?: unknown }\n if (typeof d.config !== 'object' || d.config === null) return false\n adoptConfig(d.config)\n const incoming = (d.images ?? {}) as Record<string, unknown>\n const keep = new Set<string>()\n for (const rule of cfg.rules) {\n keep.add(rule.slot)\n const raw = incoming[rule.slot]\n if (typeof raw === 'string' && /^data:image\\//.test(raw)) {\n setImage(rule.slot, raw)\n void writeImage(rule.slot, raw)\n } else {\n setImage(rule.slot, null)\n void deleteImage(rule.slot)\n }\n }\n // Slots the imported config no longer references are released.\n for (const slot of Object.keys(incoming)) {\n if (!keep.has(slot) && /^[A-Za-z0-9_-]{1,32}$/.test(slot)) void deleteImage(slot)\n }\n persistConfig()\n applyActive()\n return true\n } catch {\n return false\n }\n },\n }\n }\n ctx.slots.inject('settings.section', () => ctx.slots.register({\n name: 'settings.section', id: 'dsh-background-by-model', order: 35,\n label: () => ctx.locale.bind(NS)('nav'),\n locale: NS, store, inject: sectionInject,\n }, ThemeSection as any))\n\n // ── 9. Settings-nav icon ──────────────────────────────────────────────────\n // The harness derives the nav glyph from the section id (unknown ids fall back\n // to the settings gear) with no plugin hook, so patch the mounted nav cell in\n // place — find the cell whose label matches this section's nav text and swap\n // its svg for the sun glyph.\n const navLabel = (): string => ctx.locale.bind(NS)('nav')\n const applyNavIcon = (): void => {\n const panel = document.querySelector<HTMLElement>('[role=\"dialog\"][aria-modal=\"true\"][aria-labelledby]')\n const nav = panel?.querySelector('nav')\n if (!nav) return\n const target = navLabel()\n for (const cell of Array.from(nav.querySelectorAll('button'))) {\n const label = cell.querySelector('span')\n if (label && label.textContent?.trim() === target) {\n const svg = cell.querySelector('svg')\n if (svg && svg.dataset.dshAnyIcon !== '1') {\n const sun = document.createElementNS('http://www.w3.org/2000/svg', 'svg')\n sun.setAttribute('width', '16')\n sun.setAttribute('height', '16')\n sun.setAttribute('viewBox', '0 0 16 16')\n sun.setAttribute('fill', 'none')\n sun.setAttribute('xmlns', 'http://www.w3.org/2000/svg')\n sun.dataset.dshAnyIcon = '1'\n sun.innerHTML = SUN_PATHS\n svg.replaceWith(sun)\n }\n return\n }\n }\n }\n let navIconObserver: MutationObserver | null = null\n const watchNavIcon = (): void => {\n if (navIconObserver !== null || typeof MutationObserver === 'undefined') return\n navIconObserver = new MutationObserver(records => {\n // React only when the settings panel (or its nav) is (re)created, so\n // chat-content mutations don't trigger a scan.\n const relevant = records.some(r => {\n for (const n of r.addedNodes) {\n if (n.nodeType !== 1) continue\n const el = n as Element\n if (el.matches?.('[role=\"dialog\"][aria-modal=\"true\"][aria-labelledby]') || el.querySelector?.('[role=\"dialog\"][aria-modal=\"true\"][aria-labelledby]')) return true\n }\n return false\n })\n if (relevant) applyNavIcon()\n })\n navIconObserver.observe(document.body, { childList: true, subtree: true })\n applyNavIcon()\n }\n watchNavIcon()\n ctx.effect(() => () => { navIconObserver?.disconnect(); navIconObserver = null }, 'dsh-background-by-model: nav icon watch')\n\n // ── 10. Deferred boot restore ─────────────────────────────────────────────\n // The theme service and the host settings scope settle asynchronously after\n // this apply, so the synchronous restore can be observed mid-flight — a late\n // host adoption resets the preference, or the presenter re-applies over our\n // overrides. Re-running the restore a few ticks later guarantees the saved\n // records land.\n const restoreSaved = (): void => {\n syncHostScheme()\n const color = activeRuleColor()\n if (color !== null) {\n const snapshot = ctx.theme.getTheme()\n if (!snapshot.themes.some(t => t.id === CUSTOM_ID)) {\n // Theme missing (host adoption dropped it): re-register + activate.\n registerCustom(color[0], color[1], color[2])\n } else if (snapshot.preference !== CUSTOM_ID) {\n // Theme present but inactive: just re-assert the preference. Calling\n // registerCustom here would dispose + re-create the skin, flashing the\n // interface back to the system theme for a frame on every boot.\n ctx.theme.setTheme(CUSTOM_ID)\n }\n }\n applyWp()\n }\n const restoreTimers = [300, 1500].map(delay => window.setTimeout(restoreSaved, delay))\n ctx.effect(() => () => { restoreTimers.forEach(id => window.clearTimeout(id)) }, 'dsh-background-by-model: boot restore')\n\n // ── 11. Theme watchdog ────────────────────────────────────────────────────\n // The theme service keeps only built-in preferences in memory, so ANY\n // host-scope adoption can silently drop the custom theme — reverting the label\n // colors and the inner surfaces to the system palette. While the active rule\n // carries a color, re-register and re-assert on a slow interval.\n //\n // A color-less rule needs the same slow re-check for the opposite reason: it\n // paints from the HOST palette, which the host can re-project (or which the\n // scheme flag can fall behind) with no event of ours to hang a repaint on.\n // Without this, such a rule keeps whatever palette it read first — the light\n // one, if the read happened while the plugin's own light palette was still\n // forcing the flag off — until an unrelated apply happens to run.\n const watchdogId = window.setInterval(() => {\n syncHostScheme()\n const color = activeRuleColor()\n if (color === null) {\n refreshSystemTheme()\n return\n }\n const snapshot = ctx.theme.getTheme()\n let changed = false\n if (!snapshot.themes.some(t => t.id === CUSTOM_ID)) {\n registerCustom(color[0], color[1], color[2])\n changed = true\n } else if (snapshot.preference !== CUSTOM_ID) {\n ctx.theme.setTheme(CUSTOM_ID)\n changed = true\n }\n if (changed) applyWp()\n }, 1000)\n ctx.effect(() => () => { window.clearInterval(watchdogId) }, 'dsh-background-by-model: theme watchdog')\n\n // ── 12. Theme-reset watchdog ──────────────────────────────────────────────\n const disposeThemeResets = watchThemeResets()\n ctx.effect(() => () => { disposeThemeResets() }, 'dsh-background-by-model: theme resets watch')\n\n // ── 13. Flush pending writes on page hide ─────────────────────────────────\n const onPageHide = (): void => flushSave()\n window.addEventListener('pagehide', onPageHide)\n ctx.effect(() => () => window.removeEventListener('pagehide', onPageHide), 'dsh-background-by-model: pagehide flush')\n}\n\n/** Color of the currently active rule, or null when it uses the system theme. */\nfunction activeRuleColor(): [number, number, number] | null {\n if (activeRuleId === null) return null\n const rule = ruleById(activeRuleId)\n return rule === null ? null : rule.color\n}\n"],"mappings":";;;;;;;;;;EAsBA,SAAS,eAA4B;GACnC,IAAI;IAGF,OAAO,QAAQ,+BAA+B;GAChD,QAAQ,CAER;GAEA,OAAO,QAAQ,wCAAwC;EACzD;EAEA,MAAa,cAAmB,aAAa,C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