dsh-fish-ui 0.3.1 → 0.5.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/dist/client.js ADDED
@@ -0,0 +1,3823 @@
1
+ /**
2
+ * Deep Fish UI — the blank New Session surface.
3
+ *
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.
18
+ */
19
+ window.__ModuleLoader__.load({
20
+ id: 'dsh-fish-ui',
21
+ factory(require) {
22
+ const React = require('react');
23
+ const h = React.createElement;
24
+ const SCENES = {
25
+ atlas: {
26
+ en: 'Tidal Atlas', zh: '潮汐图谱', caption: ['Drifting depth contours', '等深线随海流缓缓漂移'],
27
+ colors: ['#152665', '#2E4DA7', '#9CBFFF', '#D9E5FF'],
28
+ icon: 'contour',
29
+ },
30
+ aurora: {
31
+ en: 'Polar Silk', zh: '极光帷幕', caption: ['Ribbons of light over a polar ridge', '极光掠过远山的轮廓'],
32
+ colors: ['#171b48', '#384676', '#91ead0', '#d4b1fb'],
33
+ icon: 'aurora',
34
+ },
35
+ orbit: {
36
+ en: 'Lunar Orbit', zh: '月相轨道', caption: ['Satellites trace an orbital chart', '卫星沿星图上的轨道运行'],
37
+ colors: ['#191b38', '#484069', '#d0baff', '#f7d8a3'],
38
+ icon: 'orbit',
39
+ },
40
+ dunes: {
41
+ en: 'Amber Dunes', zh: '琥珀沙丘', caption: ['Wind moves across the sand ridges', '风吹动落日下的沙脊'],
42
+ colors: ['#65383f', '#c87852', '#ffc985', '#fff1bd'],
43
+ icon: 'dunes',
44
+ },
45
+ rain: {
46
+ en: 'Neon Rain', zh: '霓虹夜雨', caption: ['Rain streaks past a lit skyline', '斜雨掠过楼顶的霓虹灯'],
47
+ colors: ['#111936', '#374274', '#80d6ec', '#f2a1d8'],
48
+ icon: 'rain',
49
+ },
50
+ lotus: {
51
+ en: 'Celadon Pond', zh: '青瓷莲池', caption: ['Ripples open between lotus leaves', '水纹从荷叶间一圈圈散开'],
52
+ colors: ['#123a3b', '#447766', '#b2dbc0', '#f7cfbf'],
53
+ icon: 'lotus',
54
+ },
55
+ };
56
+ const BRAND_BLUE = '#4D6BFE';
57
+ const ACCENT_SWATCHES = [
58
+ [BRAND_BLUE, 'DeepSeek 蓝', 'DeepSeek blue'],
59
+ ['#7855CA', '鸢尾紫', 'Iris'],
60
+ ['#157B77', '孔雀青', 'Teal'],
61
+ ['#AB6132', '琥珀棕', 'Amber'],
62
+ ['#BA4774', '玫瑰红', 'Rose'],
63
+ ];
64
+ const STUDIO_CHOICES = {
65
+ scene: Object.keys(SCENES), sceneMotion: ['still', 'calm', 'flow'], iconStyle: ['line', 'duotone'],
66
+ };
67
+ // The same vector originals are used on the conversation, the selector and the cover.
68
+ // Only the conversation animates. No timers or network requests are needed for a plate.
69
+ const path = (d, props) => h('path', { d, ...props });
70
+ const circle = (cx, cy, r, props) => h('circle', { cx, cy, r, ...props });
71
+ const ellipse = (cx, cy, rx, ry, props) => h('ellipse', { cx, cy, rx, ry, ...props });
72
+ const marks = (count, draw) => Array.from({ length: count }, (_, n) => draw(n));
73
+ function chartStars(color, count) {
74
+ return h('g', { fill: color }, marks(count, n => circle((n * 97 + 19) % 402, (n * 47 + 13) % 170, n % 6 === 0 ? 1.05 : .52, { key: n, opacity: .35 + (n % 4) * .15 })));
75
+ }
76
+ function drawAtlas([, , mint, sand], url) {
77
+ const contour = 'M-77 -14C-78 -37 -50 -57 -28 -52S7 -61 31 -49S69 -35 71 -13S99 16 72 33S37 61 13 49S-17 60 -41 45S-83 19 -77 -14Z';
78
+ const bank = (x, y, scale, rotate, count, hue) => h('g', {
79
+ transform: 'translate(' + x + ' ' + y + ') rotate(' + rotate + ') scale(' + scale + ')',
80
+ }, marks(count, n => path(contour, {
81
+ key: n, transform: 'scale(' + (.19 + n * .12) + ')',
82
+ fill: n === 5 ? url('wash') : 'none', stroke: hue,
83
+ strokeWidth: n % 4 === 0 ? 1.15 : .65, opacity: n % 4 === 0 ? .8 : .53,
84
+ })));
85
+ return h('g', null, h('rect', { width: 400, height: 180, fill: url('grid'), opacity: .42 }), h('g', { className: 'fish-current' }, bank(336, 17, 1.23, -22, 18, mint), bank(41, 174, .94, 14, 16, mint)), path('M-12 86Q63 32 136 67T268 104T416 64', { fill: 'none', stroke: sand, strokeDasharray: '2 4', opacity: .78 }), h('g', { transform: 'translate(274 94)', stroke: sand, fill: 'none', strokeWidth: .75 }, circle(0, 0, 10), circle(0, 0, 2.4), path('M-16 0H-6M6 0H16M0 -16V-6M0 6V16')), h('g', { fill: sand }, circle(92, 56, 1.8), circle(182, 88, 1.4)));
86
+ }
87
+ function drawAurora([ink, mid, mint, lilac], url) {
88
+ return h('g', null, chartStars('#e7faf6', 54), h('g', { className: 'fish-curtain' }, path('M-45 109C50 -42 104 150 208 55S355 -33 453 16L443 75C310 22 286 87 191 110S43 37 -38 146Z', { fill: url('silk') }), h('g', { fill: 'none', stroke: mint }, marks(21, n => path('M-25 ' + (106 + n * .8) + 'C58 ' + (-32 + n * 1.5) + ' 109 ' + (145 + n * 1.2) + ' 200 ' + (67 + n * .72) + 'S342 ' + (-38 + n * 1.5) + ' 428 ' + (14 + n * .85), { key: n, strokeWidth: n % 5 === 0 ? .85 : .4, opacity: .22 + n * .016 }))), path('M-15 66C83 12 122 105 203 56S340 -8 427 9', { fill: 'none', stroke: lilac, opacity: .6, strokeWidth: 1 })), path('M0 155L49 131 74 141 122 107 145 124 175 102 198 119 224 101 276 133 315 107 361 123 400 102V181H0Z', { fill: mid }), path('M0 164L73 143 108 152 157 123 189 140 233 116 278 142 324 127 362 141 400 128V181H0Z', { fill: ink }), path('M0 164L73 143 108 152 157 123 189 140 233 116 278 142 324 127 362 141 400 128', { fill: 'none', stroke: lilac, strokeWidth: .7, opacity: .6 }));
89
+ }
90
+ function drawOrbit([ink, mid, lilac, gold], url) {
91
+ return h('g', null, chartStars('#f0e7ff', 66), h('g', { transform: 'translate(267 77) rotate(-21)', fill: 'none', stroke: lilac }, marks(5, n => ellipse(0, 0, 50 + n * 25, 19 + n * 13, {
92
+ key: n, strokeWidth: n === 2 ? 1.1 : .6, strokeDasharray: n === 3 ? '2 3' : undefined, opacity: .6,
93
+ })), h('g', { transform: 'scale(1 .40)' }, h('g', { className: 'fish-revolve' }, ellipse(75, 0, 3.1, 7.75, { fill: gold, stroke: 'none' })))), circle(267, 77, 43, { fill: url('halo') }), circle(267, 77, 29, { fill: url('planet') }), path('M249 54Q237 87 268 106A29 29 0 0 1 249 54Z', { fill: mid, opacity: .7 }), h('g', { fill: ink, opacity: .2 }, circle(273, 65, 3.2), circle(283, 78, 4.3), circle(265, 88, 2)), path('M20 68L55 53 78 70 110 43 141 49', { fill: 'none', stroke: lilac, strokeWidth: .6 }), h('g', { fill: gold }, circle(20, 68, 1.4), circle(55, 53, 1.8), circle(78, 70, 1.4), circle(110, 43, 2), circle(141, 49, 1.4)), path('M335 134v10m-5 -5h10M162 24v7m-3.5 -3.5h7', { fill: 'none', stroke: gold, strokeWidth: 1 }));
94
+ }
95
+ function drawDunes([ink, mid, apricot, ivory], url) {
96
+ return h('g', null, circle(277, 55, 52, { fill: url('halo') }), circle(277, 55, 28, { fill: url('planet') }), circle(277, 55, 34, { fill: 'none', stroke: ivory, opacity: .5, strokeWidth: .6 }), path('M-14 105Q49 81 99 95T204 91T305 88T415 61V182H-14Z', { fill: apricot, opacity: .64 }), path('M-14 97C37 83 86 122 160 116S326 56 415 88V182H-14Z', { fill: mid }), h('g', { className: 'fish-sand' }, path('M-18 142C66 150 145 79 220 98S339 154 421 120V188H-18Z', { fill: ink }), h('g', { fill: 'none', stroke: apricot }, marks(16, n => path('M-20 ' + (142 + n * 3.2) + 'C68 ' + (150 + n * 2.5) + ' 146 ' + (78 + n * 3.6) + ' 220 ' + (98 + n * 3.3) + 'S339 ' + (154 + n * 3.5) + ' 423 ' + (120 + n * 2.5), { key: n, strokeWidth: n === 0 ? 1.4 : .55, opacity: n === 0 ? .98 : .48 })))), path('M62 59q6 -4 11 0q4 -6 10 -6M101 44q4 -2 7 1q4 -4 8 -4', { fill: 'none', stroke: ivory, opacity: .8, strokeWidth: .9 }));
97
+ }
98
+ function drawRain([ink, mid, ice, pink], url) {
99
+ const roofs = marks(20, n => {
100
+ const x = n * 22 - 8;
101
+ const y = 55 + (n * 37) % 74;
102
+ return h('g', { key: n }, h('rect', { x, y, width: 19, height: 150 - y, fill: n % 3 === 0 ? mid : ink }), path('M' + x + ' ' + y + 'h18', { stroke: n % 3 === 0 ? pink : ice, opacity: .8, strokeWidth: 1 }), h('rect', { x: x + 3, y: y + 5, width: 12, height: 144 - y, fill: url('windows') }));
103
+ });
104
+ return h('g', null, circle(287, 62, 45, { fill: url('halo') }), circle(287, 62, 20, { fill: pink, opacity: .85 }), roofs, path('M0 147H400V180H0Z', { fill: ink }), h('g', null, marks(41, n => {
105
+ const x = (n * 61) % 400;
106
+ return path('M' + x + ' ' + (150 + n % 24) + 'h' + (3 + n % 13), { key: n, stroke: n % 3 ? ice : pink, opacity: .28 + n % 4 * .11, strokeWidth: 1 });
107
+ })), h('g', { className: 'fish-rainfall', stroke: ice, strokeWidth: .65, opacity: .57 }, marks(48, n => {
108
+ const x = (n * 83) % 452 - 12;
109
+ return path('M' + x + ' ' + ((n * 43) % 226 - 33) + 'l-5 14', { key: n });
110
+ })));
111
+ }
112
+ function drawLotus([ink, mid, jade, blush], url) {
113
+ const pad = (x, y, size, angle) => h('g', { transform: 'translate(' + x + ' ' + y + ') rotate(' + angle + ') scale(' + size + ')' }, path('M0 0L-28 17C-47 7 -43 -17 -21 -25C5 -40 45 -22 44 0C42 22 6 36 -22 23Z', { fill: mid, stroke: jade, strokeWidth: 1.15 }), path('M0 0Q-10 -9 -22 -18M0 0Q3 -16 10 -25M0 0Q21 -10 34 -10M0 0Q21 5 30 14M0 0Q3 13 -9 23', { fill: 'none', stroke: jade, opacity: .55, strokeWidth: .8 }));
114
+ return h('g', null, h('g', { transform: 'translate(249 93) scale(1 .48)', fill: 'none', stroke: jade }, h('g', { className: 'fish-pond-ring' }, marks(6, n => circle(0, 0, 22 + n * 17, { key: n, strokeWidth: n % 2 ? .65 : 1.15, opacity: .72 - n * .075 })))), pad(370, 33, 1.12, -16), pad(332, 2, .72, 12), pad(32, 148, 1.08, 8), pad(84, 155, .53, -21), h('g', { transform: 'translate(247 90)' }, marks(9, n => path('M0 0C-8 -5 -10 -14 -3 -23C4 -18 9 -7 0 0Z', { key: n, transform: 'rotate(' + (n * 40) + ')', fill: n % 2 ? blush : jade, stroke: ink, strokeWidth: .75 })), circle(0, 0, 3.6, { fill: '#f8da91' })), h('g', { fill: jade, opacity: .65 }, circle(169, 37, 1.15), circle(178, 39, .7), circle(129, 111, 1)));
115
+ }
116
+ const DRAW_SCENE = { atlas: drawAtlas, aurora: drawAurora, orbit: drawOrbit, dunes: drawDunes, rain: drawRain, lotus: drawLotus };
117
+ // Each pair is an outline and, where appropriate, a second ink underneath it.
118
+ const FISH_ICONS = {
119
+ fish: ['M2 8.5 7 11c3-6 10-6.5 14 1-4.5 7.5-11 7-14 1L2 15.5Z M14 7.2c-2 3.1-2 6.5 0 9.6 M17.2 11.2h.1', 'M7 12c3-6 10-6 14 0-4 7-11 7-14 0Z'],
120
+ contour: ['M2 14c0-5 3-6 6-6s3-5 7-5 7 4 7 8-5 4-7 7-6 4-9 2-4-3-4-6Z M6 14c0-3 4-3 6-6s6-1 6 2-3 3-5 6-7 2-7-2Z M10 14l4-3', 'M2 14c0-5 3-6 6-6s3-5 7-5 7 4 7 8-5 4-7 7-6 4-9 2-4-3-4-6Z'],
121
+ aurora: ['M2 16c5-13 8 2 14-9l4-4 M2 20c6-14 9 0 15-10l5-6 M7 5l.6 1.8L9.5 7l-1.9.6L7 9.5l-.6-1.9L4.5 7l1.9-.2Z', 'M2 16c5-13 8 2 14-9l4-4-3 7c-6 10-9-4-15 10Z'],
122
+ orbit: ['M8 8.5a5 5 0 1 1-.5 6.3 M19.5 7c4-1 2.5 3-4 7S1 20 2.5 16c.5-1.3 2.3-3.2 4.5-5 M18 3v2m-1-1h2', 'M12 7a5 5 0 1 1 0 10 5 5 0 1 1 0-10Z'],
123
+ dunes: ['M1.5 18c5 2 8-8 14-5s6 5 7 4 M2 21h20 M3 13l4-3 4 2 M14 9a3 3 0 1 1 5 .2', 'M2 18c5 2 8-8 14-5s6 5 6 4v4H2Z'],
124
+ rain: ['M4 15V9h5v6m0-6V6h6v9m0-4h5v4 M2 16h20 M6 19l-1 2m7-2-1 2m7-2-1 2 M17 4l-1 2m5-3-1 2', 'M4 9h5V6h6v5h5v5H4Z'],
125
+ lotus: ['M12 18c-4-3-5-7 0-13 5 6 4 10 0 13Z M10 17c-4 0-7-3-8-8 4 .3 7 2 8 4m4 4c4 0 7-3 8-8-4 .3-7 2-8 4 M4 20c4 1 12 1 16 0', 'M12 18c-4-3-5-7 0-13 5 6 4 10 0 13Z'],
126
+ gallery: ['M3 4h7v7H3Zm11 0h7v7h-7ZM3 15h7v6H3Zm11 0h7v6h-7Z', 'M3 4h7v7H3Zm11 11h7v6h-7Z'],
127
+ sliders: ['M3 6h4m5 0h9M3 12h10m5 0h3M3 18h3m5 0h10 M7 4v4h4V4Zm7 6v4h4v-4Zm-8 6v4h4v-4Z', 'M7 4h4v4H7Zm7 6h4v4h-4Zm-8 6h4v4H6Z'],
128
+ reading: ['M3 5c4-1 6-.5 9 2 3-2.5 5-3 9-2v13c-4-1-6-.5-9 2-3-2.5-5-3-9-2ZM12 7v13', 'M3 5c4-1 6-.5 9 2v13c-3-2.5-5-3-9-2Z'],
129
+ code: ['m7 7-5 5 5 5m10-10 5 5-5 5m-4-13-3 16'],
130
+ hero: ['M4 3h16v18H4ZM7 16l4-5 3 3 2-2 2 4M8 7h.1', 'M5 17l6-6 3 3 2-2 3 5Z'],
131
+ field: ['M3 6h18M3 12h18M3 18h18M6 3v18M12 3v18M18 3v18'],
132
+ wave: ['M2 8q3-4 7 0t7 0q3-3 6-1 M2 13q3-4 7 0t7 0q3-3 6-1 M2 18q3-4 7 0t7 0q3-3 6-1'],
133
+ ripple: ['M6 10c-5 2-5 6 0 8s13 1 15-2-2-5-4-6 M8 12c-3 2 0 4 4 4s7-2 4-4 M12 3c-3 4-3.5 6 0 7 3.5-1 3-3 0-7Z', 'M12 3c-3 4-3.5 6 0 7 3.5-1 3-3 0-7Z'],
134
+ thinkingSphere: ['M12 3a9 9 0 1 1 0 18 9 9 0 0 1 0-18Zm0 0c-6 5-6 13 0 18 6-5 6-13 0-18ZM3 12h18'],
135
+ thinkingLabel: ['M4 4h16v13h-8l-5 4v-4H4ZM7 9h10M7 12h7', 'M4 4h16v13h-8l-5 4v-4H4Z'],
136
+ glass: ['m3 8 9-5 9 5-9 5Zm0 4 9 5 9-5M3 16l9 5 9-5', 'm3 8 9-5 9 5-9 5Z'],
137
+ effortBadge: ['m13 2-8 12h6l-1 8 9-13h-7Z', 'm13 2-8 12h6l-1 8 9-13h-7Z'],
138
+ sidebarDots: ['M3 4h18v16H3ZM10 4v16M6.3 8h.3m-.3 4h.3m-.3 4h.3', 'M3 4h7v16H3Z'],
139
+ sidebarRail: ['M3 4h18v16H3ZM8 4v16M12 9h6m-6 5h4', 'M3 4h5v16H3Z'],
140
+ bold: ['M6 4h7a4 4 0 0 1 0 8H7m0-8v16h7a4 4 0 0 0 0-8H7'],
141
+ focusRing: ['M8 3H3v5m13-5h5v5m0 8v5h-5M3 16v5h5 M8 8h8v8H8Z', 'M8 8h8v8H8Z'],
142
+ diff: ['M5 3v13c0 4 4 4 7 4h4m-2-3 3 3-3 3 M12 6h9m-4.5-4.5v9'],
143
+ fishFont: ['m2 18 5-14 5 14M4 13h6m3 2c2-3 7-1 7-3s-2-4-6-2m6 2v6c-3 2-8 1-7-3'],
144
+ fishGlow: ['M12 2l2.7 7.3L22 12l-7.3 2.7L12 22l-2.7-7.3L2 12l7.3-2.7Z', 'M12 2l2.7 7.3L22 12l-7.3 2.7L12 22l-2.7-7.3L2 12l7.3-2.7Z'],
145
+ fishMotion: ['M2 8h7M2 12h4m-3 4h5m1-4 6-7 7 7-7 7Z', 'm9 12 6-7 7 7-7 7Z'],
146
+ fishCode: ['M3 4h18v16H3Zm0 4h18m-14 4 3 2-3 2m5 0h4', 'M3 4h18v4H3Z'],
147
+ catppuccin: ['M12 3a9 9 0 1 0 0 18h1c2 0 2-2 1-3s-1-3 1-3h3c5 0 3-12-6-12Z M7 10h.1m3-3h.1m4 0h.1m3 3h.1', 'M12 3a9 9 0 1 0 0 18h1c2 0 2-2 1-3s-1-3 1-3h3c5 0 3-12-6-12Z'],
148
+ cursor: ['m4 3 15 9-7 1-3 7Z', 'm4 3 15 9-7 1-3 7Z'],
149
+ textMotion: ['M3 6h12M3 11h8m-8 5h5m7-6 6 4-6 4Z', 'm15 10 6 4-6 4Z'],
150
+ still: ['M7 5v14M17 5v14'],
151
+ line: ['m3 18 4-1L20 5l-2-2L5 15ZM3 21h18'],
152
+ duotone: ['M3 5h11v12H3Zm7 4h11v12H10Z', 'M10 9h11v12H10Z'],
153
+ check: ['m5 12 4.5 4.5L19 7'],
154
+ close: ['m6 6 12 12M18 6 6 18'],
155
+ reset: ['M4 10a8 8 0 1 1 1 7M4 4v6h6'],
156
+ newChat: ['M13 4H7a4 4 0 0 0-4 4v7a4 4 0 0 0 4 4h1v3l5-3h3a4 4 0 0 0 4-4v-3M18 2v7m-3.5-3.5h7', 'M4 8a3 3 0 0 1 3-3h5v6h7v4c0 2-1 3-3 3h-3l-5 3v-3H7c-2 0-3-1-3-3Z'],
157
+ search: ['M10.5 3.5a7 7 0 1 0 0 14 7 7 0 0 0 0-14ZM16 16l5 5M7 10a3.5 3.5 0 0 1 3.5-3.5', 'M10.5 3.5a7 7 0 1 0 0 14 7 7 0 0 0 0-14Z'],
158
+ attach: ['m8 14 7.7-7.7a2.1 2.1 0 0 1 3 3l-9 9a4.2 4.2 0 0 1-6-6l9.6-9.6a2 2 0 0 1 .9-.6 M7.5 14.5l6.7-6.7', 'm7 17 10-10 1.8 1.5L9 18Z'],
159
+ copy: ['M8 7V5a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-2 M5 7h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z', 'M5 7h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z'],
160
+ send: ['M12 20V4m-7 7 7-7 7 7', 'M5 11l7-7 7 7-7-2Z'],
161
+ plane: ['M2 11 22 3l-6 18-5-6-4 4v-6Zm5 2 10-6-6 8', 'm7 13 10-6-6 8 5 6 6-18Z'],
162
+ folder: ['M3 6a2 2 0 0 1 2-2h5l3 3h6a2 2 0 0 1 2 2v1M3 6v13h15l4-9H8l-3 6', 'M8 10h14l-4 9H4Z'],
163
+ folderClosed: ['M3 7a2 2 0 0 1 2-2h5l3 3h6a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2ZM3 10h18', 'M3 10h18v8c0 1-1 2-2 2H5c-1 0-2-1-2-2Z'],
164
+ mic: ['M9 6a3 3 0 1 1 6 0v6a3 3 0 0 1-6 0Zm-4 6a7 7 0 0 0 14 0m-7 7v3m-4 0h8', 'M9 6a3 3 0 1 1 6 0v6a3 3 0 0 1-6 0Z'],
165
+ };
166
+ const PRODUCT_ICONS = {
167
+ 'new-chat-outline': 'newChat', 'search-outline': 'search', 'settings-outline': 'sliders',
168
+ 'panel-left-outline': 'sidebarRail', 'copy-outline': 'copy', 'code-outline': 'fishCode',
169
+ 'paperclip-outline': 'attach', 'paper-plane-outline': 'plane', 'send-outline': 'send',
170
+ 'folder-open-outline': 'folder', 'folder-open': 'folder', 'folder-close': 'folderClosed',
171
+ 'microphone-outline': 'mic', 'sliders-two-outline': 'sliders',
172
+ };
173
+ // Mask the existing sized SVG. The host keeps its button, title, events and disabled state.
174
+ function productIconCss() {
175
+ const ids = (name) => ':is([data-icon="dsw-icon-' + name + '-regular"],[data-icon="dsw-icon-' + name + '-medium"])';
176
+ const mask = (outline, tone) => {
177
+ const svg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">'
178
+ + (tone ? '<path d="' + tone + '" opacity=".43"/>' : '')
179
+ + '<path d="' + outline + '" fill="none" stroke="black" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round"/></svg>';
180
+ return 'url("data:image/svg+xml,' + encodeURIComponent(svg) + '")';
181
+ };
182
+ const rules = Object.entries(PRODUCT_ICONS).map(([name, icon]) => {
183
+ const [outline, tone] = FISH_ICONS[icon];
184
+ return 'svg' + ids(name) + '{--fish-outline:' + mask(outline) + ';--fish-duotone:' + mask(outline, tone) + '}';
185
+ });
186
+ const target = ' svg:is(' + Object.keys(PRODUCT_ICONS).map(ids).join(',') + ')';
187
+ const root = 'html:not(.df-off-hosticons)';
188
+ return '@supports (mask-image:linear-gradient(white,black)){' + rules.join('')
189
+ + root + '[data-fish-icons="line"]' + target + '{background:currentColor;mask:var(--fish-outline) center/contain no-repeat}'
190
+ + root + '[data-fish-icons="duotone"]' + target + '{background:linear-gradient(128deg,currentColor 42%,color-mix(in srgb,currentColor 55%,var(--df-accent)));mask:var(--fish-duotone) center/contain no-repeat}'
191
+ + root + '[data-fish-icons]' + target + '>use{visibility:hidden}}';
192
+ }
193
+ function FishBrand() {
194
+ return h('svg', { viewBox: '0 0 64 64', className: 'fish-logo', 'aria-hidden': true, focusable: false }, path('M27 28Q28 18 40 12L38 23ZM31 39Q29 45 32 50Q40 43 40 33Z', { fill: '#9DD7FF' }), path('M18 36C25 25 39 16 54 17C52 32 39 43 21 43C16 47 11 49 6 49C9 44 12 40 15 38C11 34 9 29 10 24C15 26 18 31 18 36Z', { fill: '#F5FBFF' }), path('M23 39C31 37 36 33 40 29M11 53Q18 52 24 48', { fill: 'none', stroke: '#8DC0FF', strokeWidth: 2, strokeLinecap: 'round' }), circle(46.3, 23.4, 2.1, { fill: '#243EAA' }));
195
+ }
196
+ function FishIcon({ name, size = 18 }) {
197
+ const [outline, tone] = FISH_ICONS[name];
198
+ return h('svg', { className: 'fish-icon', width: size, height: size, viewBox: '0 0 24 24', fill: 'none', 'aria-hidden': true, focusable: false }, tone && path(tone, { className: 'fish-icon-tone' }), path(outline, { stroke: 'currentColor', strokeWidth: 1.65, strokeLinecap: 'round', strokeLinejoin: 'round' }));
199
+ }
200
+ const FishPlate = React.memo(function FishPlate({ scene, className, align = 'xMidYMid slice' }) {
201
+ const id = 'fish-plate-' + React.useId().replace(/[^a-zA-Z0-9_-]/g, '');
202
+ const ref = (name) => 'url(#' + id + '-' + name + ')';
203
+ const colors = SCENES[scene].colors;
204
+ const [ink, mid, accent, glint] = colors;
205
+ const stop = (offset, stopColor, stopOpacity = 1) => h('stop', { offset, stopColor, stopOpacity });
206
+ return h('svg', { className, viewBox: '0 0 400 180', preserveAspectRatio: align, 'aria-hidden': true, focusable: false }, h('defs', null, h('linearGradient', { id: id + '-base', x1: '0%', y1: '100%', x2: '82%', y2: '0%' }, stop(0, ink), stop(1, mid)), h('radialGradient', { id: id + '-wash' }, stop(0, accent, .29), stop(1, accent, .02)), h('radialGradient', { id: id + '-halo' }, stop(0, glint, .63), stop(.5, glint, .27), stop(1, glint, 0)), h('linearGradient', { id: id + '-planet', x2: '90%', y2: '70%' }, stop(0, glint), stop(.65, accent), stop(1, mid)), h('linearGradient', { id: id + '-silk', x1: '0%', y1: '90%', x2: '55%', y2: '0%' }, stop(0, accent, .02), stop(.55, accent, .8), stop(1, glint, .08)), h('pattern', { id: id + '-grid', width: 18, height: 18, patternUnits: 'userSpaceOnUse' }, path('M18 0H0V18', { fill: 'none', stroke: accent, opacity: .55, strokeWidth: .54 })), h('pattern', { id: id + '-windows', width: 5, height: 7, patternUnits: 'userSpaceOnUse' }, h('rect', { x: 1, y: 1, width: 1.3, height: 2.6, fill: glint, opacity: .65 }))), h('rect', { width: 400, height: 180, fill: ref('base') }), DRAW_SCENE[scene](colors, ref));
207
+ });
208
+ /* ------------------------------------------------------------ hero mascot */
209
+ /** Dot grid sampled from the mascot artwork: one hex digit per cell. */
210
+ const GIRL_COLUMNS = 104;
211
+ const GIRL_ROWS = 73;
212
+ const GIRL_GRID = '00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000121100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013133112320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000163116400000264223200000000000000000000000000000000000000000000000000000000000000000000000000000000000326000001000000a800134000000000000000000000000000000000000000000000000000000000000000000000000000000002500000001200020000000014000000000000000000000000000000000000000000000000000000000000000000000000000000353000310023201320020000050000000000000000000000000000000000000000000000000000000000000000000000000000003000003310000000001300001b33300000000000000000000000000000000000000000000000000000000000000000000000000100010110035457764200000022002400000000000000000000000000000000000000000000000000000000000000000000000030000300006aba999accb820022000003000000000000000000000000000000000000000000000000000000000000000000000031000000224abbaa976778bca300200008900000000000000000000000000000000000000000000000000000000000000000000a1031005789787777898777679c8000000055000000000000000000000000000000000000000000000000000000000000000000b800220a98b96777777788777777ab30001008100000000000000000000000000000000000000000000000000000000000000007f00002b97b97777777777777777768c402100460000000000000000000000000000000000000000000000000000000000000000ef4000a9699777777777777778777677b600000a2000000000000000000000000000000000000000000000000000000000000000820107a68978777777777777778766788b30000c220000000000000000000000000000000000000000000000000000000000000300003b77887877777777877777787677889220af30300000000000000000000000000000000000000000000000000000000000130000897787787777777797754778877779960025d002000000000000000000000000000000000000000000000000000000000040000297777778777875878a777677977777981000870300000000000000000000000000000000000000000000000000000000003101069878778777865578779777778977778a70105a0300000000000000000000000000000000000000000000000000000000000c60288778778877744778855977777987777994004b0401000000000000000000000000000000000000000000000000000000008d00596788777777757878880497777897777888009a059800000000000000000000000000000000000000000000000000000002e00077578878668777777899203987779777778931ea57780000000000000000000000000000000000000000000000000000000aa004956788784587777777894246988789787788648688681000000000000000000000000000000000000000000000000000000ec00784679878439877777868710049888a74778877667da30000000000000000000000000000000000000000000000000000002fe20964779878408877777856800005878836877877749dd800000000000000000000000000000000000000000000000000000003c01857679879305977777762910000327985487876a7bbad90000000000000000000000000000000000000000000000000000000e00778679878433887877782610001620864877786aecbaad700000000000000000000000000000000000000000000000000002dda47786798787005868867755205cffde4587778887bbbaaad7000000000000000000000000000000000000000000000000004dccdb677778979300076788777604fc5d48fa77778868aaaaaaad50000000000000000000000000000000000000000000000003c2bcc9677778976300046677777704cb7ca0b96777796bbaaaaaaad400000000000000000000000000000000000000000000000a91ebb8777777974300002477776460abe8a02387877889acbaaaaabc2000000000000000000000000000000000000000000000009edba77777779812039a7038678400687660058787689703accbaaabc1000000000000000000000000000000000000000000000004ba977777778900dffab603624520073430087886599c00037bccbabc000000000000000000000000000000000000000000000000ba878787778908c9c89b001100000121104789756a9a900000369ccdb0000000000000000000000000000000000000000000000aca88969777893f26bbe91000111111111347a8649a98b8100000015afc000000000000000000000000000000000000000000006caa8996a877786f01a6562011111111222237a669aa888cb7414600000aa0000000000000000000000000000000000000000002daaa89b6a96777b9502742111111000111110586999998799047558778698000000000000000000000000000000000000000000bbaabaa969a77778600022011110012201100177aa7999777a400000210210000000000000000000000000000000000000000009caaadc6078b877779501112111036666010028aaa76a9a777880000000000000000000000000000000000000000000000000006daabda144a7aa778777401211105a434201000bb996699a86778400000000000000000000000000000000000000000000000005daaca4002aa7898789777532111014343101009d987769aa9677781000000000000000000000000000000000000000000000003dbcc700006c99788977a8473001110011001009db877768a9976767700000000000000000000000000000000000000000000000ddc8200005c9998789a868acb20000000011004cbb777667a9a8676786000000000000000000000000000000000000000000000bb600008867aa88977899967abc8310000000235baa7774678a99666759600000000000000000000000000000000000000000000d6269893007b9787778a788779aabcba52213425cb898536889997667509700000000000000000000000000000000000000000000562020000b97788889a967898989bb65444433278aa7647798998666810780000000000000000000000000000000000000000000000000007b7777225bca7768b989b802333331015c977677a889966777004830000000000000000000000000000000000000000000000000b7778410007c8676898ac502122222203c9877669a88a97878400096000000000000000000000000000000000000000000000006878861220003957889984001019491111ba986569a99aa447781000991000000000000000000000000000000000000000000006878785022000047576608100107e1e6000069a5458bb82000777600008a300000000000000000000000000000000000000000498787787113a00017454607a8bbac969b676067264478200000576840000995000000000000000000000000000000000000005996888788620aa0100835b607edbbdb687bdcccc6295362000000576682000198520000000000000000000000000000000000587204876892004b00214834a904fcbba9677bcbacb07a844500000098666700006965300000000000000000000000000000005740001977799000ad000077446b00cdcbada09caaae702977662001009a7666600029706200000000000000000000000000000970000088768a8102ce200085448d101cbabd706eaabb002d967885300005966665101881060000000000000000000000000001a70000078777999206cda0028435c6002babcc201dcbb7002bea6889940006a8766662588303500000000000000000000000000990000079776898a609bce005634ac006fbabbb010bbbac7002de22878a810398875555779200710000000000000000000000007a50000797777989911bbbc006348f9003bdcac60e57cabcf6008d80877984607988755545700073000000000000000000000003995003897776987a503daae81659df6000047dc30005dbbb81002dd27777906259888854545510850000000000000000000000078894688777679789006caad9593aed0001100c901001cd2000000af8677771b429888885455566740000000000000000000000098777787777787789308cab97820df4001000021000008400011004c7778726d60398888974454566400000000000000000000019665687777678778787aab768300eb00010001011200100120000158857a20cf702987876985445768740000000000000000003666668777777877767bcab8679002f40001000100013500001000000af752005f706a7789008a53450488500000000000000038867667877787787777bbab9776bb02e00000000000009e000010000002fa00009d6099877930099634303783000000000000189402766787789778778baaaa89769fa2d000000000000000000000000000dc0006dc6059877870079973530486000000000005a4000766687889777777baaaaa8b757e52d000000000000100100000000000ad003fbc606787778008889745106700000000008a1000676568888877787abaaaaa9aa77901f3000000000001001000000000008c000acba3777877900977896550070000000008b00001756568888877787baaaaaaa9baba00f8002210000000000000000000009b000cbab967678785787788966305000000007a4000046466588888777769cbaaaaaaaabd10be1123232100106a001000000000c800ccaaaa767677788777a258556400000004980000065466579888777765acbbaaaaabbcc04f9012222321107c011011122005f200dbaaab96776777777880086561000000078700001654465688887775665bbbbaaaaabcd009f702222223221012233323321ec02bcbaaaab86776777788000475620';
213
+ const GIRL_LINES = '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001221000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000050551247200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e601e8000001b624620000000000000000000000000000000000000000000000000000000000000000000000000000000000061f000000000000ff00068000000000000000000000000000000000000000000000000000000000000000000000000000000004b000000004000300000000090000000000000000000000000000000000000000000000000000000000000000000000000000006c5000600015100520030000080000000000000000000000000000000000000000000000000000000000000000000000000000005000005700000000000400000f55700000000000000000000000000000000000000000000000000000000000000000000000000100020000012125521100000021002800000000000000000000000000000000000000000000000000000000000000000000000070000600003fea779dfff910011000005000000000000000000000000000000000000000000000000000000000000000000000050000000112deb98422225efe10010000ff00000000000000000000000000000000000000000000000000000000000000000000f006000259b233233353322239fb000000099000000000000000000000000000000000000000000000000000000000000000000fd00110f95f52223222233323323cf1000000f000000000000000000000000000000000000000000000000000000000000000007f00001f82a43333333332333333324f2010005c0000000000000000000000000000000000000000000000000000000000000000ff1000f9254333333333333333333223f400000f1000000000000000000000000000000000000000000000000000000000000000f10008e23433333333333333323322333f10000f110000000000000000000000000000000000000000000000000000000000000300001f3333333333333332322234223335d110ff10400000000000000000000000000000000000000000000000000000000000060000983333333333333353222323422326920012f0010000000000000000000000000000000000000000000000000000000000700001d33333333334223239232232632323990000da0300000000000000000000000000000000000000000000000000000000004000059333333333322223337333323523324b70002f0100000000000000000000000000000000000000000000000000000000000f901b5333323333212233322b333326323336c1001f010000000000000000000000000000000000000000000000000000000000cf002b22333332332224343601a333236233237800bf02ee00000000000000000000000000000000000000000000000000000001f00085233324224333332369101a43326323334910fb246d0000000000000000000000000000000000000000000000000000000ff002c22333262273333333492116b733342333452152332b0000000000000000000000000000000000000000000000000000000ff00791234337119333333327a0002c533a31233332223f810000000000000000000000000000000000000000000000000000001ff10d22234338108633332422d00002735612433323313cf300000000000000000000000000000000000000000000000000000001f00a22235339102933322321f0000011287223333273743f80000000000000000000000000000000000000000000000000000000f005242343381118533222618000002104213333324f8433f400000000000000000000000000000000000000000000000000001ff813332243288004825322522102fffff1253323333654344f2000000000000000000000000000000000000000000000000001fc9d823332342b100082453224601fd2f13f9333233234333344f20000000000000000000000000000000000000000000000001f16683233323634100013233324901f72c90f82333342894333335f100000000000000000000000000000000000000000000000f90f453233323751100001163242270bdf3c011423323347e9433336f100000000000000000000000000000000000000000000000dfd4432333326801018d201b46b200572260025333233201afc84349f0000000000000000000000000000000000000000000000001a4323333334900fff7c2017129100b1110083432243f00013dfd97bf000000000000000000000000000000000000000000000000b5333233233806f3a36f000100000010002547322739900000128ffff0000000000000000000000000000000000000000000000cb533325322361f12ccfb0000000000000124b3225733e7000000002bff000000000000000000000000000000000000000000002f4433327322342f00e2251000000000111116b22584333ff9204a00000ff0000000000000000000000000000000000000000001f54433a2642323c9201a1100000000000001023243333325b03d86fced4fe000000000000000000000000000000000000000000f943548724822224200011000000001100000043662334223d100000100100000000000000000000000000000000000000000008e444ff2023932322b20000100002babe00001896932434322780000000000000000000000000000000000000000000000000002f548fa0119276333225100110009f214200000ea33224353222a200000000000000000000000000000000000000000000000002f66eb1001b72343235325211000005343000008f3332234432224a0000000000000000000000000000000000000000000000001fbdf300002e333333239322100000000000000af932222363422226a00000000000000000000000000000000000000000000000fff5100002f434333383238ff10000000000001f8722322353532223b8000000000000000000000000000000000000000000000ff20000ff45b5333323433228bf5100000000112e73232123343422222e900000000000000000000000000000000000000000000f515fef1003a3233223533322389dfff41102612fa33321233335222420fb00000000000000000000000000000000000000000000591010000f622557477323343333be36255411134662222343333222800cf0000000000000000000000000000000000000000000000000005f2236112ff922238333c601111111002f4332227333522246003f10000000000000000000000000000000000000000000000000f3337100006f52323437f201011111101f43322245338836491000fb000000000000000000000000000000000000000000000005623440110001d2253675100000c1f0000fa542224767ef1175b0000ff0000000000000000000000000000000000000000000004734352011000015242207000004f1f2000027d2125df9100065780000ff1000000000000000000000000000000000000000002e9343376001f00009121203b3dd8f324d222022121169100000272a10000ff3000000000000000000000000000000000000006ff2633269710ff0000c12f303fc66e72338eceef21c21410000002622b10001fa6100000000000000000000000000000000009fc1026323a1001f00102c11da02f744332237754ce03f6214000000e9222900005d46200000000000000000000000000000009f50000b3228a000cf0000b7112f00fc444d803a444f30172225100000fe222470001c70a100000000000000000000000000000fc00000b522398001ff1000d2126f000c444f302f444c001f6236a2100002922246000bc00d0000000000000000000000000000fc000008822246a102efb001d112f20018447f100f8463001ff9256ab20003c42224712ab102900000000000000000000000000ff000008b322354b20899f005511af005f9446c000b644d2001ff11536fc001c542222257e100f00000000000000000000000009f200009b3223536a10d46d006113f8001ffa4e20f22c45df7007f303328815056353222129000e3000000000000000000000001d92001aa3222433a201f44f30325ff2000013ff10002faafa0001ff12322904129334422222400d500000000000000000000000995a12a7222234338002e44f62c18ff0000000fd00000ff1000000cf3233440f2195334421223659100000000000000000000000c6322452222243337103a4632910ff100000001000000d200012001f2337712f2018333493112123610000000000000000000000c222242222233333232558325100ff00010000000400000010000025322f10ff201933432ca211287dc200000000000000000017322243222323333229a463228001f10001000000002700000000000df321002f202b323900ae212201cd60000000000000002fd6622243223323332375443222cf01f0000100010000ff000010000001fb00006f20b8322b100ab212101be10000000000000ff3016223322352333237444434225fb1f000000001000000000010000000ff0002fe20284228600598212101f8000000000007f500083223333432333364443439222f21f000000001000000000000000000ef001f9c20235324b008538313009d0000000000ef0000772223333332233554443434422500f1000000000000000000000000009f00089641323422a009234922400e000000000df00001922224333322233a44344443448900f900140000000000000000000000df000d547522233252242246a24109000000009f1000056242253333222323c4433444444f00ff001324200000cf000000000000fa00fc4446222223255222c12b229300000001eb000008312223433322232249444444445cf01fb00111241000df000000133002f100f64446322222322228900c32900000000ab80000082112224333223222244444444448f007f701111224110001246323310ff01fd44444832222322248000172810';
214
+ /** Grid aspect (width / height), used to keep the portrait undistorted. */
215
+ const GIRL_ASPECT = GIRL_COLUMNS / GIRL_ROWS;
216
+ /** Wordmark set in dots on the left: two lines, sampled from live text. */
217
+ const LOCKUP_LINES = ['deepseek', 'harness'];
218
+ const LOCKUP_COLUMNS = 140;
219
+ const LOCKUP_ROWS = 58;
220
+ /** Alpha buckets drawn per frame, so the twinkle costs one fill per level. */
221
+ const LEVELS = 12;
222
+ const TAU = Math.PI * 2;
223
+ /**
224
+ * Twinkle refresh rate. The field is dense, so the frame budget is kept
225
+ * loose: slow alpha breathing reads the same at 16 fps, and the canvas is
226
+ * only alive while the blank home is on screen.
227
+ */
228
+ const FRAME_MS = 1000 / 30;
229
+ /** One dot's cell in CSS pixels: fixed, so dots never scale with the window. */
230
+ const DOT_PITCH = 9;
231
+ /** Smallest dot pitch the wordmark may use before it is dropped. */
232
+ const TEXT_MIN_PITCH = 3.6;
233
+ /** Wordmark assembly: dots reveal left to right over this long. */
234
+ const ASSEMBLY_MS = 1300;
235
+ /** Each line's slice of the assembly, in timeline fractions: line 1 starts
236
+ * while line 0 is still finishing, so the two never pop at once. */
237
+ const ASSEMBLY_SECOND_LINE = 0.42;
238
+ const ASSEMBLY_LINE_SPAN = 0.58;
239
+ /** Temporary on-canvas readout used to diagnose layout mismatches. */
240
+ const DEBUG = false;
241
+ /** Dot model of the portrait for the light canvas (ink-weighted). */
242
+ let dotModel;
243
+ /** Dot model of the portrait for the dark canvas (line-art weighted). */
244
+ let lineModel;
245
+ /** Dot model of the wordmark, built once by rasterising live text. */
246
+ let lockupModel;
247
+ /**
248
+ * Decode one hex grid into dots: one dot per non-empty cell, weight from the
249
+ * digit, each with its own twinkle phase and speed so the field never blinks
250
+ * in unison.
251
+ * @param cells - one hex digit per grid cell, row-major.
252
+ * @returns dots in normalised space (`u`/`v` 0..1, `a` weight 0..1).
253
+ */
254
+ function decodeGrid(cells) {
255
+ const dots = [];
256
+ for (let index = 0; index < cells.length; index += 1) {
257
+ const weight = Number.parseInt(cells[index], 16);
258
+ if (!(weight > 0))
259
+ continue;
260
+ const row = Math.floor(index / GIRL_COLUMNS);
261
+ const column = index % GIRL_COLUMNS;
262
+ dots.push({
263
+ u: (column + 0.5) / GIRL_COLUMNS,
264
+ v: (row + 0.5) / GIRL_ROWS,
265
+ a: weight / 15,
266
+ phase: Math.random() * TAU,
267
+ speed: 0.5 + Math.random() * 0.8,
268
+ });
269
+ }
270
+ return dots;
271
+ }
272
+ /**
273
+ * Light canvas: the artwork's ink drives dot weight, so dark hair and the
274
+ * dark dress read dark on the pale canvas.
275
+ * @returns dots in normalised space.
276
+ */
277
+ function mascotDots() {
278
+ if (dotModel === undefined)
279
+ dotModel = decodeGrid(GIRL_GRID);
280
+ return dotModel;
281
+ }
282
+ /**
283
+ * Dark canvas: the dots are light, so the artwork's ink is inverted — skin
284
+ * and the white apron become dense bright dots while ink-heavy hair and the
285
+ * dress fade back into the canvas. Cells with no ink but enclosed by the
286
+ * figure count as full weight, which is what keeps the face from turning
287
+ * into an empty hole.
288
+ * @returns dots in normalised space.
289
+ */
290
+ function invertedDots() {
291
+ if (lineModel !== undefined)
292
+ return lineModel;
293
+ const total = GIRL_COLUMNS * GIRL_ROWS;
294
+ const occupied = new Uint8Array(total);
295
+ const weight = new Float32Array(total);
296
+ for (let index = 0; index < GIRL_GRID.length && index < total; index += 1) {
297
+ const value = Number.parseInt(GIRL_GRID[index], 16);
298
+ if (!(value > 0))
299
+ continue;
300
+ occupied[index] = 1;
301
+ weight[index] = value / 15;
302
+ }
303
+ const rowFirst = new Int32Array(GIRL_ROWS).fill(-1);
304
+ const rowLast = new Int32Array(GIRL_ROWS).fill(-1);
305
+ const columnFirst = new Int32Array(GIRL_COLUMNS).fill(-1);
306
+ const columnLast = new Int32Array(GIRL_COLUMNS).fill(-1);
307
+ for (let row = 0; row < GIRL_ROWS; row += 1) {
308
+ for (let column = 0; column < GIRL_COLUMNS; column += 1) {
309
+ if (occupied[row * GIRL_COLUMNS + column] === 0)
310
+ continue;
311
+ if (rowFirst[row] < 0)
312
+ rowFirst[row] = column;
313
+ rowLast[row] = column;
314
+ if (columnFirst[column] < 0)
315
+ columnFirst[column] = row;
316
+ columnLast[column] = row;
317
+ }
318
+ }
319
+ const dots = [];
320
+ for (let row = 0; row < GIRL_ROWS; row += 1) {
321
+ for (let column = 0; column < GIRL_COLUMNS; column += 1) {
322
+ if (row < columnFirst[column] || row > columnLast[column])
323
+ continue;
324
+ if (column < rowFirst[row] || column > rowLast[row])
325
+ continue;
326
+ const index = row * GIRL_COLUMNS + column;
327
+ const alpha = occupied[index] === 1 ? 1 - weight[index] : 1;
328
+ if (alpha < 0.45)
329
+ continue;
330
+ dots.push({
331
+ u: (column + 0.5) / GIRL_COLUMNS,
332
+ v: (row + 0.5) / GIRL_ROWS,
333
+ a: alpha,
334
+ phase: Math.random() * TAU,
335
+ speed: 0.5 + Math.random() * 0.8,
336
+ });
337
+ }
338
+ }
339
+ lineModel = dots;
340
+ return dots;
341
+ }
342
+ /**
343
+ * Rasterise the two wordmark lines with the UI font and reduce them to the
344
+ * same dotted grid the portrait uses.
345
+ * @returns dots in normalised block space (`u`/`v` 0..1, `a` weight 0..1).
346
+ */
347
+ function lockupDots() {
348
+ if (lockupModel !== undefined)
349
+ return lockupModel;
350
+ const supersample = 4;
351
+ const family = '"Segoe UI", system-ui, sans-serif';
352
+ // Display treatment: heavy italic with wide tracking, filled solid. Each
353
+ // line is rasterised on its own canvas, so a descender that crosses the
354
+ // other line's band still belongs to its own colour.
355
+ const style = 'italic 700';
356
+ const probe = document.createElement('canvas').getContext('2d');
357
+ probe.font = `${style} 100px ${family}`;
358
+ if ('letterSpacing' in probe)
359
+ probe.letterSpacing = '6px';
360
+ const width = LOCKUP_COLUMNS * supersample;
361
+ const height = LOCKUP_ROWS * supersample;
362
+ const widest = Math.max(...LOCKUP_LINES.map(line => probe.measureText(line).width), 1);
363
+ const size = ((width * 0.94) / widest) * 100;
364
+ const model = LOCKUP_LINES.map((line, lineIndex) => {
365
+ const big = document.createElement('canvas');
366
+ big.width = width;
367
+ big.height = height;
368
+ const bigContext = big.getContext('2d');
369
+ bigContext.textAlign = 'left';
370
+ bigContext.textBaseline = 'middle';
371
+ if ('letterSpacing' in bigContext)
372
+ bigContext.letterSpacing = '6px';
373
+ bigContext.font = `${style} ${size.toFixed(1)}px ${family}`;
374
+ bigContext.fillStyle = 'rgba(255, 255, 255, 0.92)';
375
+ bigContext.fillText(line, width * 0.02, height * (0.34 + 0.4 * lineIndex));
376
+ const small = document.createElement('canvas');
377
+ small.width = LOCKUP_COLUMNS;
378
+ small.height = LOCKUP_ROWS;
379
+ const smallContext = small.getContext('2d');
380
+ smallContext.drawImage(big, 0, 0, LOCKUP_COLUMNS, LOCKUP_ROWS);
381
+ const pixels = smallContext.getImageData(0, 0, LOCKUP_COLUMNS, LOCKUP_ROWS).data;
382
+ const dots = [];
383
+ for (let index = 0; index < LOCKUP_COLUMNS * LOCKUP_ROWS; index += 1) {
384
+ const alpha = pixels[index * 4 + 3] / 255;
385
+ if (alpha < 0.08)
386
+ continue;
387
+ dots.push({
388
+ u: ((index % LOCKUP_COLUMNS) + 0.5) / LOCKUP_COLUMNS,
389
+ v: (Math.floor(index / LOCKUP_COLUMNS) + 0.5) / LOCKUP_ROWS,
390
+ a: Math.min(1, alpha * 1.25),
391
+ phase: Math.random() * TAU,
392
+ speed: 0.5 + Math.random() * 0.8,
393
+ });
394
+ }
395
+ return dots;
396
+ });
397
+ lockupModel = model;
398
+ return model;
399
+ }
400
+ /**
401
+ * Paint the dot mascot and wordmark into a canvas, twinkling in place.
402
+ * @param canvas - the frame canvas sized to the conversation area.
403
+ * @returns disposer that cancels the animation and observers.
404
+ */
405
+ function attachMascot(canvas) {
406
+ const context = canvas.getContext('2d');
407
+ if (context === null)
408
+ return () => { };
409
+ const portraitLight = mascotDots();
410
+ const portraitDark = invertedDots();
411
+ const wordmark = lockupDots();
412
+ const motion = window.matchMedia('(prefers-reduced-motion: reduce)');
413
+ let reduced = motion.matches;
414
+ const started = performance.now();
415
+ // The reveal clock starts on the first paint that actually has a canvas to draw
416
+ // into, otherwise the animation can finish while the element is still sizing.
417
+ let revealStarted = 0;
418
+ let width = 1;
419
+ let height = 1;
420
+ let dpr = 1;
421
+ let frame = 0;
422
+ let drawnAt = 0;
423
+ let disposed = false;
424
+ /** Composer card geometry in canvas coordinates; the composition's bound. */
425
+ let composerLeft = 0;
426
+ let composerWidth = 0;
427
+ let composerTop = 0;
428
+ let composerNode = null;
429
+ const composerObserver = new ResizeObserver(() => { readComposer(); });
430
+ /** Re-read the composer card (it mounts with the hero and resizes with it). */
431
+ const readComposer = () => {
432
+ const canvasRect = canvas.getBoundingClientRect();
433
+ // Pick the composer card that actually overlaps this conversation area:
434
+ // hidden or off-screen cards (other panels, mounted shells) must not
435
+ // become the layout bound.
436
+ let node = null;
437
+ let rect = null;
438
+ for (const candidate of document.querySelectorAll('[data-composer-card]')) {
439
+ const box = candidate.getBoundingClientRect();
440
+ if (box.width < 80 || box.height < 20)
441
+ continue;
442
+ if (box.right <= canvasRect.left || box.left >= canvasRect.right)
443
+ continue;
444
+ if (rect === null || box.width > rect.width) {
445
+ node = candidate;
446
+ rect = box;
447
+ }
448
+ }
449
+ if (node !== composerNode) {
450
+ composerObserver.disconnect();
451
+ composerNode = node;
452
+ if (node !== null)
453
+ composerObserver.observe(node);
454
+ }
455
+ if (node === null || rect === null) {
456
+ composerLeft = 0;
457
+ composerWidth = 0;
458
+ composerTop = 0;
459
+ return;
460
+ }
461
+ composerLeft = rect.left - canvasRect.left;
462
+ composerWidth = rect.width;
463
+ composerTop = rect.top - canvasRect.top;
464
+ };
465
+ /** Last canvas box in viewport coordinates, for pointer hit-testing. */
466
+ let boxLeft = 0;
467
+ let boxTop = 0;
468
+ let boxWidth = 0;
469
+ let boxHeight = 0;
470
+ /** Pointer position in canvas coordinates; inactive while outside. */
471
+ let pointerX = -1e6;
472
+ let pointerY = -1e6;
473
+ let pointerActive = false;
474
+ const onPointerMove = (event) => {
475
+ pointerX = event.clientX - boxLeft;
476
+ pointerY = event.clientY - boxTop;
477
+ pointerActive = pointerX >= 0 && pointerY >= 0 && pointerX <= boxWidth && pointerY <= boxHeight;
478
+ if (pointerActive) {
479
+ trail.push({ x: pointerX, y: pointerY, at: performance.now() });
480
+ if (trail.length > 8)
481
+ trail.shift();
482
+ spawnRipple();
483
+ }
484
+ if (reduced)
485
+ paint(performance.now());
486
+ };
487
+ const onPointerLeave = () => { pointerActive = false; };
488
+ /** Moving the pointer over the field band leaves a light ripple behind. */
489
+ const spawnRipple = () => {
490
+ const cfg = dfSettings;
491
+ if (cfg !== undefined && cfg.ripple === false)
492
+ return;
493
+ const nowMs = performance.now();
494
+ if (nowMs - lastRippleAt < 90)
495
+ return;
496
+ const bandTop = boxHeight - Math.min(440, Math.max(230, boxHeight * 0.4));
497
+ if (pointerY < bandTop)
498
+ return;
499
+ lastRippleAt = nowMs;
500
+ fieldRipples.push({ x: pointerX, y: pointerY, at: nowMs });
501
+ if (fieldRipples.length > 8)
502
+ fieldRipples.shift();
503
+ };
504
+ /** Recent pointer samples so the light leaves a short, fading trail. */
505
+ const trail = [];
506
+ /** Click ripples: origin plus start time, oldest first. */
507
+ const ripples = [];
508
+ const onPointerDown = (event) => {
509
+ const x = event.clientX - boxLeft;
510
+ const y = event.clientY - boxTop;
511
+ if (x < 0 || y < 0 || x > boxWidth || y > boxHeight)
512
+ return;
513
+ ripples.push({ x, y, at: performance.now() });
514
+ if (ripples.length > 5)
515
+ ripples.shift();
516
+ };
517
+ const measure = () => {
518
+ const rect = canvas.getBoundingClientRect();
519
+ dpr = Math.min(window.devicePixelRatio || 1, 2);
520
+ width = Math.max(1, rect.width);
521
+ height = Math.max(1, rect.height);
522
+ canvas.width = Math.round(width * dpr);
523
+ canvas.height = Math.round(height * dpr);
524
+ boxLeft = rect.left;
525
+ boxTop = rect.top;
526
+ boxWidth = width;
527
+ boxHeight = height;
528
+ readComposer();
529
+ };
530
+ /**
531
+ * Draw one frame: both groups hold still and only their alpha breathes.
532
+ * @param now - frame timestamp.
533
+ */
534
+ let bgLayer = null;
535
+ let bgGlow = null;
536
+ let fieldDots = null;
537
+ const fieldRipples = [];
538
+ let lastRippleAt = 0;
539
+ let fieldKeyCache = '';
540
+ let composerFocused = false;
541
+ let focusAmount = 0;
542
+ let bgKey = '';
543
+ const paint = (now) => {
544
+ frame = 0;
545
+ if (disposed || document.hidden)
546
+ return;
547
+ const cfg = dfSettings;
548
+ if (cfg !== undefined && cfg.hero === false) {
549
+ context.setTransform(dpr, 0, 0, dpr, 0, 0);
550
+ context.clearRect(0, 0, width, height);
551
+ frame = requestAnimationFrame(paint);
552
+ return;
553
+ }
554
+ if (revealStarted === 0 && width > 200 && height > 200)
555
+ revealStarted = now;
556
+ // The assembly is a short, fast reveal: give it a smoother frame rate
557
+ // than the slow twinkle, then fall back to the cheap cadence.
558
+ const assembling = now - revealStarted < ASSEMBLY_MS + 80;
559
+ const interval = (assembling ? 1000 / 60 : FRAME_MS) - 1;
560
+ if (!reduced && now - drawnAt < interval) {
561
+ frame = requestAnimationFrame(paint);
562
+ return;
563
+ }
564
+ drawnAt = now;
565
+ const time = reduced ? 0 : (now - started) / 1000;
566
+ const dark = document.body.hasAttribute('data-ds-dark-theme');
567
+ const ink = dark ? '236, 238, 242' : '102, 108, 120';
568
+ // The composer card is the layout's bound: the pair is centred on it and
569
+ // can never be wider than the input box.
570
+ const limit = composerWidth > 160 ? composerWidth : width * 0.94;
571
+ const originX = composerWidth > 160 ? composerLeft : (width - limit) / 2;
572
+ // One pitch drives both groups: the wordmark and the portrait always share
573
+ // the same dot size, and that pitch scales with the space available. Two
574
+ // hard bounds: the composer width (the pair never exceeds the input box)
575
+ // and the space above the composer (the pair hangs above it instead of
576
+ // being covered by it).
577
+ const availW = limit * 0.94;
578
+ const pairCells = LOCKUP_COLUMNS + GIRL_COLUMNS - 30;
579
+ const bandTop = composerTop > 140 ? composerTop : height * 0.86;
580
+ const heightPitch = Math.max(1, bandTop - 8) / GIRL_ROWS;
581
+ let pitch = Math.min(DOT_PITCH, availW / pairCells, heightPitch);
582
+ let showText = true;
583
+ if (pitch < TEXT_MIN_PITCH) {
584
+ // Only when the type would fall below the readable floor: drop the
585
+ // wordmark and keep the portrait as large as it can be.
586
+ showText = false;
587
+ pitch = Math.min(DOT_PITCH, availW / GIRL_COLUMNS, heightPitch);
588
+ }
589
+ if (pitch < 2.2) {
590
+ context.setTransform(dpr, 0, 0, dpr, 0, 0);
591
+ context.clearRect(0, 0, width, height);
592
+ return;
593
+ }
594
+ const blockW = LOCKUP_COLUMNS * pitch;
595
+ const blockH = LOCKUP_ROWS * pitch;
596
+ const portraitW = GIRL_COLUMNS * pitch;
597
+ const portraitH = GIRL_ROWS * pitch;
598
+ const overlap = Math.max(8, pitch * 30);
599
+ const pairW = blockW + portraitW - overlap;
600
+ // Hang the pair off the composer: the portrait's bottom edge sits on the
601
+ // composer's top edge, and the dot pitch above guaranteed it fits there.
602
+ const portraitY = Math.min(Math.max(bandTop - portraitH / 2, 6 + portraitH / 2), Math.max(6 + portraitH / 2, height - portraitH / 2 - 6));
603
+ let portraitX;
604
+ let blockX = 0;
605
+ if (showText) {
606
+ blockX = originX + Math.max(0, (limit - pairW) / 2);
607
+ portraitX = blockX + blockW - overlap + portraitW / 2;
608
+ }
609
+ else {
610
+ portraitX = originX + limit / 2;
611
+ }
612
+ // Keep the pair inside the canvas even if the composer rect was odd.
613
+ const minX = portraitW / 2 + 6;
614
+ const maxX = Math.max(minX, width - portraitW / 2 - 6);
615
+ portraitX = Math.min(Math.max(portraitX, minX), maxX);
616
+ const blockY = portraitY - blockH / 2;
617
+ // The portrait and the wordmark are centred on each other, which leaves their
618
+ // cell rows half a cell apart; nudge the portrait so every dot in the scene
619
+ // (artwork and printed field alike) lands on one single lattice.
620
+ const portraitYAligned = portraitY + pitch / 2;
621
+ const portraitRadius = Math.max(0.8, pitch * 0.28);
622
+ const lockupRadius = Math.max(0.8, pitch * 0.34);
623
+ // A faint dot field under everything, built on the artwork's own pitch and
624
+ // ink so the background reads as part of the same printed sheet.
625
+ // Phase the background lattice onto the artwork's own grid: the wordmark and the
626
+ // portrait already sit on one lattice (their origins differ by a whole number
627
+ // of cells), so matching that phase makes the field read as the same printed
628
+ // sheet instead of a second, offset grid.
629
+ // Artwork dots sit at the CENTRES of their cells (blockX + (col + 0.5) * pitch),
630
+ // so the field has to be phased half a cell further: its dots land exactly on
631
+ // the artwork's dots, like stones on intersections, not inside the squares.
632
+ const phaseX = (((blockX + pitch / 2) % pitch) + pitch) % pitch;
633
+ const phaseY = (((blockY + pitch / 2) % pitch) + pitch) % pitch;
634
+ const buildKey = pitch.toFixed(3) + '|' + ink + '|' + phaseX.toFixed(3) + '|'
635
+ + phaseY.toFixed(3) + '|' + width + '|' + height + '|' + dpr;
636
+ if (buildKey !== bgKey) {
637
+ bgKey = buildKey;
638
+ bgLayer = document.createElement('canvas');
639
+ bgLayer.width = Math.max(1, Math.round(width * dpr));
640
+ bgLayer.height = Math.max(1, Math.round(height * dpr));
641
+ const layerContext = bgLayer.getContext('2d');
642
+ if (layerContext === null) {
643
+ bgLayer = null;
644
+ }
645
+ else {
646
+ layerContext.setTransform(dpr, 0, 0, dpr, 0, 0);
647
+ const fieldRadius = Math.max(0.45, pitch * 0.11);
648
+ // The resting field.
649
+ layerContext.fillStyle = 'rgba(' + ink + ', 0.1)';
650
+ for (let y = phaseY; y < height + pitch; y += pitch) {
651
+ for (let x = phaseX; x < width + pitch; x += pitch) {
652
+ layerContext.beginPath();
653
+ layerContext.arc(x, y, fieldRadius, 0, TAU);
654
+ layerContext.fill();
655
+ }
656
+ }
657
+ // The focused field: the same lattice, but brighter close to the
658
+ // composer card and fading out with distance, so the click lights the
659
+ // dots around the input rather than the whole page.
660
+ bgGlow = document.createElement('canvas');
661
+ bgGlow.width = bgLayer.width;
662
+ bgGlow.height = bgLayer.height;
663
+ const glowContext = bgGlow.getContext('2d');
664
+ if (glowContext === null) {
665
+ bgGlow = null;
666
+ }
667
+ else {
668
+ glowContext.setTransform(dpr, 0, 0, dpr, 0, 0);
669
+ const cardLeft = composerWidth > 160 ? composerLeft : (width - limit) / 2;
670
+ const cardWidthForGlow = composerWidth > 160 ? composerWidth : limit;
671
+ const glowRadiusX = Math.max(160, cardWidthForGlow * 0.55);
672
+ const glowRadiusY = Math.max(150, Math.min(height * 0.3, 260));
673
+ const centerX = cardLeft + cardWidthForGlow / 2;
674
+ const centerY = composerTop + 8;
675
+ for (let y = phaseY; y < height + pitch; y += pitch) {
676
+ for (let x = phaseX; x < width + pitch; x += pitch) {
677
+ const dx = (x - centerX) / glowRadiusX;
678
+ const dy = (y - centerY) / glowRadiusY;
679
+ const falloff = Math.exp(-(dx * dx + dy * dy) * 2.1);
680
+ if (falloff < 0.03)
681
+ continue;
682
+ glowContext.fillStyle = 'rgba(' + ink + ', ' + (0.3 * falloff).toFixed(3) + ')';
683
+ glowContext.beginPath();
684
+ glowContext.arc(x, y, fieldRadius, 0, TAU);
685
+ glowContext.fill();
686
+ }
687
+ }
688
+ }
689
+ }
690
+ }
691
+ // The portrait runs one opacity notch brighter than the wordmark, so the
692
+ // two groups keep separate alpha ladders.
693
+ const portraitPaths = [];
694
+ const wordmarkPaths = [[], []];
695
+ for (let level = 0; level < LEVELS; level += 1) {
696
+ portraitPaths.push(new Path2D());
697
+ wordmarkPaths[0].push(new Path2D());
698
+ wordmarkPaths[1].push(new Path2D());
699
+ }
700
+ // Wordmark assembly: dots light up left to right, with a bright front.
701
+ const assembly = reduced ? 1 : Math.min(1, (now - revealStarted) / ASSEMBLY_MS);
702
+ // The portrait follows the wordmark: a soft vertical wipe grows it downward
703
+ // about a tenth of a second later.
704
+ const portraitProgress = reduced
705
+ ? 1
706
+ : Math.max(0, Math.min(1, ((now - revealStarted) - 140) / 1100));
707
+ while (ripples.length > 0 && now - ripples[0].at > 760)
708
+ ripples.shift();
709
+ const trailNow = trail.filter(sample => now - sample.at < 420);
710
+ const rippleBoost = (x, y) => {
711
+ let best = 0;
712
+ for (const ripple of ripples) {
713
+ const age = (now - ripple.at) / 760;
714
+ const radius = age * 640;
715
+ const dx = x - ripple.x;
716
+ const dy = y - ripple.y;
717
+ if (dx * dx + dy * dy > (radius + 200) * (radius + 200))
718
+ continue;
719
+ const distance = Math.sqrt(dx * dx + dy * dy);
720
+ if (Math.abs(distance - radius) > 160)
721
+ continue;
722
+ const band = Math.exp(-Math.pow((distance - radius) / 44, 2));
723
+ best = Math.max(best, band * (1 - age));
724
+ }
725
+ return 1 + 1.25 * best;
726
+ };
727
+ const trailBoost = (x, y) => {
728
+ let best = 0;
729
+ for (const sample of trailNow) {
730
+ const age = Math.max(0, (now - sample.at) / 420);
731
+ const dx = x - sample.x;
732
+ const dy = y - sample.y;
733
+ if (Math.abs(dx) > 260 || Math.abs(dy) > 260)
734
+ continue;
735
+ best = Math.max(best, Math.exp(-(dx * dx + dy * dy) / (2 * 95 * 95)) * (1 - age));
736
+ }
737
+ return 1 + 0.95 * best;
738
+ };
739
+ const place = (target, dot, x, y, radius, kind, line) => {
740
+ // The portrait holds a steady level; only the wordmark breathes.
741
+ const breathe = reduced ? 0.6 : 0.5 + 0.5 * Math.sin(time * dot.speed + dot.phase);
742
+ // Ease the wave so the low and high ends linger instead of sweeping
743
+ // through the extremes linearly, which reads as a softer pulse.
744
+ const eased = breathe * breathe * (3 - 2 * breathe);
745
+ let tone = kind === 'portrait' ? dot.a : dot.a * (0.35 + 0.65 * eased);
746
+ if (kind === 'portrait' && portraitProgress < 1) {
747
+ const local = Math.max(0, Math.min(1, (portraitProgress - dot.v * 0.45) / 0.55));
748
+ const wipe = local * local * (3 - 2 * local);
749
+ if (wipe <= 0.004)
750
+ return;
751
+ tone *= wipe;
752
+ }
753
+ if (kind === 'wordmark') {
754
+ if (assembly < 1) {
755
+ // Whole-word fade: the line rises as one piece, no left-to-right sweep.
756
+ const offset = line === 1 ? ASSEMBLY_SECOND_LINE : 0;
757
+ const progress = Math.max(0, Math.min(1, (assembly - offset) / ASSEMBLY_LINE_SPAN));
758
+ const smooth = progress * progress * (3 - 2 * progress);
759
+ if (smooth <= 0.02)
760
+ return;
761
+ tone *= smooth;
762
+ }
763
+ if (pointerActive)
764
+ tone *= trailBoost(x, y);
765
+ }
766
+ // Ripples are a wordmark effect; the portrait stays untouched.
767
+ if (kind === 'wordmark')
768
+ tone = Math.min(1, tone * rippleBoost(x, y));
769
+ const level = Math.min(LEVELS - 1, Math.max(0, Math.round(tone * (LEVELS - 1))));
770
+ // Halftone weighting: heavier cells draw slightly larger dots, so the
771
+ // field reads as printed ink rather than a uniform grid.
772
+ const size = radius * (0.82 + 0.36 * dot.a);
773
+ target[level].moveTo(x + size, y);
774
+ target[level].arc(x, y, size, 0, TAU);
775
+ };
776
+ const portrait = dark ? portraitDark : portraitLight;
777
+ for (const dot of portrait) {
778
+ place(portraitPaths, dot, portraitX + (dot.u - 0.5) * portraitW, portraitYAligned + (dot.v - 0.5) * portraitH, portraitRadius, 'portrait');
779
+ }
780
+ if (showText) {
781
+ wordmark.forEach((dots, index) => {
782
+ for (const dot of dots) {
783
+ place(wordmarkPaths[index], dot, blockX + dot.u * blockW, blockY + dot.v * blockH, lockupRadius, 'wordmark', index);
784
+ }
785
+ });
786
+ }
787
+ context.setTransform(dpr, 0, 0, dpr, 0, 0);
788
+ context.clearRect(0, 0, width, height);
789
+ // The field is painted after the clear so it survives the frame.
790
+ if (bgLayer !== null && (cfg === undefined || cfg.field !== false)) {
791
+ context.drawImage(bgLayer, 0, 0, width, height);
792
+ }
793
+ const focusTarget = composerFocused ? 1 : 0;
794
+ focusAmount += (focusTarget - focusAmount) * 0.14;
795
+ if (focusAmount > 0.005 && bgGlow !== null) {
796
+ context.save();
797
+ context.globalAlpha = Math.min(1, focusAmount);
798
+ context.drawImage(bgGlow, 0, 0, width, height);
799
+ context.restore();
800
+ }
801
+ // The wave field lives on the lattice: the light pattern is pure brightness,
802
+ // and the pointer can nudge dots aside. Nothing follows the cursor and every
803
+ // displaced dot springs straight back to its own cell.
804
+ const fieldKey = width + '|' + height + '|' + pitch.toFixed(3) + '|'
805
+ + phaseX.toFixed(2) + '|' + phaseY.toFixed(2);
806
+ if (fieldKey !== fieldKeyCache) {
807
+ fieldKeyCache = fieldKey;
808
+ fieldDots = [];
809
+ const bandHeight = Math.min(440, Math.max(230, height * 0.4));
810
+ const bandTop = height - bandHeight;
811
+ for (let y = phaseY; y < height + pitch; y += pitch) {
812
+ if (y < bandTop)
813
+ continue;
814
+ const depth = Math.min(1, (y - bandTop) / bandHeight);
815
+ const vertical = depth * depth * (3 - 2 * depth);
816
+ for (let x = phaseX; x < width + pitch; x += pitch) {
817
+ fieldDots.push({ x: x, y: y, vertical: vertical, ox: 0, oy: 0, vx: 0, vy: 0 });
818
+ }
819
+ }
820
+ }
821
+ if (!reduced && fieldDots !== null && (cfg === undefined || cfg.wave !== false)) {
822
+ const dt = 1 / 30;
823
+ const unit = pitch / 8;
824
+ const fieldRadius = Math.max(0.45, pitch * 0.11);
825
+ const breathe = 0.86 + 0.14 * Math.sin(time * 0.13);
826
+ const buckets = [[], [], [], [], [], []];
827
+ while (fieldRipples.length > 0 && now - fieldRipples[0].at > 1100)
828
+ fieldRipples.shift();
829
+ for (const dot of fieldDots) {
830
+ const warpX = Math.sin(dot.y * 0.006 / unit + time * 0.23) * 30
831
+ + Math.sin(dot.x * 0.003 / unit - time * 0.17) * 20;
832
+ const warpY = Math.sin(dot.x * 0.0035 / unit + time * 0.29) * 26;
833
+ const u = (dot.x + warpX) / unit;
834
+ const v = (dot.y + warpY) / unit;
835
+ const field = 0.5
836
+ + 0.3 * Math.sin(u * 0.0035 - time * 0.55)
837
+ + 0.22 * Math.sin(u * 0.0061 + time * 0.37 + v * 0.01)
838
+ + 0.18 * Math.sin(u * 0.0107 - time * 0.29 + v * 0.021)
839
+ + 0.12 * Math.sin(u * 0.0173 + time * 0.83 - v * 0.033);
840
+ let light = Math.max(0, Math.min(1, field)) ** 1.6;
841
+ // A touch only adds light: rings race outward and fade, the dots stay put.
842
+ for (const ripple of fieldRipples) {
843
+ const age = (now - ripple.at) / 1100;
844
+ const rdx = dot.x - ripple.x;
845
+ const rdy = dot.y - ripple.y;
846
+ const distance = Math.sqrt(rdx * rdx + rdy * rdy);
847
+ const ring = Math.exp(-Math.pow((distance - age * 420) / 42, 2)) * (1 - age);
848
+ if (ring > 0.001)
849
+ light += ring * 0.8;
850
+ }
851
+ const alpha = dot.vertical * (0.05 + Math.min(1, light) * 0.85) * breathe * (dark ? 1 : 1.2);
852
+ const level = Math.min(5, Math.floor(alpha * 7));
853
+ buckets[level].push(dot.x, dot.y);
854
+ }
855
+ for (let level = 0; level < buckets.length; level += 1) {
856
+ const bucket = buckets[level];
857
+ if (bucket.length === 0)
858
+ continue;
859
+ const alpha = 0.03 + level * 0.105;
860
+ context.fillStyle = 'rgba(' + ink + ', ' + alpha.toFixed(3) + ')';
861
+ context.beginPath();
862
+ for (let index = 0; index < bucket.length; index += 2) {
863
+ context.moveTo(bucket[index] + fieldRadius, bucket[index + 1]);
864
+ context.arc(bucket[index], bucket[index + 1], fieldRadius, 0, TAU);
865
+ }
866
+ context.fill();
867
+ }
868
+ }
869
+ const paintGroup = (paths, boost, color) => {
870
+ for (let level = 0; level < LEVELS; level += 1) {
871
+ const alpha = Math.min(1, (0.05 + (level / (LEVELS - 1)) * 0.5) * boost).toFixed(3);
872
+ context.fillStyle = `rgba(${color}, ${alpha})`;
873
+ context.fill(paths[level]);
874
+ }
875
+ };
876
+ // The portrait's opacity nudge flips with the palette: +10% on the light
877
+ // canvas, and its inverse trim on the dark one, where light dots already
878
+ // read brighter against the canvas.
879
+ paintGroup(portraitPaths, dark ? 1.15 : 1.8, ink);
880
+ if (showText) {
881
+ paintGroup(wordmarkPaths[0], dark ? 1 : 1.2, ink);
882
+ paintGroup(wordmarkPaths[1], dark ? 1 : 1.2, '122, 170, 255');
883
+ }
884
+ if (DEBUG) {
885
+ context.fillStyle = '#ff5555';
886
+ context.font = '12px monospace';
887
+ const readout = [
888
+ 'pitch=' + pitch.toFixed(2) + ' limit=' + limit.toFixed(0) + ' composerTop=' + composerTop.toFixed(0),
889
+ 'canvas=' + width.toFixed(0) + 'x' + height.toFixed(0) + ' dpr=' + dpr + ' showText=' + showText,
890
+ 'portrait=' + portraitW.toFixed(0) + 'x' + portraitH.toFixed(0)
891
+ + ' @ ' + portraitX.toFixed(0) + ',' + portraitY.toFixed(0),
892
+ 'block=' + blockW.toFixed(0) + 'x' + blockH.toFixed(0)
893
+ + ' @ ' + blockX.toFixed(0) + ',' + blockY.toFixed(0),
894
+ ];
895
+ readout.forEach((line, index) => context.fillText(line, 12, 20 + index * 16));
896
+ context.strokeStyle = '#ff5555';
897
+ context.strokeRect(portraitX - portraitW / 2, portraitY - portraitH / 2, portraitW, portraitH);
898
+ context.strokeStyle = '#5599ff';
899
+ context.strokeRect(blockX, blockY, blockW, blockH);
900
+ }
901
+ if (!reduced)
902
+ frame = requestAnimationFrame(paint);
903
+ };
904
+ const observer = new ResizeObserver(() => {
905
+ measure();
906
+ if (reduced)
907
+ paint(performance.now());
908
+ });
909
+ observer.observe(canvas);
910
+ /** Focus inside the composer card lights the field around it. */
911
+ const onFocusChange = () => {
912
+ const active = document.activeElement;
913
+ composerFocused = active !== null && active !== document.body
914
+ && typeof active.closest === 'function'
915
+ && active.closest('[data-composer-card]') !== null;
916
+ };
917
+ window.addEventListener('focusin', onFocusChange, { passive: true });
918
+ window.addEventListener('focusout', onFocusChange, { passive: true });
919
+ window.addEventListener('pointermove', onPointerMove, { passive: true });
920
+ window.addEventListener('pointerleave', onPointerLeave, { passive: true });
921
+ window.addEventListener('pointerdown', onPointerDown, { passive: true });
922
+ const refresh = () => {
923
+ if (disposed)
924
+ return;
925
+ cancelAnimationFrame(frame);
926
+ frame = 0;
927
+ if (!document.hidden)
928
+ frame = requestAnimationFrame(paint);
929
+ };
930
+ const onMotion = () => { reduced = motion.matches; refresh(); };
931
+ const themeObserver = new MutationObserver(refresh);
932
+ themeObserver.observe(document.body, { attributes: true, attributeFilter: ['data-ds-dark-theme'] });
933
+ const unsubscribeSettings = dfSubscribeSettings(refresh);
934
+ motion.addEventListener('change', onMotion);
935
+ document.addEventListener('visibilitychange', refresh);
936
+ measure();
937
+ refresh();
938
+ return () => {
939
+ disposed = true;
940
+ unsubscribeSettings();
941
+ themeObserver.disconnect();
942
+ motion.removeEventListener('change', onMotion);
943
+ document.removeEventListener('visibilitychange', refresh);
944
+ cancelAnimationFrame(frame);
945
+ observer.disconnect();
946
+ composerObserver.disconnect();
947
+ window.removeEventListener('focusin', onFocusChange);
948
+ window.removeEventListener('focusout', onFocusChange);
949
+ window.removeEventListener('pointermove', onPointerMove);
950
+ window.removeEventListener('pointerleave', onPointerLeave);
951
+ window.removeEventListener('pointerdown', onPointerDown);
952
+ };
953
+ }
954
+ /**
955
+ * Frame layer for the blank home: paint the dot mascot below the content and
956
+ * pass the wrapped scroll body through untouched.
957
+ * @param props - the home flag and the wrapped Conversation body.
958
+ * @returns the layout-neutral frame.
959
+ */
960
+ function HeroFrame({ hero, children }) {
961
+ const { values } = useDfSettings();
962
+ const show = hero === true && values.hero;
963
+ const canvasRef = React.useRef(null);
964
+ React.useEffect(() => {
965
+ const canvas = canvasRef.current;
966
+ if (!show || canvas === null)
967
+ return undefined;
968
+ return attachMascot(canvas);
969
+ }, [show]);
970
+ return h('div', { className: 'dwe-frame' }, values.aurora && h('div', { className: 'fish-backdrop', 'data-home': hero === true, 'aria-hidden': true }, h(FishPlate, { scene: values.scene })), show ? h('div', { key: 'sign', className: 'dwe-sign' }, 'dsh-fish-ui') : null, show ? h('canvas', { key: 'mascot', ref: canvasRef, className: 'dwe-whale', 'aria-hidden': 'true' }) : null, children);
971
+ }
972
+ /* ---------------------------------------------------------------- styles */
973
+ const CSS = `
974
+ /* Hero frame layer: layout-neutral wrapper (display: contents keeps the wrapped
975
+ scroll body a direct flex item) plus one canvas that sits above the
976
+ Conversation background and below its content. */
977
+ .dwe-frame {
978
+ display: contents;
979
+ }
980
+ .dwe-whale {
981
+ position: absolute;
982
+ inset: 0;
983
+ z-index: -1;
984
+ width: 100%;
985
+ height: 100%;
986
+ display: block;
987
+ pointer-events: none;
988
+ }
989
+
990
+ /* One whale on the blank home: the official pixel whale would otherwise sit
991
+ behind this dot field, so its canvas is hidden. It keeps its slot layer and
992
+ still renders the wrapped content; only its artwork is suppressed. */
993
+ :root:has(canvas.dwe-whale) [data-home-whale] {
994
+ display: none !important;
995
+ }
996
+
997
+ /* Blank-home headline: drop the headline copy and the brand mark
998
+ beside it, leaving the dot portrait alone above the composer. The title group
999
+ is a CSS-module class (matched by its local name inside the hash, scoped by
1000
+ the headline ancestor); the mark is the hero's own brand slot, matched by its
1001
+ public slot key. If upstream renames either hook the rule simply stops
1002
+ applying. */
1003
+ :root:has(canvas.dwe-whale) [class*="headline"] [class*="titleGroup"],
1004
+ :root:has(canvas.dwe-whale) [data-slot="conversation.hero.brand.mark"] {
1005
+ display: none !important;
1006
+ }
1007
+
1008
+
1009
+ /* Product signature: only while the blank home is on screen, because the
1010
+ element lives inside the hero frame layer. */
1011
+ .dwe-sign {
1012
+ position: fixed;
1013
+ right: 14px;
1014
+ bottom: 10px;
1015
+ z-index: 2147483000;
1016
+ font-size: 11px;
1017
+ letter-spacing: 0.08em;
1018
+ color: var(--dsw-alias-label-tertiary);
1019
+ opacity: 0.28;
1020
+ pointer-events: none;
1021
+ user-select: none;
1022
+ }
1023
+
1024
+ /* ------------------------------------------------------------------ accents */
1025
+
1026
+ /* Composer focus: the shipped 0.5px hairline turns whale blue and an inset ring
1027
+ thickens the edge. The inset shadow follows the card radius and costs no
1028
+ layout, and a focused draft editor is the only trigger — toolbar buttons
1029
+ inside the card keep the resting look. */
1030
+ /* Frosted composer, but only where something interesting runs behind it: while a
1031
+ Session is open the messages scroll under the card, so glass reads as glass. On
1032
+ the blank home the card sits on flat dotted paper, where translucency only muddies
1033
+ the surface — there it keeps the shipped solid background. */
1034
+ /* On the blank home the card must be fully opaque: the shipped menu surface is
1035
+ slightly translucent, so the wave field behind it would show through the card as
1036
+ moving light bands. */
1037
+ /* The blank home keeps the card solid only when frosting is switched off. */
1038
+ :root.df-off-glass body:has(canvas.dwe-whale) [data-composer-card] {
1039
+ background: var(--dsw-specific-input-major, var(--dsw-alias-bg-layer-1));
1040
+ }
1041
+
1042
+ :root:not(.df-off-glass) [data-composer-card] {
1043
+ /* Much more translucent than the host surface, with a stronger blur and a touch of
1044
+ saturation: the frosted look only reads if the backdrop is actually visible. */
1045
+ background:
1046
+ linear-gradient(
1047
+ 180deg,
1048
+ color-mix(in srgb, var(--dsw-alias-label-primary) 7%, transparent),
1049
+ color-mix(in srgb, var(--dsw-alias-label-primary) 2%, transparent) 42%,
1050
+ transparent
1051
+ ),
1052
+ color-mix(in srgb, var(--dsw-specific-input-major, var(--dsw-alias-bg-layer-1)) 54%, transparent);
1053
+ -webkit-backdrop-filter: blur(26px) saturate(1.25);
1054
+ backdrop-filter: blur(26px) saturate(1.25);
1055
+ }
1056
+
1057
+ /* Composer focus: a soft whale-blue ring fades in under the card's own hairline
1058
+ instead of recolouring it (a rebinding token switches instantly and reads as a
1059
+ pop). Both states declare the same shadow layers so the transition interpolates
1060
+ every layer, and the easing starts quickly and settles slowly. */
1061
+ /* Focus ring in light grey: the composer is a text surface, so the highlight stays
1062
+ neutral and the accent colour is reserved for content. */
1063
+ :root {
1064
+ --df-focus-ink: 124, 128, 136;
1065
+ }
1066
+
1067
+ body[data-ds-dark-theme] {
1068
+ --df-focus-ink: 224, 226, 232;
1069
+ }
1070
+
1071
+ :root:not(.df-off-focusring) [data-composer-card] {
1072
+ box-shadow:
1073
+ var(--dsw-elevation-soft),
1074
+ inset 0 0 0 1px rgba(var(--df-focus-ink), 0),
1075
+ 0 0 0 0 rgba(var(--df-focus-ink), 0),
1076
+ 0 0 12px 0 rgba(var(--df-focus-ink), 0),
1077
+ 0 0 32px 2px rgba(var(--df-focus-ink), 0);
1078
+ transition: box-shadow 240ms cubic-bezier(0.22, 1, 0.36, 1);
1079
+ }
1080
+
1081
+ :root:not(.df-off-focusring) [data-composer-card]:has(:is([contenteditable="true"], [role="textbox"], textarea):focus) {
1082
+ box-shadow:
1083
+ var(--dsw-elevation-soft),
1084
+ inset 0 0 0 1.2px rgba(var(--df-focus-ink), 0.92),
1085
+ 0 0 0 3px rgba(var(--df-focus-ink), 0.12),
1086
+ 0 0 14px 1px rgba(var(--df-focus-ink), 0.22),
1087
+ 0 0 40px 6px rgba(var(--df-focus-ink), 0.1);
1088
+ }
1089
+
1090
+ /* --------------------------------------------------- frame-wide ambient layer */
1091
+ .df-overlay {
1092
+ position: fixed;
1093
+ inset: 0;
1094
+ width: 100vw;
1095
+ height: 100vh;
1096
+ display: block;
1097
+ pointer-events: none;
1098
+ }
1099
+
1100
+ /* ------------------------------------------- composer stats in the button row */
1101
+ .df-stats {
1102
+ display: inline-flex;
1103
+ align-items: center;
1104
+ gap: 8px;
1105
+ margin-right: 2px;
1106
+ color: var(--dsw-alias-label-tertiary);
1107
+ font-size: var(--dsh-content-font-size-secondary, 12px);
1108
+ font-variant-numeric: tabular-nums;
1109
+ line-height: 20px;
1110
+ white-space: nowrap;
1111
+ user-select: none;
1112
+ }
1113
+
1114
+ .df-stats-item {
1115
+ opacity: 0.85;
1116
+ }
1117
+
1118
+
1119
+ /* ---------------------------------------------- reasoning effort celebration */
1120
+ body[data-ds-dark-theme] {
1121
+ --df-effort-field: rgba(255, 255, 255, 0.8);
1122
+ --df-effort-ink: rgba(255, 255, 255, 0.95);
1123
+ --df-effort-glow: rgba(255, 255, 255, 0.6);
1124
+ }
1125
+
1126
+ body:not([data-ds-dark-theme]) {
1127
+ --df-effort-field: rgba(58, 62, 72, 0.55);
1128
+ --df-effort-ink: rgba(22, 24, 28, 0.92);
1129
+ --df-effort-glow: rgba(40, 44, 52, 0.4);
1130
+ }
1131
+
1132
+ [data-composer-card] {
1133
+ position: relative;
1134
+ /* Own stacking context so the field can paint above the card surface but below its
1135
+ content without touching the host's children. */
1136
+ isolation: isolate;
1137
+ }
1138
+
1139
+ [data-composer-card].df-effort-on::before {
1140
+ content: '';
1141
+ position: absolute;
1142
+ left: 13%;
1143
+ right: 13%;
1144
+ bottom: 1px;
1145
+ height: 40px;
1146
+ z-index: -1;
1147
+ pointer-events: none;
1148
+ border-radius: 10px;
1149
+ opacity: 0.42;
1150
+ /* Two vertical highlight bars travel from the middle outwards while the model
1151
+ thinks; the third layer is the dot print itself. */
1152
+ background-image: linear-gradient(
1153
+ 90deg,
1154
+ transparent 0%,
1155
+ var(--df-effort-glow) 50%,
1156
+ transparent 100%
1157
+ ),
1158
+ linear-gradient(
1159
+ 90deg,
1160
+ transparent 0%,
1161
+ var(--df-effort-glow) 50%,
1162
+ transparent 100%
1163
+ ),
1164
+ radial-gradient(
1165
+ circle at 1px 1px,
1166
+ var(--df-effort-field) 0.9px,
1167
+ transparent 1.15px
1168
+ );
1169
+ background-size: 0% 100%, 0% 100%, 4px 4px;
1170
+ background-repeat: no-repeat, no-repeat, repeat;
1171
+ background-position: 50% 50%, 50% 50%, 0 0;
1172
+ /* Fade the field out towards both edges so it reads as depth, not a band. */
1173
+ -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 26%, #000 74%, transparent 100%);
1174
+ mask-image: linear-gradient(90deg, transparent 0%, #000 26%, #000 74%, transparent 100%);
1175
+ clip-path: inset(0 50% 0 50%);
1176
+ animation: df-effort-open 800ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
1177
+ }
1178
+
1179
+ [data-composer-card].df-effort-on::after {
1180
+ content: attr(data-df-effort);
1181
+ position: absolute;
1182
+ left: 0;
1183
+ right: 0;
1184
+ bottom: 3px;
1185
+ height: 40px;
1186
+ z-index: 2;
1187
+ pointer-events: none;
1188
+ text-align: center;
1189
+ font: italic 900 30px / 40px "Segoe UI", system-ui, sans-serif;
1190
+ letter-spacing: 0.08em;
1191
+ background-image: radial-gradient(
1192
+ circle at 1px 1px,
1193
+ var(--df-effort-ink) 0.95px,
1194
+ transparent 1.15px
1195
+ );
1196
+ background-size: 3px 3px;
1197
+ -webkit-background-clip: text;
1198
+ background-clip: text;
1199
+ color: transparent;
1200
+ opacity: 0;
1201
+ /* The shadow follows the dot alpha, so the word carries a soft halo. */
1202
+ filter:
1203
+ drop-shadow(0 0 5px rgba(255, 255, 255, 0.4))
1204
+ drop-shadow(0 0 16px rgba(255, 255, 255, 0.2));
1205
+ animation: df-effort-word 620ms 740ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
1206
+ }
1207
+
1208
+ [data-composer-card].df-effort-max::after {
1209
+ background-image: radial-gradient(
1210
+ circle at 1px 1px,
1211
+ var(--df-accent) 0.95px,
1212
+ transparent 1.15px
1213
+ );
1214
+ filter:
1215
+ drop-shadow(0 0 6px rgba(122, 170, 255, 0.75))
1216
+ drop-shadow(0 0 20px rgba(122, 170, 255, 0.45));
1217
+ }
1218
+
1219
+ body:has([data-chat-running]) [data-composer-card].df-effort-on::before {
1220
+ animation:
1221
+ df-effort-open 800ms cubic-bezier(0.22, 1, 0.36, 1) forwards,
1222
+ df-effort-spread 2.2s 900ms ease-out infinite;
1223
+ }
1224
+
1225
+ @keyframes df-effort-open {
1226
+ from { clip-path: inset(0 50% 0 50%); }
1227
+ to { clip-path: inset(0 0 0 0); }
1228
+ }
1229
+
1230
+ @keyframes df-effort-word {
1231
+ from { opacity: 0; }
1232
+ to { opacity: 1; }
1233
+ }
1234
+
1235
+ @keyframes df-effort-spread {
1236
+ 0% {
1237
+ background-size: 12% 100%, 12% 100%, 4px 4px;
1238
+ background-position: 50% 50%, 50% 50%, 0 0;
1239
+ }
1240
+ 100% {
1241
+ background-size: 12% 100%, 12% 100%, 4px 4px;
1242
+ background-position: 0% 50%, 100% 50%, 0 0;
1243
+ }
1244
+ }
1245
+
1246
+ @media (prefers-reduced-motion: reduce) {
1247
+ [data-composer-card].df-effort-on::before,
1248
+ [data-composer-card].df-effort-on::after,
1249
+ body:has([data-chat-running]) [data-composer-card].df-effort-on::before {
1250
+ animation: none;
1251
+ clip-path: inset(0 0 0 0);
1252
+ opacity: 1;
1253
+ }
1254
+ }
1255
+
1256
+
1257
+
1258
+
1259
+ /* ------------------------------------------------------------- startup splash */
1260
+ .df-splash {
1261
+ position: fixed;
1262
+ inset: 0;
1263
+ z-index: 2147483600;
1264
+ display: flex;
1265
+ align-items: center;
1266
+ justify-content: center;
1267
+ background: #050507;
1268
+ pointer-events: none;
1269
+ animation: df-splash-out 460ms 1860ms cubic-bezier(0.4, 0, 1, 1) forwards;
1270
+ contain: strict;
1271
+ }
1272
+
1273
+ /* Compositor-only animation: every property below is opacity or transform. */
1274
+ .df-splash-grid {
1275
+ position: absolute;
1276
+ inset: -2px;
1277
+ background-image: radial-gradient(circle at 1px 1px, rgba(186, 196, 214, 0.5) 0.9px, transparent 1.15px);
1278
+ background-size: 18px 18px;
1279
+ opacity: 0;
1280
+ will-change: opacity;
1281
+ animation: df-splash-grid-in 620ms 60ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
1282
+ }
1283
+
1284
+ .df-splash-ring {
1285
+ position: absolute;
1286
+ width: 108vmax;
1287
+ height: 108vmax;
1288
+ border: 1px solid rgba(176, 196, 232, 0.55);
1289
+ border-radius: 50%;
1290
+ opacity: 0;
1291
+ transform: scale(0.08);
1292
+ will-change: transform, opacity;
1293
+ animation: df-splash-ring 900ms 60ms cubic-bezier(0.16, 0.84, 0.36, 1) forwards;
1294
+ }
1295
+
1296
+ .df-splash-mark {
1297
+ position: relative;
1298
+ display: flex;
1299
+ flex-direction: column;
1300
+ align-items: center;
1301
+ gap: 0.08em;
1302
+ overflow: hidden;
1303
+ }
1304
+
1305
+ .df-splash-line {
1306
+ display: block;
1307
+ font: 800 clamp(38px, 7.8vw, 108px) / 1.14 "Segoe UI", system-ui, sans-serif;
1308
+ letter-spacing: 0.09em;
1309
+ color: transparent;
1310
+ background-size: 5px 5px;
1311
+ -webkit-background-clip: text;
1312
+ background-clip: text;
1313
+ opacity: 0;
1314
+ transform: translate3d(0, 14px, 0) scale(0.985);
1315
+ will-change: transform, opacity;
1316
+ animation: df-splash-line 760ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
1317
+ }
1318
+
1319
+ .df-splash-deepseek {
1320
+ background-image: radial-gradient(circle at 1px 1px, #eef0f4 1.1px, transparent 1.35px);
1321
+ }
1322
+
1323
+ .df-splash-harness {
1324
+ background-image: radial-gradient(circle at 1px 1px, #7aaaff 1.1px, transparent 1.35px);
1325
+ animation-delay: 170ms;
1326
+ }
1327
+
1328
+ .df-splash-sheen {
1329
+ position: absolute;
1330
+ top: -10%;
1331
+ bottom: -10%;
1332
+ left: 0;
1333
+ width: 34%;
1334
+ background: linear-gradient(
1335
+ 90deg,
1336
+ rgba(255, 255, 255, 0) 0%,
1337
+ rgba(255, 255, 255, 0.42) 50%,
1338
+ rgba(255, 255, 255, 0) 100%
1339
+ );
1340
+ opacity: 0;
1341
+ transform: translate3d(-120%, 0, 0);
1342
+ will-change: transform, opacity;
1343
+ animation: df-splash-sheen 820ms 1080ms cubic-bezier(0.4, 0, 0.6, 1) forwards;
1344
+ }
1345
+
1346
+ .df-splash-veil {
1347
+ position: absolute;
1348
+ inset: 0;
1349
+ background:
1350
+ radial-gradient(circle at 50% 46%, rgba(0, 0, 0, 0) 38%, rgba(0, 0, 0, 0.62) 100%),
1351
+ linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 26%);
1352
+ }
1353
+
1354
+ @keyframes df-splash-grid-in {
1355
+ to { opacity: 0.55; }
1356
+ }
1357
+
1358
+ @keyframes df-splash-ring {
1359
+ 0% { opacity: 0; transform: scale(0.08); }
1360
+ 30% { opacity: 0.5; }
1361
+ 100% { opacity: 0; transform: scale(1.15); }
1362
+ }
1363
+
1364
+ @keyframes df-splash-line {
1365
+ to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
1366
+ }
1367
+
1368
+ @keyframes df-splash-sheen {
1369
+ 0% { opacity: 0; transform: translate3d(-120%, 0, 0); }
1370
+ 20% { opacity: 0.9; }
1371
+ 100% { opacity: 0; transform: translate3d(300%, 0, 0); }
1372
+ }
1373
+
1374
+ @keyframes df-splash-out {
1375
+ to { opacity: 0; visibility: hidden; }
1376
+ }
1377
+
1378
+ @media (prefers-reduced-motion: reduce) {
1379
+ .df-splash,
1380
+ .df-splash-grid,
1381
+ .df-splash-ring,
1382
+ .df-splash-line,
1383
+ .df-splash-sheen {
1384
+ animation: none;
1385
+ opacity: 1;
1386
+ transform: none;
1387
+ }
1388
+ }
1389
+
1390
+ /* ------------------------------------------------------------ settings page */
1391
+ .df-set {
1392
+ max-width: 720px;
1393
+ padding: 4px 2px 24px;
1394
+ color: var(--dsw-alias-label-primary);
1395
+ font-synthesis: none;
1396
+ }
1397
+
1398
+ .df-set-group {
1399
+ margin: 0 0 22px;
1400
+ padding: 0 0 6px;
1401
+ border-bottom: 1px solid var(--dsw-alias-border-l1);
1402
+ }
1403
+
1404
+ .df-set-group:last-of-type {
1405
+ border-bottom: 0;
1406
+ }
1407
+
1408
+ .df-set-group-title {
1409
+ margin: 0 0 6px;
1410
+ color: var(--dsw-alias-label-tertiary);
1411
+ font-size: 11px;
1412
+ font-weight: 600;
1413
+ letter-spacing: 0.08em;
1414
+ text-transform: uppercase;
1415
+ }
1416
+
1417
+ .df-set-row {
1418
+ display: flex;
1419
+ align-items: center;
1420
+ gap: 16px;
1421
+ padding: 10px 0;
1422
+ }
1423
+
1424
+ .df-set-text {
1425
+ display: flex;
1426
+ flex-direction: column;
1427
+ gap: 2px;
1428
+ min-width: 0;
1429
+ flex: 1 1 auto;
1430
+ }
1431
+
1432
+ .df-set-label {
1433
+ font-size: 14px;
1434
+ line-height: 1.4;
1435
+ }
1436
+
1437
+ .df-set-desc {
1438
+ color: var(--dsw-alias-label-tertiary);
1439
+ font-size: 12px;
1440
+ line-height: 1.45;
1441
+ }
1442
+
1443
+ /* The control is an SVG capsule with a drawn circle knob, so the track ends are
1444
+ exact semicircles and the knob is an exact circle at any zoom. */
1445
+ .df-switch {
1446
+ flex: none;
1447
+ display: inline-flex;
1448
+ padding: 0;
1449
+ border: 0;
1450
+ border-radius: 14px;
1451
+ background: transparent;
1452
+ cursor: pointer;
1453
+ }
1454
+
1455
+ .df-switch:focus-visible {
1456
+ outline: 2px solid var(--dsw-focus-ring-color, #7aaaff);
1457
+ outline-offset: 2px;
1458
+ }
1459
+
1460
+ @media (prefers-reduced-motion: reduce) {
1461
+ .df-switch svg rect,
1462
+ .df-switch svg g,
1463
+ .df-switch svg circle {
1464
+ transition: none !important;
1465
+ }
1466
+ }
1467
+
1468
+ .df-set-footer {
1469
+ display: flex;
1470
+ align-items: center;
1471
+ justify-content: space-between;
1472
+ gap: 12px;
1473
+ padding-top: 8px;
1474
+ }
1475
+
1476
+ .df-set-reset {
1477
+ padding: 7px 14px;
1478
+ border: 1px solid var(--dsw-alias-border-l2);
1479
+ border-radius: var(--dsw-radius-sm, 6px);
1480
+ background: transparent;
1481
+ color: var(--dsw-alias-label-primary);
1482
+ font: inherit;
1483
+ font-size: 13px;
1484
+ cursor: pointer;
1485
+ }
1486
+
1487
+ .df-set-reset:hover {
1488
+ background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.1));
1489
+ }
1490
+
1491
+ .df-set-note {
1492
+ color: var(--dsw-alias-label-tertiary);
1493
+ font-size: 12px;
1494
+ font-variant-numeric: tabular-nums;
1495
+ }
1496
+
1497
+ /* -------------------------------------------------------- sidebar entry + sheet */
1498
+ .df-foot {
1499
+ display: flex;
1500
+ flex-direction: column;
1501
+ gap: 2px;
1502
+ min-width: 0;
1503
+ }
1504
+
1505
+ .df-foot-button {
1506
+ position: relative;
1507
+ overflow: hidden;
1508
+ display: flex;
1509
+ align-items: center;
1510
+ gap: 10px;
1511
+ width: 100%;
1512
+ padding: 7px 10px;
1513
+ border: 0;
1514
+ border-radius: var(--dsw-radius-sm, 6px);
1515
+ background: transparent;
1516
+ color: var(--dsw-alias-label-secondary);
1517
+ font: inherit;
1518
+ font-size: 13px;
1519
+ line-height: 20px;
1520
+ text-align: left;
1521
+ cursor: pointer;
1522
+ white-space: nowrap;
1523
+ overflow: hidden;
1524
+ }
1525
+
1526
+ .df-foot-dots {
1527
+ position: absolute;
1528
+ inset: 0;
1529
+ width: 100%;
1530
+ height: 100%;
1531
+ display: block;
1532
+ pointer-events: none;
1533
+ }
1534
+
1535
+ .df-foot-button > :not(.df-foot-dots) {
1536
+ position: relative;
1537
+ z-index: 1;
1538
+ }
1539
+
1540
+ .df-foot-button:hover {
1541
+ background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.1));
1542
+ color: var(--dsw-alias-label-primary);
1543
+ }
1544
+
1545
+ .df-foot-button:focus-visible {
1546
+ outline: 2px solid var(--dsw-focus-ring-color, #7aaaff);
1547
+ outline-offset: 1px;
1548
+ }
1549
+
1550
+ .df-foot-label {
1551
+ overflow: hidden;
1552
+ text-overflow: ellipsis;
1553
+ }
1554
+
1555
+ .df-sheet-root {
1556
+ position: fixed;
1557
+ inset: 0;
1558
+ z-index: 2147483001;
1559
+ }
1560
+
1561
+ .df-sheet-scrim {
1562
+ position: absolute;
1563
+ inset: 0;
1564
+ background: rgba(0, 0, 0, 0.28);
1565
+ }
1566
+
1567
+ .df-sheet-panel {
1568
+ position: absolute;
1569
+ left: 14px;
1570
+ bottom: 78px;
1571
+ width: min(420px, calc(100vw - 28px));
1572
+ max-height: min(72vh, 640px);
1573
+ display: flex;
1574
+ flex-direction: column;
1575
+ border: 0;
1576
+ border-radius: 20px;
1577
+ /* Opaque on purpose: a raised surface layered over the base colour, so the panel is
1578
+ always solid and always uses the app's own palette instead of a hand-picked grey. */
1579
+ background-color: var(--dsw-alias-bg-base, #f6f6f8);
1580
+ background-image: linear-gradient(
1581
+ var(--dsw-alias-bg-layer-1, transparent),
1582
+ var(--dsw-alias-bg-layer-1, transparent)
1583
+ );
1584
+ box-shadow: var(--dsw-elevation-panel, 0 18px 48px rgba(0, 0, 0, 0.42));
1585
+ overflow: hidden;
1586
+ animation: df-sheet-in 200ms cubic-bezier(0.22, 1, 0.36, 1);
1587
+ }
1588
+
1589
+ @keyframes df-sheet-in {
1590
+ from { opacity: 0; transform: translateY(8px); }
1591
+ to { opacity: 1; transform: translateY(0); }
1592
+ }
1593
+
1594
+ .df-sheet-head {
1595
+ display: flex;
1596
+ align-items: center;
1597
+ justify-content: space-between;
1598
+ gap: 12px;
1599
+ padding: 14px 16px 12px;
1600
+ border-bottom: 1px solid var(--dsw-alias-border-l1);
1601
+ }
1602
+
1603
+ .df-sheet-title {
1604
+ font-size: 14px;
1605
+ font-weight: 600;
1606
+ color: var(--dsw-alias-label-primary);
1607
+ }
1608
+
1609
+ .df-sheet-close {
1610
+ border: 0;
1611
+ background: transparent;
1612
+ color: var(--dsw-alias-label-tertiary);
1613
+ font-size: 18px;
1614
+ line-height: 1;
1615
+ padding: 2px 6px;
1616
+ border-radius: 6px;
1617
+ cursor: pointer;
1618
+ }
1619
+
1620
+ .df-sheet-close:hover {
1621
+ background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.1));
1622
+ color: var(--dsw-alias-label-primary);
1623
+ }
1624
+
1625
+ .df-sheet-body {
1626
+ padding: 4px 16px 8px;
1627
+ overflow-y: auto;
1628
+ }
1629
+
1630
+ @media (prefers-reduced-motion: reduce) {
1631
+ .df-sheet-panel { animation: none; }
1632
+ }
1633
+ /* fish reading:start */
1634
+ /* Deep Fish reading: semantic hooks only; never animate streamed text. */
1635
+ body {
1636
+ --df-accent: var(--dsw-alias-brand-primary, #4D6BFE);
1637
+ --df-focus: color-mix(in srgb, var(--df-accent) 18%, transparent);
1638
+ }
1639
+
1640
+ :root:not(.df-off-reading) [data-chat-flow-kind="assistant-step"]:not([data-chat-group-part="reasoning"]) :is(p, li) {
1641
+ line-height: 1.85;
1642
+ text-wrap: pretty;
1643
+ }
1644
+ :root:not(.df-off-reading) [data-chat-flow-kind="assistant-step"] :is(h1, h2, h3, h4) {
1645
+ color: var(--dsw-alias-label-primary);
1646
+ letter-spacing: -0.015em;
1647
+ line-height: 1.45;
1648
+ text-wrap: balance;
1649
+ }
1650
+ :root:not(.df-off-reading) [data-chat-flow-kind="assistant-step"] :is(h2, h3) {
1651
+ padding-block-start: 0.25em;
1652
+ }
1653
+ :root:not(.df-off-reading) [data-chat-flow-kind="assistant-step"] blockquote {
1654
+ border-inline-start: 2px solid color-mix(in srgb, var(--df-accent) 38%, transparent);
1655
+ padding-inline-start: 1em;
1656
+ color: var(--dsw-alias-label-secondary);
1657
+ }
1658
+ :root:not(.df-off-reading) [data-chat-flow-kind="assistant-step"] :is(p, li) > code {
1659
+ color: var(--dsw-alias-label-primary);
1660
+ background: var(--dsw-alias-interactive-bg-hover);
1661
+ border-radius: 4px;
1662
+ padding: 0.12em 0.35em;
1663
+ }
1664
+ :root:not(.df-off-code) [data-chat-flow-kind="assistant-step"] pre {
1665
+ font-variant-ligatures: none;
1666
+ tab-size: 2;
1667
+ }
1668
+ /* Sidebar brand: the whale mark and the product name carry a quiet halo so they read as
1669
+ part of the same light as the accent. */
1670
+ [data-slot="sidebar.brand.mark"] {
1671
+ filter:
1672
+ drop-shadow(0 0 5px color-mix(in srgb, var(--df-accent) 50%, transparent))
1673
+ drop-shadow(0 0 16px color-mix(in srgb, var(--df-accent) 26%, transparent));
1674
+ }
1675
+
1676
+ [data-slot="sidebar.brand.name"] {
1677
+ text-shadow:
1678
+ 0 0 1px color-mix(in srgb, var(--df-accent) 42%, transparent),
1679
+ 0 0 9px color-mix(in srgb, var(--df-accent) 34%, transparent),
1680
+ 0 0 22px color-mix(in srgb, var(--df-accent) 18%, transparent);
1681
+ }
1682
+
1683
+ /* User messages carry a whale-blue halo: a hairline ring plus two soft halos. */
1684
+ [data-message-bubble] {
1685
+ box-shadow:
1686
+ 0 0 0 1px color-mix(in srgb, var(--df-accent) 52%, transparent),
1687
+ 0 0 14px 1px color-mix(in srgb, var(--df-accent) 22%, transparent),
1688
+ 0 0 38px 8px color-mix(in srgb, var(--df-accent) 10%, transparent);
1689
+ }
1690
+
1691
+ /* Selected conversation: a flat black plate in dark theme instead of the host's
1692
+ translucent hover fill. */
1693
+ body[data-ds-dark-theme] [class*="_sessionRow"][class*="_selected"] {
1694
+ background-color: #0d0d10;
1695
+ }
1696
+
1697
+ body:not([data-ds-dark-theme]) [class*="_sessionRow"][class*="_selected"] {
1698
+ background-color: #e9e9ec;
1699
+ }
1700
+
1701
+ :root:not(.df-off-bold) [data-chat-flow-kind="assistant-step"] :is(p, li, td, blockquote) :is(strong, b) {
1702
+ color: var(--df-accent);
1703
+ /* A soft halo so the accent reads as light rather than paint. */
1704
+ text-shadow:
1705
+ 0 0 1px color-mix(in srgb, var(--df-accent) 55%, transparent),
1706
+ 0 0 8px color-mix(in srgb, var(--df-accent) 42%, transparent),
1707
+ 0 0 20px color-mix(in srgb, var(--df-accent) 22%, transparent);
1708
+ }
1709
+ :root:not(.df-off-thinkinglabel) [data-chat-running] [class*="_runningText"] {
1710
+ opacity: 0;
1711
+ }
1712
+ :root:not(.df-off-thinkingsphere) [data-chat-running] [class*="_runningIcon"] {
1713
+ display: none;
1714
+ }
1715
+
1716
+ /* Compact figures leave submit reachable in a narrow composer. */
1717
+ .df-stats {
1718
+ gap: 10px;
1719
+ font-size: 11px;
1720
+ letter-spacing: 0.015em;
1721
+ font-variant-numeric: tabular-nums;
1722
+ }
1723
+ .df-stats-label {
1724
+ margin-inline-end: 4px;
1725
+ color: var(--dsw-alias-label-tertiary);
1726
+ font-size: 9px;
1727
+ letter-spacing: 0.06em;
1728
+ }
1729
+ .df-stats-item { color: var(--dsw-alias-label-secondary); }
1730
+ @media (max-width: 640px) {
1731
+ .df-stats-label { display: none; }
1732
+ .df-stats { gap: 6px; }
1733
+ }
1734
+ @media (max-width: 420px) {
1735
+ .df-stats-output { display: none; }
1736
+ }
1737
+ .df-switch:disabled { cursor: default; opacity: 0.48; }
1738
+ .df-set-reset:disabled { cursor: default; opacity: 0.48; }
1739
+ .df-settings-status {
1740
+ margin: 0 0 16px;
1741
+ font-size: 12px;
1742
+ color: var(--dsw-alias-label-secondary);
1743
+ }
1744
+ .df-settings-status[role="alert"] { color: var(--dsw-alias-state-error-primary); }
1745
+ @media (prefers-reduced-motion: reduce) {
1746
+ .df-sheet-panel, .df-sheet-scrim { animation: none; }
1747
+ [data-composer-card] { transition: none !important; }
1748
+ }
1749
+
1750
+ /* fish reading:end */
1751
+ `;
1752
+ /* fish indicator:start */
1753
+ /**
1754
+ * Dot sphere and English status label.
1755
+ *
1756
+ * The host text keeps the real clock, so we read the elapsed seconds out of it and
1757
+ * redraw both the words and a sweeping highlight on our own overlay canvas. The host
1758
+ * label is hidden by `reading.css` while this is on; turning it off restores the host
1759
+ * row untouched and only parks the sphere to the left of the visible text.
1760
+ */
1761
+ function DfOverlay() {
1762
+ const canvasRef = React.useRef(null);
1763
+ const settings = useDfSettings();
1764
+ const sphereOn = settings.values.thinkingSphere !== false;
1765
+ const labelOn = settings.values.thinkingLabel !== false;
1766
+ React.useEffect(() => {
1767
+ const canvas = canvasRef.current;
1768
+ if (!canvas)
1769
+ return;
1770
+ const context = canvas.getContext('2d');
1771
+ if (!context)
1772
+ return;
1773
+ const motion = matchMedia('(prefers-reduced-motion: reduce)');
1774
+ // Wall clock anchor. The host may remount its row on every tick, so an element
1775
+ // keyed start time resets constantly; a single anchor survives those remounts
1776
+ // and is dropped as soon as the row leaves the document.
1777
+ const clock = { since: 0 };
1778
+ let frame = 0;
1779
+ let stopped = false;
1780
+ const clear = () => context.clearRect(0, 0, canvas.width, canvas.height);
1781
+ // The hidden host text cannot be trusted for the clock (its digits are not the
1782
+ // elapsed value), so the label counts wall time from when the running row first
1783
+ // appeared and restarts whenever the row leaves the document.
1784
+ const elapsedOf = (now) => {
1785
+ if (clock.since === 0)
1786
+ clock.since = now;
1787
+ return Math.max(0, Math.round((now - clock.since) / 1000));
1788
+ };
1789
+ const drawSphere = (cx, cy, spin, ink) => {
1790
+ // Two batched passes: a soft halo under a crisp core, so the sphere reads as
1791
+ // light instead of loose dots. Only 42 dots, so buckets are cheap.
1792
+ const points = [];
1793
+ for (let index = 0; index < 42; index += 1) {
1794
+ const v = 1 - (2 * (index + 0.5)) / 42;
1795
+ const ring = Math.sqrt(1 - v * v);
1796
+ const angle = index * 2.39996323 + spin;
1797
+ const depth = Math.sin(angle) * ring;
1798
+ points.push({
1799
+ x: cx + Math.cos(angle) * ring * 8,
1800
+ y: cy + v * 8,
1801
+ alpha: 0.25 + (depth + 1) * 0.32,
1802
+ radius: 0.8 + (depth + 1) * 0.35,
1803
+ });
1804
+ }
1805
+ context.fillStyle = ink;
1806
+ const passes = [
1807
+ { grow: 2.1, scale: 0.28 },
1808
+ { grow: 1, scale: 1 },
1809
+ ];
1810
+ for (const pass of passes) {
1811
+ const buckets = new Map();
1812
+ for (const point of points) {
1813
+ const alpha = point.alpha * pass.scale;
1814
+ if (alpha < 0.02)
1815
+ continue;
1816
+ const level = Math.min(10, Math.max(1, Math.round(alpha * 10)));
1817
+ let bucket = buckets.get(level);
1818
+ if (bucket === undefined) {
1819
+ bucket = new Path2D();
1820
+ buckets.set(level, bucket);
1821
+ }
1822
+ const radius = point.radius * pass.grow;
1823
+ bucket.moveTo(point.x + radius, point.y);
1824
+ bucket.arc(point.x, point.y, radius, 0, Math.PI * 2);
1825
+ }
1826
+ for (const [level, path] of buckets) {
1827
+ context.globalAlpha = level / 10;
1828
+ context.fill(path);
1829
+ }
1830
+ }
1831
+ context.globalAlpha = 1;
1832
+ };
1833
+ const drawLabel = (row, label, x, cy, seconds, now, ink) => {
1834
+ const style = getComputedStyle(label);
1835
+ const font = style.fontWeight + ' ' + style.fontSize + ' ' + style.fontFamily;
1836
+ context.font = font;
1837
+ context.textBaseline = 'middle';
1838
+ const text = 'Deep thinking for ' + seconds + 's. . .';
1839
+ const width = context.measureText(text).width;
1840
+ const accent = (getComputedStyle(row).getPropertyValue('--df-accent') || '').trim() || '#7aaaff';
1841
+ const band = motion.matches ? -1e4 : ((now % 2600) / 2600) * (width + 140) - 70;
1842
+ context.save();
1843
+ context.beginPath();
1844
+ context.rect(x - 2, cy - 20, width + 4, 40);
1845
+ context.clip();
1846
+ context.fillStyle = ink;
1847
+ context.globalAlpha = 0.92;
1848
+ context.fillText(text, x, cy);
1849
+ context.globalAlpha = 1;
1850
+ const gradient = context.createLinearGradient(x + band - 70, 0, x + band + 70, 0);
1851
+ gradient.addColorStop(0, 'rgba(122, 170, 255, 0)');
1852
+ gradient.addColorStop(0.5, accent);
1853
+ gradient.addColorStop(1, 'rgba(122, 170, 255, 0)');
1854
+ context.fillStyle = gradient;
1855
+ context.fillText(text, x, cy);
1856
+ context.restore();
1857
+ };
1858
+ const paint = (now) => {
1859
+ frame = 0;
1860
+ if (stopped || document.hidden)
1861
+ return;
1862
+ const dpr = Math.min(2, devicePixelRatio || 1);
1863
+ const width = innerWidth;
1864
+ const height = innerHeight;
1865
+ if (canvas.width !== Math.round(width * dpr) || canvas.height !== Math.round(height * dpr)) {
1866
+ canvas.width = Math.round(width * dpr);
1867
+ canvas.height = Math.round(height * dpr);
1868
+ }
1869
+ clear();
1870
+ context.setTransform(dpr, 0, 0, dpr, 0, 0);
1871
+ const card = document.querySelector('[data-composer-card]');
1872
+ const cardTop = card === null ? height : card.getBoundingClientRect().top;
1873
+ const spin = motion.matches ? 0.35 : now / 1800;
1874
+ const running = document.querySelectorAll('[data-chat-running]');
1875
+ if (running.length === 0)
1876
+ clock.since = 0;
1877
+ let visible = false;
1878
+ for (const row of document.querySelectorAll('[data-chat-running]:not([data-holding])')) {
1879
+ const bounds = row.getBoundingClientRect();
1880
+ if (bounds.height === 0 || bounds.top < 0 || bounds.bottom > height)
1881
+ continue;
1882
+ // The overlay paints above every column: never let the sphere or the label
1883
+ // sit over the composer card.
1884
+ if (bounds.bottom + 2 > cardTop)
1885
+ continue;
1886
+ const label = row.querySelector('[class*="_runningText"]');
1887
+ if (label === null)
1888
+ continue;
1889
+ const labelRect = label.getBoundingClientRect();
1890
+ const ink = getComputedStyle(label).color || 'rgb(200, 205, 215)';
1891
+ const size = 24;
1892
+ let cx;
1893
+ let cy;
1894
+ if (labelOn) {
1895
+ cx = bounds.left + 2 + size / 2;
1896
+ cy = bounds.top + Math.min(bounds.height, 30) / 2;
1897
+ }
1898
+ else {
1899
+ if (labelRect.width === 0)
1900
+ continue;
1901
+ // Keep clear of the host words: park the sphere in the gutter to their left.
1902
+ cx = Math.max(size / 2 + 6, labelRect.left - size / 2 - 8);
1903
+ cy = labelRect.top + labelRect.height / 2;
1904
+ }
1905
+ visible = true;
1906
+ if (sphereOn)
1907
+ drawSphere(cx, cy, spin, ink);
1908
+ if (labelOn) {
1909
+ const seconds = elapsedOf(now);
1910
+ const x = bounds.left + 2 + (sphereOn ? size + 8 : 0);
1911
+ drawLabel(row, label, x, cy, seconds, now, ink);
1912
+ }
1913
+ }
1914
+ if (visible && !motion.matches)
1915
+ frame = requestAnimationFrame(paint);
1916
+ };
1917
+ const refresh = () => {
1918
+ if (frame)
1919
+ cancelAnimationFrame(frame);
1920
+ frame = 0;
1921
+ if (document.hidden)
1922
+ clear();
1923
+ else
1924
+ frame = requestAnimationFrame(paint);
1925
+ };
1926
+ const observer = new MutationObserver(refresh);
1927
+ observer.observe(document.body, {
1928
+ childList: true,
1929
+ subtree: true,
1930
+ characterData: true,
1931
+ attributes: true,
1932
+ attributeFilter: ['data-holding', 'data-ds-dark-theme'],
1933
+ });
1934
+ window.addEventListener('resize', refresh);
1935
+ document.addEventListener('scroll', refresh, true);
1936
+ document.addEventListener('visibilitychange', refresh);
1937
+ motion.addEventListener('change', refresh);
1938
+ refresh();
1939
+ return () => {
1940
+ stopped = true;
1941
+ cancelAnimationFrame(frame);
1942
+ observer.disconnect();
1943
+ window.removeEventListener('resize', refresh);
1944
+ document.removeEventListener('scroll', refresh, true);
1945
+ document.removeEventListener('visibilitychange', refresh);
1946
+ motion.removeEventListener('change', refresh);
1947
+ };
1948
+ }, [sphereOn, labelOn]);
1949
+ return sphereOn || labelOn
1950
+ ? h('canvas', { ref: canvasRef, className: 'df-overlay', 'aria-hidden': 'true' })
1951
+ : null;
1952
+ }
1953
+ /* fish indicator:end */
1954
+ /** Compact session stats for the composer button row. */
1955
+ /**
1956
+ * Hover dot field for every rows in the sidebar.
1957
+ *
1958
+ * No nodes are injected into host buttons: a single fixed canvas tracks the pointer,
1959
+ * finds the sidebar button under it, and prints a dot field clipped to that button.
1960
+ */
1961
+ function DfSidebarDots() {
1962
+ const canvasRef = React.useRef(null);
1963
+ const { values } = useDfSettings();
1964
+ const showDots = values.sidebarDots !== false;
1965
+ const showRail = values.sidebarRail !== false;
1966
+ React.useEffect(() => {
1967
+ const canvas = canvasRef.current;
1968
+ if (canvas === null)
1969
+ return;
1970
+ const context = canvas.getContext('2d');
1971
+ if (context === null)
1972
+ return;
1973
+ const motion = matchMedia('(prefers-reduced-motion: reduce)');
1974
+ const state = {
1975
+ row: null,
1976
+ x: 0,
1977
+ y: 0,
1978
+ inside: false,
1979
+ rail: false,
1980
+ alpha: 0,
1981
+ frame: 0,
1982
+ live: false,
1983
+ dirty: false,
1984
+ };
1985
+ let stopped = false;
1986
+ let dpr = Math.min(2, devicePixelRatio || 1);
1987
+ let rootCache = null;
1988
+ // The sidebar column itself is the scope: walk up from our footer button to the
1989
+ // column landmark, once, and only light controls inside it. A lowest-common-ancestor
1990
+ // guess leaked into the chat column and put rails on every button in the app.
1991
+ const sidebarScope = () => {
1992
+ if (rootCache !== null && rootCache.isConnected)
1993
+ return rootCache;
1994
+ const foot = document.querySelector('.df-foot-button');
1995
+ if (foot === null)
1996
+ return null;
1997
+ let node = foot;
1998
+ for (let depth = 0; depth < 10; depth += 1) {
1999
+ node = node.parentElement;
2000
+ if (node === null)
2001
+ break;
2002
+ if (node.matches('aside, [data-slot="sidebar"], [data-sidebar], [role="navigation"]')) {
2003
+ rootCache = node;
2004
+ return node;
2005
+ }
2006
+ }
2007
+ // No landmark: take the column wrapper a few levels up as a best effort.
2008
+ let fallback = foot;
2009
+ for (let depth = 0; depth < 5 && fallback.parentElement !== null; depth += 1) {
2010
+ fallback = fallback.parentElement;
2011
+ }
2012
+ rootCache = fallback;
2013
+ return fallback;
2014
+ };
2015
+ const paint = () => {
2016
+ state.frame = 0;
2017
+ if (stopped)
2018
+ return;
2019
+ const width = innerWidth;
2020
+ const height = innerHeight;
2021
+ if (canvas.width !== Math.round(width * dpr) || canvas.height !== Math.round(height * dpr)) {
2022
+ canvas.width = Math.round(width * dpr);
2023
+ canvas.height = Math.round(height * dpr);
2024
+ }
2025
+ const target = state.inside ? 1 : 0;
2026
+ state.alpha = motion.matches ? target : state.alpha + (target - state.alpha) * 0.22;
2027
+ context.setTransform(dpr, 0, 0, dpr, 0, 0);
2028
+ context.clearRect(0, 0, width, height);
2029
+ if (!state.inside && state.alpha < 0.02) {
2030
+ state.alpha = 0;
2031
+ state.live = false;
2032
+ return;
2033
+ }
2034
+ if (state.row === null || !state.row.isConnected) {
2035
+ state.inside = false;
2036
+ state.live = false;
2037
+ return;
2038
+ }
2039
+ const rect = state.row.getBoundingClientRect();
2040
+ if (rect.width < 8 || rect.height < 8 || rect.bottom < 0 || rect.top > height) {
2041
+ state.live = false;
2042
+ return;
2043
+ }
2044
+ const style = getComputedStyle(state.row);
2045
+ const radius = parseFloat(style.borderTopLeftRadius) || 8;
2046
+ const accent = (style.getPropertyValue('--df-accent') || '').trim() || '#7aa4ff';
2047
+ const reach = 74;
2048
+ context.save();
2049
+ context.beginPath();
2050
+ if (typeof context.roundRect === 'function') {
2051
+ context.roundRect(rect.left, rect.top, rect.width, rect.height, radius);
2052
+ }
2053
+ else {
2054
+ context.rect(rect.left, rect.top, rect.width, rect.height);
2055
+ }
2056
+ context.clip();
2057
+ context.fillStyle = accent;
2058
+ if (showDots) {
2059
+ const startX = Math.floor(rect.left / 4) * 4 + 2;
2060
+ const startY = Math.floor(rect.top / 4) * 4 + 2;
2061
+ for (let y = startY; y < rect.bottom; y += 4) {
2062
+ for (let x = startX; x < rect.right; x += 4) {
2063
+ const dx = x - state.x;
2064
+ const dy = y - state.y;
2065
+ const distance = Math.sqrt(dx * dx + dy * dy);
2066
+ if (distance > reach)
2067
+ continue;
2068
+ const alpha = Math.pow(1 - distance / reach, 1.35) * state.alpha * 0.72;
2069
+ if (alpha < 0.02)
2070
+ continue;
2071
+ context.globalAlpha = Math.min(1, alpha);
2072
+ context.beginPath();
2073
+ context.arc(x, y, 0.85, 0, Math.PI * 2);
2074
+ context.fill();
2075
+ }
2076
+ }
2077
+ }
2078
+ // A short whale-blue rail marks the hovered control — buttons only.
2079
+ if (state.rail && showRail) {
2080
+ const railWidth = 3;
2081
+ const railInset = 5;
2082
+ const railHeight = Math.max(6, rect.height - railInset * 2);
2083
+ const railTop = rect.top + (rect.height - railHeight) / 2;
2084
+ context.globalAlpha = Math.min(1, state.alpha * 0.9);
2085
+ context.beginPath();
2086
+ if (typeof context.roundRect === 'function') {
2087
+ context.roundRect(rect.left + 2, railTop, railWidth, railHeight, 1.5);
2088
+ }
2089
+ else {
2090
+ context.rect(rect.left + 2, railTop, railWidth, railHeight);
2091
+ }
2092
+ context.fill();
2093
+ }
2094
+ context.restore();
2095
+ context.globalAlpha = 1;
2096
+ const moving = state.dirty;
2097
+ state.dirty = false;
2098
+ if (motion.matches) {
2099
+ if (!state.inside) {
2100
+ context.clearRect(0, 0, width, height);
2101
+ state.alpha = 0;
2102
+ }
2103
+ state.live = false;
2104
+ return;
2105
+ }
2106
+ if (state.inside && state.alpha >= 0.98 && !moving) {
2107
+ state.live = false;
2108
+ return;
2109
+ }
2110
+ if (state.inside || state.alpha >= 0.02) {
2111
+ state.frame = requestAnimationFrame(paint);
2112
+ }
2113
+ else {
2114
+ state.live = false;
2115
+ }
2116
+ };
2117
+ const wake = () => {
2118
+ if (stopped || state.live)
2119
+ return;
2120
+ state.live = true;
2121
+ if (state.frame === 0)
2122
+ state.frame = requestAnimationFrame(paint);
2123
+ };
2124
+ const onMove = event => {
2125
+ const target = event.target instanceof Element
2126
+ ? event.target.closest('button, a, [role="button"]')
2127
+ : null;
2128
+ const scope = sidebarScope();
2129
+ const insideSidebar = target !== null
2130
+ && scope !== null
2131
+ && scope.contains(target)
2132
+ && !target.closest('.df-foot');
2133
+ if (!insideSidebar) {
2134
+ if (state.inside) {
2135
+ state.inside = false;
2136
+ state.row = null;
2137
+ wake();
2138
+ }
2139
+ return;
2140
+ }
2141
+ state.row = target;
2142
+ state.rail = target.matches('button');
2143
+ state.x = event.clientX;
2144
+ state.y = event.clientY;
2145
+ state.inside = true;
2146
+ state.dirty = true;
2147
+ wake();
2148
+ };
2149
+ const onLeave = () => {
2150
+ if (!state.inside)
2151
+ return;
2152
+ state.inside = false;
2153
+ state.row = null;
2154
+ wake();
2155
+ };
2156
+ document.addEventListener('pointermove', onMove, { passive: true });
2157
+ document.addEventListener('pointerleave', onLeave);
2158
+ window.addEventListener('blur', onLeave);
2159
+ window.addEventListener('resize', wake);
2160
+ return () => {
2161
+ stopped = true;
2162
+ document.removeEventListener('pointermove', onMove);
2163
+ document.removeEventListener('pointerleave', onLeave);
2164
+ window.removeEventListener('blur', onLeave);
2165
+ window.removeEventListener('resize', wake);
2166
+ if (state.frame !== 0)
2167
+ cancelAnimationFrame(state.frame);
2168
+ state.frame = 0;
2169
+ state.live = false;
2170
+ };
2171
+ }, [showDots, showRail]);
2172
+ return showDots || showRail
2173
+ ? h('canvas', { ref: canvasRef, className: 'df-overlay', 'aria-hidden': 'true' })
2174
+ : null;
2175
+ }
2176
+ /**
2177
+ * Dot trail behind the composer caret.
2178
+ *
2179
+ * The caret itself is host-owned, so we only read its position (collapsed selection
2180
+ * range inside the active composer) and print a fading line of dots behind it on our
2181
+ * overlay canvas, clipped to the composer card. Dots never move once printed; they only
2182
+ * fade.
2183
+ */
2184
+ function DfCaretTrail() {
2185
+ const canvasRef = React.useRef(null);
2186
+ React.useEffect(() => {
2187
+ const canvas = canvasRef.current;
2188
+ if (canvas === null)
2189
+ return;
2190
+ const context = canvas.getContext('2d');
2191
+ if (context === null)
2192
+ return;
2193
+ const motion = matchMedia('(prefers-reduced-motion: reduce)');
2194
+ if (motion.matches)
2195
+ return undefined;
2196
+ const trail = [];
2197
+ const LIFE = 650;
2198
+ const STEP = 3;
2199
+ let stopped = false;
2200
+ let frame = 0;
2201
+ let last = null;
2202
+ let trailCard = null;
2203
+ let dpr = Math.min(2, devicePixelRatio || 1);
2204
+ // A caret (or an IME composition) has no reliable box of its own, so every
2205
+ // measurement falls back to the text or element next to the insertion point.
2206
+ const rectAt = (container, offset) => {
2207
+ if (container === null)
2208
+ return null;
2209
+ const range = document.createRange();
2210
+ try {
2211
+ range.setStart(container, offset);
2212
+ range.collapse(true);
2213
+ }
2214
+ catch (error) {
2215
+ return null;
2216
+ }
2217
+ const collapsed = range.getBoundingClientRect();
2218
+ if (collapsed.height > 0 && (collapsed.left > 0 || collapsed.top > 0)) {
2219
+ return { left: collapsed.left, top: collapsed.top, height: collapsed.height };
2220
+ }
2221
+ const measure = (node, side) => {
2222
+ if (node === null)
2223
+ return null;
2224
+ const inner = document.createRange();
2225
+ inner.selectNodeContents(node);
2226
+ const box = inner.getBoundingClientRect();
2227
+ if (box.height === 0)
2228
+ return null;
2229
+ return { left: side === 'end' ? box.right : box.left, top: box.top, height: box.height };
2230
+ };
2231
+ if (container.nodeType === 3) {
2232
+ const text = container.textContent || '';
2233
+ if (offset > 0) {
2234
+ const inner = document.createRange();
2235
+ inner.setStart(container, offset - 1);
2236
+ inner.setEnd(container, offset);
2237
+ const box = inner.getBoundingClientRect();
2238
+ if (box.height > 0)
2239
+ return { left: box.right, top: box.top, height: box.height };
2240
+ }
2241
+ if (text.length > 0) {
2242
+ const inner = document.createRange();
2243
+ inner.setStart(container, 0);
2244
+ inner.setEnd(container, 1);
2245
+ const box = inner.getBoundingClientRect();
2246
+ if (box.height > 0)
2247
+ return { left: box.left, top: box.top, height: box.height };
2248
+ }
2249
+ return null;
2250
+ }
2251
+ if (container.nodeType === 1) {
2252
+ const children = container.childNodes;
2253
+ return measure(offset > 0 ? children[offset - 1] : null, 'end')
2254
+ || measure(offset < children.length ? children[offset] : null, 'start');
2255
+ }
2256
+ return null;
2257
+ };
2258
+ const caretOf = () => {
2259
+ const active = document.activeElement;
2260
+ if (active === null || typeof active.closest !== 'function')
2261
+ return null;
2262
+ const card = active.closest('[data-composer-card]');
2263
+ if (card === null)
2264
+ return null;
2265
+ const editable = active instanceof HTMLElement && active.isContentEditable
2266
+ ? active
2267
+ : active.closest('[contenteditable], [role="textbox"], textarea');
2268
+ if (editable === null || !card.contains(editable))
2269
+ return null;
2270
+ const selection = window.getSelection();
2271
+ if (selection === null || selection.rangeCount === 0)
2272
+ return null;
2273
+ // While an IME composes, the selection covers the composition text; the caret
2274
+ // sits at its focus end, so measure there instead of bailing out.
2275
+ const container = selection.isCollapsed ? selection.anchorNode : selection.focusNode;
2276
+ const offset = selection.isCollapsed ? selection.anchorOffset : selection.focusOffset;
2277
+ if (container === null)
2278
+ return null;
2279
+ if (container !== active && !active.contains(container))
2280
+ return null;
2281
+ const rect = rectAt(container, offset);
2282
+ if (rect === null || rect.height === 0)
2283
+ return null;
2284
+ return { x: rect.left, y: rect.top, height: rect.height, card };
2285
+ };
2286
+ const push = (from, to, now) => {
2287
+ const deviceX = to.x - from.x;
2288
+ const deviceY = to.y - from.y;
2289
+ const distance = Math.sqrt(deviceX * deviceX + deviceY * deviceY);
2290
+ if (distance < 1.5)
2291
+ return;
2292
+ // A line wrap or a jump to another spot is not a trail; only same-line motion is.
2293
+ if (distance > 90 || Math.abs(deviceY) > 6)
2294
+ return;
2295
+ const topFrom = from.y;
2296
+ const topTo = to.y;
2297
+ const steps = Math.max(1, Math.min(40, Math.round(distance / STEP)));
2298
+ for (let index = 1; index <= steps; index += 1) {
2299
+ const t = index / steps;
2300
+ trail.push({
2301
+ x: from.x + deviceX * t,
2302
+ y: topFrom + (topTo - topFrom) * t,
2303
+ height: to.height || 18,
2304
+ born: now - (steps - index) * 6,
2305
+ });
2306
+ }
2307
+ while (trail.length > 220)
2308
+ trail.shift();
2309
+ };
2310
+ const sample = () => {
2311
+ const caret = caretOf();
2312
+ if (caret === null) {
2313
+ last = null;
2314
+ trailCard = null;
2315
+ return;
2316
+ }
2317
+ trailCard = caret.card;
2318
+ const now = performance.now();
2319
+ if (last !== null) {
2320
+ const sameCard = last.card === caret.card;
2321
+ if (sameCard)
2322
+ push({ x: last.x, y: last.y, height: last.height }, caret, now);
2323
+ }
2324
+ last = { x: caret.x, y: caret.y, height: caret.height, card: caret.card };
2325
+ wake();
2326
+ };
2327
+ const paint = () => {
2328
+ frame = 0;
2329
+ if (stopped)
2330
+ return;
2331
+ const width = innerWidth;
2332
+ const height = innerHeight;
2333
+ if (canvas.width !== Math.round(width * dpr) || canvas.height !== Math.round(height * dpr)) {
2334
+ canvas.width = Math.round(width * dpr);
2335
+ canvas.height = Math.round(height * dpr);
2336
+ }
2337
+ context.setTransform(dpr, 0, 0, dpr, 0, 0);
2338
+ context.clearRect(0, 0, width, height);
2339
+ const now = performance.now();
2340
+ while (trail.length > 0 && now - trail[0].born > LIFE)
2341
+ trail.shift();
2342
+ if (trail.length === 0) {
2343
+ trailCard = null;
2344
+ return;
2345
+ }
2346
+ const card = trailCard;
2347
+ let clip = null;
2348
+ let radius = 12;
2349
+ if (card !== null && card.isConnected) {
2350
+ clip = card.getBoundingClientRect();
2351
+ const style = getComputedStyle(card);
2352
+ radius = parseFloat(style.borderTopLeftRadius) || 12;
2353
+ }
2354
+ const accent = (getComputedStyle(document.body).getPropertyValue('--df-accent') || '').trim() || '#7aa4ff';
2355
+ context.save();
2356
+ if (clip !== null) {
2357
+ context.beginPath();
2358
+ if (typeof context.roundRect === 'function') {
2359
+ context.roundRect(clip.left, clip.top, clip.width, clip.height, radius);
2360
+ }
2361
+ else {
2362
+ context.rect(clip.left, clip.top, clip.width, clip.height);
2363
+ }
2364
+ context.clip();
2365
+ }
2366
+ // Collect every dot once, then paint a soft halo pass and a crisp pass in
2367
+ // batches: per-dot fills with shadows would crawl.
2368
+ const dots = [];
2369
+ for (const point of trail) {
2370
+ const age = (now - point.born) / LIFE;
2371
+ if (age >= 1)
2372
+ continue;
2373
+ const alpha = Math.pow(1 - age, 1.4) * 0.85;
2374
+ if (alpha < 0.02)
2375
+ continue;
2376
+ for (let offset = 1; offset < point.height - 0.5; offset += 3) {
2377
+ dots.push(point.x, point.y + offset, alpha);
2378
+ }
2379
+ }
2380
+ context.fillStyle = accent;
2381
+ const passes = [
2382
+ { radius: 2.4, scale: 0.3 },
2383
+ { radius: 1.05, scale: 1 },
2384
+ ];
2385
+ for (const pass of passes) {
2386
+ const buckets = new Map();
2387
+ for (let index = 0; index < dots.length; index += 3) {
2388
+ const alpha = dots[index + 2] * pass.scale;
2389
+ if (alpha < 0.02)
2390
+ continue;
2391
+ const level = Math.min(10, Math.max(1, Math.round(alpha * 10)));
2392
+ let bucket = buckets.get(level);
2393
+ if (bucket === undefined) {
2394
+ bucket = new Path2D();
2395
+ buckets.set(level, bucket);
2396
+ }
2397
+ bucket.moveTo(dots[index] + pass.radius, dots[index + 1]);
2398
+ bucket.arc(dots[index], dots[index + 1], pass.radius, 0, Math.PI * 2);
2399
+ }
2400
+ for (const [level, path] of buckets) {
2401
+ context.globalAlpha = level / 10;
2402
+ context.fill(path);
2403
+ }
2404
+ }
2405
+ context.restore();
2406
+ context.globalAlpha = 1;
2407
+ frame = requestAnimationFrame(paint);
2408
+ };
2409
+ const wake = () => {
2410
+ if (stopped || frame !== 0)
2411
+ return;
2412
+ frame = requestAnimationFrame(paint);
2413
+ };
2414
+ window.__dfCaretProbe = () => {
2415
+ const caret = caretOf();
2416
+ return caret === null
2417
+ ? { ok: false, active: document.activeElement ? document.activeElement.tagName : null }
2418
+ : { ok: true, x: Math.round(caret.x), y: Math.round(caret.y), height: Math.round(caret.height) };
2419
+ };
2420
+ const onActivity = () => sample();
2421
+ document.addEventListener('selectionchange', onActivity);
2422
+ document.addEventListener('input', onActivity, true);
2423
+ document.addEventListener('beforeinput', onActivity, true);
2424
+ document.addEventListener('compositionupdate', onActivity, true);
2425
+ document.addEventListener('keyup', onActivity, true);
2426
+ document.addEventListener('click', onActivity, true);
2427
+ document.addEventListener('pointerup', onActivity, true);
2428
+ window.addEventListener('resize', wake);
2429
+ return () => {
2430
+ stopped = true;
2431
+ document.removeEventListener('selectionchange', onActivity);
2432
+ document.removeEventListener('input', onActivity, true);
2433
+ document.removeEventListener('beforeinput', onActivity, true);
2434
+ document.removeEventListener('compositionupdate', onActivity, true);
2435
+ document.removeEventListener('keyup', onActivity, true);
2436
+ document.removeEventListener('click', onActivity, true);
2437
+ document.removeEventListener('pointerup', onActivity, true);
2438
+ window.removeEventListener('resize', wake);
2439
+ if (frame !== 0)
2440
+ cancelAnimationFrame(frame);
2441
+ frame = 0;
2442
+ trail.length = 0;
2443
+ };
2444
+ }, []);
2445
+ return h('canvas', {
2446
+ ref: canvasRef,
2447
+ className: 'df-overlay df-caret-layer',
2448
+ 'aria-hidden': 'true',
2449
+ style: { zIndex: 2147483000 },
2450
+ });
2451
+ }
2452
+ /**
2453
+ * Reasoning effort badge, done entirely in CSS.
2454
+ *
2455
+ * We only read the effort label and stamp two attributes on the composer card; the
2456
+ * unfolding dot field and the dot-printed level name are pseudo-elements, so there is no
2457
+ * canvas geometry to measure and nothing to drift when the layout changes.
2458
+ */
2459
+ const DF_EFFORT_OFF = /^(off|none|disabled?|无|关闭)$/i;
2460
+ function dfEffortLabel() {
2461
+ const card = document.querySelector('[data-composer-card]');
2462
+ if (card === null)
2463
+ return null;
2464
+ const node = card.querySelector('[class*="_triggerEffort"]');
2465
+ if (node === null)
2466
+ return null;
2467
+ const text = (node.textContent || '').trim();
2468
+ return text === '' ? null : text;
2469
+ }
2470
+ function dfPaintEffort(label) {
2471
+ const card = document.querySelector('[data-composer-card]');
2472
+ if (card === null)
2473
+ return;
2474
+ if (label === null) {
2475
+ card.removeAttribute('data-df-effort');
2476
+ card.classList.remove('df-effort-on', 'df-effort-max');
2477
+ return;
2478
+ }
2479
+ const word = label.toUpperCase();
2480
+ const changed = card.getAttribute('data-df-effort') !== word;
2481
+ card.setAttribute('data-df-effort', word);
2482
+ card.classList.toggle('df-effort-max', word === 'MAX');
2483
+ if (changed) {
2484
+ // Toggle the class off and on so the CSS animation replays for the new word.
2485
+ card.classList.remove('df-effort-on');
2486
+ void card.offsetWidth;
2487
+ card.classList.add('df-effort-on');
2488
+ }
2489
+ else if (!card.classList.contains('df-effort-on')) {
2490
+ card.classList.add('df-effort-on');
2491
+ }
2492
+ }
2493
+ /**
2494
+ * Startup splash: the dot wordmark over the boot screen.
2495
+ *
2496
+ * The whole animation is CSS transform/opacity so the compositor drives it: no canvas,
2497
+ * no per-frame JavaScript while the app is still booting.
2498
+ */
2499
+ function dfPlaySplash() {
2500
+ if (window.__dfSplashPlayed === true)
2501
+ return;
2502
+ window.__dfSplashPlayed = true;
2503
+ try {
2504
+ if (typeof document === 'undefined' || document.body === null)
2505
+ return;
2506
+ if (matchMedia('(prefers-reduced-motion: reduce)').matches)
2507
+ return;
2508
+ const layer = document.createElement('div');
2509
+ layer.className = 'df-splash';
2510
+ layer.setAttribute('aria-hidden', 'true');
2511
+ const grid = document.createElement('div');
2512
+ grid.className = 'df-splash-grid';
2513
+ const ring = document.createElement('div');
2514
+ ring.className = 'df-splash-ring';
2515
+ const mark = document.createElement('div');
2516
+ mark.className = 'df-splash-mark';
2517
+ const deepseek = document.createElement('span');
2518
+ deepseek.className = 'df-splash-line df-splash-deepseek';
2519
+ deepseek.textContent = 'deepseek';
2520
+ const harness = document.createElement('span');
2521
+ harness.className = 'df-splash-line df-splash-harness';
2522
+ harness.textContent = 'harness';
2523
+ const sheen = document.createElement('div');
2524
+ sheen.className = 'df-splash-sheen';
2525
+ mark.append(deepseek, harness, sheen);
2526
+ const veil = document.createElement('div');
2527
+ veil.className = 'df-splash-veil';
2528
+ layer.append(grid, ring, mark, veil);
2529
+ document.body.appendChild(layer);
2530
+ const remove = () => {
2531
+ if (layer.isConnected)
2532
+ layer.remove();
2533
+ };
2534
+ layer.addEventListener('animationend', event => {
2535
+ if (event.animationName === 'df-splash-out')
2536
+ remove();
2537
+ });
2538
+ setTimeout(remove, 3200);
2539
+ }
2540
+ catch (error) {
2541
+ console.warn('[dsh-fish-ui] splash failed', error);
2542
+ }
2543
+ }
2544
+ /* fish runtime:start */
2545
+ // Profile settings and host theme token layers.
2546
+ const DF_SETTINGS_KEY = 'dsh-fish-ui:settings';
2547
+ const DF_FLAGS = [
2548
+ 'hero', 'field', 'wave', 'ripple', 'thinkingSphere', 'thinkingLabel',
2549
+ 'glass', 'effortBadge', 'sidebarDots', 'sidebarRail', 'bold', 'focusRing', 'diff',
2550
+ 'reading', 'code', 'fishFont', 'fishGlow', 'fishMotion', 'fishCode',
2551
+ 'catppuccin', 'aurora', 'cursor', 'textMotion', 'hostIcons',
2552
+ ];
2553
+ const DF_DEFAULT_SETTINGS = Object.freeze({
2554
+ ...Object.fromEntries(DF_FLAGS.map(key => [key, true])),
2555
+ scene: 'atlas', sceneMotion: 'calm', iconStyle: 'duotone', accentColor: BRAND_BLUE,
2556
+ });
2557
+ function validSetting(key, value) {
2558
+ if (key === 'accentColor')
2559
+ return typeof value === 'string' && /^#[0-9a-f]{6}$/i.test(value);
2560
+ if (Object.hasOwn(STUDIO_CHOICES, key))
2561
+ return typeof value === 'string' && STUDIO_CHOICES[key].includes(value);
2562
+ return DF_FLAGS.includes(key) && typeof value === 'boolean';
2563
+ }
2564
+ const DF_OFF_CLASS = Object.freeze(Object.fromEntries(DF_FLAGS
2565
+ .map(key => [key, 'df-off-' + key.toLowerCase()])));
2566
+ const dfSettingsListeners = new Set();
2567
+ let dfSettings = DF_DEFAULT_SETTINGS;
2568
+ let dfSnapshot = { values: dfSettings, status: 'loading', writable: false, pending: false, error: '' };
2569
+ let dfWrite = null;
2570
+ let dfSettingsOwner = null;
2571
+ let dfTheme = null;
2572
+ const dfThemeLayers = new Map();
2573
+ let dfMounted = false;
2574
+ const dfReadLegacy = () => {
2575
+ try {
2576
+ const parsed = JSON.parse(window.localStorage.getItem(DF_SETTINGS_KEY));
2577
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))
2578
+ return null;
2579
+ const values = Object.fromEntries(DF_FLAGS
2580
+ .filter(key => typeof parsed[key] === 'boolean').map(key => [key, parsed[key]]));
2581
+ return Object.keys(values).length ? values : null;
2582
+ }
2583
+ catch {
2584
+ return null;
2585
+ }
2586
+ };
2587
+ const dfLegacy = dfReadLegacy();
2588
+ dfSettings = Object.freeze({ ...DF_DEFAULT_SETTINGS, ...dfLegacy });
2589
+ dfSnapshot = { ...dfSnapshot, values: dfSettings };
2590
+ const dfSubscribeSettings = (listener) => {
2591
+ dfSettingsListeners.add(listener);
2592
+ return () => dfSettingsListeners.delete(listener);
2593
+ };
2594
+ const dfGetSnapshot = () => dfSnapshot;
2595
+ const useDfSettings = () => React.useSyncExternalStore(dfSubscribeSettings, dfGetSnapshot, dfGetSnapshot);
2596
+ const dfModes = (light, dark) => ({ light, dark });
2597
+ const DF_CODE = {
2598
+ '--shiki-token-constant': dfModes('#2562A5', '#92BEF4'),
2599
+ '--shiki-token-string': dfModes('#326B55', '#A5CCB8'),
2600
+ '--shiki-token-comment': dfModes('#657287', '#8E9BAF'),
2601
+ '--shiki-token-keyword': dfModes('#765795', '#C0ACD8'),
2602
+ '--shiki-token-parameter': dfModes('#956032', '#D8B18A'),
2603
+ '--shiki-token-function': dfModes('#406A9D', '#A7C8F2'),
2604
+ '--shiki-token-string-expression': dfModes('#326B55', '#A5CCB8'),
2605
+ '--shiki-token-punctuation': dfModes('#546377', '#A6B2C4'),
2606
+ '--shiki-token-link': dfModes('#3269B7', '#8AB6FA'),
2607
+ };
2608
+ const DF_DIFF = {
2609
+ '--dsw-alias-file-diff-added-bg': dfModes('rgb(58 117 196 / 9%)', 'rgb(122 170 255 / 12%)'),
2610
+ '--dsw-alias-file-diff-added-gutter': dfModes('rgb(58 117 196 / 6%)', 'rgb(122 170 255 / 7%)'),
2611
+ '--dsw-alias-file-diff-added-marker': dfModes('#3269B7', '#8AB6FA'),
2612
+ '--dsw-alias-file-diff-deleted-bg': dfModes('rgb(164 97 83 / 9%)', 'rgb(213 156 139 / 10%)'),
2613
+ '--dsw-alias-file-diff-deleted-gutter': dfModes('rgb(164 97 83 / 6%)', 'rgb(213 156 139 / 6%)'),
2614
+ '--dsw-alias-file-diff-deleted-marker': dfModes('#995C50', '#D4A18F'),
2615
+ '--dsw-alias-code-diff-added': dfModes('rgb(58 117 196 / 10%)', 'rgb(122 170 255 / 13%)'),
2616
+ '--dsw-alias-code-diff-deleted': dfModes('rgb(164 97 83 / 10%)', 'rgb(213 156 139 / 11%)'),
2617
+ };
2618
+ const DF_CAT = {
2619
+ '--dsw-alias-bg-base': dfModes('#eff1f5', '#1e1e2e'),
2620
+ '--dsw-alias-bg-layer-1': dfModes('#e6e9ef', '#181825'),
2621
+ '--dsw-alias-bg-layer-2': dfModes('#dce0e8', '#11111b'),
2622
+ '--dsw-alias-bg-overlay': dfModes('#eff1f5', '#181825'),
2623
+ '--dsw-alias-border-l1': dfModes('#bcc0cc', '#313244'),
2624
+ '--dsw-alias-border-l2': dfModes('#acb0be', '#45475a'),
2625
+ '--dsw-alias-label-primary': dfModes('#4c4f69', '#cdd6f4'),
2626
+ '--dsw-alias-label-secondary': dfModes('#6c6f85', '#a6adc8'),
2627
+ '--dsw-specific-sidebar-fill': dfModes('#e6e9ef', '#181825'),
2628
+ '--dsw-alias-state-success-primary': dfModes('#40a02b', '#a6e3a1'),
2629
+ '--dsw-alias-state-warn-primary': dfModes('#df8e1d', '#f9e2af'),
2630
+ '--dsw-alias-state-error-primary': dfModes('#d20f39', '#f38ba8'),
2631
+ '--dsw-alias-state-idle-primary': dfModes('#8c8fa1', '#7f849c'),
2632
+ };
2633
+ function dfSyncTheme() {
2634
+ if (dfTheme === null)
2635
+ return;
2636
+ const ink = dfSettings.accentColor.toUpperCase();
2637
+ const layers = new Map();
2638
+ if (dfSettings.catppuccin)
2639
+ layers.set('palette', DF_CAT);
2640
+ const channels = [1, 3, 5].map(start => parseInt(ink.slice(start, start + 2), 16));
2641
+ const mixInk = (end, weight) => '#' + channels.map(channel => Math.round(channel * (1 - weight) + end * weight).toString(16).padStart(2, '0')).join('');
2642
+ const brightness = .2126 * channels[0] + .7152 * channels[1] + .0722 * channels[2];
2643
+ // Retain the selected hue and keep pale or very dark custom swatches visible on both surfaces.
2644
+ const lightInk = brightness > 165 ? mixInk(0, 1 - 138 / brightness) : ink;
2645
+ const darkInk = brightness < 165 ? mixInk(255, (165 - brightness) / (255 - brightness)) : ink;
2646
+ const focus = 'color-mix(in srgb, ' + ink + ' 22%, transparent)';
2647
+ layers.set('accent-' + ink.slice(1), {
2648
+ '--dsw-alias-brand-primary': dfModes(ink, ink),
2649
+ '--df-accent': dfModes(lightInk, darkInk),
2650
+ '--df-focus': dfModes(focus, focus),
2651
+ '--fish-second-ink': dfModes(darkInk, ink),
2652
+ });
2653
+ if (dfSettings.code)
2654
+ layers.set('code', DF_CODE);
2655
+ if (dfSettings.diff)
2656
+ layers.set('diff', DF_DIFF);
2657
+ for (const [name, dispose] of dfThemeLayers) {
2658
+ if (!layers.has(name)) {
2659
+ dispose();
2660
+ dfThemeLayers.delete(name);
2661
+ }
2662
+ }
2663
+ for (const [name, tokens] of layers) {
2664
+ if (!dfThemeLayers.has(name))
2665
+ dfThemeLayers.set(name, dfTheme.overrideTokens('dsh-fish-ui:' + name, tokens));
2666
+ }
2667
+ }
2668
+ function dfApplySettings() {
2669
+ if (!dfMounted)
2670
+ return;
2671
+ for (const [key, className] of Object.entries(DF_OFF_CLASS)) {
2672
+ document.documentElement.classList.toggle(className, dfSettings[key] === false);
2673
+ }
2674
+ document.documentElement.dataset.fishPace = dfSettings.sceneMotion;
2675
+ document.documentElement.dataset.fishIcons = dfSettings.iconStyle;
2676
+ dfSyncTheme();
2677
+ }
2678
+ function dfPublish(patch) {
2679
+ dfSnapshot = Object.freeze({ ...dfSnapshot, ...patch });
2680
+ dfSettings = dfSnapshot.values;
2681
+ dfApplySettings();
2682
+ dfSettingsListeners.forEach(listener => listener());
2683
+ }
2684
+ function dfConnectSettings(scope) {
2685
+ // This is the Host patch entry id; the bundle-config key below is the package name.
2686
+ const form = scope.configForms.get('dsh-fish-ui');
2687
+ let active = true;
2688
+ let migrating = false;
2689
+ let migrationTried = false;
2690
+ const adopt = () => {
2691
+ if (!active)
2692
+ return;
2693
+ const snapshot = form.getSnapshot();
2694
+ if (snapshot.status !== 'ready' || snapshot.value === undefined) {
2695
+ dfPublish({ status: snapshot.status, writable: false });
2696
+ return;
2697
+ }
2698
+ const ownsValues = Object.keys(DF_DEFAULT_SETTINGS).some(key => snapshot.user !== null && typeof snapshot.user === 'object' && Object.hasOwn(snapshot.user, key));
2699
+ const legacyKeys = dfLegacy === null ? []
2700
+ : Object.keys(dfLegacy).filter(key => Object.hasOwn(DF_DEFAULT_SETTINGS, key));
2701
+ if (!migrationTried && legacyKeys.length > 0 && !ownsValues && !snapshot.value.settingsMigrated && snapshot.writable) {
2702
+ migrationTried = true;
2703
+ migrating = true;
2704
+ dfPublish({ status: 'ready', writable: true, pending: true, error: '' });
2705
+ // Only carry keys the current schema still owns: a legacy blob may mention
2706
+ // preferences that were removed, and one unknown path rejects the whole write.
2707
+ const ops = Object.entries(dfLegacy)
2708
+ .filter(([key]) => Object.hasOwn(DF_DEFAULT_SETTINGS, key))
2709
+ .map(([key, value]) => ({ op: 'set', path: [key], value }));
2710
+ ops.push({ op: 'set', path: ['settingsMigrated'], value: true });
2711
+ // Fence the exact snapshot that established the namespace was empty.
2712
+ const migrate = async () => form.mutate(ops, snapshot.revision);
2713
+ migrate().then(ok => {
2714
+ if (!active)
2715
+ return;
2716
+ migrating = false;
2717
+ dfPublish({ pending: false, error: ok ? '' : 'conflict' });
2718
+ adopt();
2719
+ }, () => {
2720
+ if (!active)
2721
+ return;
2722
+ migrating = false;
2723
+ dfPublish({ pending: false, error: 'save' });
2724
+ adopt();
2725
+ });
2726
+ // Keep the legacy key read-only: other profiles may share this origin.
2727
+ return;
2728
+ }
2729
+ if (migrating)
2730
+ return;
2731
+ const values = Object.freeze(Object.fromEntries(Object.entries(DF_DEFAULT_SETTINGS)
2732
+ .map(([key, fallback]) => [key, validSetting(key, snapshot.value[key]) ? snapshot.value[key] : fallback])));
2733
+ dfPublish({ values, status: 'ready', writable: snapshot.writable });
2734
+ };
2735
+ const write = async (values) => {
2736
+ if (!active || dfSnapshot.pending || dfSnapshot.status !== 'ready' || !dfSnapshot.writable)
2737
+ return;
2738
+ dfPublish({ pending: true, error: '' });
2739
+ try {
2740
+ const ops = Object.entries(values).filter(([key, value]) => validSetting(key, value))
2741
+ .map(([key, value]) => ({ op: 'set', path: [key], value }));
2742
+ ops.push({ op: 'set', path: ['settingsMigrated'], value: true });
2743
+ const ok = await form.mutate(ops, form.getSnapshot().revision);
2744
+ if (active)
2745
+ dfPublish({ error: ok ? '' : 'conflict' });
2746
+ }
2747
+ catch {
2748
+ if (active)
2749
+ dfPublish({ error: 'save' });
2750
+ }
2751
+ finally {
2752
+ if (active) {
2753
+ dfPublish({ pending: false });
2754
+ adopt();
2755
+ }
2756
+ }
2757
+ };
2758
+ scope.effect(() => {
2759
+ dfWrite = write;
2760
+ dfSettingsOwner = write;
2761
+ const unsubscribe = form.subscribe(adopt);
2762
+ adopt();
2763
+ return () => {
2764
+ active = false;
2765
+ unsubscribe();
2766
+ if (dfWrite === write)
2767
+ dfWrite = null;
2768
+ if (dfSettingsOwner === write) {
2769
+ dfSettingsOwner = null;
2770
+ dfPublish({ status: 'unavailable', writable: false, pending: false });
2771
+ }
2772
+ };
2773
+ }, 'dsh-fish-ui: Host preferences');
2774
+ }
2775
+ const dfSetSetting = (key, value) => dfWrite?.({ [key]: value });
2776
+ class DfBoundary extends React.Component {
2777
+ state = { failed: false };
2778
+ static getDerivedStateFromError() { return { failed: true }; }
2779
+ componentDidCatch(error) { console.error('[dsh-fish-ui] enhancement failed', error); }
2780
+ render() { return this.state.failed ? (this.props.fallback ?? null) : this.props.children; }
2781
+ }
2782
+ const dfSafe = Component => function DeepFishSafeSlot(props) {
2783
+ return h(DfBoundary, { fallback: props.children }, h(Component, props));
2784
+ };
2785
+ /* fish runtime:end */
2786
+ /** Settings copy follows the app language (Chinese unless the UI is English). */
2787
+ const dfUsesChinese = () => {
2788
+ const lang = (document.documentElement.lang || navigator.language || '').toLowerCase();
2789
+ return lang.startsWith('zh');
2790
+ };
2791
+ const DF_COPY = {
2792
+ zh: {
2793
+ lead: '\u8fd9\u91cc\u7684\u5f00\u5173\u7acb\u5373\u751f\u6548\uff0c\u5e76\u6309\u914d\u7f6e\u6587\u4ef6\u8bb0\u4f4f\u3002',
2794
+ groups: {
2795
+ hero: '\u6b22\u8fce\u9875',
2796
+ thinking: '\u601d\u8003\u4e2d',
2797
+ composer: '\u8f93\u5165\u6846',
2798
+ accents: '\u5f3a\u8c03\u8272',
2799
+ sidebar: '侧边栏',
2800
+ },
2801
+ items: {
2802
+ hero: ['\u70b9\u9635\u4eba\u50cf\u4e0e\u5b57\u6807', '\u7a7a\u767d\u6b22\u8fce\u9875\u4e0a\u7684\u7acb\u7ed8\u548c\u5b57\u6807'],
2803
+ field: ['\u80cc\u666f\u70b9\u9635', '\u94fa\u6ee1\u6574\u9875\u7684\u6de1\u70b9\u9635'],
2804
+ wave: ['\u5e95\u90e8\u6ce2\u6d6a', '\u9875\u9762\u5e95\u90e8\u7f13\u6162\u6d41\u52a8\u7684\u660e\u6697\u6ce2'],
2805
+ ripple: ['\u6307\u9488\u6d9f\u6f2a', '\u9f20\u6807\u5212\u8fc7\u70b9\u9635\u65f6\u8361\u5f00\u7684\u5149\u73af'],
2806
+ thinkingSphere: ['\u70b9\u9635\u7403', '\u601d\u8003\u65f6\u65cb\u8f6c\u7684\u5c0f\u7403'],
2807
+ thinkingLabel: ['英文思考文案', '把状态行换成 “Deep thinking for 12s. . .”'],
2808
+ glass: ['\u78e8\u7802\u73bb\u7483', '\u4f1a\u8bdd\u9875\u8f93\u5165\u6846\u7684\u534a\u900f\u660e\u6548\u679c'],
2809
+ stats: ['\u7528\u91cf\u8bfb\u6570', '\u5728\u53d1\u9001\u6309\u94ae\u6392\u663e\u793a\u4e0a\u4e0b\u6587\u4e0e Token \u7528\u91cf'],
2810
+ bold: ['\u9cb8\u9c7c\u84dd\u52a0\u7c97', '\u804a\u5929\u91cc\u7684\u52a0\u7c97\u6587\u5b57\u53d8\u6210\u9cb8\u9c7c\u84dd'],
2811
+ focusRing: ['\u805a\u7126\u63cf\u8fb9', '\u8f93\u5165\u6846\u805a\u7126\u65f6\u7684\u67d4\u5149\u63cf\u8fb9'],
2812
+ diff: ['diff \u6362\u84dd', '\u65b0\u589e / \u5220\u9664\u884c\u6539\u6210\u84dd\u8272\u65cf'],
2813
+ },
2814
+ reset: '\u6062\u590d\u9ed8\u8ba4',
2815
+ close: '\u5173\u95ed',
2816
+ dialog: 'Deep Fish UI \u8bbe\u7f6e',
2817
+ button: 'Deep Fish UI \u8bbe\u7f6e',
2818
+ },
2819
+ en: {
2820
+ lead: 'Everything here applies immediately and is remembered per profile.',
2821
+ groups: { hero: 'Welcome page', thinking: 'Thinking', composer: 'Composer', accents: 'Accents', sidebar: 'Sidebar' },
2822
+ items: {
2823
+ hero: ['Dot artwork', 'The portrait and the wordmark on the blank home'],
2824
+ field: ['Dot field', 'The faint lattice behind everything'],
2825
+ wave: ['Bottom wave', 'The slow brightness wave along the bottom edge'],
2826
+ ripple: ['Pointer ripples', 'Light rings where the pointer crosses the field'],
2827
+ thinkingSphere: ['Dot sphere', 'The rotating point-sphere beside the live status'],
2828
+ thinkingLabel: ['English status label', 'Replace the status row with “Deep thinking for 12s. . .”'],
2829
+ glass: ['Frosted glass', 'Translucent input card on session pages'],
2830
+ bold: ['Whale-blue bold', 'Bold runs in chat prose take the accent colour'],
2831
+ focusRing: ['Focus ring', 'The soft ring while the composer has focus'],
2832
+ diff: ['Re-inked diffs', 'Added and removed lines in the blue family'],
2833
+ },
2834
+ reset: 'Reset to defaults',
2835
+ close: 'Close',
2836
+ dialog: 'Deep Fish UI settings',
2837
+ button: 'Deep Fish UI settings',
2838
+ },
2839
+ };
2840
+ Object.assign(DF_COPY.zh.items, {
2841
+ reading: ['阅读排版', '舒展段落、标题与引用,保留你的字号'],
2842
+ code: ['代码配色', '低饱和语法颜色,保持代码层次'],
2843
+ effortBadge: ['推理等级动画', '输入框里用点阵显示当前推理等级'],
2844
+ sidebarDots: ['悬停点阵', '鼠标悬停在侧边栏按钮上时亮起点阵'],
2845
+ sidebarRail: ['蓝色竖线', '在悬停按钮左侧显示鲸鱼蓝竖线'],
2846
+ thinkingLabel: ['英文思考文案', '把状态行换成 “Deep thinking for 12s. . .”'],
2847
+ diff: ['差异配色', '新增用蓝色,删除用暖色,保留语法高亮'],
2848
+ });
2849
+ Object.assign(DF_COPY.en.items, {
2850
+ reading: ['Reading layout', 'Clear paragraphs, headings and quotes at your chosen font size'],
2851
+ code: ['Code palette', 'Muted, distinct syntax colours'],
2852
+ effortBadge: ['Effort badge', 'Print the reasoning level in dots inside the composer'],
2853
+ sidebarDots: ['Hover dot field', 'Light the dot field around the pointer on sidebar buttons'],
2854
+ sidebarRail: ['Blue rail', 'Show a whale-blue rail on the left of the hovered button'],
2855
+ thinkingLabel: ['English status label', 'Replace the status row with “Deep thinking for 12s. . .”'],
2856
+ diff: ['Diff palette', 'Blue additions and warm deletions, with syntax highlighting intact'],
2857
+ });
2858
+ Object.assign(DF_COPY.zh.items, {
2859
+ fishFont: ['Maple Mono 字体', '全站换成 Maple Mono NF CN,正文与代码统一字体'],
2860
+ fishGlow: ['输入框柔光', '16px 圆角,聚焦时带主题色光晕'],
2861
+ fishMotion: ['轻动效', '按钮悬停上浮,界面过渡更柔和'],
2862
+ fishCode: ['代码块质感', '圆角描边与行内代码小药丸'],
2863
+ });
2864
+ Object.assign(DF_COPY.en.items, {
2865
+ fishFont: ['Maple Mono type', 'Use Maple Mono NF CN everywhere, including code'],
2866
+ fishGlow: ['Composer glow', '16px radius plus an accent glow on focus'],
2867
+ fishMotion: ['Soft motion', 'Buttons lift on hover and surfaces ease between states'],
2868
+ fishCode: ['Code surface', 'Rounded code blocks and tinted inline-code pills'],
2869
+ });
2870
+ Object.assign(DF_COPY.zh.items, {
2871
+ catppuccin: ['Catppuccin 配色', 'Latte / Mocha 全套背景、文字、边框与强调色'],
2872
+ aurora: ['会话背景', '在欢迎页和聊天记录后面显示所选场景'],
2873
+ cursor: ['指针物理', '跟随指针的柔光、输入框微倾斜'],
2874
+ textMotion: ['思考与文字动效', '回复浮入、思考块微光、流式文字呼吸感'],
2875
+ hostIcons: ['导航与操作图标', '新会话、搜索、文件夹、复制和发送等按钮使用所选图标风格'],
2876
+ });
2877
+ Object.assign(DF_COPY.en.items, {
2878
+ catppuccin: ['Catppuccin palette', 'Latte / Mocha backgrounds, text, borders and accents'],
2879
+ aurora: ['Conversation backdrop', 'Show the selected scene on the welcome page and behind messages'],
2880
+ cursor: ['Pointer physics', 'A cursor-following glow and a subtle composer tilt'],
2881
+ textMotion: ['Thinking & text motion', 'Replies rise in, reasoning shimmers, streaming text breathes'],
2882
+ hostIcons: ['Navigation & action icons', 'Use the chosen icon style for new chats, search, folders, copy, send and related controls'],
2883
+ });
2884
+ /** Switch drawn as SVG so the capsule ends and the knob are exact shapes. */
2885
+ function DfSwitchSvg({ value }) {
2886
+ const on = value === true;
2887
+ return h('svg', {
2888
+ width: 42,
2889
+ height: 24,
2890
+ viewBox: '0 0 42 24',
2891
+ 'aria-hidden': 'true',
2892
+ style: { display: 'block', overflow: 'visible' },
2893
+ }, [
2894
+ h('rect', {
2895
+ key: 'track',
2896
+ x: 0.5,
2897
+ y: 0.5,
2898
+ width: 41,
2899
+ height: 23,
2900
+ rx: 11.5,
2901
+ ry: 11.5,
2902
+ style: {
2903
+ fill: on
2904
+ ? 'color-mix(in srgb, var(--dsw-alias-label-primary) 94%, transparent)'
2905
+ : 'color-mix(in srgb, var(--dsw-alias-label-tertiary) 44%, transparent)',
2906
+ // Only the enabled state carries an outline; keep the SVG geometry fixed.
2907
+ stroke: on
2908
+ ? 'color-mix(in srgb, var(--dsw-alias-label-primary) 94%, transparent)'
2909
+ : 'none',
2910
+ strokeWidth: 1,
2911
+ transition: 'fill 200ms cubic-bezier(0.22, 1, 0.36, 1), stroke 200ms cubic-bezier(0.22, 1, 0.36, 1)',
2912
+ },
2913
+ }),
2914
+ h('g', {
2915
+ key: 'knob',
2916
+ style: {
2917
+ transform: on ? 'translateX(18px)' : 'translateX(0px)',
2918
+ transition: 'transform 220ms cubic-bezier(0.22, 1, 0.36, 1)',
2919
+ },
2920
+ }, h('circle', {
2921
+ cx: 12,
2922
+ cy: 12,
2923
+ r: 9,
2924
+ style: {
2925
+ fill: on ? 'var(--dsw-alias-bg-base, #17171a)' : 'color-mix(in srgb, var(--dsw-alias-label-primary) 82%, transparent)',
2926
+ transition: 'fill 200ms cubic-bezier(0.22, 1, 0.36, 1)',
2927
+ },
2928
+ })),
2929
+ ]);
2930
+ }
2931
+ /** One settings row: a label on the left and a switch on the right. */
2932
+ function DfSwitch({ icon, label, description, value, disabled, onChange }) {
2933
+ return h('div', { className: 'df-set-row' }, [
2934
+ h('span', { key: 'icon', className: 'fish-row-icon' }, h(FishIcon, { name: icon })),
2935
+ h('div', { key: 'text', className: 'df-set-text' }, [
2936
+ h('span', { key: 'label', className: 'df-set-label' }, label),
2937
+ description === undefined
2938
+ ? null
2939
+ : h('span', { key: 'desc', className: 'df-set-desc' }, description),
2940
+ ]),
2941
+ h('button', {
2942
+ key: 'switch',
2943
+ type: 'button',
2944
+ role: 'switch',
2945
+ disabled,
2946
+ 'aria-checked': value ? 'true' : 'false',
2947
+ 'aria-label': label,
2948
+ className: 'df-switch',
2949
+ 'data-on': value ? 'true' : undefined,
2950
+ onClick: () => onChange(!value),
2951
+ }, h(DfSwitchSvg, { key: 'glyph', value: value === true })),
2952
+ ]);
2953
+ }
2954
+ const FISH_CSS = `
2955
+ :root {
2956
+ --fish-font: "Maple Mono NF CN", "Maple Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
2957
+ --fish-ink: var(--df-accent, #4D6BFE);
2958
+ }
2959
+ :root:not(.df-off-fishfont) body {
2960
+ font-family: var(--fish-font) !important;
2961
+ font-feature-settings: "ss01" 1, "cv01" 1, "liga" 1;
2962
+ -webkit-font-smoothing: antialiased;
2963
+ text-rendering: optimizeLegibility;
2964
+ }
2965
+ :root:not(.df-off-fishfont) button,
2966
+ :root:not(.df-off-fishfont) input,
2967
+ :root:not(.df-off-fishfont) textarea,
2968
+ :root:not(.df-off-fishfont) select,
2969
+ :root:not(.df-off-fishfont) [contenteditable="true"] {
2970
+ font-family: inherit !important;
2971
+ }
2972
+ :root:not(.df-off-fishfont) code,
2973
+ :root:not(.df-off-fishfont) pre,
2974
+ :root:not(.df-off-fishfont) kbd,
2975
+ :root:not(.df-off-fishfont) samp {
2976
+ font-family: var(--fish-font) !important;
2977
+ }
2978
+ :root:not(.df-off-fishfont) p,
2979
+ :root:not(.df-off-fishfont) li,
2980
+ :root:not(.df-off-fishfont) blockquote {
2981
+ line-height: 1.75;
2982
+ }
2983
+ :root:not(.df-off-fishglow) [data-composer-card] {
2984
+ border-radius: 16px !important;
2985
+ transition: box-shadow .25s ease, border-color .25s ease;
2986
+ }
2987
+ :root:not(.df-off-fishglow) [data-composer-card]:focus-within {
2988
+ box-shadow: 0 0 0 1px var(--fish-ink),
2989
+ 0 18px 50px -28px var(--fish-ink) !important;
2990
+ }
2991
+ :root:not(.df-off-fishcode) pre {
2992
+ border-radius: 12px;
2993
+ border: 1px solid color-mix(in srgb, var(--dsw-alias-border-l1, #333) 70%, transparent);
2994
+ }
2995
+ :root:not(.df-off-fishcode) :not(pre) > code {
2996
+ background: color-mix(in srgb, var(--dsw-alias-bg-layer-2, #222) 78%, transparent);
2997
+ padding: .12em .38em;
2998
+ border-radius: 5px;
2999
+ }
3000
+ :root:not(.df-off-fishmotion) button {
3001
+ transition: transform .16s ease, box-shadow .16s ease;
3002
+ }
3003
+ :root:not(.df-off-fishmotion) button:hover {
3004
+ transform: translateY(-1px);
3005
+ }
3006
+ ::selection {
3007
+ background: color-mix(in srgb, var(--fish-ink) 32%, transparent);
3008
+ }
3009
+ ::-webkit-scrollbar {
3010
+ width: 9px;
3011
+ height: 9px;
3012
+ }
3013
+ ::-webkit-scrollbar-thumb {
3014
+ background: color-mix(in srgb, var(--dsw-alias-border-l2, #555) 60%, transparent);
3015
+ border-radius: 999px;
3016
+ }
3017
+ ::-webkit-scrollbar-thumb:hover {
3018
+ background: var(--fish-ink);
3019
+ }
3020
+ @media (prefers-reduced-motion: reduce) {
3021
+ * { animation: none !important; transition: none !important; }
3022
+ }
3023
+ `;
3024
+ const FISH_FX_CSS = `
3025
+ body { --fish-ink: var(--df-accent, #4D6BFE); }
3026
+ .fish-cursor-glow {
3027
+ position: fixed;
3028
+ left: 0;
3029
+ top: 0;
3030
+ width: 360px;
3031
+ height: 360px;
3032
+ margin: -180px 0 0 -180px;
3033
+ border-radius: 50%;
3034
+ pointer-events: none;
3035
+ z-index: 1;
3036
+ opacity: 0;
3037
+ transition: opacity .35s ease;
3038
+ background: radial-gradient(circle, color-mix(in srgb, var(--df-accent, #4D6BFE) 18%, transparent), transparent 66%);
3039
+ will-change: transform;
3040
+ }
3041
+ .fish-cursor-glow[data-active] { opacity: .55; }
3042
+ :root:not(.df-off-cursor) [data-composer-card] {
3043
+ transition: transform .2s ease, box-shadow .25s ease;
3044
+ }
3045
+ [data-composer-card].fish-tilting {
3046
+ transform: perspective(900px) rotateX(var(--fish-tilt-x)) rotateY(var(--fish-tilt-y));
3047
+ }
3048
+ :root:not(.df-off-textmotion) [data-chat-flow-kind="assistant-step"] {
3049
+ animation: fish-rise .4s cubic-bezier(.16,1,.3,1) both;
3050
+ }
3051
+ @keyframes fish-rise {
3052
+ from { opacity: 0; transform: translateY(7px); }
3053
+ to { opacity: 1; transform: none; }
3054
+ }
3055
+ :root:not(.df-off-textmotion) [data-chat-group-part="reasoning"] {
3056
+ border-left: 2px solid color-mix(in srgb, var(--df-accent, #4D6BFE) 45%, transparent);
3057
+ padding-left: 10px;
3058
+ animation: fish-breathe 4.5s ease-in-out infinite;
3059
+ }
3060
+ @keyframes fish-breathe {
3061
+ 0%, 100% { opacity: .72; }
3062
+ 50% { opacity: 1; }
3063
+ }
3064
+ @media (prefers-reduced-motion: reduce) {
3065
+ .fish-cursor-glow { display: none; }
3066
+ :root body { animation: none !important; }
3067
+ }
3068
+ `;
3069
+ const FISH_STUDIO_CSS = `
3070
+ .fish-backdrop {
3071
+ position: absolute;
3072
+ inset: 0;
3073
+ overflow: hidden;
3074
+ pointer-events: none;
3075
+ user-select: none;
3076
+ opacity: .18;
3077
+ mask-image: linear-gradient(90deg, #000, rgb(0 0 0 / .38) 28% 72%, #000);
3078
+ }
3079
+ .fish-backdrop[data-home="true"] {
3080
+ z-index: -2;
3081
+ opacity: .43;
3082
+ mask-image: radial-gradient(ellipse at 45% 46%, rgb(0 0 0 / .27) 12%, rgb(0 0 0 / .6) 58%, #000 96%);
3083
+ }
3084
+ body[data-ds-dark-theme] .fish-backdrop { opacity: .34; }
3085
+ body[data-ds-dark-theme] .fish-backdrop[data-home="true"] { opacity: .82; }
3086
+ [data-conversation-content]:has(.fish-backdrop[data-home="false"]) [data-conversation-scroll] {
3087
+ position: relative;
3088
+ }
3089
+ .fish-backdrop > svg, .fish-cover > svg, .fish-card-art > svg {
3090
+ display: block;
3091
+ width: 100%;
3092
+ height: 100%;
3093
+ }
3094
+ .fish-backdrop { --fish-cycle: 34s; --fish-shower: 5s; }
3095
+ html[data-fish-pace="flow"] .fish-backdrop { --fish-cycle: 14s; --fish-shower: 1.8s; }
3096
+ @media (prefers-reduced-motion: no-preference) {
3097
+ html:not([data-fish-pace="still"]) .fish-backdrop .fish-current { animation: fish-current var(--fish-cycle) ease-in-out infinite alternate; }
3098
+ html:not([data-fish-pace="still"]) .fish-backdrop .fish-curtain { animation: fish-curtain var(--fish-cycle) ease-in-out infinite alternate; }
3099
+ html:not([data-fish-pace="still"]) .fish-backdrop .fish-revolve { animation: fish-revolve calc(var(--fish-cycle) * 1.4) linear infinite; }
3100
+ html:not([data-fish-pace="still"]) .fish-backdrop .fish-sand { animation: fish-sand var(--fish-cycle) ease-in-out infinite alternate; }
3101
+ html:not([data-fish-pace="still"]) .fish-backdrop .fish-rainfall { animation: fish-rainfall var(--fish-shower) linear infinite; }
3102
+ html:not([data-fish-pace="still"]) .fish-backdrop .fish-pond-ring { animation: fish-pond-ring calc(var(--fish-cycle) * .42) ease-out infinite; }
3103
+ html[data-fish-paused] .fish-backdrop g { animation-play-state: paused !important; }
3104
+ }
3105
+ @keyframes fish-current { from { transform: translate(-5px, -2px); } to { transform: translate(7px, 3px); } }
3106
+ @keyframes fish-curtain { from { transform: translate(-4px, 2px) skewX(-3deg); opacity: .76; } to { transform: translate(7px, -6px) skewX(5deg); opacity: 1; } }
3107
+ @keyframes fish-revolve { to { transform: rotate(360deg); } }
3108
+ @keyframes fish-sand { from { transform: translate(-7px, 2px); } to { transform: translate(7px, -2px); } }
3109
+ @keyframes fish-rainfall { 0% { transform: translate(5px,-14px); opacity: 0; } 18%, 78% { opacity: .7; } 100% { transform: translate(-6px,17px); opacity: 0; } }
3110
+ @keyframes fish-pond-ring { 0% { transform: scale(.76); opacity: 0; } 24% { opacity: .9; } 100% { transform: scale(1.13); opacity: 0; } }
3111
+
3112
+ .fish-studio, .df-sheet-panel {
3113
+ --fish-panel: var(--dsw-alias-bg-base, #f5f7f5);
3114
+ --fish-label: var(--dsw-alias-label-primary, #293936);
3115
+ --fish-muted: var(--dsw-alias-label-secondary, #53645f);
3116
+ --fish-edge: color-mix(in srgb, var(--fish-label) 17%, transparent);
3117
+ --fish-well: color-mix(in srgb, var(--fish-label) 5%, var(--fish-panel));
3118
+ --fish-selected: color-mix(in srgb, var(--df-accent, #4D6BFE) 12%, var(--fish-panel));
3119
+ }
3120
+ .df-sheet-panel {
3121
+ width: min(526px, calc(100vw - 28px));
3122
+ max-height: min(88dvh, 808px);
3123
+ bottom: max(14px, min(7vh, 64px));
3124
+ background: var(--fish-panel);
3125
+ border: 1px solid var(--fish-edge);
3126
+ box-shadow: 0 22px 64px rgb(15 30 40 / .27), 0 3px 14px rgb(15 30 40 / .13);
3127
+ box-sizing: border-box;
3128
+ }
3129
+ .df-sheet-head { flex: none; padding: 12px 17px; }
3130
+ .df-sheet-title { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; letter-spacing: -.02em; }
3131
+ .fish-brand {
3132
+ flex: none;
3133
+ width: 27px;
3134
+ height: 27px;
3135
+ display: inline-grid;
3136
+ place-items: center;
3137
+ border-radius: 9px;
3138
+ background: linear-gradient(145deg, #718DFF, #4D6BFE 48%, #243EAA);
3139
+ box-shadow: inset 0 0 0 1px rgb(191 212 255 / .42);
3140
+ }
3141
+ .fish-logo { display: block; width: 100%; height: 100%; }
3142
+ .df-foot-button { gap: 8px; }
3143
+ .df-foot-button .fish-brand { width: 22px; height: 22px; border-radius: 7px; }
3144
+ .fish-foot-scene { display: inline-flex; margin-inline-start: auto; color: var(--df-accent); }
3145
+ .df-sheet-close {
3146
+ display: inline-grid; place-items: center; width: 28px; height: 28px;
3147
+ border: 1px solid var(--fish-edge); border-radius: 50%; color: var(--fish-muted);
3148
+ }
3149
+ .df-sheet-body { padding: 0; overscroll-behavior: contain; min-height: 0; }
3150
+ .fish-studio {
3151
+ box-sizing: border-box; max-width: 740px; width: 100%; min-width: 0; margin: 0;
3152
+ padding: 14px 16px 12px; color: var(--fish-label); container-type: inline-size;
3153
+ }
3154
+ .fish-studio *, .fish-studio *::before, .fish-studio *::after { box-sizing: border-box; }
3155
+ .fish-studio fieldset { min-inline-size: 0; border: 0; padding: 0; margin: 0; }
3156
+ .fish-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
3157
+ .fish-icon { display: inline-block; flex: none; vertical-align: middle; }
3158
+ .fish-icon-tone { fill: color-mix(in srgb, var(--fish-second-ink, #78bea9) 66%, currentColor); opacity: .52; }
3159
+ html[data-fish-icons="line"] .fish-icon-tone { display: none; }
3160
+ .fish-cover {
3161
+ position: relative; isolation: isolate; overflow: hidden; height: clamp(104px, 24cqi, 154px);
3162
+ border-radius: 13px; color: #fff; background: #133b43;
3163
+ }
3164
+ .fish-cover > svg { position: absolute; inset: 0; }
3165
+ .fish-cover::after {
3166
+ position: absolute; content: ""; inset: 0; pointer-events: none;
3167
+ background: linear-gradient(90deg, rgb(7 19 28 / .79), rgb(7 19 28 / .43) 43%, transparent 77%);
3168
+ }
3169
+ .fish-cover-copy { position: absolute; z-index: 1; inset-inline: 17px; bottom: 13px; }
3170
+ .fish-cover-kicker {
3171
+ display: block; margin: 0 0 4px; font: 600 9px/1.2 var(--fish-font, monospace);
3172
+ letter-spacing: .16em; text-transform: uppercase; color: #e3eceb;
3173
+ }
3174
+ .fish-cover h2 {
3175
+ margin: 0; color: #fffaf1; font: 500 clamp(23px, 5.8cqi, 36px)/1.13 "Baskervville", "Songti SC", Georgia, serif;
3176
+ letter-spacing: -.02em;
3177
+ }
3178
+ .fish-cover p { margin: 5px 0 0; font-size: 11px; color: #edf1ef; }
3179
+ .fish-swatches { position: absolute; z-index: 1; right: 12px; bottom: 12px; display: flex; border: 1px solid rgb(255 255 255 / .5); border-radius: 3px; overflow: hidden; }
3180
+ .fish-swatches i { width: 10px; height: 7px; }
3181
+ .fish-tabs { display: flex; gap: 16px; margin: 10px 0 13px; border-bottom: 1px solid var(--fish-edge); }
3182
+ .fish-tabs button {
3183
+ position: relative; display: inline-flex; align-items: center; gap: 6px;
3184
+ min-height: 34px; padding: 3px 3px 7px; background: none; border: 0; color: var(--fish-muted);
3185
+ font: inherit; font-size: 12px; cursor: pointer;
3186
+ }
3187
+ .fish-tabs button[aria-pressed="true"] { font-weight: 650; color: var(--df-accent); }
3188
+ .fish-tabs button[aria-pressed="true"]::after { position: absolute; content: ""; inset: auto 1px -1px; height: 2px; border-radius: 2px; background: currentColor; }
3189
+ .fish-scene-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
3190
+ .fish-scene-card {
3191
+ position: relative; min-width: 0; display: flex; flex-direction: column; padding: 3px; overflow: hidden;
3192
+ border-radius: 10px; border: 1px solid var(--fish-edge); background: var(--fish-panel); cursor: pointer;
3193
+ }
3194
+ .fish-card-art { position: relative; display: block; overflow: hidden; aspect-ratio: 2.46; border-radius: 6px; }
3195
+ .fish-card-label {
3196
+ display: flex; align-items: center; gap: 6px; min-height: 29px; padding: 4px 4px 1px;
3197
+ color: var(--fish-label); font-size: 11px; font-weight: 600; line-height: 1.25;
3198
+ }
3199
+ .fish-card-label svg { color: var(--fish-muted); }
3200
+ .fish-picked {
3201
+ position: absolute; display: grid; place-items: center; right: 5px; top: 5px; width: 18px; height: 18px;
3202
+ border: 1px solid rgb(0 0 0 / .2); border-radius: 50%; background: #f8fff9; color: #17453e;
3203
+ }
3204
+ .fish-scene-card:has(input:checked) { background: var(--fish-selected); border-color: var(--df-accent); box-shadow: inset 0 0 0 .5px var(--df-accent); }
3205
+ .fish-scene-card:has(input:checked) .fish-card-label svg { color: var(--df-accent); }
3206
+ .fish-studio :is(button, .fish-segment, .fish-scene-card):focus-visible,
3207
+ .fish-studio label:has(input:focus-visible), .df-sheet-close:focus-visible {
3208
+ outline: 2px solid var(--df-accent, #4D6BFE); outline-offset: 2px;
3209
+ }
3210
+ @media (hover: hover) {
3211
+ .fish-scene-card:not(:has(:disabled)):hover { border-color: var(--df-accent); }
3212
+ .fish-segment:hover, .fish-tabs button:hover { color: var(--fish-label); }
3213
+ }
3214
+ .fish-controls {
3215
+ margin-top: 12px; padding: 0 11px; border: 1px solid var(--fish-edge); border-radius: 11px;
3216
+ background: color-mix(in srgb, var(--fish-well) 35%, var(--fish-panel));
3217
+ }
3218
+ .fish-controls > :is(fieldset,.df-set-row) + :is(fieldset,.df-set-row) { border-top: 1px solid var(--fish-edge); }
3219
+ .fish-inks { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
3220
+ .fish-ink-option {
3221
+ position: relative; display: grid; place-items: center; width: 24px; height: 26px; cursor: pointer;
3222
+ }
3223
+ .fish-ink-option::before {
3224
+ content: ''; width: 16px; height: 16px; border-radius: 50%; background: var(--fish-swatch);
3225
+ }
3226
+ .fish-ink-option:has(input:checked)::before { outline: 1.5px solid var(--fish-swatch); outline-offset: 2px; }
3227
+ .fish-custom-color { position: relative; cursor: pointer; font-size: 11px; color: var(--fish-label);
3228
+ padding: 3px 6px; border: 1px solid var(--fish-edge); border-radius: 5px; }
3229
+ .fish-custom-color input { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; opacity: 0; }
3230
+ .fish-controls .df-set-row, .fish-controls-row { min-height: 40px; padding: 5px 0; }
3231
+ .fish-controls .df-set-row { gap: 8px; }
3232
+ .fish-controls .df-set-desc { display: none; }
3233
+ .fish-controls-row, .fish-control-label, .fish-segment, .df-set-reset, .fish-row-icon { display: inline-flex; align-items: center; }
3234
+ .fish-controls-row { display: flex; justify-content: space-between; gap: 6px; }
3235
+ .fish-control-label, .fish-controls .df-set-label { font-size: 12px; font-weight: 550; }
3236
+ .fish-control-label { gap: 8px; }
3237
+ .fish-control-label > svg, .fish-row-icon { color: var(--df-accent); }
3238
+ .fish-segment-track { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; background: var(--fish-well); border-radius: 7px; }
3239
+ .fish-segment {
3240
+ position: relative; justify-content: center; gap: 4px; padding: 4px 7px; min-height: 24px; border: 1px solid transparent;
3241
+ border-radius: 5px; color: var(--fish-muted); cursor: pointer; font-size: 11px; line-height: 1.15;
3242
+ }
3243
+ .fish-segment:has(input:checked) { border-color: var(--fish-edge); background: var(--fish-panel); color: var(--df-accent); font-weight: 650; }
3244
+ .fish-studio fieldset:disabled .fish-segment, .fish-studio fieldset:disabled .fish-scene-card { cursor: default; opacity: .65; }
3245
+ .fish-details .df-set-group { margin: 0 0 14px; padding: 0 0 7px; }
3246
+ .fish-details .df-set-group-title { margin: 12px 0 3px; color: var(--df-accent); font-weight: 650; }
3247
+ .fish-details .df-set-row { gap: 10px; padding: 7px 0; }
3248
+ .fish-details .fish-row-icon { justify-content: center; width: 29px; height: 29px; border-radius: 8px; background: var(--fish-selected); }
3249
+ .fish-studio .df-set-label { color: var(--fish-label); }
3250
+ .fish-studio .df-set-desc, .fish-studio .df-set-note { color: var(--fish-muted); }
3251
+ .fish-studio .df-switch svg { width: 34px; height: 20px; }
3252
+ .fish-studio .df-switch[data-on="true"] rect { fill: var(--df-accent) !important; stroke: var(--df-accent) !important; }
3253
+ .fish-studio .df-set-footer { padding-top: 11px; gap: 8px; }
3254
+ .fish-studio .df-set-reset { gap: 5px; padding: 4px 0; font-size: 11px; border: 0; background: transparent; color: var(--fish-muted); }
3255
+ .fish-studio .df-set-note { font-size: 10px; }
3256
+ .fish-studio .df-settings-status { margin: 0 0 9px; }
3257
+ @container (max-width: 390px) {
3258
+ .fish-scene-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
3259
+ .fish-card-art { aspect-ratio: 2.7; }
3260
+ .fish-control-label { gap: 5px; }
3261
+ .fish-segment { padding-inline: 5px; }
3262
+ }
3263
+ @container (max-width: 300px) {
3264
+ .fish-controls-row { flex-wrap: wrap; padding-block: 7px; }
3265
+ .fish-swatches, .fish-segment svg { display: none; }
3266
+ }
3267
+ @media (max-height: 540px) {
3268
+ .df-sheet-panel { bottom: 8px; max-height: calc(100dvh - 16px); }
3269
+ }
3270
+ `;
3271
+ function attachPointerPhysics() {
3272
+ const media = window.matchMedia('(hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference)');
3273
+ let glow = null;
3274
+ let card = null;
3275
+ let frame = 0;
3276
+ let x = 0, y = 0, targetX = 0, targetY = 0;
3277
+ const clearCard = () => {
3278
+ if (!card)
3279
+ return;
3280
+ card.classList.remove('fish-tilting');
3281
+ card.style.removeProperty('--fish-tilt-x');
3282
+ card.style.removeProperty('--fish-tilt-y');
3283
+ card = null;
3284
+ };
3285
+ const paint = () => {
3286
+ x += (targetX - x) * .22;
3287
+ y += (targetY - y) * .22;
3288
+ glow.style.transform = 'translate3d(' + x.toFixed(1) + 'px,' + y.toFixed(1) + 'px,0)';
3289
+ frame = Math.abs(targetX - x) + Math.abs(targetY - y) > .6 ? requestAnimationFrame(paint) : 0;
3290
+ };
3291
+ const move = (event) => {
3292
+ if (event.pointerType === 'touch')
3293
+ return;
3294
+ targetX = event.clientX;
3295
+ targetY = event.clientY;
3296
+ if (!glow.hasAttribute('data-active')) {
3297
+ x = targetX;
3298
+ y = targetY;
3299
+ glow.setAttribute('data-active', '');
3300
+ }
3301
+ if (!frame)
3302
+ frame = requestAnimationFrame(paint);
3303
+ const next = event.target instanceof Element ? event.target.closest('[data-composer-card]') : null;
3304
+ if (next !== card) {
3305
+ clearCard();
3306
+ card = next;
3307
+ }
3308
+ if (!card)
3309
+ return;
3310
+ const rect = card.getBoundingClientRect();
3311
+ if (!rect.width || !rect.height)
3312
+ return;
3313
+ card.style.setProperty('--fish-tilt-x', ((.5 - (targetY - rect.top) / rect.height) * 1.6).toFixed(2) + 'deg');
3314
+ card.style.setProperty('--fish-tilt-y', (((targetX - rect.left) / rect.width - .5) * 1.6).toFixed(2) + 'deg');
3315
+ card.classList.add('fish-tilting');
3316
+ };
3317
+ const leave = () => {
3318
+ cancelAnimationFrame(frame);
3319
+ frame = 0;
3320
+ glow?.removeAttribute('data-active');
3321
+ clearCard();
3322
+ };
3323
+ const stop = () => {
3324
+ leave();
3325
+ window.removeEventListener('pointermove', move);
3326
+ document.documentElement.removeEventListener('pointerleave', leave);
3327
+ window.removeEventListener('blur', leave);
3328
+ glow?.remove();
3329
+ glow = null;
3330
+ };
3331
+ const sync = () => {
3332
+ const enabled = dfSettings.cursor && media.matches && !document.hidden;
3333
+ if (enabled === Boolean(glow))
3334
+ return;
3335
+ if (!enabled) {
3336
+ stop();
3337
+ return;
3338
+ }
3339
+ glow = document.createElement('div');
3340
+ glow.className = 'fish-cursor-glow';
3341
+ glow.setAttribute('aria-hidden', 'true');
3342
+ document.body.append(glow);
3343
+ window.addEventListener('pointermove', move, { passive: true });
3344
+ document.documentElement.addEventListener('pointerleave', leave);
3345
+ window.addEventListener('blur', leave);
3346
+ };
3347
+ const unsubscribe = dfSubscribeSettings(sync);
3348
+ media.addEventListener('change', sync);
3349
+ document.addEventListener('visibilitychange', sync);
3350
+ sync();
3351
+ return () => {
3352
+ unsubscribe();
3353
+ media.removeEventListener('change', sync);
3354
+ document.removeEventListener('visibilitychange', sync);
3355
+ stop();
3356
+ };
3357
+ }
3358
+ function FishScenePicker({ state, disabled, zh }) {
3359
+ const group = React.useId();
3360
+ return h('fieldset', { className: 'fish-scene-picker', disabled }, h('legend', { className: 'fish-sr' }, zh ? '选择场景' : 'Choose a scene'), h('div', { className: 'fish-scene-grid' }, Object.entries(SCENES).map(([id, scene]) => h('label', { className: 'fish-scene-card', key: id }, h('input', { type: 'radio', className: 'fish-sr', name: group, value: id, checked: state.scene === id,
3361
+ onChange: () => dfSetSetting('scene', id) }), h('span', { className: 'fish-card-art' }, h(FishPlate, { scene: id }), state.scene === id && h('span', { className: 'fish-picked' }, h(FishIcon, { name: 'check', size: 13 }))), h('span', { className: 'fish-card-label' }, h(FishIcon, { name: scene.icon, size: 16 }), zh ? scene.zh : scene.en)))));
3362
+ }
3363
+ function FishAccentPicker({ value, disabled, zh }) {
3364
+ const input = React.useRef(null);
3365
+ const group = React.useId();
3366
+ const title = zh ? '强调色' : 'Accent color';
3367
+ // A native color dialog can emit many input events while scrubbing. Persist its committed change.
3368
+ React.useEffect(() => {
3369
+ const node = input.current;
3370
+ if (!node)
3371
+ return;
3372
+ const commit = () => dfSetSetting('accentColor', node.value.toUpperCase());
3373
+ node.addEventListener('change', commit);
3374
+ return () => node.removeEventListener('change', commit);
3375
+ }, []);
3376
+ React.useEffect(() => { if (input.current)
3377
+ input.current.value = value; }, [value]);
3378
+ return h('fieldset', { className: 'fish-accent-picker', disabled }, h('legend', { className: 'fish-sr' }, title), h('div', { className: 'fish-controls-row' }, h('span', { className: 'fish-control-label', 'aria-hidden': true }, h(FishIcon, { name: 'catppuccin' }), title), h('div', { className: 'fish-inks' }, ACCENT_SWATCHES.map(([hex, cn, en]) => h('label', { key: hex, className: 'fish-ink-option',
3379
+ style: { '--fish-swatch': hex }, title: zh ? cn : en }, h('input', { type: 'radio', className: 'fish-sr', name: group, value: hex, 'aria-label': zh ? cn : en,
3380
+ checked: value.toUpperCase() === hex, onChange: () => dfSetSetting('accentColor', hex) }))), h('label', { className: 'fish-custom-color' }, zh ? '自选' : 'Custom', h('input', { type: 'color', ref: input, defaultValue: value, 'aria-label': zh ? '自选强调色' : 'Custom accent color' })))));
3381
+ }
3382
+ function FishSegments({ name, label, icon, value, options, disabled }) {
3383
+ const group = React.useId();
3384
+ return h('fieldset', { className: 'fish-segments', disabled }, h('legend', { className: 'fish-sr' }, label), h('div', { className: 'fish-controls-row' }, h('span', { className: 'fish-control-label', 'aria-hidden': true }, h(FishIcon, { name: icon }), label), h('div', { className: 'fish-segment-track' }, options.map(([id, title, glyph]) => h('label', { key: id, className: 'fish-segment' }, h('input', { type: 'radio', className: 'fish-sr', name: group, value: id, checked: value === id,
3385
+ onChange: () => dfSetSetting(name, id) }), h(FishIcon, { name: glyph, size: 14 }), title)))));
3386
+ }
3387
+ function DfSettingsPage() {
3388
+ const copy = dfUsesChinese() ? DF_COPY.zh : DF_COPY.en;
3389
+ const settings = useDfSettings();
3390
+ const state = settings.values;
3391
+ const [tab, setTab] = React.useState('scenes');
3392
+ const scene = SCENES[state.scene];
3393
+ const disabled = settings.status !== 'ready' || !settings.writable || settings.pending;
3394
+ const update = (key) => (value) => dfSetSetting(key, value);
3395
+ const reset = () => dfWrite?.(DF_DEFAULT_SETTINGS);
3396
+ const group = (title, children) => h('section', { key: title, className: 'df-set-group' }, [
3397
+ h('h3', { key: 'title', className: 'df-set-group-title' }, title),
3398
+ ...children,
3399
+ ]);
3400
+ const item = (key) => {
3401
+ const row = copy.items[key];
3402
+ return h(DfSwitch, {
3403
+ key: key,
3404
+ icon: key === 'aurora' ? 'gallery' : key === 'hostIcons' ? 'duotone' : key,
3405
+ label: row[0],
3406
+ description: row[1],
3407
+ value: state[key],
3408
+ disabled,
3409
+ onChange: update(key),
3410
+ });
3411
+ };
3412
+ const zh = dfUsesChinese();
3413
+ const status = settings.error
3414
+ ? (zh ? '保存未完成。如果刚更新过插件,请完整退出 DSH 重启后再试。' : 'Could not save. If you just updated the plugin, quit and reopen DSH, then try again.')
3415
+ : settings.status === 'loading' ? (zh ? '正在读取主题设置…' : 'Loading theme preferences…')
3416
+ : settings.status !== 'ready' ? (zh ? '此宿主暂未提供主题设置。' : 'Theme preferences are unavailable on this host.')
3417
+ : !settings.writable ? (zh ? '此配置只读。' : 'These preferences are read-only.')
3418
+ : settings.pending ? (zh ? '正在保存…' : 'Saving…') : '';
3419
+ const details = [
3420
+ group(zh ? '阅读' : 'Reading', [item('reading'), item('code')]),
3421
+ group(copy.groups.hero, [
3422
+ item('hero'), item('field'), item('wave'), item('ripple'),
3423
+ ]),
3424
+ group(copy.groups.thinking, [
3425
+ item('thinkingSphere'), item('thinkingLabel'),
3426
+ ]),
3427
+ group(copy.groups.composer, [
3428
+ item('glass'), item('effortBadge'),
3429
+ ]),
3430
+ group(copy.groups.sidebar, [
3431
+ item('sidebarDots'), item('sidebarRail'),
3432
+ ]),
3433
+ group(copy.groups.accents, [
3434
+ item('bold'), item('focusRing'), item('diff'),
3435
+ ]),
3436
+ group(zh ? 'Fish 字体与质感' : 'Fish finish', [
3437
+ item('fishFont'), item('fishGlow'), item('fishMotion'), item('fishCode'),
3438
+ ]),
3439
+ group(zh ? '配色与交互' : 'Color & interaction', [
3440
+ item('catppuccin'), item('hostIcons'), item('cursor'), item('textMotion'),
3441
+ ]),
3442
+ ];
3443
+ const tabButton = (id, label, icon) => h('button', { type: 'button', 'aria-pressed': tab === id,
3444
+ onClick: () => setTab(id) }, h(FishIcon, { name: icon, size: 16 }), label);
3445
+ return h('div', { className: 'df-set fish-studio' }, h('div', { className: 'fish-cover', style: { backgroundColor: scene.colors[0] } }, h(FishPlate, { scene: state.scene }), h('div', { className: 'fish-cover-copy' }, h('span', { className: 'fish-cover-kicker' }, zh ? scene.en : 'Selected scene'), h('h2', null, zh ? scene.zh : scene.en), h('p', null, scene.caption[zh ? 1 : 0])), h('div', { className: 'fish-swatches', 'aria-hidden': true }, scene.colors.map(color => h('i', { key: color, style: { background: color } })))), h('div', { className: 'fish-tabs', role: 'group', 'aria-label': zh ? '外观设置' : 'Appearance settings' }, tabButton('scenes', zh ? '场景' : 'Scenes', 'gallery'), tabButton('details', zh ? '界面细节' : 'Interface details', 'sliders')), status && h('p', { className: 'df-settings-status', role: settings.error ? 'alert' : 'status' }, status), tab === 'scenes' ? h('div', { className: 'fish-scenes' }, h(FishScenePicker, { state, disabled, zh }), h('div', { className: 'fish-controls' }, h(FishAccentPicker, { value: state.accentColor, disabled, zh }), item('aurora'), h(FishSegments, { name: 'sceneMotion', label: zh ? '背景动效' : 'Scene motion', icon: 'wave',
3446
+ value: state.sceneMotion, disabled: disabled || !state.aurora,
3447
+ options: [['still', zh ? '静止' : 'Still', 'still'], ['calm', zh ? '舒缓' : 'Calm', 'wave'], ['flow', zh ? '流动' : 'Flow', 'fishMotion']] }), h(FishSegments, { name: 'iconStyle', label: zh ? '图标风格' : 'Icon style', icon: 'duotone',
3448
+ value: state.iconStyle, disabled, options: [['line', zh ? '线描' : 'Outline', 'line'], ['duotone', zh ? '双色' : 'Duotone', 'duotone']] })))
3449
+ : h('div', { className: 'fish-details' }, details), h('div', { className: 'df-set-footer' }, h('button', { type: 'button', className: 'df-set-reset', disabled, onClick: reset }, h(FishIcon, { name: 'reset', size: 13 }), copy.reset), h('span', { className: 'df-set-note' }, zh ? '随当前配置自动保存' : 'Autosaved to this profile')));
3450
+ }
3451
+ // ----------------------------------------------------------- sidebar entry
3452
+ /** Sheet state shared by the sidebar button and the panel itself. */
3453
+ let dfSheetOpen = false;
3454
+ const dfSheetListeners = new Set();
3455
+ function dfSetSheetOpen(next) {
3456
+ dfSheetOpen = next;
3457
+ dfSheetListeners.forEach((listener) => listener());
3458
+ }
3459
+ function useDfSheet() {
3460
+ const [open, setOpen] = React.useState(dfSheetOpen);
3461
+ React.useEffect(() => {
3462
+ const listener = () => setOpen(dfSheetOpen);
3463
+ dfSheetListeners.add(listener);
3464
+ return () => { dfSheetListeners.delete(listener); };
3465
+ }, []);
3466
+ return open;
3467
+ }
3468
+ let dfReactDOM = null;
3469
+ try {
3470
+ dfReactDOM = require('react-dom');
3471
+ }
3472
+ catch (error) {
3473
+ dfReactDOM = null;
3474
+ }
3475
+ /** The floating settings sheet, portalled to the body when react-dom is around. */
3476
+ function DfSheet() {
3477
+ const open = useDfSheet();
3478
+ const panelRef = React.useRef(null);
3479
+ React.useEffect(() => {
3480
+ if (!open)
3481
+ return undefined;
3482
+ const previousFocus = document.activeElement;
3483
+ const panel = panelRef.current;
3484
+ const focusable = () => panel === null ? [] : [...panel.querySelectorAll('button:not(:disabled), input:checked:not(:disabled), input[type="color"]:not(:disabled), [href], [tabindex="0"]')];
3485
+ (focusable()[0] || panel)?.focus();
3486
+ const onKeyDown = (event) => {
3487
+ if (event.key === 'Escape') {
3488
+ event.preventDefault();
3489
+ event.stopPropagation();
3490
+ dfSetSheetOpen(false);
3491
+ }
3492
+ if (event.key !== 'Tab')
3493
+ return;
3494
+ const items = focusable();
3495
+ const first = items[0] || panel;
3496
+ const last = items[items.length - 1] || panel;
3497
+ if (event.shiftKey && (document.activeElement === first || document.activeElement === panel)) {
3498
+ event.preventDefault();
3499
+ last?.focus();
3500
+ }
3501
+ else if (!event.shiftKey && (document.activeElement === last || document.activeElement === panel)) {
3502
+ event.preventDefault();
3503
+ first?.focus();
3504
+ }
3505
+ };
3506
+ document.addEventListener('keydown', onKeyDown, true);
3507
+ return () => {
3508
+ document.removeEventListener('keydown', onKeyDown, true);
3509
+ if (previousFocus instanceof HTMLElement && previousFocus.isConnected)
3510
+ previousFocus.focus();
3511
+ };
3512
+ }, [open]);
3513
+ if (!open)
3514
+ return null;
3515
+ const panel = h('div', { key: 'panel', className: 'df-sheet-panel', ref: panelRef, role: 'dialog', 'aria-modal': 'true', tabIndex: -1, 'aria-label': dfUsesChinese() ? DF_COPY.zh.dialog : DF_COPY.en.dialog }, [
3516
+ h('div', { key: 'head', className: 'df-sheet-head' }, [
3517
+ h('span', { key: 'title', className: 'df-sheet-title' }, h('span', { className: 'fish-brand' }, h(FishBrand)), 'Deep Fish UI'),
3518
+ h('button', {
3519
+ key: 'close',
3520
+ type: 'button',
3521
+ className: 'df-sheet-close',
3522
+ 'aria-label': dfUsesChinese() ? DF_COPY.zh.close : DF_COPY.en.close,
3523
+ onClick: () => dfSetSheetOpen(false),
3524
+ }, h(FishIcon, { name: 'close', size: 16 })),
3525
+ ]),
3526
+ h('div', { key: 'body', className: 'df-sheet-body' }, h(DfSettingsPage)),
3527
+ ]);
3528
+ const scrim = h('div', {
3529
+ key: 'scrim',
3530
+ className: 'df-sheet-scrim',
3531
+ onClick: () => dfSetSheetOpen(false),
3532
+ });
3533
+ const both = h('div', { className: 'df-sheet-root' }, [scrim, panel]);
3534
+ if (dfReactDOM !== null && typeof dfReactDOM.createPortal === 'function') {
3535
+ return dfReactDOM.createPortal(both, document.body);
3536
+ }
3537
+ return both;
3538
+ }
3539
+ /**
3540
+ * Sidebar footer button that opens the sheet.
3541
+ *
3542
+ * The button carries its own dot field: completely unlit at rest, it surfaces only in a
3543
+ * soft pool around the pointer, clipped to the button, and fades away when the pointer
3544
+ * leaves. Dots never move; only their brightness changes.
3545
+ */
3546
+ function DfSidebarAction({ wide }) {
3547
+ const open = useDfSheet();
3548
+ const { values } = useDfSettings();
3549
+ const showDots = values.sidebarDots !== false;
3550
+ const showRail = values.sidebarRail !== false;
3551
+ const canvasRef = React.useRef(null);
3552
+ React.useEffect(() => {
3553
+ if (!showDots && !showRail)
3554
+ return;
3555
+ const canvas = canvasRef.current;
3556
+ if (canvas === null)
3557
+ return;
3558
+ const context = canvas.getContext('2d');
3559
+ if (context === null)
3560
+ return;
3561
+ const button = canvas.parentElement;
3562
+ if (button === null)
3563
+ return;
3564
+ const motion = matchMedia('(prefers-reduced-motion: reduce)');
3565
+ const state = { x: -999, y: -999, inside: false, alpha: 0, frame: 0, live: false, dirty: false };
3566
+ let stopped = false;
3567
+ let dpr = Math.min(2, devicePixelRatio || 1);
3568
+ const measure = () => {
3569
+ const rect = canvas.getBoundingClientRect();
3570
+ dpr = Math.min(2, devicePixelRatio || 1);
3571
+ const width = Math.max(1, Math.round(rect.width * dpr));
3572
+ const height = Math.max(1, Math.round(rect.height * dpr));
3573
+ if (canvas.width !== width || canvas.height !== height) {
3574
+ canvas.width = width;
3575
+ canvas.height = height;
3576
+ }
3577
+ };
3578
+ const paint = () => {
3579
+ state.frame = 0;
3580
+ if (stopped)
3581
+ return;
3582
+ const rect = canvas.getBoundingClientRect();
3583
+ const width = rect.width;
3584
+ const height = rect.height;
3585
+ const target = state.inside ? 1 : 0;
3586
+ state.alpha = motion.matches ? target : state.alpha + (target - state.alpha) * 0.22;
3587
+ context.setTransform(dpr, 0, 0, dpr, 0, 0);
3588
+ context.clearRect(0, 0, width, height);
3589
+ if (!state.inside && state.alpha < 0.02) {
3590
+ state.alpha = 0;
3591
+ state.live = false;
3592
+ return;
3593
+ }
3594
+ const radius = 64;
3595
+ const accent = (getComputedStyle(button).getPropertyValue('--df-accent') || '').trim() || '#7aa4ff';
3596
+ context.fillStyle = accent;
3597
+ if (showDots)
3598
+ for (let y = 3; y < height; y += 4) {
3599
+ for (let x = 3; x < width; x += 4) {
3600
+ const dx = x - state.x;
3601
+ const dy = y - state.y;
3602
+ const distance = Math.sqrt(dx * dx + dy * dy);
3603
+ if (distance > radius)
3604
+ continue;
3605
+ const alpha = Math.pow(1 - distance / radius, 1.35) * state.alpha;
3606
+ if (alpha < 0.02)
3607
+ continue;
3608
+ context.globalAlpha = Math.min(1, alpha);
3609
+ context.beginPath();
3610
+ context.arc(x, y, 0.85, 0, Math.PI * 2);
3611
+ context.fill();
3612
+ }
3613
+ }
3614
+ if (showRail) {
3615
+ const railHeight = Math.max(6, height - 10);
3616
+ const railTop = (height - railHeight) / 2;
3617
+ context.globalAlpha = Math.min(1, state.alpha * 0.9);
3618
+ context.beginPath();
3619
+ if (typeof context.roundRect === 'function') {
3620
+ context.roundRect(2, railTop, 3, railHeight, 1.5);
3621
+ }
3622
+ else {
3623
+ context.rect(2, railTop, 3, railHeight);
3624
+ }
3625
+ context.fill();
3626
+ context.globalAlpha = 1;
3627
+ }
3628
+ const moving = state.dirty;
3629
+ state.dirty = false;
3630
+ if (motion.matches) {
3631
+ if (!state.inside) {
3632
+ context.clearRect(0, 0, width, height);
3633
+ state.alpha = 0;
3634
+ }
3635
+ state.live = false;
3636
+ return;
3637
+ }
3638
+ // Idle inside the button: stop the loop until the pointer moves again.
3639
+ if (state.inside && state.alpha >= 0.98 && !moving) {
3640
+ state.live = false;
3641
+ return;
3642
+ }
3643
+ if (state.inside || state.alpha >= 0.02) {
3644
+ state.frame = requestAnimationFrame(paint);
3645
+ }
3646
+ else {
3647
+ state.live = false;
3648
+ }
3649
+ };
3650
+ const wake = () => {
3651
+ if (stopped || state.live)
3652
+ return;
3653
+ state.live = true;
3654
+ if (state.frame === 0)
3655
+ state.frame = requestAnimationFrame(paint);
3656
+ };
3657
+ const track = event => {
3658
+ const rect = canvas.getBoundingClientRect();
3659
+ state.x = event.clientX - rect.left;
3660
+ state.y = event.clientY - rect.top;
3661
+ state.inside = true;
3662
+ state.dirty = true;
3663
+ wake();
3664
+ };
3665
+ const leave = () => {
3666
+ state.inside = false;
3667
+ wake();
3668
+ };
3669
+ const resizeObserver = new ResizeObserver(() => {
3670
+ measure();
3671
+ if (state.inside || state.alpha > 0.02)
3672
+ wake();
3673
+ });
3674
+ resizeObserver.observe(canvas);
3675
+ button.addEventListener('pointerenter', track);
3676
+ button.addEventListener('pointermove', track);
3677
+ button.addEventListener('pointerleave', leave);
3678
+ measure();
3679
+ return () => {
3680
+ stopped = true;
3681
+ resizeObserver.disconnect();
3682
+ button.removeEventListener('pointerenter', track);
3683
+ button.removeEventListener('pointermove', track);
3684
+ button.removeEventListener('pointerleave', leave);
3685
+ if (state.frame !== 0)
3686
+ cancelAnimationFrame(state.frame);
3687
+ state.frame = 0;
3688
+ state.live = false;
3689
+ };
3690
+ }, [showDots, showRail]);
3691
+ return h('div', { className: 'df-foot' }, [
3692
+ h('button', {
3693
+ key: 'button',
3694
+ type: 'button',
3695
+ className: 'df-foot-button',
3696
+ title: 'Deep Fish UI',
3697
+ 'aria-label': dfUsesChinese() ? DF_COPY.zh.button : DF_COPY.en.button,
3698
+ onClick: () => dfSetSheetOpen(!dfSheetOpen),
3699
+ }, [
3700
+ showDots || showRail
3701
+ ? h('canvas', { key: 'dots', ref: canvasRef, className: 'df-foot-dots', 'aria-hidden': 'true' })
3702
+ : null,
3703
+ h('span', { key: 'icon', className: 'fish-brand' }, h(FishBrand)),
3704
+ wide ? h('span', { key: 'label', className: 'df-foot-label' }, 'Deep Fish UI') : null,
3705
+ wide ? h('span', { key: 'scene', className: 'fish-foot-scene', title: dfUsesChinese() ? SCENES[values.scene].zh : SCENES[values.scene].en }, h(FishIcon, { name: SCENES[values.scene].icon, size: 16 })) : null,
3706
+ ]),
3707
+ h(DfSheet, { key: 'sheet' }),
3708
+ ]);
3709
+ }
3710
+ return {
3711
+ inject: ['slots'],
3712
+ apply(ctx) {
3713
+ dfPlaySplash();
3714
+ ctx.effect(() => {
3715
+ dfMounted = true;
3716
+ const visible = () => document.documentElement.toggleAttribute('data-fish-paused', document.hidden);
3717
+ document.addEventListener('visibilitychange', visible);
3718
+ visible();
3719
+ dfApplySettings();
3720
+ return () => {
3721
+ dfMounted = false;
3722
+ dfWrite = null;
3723
+ dfSetSheetOpen(false);
3724
+ for (const className of Object.values(DF_OFF_CLASS))
3725
+ document.documentElement.classList.remove(className);
3726
+ delete document.documentElement.dataset.fishPace;
3727
+ delete document.documentElement.dataset.fishIcons;
3728
+ document.removeEventListener('visibilitychange', visible);
3729
+ document.documentElement.removeAttribute('data-fish-paused');
3730
+ for (const dispose of dfThemeLayers.values())
3731
+ dispose();
3732
+ dfThemeLayers.clear();
3733
+ dfTheme = null;
3734
+ };
3735
+ }, 'dsh-fish-ui: lifecycle');
3736
+ ctx.effect(() => {
3737
+ const style = document.createElement('style');
3738
+ style.dataset.dshPlugin = 'dsh-fish-ui';
3739
+ style.textContent = CSS;
3740
+ document.head.append(style);
3741
+ return () => style.remove();
3742
+ }, 'dsh-fish-ui: styles');
3743
+ ctx.effect(() => {
3744
+ const style = document.createElement('style');
3745
+ style.dataset.dshPlugin = 'dsh-fish-ui:finish';
3746
+ style.textContent = FISH_CSS;
3747
+ document.head.append(style);
3748
+ return () => style.remove();
3749
+ }, 'dsh-fish-ui: finish styles');
3750
+ ctx.effect(() => {
3751
+ const style = document.createElement('style');
3752
+ style.dataset.dshPlugin = 'dsh-fish-ui: fx';
3753
+ style.textContent = FISH_FX_CSS + '\n' + FISH_STUDIO_CSS + '\n' + productIconCss();
3754
+ document.head.append(style);
3755
+ return () => style.remove();
3756
+ }, 'dsh-fish-ui: fx styles');
3757
+ ctx.effect(attachPointerPhysics, 'dsh-fish-ui: pointer physics');
3758
+ ctx.inject(['theme'], scope => {
3759
+ scope.effect(() => {
3760
+ dfTheme = scope.theme;
3761
+ dfSyncTheme();
3762
+ return () => {
3763
+ for (const dispose of dfThemeLayers.values())
3764
+ dispose();
3765
+ dfThemeLayers.clear();
3766
+ dfTheme = null;
3767
+ };
3768
+ }, 'dsh-fish-ui: token layers');
3769
+ });
3770
+ ctx.effect(() => {
3771
+ const sync = () => {
3772
+ const enabled = dfGetSnapshot().values.effortBadge !== false;
3773
+ const label = enabled ? dfEffortLabel() : null;
3774
+ dfPaintEffort(label !== null && !DF_EFFORT_OFF.test(label) ? label : null);
3775
+ };
3776
+ sync();
3777
+ const timer = setInterval(sync, 500);
3778
+ return () => {
3779
+ clearInterval(timer);
3780
+ const card = document.querySelector('[data-composer-card]');
3781
+ if (card !== null) {
3782
+ card.removeAttribute('data-df-effort');
3783
+ card.classList.remove('df-effort-on', 'df-effort-max');
3784
+ }
3785
+ };
3786
+ }, 'dsh-fish-ui: effort badge');
3787
+ // Fresh conversation on every launch. The service may not be reachable the first
3788
+ // moment the shell is up, so retry for a few seconds and leave a manual trigger.
3789
+ ctx.inject(['uiWorkspace'], scope => {
3790
+ const open = tries => {
3791
+ try {
3792
+ if (typeof scope.uiWorkspace.startSession === 'function') {
3793
+ scope.uiWorkspace.startSession();
3794
+ console.info('[dsh-fish-ui] opened a new session on launch');
3795
+ return;
3796
+ }
3797
+ }
3798
+ catch (error) {
3799
+ console.warn('[dsh-fish-ui] new session failed', error);
3800
+ return;
3801
+ }
3802
+ if (tries < 30)
3803
+ window.setTimeout(() => open(tries + 1), 400);
3804
+ };
3805
+ window.__dfNewSession = () => open(0);
3806
+ scope.effect(() => {
3807
+ const timer = window.setTimeout(() => open(0), 2500);
3808
+ return () => window.clearTimeout(timer);
3809
+ }, 'dsh-fish-ui: new session on launch');
3810
+ });
3811
+ ctx.inject(['configForms'], dfConnectSettings);
3812
+ const add = (name, options, Component) => ctx.slots.inject(name, () => ctx.slots.register({ name, ...options }, dfSafe(Component)));
3813
+ add('conversation.hero.frame', { id: 'dot-whale', order: 20 }, HeroFrame);
3814
+ add('sidebar.footer.action', { id: 'dsh-fish-ui', order: 5, label: () => 'Deep Fish UI' }, DfSidebarAction);
3815
+ add('shell.overlay', { id: 'df-ambient', order: 5 }, DfOverlay);
3816
+ add('shell.overlay', { id: 'df-sidebar-dots', order: 6 }, DfSidebarDots);
3817
+ add('shell.overlay', { id: 'df-caret-trail', order: 4 }, DfCaretTrail);
3818
+ // Package name, distinct from the Host entry id even though both currently match.
3819
+ add('plugins.bundle.config', { key: 'dsh-fish-ui' }, DfSettingsPage);
3820
+ },
3821
+ };
3822
+ },
3823
+ });