@locusgraph/loop 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/README.md +2 -0
  2. package/dist/agent/pulse/gradient-label.js +86 -15
  3. package/dist/agent/pulse/marks/bars-mark.js +46 -10
  4. package/dist/agent/pulse/marks/glyph-mark.js +56 -11
  5. package/dist/agent/pulse/marks/locus-mark.js +63 -28
  6. package/dist/agent/pulse/marks/orb-mark.js +31 -8
  7. package/dist/agent/pulse/marks/spinner-mark.js +29 -1
  8. package/dist/agent/pulse/pulse.js +150 -35
  9. package/dist/agent/pulse/use-loop-animation.js +36 -17
  10. package/dist/agent/steps/step-icon.js +110 -24
  11. package/dist/agent/steps/steps.js +235 -25
  12. package/dist/agent/thinking/thinking.js +203 -23
  13. package/dist/agent/thinking/thought-duration.js +7 -9
  14. package/dist/agent/tool/json-block.js +38 -11
  15. package/dist/agent/tool/tool-status.js +51 -18
  16. package/dist/agent/tool/tool.js +184 -6
  17. package/dist/approval/inbox/inbox-row.d.ts +3 -2
  18. package/dist/approval/inbox/inbox-row.js +321 -7
  19. package/dist/approval/inbox/inbox-selection.js +7 -13
  20. package/dist/approval/inbox/inbox.d.ts +2 -1
  21. package/dist/approval/inbox/inbox.js +250 -18
  22. package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
  23. package/dist/approval/inbox/virtual-inbox-list.js +129 -0
  24. package/dist/approval/memory/memory-choices.js +27 -22
  25. package/dist/approval/memory/memory-review.js +242 -17
  26. package/dist/approval/memory/memory-row.js +215 -19
  27. package/dist/approval/plan/plan-review.js +279 -28
  28. package/dist/approval/plan/plan-step-row.js +194 -43
  29. package/dist/approval/plan/plan-steps.js +24 -23
  30. package/dist/approval/plan/question-choices.js +158 -39
  31. package/dist/approval/plan/question.d.ts +1 -1
  32. package/dist/approval/plan/question.js +223 -26
  33. package/dist/approval/run/run-bar.js +178 -22
  34. package/dist/approval/shared/decision-line.js +1 -1
  35. package/dist/approval/shared/risk-badge.js +47 -16
  36. package/dist/approval/shared/time.js +5 -8
  37. package/dist/approval/shared/use-focus-on-mount.js +23 -6
  38. package/dist/approval/spend/raise-cap-form.js +235 -17
  39. package/dist/approval/spend/spend-gate.js +239 -21
  40. package/dist/approval/spend/spend-math.js +7 -8
  41. package/dist/approval/spend/spend-meter.js +362 -34
  42. package/dist/approval/tool/approval.js +272 -27
  43. package/dist/approval/tool/args/args-editor.js +262 -26
  44. package/dist/approval/tool/args/args-field.js +259 -19
  45. package/dist/approval/tool/args/args-validation.js +38 -47
  46. package/dist/approval/tool/deny-form.js +130 -10
  47. package/dist/approval/tool/tool-inputs.js +127 -38
  48. package/dist/chat/chat/chat-item-spacing.d.ts +3 -0
  49. package/dist/chat/chat/chat-item-spacing.js +19 -0
  50. package/dist/chat/chat/chat.d.ts +2 -1
  51. package/dist/chat/chat/chat.js +181 -5
  52. package/dist/chat/chat/use-stick-to-bottom.js +123 -47
  53. package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
  54. package/dist/chat/chat/virtual-chat-items.js +153 -0
  55. package/dist/chat/composer/composer-actions.js +151 -16
  56. package/dist/chat/composer/composer.js +330 -32
  57. package/dist/chat/composer/use-auto-grow.js +24 -9
  58. package/dist/chat/files/file-meta.js +19 -19
  59. package/dist/chat/files/files.js +316 -28
  60. package/dist/chat/reply/fenced-code.js +45 -21
  61. package/dist/chat/reply/markdown-components.js +137 -17
  62. package/dist/chat/reply/reply.js +105 -10
  63. package/dist/chat/turn/group-parts.js +43 -29
  64. package/dist/chat/turn/turn.js +238 -30
  65. package/dist/cost/context.js +321 -23
  66. package/dist/cost/cost-steps.js +220 -14
  67. package/dist/cost/cost.js +521 -27
  68. package/dist/cost/model-picker.js +181 -6
  69. package/dist/cost/shared/context-breakdown.js +299 -10
  70. package/dist/cost/shared/meter-marks.js +107 -9
  71. package/dist/cost/shared/model-option-row.js +178 -21
  72. package/dist/cost/shared/step-cost-row.js +248 -20
  73. package/dist/cost/shared/usage-totals.js +22 -18
  74. package/dist/memory/cite.js +182 -11
  75. package/dist/memory/memorized.js +217 -11
  76. package/dist/memory/recall.js +296 -17
  77. package/dist/memory/shared/host-label.js +19 -22
  78. package/dist/memory/shared/source-mark.js +39 -3
  79. package/dist/memory/sources.js +255 -13
  80. package/dist/shared/decision-summary.js +133 -14
  81. package/dist/shared/panel-empty.js +78 -3
  82. package/dist/shared/panel.js +243 -13
  83. package/dist/shared/status-dot.js +38 -8
  84. package/dist/shared/virtual/use-list-virtualizer.d.ts +24 -0
  85. package/dist/shared/virtual/use-list-virtualizer.js +68 -0
  86. package/dist/thread/actions/action-button.js +65 -3
  87. package/dist/thread/actions/actions.js +184 -13
  88. package/dist/thread/actions/branch-switcher.js +102 -5
  89. package/dist/thread/canvas/canvas.js +205 -5
  90. package/dist/thread/canvas/version-switcher.js +149 -8
  91. package/dist/thread/code/code.js +186 -24
  92. package/dist/thread/code/copy-code-button.js +61 -13
  93. package/dist/thread/code/highlight.js +30 -29
  94. package/dist/thread/history/history-rows.d.ts +16 -0
  95. package/dist/thread/history/history-rows.js +23 -0
  96. package/dist/thread/history/history.d.ts +3 -2
  97. package/dist/thread/history/history.js +174 -5
  98. package/dist/thread/history/{history-row.d.ts → row/history-row.d.ts} +3 -2
  99. package/dist/thread/history/row/history-row.js +137 -0
  100. package/dist/thread/history/row/thread-item-menu.js +84 -0
  101. package/dist/thread/history/row/thread-title-editor.js +81 -0
  102. package/dist/thread/history/thread-groups.d.ts +1 -1
  103. package/dist/thread/history/thread-groups.js +40 -34
  104. package/dist/thread/history/virtual-history-list.d.ts +11 -0
  105. package/dist/thread/history/virtual-history-list.js +107 -0
  106. package/dist/thread/index.d.ts +1 -1
  107. package/dist/thread/starters/starters.js +92 -7
  108. package/dist/thread/use-copied.js +45 -15
  109. package/dist/types.js +1 -1
  110. package/package.json +6 -4
  111. package/dist/thread/history/history-row.js +0 -17
  112. package/dist/thread/history/thread-item-menu.js +0 -6
  113. package/dist/thread/history/thread-title-editor.js +0 -25
  114. /package/dist/thread/history/{thread-item-menu.d.ts → row/thread-item-menu.d.ts} +0 -0
  115. /package/dist/thread/history/{thread-title-editor.d.ts → row/thread-title-editor.d.ts} +0 -0
@@ -0,0 +1,153 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { cn } from "@locusgraph/components";
3
+ import { cloneElement, isValidElement, useEffect, useLayoutEffect } from "react";
4
+ import { rowOffsetStyle, useListVirtualizer, virtualRowClassName } from "../../shared/virtual/use-list-virtualizer.js";
5
+ import { gapBeforeItem, isPositionable } from "./chat-item-spacing.js";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const estimatedTurnHeightPx = 180;
8
+ function itemKey(item, index) {
9
+ return isValidElement(item) && item.key !== null ? item.key : index;
10
+ }
11
+ function withSetPosition(item, index, count) {
12
+ if (!isPositionable(item)) {
13
+ return item;
14
+ }
15
+ return cloneElement(item, {
16
+ "aria-posinset": index + 1,
17
+ "aria-setsize": count
18
+ });
19
+ }
20
+ export function VirtualChatItems(t0) {
21
+ const $ = _c(27);
22
+ const {
23
+ items,
24
+ viewportRef,
25
+ onScrollingChange
26
+ } = t0;
27
+ let t1;
28
+ if ($[0] !== viewportRef) {
29
+ t1 = () => viewportRef.current;
30
+ $[0] = viewportRef;
31
+ $[1] = t1;
32
+ } else {
33
+ t1 = $[1];
34
+ }
35
+ let t2;
36
+ if ($[2] !== items) {
37
+ t2 = index => itemKey(items[index], index);
38
+ $[2] = items;
39
+ $[3] = t2;
40
+ } else {
41
+ t2 = $[3];
42
+ }
43
+ let t3;
44
+ if ($[4] !== items.length || $[5] !== t1 || $[6] !== t2) {
45
+ t3 = {
46
+ count: items.length,
47
+ getScrollElement: t1,
48
+ estimateSize: _temp,
49
+ getItemKey: t2,
50
+ anchorTo: "end"
51
+ };
52
+ $[4] = items.length;
53
+ $[5] = t1;
54
+ $[6] = t2;
55
+ $[7] = t3;
56
+ } else {
57
+ t3 = $[7];
58
+ }
59
+ const {
60
+ virtualizer,
61
+ rows,
62
+ totalSize,
63
+ isScrolling,
64
+ itemProps
65
+ } = useListVirtualizer(t3);
66
+ let t4;
67
+ let t5;
68
+ if ($[8] !== virtualizer) {
69
+ t4 = () => {
70
+ virtualizer.scrollToEnd();
71
+ };
72
+ t5 = [virtualizer];
73
+ $[8] = virtualizer;
74
+ $[9] = t4;
75
+ $[10] = t5;
76
+ } else {
77
+ t4 = $[9];
78
+ t5 = $[10];
79
+ }
80
+ useLayoutEffect(t4, t5);
81
+ let t6;
82
+ let t7;
83
+ if ($[11] !== isScrolling || $[12] !== onScrollingChange) {
84
+ t6 = () => {
85
+ onScrollingChange(isScrolling);
86
+ };
87
+ t7 = [isScrolling, onScrollingChange];
88
+ $[11] = isScrolling;
89
+ $[12] = onScrollingChange;
90
+ $[13] = t6;
91
+ $[14] = t7;
92
+ } else {
93
+ t6 = $[13];
94
+ t7 = $[14];
95
+ }
96
+ useEffect(t6, t7);
97
+ let t8;
98
+ if ($[15] !== totalSize) {
99
+ t8 = {
100
+ height: totalSize
101
+ };
102
+ $[15] = totalSize;
103
+ $[16] = t8;
104
+ } else {
105
+ t8 = $[16];
106
+ }
107
+ let t9;
108
+ if ($[17] !== itemProps || $[18] !== items || $[19] !== rows) {
109
+ let t10;
110
+ if ($[21] !== itemProps || $[22] !== items) {
111
+ t10 = row => /*#__PURE__*/_jsx("div", {
112
+ "data-slot": "chat-item",
113
+ ...itemProps(row.index),
114
+ className: cn(virtualRowClassName, "flex flex-col"),
115
+ style: {
116
+ ...rowOffsetStyle(row.start),
117
+ paddingTop: gapBeforeItem(items, row.index)
118
+ },
119
+ children: withSetPosition(items[row.index], row.index, items.length)
120
+ }, row.key);
121
+ $[21] = itemProps;
122
+ $[22] = items;
123
+ $[23] = t10;
124
+ } else {
125
+ t10 = $[23];
126
+ }
127
+ t9 = rows.map(t10);
128
+ $[17] = itemProps;
129
+ $[18] = items;
130
+ $[19] = rows;
131
+ $[20] = t9;
132
+ } else {
133
+ t9 = $[20];
134
+ }
135
+ let t10;
136
+ if ($[24] !== t8 || $[25] !== t9) {
137
+ t10 = /*#__PURE__*/_jsx("div", {
138
+ "data-slot": "chat-virtual-list",
139
+ className: "relative w-full",
140
+ style: t8,
141
+ children: t9
142
+ });
143
+ $[24] = t8;
144
+ $[25] = t9;
145
+ $[26] = t10;
146
+ } else {
147
+ t10 = $[26];
148
+ }
149
+ return t10;
150
+ }
151
+ function _temp() {
152
+ return estimatedTurnHeightPx;
153
+ }
@@ -1,23 +1,158 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ArrowUp as ArrowUpIcon, Attachment as PaperclipIcon, StopFilledAlt as SquareIcon, } from "@carbon/icons-react";
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { ArrowUp as ArrowUpIcon, Attachment as PaperclipIcon, StopFilledAlt as SquareIcon } from "@carbon/icons-react";
3
3
  import { Button } from "@locusgraph/components";
4
4
  import { useRef } from "react";
5
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
5
6
  export function isComposerBusy(status) {
6
- return status === "submitting" || status === "streaming";
7
+ return status === "submitting" || status === "streaming";
7
8
  }
8
- export function ComposerSubmit({ status, canSend, onStop }) {
9
- if (isComposerBusy(status)) {
10
- return (_jsxs(Button, { type: "button", size: "sm", variant: "outline", "data-slot": "composer-stop", "aria-label": "Stop", disabled: !onStop, onClick: onStop, children: [_jsx(SquareIcon, { "aria-hidden": "true", className: "size-2.5 fill-current" }), "Stop"] }));
9
+ export function ComposerSubmit(t0) {
10
+ const $ = _c(7);
11
+ const {
12
+ status,
13
+ canSend,
14
+ onStop
15
+ } = t0;
16
+ if (isComposerBusy(status)) {
17
+ const t1 = !onStop;
18
+ let t2;
19
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
20
+ t2 = /*#__PURE__*/_jsx(SquareIcon, {
21
+ "aria-hidden": "true",
22
+ className: "size-2.5 fill-current"
23
+ });
24
+ $[0] = t2;
25
+ } else {
26
+ t2 = $[0];
11
27
  }
12
- return (_jsx(Button, { type: "submit", size: "icon-sm", "data-slot": "composer-send", "aria-label": "Send", disabled: !canSend, children: _jsx(ArrowUpIcon, { "aria-hidden": "true" }) }));
28
+ let t3;
29
+ if ($[1] !== onStop || $[2] !== t1) {
30
+ t3 = /*#__PURE__*/_jsxs(Button, {
31
+ type: "button",
32
+ size: "sm",
33
+ variant: "outline",
34
+ "data-slot": "composer-stop",
35
+ "aria-label": "Stop",
36
+ disabled: t1,
37
+ onClick: onStop,
38
+ children: [t2, "Stop"]
39
+ });
40
+ $[1] = onStop;
41
+ $[2] = t1;
42
+ $[3] = t3;
43
+ } else {
44
+ t3 = $[3];
45
+ }
46
+ return t3;
47
+ }
48
+ const t1 = !canSend;
49
+ let t2;
50
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
51
+ t2 = /*#__PURE__*/_jsx(ArrowUpIcon, {
52
+ "aria-hidden": "true"
53
+ });
54
+ $[4] = t2;
55
+ } else {
56
+ t2 = $[4];
57
+ }
58
+ let t3;
59
+ if ($[5] !== t1) {
60
+ t3 = /*#__PURE__*/_jsx(Button, {
61
+ type: "submit",
62
+ size: "icon-sm",
63
+ "data-slot": "composer-send",
64
+ "aria-label": "Send",
65
+ disabled: t1,
66
+ children: t2
67
+ });
68
+ $[5] = t1;
69
+ $[6] = t3;
70
+ } else {
71
+ t3 = $[6];
72
+ }
73
+ return t3;
13
74
  }
14
- export function ComposerAttachButton({ accept, disabled, onAttachFiles, }) {
15
- const inputRef = useRef(null);
16
- return (_jsxs(_Fragment, { children: [_jsx("input", { ref: inputRef, type: "file", multiple: true, hidden: true, accept: accept, tabIndex: -1, "aria-hidden": "true", onChange: (event) => {
17
- const picked = Array.from(event.currentTarget.files ?? []);
18
- event.currentTarget.value = "";
19
- if (picked.length > 0) {
20
- onAttachFiles(picked);
21
- }
22
- } }), _jsx(Button, { type: "button", size: "icon-sm", variant: "ghost", "data-slot": "composer-attach", "aria-label": "Attach files", className: "text-muted-foreground hover:text-foreground", disabled: disabled, onClick: () => inputRef.current?.click(), children: _jsx(PaperclipIcon, { "aria-hidden": "true" }) })] }));
75
+ export function ComposerAttachButton(t0) {
76
+ const $ = _c(12);
77
+ const {
78
+ accept,
79
+ disabled,
80
+ onAttachFiles
81
+ } = t0;
82
+ const inputRef = useRef(null);
83
+ let t1;
84
+ if ($[0] !== onAttachFiles) {
85
+ t1 = event => {
86
+ const picked = Array.from(event.currentTarget.files ?? []);
87
+ event.currentTarget.value = "";
88
+ if (picked.length > 0) {
89
+ onAttachFiles(picked);
90
+ }
91
+ };
92
+ $[0] = onAttachFiles;
93
+ $[1] = t1;
94
+ } else {
95
+ t1 = $[1];
96
+ }
97
+ let t2;
98
+ if ($[2] !== accept || $[3] !== t1) {
99
+ t2 = /*#__PURE__*/_jsx("input", {
100
+ ref: inputRef,
101
+ type: "file",
102
+ multiple: true,
103
+ hidden: true,
104
+ accept: accept,
105
+ tabIndex: -1,
106
+ "aria-hidden": "true",
107
+ onChange: t1
108
+ });
109
+ $[2] = accept;
110
+ $[3] = t1;
111
+ $[4] = t2;
112
+ } else {
113
+ t2 = $[4];
114
+ }
115
+ let t3;
116
+ let t4;
117
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
118
+ t3 = () => inputRef.current?.click();
119
+ t4 = /*#__PURE__*/_jsx(PaperclipIcon, {
120
+ "aria-hidden": "true"
121
+ });
122
+ $[5] = t3;
123
+ $[6] = t4;
124
+ } else {
125
+ t3 = $[5];
126
+ t4 = $[6];
127
+ }
128
+ let t5;
129
+ if ($[7] !== disabled) {
130
+ t5 = /*#__PURE__*/_jsx(Button, {
131
+ type: "button",
132
+ size: "icon-sm",
133
+ variant: "ghost",
134
+ "data-slot": "composer-attach",
135
+ "aria-label": "Attach files",
136
+ className: "text-muted-foreground hover:text-foreground",
137
+ disabled: disabled,
138
+ onClick: t3,
139
+ children: t4
140
+ });
141
+ $[7] = disabled;
142
+ $[8] = t5;
143
+ } else {
144
+ t5 = $[8];
145
+ }
146
+ let t6;
147
+ if ($[9] !== t2 || $[10] !== t5) {
148
+ t6 = /*#__PURE__*/_jsxs(_Fragment, {
149
+ children: [t2, t5]
150
+ });
151
+ $[9] = t2;
152
+ $[10] = t5;
153
+ $[11] = t6;
154
+ } else {
155
+ t6 = $[11];
156
+ }
157
+ return t6;
23
158
  }
@@ -1,42 +1,340 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+
3
+ import { c as _c } from "react/compiler-runtime";
3
4
  import { cn, Textarea } from "@locusgraph/components";
4
5
  import * as React from "react";
5
- import { ComposerAttachButton, ComposerSubmit, isComposerBusy, } from "./composer-actions.js";
6
+ import { ComposerAttachButton, ComposerSubmit, isComposerBusy } from "./composer-actions.js";
6
7
  import { useAutoGrow } from "./use-auto-grow.js";
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
9
  const noFiles = [];
8
10
  function isSendShortcut(event) {
9
- return event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing;
11
+ return event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing;
10
12
  }
11
- export function Composer({ onSubmit, onStop, status = "ready", disabled = false, value, defaultValue = "", onValueChange, placeholder = "Ask the agent…", label = "Message", files = noFiles, onAttachFiles, accept, attachments, modelSlot, errorMessage, className, ...props }) {
12
- const [uncontrolledText, setUncontrolledText] = React.useState(defaultValue);
13
- const text = value ?? uncontrolledText;
14
- const errorId = React.useId();
15
- const textareaRef = React.useRef(null);
16
- useAutoGrow(textareaRef, text);
17
- const isBusy = isComposerBusy(status);
18
- const canSend = !disabled && !isBusy && (text.trim().length > 0 || files.length > 0);
19
- const changeText = (next) => {
20
- if (value === undefined) {
21
- setUncontrolledText(next);
22
- }
23
- onValueChange?.(next);
13
+ export function Composer(t0) {
14
+ const $ = _c(84);
15
+ let accept;
16
+ let attachments;
17
+ let className;
18
+ let errorMessage;
19
+ let modelSlot;
20
+ let onAttachFiles;
21
+ let onStop;
22
+ let onSubmit;
23
+ let onValueChange;
24
+ let props;
25
+ let t1;
26
+ let t2;
27
+ let t3;
28
+ let t4;
29
+ let t5;
30
+ let t6;
31
+ let value;
32
+ if ($[0] !== t0) {
33
+ ({
34
+ onSubmit,
35
+ onStop,
36
+ status: t1,
37
+ disabled: t2,
38
+ value,
39
+ defaultValue: t3,
40
+ onValueChange,
41
+ placeholder: t4,
42
+ label: t5,
43
+ files: t6,
44
+ onAttachFiles,
45
+ accept,
46
+ attachments,
47
+ modelSlot,
48
+ errorMessage,
49
+ className,
50
+ ...props
51
+ } = t0);
52
+ $[0] = t0;
53
+ $[1] = accept;
54
+ $[2] = attachments;
55
+ $[3] = className;
56
+ $[4] = errorMessage;
57
+ $[5] = modelSlot;
58
+ $[6] = onAttachFiles;
59
+ $[7] = onStop;
60
+ $[8] = onSubmit;
61
+ $[9] = onValueChange;
62
+ $[10] = props;
63
+ $[11] = t1;
64
+ $[12] = t2;
65
+ $[13] = t3;
66
+ $[14] = t4;
67
+ $[15] = t5;
68
+ $[16] = t6;
69
+ $[17] = value;
70
+ } else {
71
+ accept = $[1];
72
+ attachments = $[2];
73
+ className = $[3];
74
+ errorMessage = $[4];
75
+ modelSlot = $[5];
76
+ onAttachFiles = $[6];
77
+ onStop = $[7];
78
+ onSubmit = $[8];
79
+ onValueChange = $[9];
80
+ props = $[10];
81
+ t1 = $[11];
82
+ t2 = $[12];
83
+ t3 = $[13];
84
+ t4 = $[14];
85
+ t5 = $[15];
86
+ t6 = $[16];
87
+ value = $[17];
88
+ }
89
+ const status = t1 === undefined ? "ready" : t1;
90
+ const disabled = t2 === undefined ? false : t2;
91
+ const defaultValue = t3 === undefined ? "" : t3;
92
+ const placeholder = t4 === undefined ? "Ask the agent\u2026" : t4;
93
+ const label = t5 === undefined ? "Message" : t5;
94
+ const files = t6 === undefined ? noFiles : t6;
95
+ const [uncontrolledText, setUncontrolledText] = React.useState(defaultValue);
96
+ const text = value ?? uncontrolledText;
97
+ const errorId = React.useId();
98
+ const textareaRef = React.useRef(null);
99
+ useAutoGrow(textareaRef, text);
100
+ let t7;
101
+ if ($[18] !== status) {
102
+ t7 = isComposerBusy(status);
103
+ $[18] = status;
104
+ $[19] = t7;
105
+ } else {
106
+ t7 = $[19];
107
+ }
108
+ const isBusy = t7;
109
+ let t8;
110
+ if ($[20] !== disabled || $[21] !== files || $[22] !== isBusy || $[23] !== text) {
111
+ t8 = !disabled && !isBusy && (text.trim().length > 0 || files.length > 0);
112
+ $[20] = disabled;
113
+ $[21] = files;
114
+ $[22] = isBusy;
115
+ $[23] = text;
116
+ $[24] = t8;
117
+ } else {
118
+ t8 = $[24];
119
+ }
120
+ const canSend = t8;
121
+ let t9;
122
+ if ($[25] !== onValueChange || $[26] !== value) {
123
+ t9 = next => {
124
+ if (value === undefined) {
125
+ setUncontrolledText(next);
126
+ }
127
+ onValueChange?.(next);
128
+ };
129
+ $[25] = onValueChange;
130
+ $[26] = value;
131
+ $[27] = t9;
132
+ } else {
133
+ t9 = $[27];
134
+ }
135
+ const changeText = t9;
136
+ let t10;
137
+ if ($[28] !== canSend || $[29] !== changeText || $[30] !== files || $[31] !== onSubmit || $[32] !== text) {
138
+ t10 = () => {
139
+ if (!canSend) {
140
+ return;
141
+ }
142
+ onSubmit(text.trim(), files);
143
+ changeText("");
144
+ };
145
+ $[28] = canSend;
146
+ $[29] = changeText;
147
+ $[30] = files;
148
+ $[31] = onSubmit;
149
+ $[32] = text;
150
+ $[33] = t10;
151
+ } else {
152
+ t10 = $[33];
153
+ }
154
+ const send = t10;
155
+ const showError = status === "error" && errorMessage;
156
+ const t11 = disabled || undefined;
157
+ const t12 = isBusy || undefined;
158
+ let t13;
159
+ if ($[34] !== className) {
160
+ t13 = cn("flex flex-col bg-card text-card-foreground ring-1 ring-border transition-shadow focus-within:ring-foreground/40 data-[status=error]:ring-destructive/60 data-disabled:opacity-60", className);
161
+ $[34] = className;
162
+ $[35] = t13;
163
+ } else {
164
+ t13 = $[35];
165
+ }
166
+ let t14;
167
+ if ($[36] !== send) {
168
+ t14 = event => {
169
+ event.preventDefault();
170
+ send();
24
171
  };
25
- const send = () => {
26
- if (!canSend) {
27
- return;
28
- }
29
- onSubmit(text.trim(), files);
30
- changeText("");
172
+ $[36] = send;
173
+ $[37] = t14;
174
+ } else {
175
+ t14 = $[37];
176
+ }
177
+ let t15;
178
+ if ($[38] !== attachments) {
179
+ t15 = attachments && /*#__PURE__*/_jsx("div", {
180
+ "data-slot": "composer-attachments",
181
+ className: "px-3 pt-3 empty:hidden",
182
+ children: attachments
183
+ });
184
+ $[38] = attachments;
185
+ $[39] = t15;
186
+ } else {
187
+ t15 = $[39];
188
+ }
189
+ const t16 = status === "error" || undefined;
190
+ const t17 = showError ? errorId : undefined;
191
+ let t18;
192
+ if ($[40] !== changeText) {
193
+ t18 = event_0 => changeText(event_0.currentTarget.value);
194
+ $[40] = changeText;
195
+ $[41] = t18;
196
+ } else {
197
+ t18 = $[41];
198
+ }
199
+ let t19;
200
+ if ($[42] !== send) {
201
+ t19 = event_1 => {
202
+ if (isSendShortcut(event_1)) {
203
+ event_1.preventDefault();
204
+ send();
205
+ }
31
206
  };
32
- const showError = status === "error" && errorMessage;
33
- return (_jsxs("form", { "data-slot": "composer", "data-status": status, "data-disabled": disabled || undefined, "aria-busy": isBusy || undefined, className: cn("flex flex-col bg-card text-card-foreground ring-1 ring-border transition-shadow focus-within:ring-foreground/40 data-[status=error]:ring-destructive/60 data-disabled:opacity-60", className), onSubmit: (event) => {
34
- event.preventDefault();
35
- send();
36
- }, ...props, children: [attachments && (_jsx("div", { "data-slot": "composer-attachments", className: "px-3 pt-3 empty:hidden", children: attachments })), _jsx(Textarea, { ref: textareaRef, "aria-label": label, "aria-invalid": status === "error" || undefined, "aria-describedby": showError ? errorId : undefined, placeholder: placeholder, disabled: disabled, value: text, rows: 1, onChange: (event) => changeText(event.currentTarget.value), onKeyDown: (event) => {
37
- if (isSendShortcut(event)) {
38
- event.preventDefault();
39
- send();
40
- }
41
- }, className: "max-h-48 min-h-14 resize-none border-0 bg-transparent px-4 pt-3.5 pb-1 text-sm leading-relaxed shadow-none placeholder:text-muted-foreground/80 focus-visible:ring-0 dark:bg-transparent" }), showError && (_jsx("p", { id: errorId, role: "alert", className: "px-4 pt-1 text-xs text-destructive", children: errorMessage })), _jsxs("div", { "data-slot": "composer-toolbar", className: "flex items-center gap-1 px-2.5 pt-1 pb-2.5", children: [onAttachFiles && (_jsx(ComposerAttachButton, { accept: accept, disabled: disabled || isBusy, onAttachFiles: onAttachFiles })), modelSlot && (_jsx("div", { "data-slot": "composer-model", className: cn("min-w-0", disabled && "pointer-events-none opacity-50"), children: modelSlot })), _jsx("div", { className: "ml-auto", children: _jsx(ComposerSubmit, { status: status, canSend: canSend, onStop: onStop }) })] })] }));
207
+ $[42] = send;
208
+ $[43] = t19;
209
+ } else {
210
+ t19 = $[43];
211
+ }
212
+ let t20;
213
+ if ($[44] !== disabled || $[45] !== label || $[46] !== placeholder || $[47] !== t16 || $[48] !== t17 || $[49] !== t18 || $[50] !== t19 || $[51] !== text) {
214
+ t20 = /*#__PURE__*/_jsx(Textarea, {
215
+ ref: textareaRef,
216
+ "aria-label": label,
217
+ "aria-invalid": t16,
218
+ "aria-describedby": t17,
219
+ placeholder: placeholder,
220
+ disabled: disabled,
221
+ value: text,
222
+ rows: 1,
223
+ onChange: t18,
224
+ onKeyDown: t19,
225
+ className: "max-h-48 min-h-14 resize-none border-0 bg-transparent px-4 pt-3.5 pb-1 text-sm leading-relaxed shadow-none placeholder:text-muted-foreground/80 focus-visible:ring-0 dark:bg-transparent"
226
+ });
227
+ $[44] = disabled;
228
+ $[45] = label;
229
+ $[46] = placeholder;
230
+ $[47] = t16;
231
+ $[48] = t17;
232
+ $[49] = t18;
233
+ $[50] = t19;
234
+ $[51] = text;
235
+ $[52] = t20;
236
+ } else {
237
+ t20 = $[52];
238
+ }
239
+ let t21;
240
+ if ($[53] !== errorId || $[54] !== errorMessage || $[55] !== showError) {
241
+ t21 = showError && /*#__PURE__*/_jsx("p", {
242
+ id: errorId,
243
+ role: "alert",
244
+ className: "px-4 pt-1 text-xs text-destructive",
245
+ children: errorMessage
246
+ });
247
+ $[53] = errorId;
248
+ $[54] = errorMessage;
249
+ $[55] = showError;
250
+ $[56] = t21;
251
+ } else {
252
+ t21 = $[56];
253
+ }
254
+ let t22;
255
+ if ($[57] !== accept || $[58] !== disabled || $[59] !== isBusy || $[60] !== onAttachFiles) {
256
+ t22 = onAttachFiles && /*#__PURE__*/_jsx(ComposerAttachButton, {
257
+ accept: accept,
258
+ disabled: disabled || isBusy,
259
+ onAttachFiles: onAttachFiles
260
+ });
261
+ $[57] = accept;
262
+ $[58] = disabled;
263
+ $[59] = isBusy;
264
+ $[60] = onAttachFiles;
265
+ $[61] = t22;
266
+ } else {
267
+ t22 = $[61];
268
+ }
269
+ let t23;
270
+ if ($[62] !== disabled || $[63] !== modelSlot) {
271
+ t23 = modelSlot && /*#__PURE__*/_jsx("div", {
272
+ "data-slot": "composer-model",
273
+ className: cn("min-w-0", disabled && "pointer-events-none opacity-50"),
274
+ children: modelSlot
275
+ });
276
+ $[62] = disabled;
277
+ $[63] = modelSlot;
278
+ $[64] = t23;
279
+ } else {
280
+ t23 = $[64];
281
+ }
282
+ let t24;
283
+ if ($[65] !== canSend || $[66] !== onStop || $[67] !== status) {
284
+ t24 = /*#__PURE__*/_jsx("div", {
285
+ className: "ml-auto",
286
+ children: /*#__PURE__*/_jsx(ComposerSubmit, {
287
+ status: status,
288
+ canSend: canSend,
289
+ onStop: onStop
290
+ })
291
+ });
292
+ $[65] = canSend;
293
+ $[66] = onStop;
294
+ $[67] = status;
295
+ $[68] = t24;
296
+ } else {
297
+ t24 = $[68];
298
+ }
299
+ let t25;
300
+ if ($[69] !== t22 || $[70] !== t23 || $[71] !== t24) {
301
+ t25 = /*#__PURE__*/_jsxs("div", {
302
+ "data-slot": "composer-toolbar",
303
+ className: "flex items-center gap-1 px-2.5 pt-1 pb-2.5",
304
+ children: [t22, t23, t24]
305
+ });
306
+ $[69] = t22;
307
+ $[70] = t23;
308
+ $[71] = t24;
309
+ $[72] = t25;
310
+ } else {
311
+ t25 = $[72];
312
+ }
313
+ let t26;
314
+ if ($[73] !== props || $[74] !== status || $[75] !== t11 || $[76] !== t12 || $[77] !== t13 || $[78] !== t14 || $[79] !== t15 || $[80] !== t20 || $[81] !== t21 || $[82] !== t25) {
315
+ t26 = /*#__PURE__*/_jsxs("form", {
316
+ "data-slot": "composer",
317
+ "data-status": status,
318
+ "data-disabled": t11,
319
+ "aria-busy": t12,
320
+ className: t13,
321
+ onSubmit: t14,
322
+ ...props,
323
+ children: [t15, t20, t21, t25]
324
+ });
325
+ $[73] = props;
326
+ $[74] = status;
327
+ $[75] = t11;
328
+ $[76] = t12;
329
+ $[77] = t13;
330
+ $[78] = t14;
331
+ $[79] = t15;
332
+ $[80] = t20;
333
+ $[81] = t21;
334
+ $[82] = t25;
335
+ $[83] = t26;
336
+ } else {
337
+ t26 = $[83];
338
+ }
339
+ return t26;
42
340
  }