fauna-api 0.0.0-stage → 1.0.676

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 (171) hide show
  1. package/dist/brands.d.ts +2 -0
  2. package/dist/brands.js +2 -0
  3. package/dist/index.d.ts +64 -0
  4. package/dist/index.js +121 -0
  5. package/dist/src/ant/chat.d.ts +130 -0
  6. package/dist/src/ant/chat.js +467 -0
  7. package/dist/src/ant/format.d.ts +40 -0
  8. package/dist/src/ant/format.js +143 -0
  9. package/dist/src/ant/graph.d.ts +130 -0
  10. package/dist/src/ant/graph.js +449 -0
  11. package/dist/src/ant/index.d.ts +16 -0
  12. package/dist/src/ant/index.js +61 -0
  13. package/dist/src/ant/persona.d.ts +151 -0
  14. package/dist/src/ant/persona.js +136 -0
  15. package/dist/src/ant/timeline.d.ts +283 -0
  16. package/dist/src/ant/timeline.js +1025 -0
  17. package/dist/src/authentification.d.ts +45 -0
  18. package/dist/src/authentification.js +194 -0
  19. package/dist/src/billing.d.ts +135 -0
  20. package/dist/src/billing.js +128 -0
  21. package/dist/src/calendar.d.ts +83 -0
  22. package/dist/src/calendar.js +133 -0
  23. package/dist/src/chats.d.ts +113 -0
  24. package/dist/src/chats.js +100 -0
  25. package/dist/src/cicada/contacts.d.ts +31 -0
  26. package/dist/src/cicada/contacts.js +28 -0
  27. package/dist/src/cicada/conversations.d.ts +73 -0
  28. package/dist/src/cicada/conversations.js +236 -0
  29. package/dist/src/cicada/inboxes.d.ts +48 -0
  30. package/dist/src/cicada/inboxes.js +82 -0
  31. package/dist/src/cicada/index.d.ts +16 -0
  32. package/dist/src/cicada/index.js +61 -0
  33. package/dist/src/cicada/phone.d.ts +48 -0
  34. package/dist/src/cicada/phone.js +306 -0
  35. package/dist/src/drive.d.ts +80 -0
  36. package/dist/src/drive.js +472 -0
  37. package/dist/src/extensions/index.d.ts +4 -0
  38. package/dist/src/extensions/index.js +5 -0
  39. package/dist/src/extensions/web/index.d.ts +6 -0
  40. package/dist/src/extensions/web/index.js +7 -0
  41. package/dist/src/extensions/web/session.d.ts +106 -0
  42. package/dist/src/extensions/web/session.js +469 -0
  43. package/dist/src/extensions/web/tools.d.ts +13 -0
  44. package/dist/src/extensions/web/tools.js +72 -0
  45. package/dist/src/friends.d.ts +39 -0
  46. package/dist/src/friends.js +119 -0
  47. package/dist/src/groups.d.ts +82 -0
  48. package/dist/src/groups.js +269 -0
  49. package/dist/src/inbox.d.ts +11 -0
  50. package/dist/src/inbox.js +35 -0
  51. package/dist/src/integrations.d.ts +52 -0
  52. package/dist/src/integrations.js +205 -0
  53. package/dist/src/magpie/explorer.d.ts +14 -0
  54. package/dist/src/magpie/explorer.js +36 -0
  55. package/dist/src/magpie/index.d.ts +16 -0
  56. package/dist/src/magpie/index.js +61 -0
  57. package/dist/src/magpie/portfolio.d.ts +52 -0
  58. package/dist/src/magpie/portfolio.js +179 -0
  59. package/dist/src/magpie/quotes.d.ts +35 -0
  60. package/dist/src/magpie/quotes.js +47 -0
  61. package/dist/src/magpie/room.d.ts +61 -0
  62. package/dist/src/magpie/room.js +238 -0
  63. package/dist/src/maps.d.ts +159 -0
  64. package/dist/src/maps.js +171 -0
  65. package/dist/src/marmot/browser.d.ts +139 -0
  66. package/dist/src/marmot/browser.js +389 -0
  67. package/dist/src/marmot/index.d.ts +20 -0
  68. package/dist/src/marmot/index.js +65 -0
  69. package/dist/src/marmot/media.d.ts +56 -0
  70. package/dist/src/marmot/media.js +265 -0
  71. package/dist/src/marmot/research.d.ts +337 -0
  72. package/dist/src/marmot/research.js +1138 -0
  73. package/dist/src/marmot/scraper.d.ts +59 -0
  74. package/dist/src/marmot/scraper.js +94 -0
  75. package/dist/src/marmot/web.d.ts +402 -0
  76. package/dist/src/marmot/web.js +2586 -0
  77. package/dist/src/marmot/workspace.d.ts +81 -0
  78. package/dist/src/marmot/workspace.js +263 -0
  79. package/dist/src/parrot/agent.d.ts +53 -0
  80. package/dist/src/parrot/agent.js +93 -0
  81. package/dist/src/parrot/chat.d.ts +84 -0
  82. package/dist/src/parrot/chat.js +237 -0
  83. package/dist/src/parrot/format.d.ts +128 -0
  84. package/dist/src/parrot/format.js +639 -0
  85. package/dist/src/parrot/generative.d.ts +261 -0
  86. package/dist/src/parrot/generative.js +185 -0
  87. package/dist/src/parrot/index.d.ts +22 -0
  88. package/dist/src/parrot/index.js +67 -0
  89. package/dist/src/parrot/room.d.ts +225 -0
  90. package/dist/src/parrot/room.js +466 -0
  91. package/dist/src/parrot/routing.d.ts +90 -0
  92. package/dist/src/parrot/routing.js +78 -0
  93. package/dist/src/parrot/share.d.ts +126 -0
  94. package/dist/src/parrot/share.js +261 -0
  95. package/dist/src/parrot/socket.d.ts +41 -0
  96. package/dist/src/parrot/socket.js +478 -0
  97. package/dist/src/payments.d.ts +73 -0
  98. package/dist/src/payments.js +107 -0
  99. package/dist/src/private/cards.css +75 -0
  100. package/dist/src/rooms.d.ts +76 -0
  101. package/dist/src/rooms.js +168 -0
  102. package/dist/src/shared/schema.d.ts +24 -0
  103. package/dist/src/shared/schema.js +1 -0
  104. package/dist/src/shared/server.d.ts +65 -0
  105. package/dist/src/shared/server.js +302 -0
  106. package/dist/src/termite/environment.d.ts +110 -0
  107. package/dist/src/termite/environment.js +263 -0
  108. package/dist/src/termite/index.d.ts +14 -0
  109. package/dist/src/termite/index.js +59 -0
  110. package/dist/src/termite/os.d.ts +326 -0
  111. package/dist/src/termite/os.js +572 -0
  112. package/dist/src/termite/versioning.d.ts +94 -0
  113. package/dist/src/termite/versioning.js +217 -0
  114. package/dist/src/tickets.d.ts +43 -0
  115. package/dist/src/tickets.js +138 -0
  116. package/dist/src/travel.d.ts +85 -0
  117. package/dist/src/travel.js +44 -0
  118. package/dist/src/ui/authentification.d.ts +24 -0
  119. package/dist/src/ui/authentification.js +177 -0
  120. package/dist/src/ui/brands.css +11 -0
  121. package/dist/src/ui/brands.d.ts +7 -0
  122. package/dist/src/ui/brands.js +14 -0
  123. package/dist/src/ui/browser.d.ts +74 -0
  124. package/dist/src/ui/browser.js +470 -0
  125. package/dist/src/ui/chat.d.ts +183 -0
  126. package/dist/src/ui/chat.js +2379 -0
  127. package/dist/src/ui/chatPanel.d.ts +109 -0
  128. package/dist/src/ui/chatPanel.js +768 -0
  129. package/dist/src/ui/chatSequence.d.ts +36 -0
  130. package/dist/src/ui/chatSequence.js +42 -0
  131. package/dist/src/ui/crown.d.ts +19 -0
  132. package/dist/src/ui/crown.js +199 -0
  133. package/dist/src/ui/cursor.d.ts +73 -0
  134. package/dist/src/ui/cursor.js +175 -0
  135. package/dist/src/ui/device.d.ts +33 -0
  136. package/dist/src/ui/device.js +49 -0
  137. package/dist/src/ui/drive.d.ts +69 -0
  138. package/dist/src/ui/drive.js +1243 -0
  139. package/dist/src/ui/generative.d.ts +39 -0
  140. package/dist/src/ui/generative.js +313 -0
  141. package/dist/src/ui/hover.d.ts +6 -0
  142. package/dist/src/ui/hover.js +210 -0
  143. package/dist/src/ui/index.d.ts +42 -0
  144. package/dist/src/ui/index.js +87 -0
  145. package/dist/src/ui/integrations.d.ts +13 -0
  146. package/dist/src/ui/integrations.js +175 -0
  147. package/dist/src/ui/maps.d.ts +87 -0
  148. package/dist/src/ui/maps.js +547 -0
  149. package/dist/src/ui/roster.d.ts +32 -0
  150. package/dist/src/ui/roster.js +163 -0
  151. package/dist/src/ui/talk.d.ts +12 -0
  152. package/dist/src/ui/talk.js +560 -0
  153. package/dist/src/ui/tickets.d.ts +13 -0
  154. package/dist/src/ui/tickets.js +966 -0
  155. package/dist/src/ui/toast.d.ts +7 -0
  156. package/dist/src/ui/toast.js +258 -0
  157. package/dist/src/ui/tokenText.d.ts +18 -0
  158. package/dist/src/ui/tokenText.js +96 -0
  159. package/dist/src/ui/tokenized.d.ts +42 -0
  160. package/dist/src/ui/tokenized.js +622 -0
  161. package/dist/src/ui/ui.css +4763 -0
  162. package/dist/src/ui/view.d.ts +23 -0
  163. package/dist/src/ui/view.js +584 -0
  164. package/dist/src/view.d.ts +113 -0
  165. package/dist/src/view.js +386 -0
  166. package/dist/src/webhooks.d.ts +66 -0
  167. package/dist/src/webhooks.js +78 -0
  168. package/dist/ui.d.ts +1 -0
  169. package/dist/ui.js +1 -0
  170. package/package.json +89 -6
  171. package/README.md +0 -3
@@ -0,0 +1,39 @@
1
+ import { Fauna } from 'fauna-api';
2
+ export declare function avatarUrl(profile?: Fauna.Authentification.Profile): string;
3
+ export declare function buildAvatar(profile?: Fauna.Authentification.Profile): HTMLImageElement;
4
+ export declare function buildModelAvatar(model?: string, iconByModel?: Record<string, string>): HTMLElement;
5
+ export declare function stampUserAvatar(el: HTMLElement, profile?: Fauna.Authentification.Profile): void;
6
+ export declare function stampModelAvatar(el: HTMLElement, model?: string, iconByModel?: Record<string, string>): void;
7
+ export type SelectorOption = {
8
+ value: string;
9
+ name: string;
10
+ icon?: string;
11
+ reasoning?: string[];
12
+ };
13
+ export type SelectorHandle = {
14
+ getValue: () => string;
15
+ setValue: (value: string) => void;
16
+ getReasoning: () => string | undefined;
17
+ setReasoning: (reasoning: string | undefined) => void;
18
+ setOptions: (options: SelectorOption[]) => void;
19
+ destroy: () => void;
20
+ };
21
+ export declare function reasoningLabel(reasoning: string): string;
22
+ export declare function createSelector(container: HTMLElement, opts?: {
23
+ options?: SelectorOption[];
24
+ value?: string;
25
+ onChange?: (value: string) => void;
26
+ reasoning?: string;
27
+ onReasoningChange?: (reasoning: string | undefined) => void;
28
+ }): SelectorHandle;
29
+ export type DemographicHandle = {
30
+ getValue: () => Partial<Fauna.Ant.Persona.Demographic>;
31
+ setValue: (value: Partial<Fauna.Ant.Persona.Demographic>) => void;
32
+ destroy: () => void;
33
+ };
34
+ export type DemographicField = 'age' | 'income' | 'sex' | 'race';
35
+ export declare function createDemographic(container: HTMLElement, opts?: {
36
+ value?: Partial<Fauna.Ant.Persona.Demographic>;
37
+ onChange?: (value: Partial<Fauna.Ant.Persona.Demographic>) => void;
38
+ omit?: DemographicField[];
39
+ }): DemographicHandle;
@@ -0,0 +1,313 @@
1
+ import { Fauna } from 'fauna-api';
2
+ export function avatarUrl(profile) {
3
+ if (profile?.icon)
4
+ return profile.icon;
5
+ const name = profile?.displayName ?? profile?.email?.split('@')[0] ?? '?';
6
+ return `https://ui-avatars.com/api/?name=${encodeURIComponent(name)}&background=0B1020&color=F3F6FF&size=64`;
7
+ }
8
+ export function buildAvatar(profile) {
9
+ const img = document.createElement('img');
10
+ img.className = 'chat-message-avatar';
11
+ img.src = avatarUrl(profile);
12
+ img.alt = profile?.displayName ?? profile?.email ?? '';
13
+ img.title = img.alt;
14
+ return img;
15
+ }
16
+ export function buildModelAvatar(model, iconByModel) {
17
+ const icon = model ? iconByModel?.[model] : undefined;
18
+ if (icon) {
19
+ const img = document.createElement('img');
20
+ img.className = 'chat-message-avatar chat-message-model-avatar';
21
+ img.src = icon;
22
+ img.alt = model ?? 'model';
23
+ img.title = model ?? '';
24
+ return img;
25
+ }
26
+ const fallback = document.createElement('span');
27
+ fallback.className = 'material-symbols-outlined chat-message-avatar chat-message-model-avatar chat-message-model-avatar-fallback';
28
+ fallback.textContent = 'neurology';
29
+ fallback.title = model ?? 'model';
30
+ return fallback;
31
+ }
32
+ export function stampUserAvatar(el, profile) {
33
+ el.querySelector(':scope > .chat-message-avatar:not(.chat-message-model-avatar)')?.remove();
34
+ el.classList.add('chat-message-authored');
35
+ el.appendChild(buildAvatar(profile));
36
+ }
37
+ export function stampModelAvatar(el, model, iconByModel) {
38
+ el.querySelector('.chat-message-model-avatar')?.remove();
39
+ el.classList.add('chat-message-model-authored');
40
+ el.appendChild(buildModelAvatar(model, iconByModel));
41
+ }
42
+ export function reasoningLabel(reasoning) {
43
+ return reasoning.charAt(0).toUpperCase() + reasoning.slice(1).toLowerCase();
44
+ }
45
+ export function createSelector(container, opts = {}) {
46
+ let options = opts.options ?? [];
47
+ let value = opts.value ?? '';
48
+ let reasoning = opts.reasoning;
49
+ let open = false;
50
+ container.classList.add('gen-select');
51
+ container.innerHTML = '';
52
+ const trigger = document.createElement('button');
53
+ trigger.type = 'button';
54
+ trigger.className = 'gen-select-trigger';
55
+ const triggerIcon = document.createElement('img');
56
+ triggerIcon.className = 'gen-select-trigger-icon';
57
+ triggerIcon.alt = '';
58
+ const triggerLabel = document.createElement('span');
59
+ triggerLabel.className = 'gen-select-trigger-label';
60
+ triggerLabel.textContent = 'Model';
61
+ const triggerReasoning = document.createElement('span');
62
+ triggerReasoning.className = 'gen-select-trigger-reasoning';
63
+ triggerReasoning.style.display = 'none';
64
+ const caret = document.createElement('span');
65
+ caret.className = 'material-symbols-outlined gen-select-caret';
66
+ caret.textContent = 'expand_more';
67
+ trigger.append(triggerIcon, triggerLabel, triggerReasoning, caret);
68
+ const menu = document.createElement('div');
69
+ menu.className = 'gen-select-menu';
70
+ menu.setAttribute('role', 'listbox');
71
+ const reasoningPanel = document.createElement('div');
72
+ reasoningPanel.className = 'gen-select-reasoning';
73
+ reasoningPanel.style.display = 'none';
74
+ container.append(trigger, menu, reasoningPanel);
75
+ const hidePanel = () => { reasoningPanel.style.display = 'none'; };
76
+ const closeMenu = () => { open = false; container.classList.remove('open'); hidePanel(); };
77
+ const openMenu = () => {
78
+ open = true;
79
+ container.classList.add('open');
80
+ const sel = menu.querySelector('.gen-select-option[aria-selected="true"]');
81
+ sel?.scrollIntoView({ block: 'nearest' });
82
+ };
83
+ trigger.onclick = (e) => { e.stopPropagation(); open ? closeMenu() : openMenu(); };
84
+ const onDocClick = (e) => { if (!container.contains(e.target))
85
+ closeMenu(); };
86
+ const onKeyDown = (e) => { if (e.key === 'Escape')
87
+ closeMenu(); };
88
+ document.addEventListener('click', onDocClick);
89
+ container.addEventListener('keydown', onKeyDown);
90
+ const renderSelection = () => {
91
+ const current = options.find((row) => row.value === value);
92
+ triggerLabel.textContent = current?.name ?? 'Model';
93
+ if (current?.icon) {
94
+ triggerIcon.src = current.icon;
95
+ triggerIcon.style.display = '';
96
+ }
97
+ else {
98
+ triggerIcon.removeAttribute('src');
99
+ triggerIcon.style.display = 'none';
100
+ }
101
+ const supports = (current?.reasoning?.length ?? 0) > 0;
102
+ if (supports && reasoning) {
103
+ triggerReasoning.textContent = `\u00b7 ${reasoningLabel(reasoning)}`;
104
+ triggerReasoning.style.display = '';
105
+ }
106
+ else {
107
+ triggerReasoning.style.display = 'none';
108
+ }
109
+ for (const el of Array.from(menu.children)) {
110
+ el.setAttribute('aria-selected', el.dataset.value === value ? 'true' : 'false');
111
+ }
112
+ };
113
+ const showPanel = (row, anchor) => {
114
+ reasoningPanel.innerHTML = '';
115
+ for (const tier of row.reasoning ?? []) {
116
+ const opt = document.createElement('button');
117
+ opt.type = 'button';
118
+ opt.className = 'gen-select-reasoning-option';
119
+ opt.textContent = reasoningLabel(tier);
120
+ opt.setAttribute('aria-selected', (value === row.value && reasoning === tier) ? 'true' : 'false');
121
+ opt.onclick = (e) => {
122
+ e.stopPropagation();
123
+ value = row.value;
124
+ reasoning = tier;
125
+ renderSelection();
126
+ closeMenu();
127
+ opts.onChange?.(value);
128
+ opts.onReasoningChange?.(reasoning);
129
+ };
130
+ reasoningPanel.appendChild(opt);
131
+ }
132
+ reasoningPanel.style.display = 'block';
133
+ const containerRect = container.getBoundingClientRect();
134
+ const anchorRect = anchor.getBoundingClientRect();
135
+ const menuRect = menu.getBoundingClientRect();
136
+ const panelRect = reasoningPanel.getBoundingClientRect();
137
+ const margin = 8;
138
+ let viewportTop = anchorRect.top;
139
+ let viewportLeft = menuRect.right + 6;
140
+ if (viewportLeft + panelRect.width + margin > window.innerWidth) {
141
+ viewportLeft = menuRect.left - panelRect.width - 6;
142
+ }
143
+ viewportLeft = Math.max(margin, Math.min(viewportLeft, window.innerWidth - panelRect.width - margin));
144
+ viewportTop = Math.max(margin, Math.min(viewportTop, window.innerHeight - panelRect.height - margin));
145
+ reasoningPanel.style.top = `${viewportTop - containerRect.top}px`;
146
+ reasoningPanel.style.left = `${viewportLeft - containerRect.left}px`;
147
+ };
148
+ const renderMenu = () => {
149
+ menu.innerHTML = '';
150
+ for (const row of options) {
151
+ const item = document.createElement('button');
152
+ item.type = 'button';
153
+ item.className = 'gen-select-option';
154
+ item.setAttribute('role', 'option');
155
+ item.dataset.value = row.value;
156
+ const icon = document.createElement('img');
157
+ icon.className = 'gen-select-option-icon';
158
+ if (row.icon)
159
+ icon.src = row.icon;
160
+ icon.alt = '';
161
+ const label = document.createElement('span');
162
+ label.className = 'gen-select-option-label';
163
+ label.textContent = row.name;
164
+ item.append(icon, label);
165
+ const supportsReasoning = (row.reasoning?.length ?? 0) > 0;
166
+ if (supportsReasoning) {
167
+ const chevron = document.createElement('span');
168
+ chevron.className = 'material-symbols-outlined gen-select-option-chevron';
169
+ chevron.textContent = 'chevron_right';
170
+ item.appendChild(chevron);
171
+ item.onmouseenter = () => showPanel(row, item);
172
+ item.onclick = (e) => { e.stopPropagation(); showPanel(row, item); };
173
+ }
174
+ else {
175
+ item.onclick = (e) => {
176
+ e.stopPropagation();
177
+ value = row.value;
178
+ reasoning = undefined;
179
+ renderSelection();
180
+ closeMenu();
181
+ opts.onChange?.(value);
182
+ opts.onReasoningChange?.(undefined);
183
+ };
184
+ item.onmouseenter = () => hidePanel();
185
+ }
186
+ menu.appendChild(item);
187
+ }
188
+ renderSelection();
189
+ };
190
+ renderMenu();
191
+ return {
192
+ getValue: () => value,
193
+ setValue: (next) => { value = next; renderSelection(); },
194
+ getReasoning: () => reasoning,
195
+ setReasoning: (next) => { reasoning = next; renderSelection(); },
196
+ setOptions: (next) => { options = next; renderMenu(); },
197
+ destroy: () => {
198
+ document.removeEventListener('click', onDocClick);
199
+ container.removeEventListener('keydown', onKeyDown);
200
+ container.innerHTML = '';
201
+ container.classList.remove('gen-select', 'open');
202
+ },
203
+ };
204
+ }
205
+ function prettyEnum(value) {
206
+ return value.replace(/_/g, ' ').toLowerCase().replace(/\b\w/g, (c) => c.toUpperCase());
207
+ }
208
+ function formatIncome(value) {
209
+ if (value >= 1000)
210
+ return `$${(value / 1000).toFixed(value % 1000 === 0 ? 0 : 1)}k`;
211
+ return `$${value}`;
212
+ }
213
+ export function createDemographic(container, opts = {}) {
214
+ let value = { ...(opts.value ?? {}) };
215
+ container.classList.add('gen-demographic');
216
+ container.innerHTML = '';
217
+ const emit = () => opts.onChange?.({ ...value });
218
+ const addSlider = (key, label, min, max, fallback, format) => {
219
+ const row = document.createElement('div');
220
+ row.className = 'gen-demographic-row';
221
+ const head = document.createElement('div');
222
+ head.className = 'gen-demographic-head';
223
+ const title = document.createElement('span');
224
+ title.textContent = label;
225
+ const readout = document.createElement('span');
226
+ readout.className = 'gen-demographic-readout';
227
+ head.append(title, readout);
228
+ const input = document.createElement('input');
229
+ input.type = 'range';
230
+ input.min = String(min);
231
+ input.max = String(max);
232
+ input.step = key === 'income' ? '1000' : '1';
233
+ const paint = () => {
234
+ if (key === 'age' && value.age === undefined)
235
+ value.age = fallback;
236
+ if (key === 'income' && value.income === undefined)
237
+ value.income = fallback;
238
+ const set = value[key] ?? fallback;
239
+ input.value = String(set);
240
+ readout.textContent = format(set);
241
+ row.classList.add('is-set');
242
+ };
243
+ input.oninput = () => {
244
+ const next = Number(input.value);
245
+ if (key === 'age')
246
+ value.age = next;
247
+ else
248
+ value.income = next;
249
+ paint();
250
+ };
251
+ input.onchange = () => emit();
252
+ row.append(head, input);
253
+ container.appendChild(row);
254
+ paint();
255
+ return paint;
256
+ };
257
+ const addChips = (key, label, values) => {
258
+ const row = document.createElement('div');
259
+ row.className = 'gen-demographic-row';
260
+ const title = document.createElement('span');
261
+ title.className = 'gen-demographic-head';
262
+ title.textContent = label;
263
+ const chips = document.createElement('div');
264
+ chips.className = 'gen-demographic-chips';
265
+ const paint = () => {
266
+ const selected = key === 'sex' ? value.sex : value.race;
267
+ for (const button of Array.from(chips.children)) {
268
+ button.classList.toggle('is-selected', button.dataset.value === selected);
269
+ }
270
+ row.classList.toggle('is-set', selected !== undefined);
271
+ };
272
+ for (const item of values) {
273
+ const button = document.createElement('button');
274
+ button.type = 'button';
275
+ button.dataset.value = item;
276
+ button.textContent = prettyEnum(item);
277
+ button.onclick = () => {
278
+ if (key === 'sex') {
279
+ value.sex = value.sex === item ? undefined : item;
280
+ }
281
+ else {
282
+ value.race = value.race === item ? undefined : item;
283
+ }
284
+ paint();
285
+ emit();
286
+ };
287
+ chips.appendChild(button);
288
+ }
289
+ row.append(title, chips);
290
+ container.appendChild(row);
291
+ paint();
292
+ return paint;
293
+ };
294
+ const skip = new Set(opts.omit ?? []);
295
+ const paints = [
296
+ !skip.has('age') && addSlider('age', 'Age', 18, 90, 35, (n) => String(n)),
297
+ !skip.has('income') && addSlider('income', 'Income', 0, 250000, 75000, formatIncome),
298
+ !skip.has('sex') && addChips('sex', 'Sex', Object.values(Fauna.Ant.Persona.Sex)),
299
+ !skip.has('race') && addChips('race', 'Race', Object.values(Fauna.Ant.Persona.Race)),
300
+ ].filter((paint) => Boolean(paint));
301
+ return {
302
+ getValue: () => ({ ...value }),
303
+ setValue: (next) => {
304
+ value = { ...next };
305
+ for (const paint of paints)
306
+ paint();
307
+ },
308
+ destroy: () => {
309
+ container.innerHTML = '';
310
+ container.classList.remove('gen-demographic');
311
+ },
312
+ };
313
+ }
@@ -0,0 +1,6 @@
1
+ export declare function createHoveringElement(elements: HTMLElement[], key?: HTMLElement): HTMLElement;
2
+ export declare function openHovering(element: HTMLElement, position: [number, number]): void;
3
+ export declare function closeHovering(element: HTMLElement): void;
4
+ export declare function createTooltip(target: HTMLElement, text: string, delay?: number): {
5
+ setText: (next: string) => void;
6
+ };
@@ -0,0 +1,210 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { createRoot } from "react-dom/client";
4
+ import gsap from "gsap";
5
+ let nextId = 1;
6
+ const POPOVERS = [];
7
+ const TOOLTIPS = [];
8
+ let listener = null;
9
+ function notify() {
10
+ listener?.();
11
+ }
12
+ // ─── Public API (imperative, unchanged signatures) ────────────────────────────
13
+ // Build a popover menu from pre-rendered nodes. When a `key` element is given,
14
+ // clicking it toggles the popover open/closed beneath it, and the popover is
15
+ // torn down automatically once the key leaves the DOM. Returns a lightweight
16
+ // host element for API compatibility (drive uses the key-driven flow and never
17
+ // touches the return value).
18
+ export function createHoveringElement(elements, key) {
19
+ ensureMounted();
20
+ const entry = { id: nextId++, nodes: elements, position: null, open: false };
21
+ POPOVERS.push(entry);
22
+ notify();
23
+ // A detached stand-in so the historical `HTMLElement` return contract holds.
24
+ const host = document.createElement('div');
25
+ host.className = 'hover';
26
+ host.__hoverId = entry.id;
27
+ if (key) {
28
+ key.addEventListener('click', (ev) => {
29
+ ev.stopPropagation();
30
+ if (entry.open) {
31
+ closeEntry(entry);
32
+ }
33
+ else {
34
+ const rect = key.getBoundingClientRect();
35
+ openEntry(entry, [rect.left, rect.top + rect.height]);
36
+ }
37
+ });
38
+ const observer = new MutationObserver(() => {
39
+ if (!key.isConnected) {
40
+ removeEntry(entry);
41
+ observer.disconnect();
42
+ }
43
+ });
44
+ observer.observe(document.body, { childList: true, subtree: true });
45
+ }
46
+ return host;
47
+ }
48
+ // Programmatically open/close a popover by its host element (kept for API
49
+ // parity with the old exports). Positions are viewport coordinates.
50
+ export function openHovering(element, position) {
51
+ const entry = POPOVERS.find((p) => p.id === element.__hoverId);
52
+ if (entry)
53
+ openEntry(entry, position);
54
+ }
55
+ export function closeHovering(element) {
56
+ const entry = POPOVERS.find((p) => p.id === element.__hoverId);
57
+ if (entry)
58
+ closeEntry(entry);
59
+ }
60
+ // Attach a delayed tooltip to any element. Shows `text` after `delay` ms of
61
+ // hover; hides on leave; self-destructs when the target leaves the DOM.
62
+ export function createTooltip(target, text, delay = 1000) {
63
+ ensureMounted();
64
+ const entry = { id: nextId++, text, position: null, visible: false };
65
+ TOOLTIPS.push(entry);
66
+ notify();
67
+ let timer = null;
68
+ target.addEventListener('mouseenter', () => {
69
+ timer = setTimeout(() => {
70
+ const rect = target.getBoundingClientRect();
71
+ entry.position = [rect.left + rect.width / 2, rect.top - 6];
72
+ entry.visible = true;
73
+ notify();
74
+ }, delay);
75
+ });
76
+ target.addEventListener('mouseleave', () => {
77
+ if (timer) {
78
+ clearTimeout(timer);
79
+ timer = null;
80
+ }
81
+ entry.visible = false;
82
+ notify();
83
+ });
84
+ const observer = new MutationObserver(() => {
85
+ if (!target.isConnected) {
86
+ const idx = TOOLTIPS.indexOf(entry);
87
+ if (idx >= 0)
88
+ TOOLTIPS.splice(idx, 1);
89
+ notify();
90
+ observer.disconnect();
91
+ }
92
+ });
93
+ observer.observe(document.body, { childList: true, subtree: true });
94
+ return {
95
+ setText: (next) => {
96
+ entry.text = next;
97
+ if (entry.visible)
98
+ notify();
99
+ },
100
+ };
101
+ }
102
+ // ─── Store mutators ────────────────────────────────────────────────────────────
103
+ function openEntry(entry, position) {
104
+ entry.position = position;
105
+ entry.open = true;
106
+ notify();
107
+ }
108
+ function closeEntry(entry) {
109
+ entry.open = false;
110
+ notify();
111
+ }
112
+ function removeEntry(entry) {
113
+ const idx = POPOVERS.indexOf(entry);
114
+ if (idx >= 0)
115
+ POPOVERS.splice(idx, 1);
116
+ notify();
117
+ }
118
+ // ─── Global dismissers (click outside / keydown / resize) ──────────────────────
119
+ if (typeof window !== 'undefined') {
120
+ window.addEventListener('click', (ev) => {
121
+ for (let i = POPOVERS.length - 1; i >= 0; i--) {
122
+ const entry = POPOVERS[i];
123
+ if (!entry.open)
124
+ continue;
125
+ // Don't dismiss when the click lands inside the popover's own nodes.
126
+ const inside = entry.nodes.some((n) => n.contains(ev.target) || n.parentElement?.contains(ev.target));
127
+ if (!inside)
128
+ closeEntry(entry);
129
+ }
130
+ });
131
+ window.addEventListener('keydown', () => {
132
+ for (const entry of POPOVERS)
133
+ if (entry.open)
134
+ closeEntry(entry);
135
+ });
136
+ window.addEventListener('resize', () => {
137
+ for (const entry of POPOVERS)
138
+ if (entry.open)
139
+ closeEntry(entry);
140
+ });
141
+ }
142
+ // ─── React component + self-mount ──────────────────────────────────────────────
143
+ const PORTAL_ID = 'fauna-hover-portal';
144
+ let mounted = false;
145
+ function ensureMounted() {
146
+ if (mounted || typeof document === 'undefined')
147
+ return;
148
+ mounted = true;
149
+ const host = document.createElement('div');
150
+ host.id = PORTAL_ID;
151
+ document.body.appendChild(host);
152
+ createRoot(host).render(_jsx(HoverRoot, {}));
153
+ }
154
+ function HoverRoot() {
155
+ const [, force] = useState(0);
156
+ useEffect(() => {
157
+ listener = () => force((n) => n + 1);
158
+ return () => { listener = null; };
159
+ }, []);
160
+ return (_jsxs(_Fragment, { children: [POPOVERS.map((entry) => _jsx(HoverPopover, { entry: entry }, entry.id)), TOOLTIPS.map((entry) => _jsx(HoverTooltip, { entry: entry }, entry.id))] }));
161
+ }
162
+ function HoverPopover({ entry }) {
163
+ const ref = useRef(null);
164
+ // Host the pre-built nodes verbatim (they carry their own click handlers).
165
+ useEffect(() => {
166
+ const el = ref.current;
167
+ if (!el)
168
+ return;
169
+ for (const node of entry.nodes)
170
+ el.appendChild(node);
171
+ return () => {
172
+ for (const node of entry.nodes)
173
+ if (node.parentElement === el)
174
+ el.removeChild(node);
175
+ };
176
+ }, []);
177
+ // Animate open/close to match the original gsap height/opacity transition.
178
+ useEffect(() => {
179
+ const el = ref.current;
180
+ if (!el)
181
+ return;
182
+ gsap.killTweensOf(el);
183
+ if (entry.open && entry.position) {
184
+ gsap.set(el, { left: entry.position[0], top: entry.position[1] });
185
+ gsap.to(el, { duration: 0.3, opacity: 1, display: 'flex', height: 'auto', ease: 'linear' });
186
+ }
187
+ else {
188
+ gsap.to(el, { duration: 0.3, opacity: 0, display: 'none', height: 0, ease: 'linear' });
189
+ }
190
+ }, [entry.open, entry.position]);
191
+ return _jsx("div", { ref: ref, className: "hover", style: { opacity: 0, display: 'none', height: 0 } });
192
+ }
193
+ function HoverTooltip({ entry }) {
194
+ const ref = useRef(null);
195
+ useEffect(() => {
196
+ const el = ref.current;
197
+ if (!el)
198
+ return;
199
+ gsap.killTweensOf(el);
200
+ if (entry.visible && entry.position) {
201
+ el.style.left = `${entry.position[0]}px`;
202
+ el.style.top = `${entry.position[1]}px`;
203
+ gsap.to(el, { duration: 0.2, opacity: 1, y: -4, display: 'block', ease: 'power2.out' });
204
+ }
205
+ else {
206
+ gsap.to(el, { duration: 0.15, opacity: 0, y: 0, display: 'none', ease: 'power2.in' });
207
+ }
208
+ }, [entry.visible, entry.position]);
209
+ return _jsx("div", { ref: ref, className: "tooltip", children: entry.text });
210
+ }
@@ -0,0 +1,42 @@
1
+ import * as DriveUI from "./drive.js";
2
+ import * as HoverUI from "./hover.js";
3
+ import * as ToastUI from "./toast.js";
4
+ import * as ChatUI from "./chat.js";
5
+ import * as GenerativeUI from "./generative.js";
6
+ import * as TalkUI from "./talk.js";
7
+ import * as TokenizedInputUI from "./tokenized.js";
8
+ import * as IntegrationsUI from "./integrations.js";
9
+ import * as AuthentificationUI from "./authentification.js";
10
+ import * as DeviceUI from "./device.js";
11
+ import * as CursorUI from "./cursor.js";
12
+ import * as TicketsUI from "./tickets.js";
13
+ import * as BrandsUI from "./brands.js";
14
+ import * as BrowserUI from "./browser.js";
15
+ import * as RosterUI from "./roster.js";
16
+ import * as MapsUI from "./maps.js";
17
+ import * as ViewUI from "./view.js";
18
+ export declare namespace UI {
19
+ function setRoute(route: string): void;
20
+ function getIP(): string;
21
+ function getPort(): number;
22
+ function getRoute(): string;
23
+ function getURL(): string;
24
+ function ping(): Promise<number>;
25
+ export import File = DriveUI;
26
+ export import Hover = HoverUI;
27
+ export import Toast = ToastUI;
28
+ export import Chat = ChatUI;
29
+ export import Generative = GenerativeUI;
30
+ export import Talk = TalkUI;
31
+ export import TokenizedInput = TokenizedInputUI;
32
+ export import Integrations = IntegrationsUI;
33
+ export import Authentification = AuthentificationUI;
34
+ export import Device = DeviceUI;
35
+ export import Cursor = CursorUI;
36
+ export import Tickets = TicketsUI;
37
+ export import Brands = BrandsUI;
38
+ export import Browser = BrowserUI;
39
+ export import Roster = RosterUI;
40
+ export import Maps = MapsUI;
41
+ export import View = ViewUI;
42
+ }