dsh-fish-ui 0.1.0 → 0.2.0

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/client.js CHANGED
@@ -1,71 +1,2761 @@
1
1
  /**
2
- * dsh-fish-ui — a Maple Mono NF CN finish layer for the DSH Web UI.
2
+ * Deep Fish UI — the blank New Session surface.
3
3
  *
4
- * A pure client half: one stylesheet appended after the shell and theme styles,
5
- * so these declarations win on equal specificity. It deliberately touches only
6
- * typography and a few surface details, leaving colors and layout to the theme
7
- * (deepclear-ui or whatever else is active).
4
+ * The blank home becomes a dotted composition: a dot-matrix portrait on the
5
+ * right and the deepseek / harness wordmark on the left, both driven by one
6
+ * canvas layer registered into `conversation.hero.frame` (the HOC slot that
7
+ * wraps the Conversation scroll body and reports whether the blank home shows).
8
+ * The layer renders the wrapped `children` unchanged and paints below the
9
+ * content (`z-index: -1`, `pointer-events: none`).
10
+ *
11
+ * It also hides the stock home chrome it replaces: the headline, the brand mark,
12
+ * and the official pixel-whale canvas. A faint `dsh-fish-ui` signature sits in
13
+ * the page corner while the home is showing.
14
+ *
15
+ * The stylesheet below also carries the accent half in the same bundle:
16
+ * whale-blue bold runs in chat prose, the whale-blue composer focus ring, and the
17
+ * re-inked diff plates. One install, one stylesheet, one place to tune.
8
18
  */
9
19
  window.__ModuleLoader__.load({
10
20
  id: 'dsh-fish-ui',
11
- factory() {
12
- const CSS = `
21
+ factory(require) {
22
+ const React = require('react')
23
+ const h = React.createElement
24
+
25
+ /* ------------------------------------------------------------ hero mascot */
26
+
27
+ /** Dot grid sampled from the mascot artwork: one hex digit per cell. */
28
+ const FISH_COLUMNS = 104
29
+ const FISH_ROWS = 73
30
+ const FISH_GRID = '00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000066666666666666660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006666666666666600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006666666666666000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000666666666660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000066666666600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000066666666000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006666660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bbbbbbbbbbbbb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000bbbbbb7777777777777bbbbb00000000000000004400000000000000000000000000000000000000000000000000000000000bbbb77777777777777777777777bbbb00000000000000000000000000000000000000000000000000000000000000000000000bbb77777779999999999999977777777bbb0000000000000044400000000000000000000000000000000000000000000000000bb7777779999999999999999999999777777bbb000000000000444000000000000000000000000000000000000000000000000bb77777799999999999999999999999999977777bbb000000000000000000000000000000000000000000000000000006600000bb77777999999999999999999999999999999977777bb0000044400000000000000000000000000000000000000000000666000bb7777999999999999999999999999999990999997777bb00044440000000000000000000000000000000000000000000066666bb777799999999999999999999999999990000099997777bb000040000000000000000000000000000000000000000000006666bb7777999999999999999999999999999900000099999777bb000000000000000000000000000000000000000000000000006666bb77799999999999999999999999999999000000999997777bb0000000000000000000000000000000000000000000000000666bb777799999999999999999999999999999990009999999777bb0000000000000000000000000000000000000000000000000666bb777799999999999999999999999999999999999999999777bb0000000000000000000000000000000000000000000000000666bb777799999999999999999999999999999999999999999770000000000000000000000000000000000000000000000000000666bb7777999999999999999999999999999999999999999997700000000000000000000000000000000000000000000000000006666bb77779999999999999999999999999999999999999997777bb00000000000000000000000000000000000000000000000006666bb7777999999999999999999999999999999999999997777bb0000000000000000000000000000000000000000000000000066660bb777799999999999999999999999999999999999997777bb00000000000000000000000000000000000000000000000000666000bb7777999999999999999999999999999999999977777bb0000000000000000000000000000000000000000000000000006600000bb77777999999999999999999999999999999977777bb000000000000000000000000000000000000000000000000000000000000bbb7777799999999999999999999999999977777bb0000000000000000000000000000000000000000000000000000000000000000bb7777779999999999999999999999777777bbb0000000000000000000000000000000000000000000000000000000000000000000bbb77777777999999999999977777777bbb00000000000000000000000000000000000000000000000000000000000000000000006bbbb77777777777777777777777bbb000000000000000000000000000000000000000000000000000000000000000000000000066666bbbbb777777777777bbbbbb000000000000000000000000000000000000000000000000000000000000000000000000000066666660000bbbbbbbbbbb0000000000000000000000000000000000000000000000000000000000000000000000000000000000666666000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006666000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000066600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
31
+ const GIRL_LINES = '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001221000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000050551247200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e601e8000001b624620000000000000000000000000000000000000000000000000000000000000000000000000000000000061f000000000000ff00068000000000000000000000000000000000000000000000000000000000000000000000000000000004b000000004000300000000090000000000000000000000000000000000000000000000000000000000000000000000000000006c5000600015100520030000080000000000000000000000000000000000000000000000000000000000000000000000000000005000005700000000000400000f55700000000000000000000000000000000000000000000000000000000000000000000000000100020000012125521100000021002800000000000000000000000000000000000000000000000000000000000000000000000070000600003fea779dfff910011000005000000000000000000000000000000000000000000000000000000000000000000000050000000112deb98422225efe10010000ff00000000000000000000000000000000000000000000000000000000000000000000f006000259b233233353322239fb000000099000000000000000000000000000000000000000000000000000000000000000000fd00110f95f52223222233323323cf1000000f000000000000000000000000000000000000000000000000000000000000000007f00001f82a43333333332333333324f2010005c0000000000000000000000000000000000000000000000000000000000000000ff1000f9254333333333333333333223f400000f1000000000000000000000000000000000000000000000000000000000000000f10008e23433333333333333323322333f10000f110000000000000000000000000000000000000000000000000000000000000300001f3333333333333332322234223335d110ff10400000000000000000000000000000000000000000000000000000000000060000983333333333333353222323422326920012f0010000000000000000000000000000000000000000000000000000000000700001d33333333334223239232232632323990000da0300000000000000000000000000000000000000000000000000000000004000059333333333322223337333323523324b70002f0100000000000000000000000000000000000000000000000000000000000f901b5333323333212233322b333326323336c1001f010000000000000000000000000000000000000000000000000000000000cf002b22333332332224343601a333236233237800bf02ee00000000000000000000000000000000000000000000000000000001f00085233324224333332369101a43326323334910fb246d0000000000000000000000000000000000000000000000000000000ff002c22333262273333333492116b733342333452152332b0000000000000000000000000000000000000000000000000000000ff00791234337119333333327a0002c533a31233332223f810000000000000000000000000000000000000000000000000000001ff10d22234338108633332422d00002735612433323313cf300000000000000000000000000000000000000000000000000000001f00a22235339102933322321f0000011287223333273743f80000000000000000000000000000000000000000000000000000000f005242343381118533222618000002104213333324f8433f400000000000000000000000000000000000000000000000000001ff813332243288004825322522102fffff1253323333654344f2000000000000000000000000000000000000000000000000001fc9d823332342b100082453224601fd2f13f9333233234333344f20000000000000000000000000000000000000000000000001f16683233323634100013233324901f72c90f82333342894333335f100000000000000000000000000000000000000000000000f90f453233323751100001163242270bdf3c011423323347e9433336f100000000000000000000000000000000000000000000000dfd4432333326801018d201b46b200572260025333233201afc84349f0000000000000000000000000000000000000000000000001a4323333334900fff7c2017129100b1110083432243f00013dfd97bf000000000000000000000000000000000000000000000000b5333233233806f3a36f000100000010002547322739900000128ffff0000000000000000000000000000000000000000000000cb533325322361f12ccfb0000000000000124b3225733e7000000002bff000000000000000000000000000000000000000000002f4433327322342f00e2251000000000111116b22584333ff9204a00000ff0000000000000000000000000000000000000000001f54433a2642323c9201a1100000000000001023243333325b03d86fced4fe000000000000000000000000000000000000000000f943548724822224200011000000001100000043662334223d100000100100000000000000000000000000000000000000000008e444ff2023932322b20000100002babe00001896932434322780000000000000000000000000000000000000000000000000002f548fa0119276333225100110009f214200000ea33224353222a200000000000000000000000000000000000000000000000002f66eb1001b72343235325211000005343000008f3332234432224a0000000000000000000000000000000000000000000000001fbdf300002e333333239322100000000000000af932222363422226a00000000000000000000000000000000000000000000000fff5100002f434333383238ff10000000000001f8722322353532223b8000000000000000000000000000000000000000000000ff20000ff45b5333323433228bf5100000000112e73232123343422222e900000000000000000000000000000000000000000000f515fef1003a3233223533322389dfff41102612fa33321233335222420fb00000000000000000000000000000000000000000000591010000f622557477323343333be36255411134662222343333222800cf0000000000000000000000000000000000000000000000000005f2236112ff922238333c601111111002f4332227333522246003f10000000000000000000000000000000000000000000000000f3337100006f52323437f201011111101f43322245338836491000fb000000000000000000000000000000000000000000000005623440110001d2253675100000c1f0000fa542224767ef1175b0000ff0000000000000000000000000000000000000000000004734352011000015242207000004f1f2000027d2125df9100065780000ff1000000000000000000000000000000000000000002e9343376001f00009121203b3dd8f324d222022121169100000272a10000ff3000000000000000000000000000000000000006ff2633269710ff0000c12f303fc66e72338eceef21c21410000002622b10001fa6100000000000000000000000000000000009fc1026323a1001f00102c11da02f744332237754ce03f6214000000e9222900005d46200000000000000000000000000000009f50000b3228a000cf0000b7112f00fc444d803a444f30172225100000fe222470001c70a100000000000000000000000000000fc00000b522398001ff1000d2126f000c444f302f444c001f6236a2100002922246000bc00d0000000000000000000000000000fc000008822246a102efb001d112f20018447f100f8463001ff9256ab20003c42224712ab102900000000000000000000000000ff000008b322354b20899f005511af005f9446c000b644d2001ff11536fc001c542222257e100f00000000000000000000000009f200009b3223536a10d46d006113f8001ffa4e20f22c45df7007f303328815056353222129000e3000000000000000000000001d92001aa3222433a201f44f30325ff2000013ff10002faafa0001ff12322904129334422222400d500000000000000000000000995a12a7222234338002e44f62c18ff0000000fd00000ff1000000cf3233440f2195334421223659100000000000000000000000c6322452222243337103a4632910ff100000001000000d200012001f2337712f2018333493112123610000000000000000000000c222242222233333232558325100ff00010000000400000010000025322f10ff201933432ca211287dc200000000000000000017322243222323333229a463228001f10001000000002700000000000df321002f202b323900ae212201cd60000000000000002fd6622243223323332375443222cf01f0000100010000ff000010000001fb00006f20b8322b100ab212101be10000000000000ff3016223322352333237444434225fb1f000000001000000000010000000ff0002fe20284228600598212101f8000000000007f500083223333432333364443439222f21f000000001000000000000000000ef001f9c20235324b008538313009d0000000000ef0000772223333332233554443434422500f1000000000000000000000000009f00089641323422a009234922400e000000000df00001922224333322233a44344443448900f900140000000000000000000000df000d547522233252242246a24109000000009f1000056242253333222323c4433444444f00ff001324200000cf000000000000fa00fc4446222223255222c12b229300000001eb000008312223433322232249444444445cf01fb00111241000df000000133002f100f64446322222322228900c32900000000ab80000082112224333223222244444444448f007f701111224110001246323310ff01fd44444832222322248000172810'
32
+
33
+ /** Grid aspect (width / height), used to keep the portrait undistorted. */
34
+ const GIRL_ASPECT = FISH_COLUMNS / FISH_ROWS
35
+
36
+ /** Wordmark set in dots on the left: two lines, sampled from live text. */
37
+ const LOCKUP_LINES = ['deepseek', 'harness']
38
+ const LOCKUP_COLUMNS = 140
39
+ const LOCKUP_ROWS = 58
40
+
41
+ /** Alpha buckets drawn per frame, so the twinkle costs one fill per level. */
42
+ const LEVELS = 12
43
+ const TAU = Math.PI * 2
44
+
45
+ /**
46
+ * Twinkle refresh rate. The field is dense, so the frame budget is kept
47
+ * loose: slow alpha breathing reads the same at 16 fps, and the canvas is
48
+ * only alive while the blank home is on screen.
49
+ */
50
+ const FRAME_MS = 1000 / 30
51
+
52
+ /** One dot's cell in CSS pixels: fixed, so dots never scale with the window. */
53
+ const DOT_PITCH = 9
54
+
55
+ /** Smallest dot pitch the wordmark may use before it is dropped. */
56
+ const TEXT_MIN_PITCH = 3.6
57
+
58
+ /** Wordmark assembly: dots reveal left to right over this long. */
59
+ const ASSEMBLY_MS = 1300
60
+
61
+ /** Each line's slice of the assembly, in timeline fractions: line 1 starts
62
+ * while line 0 is still finishing, so the two never pop at once. */
63
+ const ASSEMBLY_SECOND_LINE = 0.42
64
+ const ASSEMBLY_LINE_SPAN = 0.58
65
+
66
+ /** Temporary on-canvas readout used to diagnose layout mismatches. */
67
+ const DEBUG = false
68
+
69
+ /** Dot model of the portrait for the light canvas (ink-weighted). */
70
+ let dotModel
71
+
72
+ /** Dot model of the portrait for the dark canvas (line-art weighted). */
73
+ let lineModel
74
+
75
+ /** Dot model of the wordmark, built once by rasterising live text. */
76
+ let lockupModel
77
+
78
+ /**
79
+ * Decode one hex grid into dots: one dot per non-empty cell, weight from the
80
+ * digit, each with its own twinkle phase and speed so the field never blinks
81
+ * in unison.
82
+ * @param cells - one hex digit per grid cell, row-major.
83
+ * @returns dots in normalised space (`u`/`v` 0..1, `a` weight 0..1).
84
+ */
85
+ function decodeGrid(cells) {
86
+ const dots = []
87
+ for (let index = 0; index < cells.length; index += 1) {
88
+ const weight = Number.parseInt(cells[index], 16)
89
+ if (!(weight > 0)) continue
90
+ const row = Math.floor(index / FISH_COLUMNS)
91
+ const column = index % FISH_COLUMNS
92
+ dots.push({
93
+ u: (column + 0.5) / FISH_COLUMNS,
94
+ v: (row + 0.5) / FISH_ROWS,
95
+ a: weight / 15,
96
+ phase: Math.random() * TAU,
97
+ speed: 0.5 + Math.random() * 0.8,
98
+ })
99
+ }
100
+ return dots
101
+ }
102
+
103
+ /**
104
+ * Light canvas: the artwork's ink drives dot weight, so dark hair and the
105
+ * dark dress read dark on the pale canvas.
106
+ * @returns dots in normalised space.
107
+ */
108
+ function mascotDots() {
109
+ if (dotModel === undefined) dotModel = decodeGrid(FISH_GRID)
110
+ return dotModel
111
+ }
112
+
113
+ /**
114
+ * Dark canvas: the dots are light, so the artwork's ink is inverted — skin
115
+ * and the white apron become dense bright dots while ink-heavy hair and the
116
+ * dress fade back into the canvas. Cells with no ink but enclosed by the
117
+ * figure count as full weight, which is what keeps the face from turning
118
+ * into an empty hole.
119
+ * @returns dots in normalised space.
120
+ */
121
+ function invertedDots() {
122
+ if (lineModel !== undefined) return lineModel
123
+ const total = FISH_COLUMNS * FISH_ROWS
124
+ const occupied = new Uint8Array(total)
125
+ const weight = new Float32Array(total)
126
+ for (let index = 0; index < FISH_GRID.length && index < total; index += 1) {
127
+ const value = Number.parseInt(FISH_GRID[index], 16)
128
+ if (!(value > 0)) continue
129
+ occupied[index] = 1
130
+ weight[index] = value / 15
131
+ }
132
+ const rowFirst = new Int32Array(FISH_ROWS).fill(-1)
133
+ const rowLast = new Int32Array(FISH_ROWS).fill(-1)
134
+ const columnFirst = new Int32Array(FISH_COLUMNS).fill(-1)
135
+ const columnLast = new Int32Array(FISH_COLUMNS).fill(-1)
136
+ for (let row = 0; row < FISH_ROWS; row += 1) {
137
+ for (let column = 0; column < FISH_COLUMNS; column += 1) {
138
+ if (occupied[row * FISH_COLUMNS + column] === 0) continue
139
+ if (rowFirst[row] < 0) rowFirst[row] = column
140
+ rowLast[row] = column
141
+ if (columnFirst[column] < 0) columnFirst[column] = row
142
+ columnLast[column] = row
143
+ }
144
+ }
145
+ const dots = []
146
+ for (let row = 0; row < FISH_ROWS; row += 1) {
147
+ for (let column = 0; column < FISH_COLUMNS; column += 1) {
148
+ if (row < columnFirst[column] || row > columnLast[column]) continue
149
+ if (column < rowFirst[row] || column > rowLast[row]) continue
150
+ const index = row * FISH_COLUMNS + column
151
+ const alpha = occupied[index] === 1 ? 1 - weight[index] : 1
152
+ if (alpha < 0.45) continue
153
+ dots.push({
154
+ u: (column + 0.5) / FISH_COLUMNS,
155
+ v: (row + 0.5) / FISH_ROWS,
156
+ a: alpha,
157
+ phase: Math.random() * TAU,
158
+ speed: 0.5 + Math.random() * 0.8,
159
+ })
160
+ }
161
+ }
162
+ lineModel = dots
163
+ return dots
164
+ }
165
+
166
+ /**
167
+ * Rasterise the two wordmark lines with the UI font and reduce them to the
168
+ * same dotted grid the portrait uses.
169
+ * @returns dots in normalised block space (`u`/`v` 0..1, `a` weight 0..1).
170
+ */
171
+ function lockupDots() {
172
+ if (lockupModel !== undefined) return lockupModel
173
+ const supersample = 4
174
+ const family = '"Segoe UI", system-ui, sans-serif'
175
+ // Display treatment: heavy italic with wide tracking, filled solid. Each
176
+ // line is rasterised on its own canvas, so a descender that crosses the
177
+ // other line's band still belongs to its own colour.
178
+ const style = 'italic 700'
179
+ const probe = document.createElement('canvas').getContext('2d')
180
+ probe.font = `${style} 100px ${family}`
181
+ if ('letterSpacing' in probe) probe.letterSpacing = '6px'
182
+ const width = LOCKUP_COLUMNS * supersample
183
+ const height = LOCKUP_ROWS * supersample
184
+ const widest = Math.max(...LOCKUP_LINES.map(line => probe.measureText(line).width), 1)
185
+ const size = ((width * 0.94) / widest) * 100
186
+ const model = LOCKUP_LINES.map((line, lineIndex) => {
187
+ const big = document.createElement('canvas')
188
+ big.width = width
189
+ big.height = height
190
+ const bigContext = big.getContext('2d')
191
+ bigContext.textAlign = 'left'
192
+ bigContext.textBaseline = 'middle'
193
+ if ('letterSpacing' in bigContext) bigContext.letterSpacing = '6px'
194
+ bigContext.font = `${style} ${size.toFixed(1)}px ${family}`
195
+ bigContext.fillStyle = 'rgba(255, 255, 255, 0.92)'
196
+ bigContext.fillText(line, width * 0.02, height * (0.34 + 0.4 * lineIndex))
197
+
198
+ const small = document.createElement('canvas')
199
+ small.width = LOCKUP_COLUMNS
200
+ small.height = LOCKUP_ROWS
201
+ const smallContext = small.getContext('2d')
202
+ smallContext.drawImage(big, 0, 0, LOCKUP_COLUMNS, LOCKUP_ROWS)
203
+ const pixels = smallContext.getImageData(0, 0, LOCKUP_COLUMNS, LOCKUP_ROWS).data
204
+ const dots = []
205
+ for (let index = 0; index < LOCKUP_COLUMNS * LOCKUP_ROWS; index += 1) {
206
+ const alpha = pixels[index * 4 + 3] / 255
207
+ if (alpha < 0.08) continue
208
+ dots.push({
209
+ u: ((index % LOCKUP_COLUMNS) + 0.5) / LOCKUP_COLUMNS,
210
+ v: (Math.floor(index / LOCKUP_COLUMNS) + 0.5) / LOCKUP_ROWS,
211
+ a: Math.min(1, alpha * 1.25),
212
+ phase: Math.random() * TAU,
213
+ speed: 0.5 + Math.random() * 0.8,
214
+ })
215
+ }
216
+ return dots
217
+ })
218
+ lockupModel = model
219
+ return model
220
+ }
221
+
222
+ /**
223
+ * Paint the dot mascot and wordmark into a canvas, twinkling in place.
224
+ * @param canvas - the frame canvas sized to the conversation area.
225
+ * @returns disposer that cancels the animation and observers.
226
+ */
227
+ function attachMascot(canvas) {
228
+ const context = canvas.getContext('2d')
229
+ if (context === null) return () => {}
230
+ const portraitLight = mascotDots()
231
+ const portraitDark = invertedDots()
232
+ const wordmark = lockupDots()
233
+ const motion = window.matchMedia('(prefers-reduced-motion: reduce)')
234
+ let reduced = motion.matches
235
+ const started = performance.now()
236
+ // The reveal clock starts on the first paint that actually has a canvas to draw
237
+ // into, otherwise the animation can finish while the element is still sizing.
238
+ let revealStarted = 0
239
+ let width = 1
240
+ let height = 1
241
+ let dpr = 1
242
+ let frame = 0
243
+ let drawnAt = 0
244
+ let disposed = false
245
+ /** Composer card geometry in canvas coordinates; the composition's bound. */
246
+ let composerLeft = 0
247
+ let composerWidth = 0
248
+ let composerTop = 0
249
+ let composerNode = null
250
+ const composerObserver = new ResizeObserver(() => { readComposer() })
251
+
252
+ /** Re-read the composer card (it mounts with the hero and resizes with it). */
253
+ const readComposer = () => {
254
+ const canvasRect = canvas.getBoundingClientRect()
255
+ // Pick the composer card that actually overlaps this conversation area:
256
+ // hidden or off-screen cards (other panels, mounted shells) must not
257
+ // become the layout bound.
258
+ let node = null
259
+ let rect = null
260
+ for (const candidate of document.querySelectorAll('[data-composer-card]')) {
261
+ const box = candidate.getBoundingClientRect()
262
+ if (box.width < 80 || box.height < 20) continue
263
+ if (box.right <= canvasRect.left || box.left >= canvasRect.right) continue
264
+ if (rect === null || box.width > rect.width) {
265
+ node = candidate
266
+ rect = box
267
+ }
268
+ }
269
+ if (node !== composerNode) {
270
+ composerObserver.disconnect()
271
+ composerNode = node
272
+ if (node !== null) composerObserver.observe(node)
273
+ }
274
+ if (node === null || rect === null) {
275
+ composerLeft = 0
276
+ composerWidth = 0
277
+ composerTop = 0
278
+ return
279
+ }
280
+ composerLeft = rect.left - canvasRect.left
281
+ composerWidth = rect.width
282
+ composerTop = rect.top - canvasRect.top
283
+ }
284
+
285
+ /** Last canvas box in viewport coordinates, for pointer hit-testing. */
286
+ let boxLeft = 0
287
+ let boxTop = 0
288
+ let boxWidth = 0
289
+ let boxHeight = 0
290
+ /** Pointer position in canvas coordinates; inactive while outside. */
291
+ let pointerX = -1e6
292
+ let pointerY = -1e6
293
+ let pointerActive = false
294
+ const onPointerMove = (event) => {
295
+ pointerX = event.clientX - boxLeft
296
+ pointerY = event.clientY - boxTop
297
+ pointerActive = pointerX >= 0 && pointerY >= 0 && pointerX <= boxWidth && pointerY <= boxHeight
298
+ if (pointerActive) {
299
+ trail.push({ x: pointerX, y: pointerY, at: performance.now() })
300
+ if (trail.length > 8) trail.shift()
301
+ spawnRipple()
302
+ }
303
+ if (reduced) paint(performance.now())
304
+ }
305
+ const onPointerLeave = () => { pointerActive = false }
306
+ /** Moving the pointer over the field band leaves a light ripple behind. */
307
+ const spawnRipple = () => {
308
+ const cfg = dcSettings
309
+ if (cfg !== undefined && cfg.ripple === false) return
310
+ const nowMs = performance.now()
311
+ if (nowMs - lastRippleAt < 90) return
312
+ const bandTop = boxHeight - Math.min(440, Math.max(230, boxHeight * 0.4))
313
+ if (pointerY < bandTop) return
314
+ lastRippleAt = nowMs
315
+ fieldRipples.push({ x: pointerX, y: pointerY, at: nowMs })
316
+ if (fieldRipples.length > 8) fieldRipples.shift()
317
+ }
318
+ /** Recent pointer samples so the light leaves a short, fading trail. */
319
+ const trail = []
320
+ /** Click ripples: origin plus start time, oldest first. */
321
+ const ripples = []
322
+ const onPointerDown = (event) => {
323
+ const x = event.clientX - boxLeft
324
+ const y = event.clientY - boxTop
325
+ if (x < 0 || y < 0 || x > boxWidth || y > boxHeight) return
326
+ ripples.push({ x, y, at: performance.now() })
327
+ if (ripples.length > 5) ripples.shift()
328
+ }
329
+
330
+
331
+ const measure = () => {
332
+ const rect = canvas.getBoundingClientRect()
333
+ dpr = Math.min(window.devicePixelRatio || 1, 2)
334
+ width = Math.max(1, rect.width)
335
+ height = Math.max(1, rect.height)
336
+ canvas.width = Math.round(width * dpr)
337
+ canvas.height = Math.round(height * dpr)
338
+ boxLeft = rect.left
339
+ boxTop = rect.top
340
+ boxWidth = width
341
+ boxHeight = height
342
+ readComposer()
343
+ }
344
+
345
+ /**
346
+ * Draw one frame: both groups hold still and only their alpha breathes.
347
+ * @param now - frame timestamp.
348
+ */
349
+ let bgLayer = null
350
+ let bgGlow = null
351
+ let fieldDots = null
352
+ const fieldRipples = []
353
+ let lastRippleAt = 0
354
+ let fieldKeyCache = ''
355
+ let composerFocused = false
356
+ let focusAmount = 0
357
+ let bgKey = ''
358
+
359
+ const paint = (now) => {
360
+ frame = 0
361
+ if (disposed || document.hidden) return
362
+ const cfg = dcSettings
363
+ if (cfg !== undefined && cfg.hero === false) {
364
+ context.setTransform(dpr, 0, 0, dpr, 0, 0)
365
+ context.clearRect(0, 0, width, height)
366
+ frame = requestAnimationFrame(paint)
367
+ return
368
+ }
369
+ if (revealStarted === 0 && width > 200 && height > 200) revealStarted = now
370
+ // The assembly is a short, fast reveal: give it a smoother frame rate
371
+ // than the slow twinkle, then fall back to the cheap cadence.
372
+ const assembling = now - revealStarted < ASSEMBLY_MS + 80
373
+ const interval = (assembling ? 1000 / 60 : FRAME_MS) - 1
374
+ if (!reduced && now - drawnAt < interval) {
375
+ frame = requestAnimationFrame(paint)
376
+ return
377
+ }
378
+ drawnAt = now
379
+ const time = reduced ? 0 : (now - started) / 1000
380
+ const dark = document.body.hasAttribute('data-ds-dark-theme')
381
+ const ink = dark ? '236, 238, 242' : '102, 108, 120'
382
+ // The composer card is the layout's bound: the pair is centred on it and
383
+ // can never be wider than the input box.
384
+ const limit = composerWidth > 160 ? composerWidth : width * 0.94
385
+ const originX = composerWidth > 160 ? composerLeft : (width - limit) / 2
386
+
387
+ // One pitch drives both groups: the wordmark and the portrait always share
388
+ // the same dot size, and that pitch scales with the space available. Two
389
+ // hard bounds: the composer width (the pair never exceeds the input box)
390
+ // and the space above the composer (the pair hangs above it instead of
391
+ // being covered by it).
392
+ const availW = limit * 0.94
393
+ const pairCells = LOCKUP_COLUMNS + FISH_COLUMNS - 30
394
+ const bandTop = composerTop > 140 ? composerTop : height * 0.86
395
+ const heightPitch = Math.max(1, bandTop - 8) / FISH_ROWS
396
+ let pitch = Math.min(DOT_PITCH, availW / pairCells, heightPitch)
397
+ let showText = true
398
+ if (pitch < TEXT_MIN_PITCH) {
399
+ // Only when the type would fall below the readable floor: drop the
400
+ // wordmark and keep the portrait as large as it can be.
401
+ showText = false
402
+ pitch = Math.min(DOT_PITCH, availW / FISH_COLUMNS, heightPitch)
403
+ }
404
+ if (pitch < 2.2) {
405
+ context.setTransform(dpr, 0, 0, dpr, 0, 0)
406
+ context.clearRect(0, 0, width, height)
407
+ return
408
+ }
409
+ const blockW = LOCKUP_COLUMNS * pitch
410
+ const blockH = LOCKUP_ROWS * pitch
411
+ const portraitW = FISH_COLUMNS * pitch
412
+ const portraitH = FISH_ROWS * pitch
413
+ const overlap = Math.max(8, pitch * 30)
414
+ const pairW = blockW + portraitW - overlap
415
+
416
+ // Hang the pair off the composer: the portrait's bottom edge sits on the
417
+ // composer's top edge, and the dot pitch above guaranteed it fits there.
418
+ const portraitY = Math.min(
419
+ Math.max(bandTop - portraitH / 2, 6 + portraitH / 2),
420
+ Math.max(6 + portraitH / 2, height - portraitH / 2 - 6),
421
+ )
422
+ let portraitX
423
+ let blockX = 0
424
+ if (showText) {
425
+ blockX = originX + Math.max(0, (limit - pairW) / 2)
426
+ portraitX = blockX + blockW - overlap + portraitW / 2
427
+ } else {
428
+ portraitX = originX + limit / 2
429
+ }
430
+ // Keep the pair inside the canvas even if the composer rect was odd.
431
+ const minX = portraitW / 2 + 6
432
+ const maxX = Math.max(minX, width - portraitW / 2 - 6)
433
+ portraitX = Math.min(Math.max(portraitX, minX), maxX)
434
+ const blockY = portraitY - blockH / 2
435
+ // The portrait and the wordmark are centred on each other, which leaves their
436
+ // cell rows half a cell apart; nudge the portrait so every dot in the scene
437
+ // (artwork and printed field alike) lands on one single lattice.
438
+ const portraitYAligned = portraitY + pitch / 2
439
+ const portraitRadius = Math.max(0.8, pitch * 0.28)
440
+ const lockupRadius = Math.max(0.8, pitch * 0.34)
441
+
442
+ // A faint dot field under everything, built on the artwork's own pitch and
443
+ // ink so the background reads as part of the same printed sheet.
444
+ // Phase the background lattice onto the artwork's own grid: the wordmark and the
445
+ // portrait already sit on one lattice (their origins differ by a whole number
446
+ // of cells), so matching that phase makes the field read as the same printed
447
+ // sheet instead of a second, offset grid.
448
+ // Artwork dots sit at the CENTRES of their cells (blockX + (col + 0.5) * pitch),
449
+ // so the field has to be phased half a cell further: its dots land exactly on
450
+ // the artwork's dots, like stones on intersections, not inside the squares.
451
+ const phaseX = (((blockX + pitch / 2) % pitch) + pitch) % pitch
452
+ const phaseY = (((blockY + pitch / 2) % pitch) + pitch) % pitch
453
+ const buildKey = pitch.toFixed(3) + '|' + ink + '|' + phaseX.toFixed(3) + '|'
454
+ + phaseY.toFixed(3) + '|' + width + '|' + height + '|' + dpr
455
+ if (buildKey !== bgKey) {
456
+ bgKey = buildKey
457
+ bgLayer = document.createElement('canvas')
458
+ bgLayer.width = Math.max(1, Math.round(width * dpr))
459
+ bgLayer.height = Math.max(1, Math.round(height * dpr))
460
+ const layerContext = bgLayer.getContext('2d')
461
+ if (layerContext === null) {
462
+ bgLayer = null
463
+ } else {
464
+ layerContext.setTransform(dpr, 0, 0, dpr, 0, 0)
465
+ const fieldRadius = Math.max(0.45, pitch * 0.11)
466
+
467
+ // The resting field.
468
+ layerContext.fillStyle = 'rgba(' + ink + ', 0.1)'
469
+ for (let y = phaseY; y < height + pitch; y += pitch) {
470
+ for (let x = phaseX; x < width + pitch; x += pitch) {
471
+ layerContext.beginPath()
472
+ layerContext.arc(x, y, fieldRadius, 0, TAU)
473
+ layerContext.fill()
474
+ }
475
+ }
476
+
477
+ // The focused field: the same lattice, but brighter close to the
478
+ // composer card and fading out with distance, so the click lights the
479
+ // dots around the input rather than the whole page.
480
+ bgGlow = document.createElement('canvas')
481
+ bgGlow.width = bgLayer.width
482
+ bgGlow.height = bgLayer.height
483
+ const glowContext = bgGlow.getContext('2d')
484
+ if (glowContext === null) {
485
+ bgGlow = null
486
+ } else {
487
+ glowContext.setTransform(dpr, 0, 0, dpr, 0, 0)
488
+ const cardLeft = composerWidth > 160 ? composerLeft : (width - limit) / 2
489
+ const cardWidthForGlow = composerWidth > 160 ? composerWidth : limit
490
+ const glowRadiusX = Math.max(160, cardWidthForGlow * 0.55)
491
+ const glowRadiusY = Math.max(150, Math.min(height * 0.3, 260))
492
+ const centerX = cardLeft + cardWidthForGlow / 2
493
+ const centerY = composerTop + 8
494
+ for (let y = phaseY; y < height + pitch; y += pitch) {
495
+ for (let x = phaseX; x < width + pitch; x += pitch) {
496
+ const dx = (x - centerX) / glowRadiusX
497
+ const dy = (y - centerY) / glowRadiusY
498
+ const falloff = Math.exp(-(dx * dx + dy * dy) * 2.1)
499
+ if (falloff < 0.03) continue
500
+ glowContext.fillStyle = 'rgba(' + ink + ', ' + (0.3 * falloff).toFixed(3) + ')'
501
+ glowContext.beginPath()
502
+ glowContext.arc(x, y, fieldRadius, 0, TAU)
503
+ glowContext.fill()
504
+ }
505
+ }
506
+ }
507
+ }
508
+ }
509
+
510
+ // The portrait runs one opacity notch brighter than the wordmark, so the
511
+ // two groups keep separate alpha ladders.
512
+ const portraitPaths = []
513
+ const wordmarkPaths = [[], []]
514
+ for (let level = 0; level < LEVELS; level += 1) {
515
+ portraitPaths.push(new Path2D())
516
+ wordmarkPaths[0].push(new Path2D())
517
+ wordmarkPaths[1].push(new Path2D())
518
+ }
519
+
520
+ // Wordmark assembly: dots light up left to right, with a bright front.
521
+ const assembly = reduced ? 1 : Math.min(1, (now - revealStarted) / ASSEMBLY_MS)
522
+ // The portrait follows the wordmark: a soft vertical wipe grows it downward
523
+ // about a tenth of a second later.
524
+ const portraitProgress = reduced
525
+ ? 1
526
+ : Math.max(0, Math.min(1, ((now - revealStarted) - 140) / 1100))
527
+ while (ripples.length > 0 && now - ripples[0].at > 760) ripples.shift()
528
+ const trailNow = trail.filter(sample => now - sample.at < 420)
529
+ const rippleBoost = (x, y) => {
530
+ let best = 0
531
+ for (const ripple of ripples) {
532
+ const age = (now - ripple.at) / 760
533
+ const radius = age * 640
534
+ const dx = x - ripple.x
535
+ const dy = y - ripple.y
536
+ if (dx * dx + dy * dy > (radius + 200) * (radius + 200)) continue
537
+ const distance = Math.sqrt(dx * dx + dy * dy)
538
+ if (Math.abs(distance - radius) > 160) continue
539
+ const band = Math.exp(-Math.pow((distance - radius) / 44, 2))
540
+ best = Math.max(best, band * (1 - age))
541
+ }
542
+ return 1 + 1.25 * best
543
+ }
544
+ const trailBoost = (x, y) => {
545
+ let best = 0
546
+ for (const sample of trailNow) {
547
+ const age = Math.max(0, (now - sample.at) / 420)
548
+ const dx = x - sample.x
549
+ const dy = y - sample.y
550
+ if (Math.abs(dx) > 260 || Math.abs(dy) > 260) continue
551
+ best = Math.max(best, Math.exp(-(dx * dx + dy * dy) / (2 * 95 * 95)) * (1 - age))
552
+ }
553
+ return 1 + 0.95 * best
554
+ }
555
+ const place = (target, dot, x, y, radius, kind, line) => {
556
+ // The portrait holds a steady level; only the wordmark breathes.
557
+ const breathe = reduced ? 0.6 : 0.5 + 0.5 * Math.sin(time * dot.speed + dot.phase)
558
+ // Ease the wave so the low and high ends linger instead of sweeping
559
+ // through the extremes linearly, which reads as a softer pulse.
560
+ const eased = breathe * breathe * (3 - 2 * breathe)
561
+ let tone = kind === 'portrait' ? dot.a : dot.a * (0.35 + 0.65 * eased)
562
+ if (kind === 'portrait' && portraitProgress < 1) {
563
+ const local = Math.max(0, Math.min(1, (portraitProgress - dot.v * 0.45) / 0.55))
564
+ const wipe = local * local * (3 - 2 * local)
565
+ if (wipe <= 0.004) return
566
+ tone *= wipe
567
+ }
568
+ if (kind === 'wordmark') {
569
+ if (assembly < 1) {
570
+ // Whole-word fade: the line rises as one piece, no left-to-right sweep.
571
+ const offset = line === 1 ? ASSEMBLY_SECOND_LINE : 0
572
+ const progress = Math.max(0, Math.min(1, (assembly - offset) / ASSEMBLY_LINE_SPAN))
573
+ const smooth = progress * progress * (3 - 2 * progress)
574
+ if (smooth <= 0.02) return
575
+ tone *= smooth
576
+ }
577
+ if (pointerActive) tone *= trailBoost(x, y)
578
+ }
579
+ // Ripples are a wordmark effect; the portrait stays untouched.
580
+ if (kind === 'wordmark') tone = Math.min(1, tone * rippleBoost(x, y))
581
+ const level = Math.min(LEVELS - 1, Math.max(0, Math.round(tone * (LEVELS - 1))))
582
+ // Halftone weighting: heavier cells draw slightly larger dots, so the
583
+ // field reads as printed ink rather than a uniform grid.
584
+ const size = radius * (0.82 + 0.36 * dot.a)
585
+ target[level].moveTo(x + size, y)
586
+ target[level].arc(x, y, size, 0, TAU)
587
+ }
588
+ const portrait = dark ? portraitDark : portraitLight
589
+ for (const dot of portrait) {
590
+ place(
591
+ portraitPaths,
592
+ dot,
593
+ portraitX + (dot.u - 0.5) * portraitW,
594
+ portraitYAligned + (dot.v - 0.5) * portraitH,
595
+ portraitRadius,
596
+ 'portrait',
597
+ )
598
+ }
599
+ if (showText) {
600
+ wordmark.forEach((dots, index) => {
601
+ for (const dot of dots) {
602
+ place(
603
+ wordmarkPaths[index],
604
+ dot,
605
+ blockX + dot.u * blockW,
606
+ blockY + dot.v * blockH,
607
+ lockupRadius,
608
+ 'wordmark',
609
+ index,
610
+ )
611
+ }
612
+ })
613
+ }
614
+
615
+ context.setTransform(dpr, 0, 0, dpr, 0, 0)
616
+ context.clearRect(0, 0, width, height)
617
+ // The field is painted after the clear so it survives the frame.
618
+ if (bgLayer !== null && (cfg === undefined || cfg.field !== false)) {
619
+ context.drawImage(bgLayer, 0, 0, width, height)
620
+ }
621
+ const focusTarget = composerFocused ? 1 : 0
622
+ focusAmount += (focusTarget - focusAmount) * 0.14
623
+ if (focusAmount > 0.005 && bgGlow !== null) {
624
+ context.save()
625
+ context.globalAlpha = Math.min(1, focusAmount)
626
+ context.drawImage(bgGlow, 0, 0, width, height)
627
+ context.restore()
628
+ }
629
+
630
+ // The wave field lives on the lattice: the light pattern is pure brightness,
631
+ // and the pointer can nudge dots aside. Nothing follows the cursor and every
632
+ // displaced dot springs straight back to its own cell.
633
+ const fieldKey = width + '|' + height + '|' + pitch.toFixed(3) + '|'
634
+ + phaseX.toFixed(2) + '|' + phaseY.toFixed(2)
635
+ if (fieldKey !== fieldKeyCache) {
636
+ fieldKeyCache = fieldKey
637
+ fieldDots = []
638
+ const bandHeight = Math.min(440, Math.max(230, height * 0.4))
639
+ const bandTop = height - bandHeight
640
+ for (let y = phaseY; y < height + pitch; y += pitch) {
641
+ if (y < bandTop) continue
642
+ const depth = Math.min(1, (y - bandTop) / bandHeight)
643
+ const vertical = depth * depth * (3 - 2 * depth)
644
+ for (let x = phaseX; x < width + pitch; x += pitch) {
645
+ fieldDots.push({ x: x, y: y, vertical: vertical, ox: 0, oy: 0, vx: 0, vy: 0 })
646
+ }
647
+ }
648
+ }
649
+
650
+ if (!reduced && fieldDots !== null && (cfg === undefined || cfg.wave !== false)) {
651
+ const dt = 1 / 30
652
+ const unit = pitch / 8
653
+ const fieldRadius = Math.max(0.45, pitch * 0.11)
654
+ const breathe = 0.86 + 0.14 * Math.sin(time * 0.13)
655
+ const buckets = [[], [], [], [], [], []]
656
+ while (fieldRipples.length > 0 && now - fieldRipples[0].at > 1100) fieldRipples.shift()
657
+ for (const dot of fieldDots) {
658
+
659
+ const warpX = Math.sin(dot.y * 0.006 / unit + time * 0.23) * 30
660
+ + Math.sin(dot.x * 0.003 / unit - time * 0.17) * 20
661
+ const warpY = Math.sin(dot.x * 0.0035 / unit + time * 0.29) * 26
662
+ const u = (dot.x + warpX) / unit
663
+ const v = (dot.y + warpY) / unit
664
+ const field = 0.5
665
+ + 0.3 * Math.sin(u * 0.0035 - time * 0.55)
666
+ + 0.22 * Math.sin(u * 0.0061 + time * 0.37 + v * 0.01)
667
+ + 0.18 * Math.sin(u * 0.0107 - time * 0.29 + v * 0.021)
668
+ + 0.12 * Math.sin(u * 0.0173 + time * 0.83 - v * 0.033)
669
+ let light = Math.max(0, Math.min(1, field)) ** 1.6
670
+ // A touch only adds light: rings race outward and fade, the dots stay put.
671
+ for (const ripple of fieldRipples) {
672
+ const age = (now - ripple.at) / 1100
673
+ const rdx = dot.x - ripple.x
674
+ const rdy = dot.y - ripple.y
675
+ const distance = Math.sqrt(rdx * rdx + rdy * rdy)
676
+ const ring = Math.exp(-Math.pow((distance - age * 420) / 42, 2)) * (1 - age)
677
+ if (ring > 0.001) light += ring * 0.8
678
+ }
679
+ const alpha = dot.vertical * (0.05 + Math.min(1, light) * 0.85) * breathe * (dark ? 1 : 1.2)
680
+ const level = Math.min(5, Math.floor(alpha * 7))
681
+ buckets[level].push(dot.x, dot.y)
682
+ }
683
+ for (let level = 0; level < buckets.length; level += 1) {
684
+ const bucket = buckets[level]
685
+ if (bucket.length === 0) continue
686
+ const alpha = 0.03 + level * 0.105
687
+ context.fillStyle = 'rgba(' + ink + ', ' + alpha.toFixed(3) + ')'
688
+ context.beginPath()
689
+ for (let index = 0; index < bucket.length; index += 2) {
690
+ context.moveTo(bucket[index] + fieldRadius, bucket[index + 1])
691
+ context.arc(bucket[index], bucket[index + 1], fieldRadius, 0, TAU)
692
+ }
693
+ context.fill()
694
+ }
695
+ }
696
+
697
+ const paintGroup = (paths, boost, color) => {
698
+ for (let level = 0; level < LEVELS; level += 1) {
699
+ const alpha = Math.min(1, (0.05 + (level / (LEVELS - 1)) * 0.5) * boost).toFixed(3)
700
+ context.fillStyle = `rgba(${color}, ${alpha})`
701
+ context.fill(paths[level])
702
+ }
703
+ }
704
+ // The portrait's opacity nudge flips with the palette: +10% on the light
705
+ // canvas, and its inverse trim on the dark one, where light dots already
706
+ // read brighter against the canvas.
707
+ paintGroup(portraitPaths, dark ? 1.15 : 1.8, ink)
708
+ if (showText) {
709
+ paintGroup(wordmarkPaths[0], dark ? 1 : 1.2, ink)
710
+ paintGroup(wordmarkPaths[1], dark ? 1 : 1.2, '122, 170, 255')
711
+ }
712
+ if (DEBUG) {
713
+ context.fillStyle = '#ff5555'
714
+ context.font = '12px monospace'
715
+ const readout = [
716
+ 'pitch=' + pitch.toFixed(2) + ' limit=' + limit.toFixed(0) + ' composerTop=' + composerTop.toFixed(0),
717
+ 'canvas=' + width.toFixed(0) + 'x' + height.toFixed(0) + ' dpr=' + dpr + ' showText=' + showText,
718
+ 'portrait=' + portraitW.toFixed(0) + 'x' + portraitH.toFixed(0)
719
+ + ' @ ' + portraitX.toFixed(0) + ',' + portraitY.toFixed(0),
720
+ 'block=' + blockW.toFixed(0) + 'x' + blockH.toFixed(0)
721
+ + ' @ ' + blockX.toFixed(0) + ',' + blockY.toFixed(0),
722
+ ]
723
+ readout.forEach((line, index) => context.fillText(line, 12, 20 + index * 16))
724
+ context.strokeStyle = '#ff5555'
725
+ context.strokeRect(portraitX - portraitW / 2, portraitY - portraitH / 2, portraitW, portraitH)
726
+ context.strokeStyle = '#5599ff'
727
+ context.strokeRect(blockX, blockY, blockW, blockH)
728
+ }
729
+ if (!reduced) frame = requestAnimationFrame(paint)
730
+ }
731
+
732
+ const observer = new ResizeObserver(() => {
733
+ measure()
734
+ if (reduced) paint(performance.now())
735
+ })
736
+ observer.observe(canvas)
737
+ /** Focus inside the composer card lights the field around it. */
738
+ const onFocusChange = () => {
739
+ const active = document.activeElement
740
+ composerFocused = active !== null && active !== document.body
741
+ && typeof active.closest === 'function'
742
+ && active.closest('[data-composer-card]') !== null
743
+ }
744
+ window.addEventListener('focusin', onFocusChange, { passive: true })
745
+ window.addEventListener('focusout', onFocusChange, { passive: true })
746
+ window.addEventListener('pointermove', onPointerMove, { passive: true })
747
+ window.addEventListener('pointerleave', onPointerLeave, { passive: true })
748
+ window.addEventListener('pointerdown', onPointerDown, { passive: true })
749
+ const refresh = () => {
750
+ if (disposed) return
751
+ cancelAnimationFrame(frame)
752
+ frame = 0
753
+ if (!document.hidden) frame = requestAnimationFrame(paint)
754
+ }
755
+ const onMotion = () => { reduced = motion.matches; refresh() }
756
+ const themeObserver = new MutationObserver(refresh)
757
+ themeObserver.observe(document.body, { attributes: true, attributeFilter: ['data-ds-dark-theme'] })
758
+ const unsubscribeSettings = dcSubscribeSettings(refresh)
759
+ motion.addEventListener('change', onMotion)
760
+ document.addEventListener('visibilitychange', refresh)
761
+ measure()
762
+ refresh()
763
+
764
+ return () => {
765
+ disposed = true
766
+ unsubscribeSettings()
767
+ themeObserver.disconnect()
768
+ motion.removeEventListener('change', onMotion)
769
+ document.removeEventListener('visibilitychange', refresh)
770
+ cancelAnimationFrame(frame)
771
+ observer.disconnect()
772
+ composerObserver.disconnect()
773
+ window.removeEventListener('focusin', onFocusChange)
774
+ window.removeEventListener('focusout', onFocusChange)
775
+ window.removeEventListener('pointermove', onPointerMove)
776
+ window.removeEventListener('pointerleave', onPointerLeave)
777
+ window.removeEventListener('pointerdown', onPointerDown)
778
+ }
779
+ }
780
+
781
+ /**
782
+ * Frame layer for the blank home: paint the dot mascot below the content and
783
+ * pass the wrapped scroll body through untouched.
784
+ * @param props - the home flag and the wrapped Conversation body.
785
+ * @returns the layout-neutral frame.
786
+ */
787
+ function HeroFrame({ hero, children }) {
788
+ const { values } = useDcSettings()
789
+ const show = hero === true && values.hero
790
+ const canvasRef = React.useRef(null)
791
+ React.useEffect(() => {
792
+ const canvas = canvasRef.current
793
+ if (!show || canvas === null) return undefined
794
+ return attachMascot(canvas)
795
+ }, [show])
796
+ return h('div', { className: 'dwe-frame' },
797
+ show ? h('div', { key: 'sign', className: 'dwe-sign' }, 'dsh-fish-ui') : null,
798
+ show ? h('canvas', { key: 'mascot', ref: canvasRef, className: 'dwe-whale', 'aria-hidden': 'true' }) : null,
799
+ children)
800
+ }
801
+
802
+
803
+ /* ---------------------------------------------------------------- styles */
804
+
805
+ const CSS = `
806
+ /* Hero frame layer: layout-neutral wrapper (display: contents keeps the wrapped
807
+ scroll body a direct flex item) plus one canvas that sits above the
808
+ Conversation background and below its content. */
809
+ .dwe-frame {
810
+ display: contents;
811
+ }
812
+ .dwe-whale {
813
+ position: absolute;
814
+ inset: 0;
815
+ z-index: -1;
816
+ width: 100%;
817
+ height: 100%;
818
+ display: block;
819
+ pointer-events: none;
820
+ }
821
+
822
+ /* One whale on the blank home: the official pixel whale would otherwise sit
823
+ behind this dot field, so its canvas is hidden. It keeps its slot layer and
824
+ still renders the wrapped content; only its artwork is suppressed. */
825
+ :root:has(canvas.dwe-whale) [data-home-whale] {
826
+ display: none !important;
827
+ }
828
+
829
+ /* Blank-home headline: drop the headline copy and the brand mark
830
+ beside it, leaving the dot portrait alone above the composer. The title group
831
+ is a CSS-module class (matched by its local name inside the hash, scoped by
832
+ the headline ancestor); the mark is the hero's own brand slot, matched by its
833
+ public slot key. If upstream renames either hook the rule simply stops
834
+ applying. */
835
+ :root:has(canvas.dwe-whale) [class*="headline"] [class*="titleGroup"],
836
+ :root:has(canvas.dwe-whale) [data-slot="conversation.hero.brand.mark"] {
837
+ display: none !important;
838
+ }
839
+
840
+
841
+ /* Product signature: only while the blank home is on screen, because the
842
+ element lives inside the hero frame layer. */
843
+ .dwe-sign {
844
+ position: fixed;
845
+ right: 14px;
846
+ bottom: 10px;
847
+ z-index: 2147483000;
848
+ font-size: 11px;
849
+ letter-spacing: 0.08em;
850
+ color: var(--dsw-alias-label-tertiary);
851
+ opacity: 0.28;
852
+ pointer-events: none;
853
+ user-select: none;
854
+ }
855
+
856
+ /* ------------------------------------------------------------------ accents */
857
+
858
+ /* Composer focus: the shipped 0.5px hairline turns whale blue and an inset ring
859
+ thickens the edge. The inset shadow follows the card radius and costs no
860
+ layout, and a focused draft editor is the only trigger — toolbar buttons
861
+ inside the card keep the resting look. */
862
+ /* Frosted composer, but only where something interesting runs behind it: while a
863
+ Session is open the messages scroll under the card, so glass reads as glass. On
864
+ the blank home the card sits on flat dotted paper, where translucency only muddies
865
+ the surface — there it keeps the shipped solid background. */
866
+ /* On the blank home the card must be fully opaque: the shipped menu surface is
867
+ slightly translucent, so the wave field behind it would show through the card as
868
+ moving light bands. */
869
+ /* The blank home keeps the card solid only when frosting is switched off. */
870
+ :root.dc-off-glass body:has(canvas.dwe-whale) [data-composer-card] {
871
+ background: var(--dsw-specific-input-major, var(--dsw-alias-bg-layer-1));
872
+ }
873
+
874
+ :root:not(.dc-off-glass) [data-composer-card] {
875
+ /* Much more translucent than the host surface, with a stronger blur and a touch of
876
+ saturation: the frosted look only reads if the backdrop is actually visible. */
877
+ background:
878
+ linear-gradient(
879
+ 180deg,
880
+ color-mix(in srgb, var(--dsw-alias-label-primary) 7%, transparent),
881
+ color-mix(in srgb, var(--dsw-alias-label-primary) 2%, transparent) 42%,
882
+ transparent
883
+ ),
884
+ color-mix(in srgb, var(--dsw-specific-input-major, var(--dsw-alias-bg-layer-1)) 54%, transparent);
885
+ -webkit-backdrop-filter: blur(26px) saturate(1.25);
886
+ backdrop-filter: blur(26px) saturate(1.25);
887
+ }
888
+
889
+ /* Composer focus: a soft whale-blue ring fades in under the card's own hairline
890
+ instead of recolouring it (a rebinding token switches instantly and reads as a
891
+ pop). Both states declare the same shadow layers so the transition interpolates
892
+ every layer, and the easing starts quickly and settles slowly. */
893
+ /* Focus ring in light grey: the composer is a text surface, so the highlight stays
894
+ neutral and the accent colour is reserved for content. */
895
+ :root {
896
+ --dc-focus-ink: 124, 128, 136;
897
+ }
898
+
899
+ body[data-ds-dark-theme] {
900
+ --dc-focus-ink: 224, 226, 232;
901
+ }
902
+
903
+ :root:not(.dc-off-focusring) [data-composer-card] {
904
+ box-shadow:
905
+ var(--dsw-elevation-soft),
906
+ inset 0 0 0 1px rgba(var(--dc-focus-ink), 0),
907
+ 0 0 0 0 rgba(var(--dc-focus-ink), 0),
908
+ 0 0 12px 0 rgba(var(--dc-focus-ink), 0),
909
+ 0 0 32px 2px rgba(var(--dc-focus-ink), 0);
910
+ transition: box-shadow 240ms cubic-bezier(0.22, 1, 0.36, 1);
911
+ }
912
+
913
+ :root:not(.dc-off-focusring) [data-composer-card]:has(:is([contenteditable="true"], [role="textbox"], textarea):focus) {
914
+ box-shadow:
915
+ var(--dsw-elevation-soft),
916
+ inset 0 0 0 1.2px rgba(var(--dc-focus-ink), 0.92),
917
+ 0 0 0 3px rgba(var(--dc-focus-ink), 0.12),
918
+ 0 0 14px 1px rgba(var(--dc-focus-ink), 0.22),
919
+ 0 0 40px 6px rgba(var(--dc-focus-ink), 0.1);
920
+ }
921
+
922
+ /* --------------------------------------------------- frame-wide ambient layer */
923
+ .dc-overlay {
924
+ position: fixed;
925
+ inset: 0;
926
+ width: 100vw;
927
+ height: 100vh;
928
+ display: block;
929
+ pointer-events: none;
930
+ }
931
+
932
+ /* ------------------------------------------- composer stats in the button row */
933
+ .dc-stats {
934
+ display: inline-flex;
935
+ align-items: center;
936
+ gap: 8px;
937
+ margin-right: 2px;
938
+ color: var(--dsw-alias-label-tertiary);
939
+ font-size: var(--dsh-content-font-size-secondary, 12px);
940
+ font-variant-numeric: tabular-nums;
941
+ line-height: 20px;
942
+ white-space: nowrap;
943
+ user-select: none;
944
+ }
945
+
946
+ .dc-stats-item {
947
+ opacity: 0.85;
948
+ }
949
+
950
+
951
+ /* ---------------------------------------------- reasoning effort celebration */
952
+ body[data-ds-dark-theme] {
953
+ --dc-effort-field: rgba(255, 255, 255, 0.8);
954
+ --dc-effort-ink: rgba(255, 255, 255, 0.95);
955
+ --dc-effort-glow: rgba(255, 255, 255, 0.6);
956
+ }
957
+
958
+ body:not([data-ds-dark-theme]) {
959
+ --dc-effort-field: rgba(58, 62, 72, 0.55);
960
+ --dc-effort-ink: rgba(22, 24, 28, 0.92);
961
+ --dc-effort-glow: rgba(40, 44, 52, 0.4);
962
+ }
963
+
964
+ [data-composer-card] {
965
+ position: relative;
966
+ /* Own stacking context so the field can paint above the card surface but below its
967
+ content without touching the host's children. */
968
+ isolation: isolate;
969
+ }
970
+
971
+ [data-composer-card].dc-effort-on::before {
972
+ content: '';
973
+ position: absolute;
974
+ left: 13%;
975
+ right: 13%;
976
+ bottom: 1px;
977
+ height: 40px;
978
+ z-index: -1;
979
+ pointer-events: none;
980
+ border-radius: 10px;
981
+ opacity: 0.42;
982
+ /* Two vertical highlight bars travel from the middle outwards while the model
983
+ thinks; the third layer is the dot print itself. */
984
+ background-image: linear-gradient(
985
+ 90deg,
986
+ transparent 0%,
987
+ var(--dc-effort-glow) 50%,
988
+ transparent 100%
989
+ ),
990
+ linear-gradient(
991
+ 90deg,
992
+ transparent 0%,
993
+ var(--dc-effort-glow) 50%,
994
+ transparent 100%
995
+ ),
996
+ radial-gradient(
997
+ circle at 1px 1px,
998
+ var(--dc-effort-field) 0.9px,
999
+ transparent 1.15px
1000
+ );
1001
+ background-size: 0% 100%, 0% 100%, 4px 4px;
1002
+ background-repeat: no-repeat, no-repeat, repeat;
1003
+ background-position: 50% 50%, 50% 50%, 0 0;
1004
+ /* Fade the field out towards both edges so it reads as depth, not a band. */
1005
+ -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 26%, #000 74%, transparent 100%);
1006
+ mask-image: linear-gradient(90deg, transparent 0%, #000 26%, #000 74%, transparent 100%);
1007
+ clip-path: inset(0 50% 0 50%);
1008
+ animation: dc-effort-open 800ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
1009
+ }
1010
+
1011
+ [data-composer-card].dc-effort-on::after {
1012
+ content: attr(data-dc-effort);
1013
+ position: absolute;
1014
+ left: 0;
1015
+ right: 0;
1016
+ bottom: 3px;
1017
+ height: 40px;
1018
+ z-index: 2;
1019
+ pointer-events: none;
1020
+ text-align: center;
1021
+ font: italic 900 30px / 40px "Segoe UI", system-ui, sans-serif;
1022
+ letter-spacing: 0.08em;
1023
+ background-image: radial-gradient(
1024
+ circle at 1px 1px,
1025
+ var(--dc-effort-ink) 0.95px,
1026
+ transparent 1.15px
1027
+ );
1028
+ background-size: 3px 3px;
1029
+ -webkit-background-clip: text;
1030
+ background-clip: text;
1031
+ color: transparent;
1032
+ opacity: 0;
1033
+ /* The shadow follows the dot alpha, so the word carries a soft halo. */
1034
+ filter:
1035
+ drop-shadow(0 0 5px rgba(255, 255, 255, 0.4))
1036
+ drop-shadow(0 0 16px rgba(255, 255, 255, 0.2));
1037
+ animation: dc-effort-word 620ms 740ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
1038
+ }
1039
+
1040
+ [data-composer-card].dc-effort-max::after {
1041
+ background-image: radial-gradient(
1042
+ circle at 1px 1px,
1043
+ var(--dc-accent) 0.95px,
1044
+ transparent 1.15px
1045
+ );
1046
+ filter:
1047
+ drop-shadow(0 0 6px rgba(122, 170, 255, 0.75))
1048
+ drop-shadow(0 0 20px rgba(122, 170, 255, 0.45));
1049
+ }
1050
+
1051
+ body:has([data-chat-running]) [data-composer-card].dc-effort-on::before {
1052
+ animation:
1053
+ dc-effort-open 800ms cubic-bezier(0.22, 1, 0.36, 1) forwards,
1054
+ dc-effort-spread 2.2s 900ms ease-out infinite;
1055
+ }
1056
+
1057
+ @keyframes dc-effort-open {
1058
+ from { clip-path: inset(0 50% 0 50%); }
1059
+ to { clip-path: inset(0 0 0 0); }
1060
+ }
1061
+
1062
+ @keyframes dc-effort-word {
1063
+ from { opacity: 0; }
1064
+ to { opacity: 1; }
1065
+ }
1066
+
1067
+ @keyframes dc-effort-spread {
1068
+ 0% {
1069
+ background-size: 12% 100%, 12% 100%, 4px 4px;
1070
+ background-position: 50% 50%, 50% 50%, 0 0;
1071
+ }
1072
+ 100% {
1073
+ background-size: 12% 100%, 12% 100%, 4px 4px;
1074
+ background-position: 0% 50%, 100% 50%, 0 0;
1075
+ }
1076
+ }
1077
+
1078
+ @media (prefers-reduced-motion: reduce) {
1079
+ [data-composer-card].dc-effort-on::before,
1080
+ [data-composer-card].dc-effort-on::after,
1081
+ body:has([data-chat-running]) [data-composer-card].dc-effort-on::before {
1082
+ animation: none;
1083
+ clip-path: inset(0 0 0 0);
1084
+ opacity: 1;
1085
+ }
1086
+ }
1087
+
1088
+
1089
+
1090
+
1091
+ /* ------------------------------------------------------------- startup splash */
1092
+ .dc-splash {
1093
+ position: fixed;
1094
+ inset: 0;
1095
+ z-index: 2147483600;
1096
+ display: flex;
1097
+ align-items: center;
1098
+ justify-content: center;
1099
+ background: #050507;
1100
+ pointer-events: none;
1101
+ animation: dc-splash-out 460ms 1860ms cubic-bezier(0.4, 0, 1, 1) forwards;
1102
+ contain: strict;
1103
+ }
1104
+
1105
+ /* Compositor-only animation: every property below is opacity or transform. */
1106
+ .dc-splash-grid {
1107
+ position: absolute;
1108
+ inset: -2px;
1109
+ background-image: radial-gradient(circle at 1px 1px, rgba(186, 196, 214, 0.5) 0.9px, transparent 1.15px);
1110
+ background-size: 18px 18px;
1111
+ opacity: 0;
1112
+ will-change: opacity;
1113
+ animation: dc-splash-grid-in 620ms 60ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
1114
+ }
1115
+
1116
+ .dc-splash-ring {
1117
+ position: absolute;
1118
+ width: 108vmax;
1119
+ height: 108vmax;
1120
+ border: 1px solid rgba(176, 196, 232, 0.55);
1121
+ border-radius: 50%;
1122
+ opacity: 0;
1123
+ transform: scale(0.08);
1124
+ will-change: transform, opacity;
1125
+ animation: dc-splash-ring 900ms 60ms cubic-bezier(0.16, 0.84, 0.36, 1) forwards;
1126
+ }
1127
+
1128
+ .dc-splash-mark {
1129
+ position: relative;
1130
+ display: flex;
1131
+ flex-direction: column;
1132
+ align-items: center;
1133
+ gap: 0.08em;
1134
+ overflow: hidden;
1135
+ }
1136
+
1137
+ .dc-splash-line {
1138
+ display: block;
1139
+ font: 800 clamp(38px, 7.8vw, 108px) / 1.14 "Segoe UI", system-ui, sans-serif;
1140
+ letter-spacing: 0.09em;
1141
+ color: transparent;
1142
+ background-size: 5px 5px;
1143
+ -webkit-background-clip: text;
1144
+ background-clip: text;
1145
+ opacity: 0;
1146
+ transform: translate3d(0, 14px, 0) scale(0.985);
1147
+ will-change: transform, opacity;
1148
+ animation: dc-splash-line 760ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
1149
+ }
1150
+
1151
+ .dc-splash-deepseek {
1152
+ background-image: radial-gradient(circle at 1px 1px, #eef0f4 1.1px, transparent 1.35px);
1153
+ }
1154
+
1155
+ .dc-splash-harness {
1156
+ background-image: radial-gradient(circle at 1px 1px, #7aaaff 1.1px, transparent 1.35px);
1157
+ animation-delay: 170ms;
1158
+ }
1159
+
1160
+ .dc-splash-sheen {
1161
+ position: absolute;
1162
+ top: -10%;
1163
+ bottom: -10%;
1164
+ left: 0;
1165
+ width: 34%;
1166
+ background: linear-gradient(
1167
+ 90deg,
1168
+ rgba(255, 255, 255, 0) 0%,
1169
+ rgba(255, 255, 255, 0.42) 50%,
1170
+ rgba(255, 255, 255, 0) 100%
1171
+ );
1172
+ opacity: 0;
1173
+ transform: translate3d(-120%, 0, 0);
1174
+ will-change: transform, opacity;
1175
+ animation: dc-splash-sheen 820ms 1080ms cubic-bezier(0.4, 0, 0.6, 1) forwards;
1176
+ }
1177
+
1178
+ .dc-splash-veil {
1179
+ position: absolute;
1180
+ inset: 0;
1181
+ background:
1182
+ radial-gradient(circle at 50% 46%, rgba(0, 0, 0, 0) 38%, rgba(0, 0, 0, 0.62) 100%),
1183
+ linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 26%);
1184
+ }
1185
+
1186
+ @keyframes dc-splash-grid-in {
1187
+ to { opacity: 0.55; }
1188
+ }
1189
+
1190
+ @keyframes dc-splash-ring {
1191
+ 0% { opacity: 0; transform: scale(0.08); }
1192
+ 30% { opacity: 0.5; }
1193
+ 100% { opacity: 0; transform: scale(1.15); }
1194
+ }
1195
+
1196
+ @keyframes dc-splash-line {
1197
+ to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
1198
+ }
1199
+
1200
+ @keyframes dc-splash-sheen {
1201
+ 0% { opacity: 0; transform: translate3d(-120%, 0, 0); }
1202
+ 20% { opacity: 0.9; }
1203
+ 100% { opacity: 0; transform: translate3d(300%, 0, 0); }
1204
+ }
1205
+
1206
+ @keyframes dc-splash-out {
1207
+ to { opacity: 0; visibility: hidden; }
1208
+ }
1209
+
1210
+ @media (prefers-reduced-motion: reduce) {
1211
+ .dc-splash,
1212
+ .dc-splash-grid,
1213
+ .dc-splash-ring,
1214
+ .dc-splash-line,
1215
+ .dc-splash-sheen {
1216
+ animation: none;
1217
+ opacity: 1;
1218
+ transform: none;
1219
+ }
1220
+ }
1221
+
1222
+ /* ------------------------------------------------------------ settings page */
1223
+ .dc-set {
1224
+ max-width: 720px;
1225
+ padding: 4px 2px 24px;
1226
+ color: var(--dsw-alias-label-primary);
1227
+ font-synthesis: none;
1228
+ }
1229
+
1230
+ .dc-set-group {
1231
+ margin: 0 0 22px;
1232
+ padding: 0 0 6px;
1233
+ border-bottom: 1px solid var(--dsw-alias-border-l1);
1234
+ }
1235
+
1236
+ .dc-set-group:last-of-type {
1237
+ border-bottom: 0;
1238
+ }
1239
+
1240
+ .dc-set-group-title {
1241
+ margin: 0 0 6px;
1242
+ color: var(--dsw-alias-label-tertiary);
1243
+ font-size: 11px;
1244
+ font-weight: 600;
1245
+ letter-spacing: 0.08em;
1246
+ text-transform: uppercase;
1247
+ }
1248
+
1249
+ .dc-set-row {
1250
+ display: flex;
1251
+ align-items: center;
1252
+ gap: 16px;
1253
+ padding: 10px 0;
1254
+ }
1255
+
1256
+ .dc-set-text {
1257
+ display: flex;
1258
+ flex-direction: column;
1259
+ gap: 2px;
1260
+ min-width: 0;
1261
+ flex: 1 1 auto;
1262
+ }
1263
+
1264
+ .dc-set-label {
1265
+ font-size: 14px;
1266
+ line-height: 1.4;
1267
+ }
1268
+
1269
+ .dc-set-desc {
1270
+ color: var(--dsw-alias-label-tertiary);
1271
+ font-size: 12px;
1272
+ line-height: 1.45;
1273
+ }
1274
+
1275
+ /* The control is an SVG capsule with a drawn circle knob, so the track ends are
1276
+ exact semicircles and the knob is an exact circle at any zoom. */
1277
+ .dc-switch {
1278
+ flex: none;
1279
+ display: inline-flex;
1280
+ padding: 0;
1281
+ border: 0;
1282
+ border-radius: 14px;
1283
+ background: transparent;
1284
+ cursor: pointer;
1285
+ }
1286
+
1287
+ .dc-switch:focus-visible {
1288
+ outline: 2px solid var(--dsw-focus-ring-color, #7aaaff);
1289
+ outline-offset: 2px;
1290
+ }
1291
+
1292
+ @media (prefers-reduced-motion: reduce) {
1293
+ .dc-switch svg rect,
1294
+ .dc-switch svg g,
1295
+ .dc-switch svg circle {
1296
+ transition: none !important;
1297
+ }
1298
+ }
1299
+
1300
+ .dc-set-footer {
1301
+ display: flex;
1302
+ align-items: center;
1303
+ justify-content: space-between;
1304
+ gap: 12px;
1305
+ padding-top: 8px;
1306
+ }
1307
+
1308
+ .dc-set-reset {
1309
+ padding: 7px 14px;
1310
+ border: 1px solid var(--dsw-alias-border-l2);
1311
+ border-radius: var(--dsw-radius-sm, 6px);
1312
+ background: transparent;
1313
+ color: var(--dsw-alias-label-primary);
1314
+ font: inherit;
1315
+ font-size: 13px;
1316
+ cursor: pointer;
1317
+ }
1318
+
1319
+ .dc-set-reset:hover {
1320
+ background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.1));
1321
+ }
1322
+
1323
+ .dc-set-note {
1324
+ color: var(--dsw-alias-label-tertiary);
1325
+ font-size: 12px;
1326
+ font-variant-numeric: tabular-nums;
1327
+ }
1328
+
1329
+ /* -------------------------------------------------------- sidebar entry + sheet */
1330
+ .dc-foot {
1331
+ display: flex;
1332
+ flex-direction: column;
1333
+ gap: 2px;
1334
+ min-width: 0;
1335
+ }
1336
+
1337
+ .dc-foot-button {
1338
+ position: relative;
1339
+ overflow: hidden;
1340
+ display: flex;
1341
+ align-items: center;
1342
+ gap: 10px;
1343
+ width: 100%;
1344
+ padding: 7px 10px;
1345
+ border: 0;
1346
+ border-radius: var(--dsw-radius-sm, 6px);
1347
+ background: transparent;
1348
+ color: var(--dsw-alias-label-secondary);
1349
+ font: inherit;
1350
+ font-size: 13px;
1351
+ line-height: 20px;
1352
+ text-align: left;
1353
+ cursor: pointer;
1354
+ white-space: nowrap;
1355
+ overflow: hidden;
1356
+ }
1357
+
1358
+ .dc-foot-dots {
1359
+ position: absolute;
1360
+ inset: 0;
1361
+ width: 100%;
1362
+ height: 100%;
1363
+ display: block;
1364
+ pointer-events: none;
1365
+ }
1366
+
1367
+ .dc-foot-button > :not(.dc-foot-dots) {
1368
+ position: relative;
1369
+ z-index: 1;
1370
+ }
1371
+
1372
+ .dc-foot-button:hover {
1373
+ background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.1));
1374
+ color: var(--dsw-alias-label-primary);
1375
+ }
1376
+
1377
+ .dc-foot-button:focus-visible {
1378
+ outline: 2px solid var(--dsw-focus-ring-color, #7aaaff);
1379
+ outline-offset: 1px;
1380
+ }
1381
+
1382
+ .dc-foot-label {
1383
+ overflow: hidden;
1384
+ text-overflow: ellipsis;
1385
+ }
1386
+
1387
+ .dc-sheet-root {
1388
+ position: fixed;
1389
+ inset: 0;
1390
+ z-index: 2147483001;
1391
+ }
1392
+
1393
+ .dc-sheet-scrim {
1394
+ position: absolute;
1395
+ inset: 0;
1396
+ background: rgba(0, 0, 0, 0.28);
1397
+ }
1398
+
1399
+ .dc-sheet-panel {
1400
+ position: absolute;
1401
+ left: 14px;
1402
+ bottom: 78px;
1403
+ width: min(420px, calc(100vw - 28px));
1404
+ max-height: min(72vh, 640px);
1405
+ display: flex;
1406
+ flex-direction: column;
1407
+ border: 0;
1408
+ border-radius: 20px;
1409
+ /* Opaque on purpose: a raised surface layered over the base colour, so the panel is
1410
+ always solid and always uses the app's own palette instead of a hand-picked grey. */
1411
+ background-color: var(--dsw-alias-bg-base, #f6f6f8);
1412
+ background-image: linear-gradient(
1413
+ var(--dsw-alias-bg-layer-1, transparent),
1414
+ var(--dsw-alias-bg-layer-1, transparent)
1415
+ );
1416
+ box-shadow: var(--dsw-elevation-panel, 0 18px 48px rgba(0, 0, 0, 0.42));
1417
+ overflow: hidden;
1418
+ animation: dc-sheet-in 200ms cubic-bezier(0.22, 1, 0.36, 1);
1419
+ }
1420
+
1421
+ @keyframes dc-sheet-in {
1422
+ from { opacity: 0; transform: translateY(8px); }
1423
+ to { opacity: 1; transform: translateY(0); }
1424
+ }
1425
+
1426
+ .dc-sheet-head {
1427
+ display: flex;
1428
+ align-items: center;
1429
+ justify-content: space-between;
1430
+ gap: 12px;
1431
+ padding: 14px 16px 12px;
1432
+ border-bottom: 1px solid var(--dsw-alias-border-l1);
1433
+ }
1434
+
1435
+ .dc-sheet-title {
1436
+ font-size: 14px;
1437
+ font-weight: 600;
1438
+ color: var(--dsw-alias-label-primary);
1439
+ }
1440
+
1441
+ .dc-sheet-close {
1442
+ border: 0;
1443
+ background: transparent;
1444
+ color: var(--dsw-alias-label-tertiary);
1445
+ font-size: 18px;
1446
+ line-height: 1;
1447
+ padding: 2px 6px;
1448
+ border-radius: 6px;
1449
+ cursor: pointer;
1450
+ }
1451
+
1452
+ .dc-sheet-close:hover {
1453
+ background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.1));
1454
+ color: var(--dsw-alias-label-primary);
1455
+ }
1456
+
1457
+ .dc-sheet-body {
1458
+ padding: 4px 16px 8px;
1459
+ overflow-y: auto;
1460
+ }
1461
+
1462
+ @media (prefers-reduced-motion: reduce) {
1463
+ .dc-sheet-panel { animation: none; }
1464
+ }
1465
+ /* fish reading:start */
1466
+ /* Deep Fish reading: semantic hooks only; never animate streamed text. */
1467
+ body {
1468
+ --dc-accent: var(--dsw-alias-link);
1469
+ --dc-focus: color-mix(in srgb, var(--dc-accent) 18%, transparent);
1470
+ }
1471
+
1472
+ :root:not(.dc-off-reading) [data-chat-flow-kind="assistant-step"]:not([data-chat-group-part="reasoning"]) :is(p, li) {
1473
+ line-height: 1.85;
1474
+ text-wrap: pretty;
1475
+ }
1476
+ :root:not(.dc-off-reading) [data-chat-flow-kind="assistant-step"] :is(h1, h2, h3, h4) {
1477
+ color: var(--dsw-alias-label-primary);
1478
+ letter-spacing: -0.015em;
1479
+ line-height: 1.45;
1480
+ text-wrap: balance;
1481
+ }
1482
+ :root:not(.dc-off-reading) [data-chat-flow-kind="assistant-step"] :is(h2, h3) {
1483
+ padding-block-start: 0.25em;
1484
+ }
1485
+ :root:not(.dc-off-reading) [data-chat-flow-kind="assistant-step"] blockquote {
1486
+ border-inline-start: 2px solid color-mix(in srgb, var(--dc-accent) 38%, transparent);
1487
+ padding-inline-start: 1em;
1488
+ color: var(--dsw-alias-label-secondary);
1489
+ }
1490
+ :root:not(.dc-off-reading) [data-chat-flow-kind="assistant-step"] :is(p, li) > code {
1491
+ color: var(--dsw-alias-label-primary);
1492
+ background: var(--dsw-alias-interactive-bg-hover);
1493
+ border-radius: 4px;
1494
+ padding: 0.12em 0.35em;
1495
+ }
1496
+ :root:not(.dc-off-code) [data-chat-flow-kind="assistant-step"] pre {
1497
+ font-variant-ligatures: none;
1498
+ tab-size: 2;
1499
+ }
1500
+ /* Sidebar brand: the whale mark and the product name carry a quiet halo so they read as
1501
+ part of the same light as the accent. */
1502
+ [data-slot="sidebar.brand.mark"] {
1503
+ filter:
1504
+ drop-shadow(0 0 5px color-mix(in srgb, var(--dc-accent) 50%, transparent))
1505
+ drop-shadow(0 0 16px color-mix(in srgb, var(--dc-accent) 26%, transparent));
1506
+ }
1507
+
1508
+ [data-slot="sidebar.brand.name"] {
1509
+ text-shadow:
1510
+ 0 0 1px color-mix(in srgb, var(--dc-accent) 42%, transparent),
1511
+ 0 0 9px color-mix(in srgb, var(--dc-accent) 34%, transparent),
1512
+ 0 0 22px color-mix(in srgb, var(--dc-accent) 18%, transparent);
1513
+ }
1514
+
1515
+ /* User messages carry a whale-blue halo: a hairline ring plus two soft halos. */
1516
+ [data-message-bubble] {
1517
+ box-shadow:
1518
+ 0 0 0 1px color-mix(in srgb, var(--dc-accent) 52%, transparent),
1519
+ 0 0 14px 1px color-mix(in srgb, var(--dc-accent) 22%, transparent),
1520
+ 0 0 38px 8px color-mix(in srgb, var(--dc-accent) 10%, transparent);
1521
+ }
1522
+
1523
+ /* Selected conversation: a flat black plate in dark theme instead of the host's
1524
+ translucent hover fill. */
1525
+ body[data-ds-dark-theme] [class*="_sessionRow"][class*="_selected"] {
1526
+ background-color: #0d0d10;
1527
+ }
1528
+
1529
+ body:not([data-ds-dark-theme]) [class*="_sessionRow"][class*="_selected"] {
1530
+ background-color: #e9e9ec;
1531
+ }
1532
+
1533
+ :root:not(.dc-off-bold) [data-chat-flow-kind="assistant-step"] :is(p, li, td, blockquote) :is(strong, b) {
1534
+ color: var(--dc-accent);
1535
+ /* A soft halo so the accent reads as light rather than paint. */
1536
+ text-shadow:
1537
+ 0 0 1px color-mix(in srgb, var(--dc-accent) 55%, transparent),
1538
+ 0 0 8px color-mix(in srgb, var(--dc-accent) 42%, transparent),
1539
+ 0 0 20px color-mix(in srgb, var(--dc-accent) 22%, transparent);
1540
+ }
1541
+ :root:not(.dc-off-thinkinglabel) [data-chat-running] [class*="_runningText"] {
1542
+ opacity: 0;
1543
+ }
1544
+ :root:not(.dc-off-thinkingsphere) [data-chat-running] [class*="_runningIcon"] {
1545
+ display: none;
1546
+ }
1547
+
1548
+ /* Compact figures leave submit reachable in a narrow composer. */
1549
+ .dc-stats {
1550
+ gap: 10px;
1551
+ font-size: 11px;
1552
+ letter-spacing: 0.015em;
1553
+ font-variant-numeric: tabular-nums;
1554
+ }
1555
+ .dc-stats-label {
1556
+ margin-inline-end: 4px;
1557
+ color: var(--dsw-alias-label-tertiary);
1558
+ font-size: 9px;
1559
+ letter-spacing: 0.06em;
1560
+ }
1561
+ .dc-stats-item { color: var(--dsw-alias-label-secondary); }
1562
+ @media (max-width: 640px) {
1563
+ .dc-stats-label { display: none; }
1564
+ .dc-stats { gap: 6px; }
1565
+ }
1566
+ @media (max-width: 420px) {
1567
+ .dc-stats-output { display: none; }
1568
+ }
1569
+ .dc-switch:disabled { cursor: default; opacity: 0.48; }
1570
+ .dc-set-reset:disabled { cursor: default; opacity: 0.48; }
1571
+ .dc-settings-status {
1572
+ margin: 0 0 16px;
1573
+ font-size: 12px;
1574
+ color: var(--dsw-alias-label-secondary);
1575
+ }
1576
+ .dc-settings-status[role="alert"] { color: var(--dsw-alias-state-error-primary); }
1577
+ @media (prefers-reduced-motion: reduce) {
1578
+ .dc-sheet-panel, .dc-sheet-scrim { animation: none; }
1579
+ [data-composer-card] { transition: none !important; }
1580
+ }
1581
+
1582
+ /* fish reading:end */
1583
+ `
1584
+
1585
+ /* fish indicator:start */
1586
+ /**
1587
+ * Dot sphere and English status label.
1588
+ *
1589
+ * The host text keeps the real clock, so we read the elapsed seconds out of it and
1590
+ * redraw both the words and a sweeping highlight on our own overlay canvas. The host
1591
+ * label is hidden by `reading.css` while this is on; turning it off restores the host
1592
+ * row untouched and only parks the sphere to the left of the visible text.
1593
+ */
1594
+ function DcOverlay() {
1595
+ const canvasRef = React.useRef(null)
1596
+ const settings = useDcSettings()
1597
+ const sphereOn = settings.values.thinkingSphere !== false
1598
+ const labelOn = settings.values.thinkingLabel !== false
1599
+ React.useEffect(() => {
1600
+ const canvas = canvasRef.current
1601
+ if (!canvas) return
1602
+ const context = canvas.getContext('2d')
1603
+ if (!context) return
1604
+ const motion = matchMedia('(prefers-reduced-motion: reduce)')
1605
+ // Wall clock anchor. The host may remount its row on every tick, so an element
1606
+ // keyed start time resets constantly; a single anchor survives those remounts
1607
+ // and is dropped as soon as the row leaves the document.
1608
+ const clock = { since: 0 }
1609
+ let frame = 0
1610
+ let stopped = false
1611
+ const clear = () => context.clearRect(0, 0, canvas.width, canvas.height)
1612
+
1613
+ // The hidden host text cannot be trusted for the clock (its digits are not the
1614
+ // elapsed value), so the label counts wall time from when the running row first
1615
+ // appeared and restarts whenever the row leaves the document.
1616
+ const elapsedOf = (now) => {
1617
+ if (clock.since === 0) clock.since = now
1618
+ return Math.max(0, Math.round((now - clock.since) / 1000))
1619
+ }
1620
+
1621
+ const drawSphere = (cx, cy, spin, ink) => {
1622
+ // Two batched passes: a soft halo under a crisp core, so the sphere reads as
1623
+ // light instead of loose dots. Only 42 dots, so buckets are cheap.
1624
+ const points = []
1625
+ for (let index = 0; index < 42; index += 1) {
1626
+ const v = 1 - (2 * (index + 0.5)) / 42
1627
+ const ring = Math.sqrt(1 - v * v)
1628
+ const angle = index * 2.39996323 + spin
1629
+ const depth = Math.sin(angle) * ring
1630
+ points.push({
1631
+ x: cx + Math.cos(angle) * ring * 8,
1632
+ y: cy + v * 8,
1633
+ alpha: 0.25 + (depth + 1) * 0.32,
1634
+ radius: 0.8 + (depth + 1) * 0.35,
1635
+ })
1636
+ }
1637
+ context.fillStyle = ink
1638
+ const passes = [
1639
+ { grow: 2.1, scale: 0.28 },
1640
+ { grow: 1, scale: 1 },
1641
+ ]
1642
+ for (const pass of passes) {
1643
+ const buckets = new Map()
1644
+ for (const point of points) {
1645
+ const alpha = point.alpha * pass.scale
1646
+ if (alpha < 0.02) continue
1647
+ const level = Math.min(10, Math.max(1, Math.round(alpha * 10)))
1648
+ let bucket = buckets.get(level)
1649
+ if (bucket === undefined) {
1650
+ bucket = new Path2D()
1651
+ buckets.set(level, bucket)
1652
+ }
1653
+ const radius = point.radius * pass.grow
1654
+ bucket.moveTo(point.x + radius, point.y)
1655
+ bucket.arc(point.x, point.y, radius, 0, Math.PI * 2)
1656
+ }
1657
+ for (const [level, path] of buckets) {
1658
+ context.globalAlpha = level / 10
1659
+ context.fill(path)
1660
+ }
1661
+ }
1662
+ context.globalAlpha = 1
1663
+ }
1664
+
1665
+ const drawLabel = (row, label, x, cy, seconds, now, ink) => {
1666
+ const style = getComputedStyle(label)
1667
+ const font = style.fontWeight + ' ' + style.fontSize + ' ' + style.fontFamily
1668
+ context.font = font
1669
+ context.textBaseline = 'middle'
1670
+ const text = 'Deep thinking for ' + seconds + 's. . .'
1671
+ const width = context.measureText(text).width
1672
+ const accent = (getComputedStyle(row).getPropertyValue('--dc-accent') || '').trim() || '#7aaaff'
1673
+ const band = motion.matches ? -1e4 : ((now % 2600) / 2600) * (width + 140) - 70
1674
+ context.save()
1675
+ context.beginPath()
1676
+ context.rect(x - 2, cy - 20, width + 4, 40)
1677
+ context.clip()
1678
+ context.fillStyle = ink
1679
+ context.globalAlpha = 0.92
1680
+ context.fillText(text, x, cy)
1681
+ context.globalAlpha = 1
1682
+ const gradient = context.createLinearGradient(x + band - 70, 0, x + band + 70, 0)
1683
+ gradient.addColorStop(0, 'rgba(122, 170, 255, 0)')
1684
+ gradient.addColorStop(0.5, accent)
1685
+ gradient.addColorStop(1, 'rgba(122, 170, 255, 0)')
1686
+ context.fillStyle = gradient
1687
+ context.fillText(text, x, cy)
1688
+ context.restore()
1689
+ }
1690
+
1691
+ const paint = now => {
1692
+ frame = 0
1693
+ if (stopped || document.hidden) return
1694
+ const dpr = Math.min(2, devicePixelRatio || 1)
1695
+ const width = innerWidth
1696
+ const height = innerHeight
1697
+ if (canvas.width !== Math.round(width * dpr) || canvas.height !== Math.round(height * dpr)) {
1698
+ canvas.width = Math.round(width * dpr)
1699
+ canvas.height = Math.round(height * dpr)
1700
+ }
1701
+ clear()
1702
+ context.setTransform(dpr, 0, 0, dpr, 0, 0)
1703
+ const card = document.querySelector('[data-composer-card]')
1704
+ const cardTop = card === null ? height : card.getBoundingClientRect().top
1705
+ const spin = motion.matches ? 0.35 : now / 1800
1706
+ const running = document.querySelectorAll('[data-chat-running]')
1707
+ if (running.length === 0) clock.since = 0
1708
+ let visible = false
1709
+ for (const row of document.querySelectorAll('[data-chat-running]:not([data-holding])')) {
1710
+ const bounds = row.getBoundingClientRect()
1711
+ if (bounds.height === 0 || bounds.top < 0 || bounds.bottom > height) continue
1712
+ // The overlay paints above every column: never let the sphere or the label
1713
+ // sit over the composer card.
1714
+ if (bounds.bottom + 2 > cardTop) continue
1715
+ const label = row.querySelector('[class*="_runningText"]')
1716
+ if (label === null) continue
1717
+ const labelRect = label.getBoundingClientRect()
1718
+ const ink = getComputedStyle(label).color || 'rgb(200, 205, 215)'
1719
+ const size = 24
1720
+ let cx
1721
+ let cy
1722
+ if (labelOn) {
1723
+ cx = bounds.left + 2 + size / 2
1724
+ cy = bounds.top + Math.min(bounds.height, 30) / 2
1725
+ } else {
1726
+ if (labelRect.width === 0) continue
1727
+ // Keep clear of the host words: park the sphere in the gutter to their left.
1728
+ cx = Math.max(size / 2 + 6, labelRect.left - size / 2 - 8)
1729
+ cy = labelRect.top + labelRect.height / 2
1730
+ }
1731
+ visible = true
1732
+ if (sphereOn) drawSphere(cx, cy, spin, ink)
1733
+ if (labelOn) {
1734
+ const seconds = elapsedOf(now)
1735
+ const x = bounds.left + 2 + (sphereOn ? size + 8 : 0)
1736
+ drawLabel(row, label, x, cy, seconds, now, ink)
1737
+ }
1738
+ }
1739
+ if (visible && !motion.matches) frame = requestAnimationFrame(paint)
1740
+ }
1741
+
1742
+ const refresh = () => {
1743
+ if (frame) cancelAnimationFrame(frame)
1744
+ frame = 0
1745
+ if (document.hidden) clear()
1746
+ else frame = requestAnimationFrame(paint)
1747
+ }
1748
+ const observer = new MutationObserver(refresh)
1749
+ observer.observe(document.body, {
1750
+ childList: true,
1751
+ subtree: true,
1752
+ characterData: true,
1753
+ attributes: true,
1754
+ attributeFilter: ['data-holding', 'data-ds-dark-theme'],
1755
+ })
1756
+ window.addEventListener('resize', refresh)
1757
+ document.addEventListener('scroll', refresh, true)
1758
+ document.addEventListener('visibilitychange', refresh)
1759
+ motion.addEventListener('change', refresh)
1760
+ refresh()
1761
+ return () => {
1762
+ stopped = true
1763
+ cancelAnimationFrame(frame)
1764
+ observer.disconnect()
1765
+ window.removeEventListener('resize', refresh)
1766
+ document.removeEventListener('scroll', refresh, true)
1767
+ document.removeEventListener('visibilitychange', refresh)
1768
+ motion.removeEventListener('change', refresh)
1769
+ }
1770
+ }, [sphereOn, labelOn])
1771
+ return sphereOn || labelOn
1772
+ ? h('canvas', { ref: canvasRef, className: 'dc-overlay', 'aria-hidden': 'true' })
1773
+ : null
1774
+ }
1775
+
1776
+ /* fish indicator:end */
1777
+
1778
+ /** Compact session stats for the composer button row. */
1779
+ function DcStats(props) {
1780
+ const { values } = useDcSettings()
1781
+ const usage = props.useProjection('tokenUsage')
1782
+ const pressure = props.useProjection('contextPressure')
1783
+ if (!values.stats) return null
1784
+ const billed = usage === undefined || usage === null
1785
+ ? 0
1786
+ : (usage.uncachedInputTokens || 0) + (usage.cacheReadTokens || 0)
1787
+ + (usage.cacheWriteTokens || 0) + (usage.outputTokens || 0)
1788
+ const used = pressure === undefined || pressure === null
1789
+ ? undefined
1790
+ : (pressure.projectedTokens !== undefined ? pressure.projectedTokens : pressure.pressureTokens)
1791
+ const windowSize = pressure === undefined || pressure === null ? undefined : pressure.contextWindow
1792
+ const percent = used === undefined || windowSize === undefined || windowSize === 0
1793
+ ? null
1794
+ : Math.max(0, Math.min(100, Math.round((used / windowSize) * 100)))
1795
+ if (billed === 0 && percent === null) return null
1796
+ const tokens = billed >= 1e6
1797
+ ? (billed / 1e6).toFixed(1) + 'm'
1798
+ : billed >= 1e3
1799
+ ? (billed / 1e3).toFixed(1) + 'k'
1800
+ : String(billed)
1801
+ return h('span', { className: 'dc-stats' }, [
1802
+ percent === null
1803
+ ? null
1804
+ : h('span', { key: 'ctx', className: 'dc-stats-item', title: dcUsesChinese() ? '上下文占用' : 'Context usage' }, [h('span', { key: 'label', className: 'dc-stats-label' }, 'CTX'), percent + '%']),
1805
+ billed === 0
1806
+ ? null
1807
+ : h('span', { key: 'tok', className: 'dc-stats-item dc-stats-output', title: dcUsesChinese() ? '累计 Token 用量' : 'Cumulative token usage' }, [h('span', { key: 'label', className: 'dc-stats-label' }, 'TOK'), tokens]),
1808
+ ])
1809
+ }
1810
+
1811
+ /**
1812
+ * Hover dot field for every rows in the sidebar.
1813
+ *
1814
+ * No nodes are injected into host buttons: a single fixed canvas tracks the pointer,
1815
+ * finds the sidebar button under it, and prints a dot field clipped to that button.
1816
+ */
1817
+ function DcSidebarDots() {
1818
+ const canvasRef = React.useRef(null)
1819
+ const { values } = useDcSettings()
1820
+ const showDots = values.sidebarDots !== false
1821
+ const showRail = values.sidebarRail !== false
1822
+ React.useEffect(() => {
1823
+ const canvas = canvasRef.current
1824
+ if (canvas === null) return
1825
+ const context = canvas.getContext('2d')
1826
+ if (context === null) return
1827
+ const motion = matchMedia('(prefers-reduced-motion: reduce)')
1828
+ const state = {
1829
+ row: null,
1830
+ x: 0,
1831
+ y: 0,
1832
+ inside: false,
1833
+ rail: false,
1834
+ alpha: 0,
1835
+ frame: 0,
1836
+ live: false,
1837
+ dirty: false,
1838
+ }
1839
+ let stopped = false
1840
+ let dpr = Math.min(2, devicePixelRatio || 1)
1841
+ let rootCache = null
1842
+
1843
+ // The sidebar column itself is the scope: walk up from our footer button to the
1844
+ // column landmark, once, and only light controls inside it. A lowest-common-ancestor
1845
+ // guess leaked into the chat column and put rails on every button in the app.
1846
+ const sidebarScope = () => {
1847
+ if (rootCache !== null && rootCache.isConnected) return rootCache
1848
+ const foot = document.querySelector('.dc-foot-button')
1849
+ if (foot === null) return null
1850
+ let node = foot
1851
+ for (let depth = 0; depth < 10; depth += 1) {
1852
+ node = node.parentElement
1853
+ if (node === null) break
1854
+ if (node.matches('aside, [data-slot="sidebar"], [data-sidebar], [role="navigation"]')) {
1855
+ rootCache = node
1856
+ return node
1857
+ }
1858
+ }
1859
+ // No landmark: take the column wrapper a few levels up as a best effort.
1860
+ let fallback = foot
1861
+ for (let depth = 0; depth < 5 && fallback.parentElement !== null; depth += 1) {
1862
+ fallback = fallback.parentElement
1863
+ }
1864
+ rootCache = fallback
1865
+ return fallback
1866
+ }
1867
+
1868
+ const paint = () => {
1869
+ state.frame = 0
1870
+ if (stopped) return
1871
+ const width = innerWidth
1872
+ const height = innerHeight
1873
+ if (canvas.width !== Math.round(width * dpr) || canvas.height !== Math.round(height * dpr)) {
1874
+ canvas.width = Math.round(width * dpr)
1875
+ canvas.height = Math.round(height * dpr)
1876
+ }
1877
+ const target = state.inside ? 1 : 0
1878
+ state.alpha = motion.matches ? target : state.alpha + (target - state.alpha) * 0.22
1879
+ context.setTransform(dpr, 0, 0, dpr, 0, 0)
1880
+ context.clearRect(0, 0, width, height)
1881
+ if (!state.inside && state.alpha < 0.02) {
1882
+ state.alpha = 0
1883
+ state.live = false
1884
+ return
1885
+ }
1886
+ if (state.row === null || !state.row.isConnected) {
1887
+ state.inside = false
1888
+ state.live = false
1889
+ return
1890
+ }
1891
+ const rect = state.row.getBoundingClientRect()
1892
+ if (rect.width < 8 || rect.height < 8 || rect.bottom < 0 || rect.top > height) {
1893
+ state.live = false
1894
+ return
1895
+ }
1896
+ const style = getComputedStyle(state.row)
1897
+ const radius = parseFloat(style.borderTopLeftRadius) || 8
1898
+ const accent = (style.getPropertyValue('--dc-accent') || '').trim() || '#7aa4ff'
1899
+ const reach = 74
1900
+ context.save()
1901
+ context.beginPath()
1902
+ if (typeof context.roundRect === 'function') {
1903
+ context.roundRect(rect.left, rect.top, rect.width, rect.height, radius)
1904
+ } else {
1905
+ context.rect(rect.left, rect.top, rect.width, rect.height)
1906
+ }
1907
+ context.clip()
1908
+ context.fillStyle = accent
1909
+ if (showDots) {
1910
+ const startX = Math.floor(rect.left / 4) * 4 + 2
1911
+ const startY = Math.floor(rect.top / 4) * 4 + 2
1912
+ for (let y = startY; y < rect.bottom; y += 4) {
1913
+ for (let x = startX; x < rect.right; x += 4) {
1914
+ const dx = x - state.x
1915
+ const dy = y - state.y
1916
+ const distance = Math.sqrt(dx * dx + dy * dy)
1917
+ if (distance > reach) continue
1918
+ const alpha = Math.pow(1 - distance / reach, 1.35) * state.alpha * 0.72
1919
+ if (alpha < 0.02) continue
1920
+ context.globalAlpha = Math.min(1, alpha)
1921
+ context.beginPath()
1922
+ context.arc(x, y, 0.85, 0, Math.PI * 2)
1923
+ context.fill()
1924
+ }
1925
+ }
1926
+ }
1927
+ // A short whale-blue rail marks the hovered control — buttons only.
1928
+ if (state.rail && showRail) {
1929
+ const railWidth = 3
1930
+ const railInset = 5
1931
+ const railHeight = Math.max(6, rect.height - railInset * 2)
1932
+ const railTop = rect.top + (rect.height - railHeight) / 2
1933
+ context.globalAlpha = Math.min(1, state.alpha * 0.9)
1934
+ context.beginPath()
1935
+ if (typeof context.roundRect === 'function') {
1936
+ context.roundRect(rect.left + 2, railTop, railWidth, railHeight, 1.5)
1937
+ } else {
1938
+ context.rect(rect.left + 2, railTop, railWidth, railHeight)
1939
+ }
1940
+ context.fill()
1941
+ }
1942
+ context.restore()
1943
+ context.globalAlpha = 1
1944
+ const moving = state.dirty
1945
+ state.dirty = false
1946
+ if (motion.matches) {
1947
+ if (!state.inside) {
1948
+ context.clearRect(0, 0, width, height)
1949
+ state.alpha = 0
1950
+ }
1951
+ state.live = false
1952
+ return
1953
+ }
1954
+ if (state.inside && state.alpha >= 0.98 && !moving) {
1955
+ state.live = false
1956
+ return
1957
+ }
1958
+ if (state.inside || state.alpha >= 0.02) {
1959
+ state.frame = requestAnimationFrame(paint)
1960
+ } else {
1961
+ state.live = false
1962
+ }
1963
+ }
1964
+
1965
+ const wake = () => {
1966
+ if (stopped || state.live) return
1967
+ state.live = true
1968
+ if (state.frame === 0) state.frame = requestAnimationFrame(paint)
1969
+ }
1970
+
1971
+ const onMove = event => {
1972
+ const target = event.target instanceof Element
1973
+ ? event.target.closest('button, a, [role="button"]')
1974
+ : null
1975
+ const scope = sidebarScope()
1976
+ const insideSidebar = target !== null
1977
+ && scope !== null
1978
+ && scope.contains(target)
1979
+ && !target.closest('.dc-foot')
1980
+ if (!insideSidebar) {
1981
+ if (state.inside) {
1982
+ state.inside = false
1983
+ state.row = null
1984
+ wake()
1985
+ }
1986
+ return
1987
+ }
1988
+ state.row = target
1989
+ state.rail = target.matches('button')
1990
+ state.x = event.clientX
1991
+ state.y = event.clientY
1992
+ state.inside = true
1993
+ state.dirty = true
1994
+ wake()
1995
+ }
1996
+
1997
+ const onLeave = () => {
1998
+ if (!state.inside) return
1999
+ state.inside = false
2000
+ state.row = null
2001
+ wake()
2002
+ }
2003
+
2004
+ document.addEventListener('pointermove', onMove, { passive: true })
2005
+ document.addEventListener('pointerleave', onLeave)
2006
+ window.addEventListener('blur', onLeave)
2007
+ window.addEventListener('resize', wake)
2008
+ return () => {
2009
+ stopped = true
2010
+ document.removeEventListener('pointermove', onMove)
2011
+ document.removeEventListener('pointerleave', onLeave)
2012
+ window.removeEventListener('blur', onLeave)
2013
+ window.removeEventListener('resize', wake)
2014
+ if (state.frame !== 0) cancelAnimationFrame(state.frame)
2015
+ state.frame = 0
2016
+ state.live = false
2017
+ }
2018
+ }, [showDots, showRail])
2019
+ return showDots || showRail
2020
+ ? h('canvas', { ref: canvasRef, className: 'dc-overlay', 'aria-hidden': 'true' })
2021
+ : null
2022
+ }
2023
+
2024
+ /**
2025
+ * Dot trail behind the composer caret.
2026
+ *
2027
+ * The caret itself is host-owned, so we only read its position (collapsed selection
2028
+ * range inside the active composer) and print a fading line of dots behind it on our
2029
+ * overlay canvas, clipped to the composer card. Dots never move once printed; they only
2030
+ * fade.
2031
+ */
2032
+ function DcCaretTrail() {
2033
+ const canvasRef = React.useRef(null)
2034
+ React.useEffect(() => {
2035
+ const canvas = canvasRef.current
2036
+ if (canvas === null) return
2037
+ const context = canvas.getContext('2d')
2038
+ if (context === null) return
2039
+ const motion = matchMedia('(prefers-reduced-motion: reduce)')
2040
+ if (motion.matches) return undefined
2041
+ const trail = []
2042
+ const LIFE = 650
2043
+ const STEP = 3
2044
+ let stopped = false
2045
+ let frame = 0
2046
+ let last = null
2047
+ let trailCard = null
2048
+ let dpr = Math.min(2, devicePixelRatio || 1)
2049
+
2050
+ // A caret (or an IME composition) has no reliable box of its own, so every
2051
+ // measurement falls back to the text or element next to the insertion point.
2052
+ const rectAt = (container, offset) => {
2053
+ if (container === null) return null
2054
+ const range = document.createRange()
2055
+ try {
2056
+ range.setStart(container, offset)
2057
+ range.collapse(true)
2058
+ } catch (error) {
2059
+ return null
2060
+ }
2061
+ const collapsed = range.getBoundingClientRect()
2062
+ if (collapsed.height > 0 && (collapsed.left > 0 || collapsed.top > 0)) {
2063
+ return { left: collapsed.left, top: collapsed.top, height: collapsed.height }
2064
+ }
2065
+ const measure = (node, side) => {
2066
+ if (node === null) return null
2067
+ const inner = document.createRange()
2068
+ inner.selectNodeContents(node)
2069
+ const box = inner.getBoundingClientRect()
2070
+ if (box.height === 0) return null
2071
+ return { left: side === 'end' ? box.right : box.left, top: box.top, height: box.height }
2072
+ }
2073
+ if (container.nodeType === 3) {
2074
+ const text = container.textContent || ''
2075
+ if (offset > 0) {
2076
+ const inner = document.createRange()
2077
+ inner.setStart(container, offset - 1)
2078
+ inner.setEnd(container, offset)
2079
+ const box = inner.getBoundingClientRect()
2080
+ if (box.height > 0) return { left: box.right, top: box.top, height: box.height }
2081
+ }
2082
+ if (text.length > 0) {
2083
+ const inner = document.createRange()
2084
+ inner.setStart(container, 0)
2085
+ inner.setEnd(container, 1)
2086
+ const box = inner.getBoundingClientRect()
2087
+ if (box.height > 0) return { left: box.left, top: box.top, height: box.height }
2088
+ }
2089
+ return null
2090
+ }
2091
+ if (container.nodeType === 1) {
2092
+ const children = container.childNodes
2093
+ return measure(offset > 0 ? children[offset - 1] : null, 'end')
2094
+ || measure(offset < children.length ? children[offset] : null, 'start')
2095
+ }
2096
+ return null
2097
+ }
2098
+
2099
+ const caretOf = () => {
2100
+ const active = document.activeElement
2101
+ if (active === null || typeof active.closest !== 'function') return null
2102
+ const card = active.closest('[data-composer-card]')
2103
+ if (card === null) return null
2104
+ const editable = active.isContentEditable
2105
+ ? active
2106
+ : active.closest('[contenteditable], [role="textbox"], textarea')
2107
+ if (editable === null || !card.contains(editable)) return null
2108
+ const selection = window.getSelection()
2109
+ if (selection === null || selection.rangeCount === 0) return null
2110
+ // While an IME composes, the selection covers the composition text; the caret
2111
+ // sits at its focus end, so measure there instead of bailing out.
2112
+ const container = selection.isCollapsed ? selection.anchorNode : selection.focusNode
2113
+ const offset = selection.isCollapsed ? selection.anchorOffset : selection.focusOffset
2114
+ if (container === null) return null
2115
+ if (container !== active && !active.contains(container)) return null
2116
+ const rect = rectAt(container, offset)
2117
+ if (rect === null || rect.height === 0) return null
2118
+ return { x: rect.left, y: rect.top, height: rect.height, card }
2119
+ }
2120
+
2121
+ const push = (from, to, now) => {
2122
+ const deviceX = to.x - from.x
2123
+ const deviceY = to.y - from.y
2124
+ const distance = Math.sqrt(deviceX * deviceX + deviceY * deviceY)
2125
+ if (distance < 1.5) return
2126
+ // A line wrap or a jump to another spot is not a trail; only same-line motion is.
2127
+ if (distance > 90 || Math.abs(deviceY) > 6) return
2128
+ const topFrom = from.y
2129
+ const topTo = to.y
2130
+ const steps = Math.max(1, Math.min(40, Math.round(distance / STEP)))
2131
+ for (let index = 1; index <= steps; index += 1) {
2132
+ const t = index / steps
2133
+ trail.push({
2134
+ x: from.x + deviceX * t,
2135
+ y: topFrom + (topTo - topFrom) * t,
2136
+ height: to.height || 18,
2137
+ born: now - (steps - index) * 6,
2138
+ })
2139
+ }
2140
+ while (trail.length > 220) trail.shift()
2141
+ }
2142
+
2143
+ const sample = () => {
2144
+ const caret = caretOf()
2145
+ if (caret === null) {
2146
+ last = null
2147
+ trailCard = null
2148
+ return
2149
+ }
2150
+ trailCard = caret.card
2151
+ const now = performance.now()
2152
+ if (last !== null) {
2153
+ const sameCard = last.card === caret.card
2154
+ if (sameCard) push({ x: last.x, y: last.y, height: last.height }, caret, now)
2155
+ }
2156
+ last = { x: caret.x, y: caret.y, height: caret.height, card: caret.card }
2157
+ wake()
2158
+ }
2159
+
2160
+ const paint = () => {
2161
+ frame = 0
2162
+ if (stopped) return
2163
+ const width = innerWidth
2164
+ const height = innerHeight
2165
+ if (canvas.width !== Math.round(width * dpr) || canvas.height !== Math.round(height * dpr)) {
2166
+ canvas.width = Math.round(width * dpr)
2167
+ canvas.height = Math.round(height * dpr)
2168
+ }
2169
+ context.setTransform(dpr, 0, 0, dpr, 0, 0)
2170
+ context.clearRect(0, 0, width, height)
2171
+ const now = performance.now()
2172
+ while (trail.length > 0 && now - trail[0].born > LIFE) trail.shift()
2173
+ if (trail.length === 0) {
2174
+ trailCard = null
2175
+ return
2176
+ }
2177
+ const card = trailCard
2178
+ let clip = null
2179
+ let radius = 12
2180
+ if (card !== null && card.isConnected) {
2181
+ clip = card.getBoundingClientRect()
2182
+ const style = getComputedStyle(card)
2183
+ radius = parseFloat(style.borderTopLeftRadius) || 12
2184
+ }
2185
+ const accent = (getComputedStyle(document.body).getPropertyValue('--dc-accent') || '').trim() || '#7aa4ff'
2186
+ context.save()
2187
+ if (clip !== null) {
2188
+ context.beginPath()
2189
+ if (typeof context.roundRect === 'function') {
2190
+ context.roundRect(clip.left, clip.top, clip.width, clip.height, radius)
2191
+ } else {
2192
+ context.rect(clip.left, clip.top, clip.width, clip.height)
2193
+ }
2194
+ context.clip()
2195
+ }
2196
+ // Collect every dot once, then paint a soft halo pass and a crisp pass in
2197
+ // batches: per-dot fills with shadows would crawl.
2198
+ const dots = []
2199
+ for (const point of trail) {
2200
+ const age = (now - point.born) / LIFE
2201
+ if (age >= 1) continue
2202
+ const alpha = Math.pow(1 - age, 1.4) * 0.85
2203
+ if (alpha < 0.02) continue
2204
+ for (let offset = 1; offset < point.height - 0.5; offset += 3) {
2205
+ dots.push(point.x, point.y + offset, alpha)
2206
+ }
2207
+ }
2208
+ context.fillStyle = accent
2209
+ const passes = [
2210
+ { radius: 2.4, scale: 0.3 },
2211
+ { radius: 1.05, scale: 1 },
2212
+ ]
2213
+ for (const pass of passes) {
2214
+ const buckets = new Map()
2215
+ for (let index = 0; index < dots.length; index += 3) {
2216
+ const alpha = dots[index + 2] * pass.scale
2217
+ if (alpha < 0.02) continue
2218
+ const level = Math.min(10, Math.max(1, Math.round(alpha * 10)))
2219
+ let bucket = buckets.get(level)
2220
+ if (bucket === undefined) {
2221
+ bucket = new Path2D()
2222
+ buckets.set(level, bucket)
2223
+ }
2224
+ bucket.moveTo(dots[index] + pass.radius, dots[index + 1])
2225
+ bucket.arc(dots[index], dots[index + 1], pass.radius, 0, Math.PI * 2)
2226
+ }
2227
+ for (const [level, path] of buckets) {
2228
+ context.globalAlpha = level / 10
2229
+ context.fill(path)
2230
+ }
2231
+ }
2232
+ context.restore()
2233
+ context.globalAlpha = 1
2234
+ frame = requestAnimationFrame(paint)
2235
+ }
2236
+
2237
+ const wake = () => {
2238
+ if (stopped || frame !== 0) return
2239
+ frame = requestAnimationFrame(paint)
2240
+ }
2241
+
2242
+ window.__dcCaretProbe = () => {
2243
+ const caret = caretOf()
2244
+ return caret === null
2245
+ ? { ok: false, active: document.activeElement ? document.activeElement.tagName : null }
2246
+ : { ok: true, x: Math.round(caret.x), y: Math.round(caret.y), height: Math.round(caret.height) }
2247
+ }
2248
+ const onActivity = () => sample()
2249
+ document.addEventListener('selectionchange', onActivity)
2250
+ document.addEventListener('input', onActivity, true)
2251
+ document.addEventListener('beforeinput', onActivity, true)
2252
+ document.addEventListener('compositionupdate', onActivity, true)
2253
+ document.addEventListener('keyup', onActivity, true)
2254
+ document.addEventListener('click', onActivity, true)
2255
+ document.addEventListener('pointerup', onActivity, true)
2256
+ window.addEventListener('resize', wake)
2257
+ return () => {
2258
+ stopped = true
2259
+ document.removeEventListener('selectionchange', onActivity)
2260
+ document.removeEventListener('input', onActivity, true)
2261
+ document.removeEventListener('beforeinput', onActivity, true)
2262
+ document.removeEventListener('compositionupdate', onActivity, true)
2263
+ document.removeEventListener('keyup', onActivity, true)
2264
+ document.removeEventListener('click', onActivity, true)
2265
+ document.removeEventListener('pointerup', onActivity, true)
2266
+ window.removeEventListener('resize', wake)
2267
+ if (frame !== 0) cancelAnimationFrame(frame)
2268
+ frame = 0
2269
+ trail.length = 0
2270
+ }
2271
+ }, [])
2272
+ return h('canvas', {
2273
+ ref: canvasRef,
2274
+ className: 'dc-overlay dc-caret-layer',
2275
+ 'aria-hidden': 'true',
2276
+ style: { zIndex: 2147483000 },
2277
+ })
2278
+ }
2279
+
2280
+ /**
2281
+ * Reasoning effort badge, done entirely in CSS.
2282
+ *
2283
+ * We only read the effort label and stamp two attributes on the composer card; the
2284
+ * unfolding dot field and the dot-printed level name are pseudo-elements, so there is no
2285
+ * canvas geometry to measure and nothing to drift when the layout changes.
2286
+ */
2287
+ const DC_EFFORT_OFF = /^(off|none|disabled?|无|关闭)$/i
2288
+
2289
+ function dcEffortLabel() {
2290
+ const card = document.querySelector('[data-composer-card]')
2291
+ if (card === null) return null
2292
+ const node = card.querySelector('[class*="_triggerEffort"]')
2293
+ if (node === null) return null
2294
+ const text = (node.textContent || '').trim()
2295
+ return text === '' ? null : text
2296
+ }
2297
+
2298
+ function dcPaintEffort(label) {
2299
+ const card = document.querySelector('[data-composer-card]')
2300
+ if (card === null) return
2301
+ if (label === null) {
2302
+ card.removeAttribute('data-dc-effort')
2303
+ card.classList.remove('dc-effort-on', 'dc-effort-max')
2304
+ return
2305
+ }
2306
+ const word = label.toUpperCase()
2307
+ const changed = card.getAttribute('data-dc-effort') !== word
2308
+ card.setAttribute('data-dc-effort', word)
2309
+ card.classList.toggle('dc-effort-max', word === 'MAX')
2310
+ if (changed) {
2311
+ // Toggle the class off and on so the CSS animation replays for the new word.
2312
+ card.classList.remove('dc-effort-on')
2313
+ void card.offsetWidth
2314
+ card.classList.add('dc-effort-on')
2315
+ } else if (!card.classList.contains('dc-effort-on')) {
2316
+ card.classList.add('dc-effort-on')
2317
+ }
2318
+ }
2319
+
2320
+ /**
2321
+ * Startup splash: the dot wordmark over the boot screen.
2322
+ *
2323
+ * The whole animation is CSS transform/opacity so the compositor drives it: no canvas,
2324
+ * no per-frame JavaScript while the app is still booting.
2325
+ */
2326
+ function dcPlaySplash() {
2327
+ if (window.__dcSplashPlayed === true) return
2328
+ window.__dcSplashPlayed = true
2329
+ try {
2330
+ if (typeof document === 'undefined' || document.body === null) return
2331
+ if (matchMedia('(prefers-reduced-motion: reduce)').matches) return
2332
+ const layer = document.createElement('div')
2333
+ layer.className = 'dc-splash'
2334
+ layer.setAttribute('aria-hidden', 'true')
2335
+ const grid = document.createElement('div')
2336
+ grid.className = 'dc-splash-grid'
2337
+ const ring = document.createElement('div')
2338
+ ring.className = 'dc-splash-ring'
2339
+ const mark = document.createElement('div')
2340
+ mark.className = 'dc-splash-mark'
2341
+ const deepseek = document.createElement('span')
2342
+ deepseek.className = 'dc-splash-line dc-splash-deepseek'
2343
+ deepseek.textContent = 'deepseek'
2344
+ const harness = document.createElement('span')
2345
+ harness.className = 'dc-splash-line dc-splash-harness'
2346
+ harness.textContent = 'harness'
2347
+ const sheen = document.createElement('div')
2348
+ sheen.className = 'dc-splash-sheen'
2349
+ mark.append(deepseek, harness, sheen)
2350
+ const veil = document.createElement('div')
2351
+ veil.className = 'dc-splash-veil'
2352
+ layer.append(grid, ring, mark, veil)
2353
+ document.body.appendChild(layer)
2354
+ const remove = () => {
2355
+ if (layer.isConnected) layer.remove()
2356
+ }
2357
+ layer.addEventListener('animationend', event => {
2358
+ if (event.animationName === 'dc-splash-out') remove()
2359
+ })
2360
+ setTimeout(remove, 3200)
2361
+ } catch (error) {
2362
+ console.warn('[dsh-fish-ui] splash failed', error)
2363
+ }
2364
+ }
2365
+
2366
+ /* fish runtime:start */
2367
+ // Profile settings and token layers; embedded into client.js by build-runtime.mjs.
2368
+ const DC_SETTINGS_KEY = 'dsh-fish-ui:settings'
2369
+ const DC_DEFAULT_SETTINGS = Object.freeze(Object.fromEntries([
2370
+ 'hero', 'field', 'wave', 'ripple', 'thinkingSphere', 'thinkingLabel',
2371
+ 'glass', 'effortBadge', 'sidebarDots', 'sidebarRail', 'bold', 'focusRing', 'diff',
2372
+ 'reading', 'code', 'fishFont', 'fishGlow', 'fishMotion', 'fishCode',
2373
+ ].map(key => [key, true])))
2374
+ const DC_OFF_CLASS = Object.freeze(Object.fromEntries(Object.keys(DC_DEFAULT_SETTINGS)
2375
+ .map(key => [key, 'dc-off-' + key.toLowerCase()])))
2376
+ const dcSettingsListeners = new Set()
2377
+ let dcSettings = DC_DEFAULT_SETTINGS
2378
+ let dcSnapshot = { values: dcSettings, status: 'loading', writable: false, pending: false, error: '' }
2379
+ let dcWrite = null
2380
+ let dcSettingsOwner = null
2381
+ let dcTheme = null
2382
+ let dcThemeLayers = new Map()
2383
+ let dcMounted = false
2384
+
2385
+ const dcReadLegacy = () => {
2386
+ try {
2387
+ const parsed = JSON.parse(window.localStorage.getItem(DC_SETTINGS_KEY))
2388
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) return null
2389
+ const values = Object.fromEntries(Object.keys(DC_DEFAULT_SETTINGS)
2390
+ .filter(key => typeof parsed[key] === 'boolean').map(key => [key, parsed[key]]))
2391
+ return Object.keys(values).length ? values : null
2392
+ } catch { return null }
2393
+ }
2394
+ const dcLegacy = dcReadLegacy()
2395
+ dcSettings = Object.freeze({ ...DC_DEFAULT_SETTINGS, ...dcLegacy })
2396
+ dcSnapshot = { ...dcSnapshot, values: dcSettings }
2397
+ const dcSubscribeSettings = listener => {
2398
+ dcSettingsListeners.add(listener)
2399
+ return () => dcSettingsListeners.delete(listener)
2400
+ }
2401
+ const dcGetSnapshot = () => dcSnapshot
2402
+ const useDcSettings = () => React.useSyncExternalStore(dcSubscribeSettings, dcGetSnapshot, dcGetSnapshot)
2403
+ const dcModes = (light, dark) => ({ light, dark })
2404
+ const DC_CODE = {
2405
+ '--shiki-token-constant': dcModes('#2562A5', '#92BEF4'),
2406
+ '--shiki-token-string': dcModes('#326B55', '#A5CCB8'),
2407
+ '--shiki-token-comment': dcModes('#657287', '#8E9BAF'),
2408
+ '--shiki-token-keyword': dcModes('#765795', '#C0ACD8'),
2409
+ '--shiki-token-parameter': dcModes('#956032', '#D8B18A'),
2410
+ '--shiki-token-function': dcModes('#406A9D', '#A7C8F2'),
2411
+ '--shiki-token-string-expression': dcModes('#326B55', '#A5CCB8'),
2412
+ '--shiki-token-punctuation': dcModes('#546377', '#A6B2C4'),
2413
+ '--shiki-token-link': dcModes('#3269B7', '#8AB6FA'),
2414
+ }
2415
+ const DC_DIFF = {
2416
+ '--dsw-alias-file-diff-added-bg': dcModes('rgb(58 117 196 / 9%)', 'rgb(122 170 255 / 12%)'),
2417
+ '--dsw-alias-file-diff-added-gutter': dcModes('rgb(58 117 196 / 6%)', 'rgb(122 170 255 / 7%)'),
2418
+ '--dsw-alias-file-diff-added-marker': dcModes('#3269B7', '#8AB6FA'),
2419
+ '--dsw-alias-file-diff-deleted-bg': dcModes('rgb(164 97 83 / 9%)', 'rgb(213 156 139 / 10%)'),
2420
+ '--dsw-alias-file-diff-deleted-gutter': dcModes('rgb(164 97 83 / 6%)', 'rgb(213 156 139 / 6%)'),
2421
+ '--dsw-alias-file-diff-deleted-marker': dcModes('#995C50', '#D4A18F'),
2422
+ '--dsw-alias-code-diff-added': dcModes('rgb(58 117 196 / 10%)', 'rgb(122 170 255 / 13%)'),
2423
+ '--dsw-alias-code-diff-deleted': dcModes('rgb(164 97 83 / 10%)', 'rgb(213 156 139 / 11%)'),
2424
+ }
2425
+ const DC_IDENTITY = {
2426
+ '--dc-accent': dcModes('#3269B7', '#8AB6FA'),
2427
+ '--dc-focus': dcModes('rgb(50 105 183 / 18%)', 'rgb(138 182 250 / 18%)'),
2428
+ }
2429
+ function dcSyncTheme() {
2430
+ if (dcTheme === null) return
2431
+ for (const [name, enabled, tokens] of [
2432
+ ['identity', true, DC_IDENTITY],
2433
+ ['code', dcSettings.code, DC_CODE], ['diff', dcSettings.diff, DC_DIFF],
2434
+ ]) {
2435
+ if (enabled && !dcThemeLayers.has(name)) {
2436
+ dcThemeLayers.set(name, dcTheme.overrideTokens('dsh-fish-ui:' + name, tokens))
2437
+ } else if (!enabled && dcThemeLayers.has(name)) {
2438
+ dcThemeLayers.get(name)()
2439
+ dcThemeLayers.delete(name)
2440
+ }
2441
+ }
2442
+ }
2443
+ function dcApplySettings() {
2444
+ if (!dcMounted) return
2445
+ for (const [key, className] of Object.entries(DC_OFF_CLASS)) {
2446
+ document.documentElement.classList.toggle(className, dcSettings[key] === false)
2447
+ }
2448
+ dcSyncTheme()
2449
+ }
2450
+ function dcPublish(patch) {
2451
+ dcSnapshot = Object.freeze({ ...dcSnapshot, ...patch })
2452
+ dcSettings = dcSnapshot.values
2453
+ dcApplySettings()
2454
+ dcSettingsListeners.forEach(listener => listener())
2455
+ }
2456
+ function dcConnectSettings(scope) {
2457
+ // This is the Host patch entry id; the bundle-config key below is the package name.
2458
+ const form = scope.configForms.get('dsh-fish-ui')
2459
+ let active = true
2460
+ let migrating = false
2461
+ let migrationTried = false
2462
+ const adopt = () => {
2463
+ if (!active) return
2464
+ const snapshot = form.getSnapshot()
2465
+ if (snapshot.status !== 'ready' || snapshot.value === undefined) {
2466
+ dcPublish({ status: snapshot.status, writable: false })
2467
+ return
2468
+ }
2469
+ const ownsValues = Object.keys(DC_DEFAULT_SETTINGS).some(key =>
2470
+ snapshot.user !== null && typeof snapshot.user === 'object' && Object.hasOwn(snapshot.user, key))
2471
+ const legacyKeys = dcLegacy === null ? []
2472
+ : Object.keys(dcLegacy).filter(key => Object.hasOwn(DC_DEFAULT_SETTINGS, key))
2473
+ if (!migrationTried && legacyKeys.length > 0 && !ownsValues && !snapshot.value.settingsMigrated && snapshot.writable) {
2474
+ migrationTried = true
2475
+ migrating = true
2476
+ dcPublish({ status: 'ready', writable: true, pending: true, error: '' })
2477
+ // Only carry keys the current schema still owns: a legacy blob may mention
2478
+ // preferences that were removed, and one unknown path rejects the whole write.
2479
+ const ops = Object.entries(dcLegacy)
2480
+ .filter(([key]) => Object.hasOwn(DC_DEFAULT_SETTINGS, key))
2481
+ .map(([key, value]) => ({ op: 'set', path: [key], value }))
2482
+ ops.push({ op: 'set', path: ['settingsMigrated'], value: true })
2483
+ // Fence the exact snapshot that established the namespace was empty.
2484
+ const migrate = async () => form.mutate(ops, snapshot.revision)
2485
+ migrate().then(ok => {
2486
+ if (!active) return
2487
+ migrating = false
2488
+ dcPublish({ pending: false, error: ok ? '' : 'conflict' })
2489
+ adopt()
2490
+ }, () => {
2491
+ if (!active) return
2492
+ migrating = false
2493
+ dcPublish({ pending: false, error: 'save' })
2494
+ adopt()
2495
+ })
2496
+ // Keep the legacy key read-only: other profiles may share this origin.
2497
+ return
2498
+ }
2499
+ if (migrating) return
2500
+ const values = Object.freeze(Object.fromEntries(Object.entries(DC_DEFAULT_SETTINGS)
2501
+ .map(([key, fallback]) => [key, typeof snapshot.value[key] === 'boolean' ? snapshot.value[key] : fallback])))
2502
+ dcPublish({ values, status: 'ready', writable: snapshot.writable })
2503
+ }
2504
+ const write = async values => {
2505
+ if (!active || dcSnapshot.pending || dcSnapshot.status !== 'ready' || !dcSnapshot.writable) return
2506
+ dcPublish({ pending: true, error: '' })
2507
+ try {
2508
+ const ops = Object.entries(values).filter(([key, value]) => Object.hasOwn(DC_DEFAULT_SETTINGS, key) && typeof value === 'boolean')
2509
+ .map(([key, value]) => ({ op: 'set', path: [key], value }))
2510
+ ops.push({ op: 'set', path: ['settingsMigrated'], value: true })
2511
+ const ok = await form.mutate(ops, form.getSnapshot().revision)
2512
+ if (active) dcPublish({ error: ok ? '' : 'conflict' })
2513
+ } catch {
2514
+ if (active) dcPublish({ error: 'save' })
2515
+ } finally {
2516
+ if (active) { dcPublish({ pending: false }); adopt() }
2517
+ }
2518
+ }
2519
+ scope.effect(() => {
2520
+ dcWrite = write
2521
+ dcSettingsOwner = write
2522
+ const unsubscribe = form.subscribe(adopt)
2523
+ adopt()
2524
+ return () => {
2525
+ active = false
2526
+ unsubscribe()
2527
+ if (dcWrite === write) dcWrite = null
2528
+ if (dcSettingsOwner === write) {
2529
+ dcSettingsOwner = null
2530
+ dcPublish({ status: 'unavailable', writable: false, pending: false })
2531
+ }
2532
+ }
2533
+ }, 'dsh-fish-ui: Host preferences')
2534
+ }
2535
+ const dcSetSetting = (key, value) => dcWrite?.({ [key]: value })
2536
+
2537
+ class DcBoundary extends React.Component {
2538
+ state = { failed: false }
2539
+ static getDerivedStateFromError() { return { failed: true } }
2540
+ componentDidCatch(error) { console.error('[dsh-fish-ui] enhancement failed', error) }
2541
+ render() { return this.state.failed ? (this.props.fallback ?? null) : this.props.children }
2542
+ }
2543
+ const dcSafe = Component => function Deep FishSafeSlot(props) {
2544
+ return h(DcBoundary, { fallback: props.children }, h(Component, props))
2545
+ }
2546
+
2547
+ /* fish runtime:end */
2548
+
2549
+ /** Settings copy follows the app language (Chinese unless the UI is English). */
2550
+ const dcUsesChinese = () => {
2551
+ const lang = (document.documentElement.lang || navigator.language || '').toLowerCase()
2552
+ return lang.startsWith('zh')
2553
+ }
2554
+ const DC_COPY = {
2555
+ zh: {
2556
+ lead: '\u8fd9\u91cc\u7684\u5f00\u5173\u7acb\u5373\u751f\u6548\uff0c\u5e76\u6309\u914d\u7f6e\u6587\u4ef6\u8bb0\u4f4f\u3002',
2557
+ groups: {
2558
+ hero: '\u6b22\u8fce\u9875',
2559
+ thinking: '\u601d\u8003\u4e2d',
2560
+ composer: '\u8f93\u5165\u6846',
2561
+ accents: '\u5f3a\u8c03\u8272',
2562
+ sidebar: '侧边栏',
2563
+ },
2564
+ items: {
2565
+ hero: ['\u70b9\u9635\u4eba\u50cf\u4e0e\u5b57\u6807', '\u7a7a\u767d\u6b22\u8fce\u9875\u4e0a\u7684\u7acb\u7ed8\u548c\u5b57\u6807'],
2566
+ field: ['\u80cc\u666f\u70b9\u9635', '\u94fa\u6ee1\u6574\u9875\u7684\u6de1\u70b9\u9635'],
2567
+ wave: ['\u5e95\u90e8\u6ce2\u6d6a', '\u9875\u9762\u5e95\u90e8\u7f13\u6162\u6d41\u52a8\u7684\u660e\u6697\u6ce2'],
2568
+ ripple: ['\u6307\u9488\u6d9f\u6f2a', '\u9f20\u6807\u5212\u8fc7\u70b9\u9635\u65f6\u8361\u5f00\u7684\u5149\u73af'],
2569
+ thinkingSphere: ['\u70b9\u9635\u7403', '\u601d\u8003\u65f6\u65cb\u8f6c\u7684\u5c0f\u7403'],
2570
+ thinkingLabel: ['英文思考文案', '把状态行换成 “Deep thinking for 12s. . .”'],
2571
+ glass: ['\u78e8\u7802\u73bb\u7483', '\u4f1a\u8bdd\u9875\u8f93\u5165\u6846\u7684\u534a\u900f\u660e\u6548\u679c'],
2572
+ stats: ['\u7528\u91cf\u8bfb\u6570', '\u5728\u53d1\u9001\u6309\u94ae\u6392\u663e\u793a\u4e0a\u4e0b\u6587\u4e0e Token \u7528\u91cf'],
2573
+ bold: ['\u9cb8\u9c7c\u84dd\u52a0\u7c97', '\u804a\u5929\u91cc\u7684\u52a0\u7c97\u6587\u5b57\u53d8\u6210\u9cb8\u9c7c\u84dd'],
2574
+ focusRing: ['\u805a\u7126\u63cf\u8fb9', '\u8f93\u5165\u6846\u805a\u7126\u65f6\u7684\u67d4\u5149\u63cf\u8fb9'],
2575
+ diff: ['diff \u6362\u84dd', '\u65b0\u589e / \u5220\u9664\u884c\u6539\u6210\u84dd\u8272\u65cf'],
2576
+ },
2577
+ reset: '\u6062\u590d\u9ed8\u8ba4',
2578
+ close: '\u5173\u95ed',
2579
+ dialog: 'Deep Fish UI \u8bbe\u7f6e',
2580
+ button: 'Deep Fish UI \u8bbe\u7f6e',
2581
+ },
2582
+ en: {
2583
+ lead: 'Everything here applies immediately and is remembered per profile.',
2584
+ groups: { hero: 'Welcome page', thinking: 'Thinking', composer: 'Composer', accents: 'Accents', sidebar: 'Sidebar' },
2585
+ items: {
2586
+ hero: ['Dot artwork', 'The portrait and the wordmark on the blank home'],
2587
+ field: ['Dot field', 'The faint lattice behind everything'],
2588
+ wave: ['Bottom wave', 'The slow brightness wave along the bottom edge'],
2589
+ ripple: ['Pointer ripples', 'Light rings where the pointer crosses the field'],
2590
+ thinkingSphere: ['Dot sphere', 'The rotating point-sphere beside the live status'],
2591
+ thinkingLabel: ['English status label', 'Replace the status row with “Deep thinking for 12s. . .”'],
2592
+ glass: ['Frosted glass', 'Translucent input card on session pages'],
2593
+ bold: ['Whale-blue bold', 'Bold runs in chat prose take the accent colour'],
2594
+ focusRing: ['Focus ring', 'The soft ring while the composer has focus'],
2595
+ diff: ['Re-inked diffs', 'Added and removed lines in the blue family'],
2596
+ },
2597
+ reset: 'Reset to defaults',
2598
+ close: 'Close',
2599
+ dialog: 'Deep Fish UI settings',
2600
+ button: 'Deep Fish UI settings',
2601
+ },
2602
+ }
2603
+
2604
+ Object.assign(DC_COPY.zh.items, {
2605
+ reading: ['阅读排版', '舒展段落、标题与引用,保留你的字号'],
2606
+ code: ['代码配色', '低饱和语法颜色,保持代码层次'],
2607
+ effortBadge: ['推理等级动画', '输入框里用点阵显示当前推理等级'],
2608
+ sidebarDots: ['悬停点阵', '鼠标悬停在侧边栏按钮上时亮起点阵'],
2609
+ sidebarRail: ['蓝色竖线', '在悬停按钮左侧显示鲸鱼蓝竖线'],
2610
+ thinkingLabel: ['英文思考文案', '把状态行换成 “Deep thinking for 12s. . .”'],
2611
+ diff: ['差异配色', '新增用蓝色,删除用暖色,保留语法高亮'],
2612
+ })
2613
+ Object.assign(DC_COPY.en.items, {
2614
+ reading: ['Reading layout', 'Clear paragraphs, headings and quotes at your chosen font size'],
2615
+ code: ['Code palette', 'Muted, distinct syntax colours'],
2616
+ effortBadge: ['Effort badge', 'Print the reasoning level in dots inside the composer'],
2617
+ sidebarDots: ['Hover dot field', 'Light the dot field around the pointer on sidebar buttons'],
2618
+ sidebarRail: ['Blue rail', 'Show a whale-blue rail on the left of the hovered button'],
2619
+ thinkingLabel: ['English status label', 'Replace the status row with “Deep thinking for 12s. . .”'],
2620
+ diff: ['Diff palette', 'Blue additions and warm deletions, with syntax highlighting intact'],
2621
+ })
2622
+
2623
+ Object.assign(DC_COPY.zh.items, {
2624
+ fishFont: ['Maple Mono 字体', '全站换成 Maple Mono NF CN,正文与代码统一字体'],
2625
+ fishGlow: ['输入框柔光', '16px 圆角,聚焦时带主题色光晕'],
2626
+ fishMotion: ['轻动效', '按钮悬停上浮,界面过渡更柔和'],
2627
+ fishCode: ['代码块质感', '圆角描边与行内代码小药丸'],
2628
+ })
2629
+ Object.assign(DC_COPY.en.items, {
2630
+ fishFont: ['Maple Mono type', 'Use Maple Mono NF CN everywhere, including code'],
2631
+ fishGlow: ['Composer glow', '16px radius plus an accent glow on focus'],
2632
+ fishMotion: ['Soft motion', 'Buttons lift on hover and surfaces ease between states'],
2633
+ fishCode: ['Code surface', 'Rounded code blocks and tinted inline-code pills'],
2634
+ })
2635
+ /** Switch drawn as SVG so the capsule ends and the knob are exact shapes. */
2636
+ function DcSwitchSvg({ value }) {
2637
+ const on = value === true
2638
+ return h('svg', {
2639
+ width: 42,
2640
+ height: 24,
2641
+ viewBox: '0 0 42 24',
2642
+ 'aria-hidden': 'true',
2643
+ style: { display: 'block', overflow: 'visible' },
2644
+ }, [
2645
+ h('rect', {
2646
+ key: 'track',
2647
+ x: 0.5,
2648
+ y: 0.5,
2649
+ width: 41,
2650
+ height: 23,
2651
+ rx: 11.5,
2652
+ ry: 11.5,
2653
+ style: {
2654
+ fill: on
2655
+ ? 'color-mix(in srgb, var(--dsw-alias-label-primary) 94%, transparent)'
2656
+ : 'color-mix(in srgb, var(--dsw-alias-label-tertiary) 44%, transparent)',
2657
+ // Only the enabled state carries an outline; keep the SVG geometry fixed.
2658
+ stroke: on
2659
+ ? 'color-mix(in srgb, var(--dsw-alias-label-primary) 94%, transparent)'
2660
+ : 'none',
2661
+ strokeWidth: 1,
2662
+ transition: 'fill 200ms cubic-bezier(0.22, 1, 0.36, 1), stroke 200ms cubic-bezier(0.22, 1, 0.36, 1)',
2663
+ },
2664
+ }),
2665
+ h('g', {
2666
+ key: 'knob',
2667
+ style: {
2668
+ transform: on ? 'translateX(18px)' : 'translateX(0px)',
2669
+ transition: 'transform 220ms cubic-bezier(0.22, 1, 0.36, 1)',
2670
+ },
2671
+ }, h('circle', {
2672
+ cx: 12,
2673
+ cy: 12,
2674
+ r: 9,
2675
+ style: {
2676
+ fill: on ? 'var(--dsw-alias-bg-base, #17171a)' : 'color-mix(in srgb, var(--dsw-alias-label-primary) 82%, transparent)',
2677
+ transition: 'fill 200ms cubic-bezier(0.22, 1, 0.36, 1)',
2678
+ },
2679
+ })),
2680
+ ])
2681
+ }
2682
+
2683
+ /** One settings row: a label on the left and a switch on the right. */
2684
+ function DcSwitch({ label, description, value, disabled, onChange }) {
2685
+ return h('div', { className: 'dc-set-row' }, [
2686
+ h('div', { key: 'text', className: 'dc-set-text' }, [
2687
+ h('span', { key: 'label', className: 'dc-set-label' }, label),
2688
+ description === undefined
2689
+ ? null
2690
+ : h('span', { key: 'desc', className: 'dc-set-desc' }, description),
2691
+ ]),
2692
+ h('button', {
2693
+ key: 'switch',
2694
+ type: 'button',
2695
+ role: 'switch',
2696
+ disabled,
2697
+ 'aria-checked': value ? 'true' : 'false',
2698
+ 'aria-label': label,
2699
+ className: 'dc-switch',
2700
+ 'data-on': value ? 'true' : undefined,
2701
+ onClick: () => onChange(!value),
2702
+ }, h(DcSwitchSvg, { key: 'glyph', value: value === true })),
2703
+ ])
2704
+ }
2705
+
2706
+ /** The switch list shown inside the sidebar sheet. */
2707
+ const FISH_CSS = `
13
2708
  :root {
14
2709
  --fish-font: "Maple Mono NF CN", "Maple Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
15
- --fish-radius: 16px;
16
2710
  --fish-ink: var(--dc-accent, #7cc8ff);
17
2711
  }
18
-
19
- /* ---------- type ---------- */
20
- html, body {
2712
+ :root:not(.dc-off-fishfont) body {
21
2713
  font-family: var(--fish-font) !important;
22
2714
  font-feature-settings: "ss01" 1, "cv01" 1, "liga" 1;
23
2715
  -webkit-font-smoothing: antialiased;
24
2716
  text-rendering: optimizeLegibility;
25
2717
  }
26
- body {
27
- letter-spacing: .005em;
28
- }
29
- button, input, textarea, select, [contenteditable="true"] {
2718
+ :root:not(.dc-off-fishfont) button,
2719
+ :root:not(.dc-off-fishfont) input,
2720
+ :root:not(.dc-off-fishfont) textarea,
2721
+ :root:not(.dc-off-fishfont) select,
2722
+ :root:not(.dc-off-fishfont) [contenteditable="true"] {
30
2723
  font-family: inherit !important;
31
2724
  }
32
- code, pre, kbd, samp {
2725
+ :root:not(.dc-off-fishfont) code,
2726
+ :root:not(.dc-off-fishfont) pre,
2727
+ :root:not(.dc-off-fishfont) kbd,
2728
+ :root:not(.dc-off-fishfont) samp {
33
2729
  font-family: var(--fish-font) !important;
34
2730
  }
35
- h1, h2, h3 {
36
- font-weight: 650;
37
- letter-spacing: .012em;
38
- }
39
- p, li, blockquote {
2731
+ :root:not(.dc-off-fishfont) p,
2732
+ :root:not(.dc-off-fishfont) li,
2733
+ :root:not(.dc-off-fishfont) blockquote {
40
2734
  line-height: 1.75;
41
2735
  }
42
- :not(pre) > code {
43
- background: color-mix(in srgb, var(--dsw-alias-bg-layer-2, #222) 78%, transparent);
44
- padding: .12em .38em;
45
- border-radius: 5px;
46
- }
47
-
48
- /* ---------- surfaces ---------- */
49
- pre {
50
- border-radius: 12px;
51
- border: 1px solid color-mix(in srgb, var(--dsw-alias-border-l1, #333) 70%, transparent);
52
- }
53
- [data-composer-card] {
54
- border-radius: var(--fish-radius) !important;
2736
+ :root:not(.dc-off-fishglow) [data-composer-card] {
2737
+ border-radius: 16px !important;
55
2738
  transition: box-shadow .25s ease, border-color .25s ease;
56
2739
  }
57
- [data-composer-card]:focus-within {
2740
+ :root:not(.dc-off-fishglow) [data-composer-card]:focus-within {
58
2741
  box-shadow: 0 0 0 1px var(--fish-ink),
59
2742
  0 18px 50px -28px var(--fish-ink) !important;
60
2743
  }
61
- button {
2744
+ :root:not(.dc-off-fishcode) pre {
2745
+ border-radius: 12px;
2746
+ border: 1px solid color-mix(in srgb, var(--dsw-alias-border-l1, #333) 70%, transparent);
2747
+ }
2748
+ :root:not(.dc-off-fishcode) :not(pre) > code {
2749
+ background: color-mix(in srgb, var(--dsw-alias-bg-layer-2, #222) 78%, transparent);
2750
+ padding: .12em .38em;
2751
+ border-radius: 5px;
2752
+ }
2753
+ :root:not(.dc-off-fishmotion) button {
62
2754
  transition: transform .16s ease, box-shadow .16s ease;
63
2755
  }
64
- button:hover {
2756
+ :root:not(.dc-off-fishmotion) button:hover {
65
2757
  transform: translateY(-1px);
66
2758
  }
67
-
68
- /* ---------- selection & scroll ---------- */
69
2759
  ::selection {
70
2760
  background: color-mix(in srgb, var(--fish-ink) 32%, transparent);
71
2761
  }
@@ -80,16 +2770,350 @@ window.__ModuleLoader__.load({
80
2770
  ::-webkit-scrollbar-thumb:hover {
81
2771
  background: var(--fish-ink);
82
2772
  }
83
-
84
2773
  @media (prefers-reduced-motion: reduce) {
85
- * {
86
- animation: none !important;
87
- transition: none !important;
88
- }
2774
+ * { animation: none !important; transition: none !important; }
89
2775
  }
90
2776
  `
2777
+
2778
+ function DcSettingsPage() {
2779
+ const copy = dcUsesChinese() ? DC_COPY.zh : DC_COPY.en
2780
+ const settings = useDcSettings()
2781
+ const state = settings.values
2782
+ const disabled = settings.status !== 'ready' || !settings.writable || settings.pending
2783
+ const update = key => value => dcSetSetting(key, value)
2784
+ const reset = () => dcWrite?.(DC_DEFAULT_SETTINGS)
2785
+ const group = (title, children) => h('section', { key: title, className: 'dc-set-group' }, [
2786
+ h('h3', { key: 'title', className: 'dc-set-group-title' }, title),
2787
+ ...children,
2788
+ ])
2789
+ const item = (key) => {
2790
+ const row = copy.items[key]
2791
+ return h(DcSwitch, {
2792
+ key: key,
2793
+ label: row[0],
2794
+ description: row[1],
2795
+ value: state[key],
2796
+ disabled,
2797
+ onChange: update(key),
2798
+ })
2799
+ }
2800
+ const zh = dcUsesChinese()
2801
+ const status = settings.error
2802
+ ? (zh ? '保存未完成。如果刚更新过插件,请完整退出 DSH 重启后再试。' : 'Could not save. If you just updated the plugin, quit and reopen DSH, then try again.')
2803
+ : settings.status === 'loading' ? (zh ? '正在读取主题设置…' : 'Loading theme preferences…')
2804
+ : settings.status !== 'ready' ? (zh ? '此宿主暂未提供主题设置。' : 'Theme preferences are unavailable on this host.')
2805
+ : !settings.writable ? (zh ? '此配置只读。' : 'These preferences are read-only.')
2806
+ : settings.pending ? (zh ? '正在保存…' : 'Saving…') : ''
2807
+ return h('div', { className: 'dc-set' }, [
2808
+ h('p', { key: 'autosave', className: 'dc-settings-status' }, zh ? '更改立即生效并自动保存。' : 'Changes apply immediately and save automatically.'),
2809
+ status ? h('p', { key: 'status', className: 'dc-settings-status', role: settings.error ? 'alert' : 'status' }, status) : null,
2810
+ group(zh ? '界面与阅读' : 'Interface & reading', [item('reading'), item('code')]),
2811
+ group(copy.groups.hero, [
2812
+ item('hero'), item('field'), item('wave'), item('ripple'),
2813
+ ]),
2814
+ group(copy.groups.thinking, [
2815
+ item('thinkingSphere'), item('thinkingLabel'),
2816
+ ]),
2817
+ group(copy.groups.composer, [
2818
+ item('glass'), item('effortBadge'),
2819
+ ]),
2820
+ group(copy.groups.sidebar, [
2821
+ item('sidebarDots'), item('sidebarRail'),
2822
+ ]),
2823
+ group(copy.groups.accents, [
2824
+ item('bold'), item('focusRing'), item('diff'),
2825
+ ]),
2826
+ group(zh ? 'Fish 字体与质感' : 'Fish finish', [
2827
+ item('fishFont'), item('fishGlow'), item('fishMotion'), item('fishCode'),
2828
+ ]),
2829
+ h('div', { key: 'footer', className: 'dc-set-footer' }, [
2830
+ h('button', { key: 'reset', type: 'button', className: 'dc-set-reset', disabled, onClick: reset }, copy.reset),
2831
+ h('span', { key: 'note', className: 'dc-set-note' }, 'Deep Fish UI · 0.2.0'),
2832
+ ]),
2833
+ ])
2834
+ }
2835
+
2836
+ // ----------------------------------------------------------- sidebar entry
2837
+ /** Sheet state shared by the sidebar button and the panel itself. */
2838
+ let dcSheetOpen = false
2839
+ const dcSheetListeners = new Set()
2840
+ function dcSetSheetOpen(next) {
2841
+ dcSheetOpen = next
2842
+ dcSheetListeners.forEach((listener) => listener())
2843
+ }
2844
+ function useDcSheet() {
2845
+ const [open, setOpen] = React.useState(dcSheetOpen)
2846
+ React.useEffect(() => {
2847
+ const listener = () => setOpen(dcSheetOpen)
2848
+ dcSheetListeners.add(listener)
2849
+ return () => { dcSheetListeners.delete(listener) }
2850
+ }, [])
2851
+ return open
2852
+ }
2853
+ let dcReactDOM = null
2854
+ try {
2855
+ dcReactDOM = require('react-dom')
2856
+ } catch (error) {
2857
+ dcReactDOM = null
2858
+ }
2859
+
2860
+ /** The floating settings sheet, portalled to the body when react-dom is around. */
2861
+ function DcSheet() {
2862
+ const open = useDcSheet()
2863
+ const panelRef = React.useRef(null)
2864
+ React.useEffect(() => {
2865
+ if (!open) return undefined
2866
+ const previousFocus = document.activeElement
2867
+ const panel = panelRef.current
2868
+ const focusable = () => panel === null ? [] : [...panel.querySelectorAll('button:not(:disabled), [href], [tabindex="0"]')]
2869
+ ;(focusable()[0] || panel)?.focus()
2870
+ const onKeyDown = event => {
2871
+ if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); dcSetSheetOpen(false) }
2872
+ if (event.key !== 'Tab') return
2873
+ const items = focusable()
2874
+ const first = items[0] || panel
2875
+ const last = items[items.length - 1] || panel
2876
+ if (event.shiftKey && (document.activeElement === first || document.activeElement === panel)) {
2877
+ event.preventDefault(); last?.focus()
2878
+ } else if (!event.shiftKey && (document.activeElement === last || document.activeElement === panel)) {
2879
+ event.preventDefault(); first?.focus()
2880
+ }
2881
+ }
2882
+ document.addEventListener('keydown', onKeyDown, true)
2883
+ return () => {
2884
+ document.removeEventListener('keydown', onKeyDown, true)
2885
+ if (previousFocus instanceof HTMLElement && previousFocus.isConnected) previousFocus.focus()
2886
+ }
2887
+ }, [open])
2888
+ if (!open) return null
2889
+ const panel = h('div', { key: 'panel', className: 'dc-sheet-panel', ref: panelRef, role: 'dialog', 'aria-modal': 'true', tabIndex: -1, 'aria-label': dcUsesChinese() ? DC_COPY.zh.dialog : DC_COPY.en.dialog }, [
2890
+ h('div', { key: 'head', className: 'dc-sheet-head' }, [
2891
+ h('span', { key: 'title', className: 'dc-sheet-title' }, 'Deep Fish UI'),
2892
+ h('button', {
2893
+ key: 'close',
2894
+ type: 'button',
2895
+ className: 'dc-sheet-close',
2896
+ 'aria-label': dcUsesChinese() ? DC_COPY.zh.close : DC_COPY.en.close,
2897
+ onClick: () => dcSetSheetOpen(false),
2898
+ }, '\u00d7'),
2899
+ ]),
2900
+ h('div', { key: 'body', className: 'dc-sheet-body' }, h(DcSettingsPage)),
2901
+ ])
2902
+ const scrim = h('div', {
2903
+ key: 'scrim',
2904
+ className: 'dc-sheet-scrim',
2905
+ onClick: () => dcSetSheetOpen(false),
2906
+ })
2907
+ const both = h('div', { className: 'dc-sheet-root' }, [scrim, panel])
2908
+ if (dcReactDOM !== null && typeof dcReactDOM.createPortal === 'function') {
2909
+ return dcReactDOM.createPortal(both, document.body)
2910
+ }
2911
+ return both
2912
+ }
2913
+
2914
+ /** Nine-dot glyph used by the sidebar button and its active state. */
2915
+ function DcSettingsIcon({ size = 16, active }) {
2916
+ const unit = size / 16
2917
+ const points = [
2918
+ [3, 3], [8, 3], [13, 3],
2919
+ [3, 8], [8, 8], [13, 8],
2920
+ [3, 13], [8, 13], [13, 13],
2921
+ ]
2922
+ return h('svg', {
2923
+ viewBox: '0 0 16 16',
2924
+ width: size,
2925
+ height: size,
2926
+ 'aria-hidden': 'true',
2927
+ style: { display: 'block' },
2928
+ }, points.map((point, index) => h('circle', {
2929
+ key: index,
2930
+ cx: point[0],
2931
+ cy: point[1],
2932
+ r: 1.35 * unit,
2933
+ fill: active ? 'var(--dc-accent)' : 'currentColor',
2934
+ })))
2935
+ }
2936
+
2937
+ /**
2938
+ * Sidebar footer button that opens the sheet.
2939
+ *
2940
+ * The button carries its own dot field: completely unlit at rest, it surfaces only in a
2941
+ * soft pool around the pointer, clipped to the button, and fades away when the pointer
2942
+ * leaves. Dots never move; only their brightness changes.
2943
+ */
2944
+ function DcSidebarAction({ wide }) {
2945
+ const open = useDcSheet()
2946
+ const { values } = useDcSettings()
2947
+ const showDots = values.sidebarDots !== false
2948
+ const showRail = values.sidebarRail !== false
2949
+ const canvasRef = React.useRef(null)
2950
+ React.useEffect(() => {
2951
+ if (!showDots && !showRail) return
2952
+ const canvas = canvasRef.current
2953
+ if (canvas === null) return
2954
+ const context = canvas.getContext('2d')
2955
+ if (context === null) return
2956
+ const button = canvas.parentElement
2957
+ if (button === null) return
2958
+ const motion = matchMedia('(prefers-reduced-motion: reduce)')
2959
+ const state = { x: -999, y: -999, inside: false, alpha: 0, frame: 0, live: false, dirty: false }
2960
+ let stopped = false
2961
+ let dpr = Math.min(2, devicePixelRatio || 1)
2962
+
2963
+ const measure = () => {
2964
+ const rect = canvas.getBoundingClientRect()
2965
+ dpr = Math.min(2, devicePixelRatio || 1)
2966
+ const width = Math.max(1, Math.round(rect.width * dpr))
2967
+ const height = Math.max(1, Math.round(rect.height * dpr))
2968
+ if (canvas.width !== width || canvas.height !== height) {
2969
+ canvas.width = width
2970
+ canvas.height = height
2971
+ }
2972
+ }
2973
+
2974
+ const paint = () => {
2975
+ state.frame = 0
2976
+ if (stopped) return
2977
+ const rect = canvas.getBoundingClientRect()
2978
+ const width = rect.width
2979
+ const height = rect.height
2980
+ const target = state.inside ? 1 : 0
2981
+ state.alpha = motion.matches ? target : state.alpha + (target - state.alpha) * 0.22
2982
+ context.setTransform(dpr, 0, 0, dpr, 0, 0)
2983
+ context.clearRect(0, 0, width, height)
2984
+ if (!state.inside && state.alpha < 0.02) {
2985
+ state.alpha = 0
2986
+ state.live = false
2987
+ return
2988
+ }
2989
+ const radius = 64
2990
+ const accent = (getComputedStyle(button).getPropertyValue('--dc-accent') || '').trim() || '#7aa4ff'
2991
+ context.fillStyle = accent
2992
+ if (showDots) for (let y = 3; y < height; y += 4) {
2993
+ for (let x = 3; x < width; x += 4) {
2994
+ const dx = x - state.x
2995
+ const dy = y - state.y
2996
+ const distance = Math.sqrt(dx * dx + dy * dy)
2997
+ if (distance > radius) continue
2998
+ const alpha = Math.pow(1 - distance / radius, 1.35) * state.alpha
2999
+ if (alpha < 0.02) continue
3000
+ context.globalAlpha = Math.min(1, alpha)
3001
+ context.beginPath()
3002
+ context.arc(x, y, 0.85, 0, Math.PI * 2)
3003
+ context.fill()
3004
+ }
3005
+ }
3006
+ if (showRail) {
3007
+ const railHeight = Math.max(6, height - 10)
3008
+ const railTop = (height - railHeight) / 2
3009
+ context.globalAlpha = Math.min(1, state.alpha * 0.9)
3010
+ context.beginPath()
3011
+ if (typeof context.roundRect === 'function') {
3012
+ context.roundRect(2, railTop, 3, railHeight, 1.5)
3013
+ } else {
3014
+ context.rect(2, railTop, 3, railHeight)
3015
+ }
3016
+ context.fill()
3017
+ context.globalAlpha = 1
3018
+ }
3019
+ const moving = state.dirty
3020
+ state.dirty = false
3021
+ if (motion.matches) {
3022
+ if (!state.inside) {
3023
+ context.clearRect(0, 0, width, height)
3024
+ state.alpha = 0
3025
+ }
3026
+ state.live = false
3027
+ return
3028
+ }
3029
+ // Idle inside the button: stop the loop until the pointer moves again.
3030
+ if (state.inside && state.alpha >= 0.98 && !moving) {
3031
+ state.live = false
3032
+ return
3033
+ }
3034
+ if (state.inside || state.alpha >= 0.02) {
3035
+ state.frame = requestAnimationFrame(paint)
3036
+ } else {
3037
+ state.live = false
3038
+ }
3039
+ }
3040
+
3041
+ const wake = () => {
3042
+ if (stopped || state.live) return
3043
+ state.live = true
3044
+ if (state.frame === 0) state.frame = requestAnimationFrame(paint)
3045
+ }
3046
+
3047
+ const track = event => {
3048
+ const rect = canvas.getBoundingClientRect()
3049
+ state.x = event.clientX - rect.left
3050
+ state.y = event.clientY - rect.top
3051
+ state.inside = true
3052
+ state.dirty = true
3053
+ wake()
3054
+ }
3055
+ const leave = () => {
3056
+ state.inside = false
3057
+ wake()
3058
+ }
3059
+
3060
+ const resizeObserver = new ResizeObserver(() => {
3061
+ measure()
3062
+ if (state.inside || state.alpha > 0.02) wake()
3063
+ })
3064
+ resizeObserver.observe(canvas)
3065
+ button.addEventListener('pointerenter', track)
3066
+ button.addEventListener('pointermove', track)
3067
+ button.addEventListener('pointerleave', leave)
3068
+ measure()
3069
+ return () => {
3070
+ stopped = true
3071
+ resizeObserver.disconnect()
3072
+ button.removeEventListener('pointerenter', track)
3073
+ button.removeEventListener('pointermove', track)
3074
+ button.removeEventListener('pointerleave', leave)
3075
+ if (state.frame !== 0) cancelAnimationFrame(state.frame)
3076
+ state.frame = 0
3077
+ state.live = false
3078
+ }
3079
+ }, [showDots, showRail])
3080
+ return h('div', { className: 'dc-foot' }, [
3081
+ h('button', {
3082
+ key: 'button',
3083
+ type: 'button',
3084
+ className: 'dc-foot-button',
3085
+ title: 'Deep Fish UI',
3086
+ 'aria-label': dcUsesChinese() ? DC_COPY.zh.button : DC_COPY.en.button,
3087
+ onClick: () => dcSetSheetOpen(!dcSheetOpen),
3088
+ }, [
3089
+ showDots || showRail
3090
+ ? h('canvas', { key: 'dots', ref: canvasRef, className: 'dc-foot-dots', 'aria-hidden': 'true' })
3091
+ : null,
3092
+ h(DcSettingsIcon, { key: 'icon', size: 16, active: open }),
3093
+ wide ? h('span', { key: 'label', className: 'dc-foot-label' }, 'Deep Fish UI') : null,
3094
+ ]),
3095
+ h(DcSheet, { key: 'sheet' }),
3096
+ ])
3097
+ }
3098
+
3099
+
91
3100
  return {
3101
+ inject: ['slots'],
92
3102
  apply(ctx) {
3103
+ dcPlaySplash()
3104
+ ctx.effect(() => {
3105
+ dcMounted = true
3106
+ dcApplySettings()
3107
+ return () => {
3108
+ dcMounted = false
3109
+ dcWrite = null
3110
+ dcSetSheetOpen(false)
3111
+ for (const className of Object.values(DC_OFF_CLASS)) document.documentElement.classList.remove(className)
3112
+ for (const dispose of dcThemeLayers.values()) dispose()
3113
+ dcThemeLayers.clear()
3114
+ dcTheme = null
3115
+ }
3116
+ }, 'dsh-fish-ui: lifecycle')
93
3117
  ctx.effect(() => {
94
3118
  const style = document.createElement('style')
95
3119
  style.dataset.dshPlugin = 'dsh-fish-ui'
@@ -97,6 +3121,73 @@ window.__ModuleLoader__.load({
97
3121
  document.head.append(style)
98
3122
  return () => style.remove()
99
3123
  }, 'dsh-fish-ui: styles')
3124
+ ctx.effect(() => {
3125
+ const style = document.createElement('style')
3126
+ style.dataset.dshPlugin = 'dsh-fish-ui:finish'
3127
+ style.textContent = FISH_CSS
3128
+ document.head.append(style)
3129
+ return () => style.remove()
3130
+ }, 'dsh-fish-ui: finish styles')
3131
+ ctx.inject(['theme'], scope => {
3132
+ scope.effect(() => {
3133
+ dcTheme = scope.theme
3134
+ dcSyncTheme()
3135
+ return () => {
3136
+ for (const dispose of dcThemeLayers.values()) dispose()
3137
+ dcThemeLayers.clear()
3138
+ dcTheme = null
3139
+ }
3140
+ }, 'dsh-fish-ui: token layers')
3141
+ })
3142
+ ctx.effect(() => {
3143
+ const sync = () => {
3144
+ const enabled = dcGetSnapshot().values.effortBadge !== false
3145
+ const label = enabled ? dcEffortLabel() : null
3146
+ dcPaintEffort(label !== null && !DC_EFFORT_OFF.test(label) ? label : null)
3147
+ }
3148
+ sync()
3149
+ const timer = setInterval(sync, 500)
3150
+ return () => {
3151
+ clearInterval(timer)
3152
+ const card = document.querySelector('[data-composer-card]')
3153
+ if (card !== null) {
3154
+ card.removeAttribute('data-dc-effort')
3155
+ card.classList.remove('dc-effort-on', 'dc-effort-max')
3156
+ }
3157
+ }
3158
+ }, 'dsh-fish-ui: effort badge')
3159
+ // Fresh conversation on every launch. The service may not be reachable the first
3160
+ // moment the shell is up, so retry for a few seconds and leave a manual trigger.
3161
+ ctx.inject(['uiWorkspace'], scope => {
3162
+ const open = tries => {
3163
+ try {
3164
+ if (typeof scope.uiWorkspace.startSession === 'function') {
3165
+ scope.uiWorkspace.startSession()
3166
+ console.info('[dsh-fish-ui] opened a new session on launch')
3167
+ return
3168
+ }
3169
+ } catch (error) {
3170
+ console.warn('[dsh-fish-ui] new session failed', error)
3171
+ return
3172
+ }
3173
+ if (tries < 30) window.setTimeout(() => open(tries + 1), 400)
3174
+ }
3175
+ window.__dcNewSession = () => open(0)
3176
+ scope.effect(() => {
3177
+ const timer = window.setTimeout(() => open(0), 2500)
3178
+ return () => window.clearTimeout(timer)
3179
+ }, 'dsh-fish-ui: new session on launch')
3180
+ })
3181
+ ctx.inject(['configForms'], dcConnectSettings)
3182
+ const add = (name, options, Component) => ctx.slots.inject(name,
3183
+ () => ctx.slots.register({ name, ...options }, dcSafe(Component)))
3184
+ add('conversation.hero.frame', { id: 'dot-whale', order: 20 }, HeroFrame)
3185
+ add('sidebar.footer.action', { id: 'dsh-fish-ui', order: 5, label: () => 'Deep Fish UI' }, DcSidebarAction)
3186
+ add('shell.overlay', { id: 'dc-ambient', order: 5 }, DcOverlay)
3187
+ add('shell.overlay', { id: 'dc-sidebar-dots', order: 6 }, DcSidebarDots)
3188
+ add('shell.overlay', { id: 'dc-caret-trail', order: 4 }, DcCaretTrail)
3189
+ // Package name, distinct from the Host entry id even though both currently match.
3190
+ add('plugins.bundle.config', { key: 'dsh-fish-ui' }, DcSettingsPage)
100
3191
  },
101
3192
  }
102
3193
  },