ochreui 0.0.0-stage → 0.0.2

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.
Files changed (168) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +153 -2
  3. package/cli/ochreui.mjs +601 -0
  4. package/mcp/core.mjs +126 -0
  5. package/mcp/docs.json +906 -0
  6. package/mcp/server.mjs +23 -0
  7. package/package.json +393 -3
  8. package/registry/agent-team.ts +350 -0
  9. package/registry/avatar.ts +300 -0
  10. package/registry/badge.ts +207 -0
  11. package/registry/breadcrumb.ts +435 -0
  12. package/registry/button.ts +238 -0
  13. package/registry/card.ts +221 -0
  14. package/registry/change-summary.ts +200 -0
  15. package/registry/checkbox.ts +204 -0
  16. package/registry/code-block.ts +332 -0
  17. package/registry/color-picker.ts +720 -0
  18. package/registry/comment-thread.ts +503 -0
  19. package/registry/context-menu.ts +281 -0
  20. package/registry/cover-flow.ts +623 -0
  21. package/registry/date-picker.ts +799 -0
  22. package/registry/decision-inbox.ts +340 -0
  23. package/registry/dialog.ts +577 -0
  24. package/registry/dropdown-menu.ts +864 -0
  25. package/registry/email-draft.ts +916 -0
  26. package/registry/empty-calendar.ts +199 -0
  27. package/registry/empty-state.ts +164 -0
  28. package/registry/enrichment-orbit.ts +164 -0
  29. package/registry/filter-menu.ts +541 -0
  30. package/registry/form-field.ts +308 -0
  31. package/registry/frost-cloud.ts +381 -0
  32. package/registry/ghosted-chat.ts +210 -0
  33. package/registry/glow-cloud.ts +402 -0
  34. package/registry/grid-background.ts +164 -0
  35. package/registry/hover-card.ts +401 -0
  36. package/registry/icon-button.ts +133 -0
  37. package/registry/index.json +2124 -0
  38. package/registry/integration-beam.ts +588 -0
  39. package/registry/integration-grid.ts +209 -0
  40. package/registry/kbd.ts +176 -0
  41. package/registry/layer-stack.ts +351 -0
  42. package/registry/lead-sourcing.ts +285 -0
  43. package/registry/logo-cluster.ts +239 -0
  44. package/registry/logo-marquee.ts +505 -0
  45. package/registry/message-actions.ts +833 -0
  46. package/registry/model-orbit.ts +583 -0
  47. package/registry/model-wheel.ts +372 -0
  48. package/registry/notification-stack.ts +301 -0
  49. package/registry/number-input.ts +552 -0
  50. package/registry/number-ticker.ts +261 -0
  51. package/registry/ochre.css +917 -0
  52. package/registry/otp-input.ts +704 -0
  53. package/registry/overlay.ts +312 -0
  54. package/registry/pagination.ts +362 -0
  55. package/registry/popover.ts +296 -0
  56. package/registry/profile-menu.ts +332 -0
  57. package/registry/progress-tracker.ts +291 -0
  58. package/registry/rating.ts +461 -0
  59. package/registry/reaction-bar.ts +322 -0
  60. package/registry/region-map.ts +537 -0
  61. package/registry/resizable.ts +489 -0
  62. package/registry/scroll-area.ts +271 -0
  63. package/registry/segmented-control.ts +433 -0
  64. package/registry/select.ts +769 -0
  65. package/registry/separator.ts +97 -0
  66. package/registry/shimmer-loader.ts +211 -0
  67. package/registry/side-folder.ts +152 -0
  68. package/registry/skeleton.ts +136 -0
  69. package/registry/skill/INSTRUCTIONS.md +11 -0
  70. package/registry/skill/SKILL.md +65 -0
  71. package/registry/skill/checklist.md +45 -0
  72. package/registry/skill/references/agent-team.md +105 -0
  73. package/registry/skill/references/avatar.md +88 -0
  74. package/registry/skill/references/badge.md +92 -0
  75. package/registry/skill/references/breadcrumb.md +99 -0
  76. package/registry/skill/references/button.md +82 -0
  77. package/registry/skill/references/card.md +111 -0
  78. package/registry/skill/references/catalog.md +114 -0
  79. package/registry/skill/references/change-summary.md +103 -0
  80. package/registry/skill/references/checkbox.md +105 -0
  81. package/registry/skill/references/code-block.md +109 -0
  82. package/registry/skill/references/color-picker.md +138 -0
  83. package/registry/skill/references/comment-thread.md +164 -0
  84. package/registry/skill/references/context-menu.md +205 -0
  85. package/registry/skill/references/cover-flow.md +128 -0
  86. package/registry/skill/references/date-picker.md +154 -0
  87. package/registry/skill/references/decision-inbox.md +126 -0
  88. package/registry/skill/references/dialog.md +155 -0
  89. package/registry/skill/references/dropdown-menu.md +144 -0
  90. package/registry/skill/references/email-draft.md +182 -0
  91. package/registry/skill/references/empty-calendar.md +74 -0
  92. package/registry/skill/references/empty-state.md +118 -0
  93. package/registry/skill/references/enrichment-orbit.md +71 -0
  94. package/registry/skill/references/filter-menu.md +143 -0
  95. package/registry/skill/references/form-field.md +118 -0
  96. package/registry/skill/references/frost-cloud.md +80 -0
  97. package/registry/skill/references/ghosted-chat.md +75 -0
  98. package/registry/skill/references/glow-cloud.md +84 -0
  99. package/registry/skill/references/grid-background.md +76 -0
  100. package/registry/skill/references/hover-card.md +125 -0
  101. package/registry/skill/references/icon-button.md +99 -0
  102. package/registry/skill/references/integration-beam.md +107 -0
  103. package/registry/skill/references/integration-grid.md +100 -0
  104. package/registry/skill/references/kbd.md +65 -0
  105. package/registry/skill/references/layer-stack.md +115 -0
  106. package/registry/skill/references/lead-sourcing.md +92 -0
  107. package/registry/skill/references/logo-cluster.md +92 -0
  108. package/registry/skill/references/logo-marquee.md +123 -0
  109. package/registry/skill/references/message-actions.md +146 -0
  110. package/registry/skill/references/model-orbit.md +106 -0
  111. package/registry/skill/references/model-wheel.md +84 -0
  112. package/registry/skill/references/notification-stack.md +138 -0
  113. package/registry/skill/references/number-input.md +117 -0
  114. package/registry/skill/references/number-ticker.md +73 -0
  115. package/registry/skill/references/otp-input.md +142 -0
  116. package/registry/skill/references/pagination.md +112 -0
  117. package/registry/skill/references/popover.md +143 -0
  118. package/registry/skill/references/profile-menu.md +123 -0
  119. package/registry/skill/references/progress-tracker.md +122 -0
  120. package/registry/skill/references/rating.md +111 -0
  121. package/registry/skill/references/reaction-bar.md +128 -0
  122. package/registry/skill/references/region-map.md +109 -0
  123. package/registry/skill/references/resizable.md +127 -0
  124. package/registry/skill/references/scroll-area.md +113 -0
  125. package/registry/skill/references/segmented-control.md +96 -0
  126. package/registry/skill/references/select.md +122 -0
  127. package/registry/skill/references/separator.md +69 -0
  128. package/registry/skill/references/shimmer-loader.md +83 -0
  129. package/registry/skill/references/side-folder.md +75 -0
  130. package/registry/skill/references/skeleton.md +95 -0
  131. package/registry/skill/references/smart-recommendation.md +132 -0
  132. package/registry/skill/references/spinner.md +84 -0
  133. package/registry/skill/references/switch.md +79 -0
  134. package/registry/skill/references/tab-overload.md +70 -0
  135. package/registry/skill/references/tag-input.md +126 -0
  136. package/registry/skill/references/team-invite.md +94 -0
  137. package/registry/skill/references/testimonial-wall.md +110 -0
  138. package/registry/skill/references/text-area.md +115 -0
  139. package/registry/skill/references/text-field.md +126 -0
  140. package/registry/skill/references/text-reveal.md +71 -0
  141. package/registry/skill/references/thinking-loader.md +87 -0
  142. package/registry/skill/references/time-picker.md +122 -0
  143. package/registry/skill/references/tips-panel.md +115 -0
  144. package/registry/skill/references/toggle-group.md +98 -0
  145. package/registry/skill/references/tool-call-card.md +151 -0
  146. package/registry/skill/references/tooltip.md +94 -0
  147. package/registry/skill/references/tree-view.md +172 -0
  148. package/registry/skill/theming.md +57 -0
  149. package/registry/smart-recommendation.ts +415 -0
  150. package/registry/spinner.ts +67 -0
  151. package/registry/switch.ts +146 -0
  152. package/registry/tab-overload.ts +211 -0
  153. package/registry/tag-input.ts +620 -0
  154. package/registry/team-invite.ts +248 -0
  155. package/registry/testimonial-wall.ts +521 -0
  156. package/registry/text-area.ts +432 -0
  157. package/registry/text-field.ts +415 -0
  158. package/registry/text-reveal.ts +175 -0
  159. package/registry/theme.ts +68 -0
  160. package/registry/thinking-loader.ts +302 -0
  161. package/registry/time-picker.ts +828 -0
  162. package/registry/tips-panel.ts +312 -0
  163. package/registry/toggle-group.ts +357 -0
  164. package/registry/tool-call-card.ts +578 -0
  165. package/registry/tooltip.ts +486 -0
  166. package/registry/tree-view.ts +454 -0
  167. package/styles/base.css +500 -0
  168. package/styles/tokens.css +415 -0
@@ -0,0 +1,350 @@
1
+ // Ochre (https://ochreui.dev), MIT License, Copyright (c) 2026 Ochre. Keep this notice in copies of this file.
2
+ /**
3
+ * Agent Team, from Ochre (https://ochreui.dev).
4
+ * Needs ochre.css (`npx ochreui init`).
5
+ *
6
+ * <ui-agent-team prompt="Set up a crew to clear my support queue" [members]="members" />
7
+ * A decorative looping scene: a prompt types itself, then three agents pop in with a role and tools.
8
+ * It scales as one picture (3 : 2, at most 560px wide) and stays still with reduced motion.
9
+ *
10
+ * Public styling hooks (set them on the element or any ancestor):
11
+ * --ui-agent-team-surface pill, avatar ring and chip fill (default: the surface)
12
+ * --ui-agent-team-ink prompt and role text (default: the text colour)
13
+ * --ui-agent-team-line dashed lines (default: the border colour)
14
+ * --ui-agent-team-accent send button (default: the accent)
15
+ * --ui-agent-team-dot status dot (default: green)
16
+ * --ui-agent-team-glow-a glow at the inline start (default: a faint pink)
17
+ * --ui-agent-team-glow-b glow at the inline end (default: a faint violet)
18
+ * --ui-agent-team-tool-bg tool discs (default: white in both themes)
19
+ */
20
+ import {
21
+ Component,
22
+ DOCUMENT,
23
+ DestroyRef,
24
+ ElementRef,
25
+ PLATFORM_ID,
26
+ afterNextRender,
27
+ computed,
28
+ effect,
29
+ inject,
30
+ input,
31
+ isDevMode,
32
+ signal,
33
+ } from '@angular/core';
34
+ import { isPlatformBrowser } from '@angular/common';
35
+
36
+ export type AgentTeamTool = 'mail' | 'chat' | 'crm' | 'calendar' | 'search' | 'docs';
37
+
38
+ export interface AgentTeamMember {
39
+ /** The role under the avatar, one line. */
40
+ role: string;
41
+ /** An image URL. Left out, the agent gets one of three drawn avatars. */
42
+ avatar?: string;
43
+ /** Up to two tool glyphs, drawn overlapping in the chip. */
44
+ tools?: readonly AgentTeamTool[];
45
+ }
46
+
47
+ /** Three agents, inline start to end. */
48
+ export type AgentTeamMembers = readonly [AgentTeamMember, AgentTeamMember, AgentTeamMember];
49
+
50
+ export interface AgentTeamLabels {
51
+ /** Used when `prompt` is left out. */
52
+ prompt: string;
53
+ /** The one sentence screen readers hear, used when `label` is left out. */
54
+ label: (prompt: string, roles: readonly string[]) => string;
55
+ }
56
+
57
+ const LABELS: AgentTeamLabels = {
58
+ prompt: 'Set up a crew to clear my support queue',
59
+ label: (p, r) => `The prompt "${p}" sets up a team of three agents: ${r.slice(0, -1).join(', ')} and ${r[r.length - 1]}.`,
60
+ };
61
+
62
+ type Phase = 'empty' | 'typing' | 'sent' | 'team' | 'exit';
63
+
64
+ const LINES = [
65
+ 'M300 112C300 122 296 125.4 286 128L124 170C108 174.2 102 182 102 196',
66
+ 'M300 112V196',
67
+ 'M300 112C300 122 304 125.4 314 128L476 170C492 174.2 498 182 498 196',
68
+ ];
69
+
70
+ let uid = 0;
71
+
72
+ @Component({
73
+ selector: 'ui-agent-team',
74
+ host: {
75
+ '[attr.role]': "name() ? 'img' : null",
76
+ '[attr.aria-label]': 'name() || null',
77
+ '[attr.aria-hidden]': "name() ? null : 'true'",
78
+ '[attr.data-phase]': 'phase()',
79
+ '[attr.data-live]': 'live() || null',
80
+ },
81
+ template: `
82
+ <div aria-hidden="true" style="position: absolute; inset: 0; container-type: inline-size">
83
+ <svg class="l" viewBox="0 0 600 400" style="position: absolute; inset: 0; inline-size: 100%; block-size: 100%" fill="none" stroke-width="2.4" stroke-linecap="round" stroke-dasharray="6 7.23" aria-hidden="true">
84
+ <mask [id]="id" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="600" height="400">
85
+ @for (d of lines; track $index) {
86
+ <path class="m" [attr.d]="d" stroke="currentColor" stroke-width="8" stroke-linecap="butt" stroke-dasharray="1 1" pathLength="1" />
87
+ }
88
+ </mask>
89
+ <g [attr.mask]="'url(#' + id + ')'">
90
+ @for (d of lines; track $index) {
91
+ <path [attr.d]="d" />
92
+ }
93
+ </g>
94
+ </svg>
95
+ <div class="g" aria-hidden="true" style="position: absolute; font-size: calc(100cqi / 600); inset-inline-start: 100em; top: 52em; inline-size: 400em; block-size: 68em; border-radius: 99em; background: linear-gradient(90deg, var(--ui-agent-team-glow-a, var(--_ga)), var(--ui-agent-team-glow-b, var(--_gb))); filter: blur(22em)"></div>
96
+ <div class="p" aria-hidden="true" style="position: absolute; font-size: calc(100cqi / 600); inset-inline-start: 110em; top: 60em; display: flex; align-items: center; gap: 12em; inline-size: 380em; block-size: 52em; padding-inline: 20em 8em; box-sizing: border-box; border-radius: 99em; background: var(--_s); box-shadow: var(--_sh)">
97
+ <span style="flex: 1; min-inline-size: 0; overflow: hidden; white-space: nowrap; font-size: 15em; line-height: 1.3; letter-spacing: -0.01em"><span class="x">{{ shown() }}</span><span class="k"
98
+ style="display: inline-block; vertical-align: middle; inline-size: 0.107em; block-size: 1.133em; margin-inline-start: 0.133em; border-radius: 0.067em; background: currentColor"></span></span>
99
+ <span class="b" style="display: grid; place-items: center; flex: none; inline-size: 36em; block-size: 36em; border-radius: 50%">
100
+ <svg viewBox="0 0 24 24" style="inline-size: 18em; block-size: 18em" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
101
+ <path d="M12 19V5.5M6 11.5l6-6 6 6" />
102
+ </svg>
103
+ </span>
104
+ </div>
105
+ @for (m of team(); track $index; let i = $index) {
106
+ <div [style.--i]="i" aria-hidden="true"
107
+ style="position: absolute; font-size: calc(100cqi / 600); inset-inline-start: calc(3em + 198em * var(--i)); top: 196em; display: flex; flex-direction: column; align-items: center; gap: 14em; inline-size: 198em">
108
+ <div class="a" style="position: relative; inline-size: 84em; block-size: 84em; padding: 5em; box-sizing: border-box; border-radius: 99em; background: var(--_s); box-shadow: var(--_sh)">
109
+ @if (m.avatar) {
110
+ <img [src]="m.avatar" alt="" decoding="async" style="display: block; inline-size: 100%; block-size: 100%; border-radius: 50%; object-fit: cover" />
111
+ } @else {
112
+ <svg viewBox="0 0 64 64" style="display: block; inline-size: 100%; block-size: 100%; clip-path: circle(50%)">
113
+ @switch (i) {
114
+ @case (0) {
115
+ <rect width="64" height="64" style="fill: color-mix(in srgb, var(--ui-teal-light) 22%, var(--ui-gray-0))" />
116
+ <path d="M17 36c0-14 6-22 15-22s15 8 15 22v8H17z" style="fill: color-mix(in srgb, var(--ui-orange-light) 70%, var(--ui-gray-1000))" />
117
+ <path d="M10 64c1-11 10-17 22-17s21 6 22 17z" style="fill: color-mix(in srgb, var(--ui-indigo-light) 55%, var(--ui-gray-1000))" />
118
+ <rect x="27" y="36" width="10" height="13" rx="4" style="fill: color-mix(in srgb, var(--ui-orange-light) 30%, var(--ui-gray-0))" />
119
+ <ellipse cx="32" cy="29" rx="10.5" ry="12.5" style="fill: color-mix(in srgb, var(--ui-orange-light) 24%, var(--ui-gray-0))" />
120
+ <path d="M20.5 28c1-8 5.5-12 11.5-12s10.5 4 11.5 12c-6-1-10-4-12-7.5-2 3.5-5.5 6.5-11 7.5z" style="fill: color-mix(in srgb, var(--ui-orange-light) 70%, var(--ui-gray-1000))" />
121
+ }
122
+ @case (1) {
123
+ <rect width="64" height="64" style="fill: color-mix(in srgb, var(--ui-gray-500) 30%, var(--ui-gray-0))" />
124
+ <path d="M10 64c1-11 10-17 22-17s21 6 22 17z" style="fill: color-mix(in srgb, var(--ui-green-light) 35%, var(--ui-gray-800))" />
125
+ <rect x="27" y="36" width="10" height="13" rx="4" style="fill: color-mix(in srgb, var(--ui-orange-light) 38%, var(--ui-gray-0))" />
126
+ <ellipse cx="32" cy="29" rx="10.5" ry="12.5" style="fill: color-mix(in srgb, var(--ui-orange-light) 30%, var(--ui-gray-0))" />
127
+ <path d="M21.5 26c0-7 4.5-10.5 10.5-10.5S42.5 19 42.5 26c-2.5-3-6-4.5-10.5-4.5S24 23 21.5 26z" style="fill: var(--ui-gray-400)" />
128
+ <g fill="none" stroke-width="1.2" style="stroke: var(--ui-gray-750)">
129
+ <circle cx="27.5" cy="29" r="3" /><circle cx="36.5" cy="29" r="3" /><path d="M30.5 29h3" />
130
+ </g>
131
+ }
132
+ @default {
133
+ <rect width="64" height="64" style="fill: color-mix(in srgb, var(--ui-gray-500) 45%, var(--ui-gray-0))" />
134
+ <path d="M10 64c1-11 10-17 22-17s21 6 22 17z" style="fill: var(--ui-gray-50)" />
135
+ <rect x="27" y="36" width="10" height="13" rx="4" style="fill: color-mix(in srgb, var(--ui-orange-light) 50%, var(--ui-gray-700))" />
136
+ <ellipse cx="32" cy="29" rx="10.5" ry="12.5" style="fill: color-mix(in srgb, var(--ui-orange-light) 55%, var(--ui-gray-650))" />
137
+ <path d="M20.5 27c-1-8 4.5-13 11.5-13s12.5 5 11.5 13c-2-3.5-4.5-5.5-8-5.5-3 1.5-8 1.5-11 0-2 1-3.2 2.8-4 5.5z" style="fill: var(--ui-gray-850)" />
138
+ }
139
+ }
140
+ </svg>
141
+ }
142
+ <span class="d" style="position: absolute; inset-inline-start: 65.5em; top: 63.5em; inline-size: 11em; block-size: 11em; border-radius: 50%"></span>
143
+ </div>
144
+ <div class="h" style="display: flex; align-items: center; gap: 10em; max-inline-size: 190em; block-size: 42em; padding-inline: 7em 15em; box-sizing: border-box; border-radius: 99em; background: var(--_s); box-shadow: var(--_sh)">
145
+ @if (m.tools?.length) {
146
+ <span style="display: flex; flex: none">
147
+ @for (tool of m.tools!.slice(0, 2); track $index) {
148
+ <span [style.margin-inline-start.em]="$index ? -8 : null"
149
+ style="display: grid; place-items: center; inline-size: 26em; block-size: 26em; border-radius: 50%; background: var(--ui-agent-team-tool-bg, var(--ui-gray-0)); box-shadow: 0 0 0 1em var(--ui-hairline), 0 1.5em 3em var(--_k)">
150
+ <svg viewBox="0 0 16 16" style="inline-size: 14em; block-size: 14em" fill="none" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
151
+ @switch (tool) {
152
+ @case ('mail') {
153
+ <rect x="1.8" y="3.3" width="12.4" height="9.4" rx="1.8" style="stroke: var(--ui-blue-light)" />
154
+ <path d="M2.6 4.6 8 8.8l5.4-4.2" style="stroke: var(--ui-red-light)" />
155
+ }
156
+ @case ('chat') {
157
+ <path d="M2 3.5A1.5 1.5 0 0 1 3.5 2h6A1.5 1.5 0 0 1 11 3.5v4A1.5 1.5 0 0 1 9.5 9H5.5L3 11V9h0A1 1 0 0 1 2 8z" stroke="none" style="fill: var(--ui-purple-light)" />
158
+ <path d="M7 8.5A1.5 1.5 0 0 1 8.5 7h4A1.5 1.5 0 0 1 14 8.5v3a1.5 1.5 0 0 1-1 1.4V15l-2.4-2H8.5A1.5 1.5 0 0 1 7 11.5z" stroke="none" style="fill: var(--ui-teal-light)" />
159
+ }
160
+ @case ('crm') {
161
+ <circle cx="8" cy="5.6" r="2.7" stroke="none" style="fill: var(--ui-orange-light)" />
162
+ <path d="M2.8 14c.5-3 2.6-4.7 5.2-4.7s4.7 1.7 5.2 4.7z" stroke="none" style="fill: var(--ui-amber-light)" />
163
+ }
164
+ @case ('calendar') {
165
+ <rect x="2" y="3" width="12" height="11" rx="2" style="stroke: var(--ui-blue-light)" />
166
+ <path d="M2.5 6.5h11M5.5 1.8v2.4M10.5 1.8v2.4" style="stroke: var(--ui-red-light)" />
167
+ <path d="M5.5 9.5h.01M8 9.5h.01M10.5 9.5h.01M5.5 11.8h.01M8 11.8h.01" stroke-width="1.8" style="stroke: var(--ui-gray-650)" />
168
+ }
169
+ @case ('search') {
170
+ <circle cx="7" cy="7" r="4.4" stroke-width="1.8" style="stroke: var(--ui-blue-light)" />
171
+ <path d="m10.4 10.4 3.6 3.6" stroke-width="2.2" style="stroke: var(--ui-green-light)" />
172
+ }
173
+ @default {
174
+ <path d="M3.5 2.5A1 1 0 0 1 4.5 1.5h5l3 3v9a1 1 0 0 1-1 1h-7a1 1 0 0 1-1-1z" stroke="none" style="fill: var(--ui-blue-light)" />
175
+ <path d="M5.8 8h4.4M5.8 10.8h3" stroke-width="1.3" style="stroke: var(--ui-gray-0)" />
176
+ }
177
+ }
178
+ </svg>
179
+ </span>
180
+ }
181
+ </span>
182
+ }
183
+ <span [style.padding-inline-start.em]="m.tools?.length ? null : 0.64"
184
+ style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5em; font-weight: var(--ui-weight-medium); line-height: 1.59; letter-spacing: -0.01em">{{ m.role }}</span>
185
+ </div>
186
+ </div>
187
+ }
188
+ </div>
189
+ `,
190
+ styles: `
191
+ @layer ui {
192
+ :host { display: block; position: relative; inline-size: min(560px, 100%); max-inline-size: 100%; aspect-ratio: 3 / 2; overflow: hidden; }
193
+ }
194
+ :host {
195
+ --_m: var(--ui-motion-scale, 1);
196
+ --_s: var(--ui-agent-team-surface, var(--ui-bg-surface));
197
+ --_k: light-dark(color-mix(in srgb, var(--ui-gray-1000) 6%, transparent), color-mix(in srgb, var(--ui-gray-1050) 40%, transparent));
198
+ --_sh: 0 0 0 1em var(--ui-hairline), 0 10em 24em var(--_k), 0 2em 5em var(--_k);
199
+ --_ga: light-dark(color-mix(in srgb, var(--ui-hue-pink) 26%, transparent), color-mix(in srgb, var(--ui-hue-pink) 14%, transparent));
200
+ --_gb: light-dark(color-mix(in srgb, var(--ui-hue-purple) 26%, transparent), color-mix(in srgb, var(--ui-hue-purple) 14%, transparent));
201
+ --_dot: var(--ui-agent-team-dot, var(--ui-hue-green));
202
+ --_sp: var(--ui-ease-spring);
203
+ --_on: 0;
204
+ --_o: 0ms;
205
+ box-sizing: border-box;
206
+ color: var(--ui-agent-team-ink, var(--ui-text));
207
+ font-family: var(--ui-font-sans);
208
+ }
209
+ :host::before { content: 'x x x x x x x x' / ''; display: block; block-size: 0; overflow: hidden; font-size: 0; word-spacing: 80px; }
210
+ :host([data-phase='sent']), :host([data-phase='team']) { --_on: 1; }
211
+ .l { stroke: var(--ui-agent-team-line, light-dark(var(--ui-border), var(--ui-border-strong))); }
212
+ .m { stroke-dashoffset: calc(1 - var(--_on)); transition: stroke-dashoffset calc(700ms * var(--_m)) var(--ui-ease-in-out); }
213
+ .g {
214
+ opacity: var(--_on); scale: calc(.9 + .1 * var(--_on));
215
+ transition: opacity calc(700ms * var(--_m)) var(--ui-ease-out), scale calc(900ms * var(--_m)) var(--ui-ease-out);
216
+ }
217
+ .g:dir(rtl) { rotate: 180deg; }
218
+ :host([data-live]) .k { animation: k 1s step-end infinite; }
219
+ @container style(--ui-motion-scale: 0) { .k { animation: none; } }
220
+ :host([data-phase='exit']) .x { opacity: 0; transition: opacity calc(400ms * var(--_m)) var(--ui-ease-out); }
221
+ .b { background: var(--ui-agent-team-accent, var(--ui-accent)); color: var(--ui-text-on-accent); }
222
+ :host([data-phase='sent']) .b { animation: p calc(380ms * var(--_m)) var(--ui-ease-in-out); }
223
+ .a, .h { --_d: calc((var(--_o) + 160ms * var(--i)) * var(--_m)); opacity: 0; translate: 0 10em; scale: .92; }
224
+ .h { --_o: 120ms; }
225
+ :host([data-phase='team']) .a, :host([data-phase='team']) .h {
226
+ opacity: 1; translate: none; scale: none;
227
+ transition: opacity calc(360ms * var(--_m)) var(--ui-ease-out) var(--_d), translate calc(520ms * var(--_m)) var(--_sp) var(--_d), scale calc(520ms * var(--_m)) var(--_sp) var(--_d);
228
+ }
229
+ :host([data-phase='exit']) .a, :host([data-phase='exit']) .h { opacity: 0; translate: none; scale: none; transition: opacity calc(500ms * var(--_m)) var(--ui-ease-out); }
230
+ .d { scale: 0; background: var(--_dot); box-shadow: 0 0 0 6.5em color-mix(in srgb, var(--_dot) 20%, var(--_s)), 0 0 0 8.5em var(--_s); }
231
+ :host([data-phase='team']) .d { scale: 1; transition: scale calc(420ms * var(--_m)) var(--_sp) calc((360ms + 160ms * var(--i)) * var(--_m)); }
232
+ :host([data-phase='exit']) .d { transition: scale calc(420ms * var(--_m)) cubic-bezier(.5, 0, .75, -.4); }
233
+ @keyframes k { 50% { opacity: 0; } }
234
+ @keyframes p { 26%, 42% { scale: .86; } }
235
+ @media (forced-colors: active) {
236
+ .p, .a, .h { outline: 1px solid CanvasText; }
237
+ .b { forced-color-adjust: none; background: ButtonText; color: ButtonFace; }
238
+ .d { forced-color-adjust: none; background: CanvasText; box-shadow: 0 0 0 2em Canvas; }
239
+ .l { stroke: GrayText; }
240
+ }
241
+ `,
242
+ })
243
+ export class UiAgentTeam {
244
+ /** The request that types itself into the pill. Keep it to about 40 characters: a longer one is clipped at the button. */
245
+ readonly prompt = input<string>();
246
+ /** Exactly three agents, inline start to end. */
247
+ readonly members = input.required<AgentTeamMembers>();
248
+ /** The sentence screen readers hear. Defaults to one built from the prompt and the roles; an empty string hides the scene from them. */
249
+ readonly label = input<string>();
250
+ /** The default prompt and label sentence, for translation. */
251
+ readonly labels = input<Partial<AgentTeamLabels>>({});
252
+
253
+ protected readonly lines = LINES;
254
+ protected readonly id = `ui-agent-team-${++uid}`;
255
+ protected readonly team = computed(() => this.members().slice(0, 3));
256
+
257
+ private readonly t = computed(() => ({ ...LABELS, ...this.labels() }));
258
+ private readonly text = computed(() => this.prompt() ?? this.t().prompt);
259
+ protected readonly name = computed(() => this.label() ?? this.t().label(this.text(), this.team().map((m) => m.role)));
260
+
261
+ private readonly doc = inject(DOCUMENT);
262
+ private readonly win = this.doc.defaultView;
263
+ private readonly host = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;
264
+ private readonly browser = isPlatformBrowser(inject(PLATFORM_ID));
265
+ private readonly reduce = this.browser ? this.win?.matchMedia?.('(prefers-reduced-motion: reduce)') : undefined;
266
+
267
+ /** The finished scene, still: on the server, with reduced motion or with --ui-motion-scale: 0. */
268
+ private readonly still = signal(!this.browser || !!this.reduce?.matches);
269
+ private readonly seen = signal(false);
270
+ private readonly visible = signal(true);
271
+ protected readonly live = computed(() => !this.still() && this.seen() && this.visible());
272
+ protected readonly phase = signal<Phase>(this.still() ? 'team' : 'empty');
273
+ private readonly typed = signal(this.still() ? Infinity : 0);
274
+ protected readonly shown = computed(() => this.text().slice(0, this.typed()));
275
+ private timers: ReturnType<typeof setTimeout>[] = [];
276
+
277
+ constructor() {
278
+ effect((onCleanup) => {
279
+ if (this.live()) this.cycle();
280
+ else if (this.still()) {
281
+ this.phase.set('team');
282
+ this.typed.set(Infinity);
283
+ }
284
+ onCleanup(() => this.stop());
285
+ });
286
+
287
+ let io: IntersectionObserver | undefined;
288
+ const onVisibility = () => this.visible.set(this.doc.visibilityState !== 'hidden');
289
+ const onMotion = () => this.still.set(this.isStill());
290
+ afterNextRender(() => {
291
+ onMotion();
292
+ onVisibility();
293
+ this.reduce?.addEventListener('change', onMotion);
294
+ this.doc.addEventListener('visibilitychange', onVisibility);
295
+ if (this.win?.IntersectionObserver) {
296
+ io = new this.win.IntersectionObserver((entries) => this.seen.set(entries[entries.length - 1].isIntersecting));
297
+ io.observe(this.host);
298
+ } else this.seen.set(true);
299
+ if (isDevMode() && this.label() === undefined && !this.name().trim()) {
300
+ console.warn('ui-agent-team: the scene has no label. Give it a prompt and roles, or label="" if it is purely decorative.', this.host);
301
+ }
302
+ });
303
+
304
+ inject(DestroyRef).onDestroy(() => {
305
+ this.stop();
306
+ io?.disconnect();
307
+ this.reduce?.removeEventListener('change', onMotion);
308
+ this.doc.removeEventListener('visibilitychange', onVisibility);
309
+ });
310
+ }
311
+
312
+ private isStill(): boolean {
313
+ const scale = this.win?.getComputedStyle(this.host).getPropertyValue('--ui-motion-scale').trim();
314
+ return !!this.reduce?.matches || (!!scale && parseFloat(scale) === 0);
315
+ }
316
+
317
+ private after(ms: number, fn: () => void): void {
318
+ this.timers.push(setTimeout(() => (this.isStill() ? this.still.set(true) : fn()), ms));
319
+ }
320
+
321
+ private stop(): void {
322
+ this.timers.forEach(clearTimeout);
323
+ this.timers = [];
324
+ }
325
+
326
+ private cycle(): void {
327
+ this.stop();
328
+ this.phase.set('empty');
329
+ this.typed.set(0);
330
+ const n = this.text().length;
331
+ const type = (k: number) => {
332
+ this.typed.set(k);
333
+ this.phase.set('typing');
334
+ if (k < n) this.after(22, () => type(k + 1));
335
+ else this.after(440, () => this.send());
336
+ };
337
+ this.after(520, () => (n ? type(1) : this.send()));
338
+ }
339
+
340
+ private send(): void {
341
+ this.phase.set('sent');
342
+ this.after(380, () => {
343
+ this.phase.set('team');
344
+ this.after(3880, () => {
345
+ this.phase.set('exit');
346
+ this.after(587, () => this.cycle());
347
+ });
348
+ });
349
+ }
350
+ }
@@ -0,0 +1,300 @@
1
+ // Ochre (https://ochreui.dev), MIT License, Copyright (c) 2026 Ochre. Keep this notice in copies of this file.
2
+ /**
3
+ * Avatar, from Ochre (https://ochreui.dev).
4
+ * Needs ochre.css (the --ui-* tokens and the ui-wave keyframes), which `npx ochreui init` adds once.
5
+ *
6
+ * <ui-avatar> is a person's picture or initials on their own soft color, a square for a workspace,
7
+ * or an agent's 3 x 3 pixel mark. <ui-avatar-group> overlaps avatars and ends in "+N".
8
+ *
9
+ * Public styling hooks (set them on the element or any ancestor):
10
+ * --ui-avatar-ring gap around status dots and grouped avatars; match the background (default --ui-bg-surface)
11
+ * --ui-avatar-wave one cycle of a working agent's ripple (default 1200ms; still with reduced motion)
12
+ */
13
+ import {
14
+ Component,
15
+ ElementRef,
16
+ LOCALE_ID,
17
+ afterNextRender,
18
+ booleanAttribute,
19
+ computed,
20
+ contentChildren,
21
+ forwardRef,
22
+ inject,
23
+ input,
24
+ linkedSignal,
25
+ viewChild,
26
+ } from '@angular/core';
27
+
28
+ export type AvatarSize = 20 | 24 | 32 | 40;
29
+ export type AvatarShape = 'circle' | 'square';
30
+ export type AvatarStatus = 'online' | 'away' | 'busy';
31
+ export type AvatarKind = 'person' | 'agent';
32
+
33
+ const HUES = ['blue', 'green', 'amber', 'orange', 'red', 'pink', 'purple', 'teal', 'cyan'];
34
+ const SUFFIX = /^(jr|sr|ii|iii|iv|phd|esq)\.?,?$/i;
35
+ const SHORT_SUFFIX = /^(v|vi|md)\.?,?$/i;
36
+ const PICTOGRAPH = /\p{Extended_Pictographic}|\p{Regional_Indicator}/u;
37
+ const LEADING = /^[^\p{L}\p{N}\p{Extended_Pictographic}\p{Regional_Indicator}]+/u;
38
+ const toCount = (v: number | string | undefined): number | undefined => {
39
+ const n = v === undefined || v === '' ? NaN : Math.floor(Number(v));
40
+ return Number.isNaN(n) ? undefined : Math.max(0, n);
41
+ };
42
+ const toSize = (v: AvatarSize | `${AvatarSize}` | number | string | undefined): AvatarSize | undefined =>
43
+ v === undefined || v === '' ? undefined : ([20, 24, 32, 40].includes(+v) ? (+v as AvatarSize) : 32);
44
+
45
+ function hash(text: string): number {
46
+ let h = 0x811c9dc5;
47
+ for (let i = 0; i < text.length; i++) h = Math.imul(h ^ text.charCodeAt(i), 0x01000193);
48
+ return h >>> 0;
49
+ }
50
+
51
+ let segmenter: Intl.Segmenter | undefined;
52
+ function firstGrapheme(text: string): string {
53
+ if (typeof Intl.Segmenter !== 'function') return Array.from(text)[0] ?? '';
54
+ segmenter ??= new Intl.Segmenter(undefined, { granularity: 'grapheme' });
55
+ for (const s of segmenter.segment(text)) return s.segment;
56
+ return '';
57
+ }
58
+
59
+ /** Up to two initials, from the first and last word, skipping leading punctuation and suffixes like Jr. or III. */
60
+ export function initialsOf(name: string, locale?: string): string {
61
+ const all = name
62
+ .trim()
63
+ .split(/\s+/)
64
+ .map((w) => w.replace(LEADING, ''))
65
+ .filter(Boolean);
66
+ const words = all.filter((w, i) => i === 0 || !(SUFFIX.test(w) || (all.length > 2 && SHORT_SUFFIX.test(w))));
67
+ if (!words.length) return '';
68
+ const first = firstGrapheme(words[0]);
69
+ if (PICTOGRAPH.test(first)) return first;
70
+ const last = words.length > 1 ? firstGrapheme(words[words.length - 1]) : '';
71
+ return (first + (PICTOGRAPH.test(last) ? '' : last)).toLocaleUpperCase(locale);
72
+ }
73
+
74
+ @Component({
75
+ selector: 'ui-avatar-group',
76
+ host: { role: 'group', '[attr.data-size]': 'size()', '[style.--_s.px]': 'size()' },
77
+ template: `
78
+ <ng-content />
79
+ @if (more() > 0) {
80
+ <span class="more" role="img" [class.alone]="shown() === 0" [attr.aria-label]="moreLabel()(more())">{{ moreText() }}</span>
81
+ }
82
+ `,
83
+ styles: `
84
+ :host { display: inline-flex; align-items: center; vertical-align: middle; }
85
+ .more {
86
+ display: grid;
87
+ place-items: center;
88
+ box-sizing: border-box;
89
+ min-inline-size: var(--_s);
90
+ block-size: var(--_s);
91
+ margin-inline-start: calc(var(--_s) * -0.25);
92
+ padding-inline: var(--ui-space-1);
93
+ border-radius: var(--ui-radius-full);
94
+ box-shadow: 0 0 0 2px var(--ui-avatar-ring, var(--ui-bg-surface));
95
+ outline: 1px solid transparent;
96
+ background: var(--ui-bg-muted);
97
+ color: var(--ui-text-muted);
98
+ font-size: calc(var(--_s) * 3 / 8);
99
+ line-height: 1;
100
+ font-weight: calc(var(--ui-weight-medium) + 100 * var(--ui-look-tray, 0));
101
+ font-variant-numeric: tabular-nums;
102
+ user-select: none;
103
+ }
104
+ .alone { margin-inline-start: 0; }
105
+ :host([data-size='20']) .more { font-size: calc(var(--_s) * 9 / 20); }
106
+ :host([data-size='24']) .more { font-size: calc(var(--_s) * 5 / 12); }
107
+ `,
108
+ })
109
+ export class UiAvatarGroup {
110
+ /** How many avatars show before the rest becomes "+N". */
111
+ readonly max = input<number, number | string>(4, { transform: (v) => toCount(v) ?? 4 });
112
+ /** Size of every avatar inside, and of the "+N" chip. */
113
+ readonly size = input<AvatarSize, AvatarSize | `${AvatarSize}`>(32, { transform: (v) => toSize(v) ?? 32 });
114
+ /** The full count when only the first few avatars are passed in. */
115
+ readonly total = input<number | undefined, number | string | undefined>(undefined, { transform: toCount });
116
+ /** Spoken name of the "+N" chip. */
117
+ readonly moreLabel = input<(n: number) => string>((n) => `${n} more`);
118
+
119
+ private readonly items = contentChildren(forwardRef(() => UiAvatar), { descendants: true });
120
+ readonly position = computed(() => new Map(this.items().map((a, i) => [a, i])));
121
+ readonly shown = computed(() => Math.min(this.items().length, this.max()));
122
+ protected readonly more = computed(() => Math.max(this.total() ?? 0, this.items().length) - this.shown());
123
+ protected readonly moreText = computed(() => (this.more() > 99 ? '99+' : `+${this.more()}`));
124
+ }
125
+
126
+ @Component({
127
+ selector: 'ui-avatar',
128
+ host: {
129
+ '[attr.role]': 'hidden() ? null : "img"',
130
+ '[attr.aria-label]': 'hidden() ? null : spoken()',
131
+ '[attr.aria-hidden]': 'hidden() ? "true" : null',
132
+ '[attr.hidden]': 'overflow() ? "" : null',
133
+ '[attr.data-shape]': 'shapeOf()',
134
+ '[attr.data-size]': 'sizeOf()',
135
+ '[attr.data-grouped]': 'index() >= 0 ? "" : null',
136
+ '[attr.data-anon]': 'cleanName() ? null : ""',
137
+ '[attr.data-overlap]': 'index() > 0 ? "" : null',
138
+ '[style.--_s.px]': 'sizeOf()',
139
+ '[style.--_hue]': '"var(--ui-hue-" + hue() + ")"',
140
+ '[style.--_mark]': 'color() || null',
141
+ },
142
+ template: `
143
+ <span class="face" [class.edge]="agentTile() || pictured()">
144
+ @if (agentTile()) {
145
+ <span class="mark" [class.working]="working()" aria-hidden="true">
146
+ @for (cell of pattern(); track $index) {
147
+ <i [class.on]="cell" [style.--_d]="($index % 3) + ($index - ($index % 3)) / 3"></i>
148
+ }
149
+ </span>
150
+ } @else if (initials()) {
151
+ <span aria-hidden="true">{{ initials() }}</span>
152
+ } @else {
153
+ <svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="9" r="3.5" /><path d="M5.5 19a6.5 6.5 0 0 1 13 0" /></svg>
154
+ }
155
+ @if (src() && !failed()) {
156
+ <img #img [src]="src()" alt="" loading="lazy" decoding="async" draggable="false" [class.in]="loaded()" (load)="loaded.set(true)" (error)="failed.set(true)" />
157
+ }
158
+ </span>
159
+ @if (status(); as s) {
160
+ <span class="dot" [attr.data-status]="s" aria-hidden="true"></span>
161
+ }
162
+ `,
163
+ styles: `
164
+ :host {
165
+ --_t: var(--ui-look-tray, 0);
166
+ --_ring: var(--ui-avatar-ring, var(--ui-bg-surface));
167
+ position: relative;
168
+ display: inline-grid;
169
+ flex-shrink: 0;
170
+ inline-size: var(--_s);
171
+ block-size: var(--_s);
172
+ vertical-align: middle;
173
+ user-select: none;
174
+ font-size: calc(var(--_s) * 3 / 8);
175
+ line-height: 1;
176
+ font-weight: calc(var(--ui-weight-medium) + 100 * var(--_t));
177
+ }
178
+ :host([data-size='20']) { font-size: calc(var(--_s) * 9 / 20); }
179
+ :host([data-size='24']) { font-size: calc(var(--_s) * 5 / 12); }
180
+ :host([hidden]) { display: none; }
181
+ :host([data-overlap]) { margin-inline-start: calc(var(--_s) * -0.25); }
182
+ .face {
183
+ position: relative;
184
+ display: grid;
185
+ place-items: center;
186
+ overflow: hidden;
187
+ border-radius: 50%;
188
+ outline: 1px solid transparent;
189
+ outline-offset: -1px;
190
+ background: color-mix(in srgb, var(--_hue) 18%, var(--ui-bg-surface));
191
+ color: color-mix(in srgb, var(--_hue) 55%, var(--ui-text));
192
+ }
193
+ .face > * { grid-area: 1 / 1; }
194
+ :host([data-shape='square']) .face { border-radius: calc(var(--_s) * (0.25 + 0.05 * var(--_t))); }
195
+ :host([data-grouped]) .face { box-shadow: 0 0 0 2px var(--_ring); }
196
+ .edge::after {
197
+ content: '';
198
+ position: absolute;
199
+ inset: 0;
200
+ border-radius: inherit;
201
+ box-shadow: inset 0 0 0 calc(0.5px + 0.5px * var(--_t)) var(--ui-hairline);
202
+ }
203
+ :host([data-anon]) .face:not(.edge) { background: var(--ui-bg-muted); color: var(--ui-icon); }
204
+ svg { inline-size: 60%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
205
+ img { inline-size: 100%; block-size: 100%; object-fit: cover; opacity: 0; transition: opacity var(--ui-duration-2) var(--ui-ease-out); }
206
+ img.in { opacity: 1; }
207
+ .mark { display: grid; grid-template-columns: repeat(3, 1fr); gap: calc(var(--_s) / 16); inline-size: 50%; aspect-ratio: 1; }
208
+ .mark i { border-radius: 25%; background: var(--_mark, var(--ui-hue-blue)); opacity: 0; }
209
+ .mark i.on { opacity: 1; }
210
+ .edge:has(.mark) { background: var(--ui-bg-surface); }
211
+ @media (prefers-reduced-motion: no-preference) {
212
+ .working i { opacity: 1; animation: ui-wave var(--ui-avatar-wave, 1200ms) ease-in-out calc(var(--_d) * 120ms) infinite both; }
213
+ }
214
+ @container style(--ui-motion-scale: 0) {
215
+ .working i { opacity: 0; animation: none; }
216
+ }
217
+ .dot {
218
+ position: absolute;
219
+ inset-inline-end: 0;
220
+ inset-block-end: 0;
221
+ inline-size: calc(var(--_s) * 0.28);
222
+ inline-size: round(calc(var(--_s) * 0.28), 1px);
223
+ aspect-ratio: 1;
224
+ border-radius: 50%;
225
+ box-shadow: 0 0 0 1.5px var(--_ring);
226
+ background: var(--ui-success);
227
+ }
228
+ .dot[data-status='away'] { background: var(--ui-warning); }
229
+ .dot[data-status='busy'] { background: var(--ui-danger); }
230
+ @media (forced-colors: active) {
231
+ .mark i.on, .dot, .dot[data-status] { forced-color-adjust: none; background: CanvasText; }
232
+ .dot { box-shadow: 0 0 0 1.5px Canvas; }
233
+ }
234
+ `,
235
+ })
236
+ export class UiAvatar {
237
+ /** Who it is: the initials, the spoken name and, unless `seed` is set, the color. Without it the avatar is hidden from screen readers. */
238
+ readonly name = input<string>();
239
+ /** Picture URL. The initials show while it loads and stay if it fails. */
240
+ readonly src = input<string>();
241
+ /** Width and height in px. A group's size wins. */
242
+ readonly size = input<AvatarSize | undefined, AvatarSize | `${AvatarSize}` | undefined>(undefined, { transform: toSize });
243
+ /** Circle for people, a rounded square for workspaces, teams and agents. */
244
+ readonly shape = input<AvatarShape>();
245
+ /** A dot on the corner, also added to the spoken name. */
246
+ readonly status = input<AvatarStatus>();
247
+ /** `agent` draws a 3 x 3 pixel mark instead of initials. A `src` still wins. */
248
+ readonly kind = input<AvatarKind>('person');
249
+ /** What the color and the agent's pattern come from. Pass a stable id so a rename keeps them. */
250
+ readonly seed = input<string>();
251
+ /** Agent only: the mark's color, any CSS color. */
252
+ readonly color = input<string>();
253
+ /** Agent only: the squares ripple while it works. */
254
+ readonly working = input(false, { transform: booleanAttribute });
255
+ /** Spoken words for each status. */
256
+ readonly statusLabels = input<Record<AvatarStatus, string>>({ online: 'online', away: 'away', busy: 'busy' });
257
+ /** Hide it from screen readers when the name is written next to it: `aria-hidden="true"` or `[aria-hidden]="…"`. */
258
+ readonly ariaHidden = input(false, { alias: 'aria-hidden', transform: booleanAttribute });
259
+ /** Replaces the spoken name and status. */
260
+ readonly ariaLabel = input<string>(undefined, { alias: 'aria-label' });
261
+
262
+ private readonly group = inject(UiAvatarGroup, { optional: true });
263
+ private readonly locale = inject(LOCALE_ID);
264
+ private readonly img = viewChild<ElementRef<HTMLImageElement>>('img');
265
+
266
+ protected readonly index = computed(() => this.group?.position().get(this) ?? -1);
267
+ protected readonly sizeOf = computed(() => (this.index() >= 0 ? this.group!.size() : (this.size() ?? 32)));
268
+ protected readonly shapeOf = computed(() => this.shape() ?? (this.kind() === 'agent' ? 'square' : 'circle'));
269
+ protected readonly overflow = computed(() => this.index() >= 0 && this.index() >= this.group!.shown());
270
+ protected readonly cleanName = computed(() => this.name()?.trim() ?? '');
271
+ protected readonly hidden = computed(() => this.ariaHidden() || !(this.ariaLabel() || this.cleanName()));
272
+ protected readonly spoken = computed(() => {
273
+ const status = this.status();
274
+ return this.ariaLabel() || (status ? `${this.cleanName()}, ${this.statusLabels()[status]}` : this.cleanName());
275
+ });
276
+ protected readonly initials = computed(() => initialsOf(this.cleanName(), this.locale));
277
+ private readonly code = computed(() => hash(this.seed() || this.cleanName()));
278
+ protected readonly hue = computed(() => HUES[this.code() % HUES.length]);
279
+ protected readonly pictured = computed(() => !!this.src() && this.loaded() && !this.failed());
280
+ protected readonly agentTile = computed(() => this.kind() === 'agent' && !this.pictured());
281
+ protected readonly pattern = computed(() => {
282
+ let bits = (this.code() >>> 7) & 0x1ff;
283
+ let on = 0;
284
+ for (let b = bits; b; b &= b - 1) on++;
285
+ if (on < 4) bits |= 0b101010101;
286
+ return Array.from({ length: 9 }, (_, i) => !!(bits & (1 << i)));
287
+ });
288
+
289
+ protected readonly loaded = linkedSignal({ source: this.src, computation: () => false });
290
+ protected readonly failed = linkedSignal({ source: this.src, computation: () => false });
291
+
292
+ constructor() {
293
+ afterNextRender({
294
+ read: () => {
295
+ const img = this.img()?.nativeElement;
296
+ if (img?.complete) (img.naturalWidth ? this.loaded : this.failed).set(true);
297
+ },
298
+ });
299
+ }
300
+ }