@principal-ai/logo-component 0.1.22 → 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,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
  };
@@ -1,5 +1,37 @@
1
1
  import React, { useEffect, useId, useMemo, useRef, useState } from 'react';
2
2
  import { computeFileCityLayout, fileCityLabel, FileCityPanel, } from './FileCityLogo';
3
+ // Each lit file of the P and the face square it slides to, as [col, row] on
4
+ // the 7×7 grid. The P has ten files and the face needs eleven (two 2×2 eyes
5
+ // and a three-file mouth), so the last one starts stacked on the P's foot.
6
+ const FACE_MOVES = [
7
+ { home: [2, 1], face: [1, 1], part: 'eyeL' },
8
+ { home: [3, 1], face: [2, 1], part: 'eyeL' },
9
+ { home: [2, 2], face: [1, 2], part: 'eyeL' },
10
+ { home: [2, 3], face: [2, 2], part: 'eyeL' },
11
+ { home: [4, 1], face: [5, 1], part: 'eyeR' },
12
+ { home: [4, 2], face: [5, 2], part: 'eyeR' },
13
+ { home: [3, 3], face: [4, 1], part: 'eyeR' },
14
+ { home: [4, 3], face: [4, 2], part: 'eyeR' },
15
+ { home: [2, 4], face: [2, 5], part: 'mouth' },
16
+ { home: [2, 5], face: [3, 5], part: 'mouth' },
17
+ { home: [2, 5], face: [4, 5], part: 'mouth' },
18
+ ];
19
+ // The smile's upturned corners, which pop in beside the mouth.
20
+ const SMILE_CORNERS = [
21
+ [1, 4],
22
+ [5, 4],
23
+ ];
24
+ function lighten(color, t) {
25
+ if (!/^#[0-9a-f]{6}$/i.test(color))
26
+ return color;
27
+ const ch = (i) => {
28
+ const v = parseInt(color.slice(1 + i * 2, 3 + i * 2), 16);
29
+ return Math.round(v + (255 - v) * t)
30
+ .toString(16)
31
+ .padStart(2, '0');
32
+ };
33
+ return `#${ch(0)}${ch(1)}${ch(2)}`;
34
+ }
3
35
  // CSS keyframe name for the connector draw-on. CSS animations restart on
4
36
  // element remount (unlike SMIL's document-timeline `begin`), so each group's
5
37
  // freshly-keyed connector draws from the start.
@@ -27,12 +59,14 @@ function mulberry32(seed) {
27
59
  export const FileCityLogoAnimated = (props) => {
28
60
  var _a, _b, _c, _d, _e, _f, _g;
29
61
  const uid = useId().replace(/:/g, '');
30
- const { width = 150, height = 150, batchMin = 5, batchMax = 10, cellMs = 185, pauseMs = 900, buildSteps = 1, connectors = true, connectorColor, autoPlay = true, playKey, onComplete, } = props;
62
+ const { width = 150, height = 150, batchMin = 5, batchMax = 10, cellMs = 185, pauseMs = 900, buildSteps = 1, connectors = true, connectorColor, autoPlay = true, playKey, onComplete, face: faceMode = 'none', } = props;
63
+ const watch = faceMode === 'watch';
64
+ const wake = faceMode === 'wake';
31
65
  // The trail line is a light grey (close to white); the nodes it threads
32
66
  // to are marked with accent-colored dots so the destinations pop.
33
67
  const trailColor = connectorColor !== null && connectorColor !== void 0 ? connectorColor : '#e5e7eb';
34
68
  const dotColor = (_f = (_d = (_c = (_a = props.accent) !== null && _a !== void 0 ? _a : (_b = props.theme) === null || _b === void 0 ? void 0 : _b.colors.accent) !== null && _c !== void 0 ? _c : props.primary) !== null && _d !== void 0 ? _d : (_e = props.theme) === null || _e === void 0 ? void 0 : _e.colors.primary) !== null && _f !== void 0 ? _f : '#22d3ee';
35
- const { cells, extras, bgColor, baseColor, rounded, opacity, mark, gloss } = useMemo(() => computeFileCityLayout(props),
69
+ const { cells, extras, ribbon, bgColor, baseColor, rounded, opacity, mark, gloss } = useMemo(() => computeFileCityLayout(props),
36
70
  // Re-derive only when an input that affects layout changes.
37
71
  // eslint-disable-next-line react-hooks/exhaustive-deps
38
72
  [
@@ -52,6 +86,7 @@ export const FileCityLogoAnimated = (props) => {
52
86
  props.opacity,
53
87
  props.gloss,
54
88
  props.squareRadius,
89
+ props.devRibbon,
55
90
  ]);
56
91
  // Per-cell number of samples to fully reveal it (>=1; letter cells take
57
92
  // `buildSteps`, city cells proportionally fewer by their weight).
@@ -84,6 +119,65 @@ export const FileCityLogoAnimated = (props) => {
84
119
  // walked the animation is done and the logo holds.
85
120
  const [progress, setProgress] = useState(() => cells.map(() => 0));
86
121
  const [done, setDone] = useState(false);
122
+ // The sheen used to start the moment the build finished; with a watching
123
+ // face it waits until the face has merged into the P.
124
+ const [sheen, setSheen] = useState(false);
125
+ const [face, setFace] = useState(null);
126
+ // Which way the eyes are looking, in grid squares.
127
+ const [look, setLook] = useState([0, 0]);
128
+ // Face geometry — only for the plain centred P on its 7×7 grid, where the
129
+ // face's squares line up with the logo's.
130
+ const faceGeo = useMemo(() => {
131
+ var _a, _b, _c;
132
+ if (faceMode === 'none' || mark !== 'P' || cells.length < 2)
133
+ return null;
134
+ const letters = cells.filter((cell) => cell.isLetter);
135
+ const side = Math.max(...cells.map((cell) => cell.c)) + 1;
136
+ const minC = Math.min(...letters.map((cell) => cell.c));
137
+ const minR = Math.min(...letters.map((cell) => cell.r));
138
+ // The face is authored with the P at column 2, row 1 (the 7×7 logo).
139
+ // Shift it to wherever the P actually sits — e.g. the edge-to-edge 5×5
140
+ // `margin={0}` mark — and bail if it wouldn't fit on the grid.
141
+ const dc = minC - 2;
142
+ const dr = minR - 1;
143
+ const fits = [...FACE_MOVES.map((m) => m.face), ...SMILE_CORNERS].every(([c, r]) => c + dc >= 0 && c + dc < side && r + dr >= 0 && r + dr < side);
144
+ const isPlainP = FACE_MOVES.every((m) => letters.some((l) => l.c === m.home[0] + dc && l.r === m.home[1] + dr));
145
+ if (letters.length !== 10 || !fits || !isPlainP)
146
+ return null;
147
+ const a = cells[0];
148
+ const b = cells.find((cell) => cell.c !== a.c);
149
+ const pitch = (b.x - a.x) / (b.c - a.c);
150
+ const at = (c, r) => ({
151
+ x: a.x + (c + dc - a.c) * pitch,
152
+ y: a.y + (r + dr - a.r) * pitch,
153
+ });
154
+ const primary = (_c = (_a = props.primary) !== null && _a !== void 0 ? _a : (_b = props.theme) === null || _b === void 0 ? void 0 : _b.colors.primary) !== null && _c !== void 0 ? _c : '#22d3ee';
155
+ const tiles = FACE_MOVES.map((move, i) => {
156
+ const cell = letters.find((l) => l.c === move.home[0] + dc && l.r === move.home[1] + dr);
157
+ return {
158
+ key: `face-${i}`,
159
+ part: move.part,
160
+ home: at(...move.home),
161
+ face: at(...move.face),
162
+ fill: cell.fill,
163
+ stroke: cell.stroke,
164
+ strokeWidth: cell.strokeWidth,
165
+ };
166
+ });
167
+ const block = (c) => (Object.assign(Object.assign({}, at(c, 1)), { size: pitch + a.sq }));
168
+ return {
169
+ pitch,
170
+ sq: a.sq,
171
+ rx: a.rx,
172
+ tiles,
173
+ eyeColor: lighten(primary, 0.6),
174
+ // Match the mouth's own files, which carry the P's gradient shade.
175
+ mouthColor: tiles[tiles.length - 1].fill,
176
+ eyes: { eyeL: block(1), eyeR: block(4) },
177
+ corners: SMILE_CORNERS.map(([c, r]) => at(c, r)),
178
+ };
179
+ // eslint-disable-next-line react-hooks/exhaustive-deps
180
+ }, [cells, mark, faceMode, props.primary, props.theme]);
87
181
  // The connector for the active group: which group it traces, and whether
88
182
  // it's drawing on (during the reveal) or fading out (during the pause).
89
183
  const [conn, setConn] = useState(null);
@@ -104,14 +198,34 @@ export const FileCityLogoAnimated = (props) => {
104
198
  setProgress(cells.map(() => 0));
105
199
  setConn(null);
106
200
  setDone(false);
201
+ setSheen(false);
202
+ setLook([0, 0]);
203
+ setFace(null);
107
204
  if (!autoPlay || cells.length === 0 || reduce) {
108
205
  setProgress(stepsFor.slice());
109
206
  setDone(true);
207
+ setSheen(true);
110
208
  (_a = onCompleteRef.current) === null || _a === void 0 ? void 0 : _a.call(onCompleteRef);
111
209
  return;
112
210
  }
113
211
  let timer;
114
212
  let fadeTimer;
213
+ let blinkTimer;
214
+ let enterTimer;
215
+ // The watching face is on stage before the first file appears.
216
+ if (watch && faceGeo) {
217
+ setFace({
218
+ at: 'face',
219
+ blocks: true,
220
+ mouth: false,
221
+ smile: false,
222
+ blink: false,
223
+ wink: false,
224
+ visible: false,
225
+ hideLetters: false,
226
+ });
227
+ enterTimer = setTimeout(() => setFace((f) => f && Object.assign(Object.assign({}, f), { visible: true })), 40);
228
+ }
115
229
  // Hold the finished trail on screen before it fades, so the completed
116
230
  // group lingers a beat. Keep linger + fade within the pause.
117
231
  const lingerMs = Math.max(0, Math.min(pauseMs - fadeMs - 40, 450));
@@ -128,6 +242,14 @@ export const FileCityLogoAnimated = (props) => {
128
242
  const group = groups[gi];
129
243
  const mi = memberRef.current;
130
244
  const idx = group[mi];
245
+ // The eyes turn once per group, towards where most of it is, rather
246
+ // than darting to every file as it lights up.
247
+ if (watch && faceGeo && mi === 0) {
248
+ const c = group.reduce((sum, i) => sum + cells[i].c, 0) / group.length;
249
+ const r = group.reduce((sum, i) => sum + cells[i].r, 0) / group.length;
250
+ const mid = (Math.max(...cells.map((cell) => cell.c)) + 0) / 2;
251
+ setLook([c < mid - 0.4 ? -1 : c > mid + 0.4 ? 1 : 0, r < mid - 0.6 ? -1 : r > mid + 0.6 ? 1 : 0]);
252
+ }
131
253
  setProgress((prev) => {
132
254
  const next = prev.slice();
133
255
  next[idx] = Math.min(stepsFor[idx], next[idx] + 1);
@@ -141,6 +263,11 @@ export const FileCityLogoAnimated = (props) => {
141
263
  // The trail is fully drawn — hold it for `lingerMs`, then flip to
142
264
  // fading so it dissolves before the next group begins.
143
265
  fadeTimer = setTimeout(() => setConn({ group: gi, fading: true }), lingerMs);
266
+ // …and blink once the group is done.
267
+ if (watch && faceGeo) {
268
+ setFace((f) => f && Object.assign(Object.assign({}, f), { blink: true }));
269
+ blinkTimer = setTimeout(() => setFace((f) => f && Object.assign(Object.assign({}, f), { blink: false })), 140);
270
+ }
144
271
  groupRef.current = gi + 1;
145
272
  memberRef.current = 0;
146
273
  timer = setTimeout(step, pauseMs);
@@ -154,9 +281,69 @@ export const FileCityLogoAnimated = (props) => {
154
281
  return () => {
155
282
  clearTimeout(timer);
156
283
  clearTimeout(fadeTimer);
284
+ clearTimeout(blinkTimer);
285
+ clearTimeout(enterTimer);
157
286
  };
158
287
  // eslint-disable-next-line react-hooks/exhaustive-deps
159
- }, [cells, groups, stepsFor, cellMs, pauseMs, autoPlay, playKey]);
288
+ }, [cells, groups, stepsFor, cellMs, pauseMs, autoPlay, playKey, watch, faceGeo]);
289
+ // Everything after the build: the watching face merges into the P, the
290
+ // sheen plays, then (for `wake`) the P turns into a face and back.
291
+ useEffect(() => {
292
+ if (!done)
293
+ return;
294
+ const reduce = typeof window !== 'undefined' &&
295
+ window.matchMedia &&
296
+ window.matchMedia('(prefers-reduced-motion: reduce)').matches;
297
+ if (!faceGeo || reduce || !autoPlay) {
298
+ setFace(null);
299
+ setSheen(true);
300
+ return;
301
+ }
302
+ const timers = [];
303
+ let t = 0;
304
+ const at = (delay, fn) => {
305
+ t += delay;
306
+ timers.push(setTimeout(fn, t));
307
+ };
308
+ const pose = (patch) => setFace((f) => f && Object.assign(Object.assign({}, f), patch));
309
+ if (watch) {
310
+ // The eyes settle, blink once at the finished mark, then their files
311
+ // slide home into the P.
312
+ setLook([0, 0]);
313
+ pose({ blink: false });
314
+ at(650, () => pose({ blink: true }));
315
+ at(150, () => pose({ blink: false }));
316
+ at(350, () => pose({ blocks: false, at: 'home' }));
317
+ at(700, () => setFace(null));
318
+ }
319
+ // The waking face is the flourish for `wake`, so it skips the sheen.
320
+ if (!wake)
321
+ at(0, () => setSheen(true));
322
+ if (wake) {
323
+ // A beat on the finished mark, then stand-in files take over from the
324
+ // P's own and slide into a face.
325
+ at(700, () => setFace({
326
+ at: 'home',
327
+ blocks: false,
328
+ mouth: true,
329
+ smile: false,
330
+ blink: false,
331
+ wink: false,
332
+ visible: true,
333
+ hideLetters: true,
334
+ }));
335
+ at(60, () => pose({ at: 'face' }));
336
+ at(600, () => pose({ blocks: true, smile: true }));
337
+ at(700, () => pose({ blink: true }));
338
+ at(140, () => pose({ blink: false }));
339
+ at(600, () => pose({ wink: true }));
340
+ at(420, () => pose({ wink: false }));
341
+ at(650, () => pose({ blocks: false, smile: false, at: 'home' }));
342
+ at(700, () => setFace(null));
343
+ }
344
+ return () => timers.forEach(clearTimeout);
345
+ // eslint-disable-next-line react-hooks/exhaustive-deps
346
+ }, [done, playKey, faceGeo, watch, wake, autoPlay]);
160
347
  // Easing for the per-cell fill-in so each sample lands softly.
161
348
  const ease = (t) => 1 - Math.pow(1 - t, 2);
162
349
  // Connector geometry — the full path through the active group's cell
@@ -205,6 +392,9 @@ export const FileCityLogoAnimated = (props) => {
205
392
  const reveal = done ? 1 : ease(progress[i] / stepsFor[i]);
206
393
  if (reveal <= 0)
207
394
  return null;
395
+ // While the stand-in files are performing, they are the P.
396
+ if (cell.isLetter && (face === null || face === void 0 ? void 0 : face.hideLetters))
397
+ return null;
208
398
  return (React.createElement("rect", { key: cell.key, x: cell.x, y: cell.y, width: cell.sq, height: cell.sq, rx: cell.rx, fill: cell.fill, fillOpacity: reveal, stroke: cell.stroke, strokeWidth: cell.strokeWidth, strokeOpacity: reveal }));
209
399
  };
210
400
  const showTrail = connectors && connectorPath && conn && !done;
@@ -234,12 +424,52 @@ export const FileCityLogoAnimated = (props) => {
234
424
  animation: `${DOT_POP} 220ms ease-out ${delay}ms both`,
235
425
  } }));
236
426
  }))) : null;
237
- return (React.createElement(FileCityPanel, { width: width, height: height, bgColor: bgColor, baseColor: baseColor, rounded: rounded, opacity: opacity, gloss: gloss, label: fileCityLabel(mark) },
427
+ // The face: eleven files that slide between the P's squares and the face's,
428
+ // a solid block over each eye, and the smile's two corner files.
429
+ const slide = 'cubic-bezier(0.3, 1.25, 0.5, 1)';
430
+ const faceLayer = face && faceGeo ? (React.createElement("g", { style: { opacity: face.visible ? 1 : 0, transition: 'opacity 320ms ease', pointerEvents: 'none' } },
431
+ faceGeo.tiles.map((tile, i) => {
432
+ const pos = face.at === 'face' ? tile.face : tile.home;
433
+ const isEye = tile.part !== 'mouth';
434
+ const covered = isEye && face.blocks;
435
+ return (React.createElement("rect", { key: tile.key, x: 0, y: 0, width: faceGeo.sq, height: faceGeo.sq, rx: faceGeo.rx, stroke: tile.stroke, strokeWidth: tile.strokeWidth, style: {
436
+ transform: `translate(${pos.x}px, ${pos.y}px)`,
437
+ fill: face.at === 'face' && isEye ? faceGeo.eyeColor : tile.fill,
438
+ opacity: covered || (!isEye && !face.mouth) ? 0 : 1,
439
+ // Hide under the eye block only once it has faded in.
440
+ transition: `transform 560ms ${slide} ${i * 22}ms, fill 420ms ease ${i * 22}ms, opacity 0ms linear ${covered ? 170 : 0}ms`,
441
+ } }));
442
+ }),
443
+ React.createElement("g", { style: {
444
+ transform: `translate(${look[0] * faceGeo.pitch}px, ${look[1] * faceGeo.pitch}px)`,
445
+ // A slow, even glide — no snap or overshoot.
446
+ transition: 'transform 700ms cubic-bezier(0.45, 0, 0.25, 1)',
447
+ } }, ['eyeL', 'eyeR'].map((key) => {
448
+ const eye = faceGeo.eyes[key];
449
+ const shut = face.blink || (face.wink && key === 'eyeR');
450
+ return (React.createElement("rect", { key: key, x: eye.x, y: eye.y, width: eye.size, height: eye.size, rx: Math.max(faceGeo.rx, faceGeo.sq * 0.14), fill: faceGeo.eyeColor, style: {
451
+ opacity: face.blocks ? 1 : 0,
452
+ transformBox: 'fill-box',
453
+ transformOrigin: '50% 100%',
454
+ transform: `scaleY(${shut ? 0.16 : 1})`,
455
+ transition: 'opacity 170ms ease, transform 110ms ease-out',
456
+ } }));
457
+ })),
458
+ faceGeo.corners.map((corner, i) => (React.createElement("rect", { key: `corner-${i}`, x: corner.x, y: corner.y, width: faceGeo.sq, height: faceGeo.sq, rx: faceGeo.rx, fill: faceGeo.mouthColor, style: {
459
+ opacity: face.smile ? 1 : 0,
460
+ transformBox: 'fill-box',
461
+ transformOrigin: 'center',
462
+ transform: `scale(${face.smile ? 1 : 0.3})`,
463
+ transition: `opacity 200ms ease, transform 260ms ${slide}`,
464
+ } }))))) : null;
465
+ return (React.createElement(FileCityPanel, { width: width, height: height, bgColor: bgColor, baseColor: baseColor, rounded: rounded, opacity: opacity, gloss: gloss, ribbon: ribbon, label: fileCityLabel(mark) },
466
+ face && !face.hideLetters ? faceLayer : null,
238
467
  cells.map((cell, i) => renderCell(cell, i)),
468
+ face && face.hideLetters ? faceLayer : null,
239
469
  trailLine,
240
470
  trailDots,
241
471
  done ? extras : null,
242
- done ? (React.createElement(React.Fragment, null,
472
+ sheen ? (React.createElement(React.Fragment, null,
243
473
  React.createElement("style", null, `@keyframes ${SHEEN}{from{transform:translateX(-120px)}to{transform:translateX(120px)}}`),
244
474
  React.createElement("defs", null,
245
475
  React.createElement("clipPath", { id: `sheen-clip-${uid}` }, cells.map((cell) => (React.createElement("rect", { key: cell.key, x: cell.x, y: cell.y, width: cell.sq, height: cell.sq, rx: cell.rx })))),