@principal-ai/logo-component 0.1.23 → 0.1.24

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.
@@ -0,0 +1,353 @@
1
+ "use strict";
2
+ /**
3
+ * Layout for {@link FileCityBotAvatar} — a Bot's avatar drawn in the same
4
+ * top-down "file city" grid as the brand mark, but on a denser 7×7 grid so
5
+ * the lit files can spell a letter / initials *or* form a face (two eyes and
6
+ * a mouth) that can change expression and look around.
7
+ *
8
+ * Pure and dependency-free (no React, no DOM) so the React Native port can
9
+ * use this file verbatim and only swap the renderer.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BOT_AVATAR_COLORS = exports.BOT_AVATAR_VIEW = void 0;
13
+ exports.botAvatarColor = botAvatarColor;
14
+ exports.computeBotAvatarLayout = computeBotAvatarLayout;
15
+ exports.BOT_AVATAR_VIEW = 100;
16
+ const SQUIRCLE_RADIUS = exports.BOT_AVATAR_VIEW * 0.2237;
17
+ /** Default per-Bot colours; {@link botAvatarColor} picks one from a seed. */
18
+ exports.BOT_AVATAR_COLORS = [
19
+ '#2ec5e8',
20
+ '#E05D2B',
21
+ '#2dd4a7',
22
+ '#f5a623',
23
+ '#a78bfa',
24
+ '#f472b6',
25
+ ];
26
+ function hashString(input) {
27
+ let hash = 0;
28
+ for (let i = 0; i < input.length; i++)
29
+ hash = (hash * 31 + input.charCodeAt(i)) | 0;
30
+ return Math.abs(hash);
31
+ }
32
+ /** Stable colour for a Bot, picked from its id. */
33
+ function botAvatarColor(seed) {
34
+ return exports.BOT_AVATAR_COLORS[hashString(seed) % exports.BOT_AVATAR_COLORS.length];
35
+ }
36
+ // 3×5 pixel font — same proportions as the brand mark's P.
37
+ // `1` = lit file, `0` = city file. Every square of the grid is always
38
+ // drawn — counters and the backdrop are city files, never gaps.
39
+ const FONT = {
40
+ A: ['111', '101', '111', '101', '101'],
41
+ B: ['110', '101', '110', '101', '110'],
42
+ C: ['111', '100', '100', '100', '111'],
43
+ D: ['110', '101', '101', '101', '110'],
44
+ E: ['111', '100', '110', '100', '111'],
45
+ F: ['111', '100', '110', '100', '100'],
46
+ G: ['111', '100', '101', '101', '111'],
47
+ H: ['101', '101', '111', '101', '101'],
48
+ I: ['111', '010', '010', '010', '111'],
49
+ J: ['001', '001', '001', '101', '111'],
50
+ K: ['101', '101', '110', '101', '101'],
51
+ L: ['100', '100', '100', '100', '111'],
52
+ M: ['101', '111', '111', '101', '101'],
53
+ N: ['111', '101', '101', '101', '101'],
54
+ O: ['111', '101', '101', '101', '111'],
55
+ P: ['111', '101', '111', '100', '100'],
56
+ Q: ['111', '101', '101', '111', '001'],
57
+ R: ['111', '101', '110', '101', '101'],
58
+ S: ['111', '100', '111', '001', '111'],
59
+ T: ['111', '010', '010', '010', '010'],
60
+ U: ['101', '101', '101', '101', '111'],
61
+ V: ['101', '101', '101', '101', '010'],
62
+ W: ['101', '101', '111', '111', '101'],
63
+ X: ['101', '101', '010', '101', '101'],
64
+ Y: ['101', '101', '010', '010', '010'],
65
+ Z: ['111', '001', '010', '100', '111'],
66
+ '0': ['111', '101', '101', '101', '111'],
67
+ '1': ['010', '110', '010', '010', '111'],
68
+ '2': ['111', '001', '111', '100', '111'],
69
+ '3': ['111', '001', '111', '001', '111'],
70
+ '4': ['101', '101', '111', '001', '001'],
71
+ '5': ['111', '100', '111', '001', '111'],
72
+ '6': ['111', '100', '111', '101', '111'],
73
+ '7': ['111', '001', '001', '001', '001'],
74
+ '8': ['111', '101', '111', '101', '111'],
75
+ '9': ['111', '101', '111', '001', '111'],
76
+ '?': ['111', '001', '010', '000', '010'],
77
+ };
78
+ // Faces are authored on a 7×7 grid: eyes are 2 files wide at columns 1–2 and
79
+ // 4–5 (mirrored about the centre column), the mouth lives in rows 4–5.
80
+ const FACE_SIDE = 7;
81
+ const EYE_ROWS = {
82
+ open: [1, 2],
83
+ closed: [2],
84
+ wide: [1, 2, 3],
85
+ };
86
+ // The mouth is five files, one per column 1–5. An expression says where each
87
+ // one sits (or that it's hidden), so changing expression slides the same
88
+ // five files into a new shape instead of swapping one drawing for another.
89
+ const MOUTH_COL0 = 1;
90
+ const _ = null;
91
+ const FACES = {
92
+ neutral: { left: 'open', right: 'open', mouth: [_, [5, 1], [5, 1], [5, 1], _] },
93
+ happy: { left: 'open', right: 'open', mouth: [[4, 1], [5, 1], [5, 1], [5, 1], [4, 1]] },
94
+ wink: { left: 'open', right: 'closed', mouth: [[4, 1], [5, 1], [5, 1], [5, 1], [4, 1]] },
95
+ thinking: {
96
+ left: 'open',
97
+ right: 'open',
98
+ mouth: [[5, 1], _, [5, 1], _, [5, 1]],
99
+ look: 'up-right',
100
+ brows: 'skeptical',
101
+ },
102
+ talking: { left: 'open', right: 'open', mouth: [_, [4, 2], [4, 2], [4, 2], _] },
103
+ surprised: { left: 'wide', right: 'wide', mouth: [_, _, [5, 1], _, _], brows: 'raised' },
104
+ sad: {
105
+ left: 'open',
106
+ right: 'open',
107
+ mouth: [[5, 1], [4, 1], [4, 1], [4, 1], [5, 1]],
108
+ brows: 'worried',
109
+ },
110
+ sleeping: { left: 'closed', right: 'closed', mouth: [_, _, [5, 1], _, _] },
111
+ };
112
+ const LOOKS = {
113
+ center: [0, 0],
114
+ left: [-1, 0],
115
+ right: [1, 0],
116
+ up: [0, -1],
117
+ down: [0, 1],
118
+ 'up-left': [-1, -1],
119
+ 'up-right': [1, -1],
120
+ };
121
+ function faceBitmap(expression, look, blink, hasBrows) {
122
+ var _a;
123
+ const face = FACES[expression];
124
+ const grid = Array.from({ length: FACE_SIDE }, () => new Array(FACE_SIDE).fill('city'));
125
+ const [dx, rawDy] = LOOKS[(_a = look !== null && look !== void 0 ? look : face.look) !== null && _a !== void 0 ? _a : 'center'];
126
+ const eye = (shape, col0, feature) => {
127
+ const rows = EYE_ROWS[shape];
128
+ // Keep the eyes clear of the mouth rows when looking down.
129
+ // Brows need the row above the eye: with brows on, the eyes don't climb
130
+ // into the top row, so nothing ever leaves the grid of squares.
131
+ const dy = Math.max(Math.min(rawDy, 3 - rows[rows.length - 1]), hasBrows ? 0 : -1);
132
+ for (const r of rows) {
133
+ for (const c of [col0, col0 + 1])
134
+ grid[r + dy][c + dx] = feature;
135
+ }
136
+ };
137
+ eye(blink ? 'closed' : face.left, 1, 'eyeL');
138
+ eye(blink ? 'closed' : face.right, 4, 'eyeR');
139
+ return grid;
140
+ }
141
+ function letterBitmap(text) {
142
+ const chars = Array.from(text.toUpperCase())
143
+ .filter((ch) => FONT[ch])
144
+ .slice(0, 2)
145
+ .join('') || '?';
146
+ const grid = Array.from({ length: 5 }, () => []);
147
+ Array.from(chars).forEach((ch, i) => {
148
+ for (let r = 0; r < 5; r++) {
149
+ if (i > 0)
150
+ grid[r].push('city');
151
+ for (const bit of FONT[ch][r]) {
152
+ grid[r].push(bit === '1' ? 'letter' : 'city');
153
+ }
154
+ }
155
+ });
156
+ return { grid, chars };
157
+ }
158
+ function toRgb(color) {
159
+ if (!/^#([0-9a-f]{3}){1,2}$/i.test(color))
160
+ return null;
161
+ let hex = color.slice(1);
162
+ if (hex.length === 3)
163
+ hex = hex.split('').map((c) => c + c).join('');
164
+ return [
165
+ parseInt(hex.slice(0, 2), 16),
166
+ parseInt(hex.slice(2, 4), 16),
167
+ parseInt(hex.slice(4, 6), 16),
168
+ ];
169
+ }
170
+ function withAlpha(color, alpha) {
171
+ const rgb = toRgb(color);
172
+ if (!rgb)
173
+ return color;
174
+ const a = Math.round(Math.max(0, Math.min(1, alpha)) * 255)
175
+ .toString(16)
176
+ .padStart(2, '0');
177
+ return `#${rgb.map((v) => v.toString(16).padStart(2, '0')).join('')}${a}`;
178
+ }
179
+ /** Blend two hex colours. `t` = 0 returns `a`, `t` = 1 returns `b`. */
180
+ function mix(a, b, t) {
181
+ const ca = toRgb(a);
182
+ const cb = toRgb(b);
183
+ if (!ca || !cb)
184
+ return a;
185
+ const k = Math.max(0, Math.min(1, t));
186
+ return `#${[0, 1, 2]
187
+ .map((i) => Math.round(ca[i] + (cb[i] - ca[i]) * k).toString(16).padStart(2, '0'))
188
+ .join('')}`;
189
+ }
190
+ function computeBotAvatarLayout({ variant = 'face', text = '', expression = 'neutral', look, brows, browLength = 1, browRound = 0.7, browThickness = 0.42, browLift = 0, browGradient = 0, browTaper = 0, browSlope = 0, blink = false, seed = '', primary, color = '#f8fafc', background = '#0a0f14', cells, squareRadius = 0.15, shape = 'squircle', cityStrength = 0.3, tileOutline = false, eyeTint = 0.4, }) {
191
+ var _a;
192
+ const primaryColor = primary !== null && primary !== void 0 ? primary : botAvatarColor(seed);
193
+ const baseColor = color;
194
+ const bgColor = background;
195
+ const browStyle = variant === 'face' ? ((_a = brows !== null && brows !== void 0 ? brows : FACES[expression].brows) !== null && _a !== void 0 ? _a : 'none') : 'none';
196
+ let bitmap;
197
+ let label;
198
+ if (variant === 'letter') {
199
+ const letters = letterBitmap(text);
200
+ bitmap = letters.grid;
201
+ label = `Bot avatar: file city spelling ${letters.chars}`;
202
+ }
203
+ else {
204
+ bitmap = faceBitmap(expression, look, blink, browStyle !== 'none');
205
+ label = `Bot avatar: file city face, ${expression}`;
206
+ }
207
+ const bw = bitmap[0].length;
208
+ const bh = bitmap.length;
209
+ const side = Math.max(cells !== null && cells !== void 0 ? cells : FACE_SIDE, bw, bh);
210
+ const offX = Math.floor((side - bw) / 2);
211
+ const offY = Math.floor((side - bh) / 2);
212
+ const featureAt = (c, r) => { var _a, _b; return (_b = (_a = bitmap[r - offY]) === null || _a === void 0 ? void 0 : _a[c - offX]) !== null && _b !== void 0 ? _b : 'city'; };
213
+ // Every backdrop file is the same faint neutral, so the grid reads as one
214
+ // even field and only the letter / face carries colour. `cityStrength`
215
+ // scales how present it is (1 ≈ FileCityLogo's city).
216
+ const cityFill = withAlpha(baseColor, 0.2 * cityStrength);
217
+ // Lit files run a dark→light diagonal gradient, like the brand mark.
218
+ const shade = (c, r) => mix(mix(primaryColor, '#000000', 0.12), mix(primaryColor, '#ffffff', 0.4), side > 1 ? (c + r) / (2 * (side - 1)) : 0);
219
+ // Eyes sit between the neutral base (near-white on dark, near-black on
220
+ // light) and the Bot's colour: tinted enough not to glare, still the
221
+ // brightest thing on the panel.
222
+ const eyeFill = mix(baseColor, primaryColor, eyeTint);
223
+ // A circle clips the grid's corners, so pull the grid in a little.
224
+ const pad = shape === 'circle' ? 15 : 12;
225
+ const cell = (exports.BOT_AVATAR_VIEW - pad * 2) / side;
226
+ const sq = cell * 0.78;
227
+ const inset = (cell - sq) / 2;
228
+ const rx = squareRadius > 0 ? sq * squareRadius : 0;
229
+ const out = [];
230
+ const emptyBox = () => ({ c0: Infinity, c1: -Infinity, r0: Infinity, r1: -Infinity });
231
+ const eyeBoxes = { eyeL: emptyBox(), eyeR: emptyBox() };
232
+ for (let r = 0; r < side; r++) {
233
+ for (let c = 0; c < side; c++) {
234
+ const feature = featureAt(c, r);
235
+ const base = {
236
+ key: `${c}-${r}`,
237
+ c,
238
+ r,
239
+ x: pad + c * cell + inset,
240
+ y: pad + r * cell + inset,
241
+ sq,
242
+ rx,
243
+ };
244
+ if (feature === 'eyeL' || feature === 'eyeR') {
245
+ const box = eyeBoxes[feature];
246
+ box.c0 = Math.min(box.c0, c);
247
+ box.c1 = Math.max(box.c1, c);
248
+ box.r0 = Math.min(box.r0, r);
249
+ box.r1 = Math.max(box.r1, r);
250
+ }
251
+ if (feature === 'letter') {
252
+ out.push(Object.assign(Object.assign({}, base), { fill: shade(c, r), stroke: withAlpha(primaryColor, 0.55), strokeWidth: tileOutline ? 0.6 : 0, role: 'letter' }));
253
+ }
254
+ else {
255
+ out.push(Object.assign(Object.assign({}, base), { fill: cityFill, stroke: withAlpha(baseColor, 0.08 * cityStrength), strokeWidth: tileOutline ? 0.4 : 0, role: 'city' }));
256
+ }
257
+ }
258
+ }
259
+ // Each eye is one block spanning the outer edges of the files it covers.
260
+ const eyes = ['eyeL', 'eyeR']
261
+ .filter((key) => eyeBoxes[key].c1 >= eyeBoxes[key].c0)
262
+ .map((key) => {
263
+ const { c0, c1, r0, r1 } = eyeBoxes[key];
264
+ return {
265
+ side: key === 'eyeL' ? 'left' : 'right',
266
+ x: pad + c0 * cell + inset,
267
+ y: pad + r0 * cell + inset,
268
+ width: (c1 - c0) * cell + sq,
269
+ height: (r1 - r0) * cell + sq,
270
+ rx: rx * 1.6,
271
+ fill: eyeFill,
272
+ closed: r1 === r0,
273
+ };
274
+ });
275
+ // Brows ride just above their eye, so they follow it when it looks around.
276
+ // Lifts and tilts are sized to stay inside the row of squares above the eye.
277
+ // [lift in cells, tilt in degrees] for the left and right brow; a positive
278
+ // tilt drops the right-hand end.
279
+ const BROWS = {
280
+ none: { left: [0, 0], right: [0, 0] },
281
+ flat: { left: [0, 0], right: [0, 0] },
282
+ raised: { left: [0.4, 0], right: [0.4, 0] },
283
+ skeptical: { left: [0.3, -6], right: [0, 0] },
284
+ angry: { left: [-0.05, 18], right: [-0.05, -18] },
285
+ worried: { left: [0.1, -16], right: [0.1, 16] },
286
+ };
287
+ // A step deeper into the Bot's colour than the eyes, so the brows read as
288
+ // their own feature instead of as part of the eye.
289
+ const browFill = mix(eyeFill, primaryColor, 0.6);
290
+ const browShift = Math.min(1, Math.abs(browGradient));
291
+ const browDeep = mix(browFill, mix(primaryColor, '#000000', 0.1), browShift);
292
+ const browPale = mix(browFill, mix(eyeFill, '#ffffff', 0.25), browShift);
293
+ const browHeight = sq * Math.max(0.15, Math.min(1, browThickness));
294
+ const taper = Math.max(-1, Math.min(1, browTaper));
295
+ const browOut = eyes.map((eye) => {
296
+ const [lift, tilt] = BROWS[browStyle][eye.side];
297
+ // `browSlope` leans both brows the same way relative to the nose, so it
298
+ // mirrors: positive drops the inner ends.
299
+ const rotate = tilt + (eye.side === 'left' ? browSlope : -browSlope);
300
+ const width = eye.width * browLength;
301
+ // Half the height the bar takes up once tilted, so the clamp below keeps
302
+ // its raised end inside the row of squares above the eye too.
303
+ const rad = (Math.abs(rotate) * Math.PI) / 180;
304
+ const half = (width / 2) * Math.sin(rad) + (browHeight / 2) * Math.cos(rad);
305
+ return {
306
+ side: eye.side,
307
+ cx: eye.x + eye.width / 2,
308
+ cy: Math.max(eye.y - cell + half, Math.min(eye.y - cell * 0.06 - browHeight / 2, eye.y - cell * 0.16 - browHeight / 2 - (lift + browLift) * cell)),
309
+ width,
310
+ height: browHeight,
311
+ heightInner: browHeight * (1 - 0.8 * Math.max(0, -taper)),
312
+ heightOuter: browHeight * (1 - 0.8 * Math.max(0, taper)),
313
+ rx: (browHeight / 2) * Math.max(0, Math.min(1, browRound)),
314
+ rotate,
315
+ fill: browFill,
316
+ fillInner: browGradient >= 0 ? browDeep : browPale,
317
+ fillOuter: browGradient >= 0 ? browPale : browDeep,
318
+ visible: browStyle !== 'none',
319
+ };
320
+ });
321
+ const mouth = variant === 'face'
322
+ ? FACES[expression].mouth.map((spec, index) => {
323
+ const c = offX + MOUTH_COL0 + index;
324
+ // Hidden files wait on the mouth's bottom row.
325
+ const [row, span] = spec !== null && spec !== void 0 ? spec : [5, 1];
326
+ return {
327
+ index,
328
+ x: pad + c * cell + inset,
329
+ y: pad + (offY + row) * cell + inset,
330
+ width: sq,
331
+ height: (span - 1) * cell + sq,
332
+ rx,
333
+ // Shaded by column only, so a file keeps its colour as it moves.
334
+ fill: shade(c, offY + 5),
335
+ visible: spec !== null,
336
+ };
337
+ })
338
+ : [];
339
+ return {
340
+ cells: out,
341
+ eyes,
342
+ brows: browOut,
343
+ mouth,
344
+ view: exports.BOT_AVATAR_VIEW,
345
+ radius: shape === 'circle' ? exports.BOT_AVATAR_VIEW / 2 : SQUIRCLE_RADIUS,
346
+ bgColor,
347
+ baseColor,
348
+ primaryColor,
349
+ variant,
350
+ expression,
351
+ label,
352
+ };
353
+ }
@@ -0,0 +1,124 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import React, { useId } from 'react';
13
+ import { computeBotAvatarLayout, } from './botAvatarLayout';
14
+ const ANIMATION_CSS = `
15
+ @keyframes fcba-blink { 0%, 90%, 100% { transform: scaleY(1); } 94%, 96% { transform: scaleY(0.14); } }
16
+ @keyframes fcba-dot { 0%, 60%, 100% { opacity: 0.3; } 30% { opacity: 1; } }
17
+ @keyframes fcba-talk { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(0.45); } }
18
+ .fcba-eye { transform-box: fill-box; transform-origin: 50% 100%; animation: fcba-blink 4.6s infinite; }
19
+ .fcba-dot { animation: fcba-dot 1.2s infinite; }
20
+ .fcba-talk { transform-box: fill-box; transform-origin: 50% 100%; animation: fcba-talk 0.42s ease-in-out infinite; }
21
+ @media (prefers-reduced-motion: reduce) { .fcba-eye, .fcba-dot, .fcba-talk { animation: none; } }
22
+ `;
23
+ const renderCell = (cell, extra) => (React.createElement("rect", Object.assign({ key: cell.key, x: cell.x, y: cell.y, width: cell.sq, height: cell.sq, rx: cell.rx, fill: cell.fill, stroke: cell.stroke, strokeWidth: cell.strokeWidth }, extra)));
24
+ /**
25
+ * A brow, centred on the origin: a bar whose thickness can slope from one end
26
+ * to the other. The corners are rounded by drawing the outline inset by the
27
+ * corner radius and stroking it back out with round joins.
28
+ */
29
+ const BrowShape = ({ brow, paint }) => {
30
+ const [hLeft, hRight] = brow.side === 'left'
31
+ ? [brow.heightOuter, brow.heightInner]
32
+ : [brow.heightInner, brow.heightOuter];
33
+ const r = Math.min(brow.rx, hLeft / 2, hRight / 2);
34
+ const x = brow.width / 2 - r;
35
+ const yL = hLeft / 2 - r;
36
+ const yR = hRight / 2 - r;
37
+ return (React.createElement("polygon", { points: `${-x},${-yL} ${x},${-yR} ${x},${yR} ${-x},${yL}`, fill: paint, stroke: paint, strokeWidth: r * 2, strokeLinejoin: "round" }));
38
+ };
39
+ /**
40
+ * A Bot's avatar in the brand's "file city" language: the same top-down grid
41
+ * of file squares as {@link FileCityLogo}, on a denser 7×7 grid, where the
42
+ * lit files either spell the Bot's initial(s) or form a face whose
43
+ * `expression` and `look` can follow what the Bot is doing.
44
+ */
45
+ export const FileCityBotAvatar = (_a) => {
46
+ var _b, _c, _d, _e;
47
+ var { size = 44, theme, animated = false, panel = true, hairline: showHairline = false, className, style } = _a, options = __rest(_a, ["size", "theme", "animated", "panel", "hairline", "className", "style"]);
48
+ const uid = useId().replace(/:/g, '');
49
+ const layout = computeBotAvatarLayout(Object.assign(Object.assign({}, options), { color: (_b = options.color) !== null && _b !== void 0 ? _b : theme === null || theme === void 0 ? void 0 : theme.colors.text, background: (_d = (_c = options.background) !== null && _c !== void 0 ? _c : theme === null || theme === void 0 ? void 0 : theme.colors.backgroundSecondary) !== null && _d !== void 0 ? _d : theme === null || theme === void 0 ? void 0 : theme.colors.background }));
50
+ const { cells, view, radius, bgColor, baseColor, expression } = layout;
51
+ const animate = animated && layout.variant === 'face';
52
+ // Offset each Bot's blink so a list of avatars doesn't blink in unison.
53
+ const seedSum = Array.from((_e = options.seed) !== null && _e !== void 0 ? _e : '').reduce((sum, ch) => sum + ch.charCodeAt(0), 0);
54
+ const blinkDelay = `-${((seedSum * 0.37) % 4.6).toFixed(2)}s`;
55
+ const hairline = 0.75;
56
+ return (React.createElement("svg", { width: size, height: size, viewBox: `0 0 ${view} ${view}`, xmlns: "http://www.w3.org/2000/svg", role: "img", "aria-label": layout.label, className: className, style: Object.assign({ display: 'block', flexShrink: 0 }, style) },
57
+ React.createElement("defs", null,
58
+ React.createElement("clipPath", { id: `fcba-${uid}` },
59
+ React.createElement("rect", { x: 0, y: 0, width: view, height: view, rx: radius })),
60
+ animate && React.createElement("style", null, ANIMATION_CSS),
61
+ layout.brows
62
+ .filter((brow) => brow.fillInner !== brow.fillOuter)
63
+ .map((brow) => (
64
+ // Runs along the bar; the inner end is the one nearest the other eye.
65
+ React.createElement("linearGradient", { key: brow.side, id: `fcba-brow-${brow.side}-${uid}`, gradientUnits: "userSpaceOnUse", x1: -brow.width / 2, y1: 0, x2: brow.width / 2, y2: 0 },
66
+ React.createElement("stop", { offset: "0%", stopColor: brow.side === 'left' ? brow.fillOuter : brow.fillInner }),
67
+ React.createElement("stop", { offset: "100%", stopColor: brow.side === 'left' ? brow.fillInner : brow.fillOuter }))))),
68
+ React.createElement("g", { clipPath: `url(#fcba-${uid})` },
69
+ panel && React.createElement("rect", { x: 0, y: 0, width: view, height: view, fill: bgColor }),
70
+ cells.map((cell) => renderCell(cell)),
71
+ layout.eyes.map((eye) => {
72
+ // Closed eyes don't blink; a wink keeps its closed eye shut.
73
+ const blinks = animate && !eye.closed;
74
+ return (
75
+ // The eye is one block. Its position lives on the group so that a
76
+ // change of `look` slides the whole eye, and the blink squashes
77
+ // the block inside it.
78
+ React.createElement("g", { key: eye.side, transform: `translate(${eye.x} ${eye.y})`, style: animate
79
+ ? {
80
+ transform: `translate(${eye.x}px, ${eye.y}px)`,
81
+ transition: 'transform 0.24s cubic-bezier(0.3, 1.3, 0.5, 1)',
82
+ }
83
+ : undefined },
84
+ React.createElement("rect", { x: 0, y: 0, width: eye.width, height: eye.height, rx: eye.rx, fill: eye.fill, className: blinks ? 'fcba-eye' : undefined, style: Object.assign(Object.assign({}, (blinks ? { animationDelay: blinkDelay } : {})), (animate ? { transition: 'height 0.18s ease-out' } : {})) })));
85
+ }),
86
+ layout.brows.map((brow) => {
87
+ // Both brows stay mounted so they can rise, tilt and fade.
88
+ if (!animate && !brow.visible)
89
+ return null;
90
+ return (React.createElement("g", { key: brow.side, transform: `translate(${brow.cx} ${brow.cy}) rotate(${brow.rotate})`, opacity: brow.visible ? 1 : 0, style: animate
91
+ ? {
92
+ transform: `translate(${brow.cx}px, ${brow.cy}px) rotate(${brow.rotate}deg)`,
93
+ transition: 'transform 0.26s cubic-bezier(0.3, 1.5, 0.5, 1), opacity 0.18s ease-out',
94
+ }
95
+ : undefined },
96
+ React.createElement(BrowShape, { brow: brow, paint: brow.fillInner !== brow.fillOuter
97
+ ? `url(#fcba-brow-${brow.side}-${uid})`
98
+ : brow.fill })));
99
+ }),
100
+ layout.mouth.map((file) => {
101
+ // All five mouth files stay mounted; an expression change slides
102
+ // each to its new place and fades the unused ones out.
103
+ if (!animate && !file.visible)
104
+ return null;
105
+ const motion = expression === 'talking' ? 'fcba-talk' : expression === 'thinking' ? 'fcba-dot' : undefined;
106
+ return (React.createElement("g", { key: file.index, transform: `translate(${file.x} ${file.y})`, opacity: file.visible ? 1 : 0, style: animate
107
+ ? {
108
+ transform: `translate(${file.x}px, ${file.y}px)`,
109
+ transition: 'transform 0.26s cubic-bezier(0.3, 1.3, 0.5, 1), opacity 0.18s ease-out',
110
+ }
111
+ : undefined },
112
+ React.createElement("rect", { x: 0, y: 0, width: file.width, height: file.height, rx: file.rx, fill: file.fill, className: animate && file.visible ? motion : undefined, style: animate
113
+ ? {
114
+ transition: 'height 0.2s ease-out',
115
+ animationDelay: motion === 'fcba-dot'
116
+ ? `${file.index * 0.1}s`
117
+ : motion === 'fcba-talk'
118
+ ? `${(file.index % 2) * 0.09}s`
119
+ : undefined,
120
+ }
121
+ : undefined })));
122
+ })),
123
+ panel && showHairline && React.createElement("rect", { x: hairline / 2, y: hairline / 2, width: view - hairline, height: view - hairline, rx: Math.max(0, radius - hairline / 2), fill: "none", stroke: `${baseColor.length === 7 ? baseColor : '#f8fafc'}24`, strokeWidth: hairline })));
124
+ };
@@ -89,6 +89,37 @@ function mix(a, b, t) {
89
89
  .padStart(2, '0');
90
90
  return `#${ch(0)}${ch(1)}${ch(2)}`;
91
91
  }
92
+ /**
93
+ * Build the dev-build ribbon node, or `null` when disabled. A horizontal
94
+ * band rect + centered label, both rotated about a point inset from the
95
+ * chosen corner so the band runs parallel to that corner's diagonal. The
96
+ * rect is far longer than the panel; the panel's clip trims its ends flush
97
+ * with the rounded edge, giving the native "ribbon clipped to the icon" look.
98
+ */
99
+ function buildDevRibbon(option, primaryColor) {
100
+ if (!option)
101
+ return null;
102
+ const cfg = Object.assign({ text: 'dev', corner: 'bottom-right', color: primaryColor, textColor: '#ffffff' }, (option === true ? {} : option));
103
+ const label = cfg.text.toUpperCase();
104
+ // Center of the band, inset `D` from the corner along each axis, and the
105
+ // rotation that lays it parallel to the corner's diagonal. With the panel
106
+ // rounded, the band reads as a banner across the corner; its outward end
107
+ // is clipped by the squircle edge.
108
+ const D = 16; // band-center inset from the corner
109
+ const THICK = 22; // band thickness
110
+ const LEN = VIEW * 2; // overhang, trimmed by the panel clip
111
+ const CORNERS = {
112
+ 'bottom-right': { cx: VIEW - D, cy: VIEW - D, rot: -45 },
113
+ 'bottom-left': { cx: D, cy: VIEW - D, rot: 45 },
114
+ 'top-right': { cx: VIEW - D, cy: D, rot: 45 },
115
+ 'top-left': { cx: D, cy: D, rot: -45 },
116
+ };
117
+ const { cx, cy, rot } = CORNERS[cfg.corner];
118
+ const fontSize = THICK * 0.5;
119
+ return (React.createElement("g", { key: "dev-ribbon", transform: `rotate(${rot} ${cx} ${cy})`, style: { pointerEvents: 'none' } },
120
+ React.createElement("rect", { x: cx - LEN / 2, y: cy - THICK / 2, width: LEN, height: THICK, fill: cfg.color, stroke: withAlpha('#000000', 0.18), strokeWidth: 0.6 }),
121
+ React.createElement("text", { x: cx, y: cy, textAnchor: "middle", dominantBaseline: "central", fontFamily: "system-ui, -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif", fontWeight: 700, fontSize: fontSize, letterSpacing: "0.14em", fill: cfg.textColor }, label)));
122
+ }
92
123
  /**
93
124
  * Compute the full layout (cells + overlays + palette) for a file-city
94
125
  * mark from the public props. Pure — no hooks — so both the static and
@@ -98,7 +129,7 @@ export function computeFileCityLayout({ mark = 'P', primary, accent, color, back
98
129
  // Slight global translucency gives the mark a faded "film" quality and
99
130
  // keeps the muted city from competing with the P. Restored after a
100
131
  // brief de-haze experiment that made the city too present.
101
- opacity = 0.9, gloss = false, squareRadius = 0, }) {
132
+ opacity = 0.9, gloss = false, squareRadius = 0, devRibbon = false, }) {
102
133
  var _a, _b, _c, _d, _e;
103
134
  const primaryColor = (_a = primary !== null && primary !== void 0 ? primary : theme === null || theme === void 0 ? void 0 : theme.colors.primary) !== null && _a !== void 0 ? _a : '#22d3ee';
104
135
  const accentColor = (_b = accent !== null && accent !== void 0 ? accent : theme === null || theme === void 0 ? void 0 : theme.colors.accent) !== null && _b !== void 0 ? _b : primaryColor;
@@ -387,7 +418,8 @@ opacity = 0.9, gloss = false, squareRadius = 0, }) {
387
418
  extras.push(React.createElement("circle", { key: `trail-dot-${i}`, cx: p.x, cy: p.y, r: dot, fill: mix(accentColor, '#ffffff', 0.15), stroke: bgColor, strokeWidth: 0.5 }));
388
419
  });
389
420
  }
390
- return { cells: cellsOut, extras, bgColor, baseColor, rounded, opacity, mark, gloss };
421
+ const ribbon = buildDevRibbon(devRibbon, primaryColor);
422
+ return { cells: cellsOut, extras, ribbon, bgColor, baseColor, rounded, opacity, mark, gloss };
391
423
  }
392
424
  /** Accessible label for a given mark, shared by both components. */
393
425
  export function fileCityLabel(mark) {
@@ -400,7 +432,7 @@ export function fileCityLabel(mark) {
400
432
  * rounded background panel (clipping its children) and the edge hairline.
401
433
  * `children` are the grid + overlays drawn inside the clip.
402
434
  */
403
- export const FileCityPanel = ({ width, height, bgColor, baseColor, rounded, opacity, label, gloss = false, children }) => {
435
+ export const FileCityPanel = ({ width, height, bgColor, baseColor, rounded, opacity, label, gloss = false, ribbon = null, children }) => {
404
436
  const uid = useId().replace(/:/g, '');
405
437
  // Normalize the gloss option → a config (or null when flat). `true`
406
438
  // means "use all defaults"; an object overrides individual fields.
@@ -436,7 +468,8 @@ export const FileCityPanel = ({ width, height, bgColor, baseColor, rounded, opac
436
468
  children,
437
469
  g && (React.createElement("g", { style: { pointerEvents: 'none' } },
438
470
  React.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, fill: `url(#gloss-top-${uid})` }),
439
- g.glint && (React.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, fill: `url(#gloss-spec-${uid})` }))))),
471
+ g.glint && (React.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, fill: `url(#gloss-spec-${uid})` })))),
472
+ ribbon),
440
473
  React.createElement("rect", { x: HAIRLINE / 2, y: HAIRLINE / 2, width: VIEW - HAIRLINE, height: VIEW - HAIRLINE, rx: rounded ? Math.max(0, PANEL_RADIUS - HAIRLINE / 2) : 0, fill: "none", stroke: withAlpha(baseColor, 0.14), strokeWidth: HAIRLINE })));
441
474
  };
442
475
  /**
@@ -448,8 +481,8 @@ export const FileCityPanel = ({ width, height, bgColor, baseColor, rounded, opac
448
481
  */
449
482
  export const FileCityLogo = (props) => {
450
483
  const { width = 150, height = 150 } = props;
451
- const { cells, extras, bgColor, baseColor, rounded, opacity, mark, gloss } = computeFileCityLayout(props);
452
- return (React.createElement(FileCityPanel, { width: width, height: height, bgColor: bgColor, baseColor: baseColor, rounded: rounded, opacity: opacity, gloss: gloss, label: fileCityLabel(mark) },
484
+ const { cells, extras, ribbon, bgColor, baseColor, rounded, opacity, mark, gloss } = computeFileCityLayout(props);
485
+ return (React.createElement(FileCityPanel, { width: width, height: height, bgColor: bgColor, baseColor: baseColor, rounded: rounded, opacity: opacity, gloss: gloss, ribbon: ribbon, label: fileCityLabel(mark) },
453
486
  cells.map((cell) => (React.createElement("rect", { key: cell.key, x: cell.x, y: cell.y, width: cell.sq, height: cell.sq, rx: cell.rx, fill: cell.fill, stroke: cell.stroke, strokeWidth: cell.strokeWidth }))),
454
487
  extras));
455
488
  };