@devalok/shilp-sutra 0.33.2 → 0.34.1
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.
- package/dist/_chunks/badge-group.js +306 -246
- package/dist/_chunks/chat.js +513 -0
- package/dist/_chunks/date-picker.js +748 -0
- package/dist/_chunks/document-preview.js +109 -90
- package/dist/_chunks/file-preview.js +492 -504
- package/dist/_chunks/framer.js +5564 -5613
- package/dist/_chunks/image-preview.js +127 -88
- package/dist/_chunks/keybinding.js +12 -14
- package/dist/_chunks/link-context.js +19 -16
- package/dist/_chunks/mention-suggestion.js +353 -350
- package/dist/_chunks/motion-provider.js +26 -20
- package/dist/_chunks/popover.js +127 -0
- package/dist/_chunks/primitives.js +7584 -6425
- package/dist/_chunks/rich-chat-input.js +2070 -0
- package/dist/_chunks/rolldown-runtime.js +21 -0
- package/dist/_chunks/shared.js +126 -0
- package/dist/_chunks/sonner.js +605 -734
- package/dist/_chunks/stat-row.js +418 -440
- package/dist/_chunks/tiptap.js +15850 -19964
- package/dist/_chunks/tree-view.js +231 -290
- package/dist/_chunks/use-calendar.js +161 -208
- package/dist/_chunks/vendor-client.js +314 -2199
- package/dist/_chunks/vendor-utils.js +1721 -2978
- package/dist/ai/ai-command-provider.js +23 -17
- package/dist/ai/block-renderer.js +68 -51
- package/dist/ai/blocks/index.js +2 -12
- package/dist/ai/command-bar.js +470 -519
- package/dist/ai/conversation.js +241 -227
- package/dist/ai/index.js +181 -167
- package/dist/ai/types.js +0 -1
- package/dist/composed/activity-feed.js +232 -202
- package/dist/composed/avatar-group.js +164 -222
- package/dist/composed/bulk-action-bar.js +174 -165
- package/dist/composed/command-palette.js +290 -308
- package/dist/composed/confirm-dialog.js +28 -48
- package/dist/composed/content-card.js +69 -108
- package/dist/composed/date-picker/index.js +3 -13
- package/dist/composed/deadline-indicator.js +68 -74
- package/dist/composed/emoji-picker.js +83 -110
- package/dist/composed/empty-state.js +64 -103
- package/dist/composed/error-boundary.js +129 -127
- package/dist/composed/file-preview.js +2 -12
- package/dist/composed/filter-bar.js +98 -130
- package/dist/composed/form-section.js +61 -45
- package/dist/composed/global-loading.js +34 -47
- package/dist/composed/index.js +34 -92
- package/dist/composed/inline-edit.js +92 -107
- package/dist/composed/lib/string-utils.js +8 -8
- package/dist/composed/loading-skeleton.js +103 -171
- package/dist/composed/markdown-viewer.js +187 -139
- package/dist/composed/master-detail.js +147 -156
- package/dist/composed/member-picker.js +46 -49
- package/dist/composed/multi-select-popover.js +181 -179
- package/dist/composed/page-header.js +54 -76
- package/dist/composed/page-skeletons.js +143 -127
- package/dist/composed/priority-indicator.js +105 -111
- package/dist/composed/responsive-overlay.js +36 -41
- package/dist/composed/rich-chat-input.js +2 -1860
- package/dist/composed/rich-text-editor.js +561 -424
- package/dist/composed/schedule-view.js +134 -185
- package/dist/composed/simple-tooltip.js +21 -21
- package/dist/composed/status-badge.js +133 -137
- package/dist/hooks/index.js +7 -12
- package/dist/hooks/use-color-mode.js +28 -25
- package/dist/hooks/use-mobile.js +13 -13
- package/dist/hooks/use-toast.js +2 -4
- package/dist/hooks/use-touch-device.js +9 -11
- package/dist/hooks/use-viewport-height.js +14 -14
- package/dist/motion/index.js +3 -11
- package/dist/motion/primitives-index.js +226 -186
- package/dist/shell/app-command-palette.js +203 -234
- package/dist/shell/bottom-navbar.js +150 -190
- package/dist/shell/command-registry.js +13 -14
- package/dist/shell/index.js +10 -20
- package/dist/shell/link-context.js +2 -5
- package/dist/shell/notification-center.js +238 -259
- package/dist/shell/notification-preferences.js +241 -184
- package/dist/shell/sidebar.js +251 -281
- package/dist/shell/top-bar.js +203 -237
- package/dist/tailwind/index.cjs +426 -451
- package/dist/tailwind/index.js +2 -4
- package/dist/tailwind/preset.d.ts.map +1 -1
- package/dist/tailwind/preset.js +443 -468
- package/dist/ui/accordion.js +52 -60
- package/dist/ui/alert-dialog.js +111 -156
- package/dist/ui/alert.js +177 -99
- package/dist/ui/aspect-ratio.js +13 -16
- package/dist/ui/autocomplete.js +112 -148
- package/dist/ui/avatar.js +196 -169
- package/dist/ui/badge-group.js +2 -7
- package/dist/ui/badge-indicator.js +42 -51
- package/dist/ui/badge.js +2 -15
- package/dist/ui/banner.js +76 -68
- package/dist/ui/breadcrumb.js +65 -84
- package/dist/ui/button-group.js +109 -102
- package/dist/ui/button-processing.js +69 -73
- package/dist/ui/button.js +393 -279
- package/dist/ui/card.js +151 -157
- package/dist/ui/charts/index.js +1002 -1319
- package/dist/ui/chat/index.js +2 -11
- package/dist/ui/checkbox.js +77 -100
- package/dist/ui/code.js +18 -32
- package/dist/ui/collapsible.js +21 -29
- package/dist/ui/color-input.js +453 -372
- package/dist/ui/color-swatch.js +60 -90
- package/dist/ui/combobox.js +244 -293
- package/dist/ui/container.js +18 -24
- package/dist/ui/context-menu.js +154 -203
- package/dist/ui/data-table-body.js +116 -213
- package/dist/ui/data-table-bulk-actions.js +43 -59
- package/dist/ui/data-table-card.js +84 -71
- package/dist/ui/data-table-context.js +39 -42
- package/dist/ui/data-table-header.js +98 -139
- package/dist/ui/data-table-pagination.js +69 -82
- package/dist/ui/data-table-toolbar.js +104 -130
- package/dist/ui/data-table.js +278 -354
- package/dist/ui/devalok-grain.js +77 -66
- package/dist/ui/dialog.js +122 -151
- package/dist/ui/dropdown-menu.js +152 -203
- package/dist/ui/file-upload.js +242 -266
- package/dist/ui/form.js +60 -56
- package/dist/ui/hover-card.js +54 -54
- package/dist/ui/icon-button.js +21 -26
- package/dist/ui/icon-context.js +17 -17
- package/dist/ui/icon-group.js +22 -29
- package/dist/ui/icon.js +201 -121
- package/dist/ui/index.js +74 -350
- package/dist/ui/input-otp.d.ts.map +1 -1
- package/dist/ui/input-otp.js +44 -48
- package/dist/ui/input.js +92 -169
- package/dist/ui/label.js +17 -22
- package/dist/ui/lib/date-utils.js +14 -11
- package/dist/ui/lib/motion.js +77 -36
- package/dist/ui/lib/utils.js +39 -16
- package/dist/ui/link.js +13 -24
- package/dist/ui/menubar.js +132 -210
- package/dist/ui/navigation-menu.js +164 -194
- package/dist/ui/number-input.js +72 -95
- package/dist/ui/pagination.js +122 -159
- package/dist/ui/popover.js +2 -131
- package/dist/ui/progress-ring.js +133 -143
- package/dist/ui/progress.js +51 -95
- package/dist/ui/radio.js +41 -50
- package/dist/ui/search-input.js +51 -53
- package/dist/ui/segmented-control.js +93 -114
- package/dist/ui/select.js +131 -157
- package/dist/ui/separator.js +15 -25
- package/dist/ui/sheet.js +135 -163
- package/dist/ui/sidebar.js +357 -600
- package/dist/ui/skeleton.js +179 -231
- package/dist/ui/slider.js +24 -34
- package/dist/ui/spinner.js +226 -205
- package/dist/ui/split-button.js +227 -276
- package/dist/ui/stack.js +56 -70
- package/dist/ui/stat-card.js +259 -251
- package/dist/ui/status-dot.js +67 -63
- package/dist/ui/stepper.js +119 -168
- package/dist/ui/switch.js +51 -54
- package/dist/ui/table.js +57 -90
- package/dist/ui/tabs.js +139 -156
- package/dist/ui/text.js +52 -59
- package/dist/ui/textarea.js +40 -57
- package/dist/ui/toast-types.js +0 -1
- package/dist/ui/toast.js +554 -536
- package/dist/ui/toaster.js +23 -33
- package/dist/ui/toggle-group.js +37 -41
- package/dist/ui/toggle.js +36 -40
- package/dist/ui/tooltip.js +80 -65
- package/dist/ui/tree-view/index.js +2 -6
- package/dist/ui/visually-hidden.js +12 -10
- package/llms-full.txt +1 -1
- package/llms.txt +12 -0
- package/package.json +3 -3
- package/dist/_chunks/date-time-picker.js +0 -851
- package/dist/_chunks/typing-indicator.js +0 -565
|
@@ -0,0 +1,2070 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { $t as e, en as t, in as n, rn as r } from "./primitives.js";
|
|
3
|
+
import { a as i, c as a, n as o } from "./framer.js";
|
|
4
|
+
import { cn as s } from "../ui/lib/utils.js";
|
|
5
|
+
import { Spinner as c } from "../ui/spinner.js";
|
|
6
|
+
import { Icon as l } from "../ui/icon.js";
|
|
7
|
+
import { Button as u } from "../ui/button.js";
|
|
8
|
+
import { useIsMobile as d } from "../hooks/use-mobile.js";
|
|
9
|
+
import { Dialog as f, DialogContent as p, DialogFooter as m, DialogHeader as h, DialogTitle as g } from "../ui/dialog.js";
|
|
10
|
+
import { SplitButton as _ } from "../ui/split-button.js";
|
|
11
|
+
import { emojiDataLoaders as v } from "../composed/emoji-picker.js";
|
|
12
|
+
import { c as y, d as b, g as x, h as S, i as C, l as w, m as ee, n as te, o as ne, r as T, s as re, t as E, y as ie } from "./tiptap.js";
|
|
13
|
+
import { a as ae, i as oe, n as se, o as ce, r as le, t as ue } from "./mention-suggestion.js";
|
|
14
|
+
import { useColorMode as de } from "../hooks/use-color-mode.js";
|
|
15
|
+
import { n as fe, t as D } from "./use-calendar.js";
|
|
16
|
+
import * as O from "react";
|
|
17
|
+
import { useCallback as k, useEffect as pe, useRef as A, useState as j } from "react";
|
|
18
|
+
import { Fragment as me, jsx as M, jsxs as N } from "react/jsx-runtime";
|
|
19
|
+
import * as he from "react-dom";
|
|
20
|
+
import { IconAt as ge, IconBlockquote as P, IconBold as _e, IconCalendarEvent as ve, IconChevronDown as ye, IconClock as be, IconCode as xe, IconFile as Se, IconHighlight as Ce, IconItalic as F, IconLink as we, IconList as I, IconListNumbers as Te, IconMicrophone as Ee, IconMoodSmile as De, IconPencil as Oe, IconPlayerPause as ke, IconPlayerPlay as L, IconPlus as Ae, IconSend as je, IconSlash as R, IconSquare as Me, IconStrikethrough as z, IconTextSize as Ne, IconTrash as Pe, IconUnderline as Fe, IconX as B } from "@tabler/icons-react";
|
|
21
|
+
import { createRoot as Ie } from "react-dom/client";
|
|
22
|
+
//#region src/composed/extensions/slash-command.tsx
|
|
23
|
+
var V = O.forwardRef(({ groups: e, query: t, command: n }, r) => {
|
|
24
|
+
let [i, a] = O.useState(0), o = O.useMemo(() => {
|
|
25
|
+
let n = t.toLowerCase(), r = [];
|
|
26
|
+
return e.forEach((e, t) => {
|
|
27
|
+
e.commands.forEach((e) => {
|
|
28
|
+
(!n || e.label.toLowerCase().includes(n) || e.description?.toLowerCase().includes(n)) && r.push({
|
|
29
|
+
command: e,
|
|
30
|
+
groupIndex: t
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}), r;
|
|
34
|
+
}, [e, t]);
|
|
35
|
+
if (O.useEffect(() => a(0), [o]), O.useImperativeHandle(r, () => ({ onKeyDown: ({ event: e }) => e.key === "ArrowUp" ? (a((e) => (e + o.length - 1) % o.length), !0) : e.key === "ArrowDown" ? (a((e) => (e + 1) % o.length), !0) : e.key === "Enter" ? (o[i] && n(o[i].command), !0) : !1 })), !o.length) return null;
|
|
36
|
+
let c = [], l = 0;
|
|
37
|
+
for (let t of o) {
|
|
38
|
+
let n = e[t.groupIndex].label, r = c[c.length - 1];
|
|
39
|
+
(!r || r.label !== n) && (r = {
|
|
40
|
+
label: n,
|
|
41
|
+
items: []
|
|
42
|
+
}, c.push(r)), r.items.push({
|
|
43
|
+
command: t.command,
|
|
44
|
+
flatIndex: l
|
|
45
|
+
}), l++;
|
|
46
|
+
}
|
|
47
|
+
return /* @__PURE__ */ M("div", {
|
|
48
|
+
role: "listbox",
|
|
49
|
+
"aria-label": "Slash commands",
|
|
50
|
+
className: "z-popover max-h-[320px] min-w-[220px] overflow-x-hidden overflow-y-auto rounded-ds-lg border border-surface-border-strong bg-surface-overlay p-ds-02 shadow-floating",
|
|
51
|
+
children: c.map((e, t) => /* @__PURE__ */ N("div", {
|
|
52
|
+
role: "group",
|
|
53
|
+
"aria-label": e.label,
|
|
54
|
+
children: [
|
|
55
|
+
t > 0 && /* @__PURE__ */ M("div", { className: "my-ds-01 border-t border-surface-border" }),
|
|
56
|
+
/* @__PURE__ */ M("div", {
|
|
57
|
+
className: "px-ds-03 py-ds-01 text-ds-xs font-medium text-surface-fg-subtle",
|
|
58
|
+
children: e.label
|
|
59
|
+
}),
|
|
60
|
+
e.items.map(({ command: e, flatIndex: t }) => {
|
|
61
|
+
let r = e.icon;
|
|
62
|
+
return /* @__PURE__ */ N("button", {
|
|
63
|
+
type: "button",
|
|
64
|
+
role: "option",
|
|
65
|
+
"aria-selected": t === i,
|
|
66
|
+
onClick: () => n(e),
|
|
67
|
+
className: s("flex w-full items-center gap-ds-03 rounded-ds-md px-ds-03 py-ds-02 text-left cursor-pointer", t === i ? "bg-surface-raised-hover" : "hover:bg-surface-raised-hover"),
|
|
68
|
+
children: [r && /* @__PURE__ */ M("span", {
|
|
69
|
+
className: "flex h-4 w-4 shrink-0 items-center justify-center text-surface-fg-muted",
|
|
70
|
+
children: /* @__PURE__ */ M(r, { className: "h-4 w-4" })
|
|
71
|
+
}), /* @__PURE__ */ N("div", {
|
|
72
|
+
className: "flex flex-col",
|
|
73
|
+
children: [/* @__PURE__ */ M("span", {
|
|
74
|
+
className: "text-ds-sm text-surface-fg",
|
|
75
|
+
children: e.label
|
|
76
|
+
}), e.description && /* @__PURE__ */ M("span", {
|
|
77
|
+
className: "text-ds-xs text-surface-fg-subtle",
|
|
78
|
+
children: e.description
|
|
79
|
+
})]
|
|
80
|
+
})]
|
|
81
|
+
}, e.id);
|
|
82
|
+
})
|
|
83
|
+
]
|
|
84
|
+
}, e.label))
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
V.displayName = "SlashCommandList";
|
|
88
|
+
function Le(e) {
|
|
89
|
+
return () => {
|
|
90
|
+
let t = null, n = null, r = null;
|
|
91
|
+
return {
|
|
92
|
+
onStart: (i) => {
|
|
93
|
+
n = document.createElement("div"), n.style.position = "absolute", n.style.zIndex = "1400";
|
|
94
|
+
let a = i.clientRect?.();
|
|
95
|
+
a && (n.style.left = `${a.left}px`, n.style.top = `${a.bottom + 4}px`), document.body.appendChild(n), t = Ie(n), t.render(/* @__PURE__ */ M(V, {
|
|
96
|
+
ref: (e) => {
|
|
97
|
+
r = e;
|
|
98
|
+
},
|
|
99
|
+
groups: e,
|
|
100
|
+
query: i.query,
|
|
101
|
+
command: (e) => i.command(e)
|
|
102
|
+
}));
|
|
103
|
+
},
|
|
104
|
+
onUpdate: (i) => {
|
|
105
|
+
if (!t || !n) return;
|
|
106
|
+
let a = i.clientRect?.();
|
|
107
|
+
a && (n.style.left = `${a.left}px`, n.style.top = `${a.bottom + 4}px`), t.render(/* @__PURE__ */ M(V, {
|
|
108
|
+
ref: (e) => {
|
|
109
|
+
r = e;
|
|
110
|
+
},
|
|
111
|
+
groups: e,
|
|
112
|
+
query: i.query,
|
|
113
|
+
command: (e) => i.command(e)
|
|
114
|
+
}));
|
|
115
|
+
},
|
|
116
|
+
onKeyDown: (e) => e.event.key === "Escape" ? (n && (t?.unmount(), n.remove(), n = null, t = null), !0) : r?.onKeyDown(e) ?? !1,
|
|
117
|
+
onExit: () => {
|
|
118
|
+
n && (t?.unmount(), n.remove(), n = null, t = null);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function Re(e) {
|
|
124
|
+
let t = e.flatMap((e) => e.commands);
|
|
125
|
+
return x.create({
|
|
126
|
+
name: "slashCommand",
|
|
127
|
+
addProseMirrorPlugins() {
|
|
128
|
+
return [T({
|
|
129
|
+
pluginKey: new ie("slashCommand"),
|
|
130
|
+
editor: this.editor,
|
|
131
|
+
char: "/",
|
|
132
|
+
startOfLine: !0,
|
|
133
|
+
allowSpaces: !1,
|
|
134
|
+
items: ({ query: e }) => {
|
|
135
|
+
if (!e) return t.slice(0, 8);
|
|
136
|
+
let n = e.toLowerCase();
|
|
137
|
+
return t.filter((e) => e.label.toLowerCase().includes(n) || e.description?.toLowerCase().includes(n)).slice(0, 8);
|
|
138
|
+
},
|
|
139
|
+
command: ({ editor: e, range: t, props: n }) => {
|
|
140
|
+
e.chain().focus().deleteRange(t).run(), n.action(e);
|
|
141
|
+
},
|
|
142
|
+
render: Le(e)
|
|
143
|
+
})];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/composed/rich-chat-input/reply-banner.tsx
|
|
149
|
+
function ze({ author: e, preview: t, onDismiss: n }) {
|
|
150
|
+
return /* @__PURE__ */ M(i.div, {
|
|
151
|
+
initial: {
|
|
152
|
+
height: 0,
|
|
153
|
+
opacity: 0
|
|
154
|
+
},
|
|
155
|
+
animate: {
|
|
156
|
+
height: "auto",
|
|
157
|
+
opacity: 1
|
|
158
|
+
},
|
|
159
|
+
exit: {
|
|
160
|
+
height: 0,
|
|
161
|
+
opacity: 0
|
|
162
|
+
},
|
|
163
|
+
transition: {
|
|
164
|
+
duration: .24,
|
|
165
|
+
ease: [
|
|
166
|
+
.2,
|
|
167
|
+
0,
|
|
168
|
+
.38,
|
|
169
|
+
.9
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
className: "overflow-hidden",
|
|
173
|
+
children: /* @__PURE__ */ N("div", {
|
|
174
|
+
role: "status",
|
|
175
|
+
"aria-label": `Replying to ${e}`,
|
|
176
|
+
className: "flex items-center gap-ds-03 border-b border-surface-border px-ds-04 py-ds-02b",
|
|
177
|
+
children: [/* @__PURE__ */ N("div", {
|
|
178
|
+
className: "flex-1 min-w-0",
|
|
179
|
+
children: [
|
|
180
|
+
/* @__PURE__ */ N("span", {
|
|
181
|
+
className: "text-ds-sm font-semibold text-surface-fg",
|
|
182
|
+
children: ["Replying to ", e]
|
|
183
|
+
}),
|
|
184
|
+
/* @__PURE__ */ M("span", {
|
|
185
|
+
className: "mx-ds-02 text-surface-fg-subtle",
|
|
186
|
+
children: "·"
|
|
187
|
+
}),
|
|
188
|
+
/* @__PURE__ */ M("span", {
|
|
189
|
+
className: "text-ds-sm text-surface-fg-muted truncate",
|
|
190
|
+
children: t
|
|
191
|
+
})
|
|
192
|
+
]
|
|
193
|
+
}), /* @__PURE__ */ M("button", {
|
|
194
|
+
type: "button",
|
|
195
|
+
onClick: n,
|
|
196
|
+
className: s("inline-flex h-ds-xs-plus w-ds-xs-plus items-center justify-center rounded-ds-md touch-target", "text-surface-fg-subtle hover:text-surface-fg hover:bg-surface-raised-hover", "transition-colors duration-fast-01 ease-productive-standard", "active:scale-95"),
|
|
197
|
+
"aria-label": "Cancel reply",
|
|
198
|
+
title: "Cancel reply",
|
|
199
|
+
children: /* @__PURE__ */ M(l, {
|
|
200
|
+
icon: B,
|
|
201
|
+
size: "xs"
|
|
202
|
+
})
|
|
203
|
+
})]
|
|
204
|
+
})
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/composed/rich-chat-input/schedule-send.tsx
|
|
209
|
+
function Be() {
|
|
210
|
+
let e = /* @__PURE__ */ new Date(), t = e.getHours(), n = [], r = (t, n = 0) => {
|
|
211
|
+
let r = new Date(e);
|
|
212
|
+
return r.setDate(r.getDate() + n), r.setHours(t, 0, 0, 0), r;
|
|
213
|
+
}, i = (t) => {
|
|
214
|
+
let n = new Date(e), r = n.getDay(), i = r === 0 ? 1 : r === 1 ? 7 : 8 - r;
|
|
215
|
+
return n.setDate(n.getDate() + i), n.setHours(t, 0, 0, 0), n;
|
|
216
|
+
};
|
|
217
|
+
t < 9 ? (n.push({
|
|
218
|
+
label: "Later this morning · 9:00 AM",
|
|
219
|
+
date: r(9)
|
|
220
|
+
}), n.push({
|
|
221
|
+
label: "This afternoon · 1:00 PM",
|
|
222
|
+
date: r(13)
|
|
223
|
+
}), n.push({
|
|
224
|
+
label: "This evening · 6:00 PM",
|
|
225
|
+
date: r(18)
|
|
226
|
+
})) : t < 13 ? (n.push({
|
|
227
|
+
label: "This afternoon · 1:00 PM",
|
|
228
|
+
date: r(13)
|
|
229
|
+
}), n.push({
|
|
230
|
+
label: "This evening · 6:00 PM",
|
|
231
|
+
date: r(18)
|
|
232
|
+
}), n.push({
|
|
233
|
+
label: "Tomorrow morning · 9:00 AM",
|
|
234
|
+
date: r(9, 1)
|
|
235
|
+
})) : t < 18 ? (n.push({
|
|
236
|
+
label: "This evening · 6:00 PM",
|
|
237
|
+
date: r(18)
|
|
238
|
+
}), n.push({
|
|
239
|
+
label: "Tomorrow morning · 9:00 AM",
|
|
240
|
+
date: r(9, 1)
|
|
241
|
+
}), n.push({
|
|
242
|
+
label: "Tomorrow afternoon · 1:00 PM",
|
|
243
|
+
date: r(13, 1)
|
|
244
|
+
})) : (n.push({
|
|
245
|
+
label: "Tomorrow morning · 9:00 AM",
|
|
246
|
+
date: r(9, 1)
|
|
247
|
+
}), n.push({
|
|
248
|
+
label: "Tomorrow afternoon · 1:00 PM",
|
|
249
|
+
date: r(13, 1)
|
|
250
|
+
}));
|
|
251
|
+
let a = i(9);
|
|
252
|
+
return a.getTime() - e.getTime() > 2880 * 60 * 1e3 && n.push({
|
|
253
|
+
label: "Next Monday · 9:00 AM",
|
|
254
|
+
date: a
|
|
255
|
+
}), n;
|
|
256
|
+
}
|
|
257
|
+
function Ve({ value: e, onChange: t }) {
|
|
258
|
+
let n = e.getHours() % 12 || 12, r = e.getMinutes(), i = e.getHours() >= 12, a = (n) => {
|
|
259
|
+
let r = new Date(e);
|
|
260
|
+
r.setHours(i ? n % 12 + 12 : n % 12), t(r);
|
|
261
|
+
}, o = (n) => {
|
|
262
|
+
let r = new Date(e);
|
|
263
|
+
r.setMinutes(n), t(r);
|
|
264
|
+
}, c = (n) => {
|
|
265
|
+
let r = new Date(e), i = r.getHours();
|
|
266
|
+
n && i < 12 ? r.setHours(i + 12) : !n && i >= 12 && r.setHours(i - 12), t(r);
|
|
267
|
+
};
|
|
268
|
+
return /* @__PURE__ */ N("div", {
|
|
269
|
+
className: "flex items-center gap-ds-02",
|
|
270
|
+
children: [
|
|
271
|
+
/* @__PURE__ */ M("select", {
|
|
272
|
+
value: n,
|
|
273
|
+
onChange: (e) => a(Number(e.target.value)),
|
|
274
|
+
className: "h-ds-sm rounded-ds-md border border-surface-border-strong bg-surface-raised px-ds-02 text-ds-sm text-surface-fg focus:outline-hidden focus:ring-2 focus:ring-accent-9",
|
|
275
|
+
"aria-label": "Hour",
|
|
276
|
+
children: Array.from({ length: 12 }, (e, t) => t + 1).map((e) => /* @__PURE__ */ M("option", {
|
|
277
|
+
value: e,
|
|
278
|
+
children: e
|
|
279
|
+
}, e))
|
|
280
|
+
}),
|
|
281
|
+
/* @__PURE__ */ M("span", {
|
|
282
|
+
className: "text-ds-sm text-surface-fg-subtle font-medium",
|
|
283
|
+
children: ":"
|
|
284
|
+
}),
|
|
285
|
+
/* @__PURE__ */ M("select", {
|
|
286
|
+
value: r - r % 5,
|
|
287
|
+
onChange: (e) => o(Number(e.target.value)),
|
|
288
|
+
className: "h-ds-sm rounded-ds-md border border-surface-border-strong bg-surface-raised px-ds-02 text-ds-sm text-surface-fg focus:outline-hidden focus:ring-2 focus:ring-accent-9",
|
|
289
|
+
"aria-label": "Minute",
|
|
290
|
+
children: Array.from({ length: 12 }, (e, t) => t * 5).map((e) => /* @__PURE__ */ M("option", {
|
|
291
|
+
value: e,
|
|
292
|
+
children: String(e).padStart(2, "0")
|
|
293
|
+
}, e))
|
|
294
|
+
}),
|
|
295
|
+
/* @__PURE__ */ N("div", {
|
|
296
|
+
className: "inline-flex rounded-ds-md border border-surface-border-strong overflow-hidden",
|
|
297
|
+
children: [/* @__PURE__ */ M("button", {
|
|
298
|
+
type: "button",
|
|
299
|
+
onClick: () => c(!1),
|
|
300
|
+
className: s("px-ds-02b py-ds-01 text-ds-xs font-medium transition-colors duration-fast-01", i ? "bg-surface-raised text-surface-fg-subtle hover:bg-surface-raised-hover" : "bg-accent-9 text-white"),
|
|
301
|
+
children: "AM"
|
|
302
|
+
}), /* @__PURE__ */ M("button", {
|
|
303
|
+
type: "button",
|
|
304
|
+
onClick: () => c(!0),
|
|
305
|
+
className: s("px-ds-02b py-ds-01 text-ds-xs font-medium transition-colors duration-fast-01", i ? "bg-accent-9 text-white" : "bg-surface-raised text-surface-fg-subtle hover:bg-surface-raised-hover"),
|
|
306
|
+
children: "PM"
|
|
307
|
+
})]
|
|
308
|
+
})
|
|
309
|
+
]
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
function He({ value: e, onChange: t, minDate: n }) {
|
|
313
|
+
let r = /* @__PURE__ */ new Date(), i = e ?? (() => {
|
|
314
|
+
let e = new Date(r);
|
|
315
|
+
return e.setHours(e.getHours() + 1, 0, 0, 0), e;
|
|
316
|
+
})(), a = `${i.getFullYear()}-${String(i.getMonth() + 1).padStart(2, "0")}-${String(i.getDate()).padStart(2, "0")}`, o = (e) => {
|
|
317
|
+
let n = e.target.value.split("-");
|
|
318
|
+
if (n.length !== 3) return;
|
|
319
|
+
let r = new Date(i);
|
|
320
|
+
r.setFullYear(Number(n[0]), Number(n[1]) - 1, Number(n[2])), t(r);
|
|
321
|
+
}, s = n ? `${n.getFullYear()}-${String(n.getMonth() + 1).padStart(2, "0")}-${String(n.getDate()).padStart(2, "0")}` : void 0;
|
|
322
|
+
return /* @__PURE__ */ N("div", {
|
|
323
|
+
className: "space-y-ds-03",
|
|
324
|
+
children: [/* @__PURE__ */ N("div", {
|
|
325
|
+
className: "flex items-center justify-between",
|
|
326
|
+
children: [/* @__PURE__ */ M("span", {
|
|
327
|
+
className: "text-ds-xs font-medium text-surface-fg-subtle",
|
|
328
|
+
children: "Date"
|
|
329
|
+
}), /* @__PURE__ */ M("input", {
|
|
330
|
+
type: "date",
|
|
331
|
+
value: a,
|
|
332
|
+
min: s,
|
|
333
|
+
onChange: o,
|
|
334
|
+
className: "h-ds-sm rounded-ds-md border border-surface-border-strong bg-surface-raised px-ds-03 text-ds-sm text-surface-fg focus:outline-hidden focus:ring-2 focus:ring-accent-9"
|
|
335
|
+
})]
|
|
336
|
+
}), /* @__PURE__ */ N("div", {
|
|
337
|
+
className: "flex items-center justify-between",
|
|
338
|
+
children: [/* @__PURE__ */ M("span", {
|
|
339
|
+
className: "text-ds-xs font-medium text-surface-fg-subtle",
|
|
340
|
+
children: "Time"
|
|
341
|
+
}), /* @__PURE__ */ M(Ve, {
|
|
342
|
+
value: i,
|
|
343
|
+
onChange: t
|
|
344
|
+
})]
|
|
345
|
+
})]
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
function Ue({ value: e, onChange: t, minDate: n }) {
|
|
349
|
+
let r = /* @__PURE__ */ new Date(), i = e ?? (() => {
|
|
350
|
+
let e = new Date(r);
|
|
351
|
+
return e.setHours(e.getHours() + 1, 0, 0, 0), e;
|
|
352
|
+
})(), { currentMonth: a, goToPreviousMonth: o, goToNextMonth: s } = D(i);
|
|
353
|
+
return /* @__PURE__ */ N("div", {
|
|
354
|
+
className: "space-y-ds-03",
|
|
355
|
+
children: [/* @__PURE__ */ M(fe, {
|
|
356
|
+
currentMonth: a,
|
|
357
|
+
selected: i,
|
|
358
|
+
onSelect: (e) => {
|
|
359
|
+
let n = new Date(e);
|
|
360
|
+
n.setHours(i.getHours(), i.getMinutes(), 0, 0), t(n);
|
|
361
|
+
},
|
|
362
|
+
onMonthChange: (e) => {
|
|
363
|
+
e < a ? o() : s();
|
|
364
|
+
},
|
|
365
|
+
minDate: n,
|
|
366
|
+
className: "w-full"
|
|
367
|
+
}), /* @__PURE__ */ N("div", {
|
|
368
|
+
className: "flex items-center justify-between border-t border-surface-border pt-ds-03",
|
|
369
|
+
children: [/* @__PURE__ */ M("span", {
|
|
370
|
+
className: "text-ds-xs font-medium text-surface-fg-subtle",
|
|
371
|
+
children: "Time"
|
|
372
|
+
}), /* @__PURE__ */ M(Ve, {
|
|
373
|
+
value: i,
|
|
374
|
+
onChange: t
|
|
375
|
+
})]
|
|
376
|
+
})]
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
function We({ onSchedule: e, onClose: t, onOpenDialog: n }) {
|
|
380
|
+
let [r, i] = O.useState(!1), [a, o] = O.useState(null), s = O.useMemo(() => Be(), []), c = (n) => {
|
|
381
|
+
e(n), t();
|
|
382
|
+
};
|
|
383
|
+
return r ? /* @__PURE__ */ N("div", {
|
|
384
|
+
className: "p-ds-04",
|
|
385
|
+
style: { minWidth: 270 },
|
|
386
|
+
children: [
|
|
387
|
+
/* @__PURE__ */ N("div", {
|
|
388
|
+
className: "mb-ds-03 flex items-center justify-between",
|
|
389
|
+
children: [/* @__PURE__ */ M("p", {
|
|
390
|
+
className: "text-ds-sm font-medium text-surface-fg",
|
|
391
|
+
children: "Pick date & time"
|
|
392
|
+
}), /* @__PURE__ */ M("button", {
|
|
393
|
+
type: "button",
|
|
394
|
+
onClick: () => i(!1),
|
|
395
|
+
className: "inline-flex items-center justify-center rounded-ds-md p-ds-01 text-surface-fg-subtle hover:bg-surface-raised-hover hover:text-surface-fg transition-colors",
|
|
396
|
+
"aria-label": "Back to presets",
|
|
397
|
+
children: /* @__PURE__ */ M(l, {
|
|
398
|
+
icon: B,
|
|
399
|
+
size: "sm"
|
|
400
|
+
})
|
|
401
|
+
})]
|
|
402
|
+
}),
|
|
403
|
+
/* @__PURE__ */ M(He, {
|
|
404
|
+
value: a,
|
|
405
|
+
onChange: o,
|
|
406
|
+
minDate: /* @__PURE__ */ new Date()
|
|
407
|
+
}),
|
|
408
|
+
/* @__PURE__ */ M("div", {
|
|
409
|
+
className: "mt-ds-03 flex justify-end",
|
|
410
|
+
children: /* @__PURE__ */ M(u, {
|
|
411
|
+
variant: "solid",
|
|
412
|
+
size: "sm",
|
|
413
|
+
onClick: () => {
|
|
414
|
+
a && a > /* @__PURE__ */ new Date() && (e(a), t(), o(null), i(!1));
|
|
415
|
+
},
|
|
416
|
+
disabled: !a || a <= /* @__PURE__ */ new Date(),
|
|
417
|
+
children: "Confirm"
|
|
418
|
+
})
|
|
419
|
+
})
|
|
420
|
+
]
|
|
421
|
+
}) : /* @__PURE__ */ N("div", {
|
|
422
|
+
className: "p-ds-02",
|
|
423
|
+
style: { minWidth: 260 },
|
|
424
|
+
children: [
|
|
425
|
+
/* @__PURE__ */ M("p", {
|
|
426
|
+
className: "px-ds-03 py-ds-01 text-ds-xs font-medium text-surface-fg-subtle",
|
|
427
|
+
children: "Schedule send"
|
|
428
|
+
}),
|
|
429
|
+
s.map((e, t) => /* @__PURE__ */ N("button", {
|
|
430
|
+
type: "button",
|
|
431
|
+
onClick: () => c(e.date),
|
|
432
|
+
className: "flex w-full items-center gap-ds-03 rounded-ds-md px-ds-03 py-ds-02b text-ds-sm text-surface-fg hover:bg-surface-raised-hover transition-colors duration-fast-01",
|
|
433
|
+
children: [/* @__PURE__ */ M(l, {
|
|
434
|
+
icon: be,
|
|
435
|
+
size: "sm",
|
|
436
|
+
className: "shrink-0 text-surface-fg-muted"
|
|
437
|
+
}), e.label]
|
|
438
|
+
}, t)),
|
|
439
|
+
/* @__PURE__ */ M("div", { className: "mx-ds-02 my-ds-02 h-px bg-surface-border" }),
|
|
440
|
+
/* @__PURE__ */ N("button", {
|
|
441
|
+
type: "button",
|
|
442
|
+
onClick: () => i(!0),
|
|
443
|
+
className: "flex w-full items-center gap-ds-03 rounded-ds-md px-ds-03 py-ds-02b text-ds-sm text-surface-fg hover:bg-surface-raised-hover transition-colors duration-fast-01",
|
|
444
|
+
children: [/* @__PURE__ */ M(l, {
|
|
445
|
+
icon: ve,
|
|
446
|
+
size: "sm",
|
|
447
|
+
className: "shrink-0 text-accent-11"
|
|
448
|
+
}), "Pick date & time..."]
|
|
449
|
+
}),
|
|
450
|
+
n && /* @__PURE__ */ N("button", {
|
|
451
|
+
type: "button",
|
|
452
|
+
onClick: () => {
|
|
453
|
+
n(), t();
|
|
454
|
+
},
|
|
455
|
+
className: "flex w-full items-center gap-ds-03 rounded-ds-md px-ds-03 py-ds-02b text-ds-sm text-surface-fg hover:bg-surface-raised-hover transition-colors duration-fast-01",
|
|
456
|
+
children: [/* @__PURE__ */ M(l, {
|
|
457
|
+
icon: ve,
|
|
458
|
+
size: "sm",
|
|
459
|
+
className: "shrink-0 text-surface-fg-muted"
|
|
460
|
+
}), "Open full picker..."]
|
|
461
|
+
})
|
|
462
|
+
]
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
function Ge({ open: e, onOpenChange: t, onSchedule: n, initialDate: r }) {
|
|
466
|
+
let [i, a] = O.useState(r ?? null);
|
|
467
|
+
return O.useEffect(() => {
|
|
468
|
+
e && a(r ?? null);
|
|
469
|
+
}, [e, r]), /* @__PURE__ */ M(f, {
|
|
470
|
+
open: e,
|
|
471
|
+
onOpenChange: t,
|
|
472
|
+
children: /* @__PURE__ */ N(p, {
|
|
473
|
+
className: "sm:max-w-[380px]",
|
|
474
|
+
children: [
|
|
475
|
+
/* @__PURE__ */ M(h, { children: /* @__PURE__ */ M(g, { children: r ? "Reschedule message" : "Schedule send" }) }),
|
|
476
|
+
/* @__PURE__ */ M(Ue, {
|
|
477
|
+
value: i,
|
|
478
|
+
onChange: a,
|
|
479
|
+
minDate: /* @__PURE__ */ new Date()
|
|
480
|
+
}),
|
|
481
|
+
/* @__PURE__ */ N(m, {
|
|
482
|
+
className: "gap-ds-02",
|
|
483
|
+
children: [/* @__PURE__ */ M(u, {
|
|
484
|
+
variant: "soft",
|
|
485
|
+
onClick: () => t(!1),
|
|
486
|
+
children: "Cancel"
|
|
487
|
+
}), /* @__PURE__ */ M(u, {
|
|
488
|
+
variant: "solid",
|
|
489
|
+
onClick: () => {
|
|
490
|
+
i && i > /* @__PURE__ */ new Date() && (n(i), t(!1));
|
|
491
|
+
},
|
|
492
|
+
disabled: !i || i <= /* @__PURE__ */ new Date(),
|
|
493
|
+
children: r ? "Reschedule" : "Schedule"
|
|
494
|
+
})]
|
|
495
|
+
})
|
|
496
|
+
]
|
|
497
|
+
})
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
function Ke(e) {
|
|
501
|
+
let t = /* @__PURE__ */ new Date(), n = new Date(t);
|
|
502
|
+
n.setDate(n.getDate() + 1);
|
|
503
|
+
let r = e.toDateString() === t.toDateString(), i = e.toDateString() === n.toDateString(), a = e.toLocaleTimeString(void 0, {
|
|
504
|
+
hour: "numeric",
|
|
505
|
+
minute: "2-digit"
|
|
506
|
+
});
|
|
507
|
+
return r ? `Today at ${a}` : i ? `Tomorrow at ${a}` : `${e.toLocaleDateString(void 0, {
|
|
508
|
+
weekday: "short",
|
|
509
|
+
month: "short",
|
|
510
|
+
day: "numeric"
|
|
511
|
+
})} at ${a}`;
|
|
512
|
+
}
|
|
513
|
+
function qe({ date: e, onClear: t, onEdit: n }) {
|
|
514
|
+
return /* @__PURE__ */ M(i.div, {
|
|
515
|
+
initial: {
|
|
516
|
+
height: 0,
|
|
517
|
+
opacity: 0
|
|
518
|
+
},
|
|
519
|
+
animate: {
|
|
520
|
+
height: "auto",
|
|
521
|
+
opacity: 1
|
|
522
|
+
},
|
|
523
|
+
exit: {
|
|
524
|
+
height: 0,
|
|
525
|
+
opacity: 0
|
|
526
|
+
},
|
|
527
|
+
transition: { duration: .15 },
|
|
528
|
+
className: "overflow-hidden",
|
|
529
|
+
children: /* @__PURE__ */ N("div", {
|
|
530
|
+
className: "flex items-center gap-ds-03 px-ds-04 py-ds-02b text-ds-xs text-accent-11 bg-accent-2 border-b border-accent-4",
|
|
531
|
+
children: [
|
|
532
|
+
/* @__PURE__ */ M(l, {
|
|
533
|
+
icon: be,
|
|
534
|
+
size: "xs",
|
|
535
|
+
className: "shrink-0"
|
|
536
|
+
}),
|
|
537
|
+
/* @__PURE__ */ N("span", {
|
|
538
|
+
className: "flex-1 truncate",
|
|
539
|
+
children: ["Scheduled for ", Ke(e)]
|
|
540
|
+
}),
|
|
541
|
+
n && /* @__PURE__ */ M("button", {
|
|
542
|
+
type: "button",
|
|
543
|
+
onClick: n,
|
|
544
|
+
className: "inline-flex shrink-0 items-center justify-center rounded-ds-sm p-ds-01 hover:bg-accent-3 transition-colors",
|
|
545
|
+
"aria-label": "Edit schedule",
|
|
546
|
+
children: /* @__PURE__ */ M(l, {
|
|
547
|
+
icon: Oe,
|
|
548
|
+
size: "xs"
|
|
549
|
+
})
|
|
550
|
+
}),
|
|
551
|
+
/* @__PURE__ */ M("button", {
|
|
552
|
+
type: "button",
|
|
553
|
+
onClick: t,
|
|
554
|
+
className: "inline-flex shrink-0 items-center justify-center rounded-ds-sm p-ds-01 hover:bg-accent-3 transition-colors",
|
|
555
|
+
"aria-label": "Cancel schedule",
|
|
556
|
+
children: /* @__PURE__ */ M(l, {
|
|
557
|
+
icon: B,
|
|
558
|
+
size: "xs"
|
|
559
|
+
})
|
|
560
|
+
})
|
|
561
|
+
]
|
|
562
|
+
})
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
//#endregion
|
|
566
|
+
//#region src/composed/rich-chat-input/attachment-strip.tsx
|
|
567
|
+
function Je(e) {
|
|
568
|
+
return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / (1024 * 1024)).toFixed(1)} MB`;
|
|
569
|
+
}
|
|
570
|
+
function Ye({ attachments: e, onRemoveAttachment: t }) {
|
|
571
|
+
return /* @__PURE__ */ M(i.div, {
|
|
572
|
+
initial: {
|
|
573
|
+
height: 0,
|
|
574
|
+
opacity: 0
|
|
575
|
+
},
|
|
576
|
+
animate: {
|
|
577
|
+
height: "auto",
|
|
578
|
+
opacity: 1
|
|
579
|
+
},
|
|
580
|
+
exit: {
|
|
581
|
+
height: 0,
|
|
582
|
+
opacity: 0
|
|
583
|
+
},
|
|
584
|
+
transition: {
|
|
585
|
+
duration: .24,
|
|
586
|
+
ease: [
|
|
587
|
+
.2,
|
|
588
|
+
0,
|
|
589
|
+
.38,
|
|
590
|
+
.9
|
|
591
|
+
]
|
|
592
|
+
},
|
|
593
|
+
className: "overflow-hidden",
|
|
594
|
+
children: /* @__PURE__ */ M("div", {
|
|
595
|
+
role: "list",
|
|
596
|
+
"aria-label": "Attachments",
|
|
597
|
+
className: "flex gap-ds-02 overflow-x-auto px-ds-04 py-ds-02b border-b border-surface-border",
|
|
598
|
+
children: /* @__PURE__ */ M(a, {
|
|
599
|
+
initial: !1,
|
|
600
|
+
children: e.map((e) => e.type === "image" ? /* @__PURE__ */ N(i.div, {
|
|
601
|
+
role: "listitem",
|
|
602
|
+
"aria-label": `Image: ${e.name}`,
|
|
603
|
+
layout: !0,
|
|
604
|
+
initial: {
|
|
605
|
+
scale: 0,
|
|
606
|
+
opacity: 0
|
|
607
|
+
},
|
|
608
|
+
animate: {
|
|
609
|
+
scale: 1,
|
|
610
|
+
opacity: 1
|
|
611
|
+
},
|
|
612
|
+
exit: {
|
|
613
|
+
scale: .95,
|
|
614
|
+
opacity: 0
|
|
615
|
+
},
|
|
616
|
+
transition: {
|
|
617
|
+
layout: {
|
|
618
|
+
type: "spring",
|
|
619
|
+
stiffness: 400,
|
|
620
|
+
damping: 30
|
|
621
|
+
},
|
|
622
|
+
scale: {
|
|
623
|
+
type: "spring",
|
|
624
|
+
stiffness: 400,
|
|
625
|
+
damping: 30
|
|
626
|
+
},
|
|
627
|
+
opacity: { duration: .11 }
|
|
628
|
+
},
|
|
629
|
+
className: "relative h-12 w-12 shrink-0 group",
|
|
630
|
+
children: [
|
|
631
|
+
/* @__PURE__ */ M("img", {
|
|
632
|
+
src: e.url,
|
|
633
|
+
alt: e.name,
|
|
634
|
+
className: "h-full w-full rounded-ds-md object-cover"
|
|
635
|
+
}),
|
|
636
|
+
/* @__PURE__ */ M("button", {
|
|
637
|
+
onClick: () => t(e.id),
|
|
638
|
+
className: "absolute -top-1 -right-1 h-ico-sm w-ico-sm rounded-full bg-error-9 text-error-fg flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity duration-fast-02",
|
|
639
|
+
"aria-label": `Remove ${e.name}`,
|
|
640
|
+
title: "Remove",
|
|
641
|
+
children: /* @__PURE__ */ M(l, {
|
|
642
|
+
icon: B,
|
|
643
|
+
size: "xs"
|
|
644
|
+
})
|
|
645
|
+
}),
|
|
646
|
+
e.uploading && /* @__PURE__ */ M("div", {
|
|
647
|
+
className: "absolute inset-0 rounded-ds-md bg-surface-overlay/50 flex items-center justify-center",
|
|
648
|
+
children: /* @__PURE__ */ M(c, { size: "sm" })
|
|
649
|
+
})
|
|
650
|
+
]
|
|
651
|
+
}, e.id) : /* @__PURE__ */ N(i.div, {
|
|
652
|
+
role: "listitem",
|
|
653
|
+
"aria-label": `File: ${e.name}, ${Je(e.size)}`,
|
|
654
|
+
layout: !0,
|
|
655
|
+
initial: {
|
|
656
|
+
scale: 0,
|
|
657
|
+
opacity: 0
|
|
658
|
+
},
|
|
659
|
+
animate: {
|
|
660
|
+
scale: 1,
|
|
661
|
+
opacity: 1
|
|
662
|
+
},
|
|
663
|
+
exit: {
|
|
664
|
+
scale: .95,
|
|
665
|
+
opacity: 0
|
|
666
|
+
},
|
|
667
|
+
transition: {
|
|
668
|
+
layout: {
|
|
669
|
+
type: "spring",
|
|
670
|
+
stiffness: 400,
|
|
671
|
+
damping: 30
|
|
672
|
+
},
|
|
673
|
+
scale: {
|
|
674
|
+
type: "spring",
|
|
675
|
+
stiffness: 400,
|
|
676
|
+
damping: 30
|
|
677
|
+
},
|
|
678
|
+
opacity: { duration: .11 }
|
|
679
|
+
},
|
|
680
|
+
className: "flex items-center gap-ds-02 shrink-0 rounded-ds-md bg-surface-raised px-ds-03 py-ds-01 group",
|
|
681
|
+
children: [
|
|
682
|
+
/* @__PURE__ */ M(l, {
|
|
683
|
+
icon: Se,
|
|
684
|
+
size: "xs",
|
|
685
|
+
className: "text-surface-fg-muted"
|
|
686
|
+
}),
|
|
687
|
+
/* @__PURE__ */ M("span", {
|
|
688
|
+
className: "text-ds-xs text-surface-fg-muted truncate max-w-[120px]",
|
|
689
|
+
children: e.name
|
|
690
|
+
}),
|
|
691
|
+
/* @__PURE__ */ M("span", {
|
|
692
|
+
className: "text-ds-xs text-surface-fg-subtle",
|
|
693
|
+
children: Je(e.size)
|
|
694
|
+
}),
|
|
695
|
+
/* @__PURE__ */ M("button", {
|
|
696
|
+
onClick: () => t(e.id),
|
|
697
|
+
className: "text-surface-fg-subtle hover:text-error-11 opacity-0 group-hover:opacity-100 transition-opacity duration-fast-02",
|
|
698
|
+
"aria-label": `Remove ${e.name}`,
|
|
699
|
+
title: "Remove",
|
|
700
|
+
children: /* @__PURE__ */ M(l, {
|
|
701
|
+
icon: B,
|
|
702
|
+
size: "xs"
|
|
703
|
+
})
|
|
704
|
+
})
|
|
705
|
+
]
|
|
706
|
+
}, e.id))
|
|
707
|
+
})
|
|
708
|
+
})
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
//#endregion
|
|
712
|
+
//#region src/composed/rich-chat-input/audio-waveform.tsx
|
|
713
|
+
var H = O.forwardRef(function({ mode: e, analyserNode: t, data: n, progress: r = 0, barWidth: i = 3, barGap: a = 2, barCount: o = 40, height: c = 32, className: l, ...u }, d) {
|
|
714
|
+
let [f, p] = O.useState(() => Array(o).fill(.05)), m = O.useRef(0), h = O.useRef(f);
|
|
715
|
+
O.useEffect(() => {
|
|
716
|
+
if (e !== "live" || !t) return;
|
|
717
|
+
let n = new Uint8Array(t.frequencyBinCount), r = () => {
|
|
718
|
+
t.getByteFrequencyData(n);
|
|
719
|
+
let e = Math.floor(n.length / o), i = Array(o);
|
|
720
|
+
for (let t = 0; t < o; t++) {
|
|
721
|
+
let r = 0;
|
|
722
|
+
for (let i = 0; i < e; i++) r += n[t * e + i];
|
|
723
|
+
let a = r / (e * 255);
|
|
724
|
+
i[t] = h.current[t] + (a - h.current[t]) * .3;
|
|
725
|
+
}
|
|
726
|
+
h.current = i, p(i), m.current = requestAnimationFrame(r);
|
|
727
|
+
};
|
|
728
|
+
return m.current = requestAnimationFrame(r), () => cancelAnimationFrame(m.current);
|
|
729
|
+
}, [
|
|
730
|
+
e,
|
|
731
|
+
t,
|
|
732
|
+
o
|
|
733
|
+
]), O.useEffect(() => {
|
|
734
|
+
if (!(e !== "static" || !n)) if (n.length === o) p(n);
|
|
735
|
+
else {
|
|
736
|
+
let e = Array(o), t = n.length / o;
|
|
737
|
+
for (let r = 0; r < o; r++) {
|
|
738
|
+
let i = Math.floor(r * t);
|
|
739
|
+
e[r] = n[Math.min(i, n.length - 1)];
|
|
740
|
+
}
|
|
741
|
+
p(e);
|
|
742
|
+
}
|
|
743
|
+
}, [
|
|
744
|
+
e,
|
|
745
|
+
n,
|
|
746
|
+
o
|
|
747
|
+
]);
|
|
748
|
+
let g = o * (i + a) - a, _ = O.useMemo(() => f.map((t, n) => {
|
|
749
|
+
let s = Math.max(2, t * c), l = n * (i + a), u = (c - s) / 2, d = e === "static" && r > 0 && n / o <= r;
|
|
750
|
+
return /* @__PURE__ */ M("rect", {
|
|
751
|
+
x: l,
|
|
752
|
+
y: u,
|
|
753
|
+
width: i,
|
|
754
|
+
height: s,
|
|
755
|
+
rx: i / 2,
|
|
756
|
+
fill: d ? "var(--color-accent-9)" : "var(--color-surface-border)"
|
|
757
|
+
}, n);
|
|
758
|
+
}), [
|
|
759
|
+
f,
|
|
760
|
+
r,
|
|
761
|
+
e,
|
|
762
|
+
i,
|
|
763
|
+
a,
|
|
764
|
+
o,
|
|
765
|
+
c
|
|
766
|
+
]);
|
|
767
|
+
return /* @__PURE__ */ M("svg", {
|
|
768
|
+
ref: d,
|
|
769
|
+
height: c,
|
|
770
|
+
viewBox: `0 0 ${g} ${c}`,
|
|
771
|
+
preserveAspectRatio: "none",
|
|
772
|
+
"aria-hidden": "true",
|
|
773
|
+
className: s("shrink-0", l),
|
|
774
|
+
...u,
|
|
775
|
+
children: _
|
|
776
|
+
});
|
|
777
|
+
});
|
|
778
|
+
H.displayName = "AudioWaveform";
|
|
779
|
+
//#endregion
|
|
780
|
+
//#region src/composed/rich-chat-input/recording-overlay.tsx
|
|
781
|
+
function Xe(e) {
|
|
782
|
+
let t = Math.floor(e / 60), n = Math.floor(e % 60);
|
|
783
|
+
return {
|
|
784
|
+
minutes: String(t),
|
|
785
|
+
separator: ":",
|
|
786
|
+
secs: n.toString().padStart(2, "0")
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
function Ze({ duration: e, analyserNode: t, maxDuration: n, onCancel: r }) {
|
|
790
|
+
let i = o();
|
|
791
|
+
O.useEffect(() => {
|
|
792
|
+
let e = (e) => {
|
|
793
|
+
e.key === "Escape" && r();
|
|
794
|
+
};
|
|
795
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
796
|
+
}, [r]);
|
|
797
|
+
let a = n != null && n > 0 && e >= n - 10, c = n != null && n > 0 && e >= n - 5, l = c ? "animate-[pulse_500ms_ease-in-out_infinite]" : "animate-[pulse_1s_ease-in-out_infinite]", u = Xe(e), d = c ? "text-error-11" : a ? "text-warning-11" : "text-surface-fg";
|
|
798
|
+
return /* @__PURE__ */ N("div", {
|
|
799
|
+
role: "status",
|
|
800
|
+
"aria-live": "polite",
|
|
801
|
+
"aria-label": "Recording voice message",
|
|
802
|
+
className: "absolute inset-0 flex items-center gap-ds-03 px-ds-04 py-ds-03 bg-surface-raised-hover rounded-ds-lg z-10",
|
|
803
|
+
children: [
|
|
804
|
+
/* @__PURE__ */ M("span", {
|
|
805
|
+
className: s("w-ds-02b h-ds-02b shrink-0 rounded-ds-full bg-error-9", i ? "opacity-100" : l),
|
|
806
|
+
"aria-hidden": "true"
|
|
807
|
+
}),
|
|
808
|
+
/* @__PURE__ */ N("span", {
|
|
809
|
+
className: s("text-ds-sm font-mono tabular-nums whitespace-nowrap", d),
|
|
810
|
+
"aria-label": `${u.minutes} minutes ${u.secs} seconds`,
|
|
811
|
+
children: [
|
|
812
|
+
u.minutes,
|
|
813
|
+
/* @__PURE__ */ M("span", {
|
|
814
|
+
className: i ? void 0 : "animate-[blink_1s_step-end_infinite]",
|
|
815
|
+
"aria-hidden": "true",
|
|
816
|
+
children: u.separator
|
|
817
|
+
}),
|
|
818
|
+
u.secs
|
|
819
|
+
]
|
|
820
|
+
}),
|
|
821
|
+
/* @__PURE__ */ M("div", {
|
|
822
|
+
className: "flex-1 min-w-0 overflow-hidden",
|
|
823
|
+
children: /* @__PURE__ */ M(H, {
|
|
824
|
+
mode: "live",
|
|
825
|
+
analyserNode: t,
|
|
826
|
+
height: 24,
|
|
827
|
+
barCount: 60,
|
|
828
|
+
className: "w-full"
|
|
829
|
+
})
|
|
830
|
+
})
|
|
831
|
+
]
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
Ze.displayName = "RecordingOverlay";
|
|
835
|
+
//#endregion
|
|
836
|
+
//#region src/composed/rich-chat-input/chat-toolbar.tsx
|
|
837
|
+
var U = O.createContext(null);
|
|
838
|
+
function W() {
|
|
839
|
+
let e = O.useContext(U);
|
|
840
|
+
if (!e) throw Error("Toolbar primitives must be used inside <ChatToolbar>");
|
|
841
|
+
return e;
|
|
842
|
+
}
|
|
843
|
+
function G({ onClick: e, isActive: t, disabled: n, title: r, children: i, className: a }) {
|
|
844
|
+
let { disabled: o } = W();
|
|
845
|
+
return /* @__PURE__ */ M("button", {
|
|
846
|
+
type: "button",
|
|
847
|
+
onClick: e,
|
|
848
|
+
disabled: n ?? o,
|
|
849
|
+
title: r,
|
|
850
|
+
"aria-label": r,
|
|
851
|
+
"aria-pressed": t,
|
|
852
|
+
className: s("inline-flex h-ds-xs-plus items-center justify-center rounded-ds-md touch-target", !a?.includes("w-") && "w-ds-xs-plus", "transition-[color,background-color,transform] duration-fast-01 ease-productive-standard", "hover:bg-surface-raised-hover hover:text-surface-fg", "active:scale-95", "disabled:pointer-events-none disabled:opacity-action-disabled", t ? "bg-surface-raised-hover text-accent-11" : "text-surface-fg-subtle", a),
|
|
853
|
+
children: i
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
function K() {
|
|
857
|
+
return /* @__PURE__ */ M("div", { className: "h-4 w-px bg-surface-border-subtle mx-ds-01" });
|
|
858
|
+
}
|
|
859
|
+
function q({ children: e, className: t }) {
|
|
860
|
+
return /* @__PURE__ */ M("div", {
|
|
861
|
+
className: s("flex items-center gap-ds-01", t),
|
|
862
|
+
children: e
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
function Qe() {
|
|
866
|
+
let { editor: e } = W(), { isActive: t } = S({
|
|
867
|
+
editor: e,
|
|
868
|
+
selector: ({ editor: e }) => ({ isActive: e.isActive("bold") })
|
|
869
|
+
});
|
|
870
|
+
return /* @__PURE__ */ M(G, {
|
|
871
|
+
onClick: () => e.chain().focus().toggleBold().run(),
|
|
872
|
+
isActive: t,
|
|
873
|
+
title: "Bold",
|
|
874
|
+
children: /* @__PURE__ */ M(l, {
|
|
875
|
+
icon: _e,
|
|
876
|
+
size: "xs"
|
|
877
|
+
})
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
function $e() {
|
|
881
|
+
let { editor: e } = W(), { isActive: t } = S({
|
|
882
|
+
editor: e,
|
|
883
|
+
selector: ({ editor: e }) => ({ isActive: e.isActive("italic") })
|
|
884
|
+
});
|
|
885
|
+
return /* @__PURE__ */ M(G, {
|
|
886
|
+
onClick: () => e.chain().focus().toggleItalic().run(),
|
|
887
|
+
isActive: t,
|
|
888
|
+
title: "Italic",
|
|
889
|
+
children: /* @__PURE__ */ M(l, {
|
|
890
|
+
icon: F,
|
|
891
|
+
size: "xs"
|
|
892
|
+
})
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
function et() {
|
|
896
|
+
let { editor: e } = W(), { isActive: t } = S({
|
|
897
|
+
editor: e,
|
|
898
|
+
selector: ({ editor: e }) => ({ isActive: e.isActive("underline") })
|
|
899
|
+
});
|
|
900
|
+
return /* @__PURE__ */ M(G, {
|
|
901
|
+
onClick: () => e.chain().focus().toggleUnderline().run(),
|
|
902
|
+
isActive: t,
|
|
903
|
+
title: "Underline",
|
|
904
|
+
children: /* @__PURE__ */ M(l, {
|
|
905
|
+
icon: Fe,
|
|
906
|
+
size: "xs"
|
|
907
|
+
})
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
function tt() {
|
|
911
|
+
let { editor: e } = W(), { isActive: t } = S({
|
|
912
|
+
editor: e,
|
|
913
|
+
selector: ({ editor: e }) => ({ isActive: e.isActive("strike") })
|
|
914
|
+
});
|
|
915
|
+
return /* @__PURE__ */ M(G, {
|
|
916
|
+
onClick: () => e.chain().focus().toggleStrike().run(),
|
|
917
|
+
isActive: t,
|
|
918
|
+
title: "Strikethrough",
|
|
919
|
+
children: /* @__PURE__ */ M(l, {
|
|
920
|
+
icon: z,
|
|
921
|
+
size: "xs"
|
|
922
|
+
})
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
function nt() {
|
|
926
|
+
let { editor: e } = W(), { isActive: t } = S({
|
|
927
|
+
editor: e,
|
|
928
|
+
selector: ({ editor: e }) => ({ isActive: e.isActive("highlight") })
|
|
929
|
+
});
|
|
930
|
+
return /* @__PURE__ */ M(G, {
|
|
931
|
+
onClick: () => e.chain().focus().toggleHighlight().run(),
|
|
932
|
+
isActive: t,
|
|
933
|
+
title: "Highlight",
|
|
934
|
+
children: /* @__PURE__ */ M(l, {
|
|
935
|
+
icon: Ce,
|
|
936
|
+
size: "xs"
|
|
937
|
+
})
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
function rt() {
|
|
941
|
+
let { editor: e } = W(), { isActive: t } = S({
|
|
942
|
+
editor: e,
|
|
943
|
+
selector: ({ editor: e }) => ({ isActive: e.isActive("code") })
|
|
944
|
+
});
|
|
945
|
+
return /* @__PURE__ */ M(G, {
|
|
946
|
+
onClick: () => e.chain().focus().toggleCode().run(),
|
|
947
|
+
isActive: t,
|
|
948
|
+
title: "Inline code",
|
|
949
|
+
children: /* @__PURE__ */ M(l, {
|
|
950
|
+
icon: xe,
|
|
951
|
+
size: "xs"
|
|
952
|
+
})
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
function it() {
|
|
956
|
+
let { editor: e } = W(), { isActive: t } = S({
|
|
957
|
+
editor: e,
|
|
958
|
+
selector: ({ editor: e }) => ({ isActive: e.isActive("bulletList") })
|
|
959
|
+
});
|
|
960
|
+
return /* @__PURE__ */ M(G, {
|
|
961
|
+
onClick: () => e.chain().focus().toggleBulletList().run(),
|
|
962
|
+
isActive: t,
|
|
963
|
+
title: "Bullet list",
|
|
964
|
+
children: /* @__PURE__ */ M(l, {
|
|
965
|
+
icon: I,
|
|
966
|
+
size: "xs"
|
|
967
|
+
})
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
function J() {
|
|
971
|
+
let { editor: e } = W(), { isActive: t } = S({
|
|
972
|
+
editor: e,
|
|
973
|
+
selector: ({ editor: e }) => ({ isActive: e.isActive("orderedList") })
|
|
974
|
+
});
|
|
975
|
+
return /* @__PURE__ */ M(G, {
|
|
976
|
+
onClick: () => e.chain().focus().toggleOrderedList().run(),
|
|
977
|
+
isActive: t,
|
|
978
|
+
title: "Ordered list",
|
|
979
|
+
children: /* @__PURE__ */ M(l, {
|
|
980
|
+
icon: Te,
|
|
981
|
+
size: "xs"
|
|
982
|
+
})
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
function at() {
|
|
986
|
+
let { editor: e } = W(), { isActive: t } = S({
|
|
987
|
+
editor: e,
|
|
988
|
+
selector: ({ editor: e }) => ({ isActive: e.isActive("blockquote") })
|
|
989
|
+
});
|
|
990
|
+
return /* @__PURE__ */ M(G, {
|
|
991
|
+
onClick: () => e.chain().focus().toggleBlockquote().run(),
|
|
992
|
+
isActive: t,
|
|
993
|
+
title: "Quote",
|
|
994
|
+
children: /* @__PURE__ */ M(l, {
|
|
995
|
+
icon: P,
|
|
996
|
+
size: "xs"
|
|
997
|
+
})
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
function Y() {
|
|
1001
|
+
let { editor: e } = W(), { isActive: t } = S({
|
|
1002
|
+
editor: e,
|
|
1003
|
+
selector: ({ editor: e }) => ({ isActive: e.isActive("link") })
|
|
1004
|
+
});
|
|
1005
|
+
return /* @__PURE__ */ M(G, {
|
|
1006
|
+
onClick: () => {
|
|
1007
|
+
let t = window.prompt("URL");
|
|
1008
|
+
t && e.chain().focus().setLink({ href: t }).run();
|
|
1009
|
+
},
|
|
1010
|
+
isActive: t,
|
|
1011
|
+
title: "Link",
|
|
1012
|
+
children: /* @__PURE__ */ M(l, {
|
|
1013
|
+
icon: we,
|
|
1014
|
+
size: "xs"
|
|
1015
|
+
})
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
function ot() {
|
|
1019
|
+
let { editor: e } = W();
|
|
1020
|
+
return /* @__PURE__ */ M(G, {
|
|
1021
|
+
onClick: () => e.chain().focus().insertContent("@").run(),
|
|
1022
|
+
title: "Mention",
|
|
1023
|
+
children: /* @__PURE__ */ M(l, {
|
|
1024
|
+
icon: ge,
|
|
1025
|
+
size: "xs"
|
|
1026
|
+
})
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
function st() {
|
|
1030
|
+
let { editor: e } = W();
|
|
1031
|
+
return /* @__PURE__ */ M(G, {
|
|
1032
|
+
onClick: () => e.chain().focus().insertContent(":").run(),
|
|
1033
|
+
title: "Emoji",
|
|
1034
|
+
children: /* @__PURE__ */ M(l, {
|
|
1035
|
+
icon: De,
|
|
1036
|
+
size: "xs"
|
|
1037
|
+
})
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
function ct() {
|
|
1041
|
+
let { editor: e } = W();
|
|
1042
|
+
return /* @__PURE__ */ M(G, {
|
|
1043
|
+
onClick: () => e.chain().focus().insertContent("/").run(),
|
|
1044
|
+
title: "Slash command",
|
|
1045
|
+
children: /* @__PURE__ */ M(l, {
|
|
1046
|
+
icon: R,
|
|
1047
|
+
size: "xs"
|
|
1048
|
+
})
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
function X({ items: e, isMobile: t, hasMentions: n, hasSlashCommands: r }) {
|
|
1052
|
+
let i = (t) => !e || e.includes(t);
|
|
1053
|
+
return /* @__PURE__ */ N(me, { children: [
|
|
1054
|
+
!t && /* @__PURE__ */ N(q, { children: [
|
|
1055
|
+
i("bold") && /* @__PURE__ */ M(Qe, {}),
|
|
1056
|
+
i("italic") && /* @__PURE__ */ M($e, {}),
|
|
1057
|
+
i("underline") && /* @__PURE__ */ M(et, {}),
|
|
1058
|
+
i("strike") && /* @__PURE__ */ M(tt, {}),
|
|
1059
|
+
i("highlight") && /* @__PURE__ */ M(nt, {})
|
|
1060
|
+
] }),
|
|
1061
|
+
!t && /* @__PURE__ */ M(K, {}),
|
|
1062
|
+
!t && /* @__PURE__ */ N(q, { children: [i("bulletList") && /* @__PURE__ */ M(it, {}), i("orderedList") && /* @__PURE__ */ M(J, {})] }),
|
|
1063
|
+
!t && (i("blockquote") || i("link") || i("code")) && /* @__PURE__ */ M(K, {}),
|
|
1064
|
+
!t && /* @__PURE__ */ N(q, { children: [
|
|
1065
|
+
i("blockquote") && /* @__PURE__ */ M(at, {}),
|
|
1066
|
+
i("link") && /* @__PURE__ */ M(Y, {}),
|
|
1067
|
+
i("code") && /* @__PURE__ */ M(rt, {})
|
|
1068
|
+
] }),
|
|
1069
|
+
!t && (n || r) && /* @__PURE__ */ M(K, {}),
|
|
1070
|
+
/* @__PURE__ */ N(q, { children: [
|
|
1071
|
+
n && i("mention") && /* @__PURE__ */ M(ot, {}),
|
|
1072
|
+
i("emoji") && /* @__PURE__ */ M(st, {}),
|
|
1073
|
+
r && i("slash") && /* @__PURE__ */ M(ct, {})
|
|
1074
|
+
] })
|
|
1075
|
+
] });
|
|
1076
|
+
}
|
|
1077
|
+
function lt({ editor: e, toolbar: t, isMobile: n, hasMentions: r, hasSlashCommands: i, disabled: a }) {
|
|
1078
|
+
if (t === !1) return null;
|
|
1079
|
+
let o = typeof t != "boolean" && !Array.isArray(t), s = Array.isArray(t) ? t : null;
|
|
1080
|
+
return /* @__PURE__ */ M(U.Provider, {
|
|
1081
|
+
value: {
|
|
1082
|
+
editor: e,
|
|
1083
|
+
disabled: a
|
|
1084
|
+
},
|
|
1085
|
+
children: /* @__PURE__ */ M("div", {
|
|
1086
|
+
role: "toolbar",
|
|
1087
|
+
"aria-label": "Text formatting",
|
|
1088
|
+
className: "flex flex-wrap items-center gap-ds-01 border-t border-surface-border px-ds-04 py-ds-02b",
|
|
1089
|
+
children: o ? t : /* @__PURE__ */ M(X, {
|
|
1090
|
+
items: s,
|
|
1091
|
+
isMobile: n,
|
|
1092
|
+
hasMentions: r,
|
|
1093
|
+
hasSlashCommands: i
|
|
1094
|
+
})
|
|
1095
|
+
})
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
//#endregion
|
|
1099
|
+
//#region src/composed/rich-chat-input/audio-player.tsx
|
|
1100
|
+
var ut = [
|
|
1101
|
+
1,
|
|
1102
|
+
1.5,
|
|
1103
|
+
2
|
|
1104
|
+
];
|
|
1105
|
+
function Z(e) {
|
|
1106
|
+
return `${Math.floor(e / 60)}:${Math.floor(e % 60).toString().padStart(2, "0")}`;
|
|
1107
|
+
}
|
|
1108
|
+
var dt = O.forwardRef(function({ src: e, duration: t, waveformData: n, className: r, ...i }, a) {
|
|
1109
|
+
let o = O.useRef(null), c = O.useRef(null), [l, u] = O.useState(!1), [d, f] = O.useState(0), [p, m] = O.useState(0), [h, g] = O.useState(null), _ = O.useMemo(() => {
|
|
1110
|
+
if (typeof e == "string") return e;
|
|
1111
|
+
let t = URL.createObjectURL(e);
|
|
1112
|
+
return g(t), t;
|
|
1113
|
+
}, [e]);
|
|
1114
|
+
O.useEffect(() => () => {
|
|
1115
|
+
h && URL.revokeObjectURL(h);
|
|
1116
|
+
}, [h]), O.useEffect(() => {
|
|
1117
|
+
let e = o.current;
|
|
1118
|
+
if (!e) return;
|
|
1119
|
+
let t = () => f(e.currentTime), n = () => {
|
|
1120
|
+
u(!1), f(0);
|
|
1121
|
+
};
|
|
1122
|
+
return e.addEventListener("timeupdate", t), e.addEventListener("ended", n), () => {
|
|
1123
|
+
e.removeEventListener("timeupdate", t), e.removeEventListener("ended", n);
|
|
1124
|
+
};
|
|
1125
|
+
}, []);
|
|
1126
|
+
let v = O.useCallback(() => {
|
|
1127
|
+
let e = o.current;
|
|
1128
|
+
e && (l ? (e.pause(), u(!1)) : (e.play(), u(!0)));
|
|
1129
|
+
}, [l]), y = O.useCallback((e) => {
|
|
1130
|
+
(e.key === " " || e.key === "Enter") && (e.preventDefault(), v());
|
|
1131
|
+
}, [v]), b = O.useCallback((e) => {
|
|
1132
|
+
let n = o.current, r = c.current;
|
|
1133
|
+
if (!n || !r || t <= 0) return;
|
|
1134
|
+
let i = r.getBoundingClientRect(), a = e.clientX - i.left;
|
|
1135
|
+
n.currentTime = Math.max(0, Math.min(1, a / i.width)) * t, f(n.currentTime);
|
|
1136
|
+
}, [t]), x = O.useCallback(() => {
|
|
1137
|
+
let e = (p + 1) % ut.length;
|
|
1138
|
+
m(e), o.current && (o.current.playbackRate = ut[e]);
|
|
1139
|
+
}, [p]), S = t > 0 ? d / t : 0, C = ut[p];
|
|
1140
|
+
return /* @__PURE__ */ N("div", {
|
|
1141
|
+
ref: a,
|
|
1142
|
+
role: "group",
|
|
1143
|
+
"aria-label": "Voice message player",
|
|
1144
|
+
className: s("flex items-center gap-ds-03", r),
|
|
1145
|
+
...i,
|
|
1146
|
+
children: [
|
|
1147
|
+
/* @__PURE__ */ M("audio", {
|
|
1148
|
+
ref: o,
|
|
1149
|
+
src: _,
|
|
1150
|
+
preload: "metadata"
|
|
1151
|
+
}),
|
|
1152
|
+
/* @__PURE__ */ M("button", {
|
|
1153
|
+
type: "button",
|
|
1154
|
+
onClick: v,
|
|
1155
|
+
onKeyDown: y,
|
|
1156
|
+
"aria-label": l ? "Pause voice message" : "Play voice message",
|
|
1157
|
+
className: "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-ds-full bg-accent-9 text-accent-fg hover:bg-accent-10 active:scale-95 transition-colors duration-fast-01 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-2",
|
|
1158
|
+
children: M(l ? ke : L, {
|
|
1159
|
+
size: 16,
|
|
1160
|
+
stroke: 2,
|
|
1161
|
+
"aria-hidden": "true"
|
|
1162
|
+
})
|
|
1163
|
+
}),
|
|
1164
|
+
/* @__PURE__ */ M(H, {
|
|
1165
|
+
ref: c,
|
|
1166
|
+
mode: "static",
|
|
1167
|
+
data: n,
|
|
1168
|
+
progress: S,
|
|
1169
|
+
className: "cursor-pointer",
|
|
1170
|
+
onClick: b
|
|
1171
|
+
}),
|
|
1172
|
+
/* @__PURE__ */ N("span", {
|
|
1173
|
+
className: "text-ds-xs tabular-nums text-surface-fg-subtle whitespace-nowrap",
|
|
1174
|
+
children: [
|
|
1175
|
+
Z(d),
|
|
1176
|
+
" / ",
|
|
1177
|
+
Z(t)
|
|
1178
|
+
]
|
|
1179
|
+
}),
|
|
1180
|
+
/* @__PURE__ */ N("button", {
|
|
1181
|
+
type: "button",
|
|
1182
|
+
onClick: x,
|
|
1183
|
+
"aria-label": `Playback speed ${C}x`,
|
|
1184
|
+
className: "shrink-0 text-ds-xs bg-surface-raised rounded-ds-full px-ds-02 py-[1px] hover:bg-surface-raised-hover tabular-nums transition-colors duration-fast-01 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-2",
|
|
1185
|
+
children: [C, "x"]
|
|
1186
|
+
})
|
|
1187
|
+
]
|
|
1188
|
+
});
|
|
1189
|
+
});
|
|
1190
|
+
dt.displayName = "AudioPlayer";
|
|
1191
|
+
//#endregion
|
|
1192
|
+
//#region src/composed/rich-chat-input/use-voice-recorder.ts
|
|
1193
|
+
function ft() {
|
|
1194
|
+
return typeof MediaRecorder < "u" && MediaRecorder.isTypeSupported("audio/webm;codecs=opus") ? "audio/webm;codecs=opus" : typeof MediaRecorder < "u" && MediaRecorder.isTypeSupported("audio/mp4") ? "audio/mp4" : "";
|
|
1195
|
+
}
|
|
1196
|
+
function pt(e) {
|
|
1197
|
+
let { maxDuration: t, onComplete: n } = e, [r, i] = j("idle"), [a, o] = j(0), [s, c] = j(null), [l, u] = j([]), d = A(null), f = A(null), p = A(null), m = A([]), h = A(null), g = A(null), _ = A(null), v = A(null), y = A(0), b = A([]), x = A(!1), S = A(n);
|
|
1198
|
+
S.current = n;
|
|
1199
|
+
let C = k(() => {
|
|
1200
|
+
h.current !== null && (clearInterval(h.current), h.current = null), g.current !== null && (clearInterval(g.current), g.current = null), _.current !== null && (clearTimeout(_.current), _.current = null), p.current &&= (p.current.getTracks().forEach((e) => e.stop()), null), f.current &&= (f.current.close().catch(() => {}), null), v.current = null, c(null), d.current = null, m.current = [];
|
|
1201
|
+
}, []), w = k(async () => {
|
|
1202
|
+
if (typeof MediaRecorder > "u") throw Error("MediaRecorder is not supported in this browser. Voice recording requires a modern browser with MediaRecorder support.");
|
|
1203
|
+
let e = await navigator.mediaDevices.getUserMedia({ audio: !0 });
|
|
1204
|
+
p.current = e;
|
|
1205
|
+
let n = ft(), r = n ? new MediaRecorder(e, { mimeType: n }) : new MediaRecorder(e);
|
|
1206
|
+
d.current = r, m.current = [], x.current = !1;
|
|
1207
|
+
let a = new AudioContext();
|
|
1208
|
+
f.current = a;
|
|
1209
|
+
let s = a.createMediaStreamSource(e), l = a.createAnalyser();
|
|
1210
|
+
l.fftSize = 256, l.smoothingTimeConstant = .7, s.connect(l), v.current = l, c(l), r.ondataavailable = (e) => {
|
|
1211
|
+
e.data.size > 0 && m.current.push(e.data);
|
|
1212
|
+
}, r.onstop = () => {
|
|
1213
|
+
if (x.current) C(), i("idle"), o(0), u([]);
|
|
1214
|
+
else {
|
|
1215
|
+
let e = new Blob(m.current, { type: r.mimeType || "audio/webm" }), t = y.current, n = b.current;
|
|
1216
|
+
C(), i("idle"), o(0), u([]), S.current(e, t, n);
|
|
1217
|
+
}
|
|
1218
|
+
}, r.start(), o(0), y.current = 0, h.current = setInterval(() => {
|
|
1219
|
+
y.current += 1, o((e) => e + 1);
|
|
1220
|
+
}, 1e3);
|
|
1221
|
+
let w = new Uint8Array(l.frequencyBinCount);
|
|
1222
|
+
u([]), b.current = [], g.current = setInterval(() => {
|
|
1223
|
+
if (v.current) {
|
|
1224
|
+
v.current.getByteFrequencyData(w);
|
|
1225
|
+
let e = 0;
|
|
1226
|
+
for (let t = 0; t < w.length; t++) e += w[t];
|
|
1227
|
+
let t = e / w.length / 255;
|
|
1228
|
+
b.current = [...b.current, t], u((e) => [...e, t]);
|
|
1229
|
+
}
|
|
1230
|
+
}, 100), t !== void 0 && t > 0 && (_.current = setTimeout(() => {
|
|
1231
|
+
d.current && d.current.state !== "inactive" && d.current.stop();
|
|
1232
|
+
}, t * 1e3)), i("recording");
|
|
1233
|
+
}, [t, C]), ee = k(() => {
|
|
1234
|
+
d.current && d.current.state !== "inactive" && (x.current = !1, d.current.stop());
|
|
1235
|
+
}, []), te = k(() => {
|
|
1236
|
+
d.current && d.current.state !== "inactive" ? (x.current = !0, d.current.stop()) : (C(), i("idle"), o(0), u([]));
|
|
1237
|
+
}, [C]), ne = k(() => {
|
|
1238
|
+
d.current && d.current.state === "recording" && (d.current.pause(), h.current !== null && (clearInterval(h.current), h.current = null), g.current !== null && (clearInterval(g.current), g.current = null), i("paused"));
|
|
1239
|
+
}, []), T = k(() => {
|
|
1240
|
+
if (d.current && d.current.state === "paused") {
|
|
1241
|
+
d.current.resume(), h.current = setInterval(() => {
|
|
1242
|
+
y.current += 1, o((e) => e + 1);
|
|
1243
|
+
}, 1e3);
|
|
1244
|
+
let e = new Uint8Array(v.current?.frequencyBinCount ?? 128);
|
|
1245
|
+
g.current = setInterval(() => {
|
|
1246
|
+
if (v.current) {
|
|
1247
|
+
v.current.getByteFrequencyData(e);
|
|
1248
|
+
let t = 0;
|
|
1249
|
+
for (let n = 0; n < e.length; n++) t += e[n];
|
|
1250
|
+
let n = t / e.length / 255;
|
|
1251
|
+
b.current = [...b.current, n], u((e) => [...e, n]);
|
|
1252
|
+
}
|
|
1253
|
+
}, 100), i("recording");
|
|
1254
|
+
}
|
|
1255
|
+
}, []);
|
|
1256
|
+
return pe(() => () => {
|
|
1257
|
+
h.current !== null && clearInterval(h.current), g.current !== null && clearInterval(g.current), _.current !== null && clearTimeout(_.current), d.current && d.current.state !== "inactive" && d.current.stop(), p.current && p.current.getTracks().forEach((e) => e.stop()), f.current && f.current.close().catch(() => {});
|
|
1258
|
+
}, []), {
|
|
1259
|
+
state: r,
|
|
1260
|
+
duration: a,
|
|
1261
|
+
analyserNode: s,
|
|
1262
|
+
waveformData: l,
|
|
1263
|
+
start: w,
|
|
1264
|
+
stop: ee,
|
|
1265
|
+
cancel: te,
|
|
1266
|
+
pause: ne,
|
|
1267
|
+
resume: T
|
|
1268
|
+
};
|
|
1269
|
+
}
|
|
1270
|
+
//#endregion
|
|
1271
|
+
//#region src/composed/rich-chat-input.tsx
|
|
1272
|
+
var mt = {
|
|
1273
|
+
compact: {
|
|
1274
|
+
minHeight: 44,
|
|
1275
|
+
maxHeight: 256,
|
|
1276
|
+
showToolbar: !0,
|
|
1277
|
+
toolbarPosition: "bottom"
|
|
1278
|
+
},
|
|
1279
|
+
expanded: {
|
|
1280
|
+
minHeight: 96,
|
|
1281
|
+
maxHeight: 384,
|
|
1282
|
+
showToolbar: !0,
|
|
1283
|
+
toolbarPosition: "bottom"
|
|
1284
|
+
},
|
|
1285
|
+
minimal: {
|
|
1286
|
+
minHeight: 44,
|
|
1287
|
+
maxHeight: 128,
|
|
1288
|
+
showToolbar: !1,
|
|
1289
|
+
toolbarPosition: "bottom"
|
|
1290
|
+
},
|
|
1291
|
+
inline: {
|
|
1292
|
+
minHeight: 40,
|
|
1293
|
+
maxHeight: 160,
|
|
1294
|
+
showToolbar: !1,
|
|
1295
|
+
toolbarPosition: "top"
|
|
1296
|
+
}
|
|
1297
|
+
}, ht = [
|
|
1298
|
+
"prose prose-sm max-w-none focus:outline-hidden",
|
|
1299
|
+
"font-body text-ds-md leading-relaxed text-surface-fg",
|
|
1300
|
+
"[&_p.is-editor-empty:first-child]:relative",
|
|
1301
|
+
"[&_p.is-editor-empty:first-child::before]:text-surface-fg-subtle [&_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)] [&_p.is-editor-empty:first-child::before]:pointer-events-none [&_p.is-editor-empty:first-child::before]:absolute [&_p.is-editor-empty:first-child::before]:left-0 [&_p.is-editor-empty:first-child::before]:top-0 [&_p.is-editor-empty:first-child::before]:w-full [&_p.is-editor-empty:first-child::before]:truncate",
|
|
1302
|
+
"[&_p]:mb-ds-01 [&_p]:text-surface-fg",
|
|
1303
|
+
"[&_p:last-child]:mb-0",
|
|
1304
|
+
"[&_ul]:ml-ds-04 [&_ul]:list-disc [&_ol]:ml-ds-04 [&_ol]:list-decimal",
|
|
1305
|
+
"[&_li]:text-surface-fg",
|
|
1306
|
+
"[&_code]:rounded [&_code]:bg-surface-raised [&_code]:px-ds-02 [&_code]:py-[1px] [&_code]:text-ds-md [&_code]:text-accent-11",
|
|
1307
|
+
"[&_strong]:font-semibold [&_strong]:text-surface-fg",
|
|
1308
|
+
"[[&_mark]:rounded-sm_mark]:rounded-xs [&_mark]:bg-warning-3 [&_mark]:px-[2px]",
|
|
1309
|
+
"[&_a]:text-accent-11 [&_a]:underline",
|
|
1310
|
+
"[&_.mention]:rounded-ds-sm [&_.mention]:bg-accent-2 [&_.mention]:px-ds-02 [&_.mention]:py-[1px] [&_.mention]:font-medium [&_.mention]:text-accent-11"
|
|
1311
|
+
].join(" ");
|
|
1312
|
+
function gt({ options: e }) {
|
|
1313
|
+
let [t, n] = O.useState(!1), r = O.useRef(null);
|
|
1314
|
+
return O.useEffect(() => {
|
|
1315
|
+
if (!t) return;
|
|
1316
|
+
let e = (e) => {
|
|
1317
|
+
r.current && !r.current.contains(e.target) && n(!1);
|
|
1318
|
+
};
|
|
1319
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
1320
|
+
}, [t]), /* @__PURE__ */ N("div", {
|
|
1321
|
+
ref: r,
|
|
1322
|
+
className: "relative",
|
|
1323
|
+
children: [/* @__PURE__ */ M("button", {
|
|
1324
|
+
type: "button",
|
|
1325
|
+
onClick: () => n((e) => !e),
|
|
1326
|
+
title: "More send options",
|
|
1327
|
+
"aria-label": "More send options",
|
|
1328
|
+
"aria-expanded": t,
|
|
1329
|
+
className: s("inline-flex h-ds-xs-plus w-5 items-center justify-center rounded-ds-md touch-target", "text-surface-fg-subtle hover:bg-surface-raised-hover hover:text-surface-fg", "transition-colors duration-fast-01 ease-productive-standard", t && "bg-surface-raised-hover text-surface-fg"),
|
|
1330
|
+
children: /* @__PURE__ */ M(l, {
|
|
1331
|
+
icon: ye,
|
|
1332
|
+
size: "xs"
|
|
1333
|
+
})
|
|
1334
|
+
}), t && /* @__PURE__ */ N("div", {
|
|
1335
|
+
className: "absolute bottom-full right-0 mb-ds-02 min-w-[200px] rounded-ds-lg border border-surface-border-strong bg-surface-overlay p-ds-02 shadow-floating z-popover",
|
|
1336
|
+
children: [/* @__PURE__ */ M("p", {
|
|
1337
|
+
className: "px-ds-03 py-ds-01 text-ds-xs font-medium text-surface-fg-subtle",
|
|
1338
|
+
children: "Send options"
|
|
1339
|
+
}), e.map((e, t) => /* @__PURE__ */ N("button", {
|
|
1340
|
+
type: "button",
|
|
1341
|
+
onClick: () => {
|
|
1342
|
+
e.onSelect(), n(!1);
|
|
1343
|
+
},
|
|
1344
|
+
className: "flex w-full items-center gap-ds-03 rounded-ds-md px-ds-03 py-ds-02 text-ds-sm text-surface-fg hover:bg-surface-raised-hover transition-colors duration-fast-01",
|
|
1345
|
+
children: [e.icon && /* @__PURE__ */ M(e.icon, { className: "h-ico-sm w-ico-sm text-surface-fg-muted" }), e.label]
|
|
1346
|
+
}, t))]
|
|
1347
|
+
})]
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
var _t = O.lazy(() => import("@emoji-mart/react"));
|
|
1351
|
+
function vt({ set: e = "native", onSelect: t, onClose: n }) {
|
|
1352
|
+
let [r, i] = O.useState(null), { colorMode: a } = de(), o = O.useRef(null);
|
|
1353
|
+
O.useEffect(() => {
|
|
1354
|
+
(v[e] ?? v.native)().then((e) => i(e.default));
|
|
1355
|
+
}, [e]), O.useEffect(() => {
|
|
1356
|
+
let e = (e) => {
|
|
1357
|
+
o.current && !o.current.contains(e.target) && n();
|
|
1358
|
+
};
|
|
1359
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
1360
|
+
}, [n]), O.useEffect(() => {
|
|
1361
|
+
let e = (e) => {
|
|
1362
|
+
e.key === "Escape" && n();
|
|
1363
|
+
};
|
|
1364
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
1365
|
+
}, [n]);
|
|
1366
|
+
let s = /* @__PURE__ */ M("div", {
|
|
1367
|
+
className: "flex h-[350px] w-[352px] items-center justify-center rounded-ds-lg border border-surface-border-strong bg-surface-overlay shadow-floating",
|
|
1368
|
+
children: /* @__PURE__ */ M("span", {
|
|
1369
|
+
className: "text-ds-sm text-surface-fg-subtle",
|
|
1370
|
+
children: "Loading..."
|
|
1371
|
+
})
|
|
1372
|
+
});
|
|
1373
|
+
return /* @__PURE__ */ M("div", {
|
|
1374
|
+
ref: o,
|
|
1375
|
+
className: "rounded-ds-lg border border-surface-border-strong bg-surface-overlay shadow-floating overflow-hidden",
|
|
1376
|
+
children: r ? /* @__PURE__ */ M(O.Suspense, {
|
|
1377
|
+
fallback: s,
|
|
1378
|
+
children: /* @__PURE__ */ M(_t, {
|
|
1379
|
+
data: r,
|
|
1380
|
+
set: e,
|
|
1381
|
+
onEmojiSelect: (e) => t({
|
|
1382
|
+
id: e.id,
|
|
1383
|
+
native: e.native
|
|
1384
|
+
}),
|
|
1385
|
+
theme: a === "dark" ? "dark" : "light",
|
|
1386
|
+
previewPosition: "none",
|
|
1387
|
+
skinTonePosition: "none"
|
|
1388
|
+
})
|
|
1389
|
+
}) : s
|
|
1390
|
+
});
|
|
1391
|
+
}
|
|
1392
|
+
function Q({ onClick: e, isActive: t = !1, title: n, children: r }) {
|
|
1393
|
+
return /* @__PURE__ */ M("button", {
|
|
1394
|
+
type: "button",
|
|
1395
|
+
onClick: e,
|
|
1396
|
+
title: n,
|
|
1397
|
+
"aria-label": n,
|
|
1398
|
+
"aria-pressed": t,
|
|
1399
|
+
className: s("inline-flex h-ds-xs-plus w-ds-xs-plus items-center justify-center rounded-ds-md touch-target", "transition-colors duration-fast-01 ease-productive-standard", "hover:bg-surface-raised-hover", t ? "bg-surface-raised-hover text-accent-11" : "text-surface-fg-subtle"),
|
|
1400
|
+
children: r
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
function yt({ editor: e }) {
|
|
1404
|
+
let t = S({
|
|
1405
|
+
editor: e,
|
|
1406
|
+
selector: ({ editor: e }) => ({
|
|
1407
|
+
isBold: e.isActive("bold"),
|
|
1408
|
+
isItalic: e.isActive("italic"),
|
|
1409
|
+
isUnderline: e.isActive("underline"),
|
|
1410
|
+
isStrike: e.isActive("strike"),
|
|
1411
|
+
isHighlight: e.isActive("highlight"),
|
|
1412
|
+
isCode: e.isActive("code")
|
|
1413
|
+
})
|
|
1414
|
+
});
|
|
1415
|
+
return /* @__PURE__ */ N(E, {
|
|
1416
|
+
editor: e,
|
|
1417
|
+
className: "flex gap-ds-01 rounded-ds-lg border border-surface-border-strong bg-surface-overlay p-ds-02 shadow-floating",
|
|
1418
|
+
children: [
|
|
1419
|
+
/* @__PURE__ */ M(Q, {
|
|
1420
|
+
onClick: () => e.chain().focus().toggleBold().run(),
|
|
1421
|
+
isActive: t.isBold,
|
|
1422
|
+
title: "Bold",
|
|
1423
|
+
children: /* @__PURE__ */ M(l, {
|
|
1424
|
+
icon: _e,
|
|
1425
|
+
size: "xs"
|
|
1426
|
+
})
|
|
1427
|
+
}),
|
|
1428
|
+
/* @__PURE__ */ M(Q, {
|
|
1429
|
+
onClick: () => e.chain().focus().toggleItalic().run(),
|
|
1430
|
+
isActive: t.isItalic,
|
|
1431
|
+
title: "Italic",
|
|
1432
|
+
children: /* @__PURE__ */ M(l, {
|
|
1433
|
+
icon: F,
|
|
1434
|
+
size: "xs"
|
|
1435
|
+
})
|
|
1436
|
+
}),
|
|
1437
|
+
/* @__PURE__ */ M(Q, {
|
|
1438
|
+
onClick: () => e.chain().focus().toggleUnderline().run(),
|
|
1439
|
+
isActive: t.isUnderline,
|
|
1440
|
+
title: "Underline",
|
|
1441
|
+
children: /* @__PURE__ */ M(l, {
|
|
1442
|
+
icon: Fe,
|
|
1443
|
+
size: "xs"
|
|
1444
|
+
})
|
|
1445
|
+
}),
|
|
1446
|
+
/* @__PURE__ */ M(Q, {
|
|
1447
|
+
onClick: () => e.chain().focus().toggleStrike().run(),
|
|
1448
|
+
isActive: t.isStrike,
|
|
1449
|
+
title: "Strikethrough",
|
|
1450
|
+
children: /* @__PURE__ */ M(l, {
|
|
1451
|
+
icon: z,
|
|
1452
|
+
size: "xs"
|
|
1453
|
+
})
|
|
1454
|
+
}),
|
|
1455
|
+
/* @__PURE__ */ M(Q, {
|
|
1456
|
+
onClick: () => e.chain().focus().toggleHighlight().run(),
|
|
1457
|
+
isActive: t.isHighlight,
|
|
1458
|
+
title: "Highlight",
|
|
1459
|
+
children: /* @__PURE__ */ M(l, {
|
|
1460
|
+
icon: Ce,
|
|
1461
|
+
size: "xs"
|
|
1462
|
+
})
|
|
1463
|
+
}),
|
|
1464
|
+
/* @__PURE__ */ M(Q, {
|
|
1465
|
+
onClick: () => e.chain().focus().toggleCode().run(),
|
|
1466
|
+
isActive: t.isCode,
|
|
1467
|
+
title: "Code",
|
|
1468
|
+
children: /* @__PURE__ */ M(l, {
|
|
1469
|
+
icon: xe,
|
|
1470
|
+
size: "xs"
|
|
1471
|
+
})
|
|
1472
|
+
})
|
|
1473
|
+
]
|
|
1474
|
+
});
|
|
1475
|
+
}
|
|
1476
|
+
var bt = O.forwardRef(function({ onSubmit: o, placeholder: c = "Type a message...", disabled: f = !1, content: p = "", variant: m = "compact", enterBehavior: h = "send", maxLength: g, charCountDisplay: v = "near-limit", mentions: T, onMentionSearch: E, onMentionSelect: ie, onFileUpload: de, onImageUpload: fe, slashCommands: D, onVoiceRecord: k, onTranscribe: pe, maxDuration: A, replyTo: j, onTyping: me, onEmpty: ge, isStreaming: P = !1, onCancel: _e, leadingSlot: ve, trailingSlot: ye, disclaimer: xe, toolbar: Se = !0, sendOptions: Ce, onSchedule: F, actionButton: we, emojiSet: I = "native", className: Te, ...Oe }, ke) {
|
|
1477
|
+
let [L, R] = O.useState("idle"), [z, Fe] = O.useState(!1), [B, Ie] = O.useState(!1), [V, Le] = O.useState(null), [Be, Ve] = O.useState(!1), [He, Ue] = O.useState(!1), [Ke, Je] = O.useState(0), H = O.useRef(null), Xe = O.useRef(null);
|
|
1478
|
+
O.useEffect(() => {
|
|
1479
|
+
if (!B || !H.current || !Xe.current) return;
|
|
1480
|
+
let i = H.current, a = Xe.current, o = () => {
|
|
1481
|
+
e(i, a, {
|
|
1482
|
+
placement: "top-end",
|
|
1483
|
+
middleware: [
|
|
1484
|
+
r(8),
|
|
1485
|
+
t(),
|
|
1486
|
+
n({ padding: 8 })
|
|
1487
|
+
]
|
|
1488
|
+
}).then(({ x: e, y: t }) => {
|
|
1489
|
+
Object.assign(a.style, {
|
|
1490
|
+
left: `${e}px`,
|
|
1491
|
+
top: `${t}px`
|
|
1492
|
+
});
|
|
1493
|
+
});
|
|
1494
|
+
};
|
|
1495
|
+
return o(), window.addEventListener("scroll", o, !0), window.addEventListener("resize", o), () => {
|
|
1496
|
+
window.removeEventListener("scroll", o, !0), window.removeEventListener("resize", o);
|
|
1497
|
+
};
|
|
1498
|
+
}, [B]);
|
|
1499
|
+
let [U, W] = O.useState([]), [G, K] = O.useState(null), [q, Qe] = O.useState(!1), $e = O.useRef(null), et = O.useRef(null), tt = O.useRef(void 0), nt = O.useRef(void 0), rt = O.useRef(h);
|
|
1500
|
+
rt.current = h;
|
|
1501
|
+
let it = d(), J = mt[m], at = J.maxHeight, Y = pt({
|
|
1502
|
+
maxDuration: A,
|
|
1503
|
+
onComplete: async (e, t, n) => {
|
|
1504
|
+
if (k?.(e, t), pe) {
|
|
1505
|
+
let n = await pe(e, t);
|
|
1506
|
+
if (n != null) {
|
|
1507
|
+
X?.chain().focus().insertContent(n).run(), R("idle");
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
K({
|
|
1512
|
+
blob: e,
|
|
1513
|
+
duration: t,
|
|
1514
|
+
waveformData: n
|
|
1515
|
+
}), R("review");
|
|
1516
|
+
}
|
|
1517
|
+
}), ot = O.useCallback(() => {
|
|
1518
|
+
Y.start(), R("recording");
|
|
1519
|
+
}, [Y]), st = O.useCallback(() => {
|
|
1520
|
+
Y.stop();
|
|
1521
|
+
}, [Y]), ct = O.useCallback(() => {
|
|
1522
|
+
Y.cancel(), R("idle");
|
|
1523
|
+
}, [Y]), X = ee({
|
|
1524
|
+
immediatelyRender: !1,
|
|
1525
|
+
extensions: O.useMemo(() => {
|
|
1526
|
+
let e = [
|
|
1527
|
+
re.configure({
|
|
1528
|
+
heading: !1,
|
|
1529
|
+
horizontalRule: !1,
|
|
1530
|
+
codeBlock: !1,
|
|
1531
|
+
blockquote: !1,
|
|
1532
|
+
link: {
|
|
1533
|
+
openOnClick: !1,
|
|
1534
|
+
HTMLAttributes: { class: "text-accent-11 underline" }
|
|
1535
|
+
}
|
|
1536
|
+
}),
|
|
1537
|
+
w.configure({ placeholder: c }),
|
|
1538
|
+
ne.configure({ multicolor: !1 }),
|
|
1539
|
+
C,
|
|
1540
|
+
y.configure({ limit: g || void 0 }),
|
|
1541
|
+
ce,
|
|
1542
|
+
le,
|
|
1543
|
+
se(I),
|
|
1544
|
+
x.create({
|
|
1545
|
+
name: "enterToSend",
|
|
1546
|
+
addKeyboardShortcuts() {
|
|
1547
|
+
return {
|
|
1548
|
+
Enter: () => rt.current === "send" ? (nt.current?.(), !0) : !1,
|
|
1549
|
+
"Shift-Enter": () => rt.current === "send" ? (this.editor.commands.splitBlock(), !0) : !1,
|
|
1550
|
+
"Mod-Enter": () => (nt.current?.(), !0)
|
|
1551
|
+
};
|
|
1552
|
+
}
|
|
1553
|
+
})
|
|
1554
|
+
];
|
|
1555
|
+
return (T || E) && e.push(te.configure({
|
|
1556
|
+
HTMLAttributes: { class: "mention" },
|
|
1557
|
+
suggestion: {
|
|
1558
|
+
items: async ({ query: e }) => E ? await E(e) : T ? T.filter((t) => t.label.toLowerCase().includes(e.toLowerCase())).slice(0, 8) : [],
|
|
1559
|
+
render: ue(ie)
|
|
1560
|
+
}
|
|
1561
|
+
})), D && e.push(Re(D)), e;
|
|
1562
|
+
}, [
|
|
1563
|
+
c,
|
|
1564
|
+
g,
|
|
1565
|
+
I,
|
|
1566
|
+
!!T,
|
|
1567
|
+
!!E,
|
|
1568
|
+
!!D
|
|
1569
|
+
]),
|
|
1570
|
+
content: p || void 0,
|
|
1571
|
+
editable: !f,
|
|
1572
|
+
editorProps: {
|
|
1573
|
+
attributes: { class: ht },
|
|
1574
|
+
handlePaste: (e, t) => {
|
|
1575
|
+
let n = Array.from(t.clipboardData?.files ?? []);
|
|
1576
|
+
return n.length > 0 ? (n.forEach(Z), !0) : !1;
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
}), ut = O.useCallback(() => {
|
|
1580
|
+
if (!X) return;
|
|
1581
|
+
let e = !X.isEmpty, t = U.length > 0, n = !!G;
|
|
1582
|
+
if (!e && !t && !n || P) return;
|
|
1583
|
+
let r = {
|
|
1584
|
+
html: e ? X.getHTML() : "",
|
|
1585
|
+
plainText: e ? X.getText() : ""
|
|
1586
|
+
};
|
|
1587
|
+
t && (r.attachments = U.filter((e) => !e.uploading && e.url).map((e) => ({
|
|
1588
|
+
url: e.url,
|
|
1589
|
+
name: e.name,
|
|
1590
|
+
size: e.size,
|
|
1591
|
+
type: e.type
|
|
1592
|
+
}))), n && (r.voiceNote = {
|
|
1593
|
+
blob: G.blob,
|
|
1594
|
+
duration: G.duration
|
|
1595
|
+
}), V && F ? F(r, V) : o(r), X.commands.clearContent(), W([]), K(null), Le(null), R("idle");
|
|
1596
|
+
}, [
|
|
1597
|
+
X,
|
|
1598
|
+
U,
|
|
1599
|
+
G,
|
|
1600
|
+
P,
|
|
1601
|
+
o,
|
|
1602
|
+
F,
|
|
1603
|
+
V
|
|
1604
|
+
]);
|
|
1605
|
+
nt.current = ut, O.useEffect(() => {
|
|
1606
|
+
if (!X || !me) return;
|
|
1607
|
+
let e = () => {
|
|
1608
|
+
me(!0), clearTimeout(tt.current), tt.current = setTimeout(() => me(!1), 2e3);
|
|
1609
|
+
};
|
|
1610
|
+
return X.on("update", e), () => {
|
|
1611
|
+
X.off("update", e), clearTimeout(tt.current);
|
|
1612
|
+
};
|
|
1613
|
+
}, [X, me]), O.useEffect(() => {
|
|
1614
|
+
if (!X || !ge) return;
|
|
1615
|
+
let e = () => {
|
|
1616
|
+
ge(X.isEmpty);
|
|
1617
|
+
};
|
|
1618
|
+
return X.on("update", e), e(), () => {
|
|
1619
|
+
X.off("update", e);
|
|
1620
|
+
};
|
|
1621
|
+
}, [X, ge]);
|
|
1622
|
+
let Z = O.useCallback(async (e) => {
|
|
1623
|
+
let t = Math.random().toString(36).slice(2), n = e.type.startsWith("image/");
|
|
1624
|
+
W((r) => [...r, {
|
|
1625
|
+
id: t,
|
|
1626
|
+
name: e.name,
|
|
1627
|
+
size: e.size,
|
|
1628
|
+
type: n ? "image" : "file",
|
|
1629
|
+
uploading: !0
|
|
1630
|
+
}]);
|
|
1631
|
+
try {
|
|
1632
|
+
if (n && fe) {
|
|
1633
|
+
let n = await fe(e);
|
|
1634
|
+
W((e) => e.map((e) => e.id === t ? {
|
|
1635
|
+
...e,
|
|
1636
|
+
url: n,
|
|
1637
|
+
uploading: !1
|
|
1638
|
+
} : e));
|
|
1639
|
+
} else if (de) {
|
|
1640
|
+
let n = await de(e);
|
|
1641
|
+
W((e) => e.map((e) => e.id === t ? {
|
|
1642
|
+
...e,
|
|
1643
|
+
url: n.url,
|
|
1644
|
+
name: n.name,
|
|
1645
|
+
size: n.size,
|
|
1646
|
+
uploading: !1
|
|
1647
|
+
} : e));
|
|
1648
|
+
} else if (n) {
|
|
1649
|
+
let n = URL.createObjectURL(e);
|
|
1650
|
+
W((e) => e.map((e) => e.id === t ? {
|
|
1651
|
+
...e,
|
|
1652
|
+
url: n,
|
|
1653
|
+
uploading: !1
|
|
1654
|
+
} : e));
|
|
1655
|
+
} else W((e) => e.filter((e) => e.id !== t));
|
|
1656
|
+
} catch {
|
|
1657
|
+
W((e) => e.filter((e) => e.id !== t));
|
|
1658
|
+
}
|
|
1659
|
+
}, [de, fe]), ft = O.useCallback((e) => {
|
|
1660
|
+
W((t) => t.filter((t) => t.id !== e));
|
|
1661
|
+
}, []), _t = O.useCallback((e) => {
|
|
1662
|
+
e.preventDefault(), Qe(!1), Array.from(e.dataTransfer.files).forEach(Z);
|
|
1663
|
+
}, [Z]), Q = O.useCallback((e) => {
|
|
1664
|
+
Array.from(e.target.files || []).forEach(Z), e.target.value = "";
|
|
1665
|
+
}, [Z]), bt = O.useCallback(() => {
|
|
1666
|
+
K(null), R("idle");
|
|
1667
|
+
}, []), xt = S({
|
|
1668
|
+
editor: X,
|
|
1669
|
+
selector: ({ editor: e }) => e ? { editorIsEmpty: e.isEmpty } : null
|
|
1670
|
+
})?.editorIsEmpty ?? !0;
|
|
1671
|
+
O.useEffect(() => {
|
|
1672
|
+
if (!X) return;
|
|
1673
|
+
let e = () => {
|
|
1674
|
+
Je(X.state.doc.textBetween(0, X.state.doc.content.size, void 0, " ").length);
|
|
1675
|
+
};
|
|
1676
|
+
return e(), X.on("update", e), () => {
|
|
1677
|
+
X.off("update", e);
|
|
1678
|
+
};
|
|
1679
|
+
}, [X]);
|
|
1680
|
+
let St = !xt || U.length > 0 || !!G, Ct = z || L === "review" || m === "expanded", $ = "icon-md";
|
|
1681
|
+
return /* @__PURE__ */ N("div", {
|
|
1682
|
+
ref: ke,
|
|
1683
|
+
className: s("border-t border-surface-border-subtle px-ds-05 py-ds-04", "flex items-center gap-ds-03", Te),
|
|
1684
|
+
...Oe,
|
|
1685
|
+
children: [
|
|
1686
|
+
we !== !1 && (we ?? (de || fe ? /* @__PURE__ */ M(u, {
|
|
1687
|
+
variant: "solid",
|
|
1688
|
+
size: "icon-md",
|
|
1689
|
+
onClick: () => $e.current?.click(),
|
|
1690
|
+
title: "Attach",
|
|
1691
|
+
"aria-label": "Attach file",
|
|
1692
|
+
className: "shrink-0",
|
|
1693
|
+
children: /* @__PURE__ */ M(l, {
|
|
1694
|
+
icon: Ae,
|
|
1695
|
+
size: "md"
|
|
1696
|
+
})
|
|
1697
|
+
}) : null)),
|
|
1698
|
+
/* @__PURE__ */ N("div", {
|
|
1699
|
+
role: "region",
|
|
1700
|
+
"aria-label": "Message composer",
|
|
1701
|
+
className: s("flex-1 min-w-0 overflow-hidden rounded-ds-lg border border-surface-border-strong bg-surface-raised-hover", "transition-[color,background-color,border-color,box-shadow] duration-fast-02 ease-productive-standard", "hover:bg-surface-raised-active", "focus-within:ring-2 focus-within:ring-accent-9 focus-within:ring-offset-2 focus-within:border-accent-9", L === "recording" && "border-error-7/30", q && "border-dashed border-accent-7 bg-accent-2", f && "opacity-action-disabled cursor-not-allowed"),
|
|
1702
|
+
onFocus: () => Ue(!0),
|
|
1703
|
+
onBlur: (e) => {
|
|
1704
|
+
e.currentTarget.contains(e.relatedTarget) || Ue(!1);
|
|
1705
|
+
},
|
|
1706
|
+
onDragOver: (e) => {
|
|
1707
|
+
e.preventDefault(), Qe(!0);
|
|
1708
|
+
},
|
|
1709
|
+
onDragLeave: () => Qe(!1),
|
|
1710
|
+
onDrop: _t,
|
|
1711
|
+
children: [
|
|
1712
|
+
ve,
|
|
1713
|
+
/* @__PURE__ */ M(a, { children: j && /* @__PURE__ */ M(ze, {
|
|
1714
|
+
author: j.author,
|
|
1715
|
+
preview: j.preview,
|
|
1716
|
+
onDismiss: j.onDismiss
|
|
1717
|
+
}, "reply") }),
|
|
1718
|
+
/* @__PURE__ */ M(a, { children: V && /* @__PURE__ */ M(qe, {
|
|
1719
|
+
date: V,
|
|
1720
|
+
onEdit: () => Ve(!0),
|
|
1721
|
+
onClear: () => Le(null)
|
|
1722
|
+
}, "schedule") }),
|
|
1723
|
+
/* @__PURE__ */ M(a, { children: U.length > 0 && /* @__PURE__ */ M(Ye, {
|
|
1724
|
+
attachments: U,
|
|
1725
|
+
onRemoveAttachment: ft
|
|
1726
|
+
}, "attachments") }),
|
|
1727
|
+
J.toolbarPosition === "top" && X && /* @__PURE__ */ M("div", {
|
|
1728
|
+
className: s("grid transition-[grid-template-rows,opacity] duration-moderate-01 ease-productive-standard", z ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0 pointer-events-none"),
|
|
1729
|
+
children: /* @__PURE__ */ M("div", {
|
|
1730
|
+
className: "overflow-hidden",
|
|
1731
|
+
children: /* @__PURE__ */ M(lt, {
|
|
1732
|
+
editor: X,
|
|
1733
|
+
toolbar: Se,
|
|
1734
|
+
isMobile: !1,
|
|
1735
|
+
hasMentions: !!(T || E),
|
|
1736
|
+
hasSlashCommands: !!D,
|
|
1737
|
+
disabled: f
|
|
1738
|
+
})
|
|
1739
|
+
})
|
|
1740
|
+
}),
|
|
1741
|
+
/* @__PURE__ */ N("div", {
|
|
1742
|
+
className: "relative",
|
|
1743
|
+
children: [L === "recording" && /* @__PURE__ */ M(Ze, {
|
|
1744
|
+
duration: Y.duration,
|
|
1745
|
+
analyserNode: Y.analyserNode,
|
|
1746
|
+
maxDuration: A,
|
|
1747
|
+
onCancel: ct
|
|
1748
|
+
}), /* @__PURE__ */ N("div", {
|
|
1749
|
+
ref: et,
|
|
1750
|
+
className: s("flex items-center px-ds-04 py-ds-03 cursor-text [&_.tiptap]:w-full [&_.tiptap]:outline-hidden", L === "recording" && "invisible"),
|
|
1751
|
+
style: {
|
|
1752
|
+
minHeight: J.minHeight,
|
|
1753
|
+
maxHeight: at,
|
|
1754
|
+
overflowY: "auto"
|
|
1755
|
+
},
|
|
1756
|
+
onClick: () => X?.commands.focus(),
|
|
1757
|
+
children: [/* @__PURE__ */ M("div", {
|
|
1758
|
+
className: "flex-1 min-w-0",
|
|
1759
|
+
children: /* @__PURE__ */ M(b, { editor: X })
|
|
1760
|
+
}), X && L !== "recording" && /* @__PURE__ */ N("div", {
|
|
1761
|
+
className: "flex items-center gap-ds-01 shrink-0 ml-ds-03",
|
|
1762
|
+
children: [/* @__PURE__ */ M("button", {
|
|
1763
|
+
type: "button",
|
|
1764
|
+
onClick: () => Fe((e) => !e),
|
|
1765
|
+
title: z ? "Hide formatting" : "Show formatting",
|
|
1766
|
+
"aria-label": z ? "Hide formatting" : "Show formatting",
|
|
1767
|
+
"aria-pressed": z,
|
|
1768
|
+
className: s("inline-flex h-ds-xs-plus w-ds-xs-plus items-center justify-center rounded-ds-md touch-target", "transition-colors duration-fast-01 ease-productive-standard", "hover:bg-surface-raised-hover", z ? "bg-surface-raised-hover text-accent-11" : "text-surface-fg-subtle"),
|
|
1769
|
+
children: /* @__PURE__ */ M(l, {
|
|
1770
|
+
icon: Ne,
|
|
1771
|
+
size: "xs"
|
|
1772
|
+
})
|
|
1773
|
+
}), /* @__PURE__ */ N("div", {
|
|
1774
|
+
className: "relative",
|
|
1775
|
+
children: [/* @__PURE__ */ M("button", {
|
|
1776
|
+
ref: H,
|
|
1777
|
+
type: "button",
|
|
1778
|
+
onClick: () => Ie((e) => !e),
|
|
1779
|
+
title: "Emoji",
|
|
1780
|
+
"aria-label": "Emoji",
|
|
1781
|
+
className: s("inline-flex h-ds-xs-plus w-ds-xs-plus items-center justify-center rounded-ds-md touch-target transition-colors duration-fast-01", B ? "bg-surface-raised-hover text-accent-11" : "text-surface-fg-subtle hover:bg-surface-raised-hover hover:text-surface-fg"),
|
|
1782
|
+
children: /* @__PURE__ */ M(l, {
|
|
1783
|
+
icon: De,
|
|
1784
|
+
size: "xs"
|
|
1785
|
+
})
|
|
1786
|
+
}), B && he.createPortal(/* @__PURE__ */ M("div", {
|
|
1787
|
+
ref: Xe,
|
|
1788
|
+
className: "absolute z-popover",
|
|
1789
|
+
style: {
|
|
1790
|
+
top: 0,
|
|
1791
|
+
left: 0
|
|
1792
|
+
},
|
|
1793
|
+
children: /* @__PURE__ */ M(vt, {
|
|
1794
|
+
set: I,
|
|
1795
|
+
onSelect: async ({ id: e, native: t }) => {
|
|
1796
|
+
let n = ae(await oe(I), e);
|
|
1797
|
+
n ? X.chain().focus().insertContent({
|
|
1798
|
+
type: "emojiNode",
|
|
1799
|
+
attrs: {
|
|
1800
|
+
id: e,
|
|
1801
|
+
native: n.native,
|
|
1802
|
+
set: I,
|
|
1803
|
+
x: n.x,
|
|
1804
|
+
y: n.y
|
|
1805
|
+
}
|
|
1806
|
+
}).run() : X.chain().focus().insertContent(t).run(), Ie(!1);
|
|
1807
|
+
},
|
|
1808
|
+
onClose: () => Ie(!1)
|
|
1809
|
+
})
|
|
1810
|
+
}), document.body)]
|
|
1811
|
+
})]
|
|
1812
|
+
})]
|
|
1813
|
+
})]
|
|
1814
|
+
}),
|
|
1815
|
+
L === "review" && G && /* @__PURE__ */ N("div", {
|
|
1816
|
+
className: "flex items-center gap-ds-03 px-ds-04 py-ds-02b border-b border-surface-border",
|
|
1817
|
+
children: [/* @__PURE__ */ M(dt, {
|
|
1818
|
+
src: G.blob,
|
|
1819
|
+
duration: G.duration,
|
|
1820
|
+
waveformData: G.waveformData,
|
|
1821
|
+
className: "flex-1"
|
|
1822
|
+
}), /* @__PURE__ */ M(u, {
|
|
1823
|
+
variant: "ghost",
|
|
1824
|
+
size: "icon-sm",
|
|
1825
|
+
onClick: bt,
|
|
1826
|
+
"aria-label": "Discard voice note",
|
|
1827
|
+
title: "Discard voice note",
|
|
1828
|
+
className: "text-surface-fg-subtle hover:text-error-11",
|
|
1829
|
+
children: /* @__PURE__ */ M(l, {
|
|
1830
|
+
icon: Pe,
|
|
1831
|
+
size: "sm"
|
|
1832
|
+
})
|
|
1833
|
+
})]
|
|
1834
|
+
}),
|
|
1835
|
+
it && X && !xt && /* @__PURE__ */ M(yt, { editor: X }),
|
|
1836
|
+
J.toolbarPosition === "bottom" && X && /* @__PURE__ */ M("div", {
|
|
1837
|
+
className: s("grid transition-[grid-template-rows,opacity] duration-moderate-01 ease-productive-standard", Ct ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0 pointer-events-none"),
|
|
1838
|
+
children: /* @__PURE__ */ M("div", {
|
|
1839
|
+
className: "overflow-hidden",
|
|
1840
|
+
children: /* @__PURE__ */ M(lt, {
|
|
1841
|
+
editor: X,
|
|
1842
|
+
toolbar: Se,
|
|
1843
|
+
isMobile: it,
|
|
1844
|
+
hasMentions: !!(T || E),
|
|
1845
|
+
hasSlashCommands: !!D,
|
|
1846
|
+
disabled: f
|
|
1847
|
+
})
|
|
1848
|
+
})
|
|
1849
|
+
}),
|
|
1850
|
+
g && v !== "hidden" && (() => {
|
|
1851
|
+
let e = Ke / g;
|
|
1852
|
+
return v === "always" || v === "focus" && He || (v === "near-limit" || !v) && e >= .8 || e >= 1 ? /* @__PURE__ */ N("div", {
|
|
1853
|
+
className: s("flex justify-end px-ds-04 pb-ds-02 text-ds-xs tabular-nums transition-opacity duration-fast-01", e >= 1 ? "text-error-11 font-medium" : e >= .9 ? "text-warning-11" : "text-surface-fg-subtle"),
|
|
1854
|
+
children: [
|
|
1855
|
+
Ke,
|
|
1856
|
+
"/",
|
|
1857
|
+
g
|
|
1858
|
+
]
|
|
1859
|
+
}) : null;
|
|
1860
|
+
})(),
|
|
1861
|
+
ye,
|
|
1862
|
+
/* @__PURE__ */ M("input", {
|
|
1863
|
+
ref: $e,
|
|
1864
|
+
type: "file",
|
|
1865
|
+
multiple: !0,
|
|
1866
|
+
className: "hidden",
|
|
1867
|
+
onChange: Q
|
|
1868
|
+
})
|
|
1869
|
+
]
|
|
1870
|
+
}),
|
|
1871
|
+
/* @__PURE__ */ N("div", {
|
|
1872
|
+
className: "flex items-center gap-ds-02 shrink-0",
|
|
1873
|
+
children: [Ce && Ce.length > 0 && L !== "recording" && /* @__PURE__ */ M(gt, { options: Ce }), /* @__PURE__ */ N(a, {
|
|
1874
|
+
mode: "popLayout",
|
|
1875
|
+
initial: !1,
|
|
1876
|
+
children: [
|
|
1877
|
+
L === "recording" && /* @__PURE__ */ N(i.div, {
|
|
1878
|
+
initial: {
|
|
1879
|
+
scale: .8,
|
|
1880
|
+
opacity: 0
|
|
1881
|
+
},
|
|
1882
|
+
animate: {
|
|
1883
|
+
scale: 1,
|
|
1884
|
+
opacity: 1
|
|
1885
|
+
},
|
|
1886
|
+
exit: {
|
|
1887
|
+
scale: .8,
|
|
1888
|
+
opacity: 0
|
|
1889
|
+
},
|
|
1890
|
+
transition: { duration: .15 },
|
|
1891
|
+
className: "flex items-center gap-ds-02",
|
|
1892
|
+
children: [/* @__PURE__ */ M(u, {
|
|
1893
|
+
variant: "soft",
|
|
1894
|
+
size: $,
|
|
1895
|
+
onClick: ct,
|
|
1896
|
+
"aria-label": "Cancel recording",
|
|
1897
|
+
title: "Cancel recording",
|
|
1898
|
+
className: "text-surface-fg-subtle hover:text-error-11",
|
|
1899
|
+
children: /* @__PURE__ */ M(l, {
|
|
1900
|
+
icon: Pe,
|
|
1901
|
+
size: "md"
|
|
1902
|
+
})
|
|
1903
|
+
}), /* @__PURE__ */ M(u, {
|
|
1904
|
+
variant: "solid",
|
|
1905
|
+
size: $,
|
|
1906
|
+
color: "error",
|
|
1907
|
+
onClick: st,
|
|
1908
|
+
"aria-label": "Stop recording",
|
|
1909
|
+
title: "Stop recording",
|
|
1910
|
+
children: /* @__PURE__ */ M(l, {
|
|
1911
|
+
icon: Me,
|
|
1912
|
+
size: "md"
|
|
1913
|
+
})
|
|
1914
|
+
})]
|
|
1915
|
+
}, "recording"),
|
|
1916
|
+
P && L !== "recording" && /* @__PURE__ */ M(i.div, {
|
|
1917
|
+
initial: {
|
|
1918
|
+
scale: .8,
|
|
1919
|
+
opacity: 0
|
|
1920
|
+
},
|
|
1921
|
+
animate: {
|
|
1922
|
+
scale: 1,
|
|
1923
|
+
opacity: 1
|
|
1924
|
+
},
|
|
1925
|
+
exit: {
|
|
1926
|
+
scale: .8,
|
|
1927
|
+
opacity: 0
|
|
1928
|
+
},
|
|
1929
|
+
transition: { duration: .15 },
|
|
1930
|
+
children: /* @__PURE__ */ M(u, {
|
|
1931
|
+
variant: "solid",
|
|
1932
|
+
size: $,
|
|
1933
|
+
color: "error",
|
|
1934
|
+
onClick: _e,
|
|
1935
|
+
"aria-label": "Stop",
|
|
1936
|
+
title: "Stop",
|
|
1937
|
+
children: /* @__PURE__ */ M(l, {
|
|
1938
|
+
icon: Me,
|
|
1939
|
+
size: "md"
|
|
1940
|
+
})
|
|
1941
|
+
})
|
|
1942
|
+
}, "streaming"),
|
|
1943
|
+
!P && L !== "recording" && St && F && /* @__PURE__ */ M(i.div, {
|
|
1944
|
+
initial: {
|
|
1945
|
+
scale: .8,
|
|
1946
|
+
opacity: 0
|
|
1947
|
+
},
|
|
1948
|
+
animate: {
|
|
1949
|
+
scale: 1,
|
|
1950
|
+
opacity: 1
|
|
1951
|
+
},
|
|
1952
|
+
exit: {
|
|
1953
|
+
scale: .8,
|
|
1954
|
+
opacity: 0
|
|
1955
|
+
},
|
|
1956
|
+
transition: { duration: .15 },
|
|
1957
|
+
children: /* @__PURE__ */ M(_, {
|
|
1958
|
+
onClick: ut,
|
|
1959
|
+
disabled: f,
|
|
1960
|
+
"aria-label": V ? "Schedule send" : "Send",
|
|
1961
|
+
size: $,
|
|
1962
|
+
dropdownContent: /* @__PURE__ */ M(We, {
|
|
1963
|
+
onSchedule: (e) => Le(e),
|
|
1964
|
+
onClose: () => {},
|
|
1965
|
+
onOpenDialog: () => Ve(!0)
|
|
1966
|
+
}),
|
|
1967
|
+
children: /* @__PURE__ */ M(l, {
|
|
1968
|
+
icon: V ? be : je,
|
|
1969
|
+
size: "md"
|
|
1970
|
+
})
|
|
1971
|
+
})
|
|
1972
|
+
}, "split-send"),
|
|
1973
|
+
!P && L !== "recording" && St && !F && /* @__PURE__ */ M(i.div, {
|
|
1974
|
+
initial: {
|
|
1975
|
+
scale: .8,
|
|
1976
|
+
opacity: 0
|
|
1977
|
+
},
|
|
1978
|
+
animate: {
|
|
1979
|
+
scale: 1,
|
|
1980
|
+
opacity: 1
|
|
1981
|
+
},
|
|
1982
|
+
exit: {
|
|
1983
|
+
scale: .8,
|
|
1984
|
+
opacity: 0
|
|
1985
|
+
},
|
|
1986
|
+
transition: { duration: .15 },
|
|
1987
|
+
children: /* @__PURE__ */ M(u, {
|
|
1988
|
+
variant: "solid",
|
|
1989
|
+
size: $,
|
|
1990
|
+
onClick: ut,
|
|
1991
|
+
disabled: f,
|
|
1992
|
+
"aria-label": "Send",
|
|
1993
|
+
title: "Send",
|
|
1994
|
+
children: /* @__PURE__ */ M(l, {
|
|
1995
|
+
icon: je,
|
|
1996
|
+
size: "md"
|
|
1997
|
+
})
|
|
1998
|
+
})
|
|
1999
|
+
}, "send"),
|
|
2000
|
+
!P && L !== "recording" && !St && k && /* @__PURE__ */ M(i.div, {
|
|
2001
|
+
initial: {
|
|
2002
|
+
scale: .8,
|
|
2003
|
+
opacity: 0
|
|
2004
|
+
},
|
|
2005
|
+
animate: {
|
|
2006
|
+
scale: 1,
|
|
2007
|
+
opacity: 1
|
|
2008
|
+
},
|
|
2009
|
+
exit: {
|
|
2010
|
+
scale: .8,
|
|
2011
|
+
opacity: 0
|
|
2012
|
+
},
|
|
2013
|
+
transition: { duration: .15 },
|
|
2014
|
+
children: /* @__PURE__ */ M(u, {
|
|
2015
|
+
variant: "soft",
|
|
2016
|
+
size: $,
|
|
2017
|
+
onClick: ot,
|
|
2018
|
+
"aria-label": "Record voice message",
|
|
2019
|
+
title: "Record voice message",
|
|
2020
|
+
children: /* @__PURE__ */ M(l, {
|
|
2021
|
+
icon: Ee,
|
|
2022
|
+
size: "md"
|
|
2023
|
+
})
|
|
2024
|
+
})
|
|
2025
|
+
}, "mic"),
|
|
2026
|
+
!P && L !== "recording" && !St && !k && /* @__PURE__ */ M(i.div, {
|
|
2027
|
+
initial: {
|
|
2028
|
+
scale: .8,
|
|
2029
|
+
opacity: 0
|
|
2030
|
+
},
|
|
2031
|
+
animate: {
|
|
2032
|
+
scale: 1,
|
|
2033
|
+
opacity: 1
|
|
2034
|
+
},
|
|
2035
|
+
exit: {
|
|
2036
|
+
scale: .8,
|
|
2037
|
+
opacity: 0
|
|
2038
|
+
},
|
|
2039
|
+
transition: { duration: .15 },
|
|
2040
|
+
children: /* @__PURE__ */ M(u, {
|
|
2041
|
+
variant: "solid",
|
|
2042
|
+
size: $,
|
|
2043
|
+
disabled: !0,
|
|
2044
|
+
"aria-label": "Send",
|
|
2045
|
+
title: "Send",
|
|
2046
|
+
children: /* @__PURE__ */ M(l, {
|
|
2047
|
+
icon: je,
|
|
2048
|
+
size: "md"
|
|
2049
|
+
})
|
|
2050
|
+
})
|
|
2051
|
+
}, "send-disabled")
|
|
2052
|
+
]
|
|
2053
|
+
})]
|
|
2054
|
+
}),
|
|
2055
|
+
xe && /* @__PURE__ */ M("p", {
|
|
2056
|
+
className: "mt-ds-02 text-center text-ds-xs text-surface-fg-subtle/50",
|
|
2057
|
+
children: xe
|
|
2058
|
+
}),
|
|
2059
|
+
F && /* @__PURE__ */ M(Ge, {
|
|
2060
|
+
open: Be,
|
|
2061
|
+
onOpenChange: Ve,
|
|
2062
|
+
onSchedule: (e) => Le(e),
|
|
2063
|
+
initialDate: V
|
|
2064
|
+
})
|
|
2065
|
+
]
|
|
2066
|
+
});
|
|
2067
|
+
});
|
|
2068
|
+
bt.displayName = "RichChatInput";
|
|
2069
|
+
//#endregion
|
|
2070
|
+
export { K as _, Qe as a, H as b, st as c, Y as d, ot as f, G as g, tt as h, at as i, nt as l, ct as m, pt as n, it as o, J as p, dt as r, rt as s, bt as t, $e as u, q as v, et as y };
|