@arbidocs/blocks 0.5.43 → 0.5.45

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 (45) hide show
  1. package/README.md +14 -0
  2. package/dist/agents/definitions/agentTasks.d.ts +4 -0
  3. package/dist/agents/definitions/index.d.ts +1 -0
  4. package/dist/agents/index.cjs +14 -10
  5. package/dist/agents/index.js +1 -1
  6. package/dist/calls/index.cjs +73 -696
  7. package/dist/calls/index.cjs.map +1 -1
  8. package/dist/calls/index.js +10 -666
  9. package/dist/calls/index.js.map +1 -1
  10. package/dist/{chunk-6AJJJ5HR.cjs → chunk-5R256EMF.cjs} +671 -3
  11. package/dist/chunk-5R256EMF.cjs.map +1 -0
  12. package/dist/{chunk-E3IEZMRK.cjs → chunk-ET42AFEJ.cjs} +15 -2
  13. package/dist/chunk-ET42AFEJ.cjs.map +1 -0
  14. package/dist/{chunk-FOIDBAZB.js → chunk-OQMWTEM2.js} +15 -3
  15. package/dist/chunk-OQMWTEM2.js.map +1 -0
  16. package/dist/{chunk-4U4NXFV5.js → chunk-TKTNXFAB.js} +666 -9
  17. package/dist/chunk-TKTNXFAB.js.map +1 -0
  18. package/dist/connect/index.cjs +1736 -482
  19. package/dist/connect/index.cjs.map +1 -1
  20. package/dist/connect/index.d.ts +2 -0
  21. package/dist/connect/index.js +1729 -479
  22. package/dist/connect/index.js.map +1 -1
  23. package/dist/connection/ConnectedFilterDropdown.d.ts +6 -0
  24. package/dist/connection/agents/useConnectedAgentManagement.d.ts +60 -0
  25. package/dist/connection/conversation/ConnectedConversation.d.ts +7 -9
  26. package/dist/connection/conversation/ConnectedConversationPage.d.ts +30 -0
  27. package/dist/connection/conversation/SemanticSearchButton.d.ts +12 -0
  28. package/dist/connection/files/imports/ConnectedAccountsImport.d.ts +16 -0
  29. package/dist/connection/files/imports/DriveImportPanel.d.ts +10 -0
  30. package/dist/connection/files/imports/EmailImportPanel.d.ts +21 -0
  31. package/dist/connection/files/imports/ImportHandoff.d.ts +24 -0
  32. package/dist/connection/files/imports/useDriveSyncTrigger.d.ts +11 -0
  33. package/dist/connection/files/imports/useEmailSyncTrigger.d.ts +11 -0
  34. package/dist/connection/files/imports/useImportHandoff.d.ts +20 -0
  35. package/dist/connection/files/index.d.ts +1 -0
  36. package/dist/index.cjs +14 -10
  37. package/dist/index.js +1 -1
  38. package/dist/workflow-canvas/index.cjs +2 -2
  39. package/dist/workflow-canvas/index.js +1 -1
  40. package/node_modules/@arbidocs/coedit/package.json +1 -1
  41. package/package.json +5 -5
  42. package/dist/chunk-4U4NXFV5.js.map +0 -1
  43. package/dist/chunk-6AJJJ5HR.cjs.map +0 -1
  44. package/dist/chunk-E3IEZMRK.cjs.map +0 -1
  45. package/dist/chunk-FOIDBAZB.js.map +0 -1
@@ -1,9 +1,9 @@
1
1
  "use client";
2
- import { SaveTranscriptToThread, RecordingsList, useMeetingThreadMessages, useProvisionalSpeakers, CallConversationEmpty, ProvisionalSpeakers, RecordingCard, TranscriptEntry } from '../chunk-4U4NXFV5.js';
3
- export { CallConversationEmpty, PickThreadDialog, ProvisionalSpeakers, RecordingCard, RecordingsList, SaveTranscriptToThread, ThreadCallLogCard, TranscriptEntry, TranscriptRunsContext, threadTranscriptRuns, useCallPersonName, useProvisionalSpeakers, useTranscriptRuns } from '../chunk-4U4NXFV5.js';
4
- import { useRingtoneMuted, useRingtone, IncomingCallCard, CallUserPill, contactsCallTitle, usePendingRecording, HeaderAction, isCallLive, formatCallDuration } from '../chunk-S3YRRD54.js';
2
+ import { StartCallButton, CallPeoplePicker, useProvisionalSpeakers, CallConversationEmpty, RecordingsList, SaveTranscriptToThread, ProvisionalSpeakers, RecordingCard, TranscriptEntry } from '../chunk-TKTNXFAB.js';
3
+ export { CallConversationEmpty, CallPeoplePicker, ConnectedConversationCallActions, MeetingThreadRecordingsAction, MeetingThreadTranscriptAction, PickThreadDialog, ProvisionalSpeakers, RecordingCard, RecordingsList, SaveTranscriptToThread, ScheduleCallButton, StartCallButton, ThreadCallButton, ThreadCallLogCard, TranscriptEntry, TranscriptRunsContext, buildCallCandidates, callContactOf, isPickable, matchesQuery, threadTranscriptRuns, useCallPersonName, useProvisionalSpeakers, useTranscriptRuns } from '../chunk-TKTNXFAB.js';
4
+ import { useRingtoneMuted, useRingtone, IncomingCallCard, CallUserPill, contactsCallTitle, isCallLive, formatCallDuration, usePendingRecording } from '../chunk-S3YRRD54.js';
5
5
  export { BackstageBanner, CHAT_ID_PATTERN, COMPOSITE_FPS, COMPOSITE_MAX_HEIGHT, COMPOSITE_MAX_WIDTH, CallControlBar, CallControlButton, CallFocus, CallGrid, CallHeader, CallNotice, CallParticipants, CallPersonLabel, CallSidePanel, CallStageFrame, CallStateMessage, CallStatusChip, CallTile, CallUserPill, CallsExperimentalBadge, CaptionsStrip, ChatPermissionSetting, ConnectionOverlay, ControlBadge, ControlDivider, ControlGroup, EXPIRY_DAYS, ElapsedTime, EncryptionStatusChip, HeaderAction, IncomingCallCard, LEVEL_TICK_MS, LeaveButton, LobbyRequests, MIRROR_SELF_VIEW_KEY, MODE_LABEL, MediaControl, MinimisedCall, MoreMenu, OnStageCheck, PanelComposer, PreJoin, QAPanel, RECORDING_ID_PATTERN, RINGTONE_MUTED_KEY, RaiseHandButton, RecordControl, RecordingStatusChip, SpeakingNow, TranscriptionStatusChip, VoiceMeter, WebinarAudiencePanel, WebinarEndConfirm, WebinarLiveChip, WebinarLiveControl, WebinarViewer, WebinarWaiting, chatPermissionSection, contactsCallTitle, describeMediaError, drawStageFrame, expiryChoiceOf, expiryFor, fitMedia, fitStage, formatCallDuration, getPendingRecording, isCallLive, parseCallLogDetail, parseRecordingLinkParams, publishCallStatus, recordingLink, setMirrorSelfView, setPendingRecording, sortQuestions, startCompositeCapture, startRingtone, startVoiceLevels, useBriefNotice, useElementSize, useIsSpeaking, useMirrorSelfView, useMyCallStatus, usePendingRecording, useRingtone, useRingtoneMuted, useShortcutKeys, useSpeakingIds, useSpotlightId, useVoiceLevel, useVoiceLevels } from '../chunk-S3YRRD54.js';
6
- import { useConnectedConversations } from '../chunk-SYP2A4GQ.js';
6
+ import '../chunk-SYP2A4GQ.js';
7
7
  import { useConnectedWorkspace } from '../chunk-7LN3ISPG.js';
8
8
  import { DmInviteChip } from '../chunk-2S3LT5KE.js';
9
9
  import '../chunk-ILBBV2ZY.js';
@@ -13,17 +13,17 @@ import { transcriptRuns, ConversationFilter } from '../chunk-6AMCMKTF.js';
13
13
  export { CAPTION_LINES, CAPTION_TTL_MS, INITIAL_SPOTLIGHT, MAX_GRID_TILES, NOTICE_MS, SPEAKER_ACCENTS, SPEAKING_LEVEL, TILE_ASPECT, formatElapsed, gridLayout, gridSlots, initialsOf, nearestCorner, nextSpotlight, pickSpotlight, rowCounts, speakerAccent, speakerBorder, spotlightBox, stageContentHeight } from '../chunk-6AMCMKTF.js';
14
14
  import '../chunk-7Q5INDUS.js';
15
15
  import '../chunk-NPLYHR2E.js';
16
- import { useBlocksEnvironment, requestCalendarComposer } from '../chunk-QZUZPC4J.js';
16
+ import '../chunk-QZUZPC4J.js';
17
17
  import '../chunk-U4HWVCRN.js';
18
18
  import '../chunk-TX2ZICS7.js';
19
19
  import '../chunk-7F6CBP3Z.js';
20
20
  import '../chunk-VUNV25KB.js';
21
21
  import { lazy, useState, Suspense, useEffect, useMemo, Fragment as Fragment$1 } from 'react';
22
- import { useArbi, useCallSession, declineRing, useCallsEnabled, useCanHostCalls, useCreateContact, useWorkspaces, usePeople, usePeopleSearch, threadLiveCallId, openCall, startThreadCall, chatLiveCallId, startChatCall, userDisplayName, startDmCall, startContactsCall, useConversationItems, useCall, useWorkspaceUsers, threadTranscriptLines, useArbiSessionState, useConversationData, hasRecordingTranscript, chatTranscriptRef, useRecordingWindows, supersededTranscriptLines, sortTranscriptMessages, DateSeparator, acceptRing, callSession, useRevokeCallInviteLink, useCallInviteLinks } from '@arbidocs/react';
22
+ import { useArbi, useCallSession, declineRing, useCallsEnabled, chatLiveCallId, useCanHostCalls, openCall, startChatCall, userDisplayName, startDmCall, startContactsCall, useCall, hasRecordingTranscript, chatTranscriptRef, useRecordingWindows, supersededTranscriptLines, sortTranscriptMessages, DateSeparator, acceptRing, callSession } from '@arbidocs/react';
23
23
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
24
- import { Phone, UserPlus, CalendarPlus, Disc, PhoneOff, Mail, X } from 'lucide-react';
25
- import { Tooltip, TooltipTrigger, Button, cn, TooltipContent, isAgent, Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, Input, DialogFooter, getUserDisplayName, Checkbox } from '@arbidocs/react/ui';
26
- import { chats, ArbiApiError, refusalReason } from '@arbidocs/sdk/browser';
24
+ import { isAgent, getUserDisplayName, Button } from '@arbidocs/react/ui';
25
+ import { Phone, PhoneOff } from 'lucide-react';
26
+ import { chats } from '@arbidocs/sdk/browser';
27
27
 
28
28
  var RING_TIMEOUT_MS = 3e4;
29
29
  function useRingTimeout(ring) {
@@ -78,511 +78,6 @@ function ConnectedCallLayer() {
78
78
  hasIncomingCall && callsEnabled && /* @__PURE__ */ jsx(ConnectedIncomingCall, {})
79
79
  ] });
80
80
  }
81
- function StartCallButton(props) {
82
- const enabled = useCallsEnabled();
83
- const canHost = useCanHostCalls();
84
- return enabled && (canHost || props.isLive) ? /* @__PURE__ */ jsx(EnabledStartCallButton, { ...props }) : null;
85
- }
86
- function EnabledStartCallButton({
87
- onStart,
88
- isLive = false,
89
- label = "Start call",
90
- testId = "start-call-button"
91
- }) {
92
- const [isStarting, setIsStarting] = useState(false);
93
- const inCall = useCallSession((s) => s.active !== null);
94
- const text = inCall ? "Already in a call" : isLive ? "Join call" : label;
95
- return /* @__PURE__ */ jsxs(Tooltip, { children: [
96
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
97
- Button,
98
- {
99
- type: "button",
100
- variant: "ghost",
101
- size: "icon",
102
- "aria-label": isLive ? "Join call" : label,
103
- "data-testid": testId,
104
- "data-live": isLive || void 0,
105
- disabled: isStarting || inCall,
106
- onClick: () => {
107
- setIsStarting(true);
108
- void onStart().finally(() => setIsStarting(false));
109
- },
110
- className: cn(
111
- "text-muted-foreground hover:text-foreground",
112
- isLive && "text-green-text hover:text-green-text"
113
- ),
114
- children: /* @__PURE__ */ jsx(Phone, { className: cn("size-5", isLive && "animate-pulse") })
115
- }
116
- ) }),
117
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: text }) })
118
- ] });
119
- }
120
- var INVITE_LINK_HINT = "will get an invitation to create an ARBI account and join";
121
- var NO_KEY_REASON = "Cannot receive encrypted calls yet";
122
- var NO_EMAIL_REASON = "No e-mail address to send a link to";
123
- function contactName(contact) {
124
- return contact.card?.name?.trim() || [contact.card?.given_name, contact.card?.family_name].filter(Boolean).join(" ") || (contact.user ? getUserDisplayName(contact.user) : "") || contactEmail(contact) || "Contact";
125
- }
126
- function contactEmail(contact) {
127
- return contact.email ?? contact.user?.email ?? contact.card?.emails?.[0]?.email ?? null;
128
- }
129
- function callContactOf(contact) {
130
- if (!contact.external_id || contact.status === "failed") return null;
131
- if (contact.user && isAgent(contact.user)) return null;
132
- return {
133
- contactExtId: contact.external_id,
134
- user: contact.user ?? null,
135
- name: contactName(contact),
136
- email: contactEmail(contact)
137
- };
138
- }
139
- function userCandidate(user, section, status, contactExtId = null) {
140
- const ringable = status !== "ring" || !!user.encryption_public_key;
141
- return {
142
- id: user.external_id,
143
- name: getUserDisplayName(user) || user.email,
144
- email: user.email ?? null,
145
- section,
146
- status: ringable ? status : "unavailable",
147
- reason: ringable ? void 0 : NO_KEY_REASON,
148
- user,
149
- contactExtId
150
- };
151
- }
152
- function buildCallCandidates(opts) {
153
- const seen = /* @__PURE__ */ new Set();
154
- const out = [];
155
- const add = (c) => {
156
- if (seen.has(c.id)) return;
157
- seen.add(c.id);
158
- out.push(c);
159
- };
160
- const people = (users) => users.filter((u) => !isAgent(u) && u.external_id !== opts.me);
161
- if (opts.scope !== "contacts") {
162
- for (const u of people(opts.members)) add(userCandidate(u, "members", "ring"));
163
- return out;
164
- }
165
- const contacts = (opts.contacts ?? []).filter((c) => !(c.user && isAgent(c.user)));
166
- const contactOf = new Map(
167
- contacts.filter((c) => c.user).map((c) => [c.user.external_id, c.contactExtId])
168
- );
169
- for (const u of people(opts.members)) {
170
- const contactId = contactOf.get(u.external_id) ?? opts.contactIdOf?.(u) ?? null;
171
- add(userCandidate(u, "members", contactId ? "ring" : "add-contact", contactId));
172
- }
173
- for (const c of contacts) {
174
- if (c.user) {
175
- if (c.user.external_id === opts.me) continue;
176
- add(userCandidate(c.user, "contacts", "ring", c.contactExtId));
177
- continue;
178
- }
179
- const status = c.email ? "invite" : "unavailable";
180
- add({
181
- id: c.contactExtId,
182
- name: c.name,
183
- email: c.email,
184
- section: "contacts",
185
- status,
186
- reason: c.email ? INVITE_LINK_HINT : NO_EMAIL_REASON,
187
- user: null,
188
- contactExtId: c.contactExtId
189
- });
190
- }
191
- return out;
192
- }
193
- function isPickable(c) {
194
- return c.status === "ring" || c.status === "invite";
195
- }
196
- function matchesQuery(c, query) {
197
- const q = query.trim().toLowerCase();
198
- if (!q) return true;
199
- return c.name.toLowerCase().includes(q) || (c.email ?? "").toLowerCase().includes(q);
200
- }
201
- var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
202
- var COPY = {
203
- workspace: {
204
- title: "Call thread members",
205
- description: "Only members of this thread\u2019s workspace can join. Pick who to ring \u2014 or nobody, and share the call from the thread.",
206
- action: "Start call"
207
- },
208
- chat: {
209
- title: "Call the group",
210
- description: "The people you pick are rung.",
211
- action: "Start call"
212
- },
213
- contacts: {
214
- title: "New call",
215
- description: "Your contacts with an ARBI account are rung. Others get an invitation to create an account and join.",
216
- action: "Start call"
217
- }
218
- };
219
- function CandidateRow({
220
- candidate,
221
- checked,
222
- onToggle,
223
- onAddContact,
224
- adding
225
- }) {
226
- const pickable = isPickable(candidate);
227
- const hint = candidate.status === "invite" ? candidate.reason : candidate.status === "add-contact" ? "Not in your contacts" : void 0;
228
- const row = /* @__PURE__ */ jsxs(
229
- "li",
230
- {
231
- className: cn(
232
- "flex items-center gap-3 rounded-md px-2 py-1.5",
233
- pickable ? "hover:bg-muted" : "opacity-60"
234
- ),
235
- "data-testid": `call-picker-row-${candidate.id}`,
236
- "data-status": candidate.status,
237
- "aria-disabled": !pickable || void 0,
238
- children: [
239
- /* @__PURE__ */ jsx(
240
- Checkbox,
241
- {
242
- checked,
243
- disabled: !pickable,
244
- onCheckedChange: onToggle,
245
- "aria-label": `Invite ${candidate.name}`,
246
- "data-testid": `call-picker-check-${candidate.id}`
247
- }
248
- ),
249
- /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
250
- /* @__PURE__ */ jsx("span", { className: "block truncate text-sm", children: candidate.name }),
251
- /* @__PURE__ */ jsxs("span", { className: "block truncate text-xs text-muted-foreground", children: [
252
- candidate.email,
253
- hint && /* @__PURE__ */ jsxs("span", { className: "ml-1 inline-flex items-center gap-1", children: [
254
- candidate.status === "invite" && /* @__PURE__ */ jsx(Mail, { className: "size-3", "aria-hidden": true }),
255
- candidate.email ? `\xB7 ${hint}` : hint
256
- ] })
257
- ] })
258
- ] }),
259
- candidate.status === "add-contact" && /* @__PURE__ */ jsxs(
260
- Button,
261
- {
262
- type: "button",
263
- size: "sm",
264
- variant: "outline",
265
- disabled: adding,
266
- onClick: onAddContact,
267
- "data-testid": `call-picker-add-${candidate.id}`,
268
- children: [
269
- /* @__PURE__ */ jsx(UserPlus, { className: "mr-1 size-3.5" }),
270
- "Add contact"
271
- ]
272
- }
273
- )
274
- ]
275
- }
276
- );
277
- if (candidate.status !== "unavailable" || !candidate.reason) return row;
278
- return /* @__PURE__ */ jsxs(Tooltip, { children: [
279
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: row }),
280
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: candidate.reason }) })
281
- ] });
282
- }
283
- function InviteLinks({ callExtId }) {
284
- const { notify } = useBlocksEnvironment();
285
- const revokeLink = useRevokeCallInviteLink(callExtId);
286
- const { data: invites = [] } = useCallInviteLinks(callExtId);
287
- const live = invites.filter((i) => !i.revoked_at);
288
- if (!live.length) return null;
289
- const revoke = async (id) => {
290
- try {
291
- await revokeLink(id);
292
- } catch (err) {
293
- notify(err instanceof Error ? err.message : "Could not revoke the link", "error");
294
- }
295
- };
296
- return /* @__PURE__ */ jsxs("section", { className: "flex flex-col gap-1", "data-testid": "call-picker-invite-links", children: [
297
- /* @__PURE__ */ jsx("h3", { className: "text-xs font-medium text-muted-foreground", children: "Invitations sent" }),
298
- /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-1", children: live.map((invite) => /* @__PURE__ */ jsxs("li", { className: "flex items-center gap-2 text-sm", children: [
299
- /* @__PURE__ */ jsx(Mail, { className: "size-3.5 text-muted-foreground", "aria-hidden": true }),
300
- /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children: invite.email }),
301
- invite.used_at && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "joined" }),
302
- /* @__PURE__ */ jsxs(
303
- Button,
304
- {
305
- type: "button",
306
- size: "sm",
307
- variant: "ghost",
308
- onClick: () => void revoke(invite.external_id),
309
- "data-testid": `call-picker-revoke-${invite.external_id}`,
310
- children: [
311
- /* @__PURE__ */ jsx(X, { className: "mr-1 size-3.5" }),
312
- "Revoke"
313
- ]
314
- }
315
- )
316
- ] }, invite.external_id)) })
317
- ] });
318
- }
319
- function CallPeoplePicker({
320
- open,
321
- onOpenChange,
322
- scope,
323
- workspaceExtId,
324
- members: chatMembers = [],
325
- preselected = [],
326
- title,
327
- description,
328
- actionLabel,
329
- callExtId,
330
- onSubmit
331
- }) {
332
- const { notify } = useBlocksEnvironment();
333
- const createContact = useCreateContact();
334
- const { userId: me, workspaceId: selectedWorkspaceId } = useConnectedWorkspace();
335
- const { data: workspaces = [] } = useWorkspaces({ enabled: scope !== "chat" });
336
- const [picked, setPicked] = useState(() => new Set(preselected));
337
- const [query, setQuery] = useState("");
338
- const [newEmail, setNewEmail] = useState(null);
339
- const [newName, setNewName] = useState("");
340
- const [adding, setAdding] = useState(false);
341
- const [busy, setBusy] = useState(false);
342
- const [added, setAdded] = useState([]);
343
- const { byEmail } = usePeople();
344
- const { people: hits } = usePeopleSearch(open && scope === "contacts" ? query : "");
345
- const preselectedKey = preselected.join(",");
346
- useEffect(() => {
347
- if (open) setPicked(new Set(preselectedKey ? preselectedKey.split(",") : []));
348
- }, [open, preselectedKey]);
349
- const workspaceId = workspaceExtId ?? (scope === "contacts" ? selectedWorkspaceId : null);
350
- const workspaceMembers = useMemo(
351
- () => (workspaces.find((w) => w.external_id === workspaceId)?.users ?? []).map((wu) => wu.user),
352
- [workspaces, workspaceId]
353
- );
354
- const candidates = useMemo(() => {
355
- const found = hits.flatMap(
356
- (p) => p.contactId ? [{ contactExtId: p.contactId, user: p.user, name: p.name, email: p.email }] : []
357
- );
358
- return buildCallCandidates({
359
- scope,
360
- members: scope === "chat" ? chatMembers : workspaceMembers,
361
- contacts: [...added, ...found],
362
- contactIdOf: (u) => byEmail(u.email)?.contactId ?? null,
363
- me
364
- });
365
- }, [scope, chatMembers, workspaceMembers, hits, added, byEmail, me]);
366
- const shown = candidates.filter((c) => matchesQuery(c, query));
367
- const copy = COPY[scope];
368
- const toggle = (id) => setPicked((prev) => {
369
- const next = new Set(prev);
370
- if (next.has(id)) next.delete(id);
371
- else next.add(id);
372
- return next;
373
- });
374
- const addContact = async (email, name) => {
375
- setAdding(true);
376
- try {
377
- const cardName = name?.trim();
378
- const contact = await createContact.mutateAsync({
379
- email,
380
- invite: true,
381
- ...cardName ? { card: { name: cardName, emails: [{ email }] } } : {}
382
- });
383
- if (contact.status === "failed") {
384
- throw new Error(contact.outcome_detail || "Could not add the contact");
385
- }
386
- const added2 = callContactOf(contact);
387
- if (added2) setAdded((prev) => [...prev, added2]);
388
- const id = contact.user?.external_id ?? contact.external_id;
389
- const pickable = contact.user ? !!contact.user.encryption_public_key : !!added2?.email;
390
- if (id && pickable) setPicked((prev) => new Set(prev).add(id));
391
- setNewEmail(null);
392
- setNewName("");
393
- } catch (err) {
394
- notify(
395
- err instanceof ArbiApiError ? refusalReason(err, "Could not add the contact") : err instanceof Error ? err.message : "Could not add the contact",
396
- "error"
397
- );
398
- } finally {
399
- setAdding(false);
400
- }
401
- };
402
- const submit = async () => {
403
- if (busy) return;
404
- const chosen = candidates.filter((c) => picked.has(c.id) && isPickable(c));
405
- setBusy(true);
406
- try {
407
- await onSubmit({
408
- ring: chosen.filter((c) => c.status === "ring" && c.user).map((c) => c.user),
409
- invites: chosen.filter((c) => c.status === "invite" && c.contactExtId).map((c) => ({ contactExtId: c.contactExtId, name: c.name }))
410
- });
411
- onOpenChange(false);
412
- } catch (err) {
413
- notify(err instanceof Error ? err.message : "Something went wrong", "error");
414
- } finally {
415
- setBusy(false);
416
- }
417
- };
418
- const sections = scope === "contacts" ? [
419
- { id: "members", label: "Workspace members" },
420
- { id: "contacts", label: "Contacts" }
421
- ] : [{ id: "members", label: scope === "chat" ? "Members" : "Workspace members" }];
422
- const count = candidates.filter((c) => picked.has(c.id) && isPickable(c)).length;
423
- return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-md", "data-testid": "call-people-picker", children: [
424
- /* @__PURE__ */ jsxs(DialogHeader, { children: [
425
- /* @__PURE__ */ jsx(DialogTitle, { children: title ?? copy.title }),
426
- /* @__PURE__ */ jsx(DialogDescription, { children: description ?? copy.description })
427
- ] }),
428
- /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-col gap-3", children: [
429
- /* @__PURE__ */ jsx(
430
- Input,
431
- {
432
- placeholder: "Search people",
433
- value: query,
434
- onChange: (e) => setQuery(e.target.value),
435
- "aria-label": "Search people",
436
- "data-testid": "call-picker-search"
437
- }
438
- ),
439
- /* @__PURE__ */ jsxs("div", { className: "max-h-80 overflow-y-auto", children: [
440
- sections.map((section) => {
441
- const rows = shown.filter((c) => c.section === section.id);
442
- if (!rows.length) return null;
443
- return /* @__PURE__ */ jsxs("section", { className: "mb-2", children: [
444
- /* @__PURE__ */ jsx("h3", { className: "px-2 pb-1 text-xs font-medium text-muted-foreground", children: section.label }),
445
- /* @__PURE__ */ jsx("ul", { "data-testid": `call-picker-section-${section.id}`, children: rows.map((c) => /* @__PURE__ */ jsx(
446
- CandidateRow,
447
- {
448
- candidate: c,
449
- checked: picked.has(c.id),
450
- onToggle: () => toggle(c.id),
451
- adding,
452
- onAddContact: () => c.email && void addContact(c.email)
453
- },
454
- c.id
455
- )) })
456
- ] }, section.id);
457
- }),
458
- !shown.length && /* @__PURE__ */ jsx("p", { className: "px-2 py-3 text-sm text-muted-foreground", children: scope === "contacts" && !query.trim() ? "Search your contacts by name or e-mail." : candidates.length ? "Nobody matches." : "Nobody to call here yet." })
459
- ] }),
460
- scope === "contacts" && (newEmail === null ? /* @__PURE__ */ jsxs(
461
- Button,
462
- {
463
- type: "button",
464
- variant: "ghost",
465
- size: "sm",
466
- className: "self-start",
467
- onClick: () => setNewEmail(EMAIL_RE.test(query.trim()) ? query.trim() : ""),
468
- "data-testid": "call-picker-add-contact",
469
- children: [
470
- /* @__PURE__ */ jsx(UserPlus, { className: "mr-1 size-4" }),
471
- "Add contact\u2026"
472
- ]
473
- }
474
- ) : /* @__PURE__ */ jsxs(
475
- "form",
476
- {
477
- className: "flex flex-wrap items-center gap-2",
478
- onSubmit: (e) => {
479
- e.preventDefault();
480
- if (EMAIL_RE.test(newEmail.trim())) void addContact(newEmail.trim(), newName);
481
- },
482
- children: [
483
- /* @__PURE__ */ jsx(
484
- Input,
485
- {
486
- className: "min-w-[8rem] flex-1",
487
- placeholder: "Name (optional)",
488
- value: newName,
489
- maxLength: 200,
490
- onChange: (e) => setNewName(e.target.value),
491
- "aria-label": "New contact's name",
492
- autoComplete: "off",
493
- "data-testid": "call-picker-new-name"
494
- }
495
- ),
496
- /* @__PURE__ */ jsx(
497
- Input,
498
- {
499
- className: "min-w-[10rem] flex-1",
500
- type: "email",
501
- autoFocus: true,
502
- placeholder: "name@example.com",
503
- value: newEmail,
504
- onChange: (e) => setNewEmail(e.target.value),
505
- "aria-label": "New contact's e-mail",
506
- "data-testid": "call-picker-new-email"
507
- }
508
- ),
509
- /* @__PURE__ */ jsx(
510
- Button,
511
- {
512
- type: "submit",
513
- size: "sm",
514
- disabled: adding || !EMAIL_RE.test(newEmail.trim()),
515
- "data-testid": "call-picker-new-submit",
516
- children: "Add"
517
- }
518
- ),
519
- /* @__PURE__ */ jsx(
520
- Button,
521
- {
522
- type: "button",
523
- size: "sm",
524
- variant: "ghost",
525
- onClick: () => {
526
- setNewEmail(null);
527
- setNewName("");
528
- },
529
- children: "Cancel"
530
- }
531
- )
532
- ]
533
- }
534
- )),
535
- callExtId && scope === "contacts" && /* @__PURE__ */ jsx(InviteLinks, { callExtId }),
536
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Agents can\u2019t join calls." })
537
- ] }),
538
- /* @__PURE__ */ jsxs(DialogFooter, { children: [
539
- /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => onOpenChange(false), disabled: busy, children: "Cancel" }),
540
- /* @__PURE__ */ jsx(Button, { onClick: () => void submit(), disabled: busy, "data-testid": "call-picker-submit", children: busy ? "Working\u2026" : `${actionLabel ?? copy.action}${count ? ` (${count})` : ""}` })
541
- ] })
542
- ] }) });
543
- }
544
- function ThreadCallButton({
545
- conversationId
546
- }) {
547
- const arbi = useArbi();
548
- const { data: conversations } = useConnectedConversations();
549
- const { workspaceId: workspaceExtId } = useConnectedWorkspace();
550
- const liveCallId = useCallSession((s) => threadLiveCallId(s, conversationId));
551
- const isLive = liveCallId !== null;
552
- const canHost = useCanHostCalls();
553
- const [picking, setPicking] = useState(false);
554
- const conversation = conversations.find((c) => c.external_id === conversationId);
555
- if (!conversation?.is_shared) return null;
556
- const title = conversation.title ?? null;
557
- return /* @__PURE__ */ jsxs(Fragment, { children: [
558
- /* @__PURE__ */ jsx(
559
- StartCallButton,
560
- {
561
- onStart: async () => {
562
- if (liveCallId && !canHost) return openCall(arbi, { callExtId: liveCallId });
563
- if (isLive) return startThreadCall(arbi, { threadExtId: conversationId, title, ring: [] });
564
- setPicking(true);
565
- return true;
566
- },
567
- isLive,
568
- label: "Call thread members",
569
- testId: "thread-call-button"
570
- }
571
- ),
572
- picking && /* @__PURE__ */ jsx(
573
- CallPeoplePicker,
574
- {
575
- open: true,
576
- onOpenChange: setPicking,
577
- scope: "workspace",
578
- workspaceExtId,
579
- onSubmit: async ({ ring }) => {
580
- await startThreadCall(arbi, { threadExtId: conversationId, title, ring });
581
- }
582
- }
583
- )
584
- ] });
585
- }
586
81
  function GroupCallButton({
587
82
  chatExtId,
588
83
  title,
@@ -678,157 +173,6 @@ function EnabledNewCallChip() {
678
173
  )
679
174
  ] });
680
175
  }
681
- function ScheduleCallButton({
682
- conversationId,
683
- peer,
684
- variant = "icon",
685
- className
686
- }) {
687
- const callsEnabled = useCanHostCalls();
688
- const { conversations } = useConversationItems();
689
- const { data: workspaces = [] } = useWorkspaces();
690
- const { workspaceId: selectedWorkspaceId, userId: me } = useConnectedWorkspace();
691
- const { openCalendar } = useBlocksEnvironment();
692
- if (!callsEnabled) return null;
693
- const open = () => {
694
- const conversation = conversationId ? conversations?.find((c) => c.external_id === conversationId) : void 0;
695
- let people = [];
696
- if (peer) people = [peer];
697
- else if (conversation?.is_shared) {
698
- const workspace = workspaces.find((w) => w.external_id === selectedWorkspaceId);
699
- people = (workspace?.users ?? []).map((wu) => wu.user);
700
- }
701
- requestCalendarComposer({
702
- title: peer ? `Call with ${getUserDisplayName(peer) || peer.email}` : conversation?.title ?? "",
703
- conversationId: conversationId ?? null,
704
- attendees: people.filter((u) => !isAgent(u) && u.external_id !== me).map((u) => ({
705
- email: u.email,
706
- user_id: u.external_id,
707
- name: getUserDisplayName(u) || null
708
- })),
709
- addCall: true
710
- });
711
- openCalendar();
712
- };
713
- return /* @__PURE__ */ jsxs(
714
- Button,
715
- {
716
- type: "button",
717
- variant: "ghost",
718
- size: variant === "icon" ? "icon" : "sm",
719
- className: cn(variant === "icon" && "size-8", className),
720
- onClick: open,
721
- "aria-label": "Schedule call",
722
- title: "Schedule call",
723
- "data-testid": "schedule-call-button",
724
- children: [
725
- /* @__PURE__ */ jsx(CalendarPlus, { className: "size-4" }),
726
- variant === "label" && /* @__PURE__ */ jsx("span", { className: "ml-1.5", children: "Schedule call" })
727
- ]
728
- }
729
- );
730
- }
731
- function MeetingThreadTranscriptAction({
732
- conversationExtId,
733
- meetingCallExtId,
734
- title,
735
- messages
736
- }) {
737
- const { data: call } = useCall(meetingCallExtId);
738
- const { data: workspaceUsers = [] } = useWorkspaceUsers();
739
- const lines = useMemo(
740
- () => threadTranscriptLines(messages, (id) => {
741
- const user = workspaceUsers.find((wu) => wu.user.external_id === id)?.user;
742
- return user ? getUserDisplayName(user) : null;
743
- }),
744
- [messages, workspaceUsers]
745
- );
746
- if (!meetingCallExtId || !call?.is_creator) return null;
747
- return /* @__PURE__ */ jsx(
748
- SaveTranscriptToThread,
749
- {
750
- title,
751
- lines,
752
- excludeConversationExtId: conversationExtId,
753
- iconOnly: true
754
- }
755
- );
756
- }
757
- function MeetingThreadRecordingsAction({
758
- meetingCallExtId,
759
- title,
760
- iconOnly = false
761
- }) {
762
- const [open, setOpen] = useState(false);
763
- const pending = usePendingRecording();
764
- useEffect(() => {
765
- if (pending) setOpen(true);
766
- }, [pending]);
767
- return /* @__PURE__ */ jsxs(Fragment, { children: [
768
- /* @__PURE__ */ jsx(
769
- HeaderAction,
770
- {
771
- label: "Recordings",
772
- icon: /* @__PURE__ */ jsx(Disc, { className: "size-3.5", "aria-hidden": true }),
773
- iconOnly,
774
- onClick: () => setOpen(true),
775
- testId: "meeting-recordings"
776
- }
777
- ),
778
- open && /* @__PURE__ */ jsx(Dialog, { open: true, onOpenChange: (o) => !o && setOpen(false), children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-2xl", "data-testid": "meeting-recordings-dialog", children: [
779
- /* @__PURE__ */ jsxs(DialogHeader, { children: [
780
- /* @__PURE__ */ jsx(DialogTitle, { children: "Recordings" }),
781
- /* @__PURE__ */ jsx(DialogDescription, { children: "Recordings of this meeting, encrypted under the workspace key. Playing or downloading one decrypts it in this browser." })
782
- ] }),
783
- /* @__PURE__ */ jsx(
784
- RecordingsList,
785
- {
786
- callExtId: meetingCallExtId,
787
- title,
788
- className: "max-h-[60vh] overflow-y-auto"
789
- }
790
- )
791
- ] }) })
792
- ] });
793
- }
794
- function ConnectedConversationCallActions() {
795
- const conversationId = useArbiSessionState((state) => state.conversationId);
796
- const { conversations } = useConversationItems();
797
- const conversation = conversationId ? conversations.find((c) => c.external_id === conversationId) : void 0;
798
- const meetingCallExtId = conversation?.meeting_call_ext_id ?? null;
799
- const { messageHistory } = useConversationData();
800
- const threadMessages = useMeetingThreadMessages(meetingCallExtId, messageHistory);
801
- const meetingMessages = useMemo(
802
- () => meetingCallExtId ? threadMessages.map((m) => ({
803
- content: m.content,
804
- created_at: m.created_at,
805
- tools: m.tools ?? m.meta?.tools
806
- })) : [],
807
- [meetingCallExtId, threadMessages]
808
- );
809
- if (!conversationId) return null;
810
- return /* @__PURE__ */ jsxs(Fragment, { children: [
811
- /* @__PURE__ */ jsx(ThreadCallButton, { conversationId }),
812
- /* @__PURE__ */ jsx(ScheduleCallButton, { conversationId }),
813
- meetingCallExtId && /* @__PURE__ */ jsx(
814
- MeetingThreadTranscriptAction,
815
- {
816
- conversationExtId: conversationId,
817
- meetingCallExtId,
818
- title: conversation?.title,
819
- messages: meetingMessages
820
- }
821
- ),
822
- meetingCallExtId && /* @__PURE__ */ jsx(
823
- MeetingThreadRecordingsAction,
824
- {
825
- meetingCallExtId,
826
- title: conversation?.title,
827
- iconOnly: true
828
- }
829
- )
830
- ] });
831
- }
832
176
  function ChatCallCard({
833
177
  callExtId,
834
178
  senderName,
@@ -1069,6 +413,6 @@ function ConnectedCallChatHistory({
1069
413
  ] });
1070
414
  }
1071
415
 
1072
- export { CallPeoplePicker, ChatCallCard, ConnectedCallChatHistory, ConnectedCallDock, ConnectedCallLayer, ConnectedCallRoom, ConnectedConversationCallActions, ConnectedIncomingCall, DmCallButton, GroupCallButton, MeetingThreadRecordingsAction, MeetingThreadTranscriptAction, NewCallChip, RING_TIMEOUT_MS, ScheduleCallButton, StartCallButton, ThreadCallButton, buildCallCandidates, callContactOf, isPickable, matchesQuery };
416
+ export { ChatCallCard, ConnectedCallChatHistory, ConnectedCallDock, ConnectedCallLayer, ConnectedCallRoom, ConnectedIncomingCall, DmCallButton, GroupCallButton, NewCallChip, RING_TIMEOUT_MS };
1073
417
  //# sourceMappingURL=index.js.map
1074
418
  //# sourceMappingURL=index.js.map